diff options
author | bunnei <bunneidev@gmail.com> | 2014-08-15 02:01:02 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2014-08-19 03:26:20 +0200 |
commit | 10f25866e268756cc32e2e783b3377c34529f7e6 (patch) | |
tree | 92909d5c039a62e69fe2bc91d2a6e3c4de8b4f79 /src/core/hle/function_wrappers.h | |
parent | Merge pull request #57 from lioncash/str (diff) | |
download | yuzu-10f25866e268756cc32e2e783b3377c34529f7e6.tar yuzu-10f25866e268756cc32e2e783b3377c34529f7e6.tar.gz yuzu-10f25866e268756cc32e2e783b3377c34529f7e6.tar.bz2 yuzu-10f25866e268756cc32e2e783b3377c34529f7e6.tar.lz yuzu-10f25866e268756cc32e2e783b3377c34529f7e6.tar.xz yuzu-10f25866e268756cc32e2e783b3377c34529f7e6.tar.zst yuzu-10f25866e268756cc32e2e783b3377c34529f7e6.zip |
Diffstat (limited to 'src/core/hle/function_wrappers.h')
-rw-r--r-- | src/core/hle/function_wrappers.h | 60 |
1 files changed, 42 insertions, 18 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(¶m_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(¶m_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(¶m_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(¶m_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(¶m_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(¶m_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 |