summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 @@
namespace HLE {
#define PARAM(n) Core::g_app_core->GetReg(n)
-#define RETURN(n) Core::g_app_core->SetReg(0, n)
+
+/**
+ * HLE a function return from the current ARM11 userland process
+ * @param res Result to return
+ */
+static inline void FuncReturn(u32 res) {
+ Core::g_app_core->SetReg(0, res);
+}
+
+/**
+ * HLE a function return (64-bit) from the current ARM11 userland process
+ * @param res Result to return (64-bit)
+ * @todo Verify that this function is correct
+ */
+static inline void FuncReturn64(u64 res) {
+ Core::g_app_core->SetReg(0, (u32)(res & 0xFFFFFFFF));
+ Core::g_app_core->SetReg(1, (u32)((res >> 32) & 0xFFFFFFFF));
+}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type s32
template<s32 func(u32, u32, u32, u32)> void Wrap() {
- RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)));
+ FuncReturn(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)));
}
template<s32 func(u32, u32, u32, u32, u32)> void Wrap() {
- RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)));
+ FuncReturn(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)));
}
template<s32 func(u32*, u32, u32, u32, u32, u32)> void Wrap(){
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
Core::g_app_core->SetReg(1, param_1);
- RETURN(retval);
+ FuncReturn(retval);
}
template<s32 func(s32*, u32*, s32, bool, s64)> void Wrap() {
@@ -36,57 +53,57 @@ template<s32 func(s32*, u32*, s32, bool, s64)> void Wrap() {
s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2),
(PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0)));
Core::g_app_core->SetReg(1, (u32)param_1);
- RETURN(retval);
+ FuncReturn(retval);
}
// TODO(bunnei): Is this correct? Probably not - Last parameter looks wrong for ArbitrateAddress
template<s32 func(u32, u32, u32, u32, s64)> void Wrap() {
- RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), (((s64)PARAM(5) << 32) | PARAM(4))));
+ FuncReturn(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), (((s64)PARAM(5) << 32) | PARAM(4))));
}
template<s32 func(u32*)> void Wrap(){
u32 param_1 = 0;
u32 retval = func(&param_1);
Core::g_app_core->SetReg(1, param_1);
- RETURN(retval);
+ FuncReturn(retval);
}
template<s32 func(u32, s64)> void Wrap() {
- RETURN(func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2))));
+ FuncReturn(func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2))));
}
template<s32 func(void*, void*, u32)> void Wrap(){
- RETURN(func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2)));
+ FuncReturn(func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2)));
}
template<s32 func(s32*, u32)> void Wrap(){
s32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1));
Core::g_app_core->SetReg(1, param_1);
- RETURN(retval);
+ FuncReturn(retval);
}
template<s32 func(u32, s32)> void Wrap() {
- RETURN(func(PARAM(0), (s32)PARAM(1)));
+ FuncReturn(func(PARAM(0), (s32)PARAM(1)));
}
template<s32 func(u32*, u32)> void Wrap(){
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1));
Core::g_app_core->SetReg(1, param_1);
- RETURN(retval);
+ FuncReturn(retval);
}
template<s32 func(u32)> void Wrap() {
- RETURN(func(PARAM(0)));
+ FuncReturn(func(PARAM(0)));
}
template<s32 func(void*)> void Wrap() {
- RETURN(func(Memory::GetPointer(PARAM(0))));
+ FuncReturn(func(Memory::GetPointer(PARAM(0))));
}
template<s32 func(s64*, u32, void*, s32)> void Wrap(){
- RETURN(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)),
+ FuncReturn(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)),
(s32)PARAM(3)));
}
@@ -94,14 +111,21 @@ template<s32 func(u32*, const char*)> void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, Memory::GetCharPointer(PARAM(1)));
Core::g_app_core->SetReg(1, param_1);
- RETURN(retval);
+ FuncReturn(retval);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type u32
template<u32 func()> void Wrap() {
- RETURN(func());
+ FuncReturn(func());
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Function wrappers that return type s64
+
+template<s64 func()> void Wrap() {
+ FuncReturn64(func());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -116,6 +140,6 @@ template<void func(const char*)> void Wrap() {
}
#undef PARAM
-#undef RETURN
+#undef FuncReturn
} // 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) {
DEBUG_LOG(SVC, "called nanoseconds=%d", nanoseconds);
}
+/// This returns the total CPU ticks elapsed since the CPU was powered-on
+s64 GetSystemTick() {
+ return (s64)Core::g_app_core->GetTicks();
+}
+
const HLE::FunctionDef SVC_Table[] = {
{0x00, nullptr, "Unknown"},
{0x01, HLE::Wrap<ControlMemory>, "ControlMemory"},
@@ -371,7 +376,7 @@ const HLE::FunctionDef SVC_Table[] = {
{0x25, HLE::Wrap<WaitSynchronizationN>, "WaitSynchronizationN"},
{0x26, nullptr, "SignalAndWait"},
{0x27, HLE::Wrap<DuplicateHandle>, "DuplicateHandle"},
- {0x28, nullptr, "GetSystemTick"},
+ {0x28, HLE::Wrap<GetSystemTick>, "GetSystemTick"},
{0x29, nullptr, "GetHandleInfo"},
{0x2A, nullptr, "GetSystemInfo"},
{0x2B, nullptr, "GetProcessInfo"},