1
0
Fork 0
forked from suyu/suyu

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/hle/hle.h"
namespace Wrap {
namespace HLE {
////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type s32
namespace S32 {
template<s32 func(u32, u32, u32, u32)> void U32_U32_U32_U32() {
template<s32 func(u32, u32, u32, u32)> void Wrap() {
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)));
}
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 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
Core::g_app_core->SetReg(1, param_1);
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 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2),
(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
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))));
}
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))));
}
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)));
}
template<s32 func(s32*, u32)> void S32P_U32(){
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);
}
template<s32 func(u32, s32)> void U32_S32() {
template<s32 func(u32, s32)> void Wrap() {
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 retval = func(&param_1, PARAM(1));
Core::g_app_core->SetReg(1, param_1);
RETURN(retval);
}
template<s32 func(u32)> void U32() {
template<s32 func(u32)> void Wrap() {
RETURN(func(PARAM(0)));
}
template<s32 func(void*)> void U32P() {
template<s32 func(void*)> void Wrap() {
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)),
(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 retval = func(&param_1, Memory::GetCharPointer(PARAM(1)));
Core::g_app_core->SetReg(1, param_1);
RETURN(retval);
}
} // namespace S32
////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type u32
namespace U32 {
template<u32 func()> void Void() {
template<u32 func()> void Wrap() {
RETURN(func());
}
} // namespace U32
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Function wrappers that return type void
namespace Void {
template<void func(s64)> void S64() {
template<void func(s64)> void Wrap() {
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)));
}
} // namespace Void
} // namespace Wrap
} // namespace HLE

View file

