summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2014-08-18 21:34:30 -0400
committerGravatar bunnei2014-08-18 21:34:30 -0400
commite179dceecfd379bd0aa400f85ebb873a43e63ee1 (patch)
tree92909d5c039a62e69fe2bc91d2a6e3c4de8b4f79 /src
parentMerge pull request #57 from lioncash/str (diff)
parentSVC: Added support for svc_GetSystemTick. (diff)
downloadyuzu-e179dceecfd379bd0aa400f85ebb873a43e63ee1.tar.gz
yuzu-e179dceecfd379bd0aa400f85ebb873a43e63ee1.tar.xz
yuzu-e179dceecfd379bd0aa400f85ebb873a43e63ee1.zip
Merge pull request #45 from bunnei/master
SVC: Added support for svc_GetSystemTick.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/function_wrappers.h60
-rw-r--r--src/core/hle/svc.cpp7
2 files changed, 48 insertions, 19 deletions
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h
index ea603a1bb..55eaf0621 100644
--- a/src/core/hle/function_wrappers.h
+++ b/src/core/hle/function_wrappers.h
@@ -11,24 +11,41 @@
11namespace HLE { 11namespace HLE {
12 12
13#define PARAM(n) Core::g_app_core->GetReg(n) 13#define PARAM(n) Core::g_app_core->GetReg(n)
14#define RETURN(n) Core::g_app_core->SetReg(0, n) 14
15/**
16 * HLE a function return from the current ARM11 userland process
17 * @param res Result to return
18 */
19static inline void FuncReturn(u32 res) {
20 Core::g_app_core->SetReg(0, res);
21}
22
23/**
24 * HLE a function return (64-bit) from the current ARM11 userland process
25 * @param res Result to return (64-bit)
26 * @todo Verify that this function is correct
27 */
28static inline void FuncReturn64(u64 res) {
29 Core::g_app_core->SetReg(0, (u32)(res & 0xFFFFFFFF));
30 Core::g_app_core->SetReg(1, (u32)((res >> 32) & 0xFFFFFFFF));
31}
15 32
16//////////////////////////////////////////////////////////////////////////////////////////////////// 33////////////////////////////////////////////////////////////////////////////////////////////////////
17// Function wrappers that return type s32 34// Function wrappers that return type s32
18 35
19template<s32 func(u32, u32, u32, u32)> void Wrap() { 36template<s32 func(u32, u32, u32, u32)> void Wrap() {
20 RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3))); 37 FuncReturn(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)));
21} 38}
22 39
23template<s32 func(u32, u32, u32, u32, u32)> void Wrap() { 40template<s32 func(u32, u32, u32, u32, u32)> void Wrap() {
24 RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4))); 41 FuncReturn(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)));
25} 42}
26 43
27template<s32 func(u32*, u32, u32, u32, u32, u32)> void Wrap(){ 44template<s32 func(u32*, u32, u32, u32, u32, u32)> void Wrap(){
28 u32 param_1 = 0; 45 u32 param_1 = 0;
29 u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); 46 u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
30 Core::g_app_core->SetReg(1, param_1); 47 Core::g_app_core->SetReg(1, param_1);
31 RETURN(retval); 48 FuncReturn(retval);
32} 49}
33 50
34template<s32 func(s32*, u32*, s32, bool, s64)> void Wrap() { 51template<s32 func(s32*, u32*, s32, bool, s64)> void Wrap() {
@@ -36,57 +53,57 @@ template<s32 func(s32*, u32*, s32, bool, s64)> void Wrap() {
36 s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2), 53 s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2),
37 (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0))); 54 (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0)));
38 Core::g_app_core->SetReg(1, (u32)param_1); 55 Core::g_app_core->SetReg(1, (u32)param_1);
39 RETURN(retval); 56 FuncReturn(retval);
40} 57}
41 58
42// TODO(bunnei): Is this correct? Probably not - Last parameter looks wrong for ArbitrateAddress 59// TODO(bunnei): Is this correct? Probably not - Last parameter looks wrong for ArbitrateAddress
43template<s32 func(u32, u32, u32, u32, s64)> void Wrap() { 60template<s32 func(u32, u32, u32, u32, s64)> void Wrap() {
44 RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), (((s64)PARAM(5) << 32) | PARAM(4)))); 61 FuncReturn(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), (((s64)PARAM(5) << 32) | PARAM(4))));
45} 62}
46 63
47template<s32 func(u32*)> void Wrap(){ 64template<s32 func(u32*)> void Wrap(){
48 u32 param_1 = 0; 65 u32 param_1 = 0;
49 u32 retval = func(&param_1); 66 u32 retval = func(&param_1);
50 Core::g_app_core->SetReg(1, param_1); 67 Core::g_app_core->SetReg(1, param_1);
51 RETURN(retval); 68 FuncReturn(retval);
52} 69}
53 70
54template<s32 func(u32, s64)> void Wrap() { 71template<s32 func(u32, s64)> void Wrap() {
55 RETURN(func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2)))); 72 FuncReturn(func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2))));
56} 73}
57 74
58template<s32 func(void*, void*, u32)> void Wrap(){ 75template<s32 func(void*, void*, u32)> void Wrap(){
59 RETURN(func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2))); 76 FuncReturn(func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2)));
60} 77}
61 78
62template<s32 func(s32*, u32)> void Wrap(){ 79template<s32 func(s32*, u32)> void Wrap(){
63 s32 param_1 = 0; 80 s32 param_1 = 0;
64 u32 retval = func(&param_1, PARAM(1)); 81 u32 retval = func(&param_1, PARAM(1));
65 Core::g_app_core->SetReg(1, param_1); 82 Core::g_app_core->SetReg(1, param_1);
66 RETURN(retval); 83 FuncReturn(retval);
67} 84}
68 85
69template<s32 func(u32, s32)> void Wrap() { 86template<s32 func(u32, s32)> void Wrap() {
70 RETURN(func(PARAM(0), (s32)PARAM(1))); 87 FuncReturn(func(PARAM(0), (s32)PARAM(1)));
71} 88}
72 89
73template<s32 func(u32*, u32)> void Wrap(){ 90template<s32 func(u32*, u32)> void Wrap(){
74 u32 param_1 = 0; 91 u32 param_1 = 0;
75 u32 retval = func(&param_1, PARAM(1)); 92 u32 retval = func(&param_1, PARAM(1));
76 Core::g_app_core->SetReg(1, param_1); 93 Core::g_app_core->SetReg(1, param_1);
77 RETURN(retval); 94 FuncReturn(retval);
78} 95}
79 96
80template<s32 func(u32)> void Wrap() { 97template<s32 func(u32)> void Wrap() {
81 RETURN(func(PARAM(0))); 98 FuncReturn(func(PARAM(0)));
82} 99}
83 100
84template<s32 func(void*)> void Wrap() { 101template<s32 func(void*)> void Wrap() {
85 RETURN(func(Memory::GetPointer(PARAM(0)))); 102 FuncReturn(func(Memory::GetPointer(PARAM(0))));
86} 103}
87 104
88template<s32 func(s64*, u32, void*, s32)> void Wrap(){ 105template<s32 func(s64*, u32, void*, s32)> void Wrap(){
89 RETURN(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)), 106 FuncReturn(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)),
90 (s32)PARAM(3))); 107 (s32)PARAM(3)));
91} 108}
92 109
@@ -94,14 +111,21 @@ template<s32 func(u32*, const char*)> void Wrap() {
94 u32 param_1 = 0; 111 u32 param_1 = 0;
95 u32 retval = func(&param_1, Memory::GetCharPointer(PARAM(1))); 112 u32 retval = func(&param_1, Memory::GetCharPointer(PARAM(1)));
96 Core::g_app_core->SetReg(1, param_1); 113 Core::g_app_core->SetReg(1, param_1);
97 RETURN(retval); 114 FuncReturn(retval);
98} 115}
99 116
100//////////////////////////////////////////////////////////////////////////////////////////////////// 117////////////////////////////////////////////////////////////////////////////////////////////////////
101// Function wrappers that return type u32 118// Function wrappers that return type u32
102 119
103template<u32 func()> void Wrap() { 120template<u32 func()> void Wrap() {
104 RETURN(func()); 121 FuncReturn(func());
122}
123
124////////////////////////////////////////////////////////////////////////////////////////////////////
125// Function wrappers that return type s64
126
127template<s64 func()> void Wrap() {
128 FuncReturn64(func());
105} 129}
106 130
107//////////////////////////////////////////////////////////////////////////////////////////////////// 131////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -116,6 +140,6 @@ template<void func(const char*)> void Wrap() {
116} 140}
117 141
118#undef PARAM 142#undef PARAM
119#undef RETURN 143#undef FuncReturn
120 144
121} // namespace HLE 145} // namespace HLE
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 8720bed31..4f5ad805e 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -330,6 +330,11 @@ void SleepThread(s64 nanoseconds) {
330 DEBUG_LOG(SVC, "called nanoseconds=%d", nanoseconds); 330 DEBUG_LOG(SVC, "called nanoseconds=%d", nanoseconds);
331} 331}
332 332
333/// This returns the total CPU ticks elapsed since the CPU was powered-on
334s64 GetSystemTick() {
335 return (s64)Core::g_app_core->GetTicks();
336}
337
333const HLE::FunctionDef SVC_Table[] = { 338const HLE::FunctionDef SVC_Table[] = {
334 {0x00, nullptr, "Unknown"}, 339 {0x00, nullptr, "Unknown"},
335 {0x01, HLE::Wrap<ControlMemory>, "ControlMemory"}, 340 {0x01, HLE::Wrap<ControlMemory>, "ControlMemory"},
@@ -371,7 +376,7 @@ const HLE::FunctionDef SVC_Table[] = {
371 {0x25, HLE::Wrap<WaitSynchronizationN>, "WaitSynchronizationN"}, 376 {0x25, HLE::Wrap<WaitSynchronizationN>, "WaitSynchronizationN"},
372 {0x26, nullptr, "SignalAndWait"}, 377 {0x26, nullptr, "SignalAndWait"},
373 {0x27, HLE::Wrap<DuplicateHandle>, "DuplicateHandle"}, 378 {0x27, HLE::Wrap<DuplicateHandle>, "DuplicateHandle"},
374 {0x28, nullptr, "GetSystemTick"}, 379 {0x28, HLE::Wrap<GetSystemTick>, "GetSystemTick"},
375 {0x29, nullptr, "GetHandleInfo"}, 380 {0x29, nullptr, "GetHandleInfo"},
376 {0x2A, nullptr, "GetSystemInfo"}, 381 {0x2A, nullptr, "GetSystemInfo"},
377 {0x2B, nullptr, "GetProcessInfo"}, 382 {0x2B, nullptr, "GetProcessInfo"},