1
0
Fork 0

SVC: Renamed all function wrapper templates to Wrap, moved to HLE namespace.

This commit is contained in:
bunnei 2014-06-09 22:30:39 -04:00
parent b62ef4bbd2
commit 8957622d10
2 changed files with 145 additions and 157 deletions

View File

@ -8,29 +8,27 @@
#include "core/mem_map.h" #include "core/mem_map.h"
#include "core/hle/hle.h" #include "core/hle/hle.h"
namespace Wrap { namespace HLE {
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type s32 // Function wrappers that return type s32
namespace S32 { template<s32 func(u32, u32, u32, u32)> void Wrap() {
template<s32 func(u32, u32, u32, u32)> void U32_U32_U32_U32() {
RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3))); RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)));
} }
template<s32 func(u32, u32, u32, u32, u32)> void U32_U32_U32_U32_U32() { template<s32 func(u32, u32, u32, u32, u32)> void Wrap() {
RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4))); RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)));
} }
template<s32 func(u32*, u32, u32, u32, u32, u32)> void U32P_U32_U32_U32_U32_U32(){ template<s32 func(u32*, u32, u32, u32, u32, u32)> void Wrap(){
u32 param_1 = 0; u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
Core::g_app_core->SetReg(1, param_1); Core::g_app_core->SetReg(1, param_1);
RETURN(retval); RETURN(retval);
} }
template<s32 func(s32*, u32*, s32, bool, s64)> void S32P_U32P_S32_Bool_S64() { template<s32 func(s32*, u32*, s32, bool, s64)> void Wrap() {
s32 param_1 = 0; s32 param_1 = 0;
s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2), s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2),
(PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0))); (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0)));
@ -39,82 +37,72 @@ template<s32 func(s32*, u32*, s32, bool, s64)> void S32P_U32P_S32_Bool_S64() {
} }
// TODO(bunnei): Is this correct? Probably not // TODO(bunnei): Is this correct? Probably not
template<s32 func(u32, u32, u32, u32, s64)> void U32_U32_U32_U32_S64() { template<s32 func(u32, u32, u32, u32, s64)> void Wrap() {
RETURN(func(PARAM(5), PARAM(1), PARAM(2), PARAM(3), (((s64)PARAM(4) << 32) | PARAM(0)))); RETURN(func(PARAM(5), PARAM(1), PARAM(2), PARAM(3), (((s64)PARAM(4) << 32) | PARAM(0))));
} }
template<s32 func(u32, s64)> void U32_S64() { template<s32 func(u32, s64)> void Wrap() {
RETURN(func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2)))); RETURN(func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2))));
} }
template<s32 func(void*, void*, u32)> void VoidP_VoidP_U32(){ template<s32 func(void*, void*, u32)> void Wrap(){
RETURN(func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2))); RETURN(func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2)));
} }
template<s32 func(s32*, u32)> void S32P_U32(){ template<s32 func(s32*, u32)> void Wrap(){
s32 param_1 = 0; s32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1)); u32 retval = func(&param_1, PARAM(1));
Core::g_app_core->SetReg(1, param_1); Core::g_app_core->SetReg(1, param_1);
RETURN(retval); RETURN(retval);
} }
template<s32 func(u32, s32)> void U32_S32() { template<s32 func(u32, s32)> void Wrap() {
RETURN(func(PARAM(0), (s32)PARAM(1))); RETURN(func(PARAM(0), (s32)PARAM(1)));
} }
template<s32 func(u32*, u32)> void U32P_U32(){ template<s32 func(u32*, u32)> void Wrap(){
u32 param_1 = 0; u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1)); u32 retval = func(&param_1, PARAM(1));
Core::g_app_core->SetReg(1, param_1); Core::g_app_core->SetReg(1, param_1);
RETURN(retval); RETURN(retval);
} }
template<s32 func(u32)> void U32() { template<s32 func(u32)> void Wrap() {
RETURN(func(PARAM(0))); RETURN(func(PARAM(0)));
} }
template<s32 func(void*)> void U32P() { template<s32 func(void*)> void Wrap() {
RETURN(func(Memory::GetPointer(PARAM(0)))); RETURN(func(Memory::GetPointer(PARAM(0))));
} }
template<s32 func(s64*, u32, void*, s32)> void S64P_U32_VoidP_S32(){ template<s32 func(s64*, u32, void*, s32)> void Wrap(){
RETURN(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)), RETURN(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)),
(s32)PARAM(3))); (s32)PARAM(3)));
} }
template<s32 func(u32*, const char*)> void U32P_CharP() { template<s32 func(u32*, const char*)> void Wrap() {
u32 param_1 = 0; u32 param_1 = 0;
u32 retval = func(&param_1, Memory::GetCharPointer(PARAM(1))); u32 retval = func(&param_1, Memory::GetCharPointer(PARAM(1)));
Core::g_app_core->SetReg(1, param_1); Core::g_app_core->SetReg(1, param_1);
RETURN(retval); RETURN(retval);
} }
} // namespace S32
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type u32 // Function wrappers that return type u32
namespace U32 { template<u32 func()> void Wrap() {
template<u32 func()> void Void() {
RETURN(func()); RETURN(func());
} }
} // namespace U32
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
/// Function wrappers that return type void /// Function wrappers that return type void
namespace Void { template<void func(s64)> void Wrap() {
template<void func(s64)> void S64() {
func(((s64)PARAM(1) << 32) | PARAM(0)); func(((s64)PARAM(1) << 32) | PARAM(0));
} }
template<void func(const char*)> void CharP() { template<void func(const char*)> void Wrap() {
func(Memory::GetCharPointer(PARAM(0))); func(Memory::GetCharPointer(PARAM(0)));
} }
} // namespace Void } // namespace HLE
} // namespace Wrap