@ -332,132 +332,132 @@ void SleepThread(s64 nanoseconds) {
}
const HLE::FunctionDef SVC_Table[] = {
{0x00, nullptr, "Unknown"},
{0x01, Wrap::S32::U32P_U32_U32_U32_U32_U32<ControlMemory>, "ControlMemory"},
{0x02, Wrap::S32::VoidP_VoidP_U32<QueryMemory>, "QueryMemory"},
{0x03, nullptr, "ExitProcess"},
{0x04, nullptr, "GetProcessAffinityMask"},
{0x05, nullptr, "SetProcessAffinityMask"},
{0x06, nullptr, "GetProcessIdealProcessor"},
{0x07, nullptr, "SetProcessIdealProcessor"},
{0x08, Wrap::S32::U32_U32_U32_U32_U32<CreateThread>, "CreateThread"},
{0x09, Wrap::U32::Void<ExitThread>, "ExitThread"},
{0x0A, Wrap::Void::S64<SleepThread>, "SleepThread"},
{0x0B, Wrap::S32::S32P_U32<GetThreadPriority>, "GetThreadPriority"},
{0x0C, Wrap::S32::U32_S32<SetThreadPriority>, "SetThreadPriority"},
{0x0D, nullptr, "GetThreadAffinityMask"},
{0x0E, nullptr, "SetThreadAffinityMask"},
{0x0F, nullptr, "GetThreadIdealProcessor"},
{0x10, nullptr, "SetThreadIdealProcessor"},
{0x11, nullptr, "GetCurrentProcessorNumber"},
{0x12, nullptr, "Run"},
{0x13, Wrap::S32::U32P_U32<CreateMutex>, "CreateMutex"},
{0x14, Wrap::S32::U32<ReleaseMutex>, "ReleaseMutex"},
{0x15, nullptr, "CreateSemaphore"},
{0x16, nullptr, "ReleaseSemaphore"},
{0x17, Wrap::S32::U32P_U32<CreateEvent>, "CreateEvent"},
{0x18, Wrap::S32::U32<SignalEvent>, "SignalEvent"},
{0x19, Wrap::S32::U32<ClearEvent>, "ClearEvent"},
{0x1A, nullptr, "CreateTimer"},
{0x1B, nullptr, "SetTimer"},
{0x1C, nullptr, "CancelTimer"},
{0x1D, nullptr, "ClearTimer"},
{0x1E, nullptr, "CreateMemoryBlock"},
{0x1F, Wrap::S32::U32_U32_U32_U32<MapMemoryBlock>, "MapMemoryBlock"},
{0x20, nullptr, "UnmapMemoryBlock"},
{0x21, Wrap::S32::U32P<CreateAddressArbiter>, "CreateAddressArbiter"},
{0x22, Wrap::S32::U32_U32_U32_U32_S64<ArbitrateAddress>, "ArbitrateAddress"},
{0x23, Wrap::S32::U32<CloseHandle>, "CloseHandle"},
{0x24, Wrap::S32::U32_S64<WaitSynchronization1>, "WaitSynchronization1"},
{0x25, Wrap::S32::S32P_U32P_S32_Bool_S64<WaitSynchronizationN>, "WaitSynchronizationN"},
{0x26, nullptr, "SignalAndWait"},
{0x27, Wrap::S32::U32P_U32<DuplicateHandle>, "DuplicateHandle"},
{0x28, nullptr, "GetSystemTick"},
{0x29, nullptr, "GetHandleInfo"},
{0x2A, nullptr, "GetSystemInfo"},
{0x2B, nullptr, "GetProcessInfo"},
{0x2C, nullptr, "GetThreadInfo"},
{0x2D, Wrap::S32::U32P_CharP<ConnectToPort>, "ConnectToPort"},
{0x2E, nullptr, "SendSyncRequest1"},
{0x2F, nullptr, "SendSyncRequest2"},
{0x30, nullptr, "SendSyncRequest3"},
{0x31, nullptr, "SendSyncRequest4"},
{0x32, Wrap::S32::U32<SendSyncRequest>, "SendSyncRequest"},
{0x33, nullptr, "OpenProcess"},
{0x34, nullptr, "OpenThread"},
{0x35, nullptr, "GetProcessId"},
{0x36, nullptr, "GetProcessIdOfThread"},
{0x37, Wrap::S32::U32P_U32<GetThreadId>, "GetThreadId"},
{0x38, Wrap::S32::U32P_U32<GetResourceLimit>, "GetResourceLimit"},
{0x39, nullptr, "GetResourceLimitLimitValues"},
{0x3A, Wrap::S32::S64P_U32_VoidP_S32<GetResourceLimitCurrentValues>, "GetResourceLimitCurrentValues"},
{0x3B, nullptr, "GetThreadContext"},
{0x3C, nullptr, "Break"},
{0x3D, Wrap::Void::CharP<OutputDebugString>, "OutputDebugString"},
{0x3E, nullptr, "ControlPerformanceCounter"},
{0x3F, nullptr, "Unknown"},
{0x40, nullptr, "Unknown"},
{0x41, nullptr, "Unknown"},
{0x42, nullptr, "Unknown"},
{0x43, nullptr, "Unknown"},
{0x44, nullptr, "Unknown"},
{0x45, nullptr, "Unknown"},
{0x46, nullptr, "Unknown"},
{0x47, nullptr, "CreatePort"},
{0x48, nullptr, "CreateSessionToPort"},
{0x49, nullptr, "CreateSession"},
{0x4A, nullptr, "AcceptSession"},
{0x4B, nullptr, "ReplyAndReceive1"},
{0x4C, nullptr, "ReplyAndReceive2"},
{0x4D, nullptr, "ReplyAndReceive3"},
{0x4E, nullptr, "ReplyAndReceive4"},
{0x4F, nullptr, "ReplyAndReceive"},
{0x50, nullptr, "BindInterrupt"},
{0x51, nullptr, "UnbindInterrupt"},
{0x52, nullptr, "InvalidateProcessDataCache"},
{0x53, nullptr, "StoreProcessDataCache"},
{0x54, nullptr, "FlushProcessDataCache"},
{0x55, nullptr, "StartInterProcessDma"},
{0x56, nullptr, "StopDma"},
{0x57, nullptr, "GetDmaState"},
{0x58, nullptr, "RestartDma"},
{0x59, nullptr, "Unknown"},
{0x5A, nullptr, "Unknown"},
{0x5B, nullptr, "Unknown"},
{0x5C, nullptr, "Unknown"},
{0x5D, nullptr, "Unknown"},
{0x5E, nullptr, "Unknown"},
{0x5F, nullptr, "Unknown"},
{0x60, nullptr, "DebugActiveProcess"},
{0x61, nullptr, "BreakDebugProcess"},
{0x62, nullptr, "TerminateDebugProcess"},
{0x63, nullptr, "GetProcessDebugEvent"},
{0x64, nullptr, "ContinueDebugEvent"},
{0x65, nullptr, "GetProcessList"},
{0x66, nullptr, "GetThreadList"},
{0x67, nullptr, "GetDebugThreadContext"},
{0x68, nullptr, "SetDebugThreadContext"},
{0x69, nullptr, "QueryDebugProcessMemory"},
{0x6A, nullptr, "ReadProcessMemory"},
{0x6B, nullptr, "WriteProcessMemory"},
{0x6C, nullptr, "SetHardwareBreakPoint"},
{0x6D, nullptr, "GetDebugThreadParam"},
{0x6E, nullptr, "Unknown"},
{0x6F, nullptr, "Unknown"},
{0x70, nullptr, "ControlProcessMemory"},
{0x71, nullptr, "MapProcessMemory"},
{0x72, nullptr, "UnmapProcessMemory"},
{0x73, nullptr, "Unknown"},
{0x74, nullptr, "Unknown"},
{0x75, nullptr, "Unknown"},
{0x76, nullptr, "TerminateProcess"},
{0x77, nullptr, "Unknown"},
{0x78, nullptr, "CreateResourceLimit"},
{0x79, nullptr, "Unknown"},
{0x7A, nullptr, "Unknown"},
{0x7B, nullptr, "Unknown"},
{0x7C, nullptr, "KernelSetState"},
{0x7D, nullptr, "QueryProcessMemory"},
{0x00, nullptr, "Unknown"},
{0x01, HLE::Wrap<ControlMemory>, "ControlMemory"},
{0x02, HLE::Wrap<QueryMemory>, "QueryMemory"},
{0x03, nullptr, "ExitProcess"},
{0x04, nullptr, "GetProcessAffinityMask"},
{0x05, nullptr, "SetProcessAffinityMask"},
{0x06, nullptr, "GetProcessIdealProcessor"},
{0x07, nullptr, "SetProcessIdealProcessor"},
{0x08, HLE::Wrap<CreateThread>, "CreateThread"},
{0x09, HLE::Wrap<ExitThread>, "ExitThread"},
{0x0A, HLE::Wrap<SleepThread>, "SleepThread"},
{0x0B, HLE::Wrap<GetThreadPriority>, "GetThreadPriority"},
{0x0C, HLE::Wrap<SetThreadPriority>, "SetThreadPriority"},
{0x0D, nullptr, "GetThreadAffinityMask"},
{0x0E, nullptr, "SetThreadAffinityMask"},
{0x0F, nullptr, "GetThreadIdealProcessor"},
{0x10, nullptr, "SetThreadIdealProcessor"},
{0x11, nullptr, "GetCurrentProcessorNumber"},
{0x12, nullptr, "Run"},
{0x13, HLE::Wrap<CreateMutex>, "CreateMutex"},
{0x14, HLE::Wrap<ReleaseMutex>, "ReleaseMutex"},
{0x15, nullptr, "CreateSemaphore"},
{0x16, nullptr, "ReleaseSemaphore"},
{0x17, HLE::Wrap<CreateEvent>, "CreateEvent"},
{0x18, HLE::Wrap<SignalEvent>, "SignalEvent"},
{0x19, HLE::Wrap<ClearEvent>, "ClearEvent"},
{0x1A, nullptr, "CreateTimer"},
{0x1B, nullptr, "SetTimer"},
{0x1C, nullptr, "CancelTimer"},
{0x1D, nullptr, "ClearTimer"},
{0x1E, nullptr, "CreateMemoryBlock"},
{0x1F, HLE::Wrap<MapMemoryBlock>, "MapMemoryBlock"},
{0x20, nullptr, "UnmapMemoryBlock"},
{0x21, HLE::Wrap<CreateAddressArbiter>, "CreateAddressArbiter"},
{0x22, HLE::Wrap<ArbitrateAddress>, "ArbitrateAddress"},
{0x23, HLE::Wrap<CloseHandle>, "CloseHandle"},
{0x24, HLE::Wrap<WaitSynchronization1>, "WaitSynchronization1"},
{0x25, HLE::Wrap<WaitSynchronizationN>, "WaitSynchronizationN"},
{0x26, nullptr, "SignalAndWait"},
{0x27, HLE::Wrap<DuplicateHandle>, "DuplicateHandle"},
{0x28, nullptr, "GetSystemTick"},
{0x29, nullptr, "GetHandleInfo"},
{0x2A, nullptr, "GetSystemInfo"},
{0x2B, nullptr, "GetProcessInfo"},
{0x2C, nullptr, "GetThreadInfo"},
{0x2D, HLE::Wrap<ConnectToPort>, "ConnectToPort"},
{0x2E, nullptr, "SendSyncRequest1"},
{0x2F, nullptr, "SendSyncRequest2"},
{0x30, nullptr, "SendSyncRequest3"},
{0x31, nullptr, "SendSyncRequest4"},
{0x32, HLE::Wrap<SendSyncRequest>, "SendSyncRequest"},
{0x33, nullptr, "OpenProcess"},
{0x34, nullptr, "OpenThread"},
{0x35, nullptr, "GetProcessId"},
{0x36, nullptr, "GetProcessIdOfThread"},
{0x37, HLE::Wrap<GetThreadId>, "GetThreadId"},
{0x38, HLE::Wrap<GetResourceLimit>, "GetResourceLimit"},
{0x39, nullptr, "GetResourceLimitLimitValues"},
{0x3A, HLE::Wrap<GetResourceLimitCurrentValues>, "GetResourceLimitCurrentValues"},
{0x3B, nullptr, "GetThreadContext"},
{0x3C, nullptr, "Break"},
{0x3D, HLE::Wrap<OutputDebugString>, "OutputDebugString"},
{0x3E, nullptr, "ControlPerformanceCounter"},
{0x3F, nullptr, "Unknown"},
{0x40, nullptr, "Unknown"},
{0x41, nullptr, "Unknown"},
{0x42, nullptr, "Unknown"},
{0x43, nullptr, "Unknown"},
{0x44, nullptr, "Unknown"},
{0x45, nullptr, "Unknown"},
{0x46, nullptr, "Unknown"},
{0x47, nullptr, "CreatePort"},
{0x48, nullptr, "CreateSessionToPort"},
{0x49, nullptr, "CreateSession"},
{0x4A, nullptr, "AcceptSession"},
{0x4B, nullptr, "ReplyAndReceive1"},
{0x4C, nullptr, "ReplyAndReceive2"},
{0x4D, nullptr, "ReplyAndReceive3"},
{0x4E, nullptr, "ReplyAndReceive4"},
{0x4F, nullptr, "ReplyAndReceive"},
{0x50, nullptr, "BindInterrupt"},
{0x51, nullptr, "UnbindInterrupt"},
{0x52, nullptr, "InvalidateProcessDataCache"},
{0x53, nullptr, "StoreProcessDataCache"},
{0x54, nullptr, "FlushProcessDataCache"},
{0x55, nullptr, "StartInterProcessDma"},
{0x56, nullptr, "StopDma"},
{0x57, nullptr, "GetDmaState"},
{0x58, nullptr, "RestartDma"},
{0x59, nullptr, "Unknown"},
{0x5A, nullptr, "Unknown"},
{0x5B, nullptr, "Unknown"},
{0x5C, nullptr, "Unknown"},
{0x5D, nullptr, "Unknown"},
{0x5E, nullptr, "Unknown"},
{0x5F, nullptr, "Unknown"},
{0x60, nullptr, "DebugActiveProcess"},
{0x61, nullptr, "BreakDebugProcess"},
{0x62, nullptr, "TerminateDebugProcess"},
{0x63, nullptr, "GetProcessDebugEvent"},
{0x64, nullptr, "ContinueDebugEvent"},
{0x65, nullptr, "GetProcessList"},
{0x66, nullptr, "GetThreadList"},
{0x67, nullptr, "GetDebugThreadContext"},
{0x68, nullptr, "SetDebugThreadContext"},
{0x69, nullptr, "QueryDebugProcessMemory"},
{0x6A, nullptr, "ReadProcessMemory"},
{0x6B, nullptr, "WriteProcessMemory"},
{0x6C, nullptr, "SetHardwareBreakPoint"},
{0x6D, nullptr, "GetDebugThreadParam"},
{0x6E, nullptr, "Unknown"},
{0x6F, nullptr, "Unknown"},
{0x70, nullptr, "ControlProcessMemory"},
{0x71, nullptr, "MapProcessMemory"},
{0x72, nullptr, "UnmapProcessMemory"},
{0x73, nullptr, "Unknown"},
{0x74, nullptr, "Unknown"},
{0x75, nullptr, "Unknown"},
{0x76, nullptr, "TerminateProcess"},
{0x77, nullptr, "Unknown"},
{0x78, nullptr, "CreateResourceLimit"},
{0x79, nullptr, "Unknown"},
{0x7A, nullptr, "Unknown"},
{0x7B, nullptr, "Unknown"},
{0x7C, nullptr, "KernelSetState"},
{0x7D, nullptr, "QueryProcessMemory"},
};
void Register() {