View File

@ -333,67 +333,67 @@ void SleepThread(s64 nanoseconds) {
const HLE::FunctionDef SVC_Table[] = { const HLE::FunctionDef SVC_Table[] = {
{0x00, nullptr, "Unknown"}, {0x00, nullptr, "Unknown"},
{0x01, Wrap::S32::U32P_U32_U32_U32_U32_U32<ControlMemory>, "ControlMemory"}, {0x01, HLE::Wrap<ControlMemory>, "ControlMemory"},
{0x02, Wrap::S32::VoidP_VoidP_U32<QueryMemory>, "QueryMemory"}, {0x02, HLE::Wrap<QueryMemory>, "QueryMemory"},
{0x03, nullptr, "ExitProcess"}, {0x03, nullptr, "ExitProcess"},
{0x04, nullptr, "GetProcessAffinityMask"}, {0x04, nullptr, "GetProcessAffinityMask"},
{0x05, nullptr, "SetProcessAffinityMask"}, {0x05, nullptr, "SetProcessAffinityMask"},
{0x06, nullptr, "GetProcessIdealProcessor"}, {0x06, nullptr, "GetProcessIdealProcessor"},
{0x07, nullptr, "SetProcessIdealProcessor"}, {0x07, nullptr, "SetProcessIdealProcessor"},
{0x08, Wrap::S32::U32_U32_U32_U32_U32<CreateThread>, "CreateThread"}, {0x08, HLE::Wrap<CreateThread>, "CreateThread"},
{0x09, Wrap::U32::Void<ExitThread>, "ExitThread"}, {0x09, HLE::Wrap<ExitThread>, "ExitThread"},
{0x0A, Wrap::Void::S64<SleepThread>, "SleepThread"}, {0x0A, HLE::Wrap<SleepThread>, "SleepThread"},
{0x0B, Wrap::S32::S32P_U32<GetThreadPriority>, "GetThreadPriority"}, {0x0B, HLE::Wrap<GetThreadPriority>, "GetThreadPriority"},
{0x0C, Wrap::S32::U32_S32<SetThreadPriority>, "SetThreadPriority"}, {0x0C, HLE::Wrap<SetThreadPriority>, "SetThreadPriority"},
{0x0D, nullptr, "GetThreadAffinityMask"}, {0x0D, nullptr, "GetThreadAffinityMask"},
{0x0E, nullptr, "SetThreadAffinityMask"}, {0x0E, nullptr, "SetThreadAffinityMask"},
{0x0F, nullptr, "GetThreadIdealProcessor"}, {0x0F, nullptr, "GetThreadIdealProcessor"},
{0x10, nullptr, "SetThreadIdealProcessor"}, {0x10, nullptr, "SetThreadIdealProcessor"},
{0x11, nullptr, "GetCurrentProcessorNumber"}, {0x11, nullptr, "GetCurrentProcessorNumber"},
{0x12, nullptr, "Run"}, {0x12, nullptr, "Run"},
{0x13, Wrap::S32::U32P_U32<CreateMutex>, "CreateMutex"}, {0x13, HLE::Wrap<CreateMutex>, "CreateMutex"},
{0x14, Wrap::S32::U32<ReleaseMutex>, "ReleaseMutex"}, {0x14, HLE::Wrap<ReleaseMutex>, "ReleaseMutex"},
{0x15, nullptr, "CreateSemaphore"}, {0x15, nullptr, "CreateSemaphore"},
{0x16, nullptr, "ReleaseSemaphore"}, {0x16, nullptr, "ReleaseSemaphore"},
{0x17, Wrap::S32::U32P_U32<CreateEvent>, "CreateEvent"}, {0x17, HLE::Wrap<CreateEvent>, "CreateEvent"},
{0x18, Wrap::S32::U32<SignalEvent>, "SignalEvent"}, {0x18, HLE::Wrap<SignalEvent>, "SignalEvent"},
{0x19, Wrap::S32::U32<ClearEvent>, "ClearEvent"}, {0x19, HLE::Wrap<ClearEvent>, "ClearEvent"},
{0x1A, nullptr, "CreateTimer"}, {0x1A, nullptr, "CreateTimer"},
{0x1B, nullptr, "SetTimer"}, {0x1B, nullptr, "SetTimer"},
{0x1C, nullptr, "CancelTimer"}, {0x1C, nullptr, "CancelTimer"},
{0x1D, nullptr, "ClearTimer"}, {0x1D, nullptr, "ClearTimer"},
{0x1E, nullptr, "CreateMemoryBlock"}, {0x1E, nullptr, "CreateMemoryBlock"},
{0x1F, Wrap::S32::U32_U32_U32_U32<MapMemoryBlock>, "MapMemoryBlock"}, {0x1F, HLE::Wrap<MapMemoryBlock>, "MapMemoryBlock"},
{0x20, nullptr, "UnmapMemoryBlock"}, {0x20, nullptr, "UnmapMemoryBlock"},
{0x21, Wrap::S32::U32P<CreateAddressArbiter>, "CreateAddressArbiter"}, {0x21, HLE::Wrap<CreateAddressArbiter>, "CreateAddressArbiter"},
{0x22, Wrap::S32::U32_U32_U32_U32_S64<ArbitrateAddress>, "ArbitrateAddress"}, {0x22, HLE::Wrap<ArbitrateAddress>, "ArbitrateAddress"},
{0x23, Wrap::S32::U32<CloseHandle>, "CloseHandle"}, {0x23, HLE::Wrap<CloseHandle>, "CloseHandle"},
{0x24, Wrap::S32::U32_S64<WaitSynchronization1>, "WaitSynchronization1"}, {0x24, HLE::Wrap<WaitSynchronization1>, "WaitSynchronization1"},
{0x25, Wrap::S32::S32P_U32P_S32_Bool_S64<WaitSynchronizationN>, "WaitSynchronizationN"}, {0x25, HLE::Wrap<WaitSynchronizationN>, "WaitSynchronizationN"},
{0x26, nullptr, "SignalAndWait"}, {0x26, nullptr, "SignalAndWait"},
{0x27, Wrap::S32::U32P_U32<DuplicateHandle>, "DuplicateHandle"}, {0x27, HLE::Wrap<DuplicateHandle>, "DuplicateHandle"},
{0x28, nullptr, "GetSystemTick"}, {0x28, nullptr, "GetSystemTick"},
{0x29, nullptr, "GetHandleInfo"}, {0x29, nullptr, "GetHandleInfo"},
{0x2A, nullptr, "GetSystemInfo"}, {0x2A, nullptr, "GetSystemInfo"},
{0x2B, nullptr, "GetProcessInfo"}, {0x2B, nullptr, "GetProcessInfo"},
{0x2C, nullptr, "GetThreadInfo"}, {0x2C, nullptr, "GetThreadInfo"},
{0x2D, Wrap::S32::U32P_CharP<ConnectToPort>, "ConnectToPort"}, {0x2D, HLE::Wrap<ConnectToPort>, "ConnectToPort"},
{0x2E, nullptr, "SendSyncRequest1"}, {0x2E, nullptr, "SendSyncRequest1"},
{0x2F, nullptr, "SendSyncRequest2"}, {0x2F, nullptr, "SendSyncRequest2"},
{0x30, nullptr, "SendSyncRequest3"}, {0x30, nullptr, "SendSyncRequest3"},
{0x31, nullptr, "SendSyncRequest4"}, {0x31, nullptr, "SendSyncRequest4"},
{0x32, Wrap::S32::U32<SendSyncRequest>, "SendSyncRequest"}, {0x32, HLE::Wrap<SendSyncRequest>, "SendSyncRequest"},
{0x33, nullptr, "OpenProcess"}, {0x33, nullptr, "OpenProcess"},
{0x34, nullptr, "OpenThread"}, {0x34, nullptr, "OpenThread"},
{0x35, nullptr, "GetProcessId"}, {0x35, nullptr, "GetProcessId"},
{0x36, nullptr, "GetProcessIdOfThread"}, {0x36, nullptr, "GetProcessIdOfThread"},
{0x37, Wrap::S32::U32P_U32<GetThreadId>, "GetThreadId"}, {0x37, HLE::Wrap<GetThreadId>, "GetThreadId"},
{0x38, Wrap::S32::U32P_U32<GetResourceLimit>, "GetResourceLimit"}, {0x38, HLE::Wrap<GetResourceLimit>, "GetResourceLimit"},
{0x39, nullptr, "GetResourceLimitLimitValues"}, {0x39, nullptr, "GetResourceLimitLimitValues"},
{0x3A, Wrap::S32::S64P_U32_VoidP_S32<GetResourceLimitCurrentValues>, "GetResourceLimitCurrentValues"}, {0x3A, HLE::Wrap<GetResourceLimitCurrentValues>, "GetResourceLimitCurrentValues"},
{0x3B, nullptr, "GetThreadContext"}, {0x3B, nullptr, "GetThreadContext"},
{0x3C, nullptr, "Break"}, {0x3C, nullptr, "Break"},
{0x3D, Wrap::Void::CharP<OutputDebugString>, "OutputDebugString"}, {0x3D, HLE::Wrap<OutputDebugString>, "OutputDebugString"},
{0x3E, nullptr, "ControlPerformanceCounter"}, {0x3E, nullptr, "ControlPerformanceCounter"},
{0x3F, nullptr, "Unknown"}, {0x3F, nullptr, "Unknown"},
{0x40, nullptr, "Unknown"}, {0x40, nullptr, "Unknown"},