diff options
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r-- | src/core/hle/svc.cpp | 286 |
1 files changed, 138 insertions, 148 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 76c6a0771..d964d062e 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -34,9 +34,7 @@ enum MapMemoryPermission { }; /// Map application or GSP heap memory -Result ControlMemory(void* _out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { - u32* out_addr = (u32*)_out_addr; - +Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", operation, addr0, addr1, size, permissions); @@ -76,8 +74,7 @@ Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherper } /// Connect to an OS service given the port name, returns the handle to the port to out -Result ConnectToPort(void* _out, const char* port_name) { - Handle* out = (Handle*)_out; +Result ConnectToPort(Handle* out, const char* port_name) { Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); DEBUG_LOG(SVC, "called port_name=%s", port_name); @@ -136,11 +133,9 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) { } /// Wait for the given handles to synchronize, timeout after the specified nanoseconds -Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wait_all, +Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wait_all, s64 nano_seconds) { // TODO(bunnei): Do something with nano_seconds, currently ignoring this - s32* out = (s32*)_out; - Handle* handles = (Handle*)_handles; bool unlock_all = true; bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated @@ -148,7 +143,7 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa handle_count, (wait_all ? "true" : "false"), nano_seconds); // Iterate through each handle, synchronize kernel object - for (u32 i = 0; i < handle_count; i++) { + for (s32 i = 0; i < handle_count; i++) { bool wait = false; Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handles[i]); @@ -200,18 +195,17 @@ void OutputDebugString(const char* string) { } /// Get resource limit -Result GetResourceLimit(void* _resource_limit, Handle process) { +Result GetResourceLimit(Handle* resource_limit, Handle process) { // With regards to proceess values: // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for // the current KThread. - Handle* resource_limit = (Handle*)_resource_limit; *resource_limit = 0xDEADBEEF; ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process); return 0; } /// Get resource limit current values -Result GetResourceLimitCurrentValues(void* _values, Handle resource_limit, void* names, +Result GetResourceLimitCurrentValues(s64* values, Handle resource_limit, void* names, s32 name_count) { ERROR_LOG(SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%s, name_count=%d", resource_limit, names, name_count); @@ -255,8 +249,7 @@ u32 ExitThread() { } /// Gets the priority for the specified thread -Result GetThreadPriority(void* _priority, Handle handle) { - s32* priority = (s32*)_priority; +Result GetThreadPriority(s32* priority, Handle handle) { *priority = Kernel::GetThreadPriority(handle); return 0; } @@ -267,8 +260,7 @@ Result SetThreadPriority(Handle handle, s32 priority) { } /// Create a mutex -Result CreateMutex(void* _mutex, u32 initial_locked) { - Handle* mutex = (Handle*)_mutex; +Result CreateMutex(Handle* mutex, u32 initial_locked) { *mutex = Kernel::CreateMutex((initial_locked != 0)); DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X", initial_locked ? "true" : "false", *mutex); @@ -284,20 +276,19 @@ Result ReleaseMutex(Handle handle) { } /// Get current thread ID -Result GetThreadId(void* thread_id, u32 thread) { +Result GetThreadId(u32* thread_id, Handle thread) { ERROR_LOG(SVC, "(UNIMPLEMENTED) called thread=0x%08X", thread); return 0; } /// Query memory -Result QueryMemory(void *_info, void *_out, u32 addr) { +Result QueryMemory(void* info, void* out, u32 addr) { ERROR_LOG(SVC, "(UNIMPLEMENTED) called addr=0x%08X", addr); return 0; } /// Create an event -Result CreateEvent(void* _event, u32 reset_type) { - Handle* evt = (Handle*)_event; +Result CreateEvent(Handle* evt, u32 reset_type) { *evt = Kernel::CreateEvent((ResetType)reset_type); DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type, *evt); @@ -305,8 +296,7 @@ Result CreateEvent(void* _event, u32 reset_type) { } /// Duplicates a kernel handle -Result DuplicateHandle(void* _out, Handle handle) { - Handle* out = (Handle*)_out; +Result DuplicateHandle(Handle* out, Handle handle) { DEBUG_LOG(SVC, "called handle=0x%08X", handle); // Translate kernel handles -> real handles @@ -342,132 +332,132 @@ void SleepThread(s64 nanoseconds) { } const HLE::FunctionDef SVC_Table[] = { - {0x00, nullptr, "Unknown"}, - {0x01, WrapI_VUUUUU<ControlMemory>, "ControlMemory"}, - {0x02, WrapI_VVU<QueryMemory>, "QueryMemory"}, - {0x03, nullptr, "ExitProcess"}, - {0x04, nullptr, "GetProcessAffinityMask"}, - {0x05, nullptr, "SetProcessAffinityMask"}, - {0x06, nullptr, "GetProcessIdealProcessor"}, - {0x07, nullptr, "SetProcessIdealProcessor"}, - {0x08, WrapI_UUUUU<CreateThread>, "CreateThread"}, - {0x09, WrapU_V<ExitThread>, "ExitThread"}, - {0x0A, WrapV_S64<SleepThread>, "SleepThread"}, - {0x0B, WrapI_VU<GetThreadPriority>, "GetThreadPriority"}, - {0x0C, WrapI_UI<SetThreadPriority>, "SetThreadPriority"}, - {0x0D, nullptr, "GetThreadAffinityMask"}, - {0x0E, nullptr, "SetThreadAffinityMask"}, - {0x0F, nullptr, "GetThreadIdealProcessor"}, - {0x10, nullptr, "SetThreadIdealProcessor"}, - {0x11, nullptr, "GetCurrentProcessorNumber"}, - {0x12, nullptr, "Run"}, - {0x13, WrapI_VU<CreateMutex>, "CreateMutex"}, - {0x14, WrapI_U<ReleaseMutex>, "ReleaseMutex"}, - {0x15, nullptr, "CreateSemaphore"}, - {0x16, nullptr, "ReleaseSemaphore"}, - {0x17, WrapI_VU<CreateEvent>, "CreateEvent"}, - {0x18, WrapI_U<SignalEvent>, "SignalEvent"}, - {0x19, WrapI_U<ClearEvent>, "ClearEvent"}, - {0x1A, nullptr, "CreateTimer"}, - {0x1B, nullptr, "SetTimer"}, - {0x1C, nullptr, "CancelTimer"}, - {0x1D, nullptr, "ClearTimer"}, - {0x1E, nullptr, "CreateMemoryBlock"}, - {0x1F, WrapI_UUUU<MapMemoryBlock>, "MapMemoryBlock"}, - {0x20, nullptr, "UnmapMemoryBlock"}, - {0x21, WrapI_V<CreateAddressArbiter>, "CreateAddressArbiter"}, - {0x22, WrapI_UUUUS64<ArbitrateAddress>, "ArbitrateAddress"}, - {0x23, WrapI_U<CloseHandle>, "CloseHandle"}, - {0x24, WrapI_US64<WaitSynchronization1>, "WaitSynchronization1"}, - {0x25, WrapI_VVUUS64<WaitSynchronizationN>, "WaitSynchronizationN"}, - {0x26, nullptr, "SignalAndWait"}, - {0x27, WrapI_VU<DuplicateHandle>, "DuplicateHandle"}, - {0x28, nullptr, "GetSystemTick"}, - {0x29, nullptr, "GetHandleInfo"}, - {0x2A, nullptr, "GetSystemInfo"}, - {0x2B, nullptr, "GetProcessInfo"}, - {0x2C, nullptr, "GetThreadInfo"}, - {0x2D, WrapI_VC<ConnectToPort>, "ConnectToPort"}, - {0x2E, nullptr, "SendSyncRequest1"}, - {0x2F, nullptr, "SendSyncRequest2"}, - {0x30, nullptr, "SendSyncRequest3"}, - {0x31, nullptr, "SendSyncRequest4"}, - {0x32, WrapI_U<SendSyncRequest>, "SendSyncRequest"}, - {0x33, nullptr, "OpenProcess"}, - {0x34, nullptr, "OpenThread"}, - {0x35, nullptr, "GetProcessId"}, - {0x36, nullptr, "GetProcessIdOfThread"}, - {0x37, WrapI_VU<GetThreadId>, "GetThreadId"}, - {0x38, WrapI_VU<GetResourceLimit>, "GetResourceLimit"}, - {0x39, nullptr, "GetResourceLimitLimitValues"}, - {0x3A, WrapI_VUVI<GetResourceLimitCurrentValues>, "GetResourceLimitCurrentValues"}, - {0x3B, nullptr, "GetThreadContext"}, - {0x3C, nullptr, "Break"}, - {0x3D, WrapV_C<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, 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"}, }; void Register() { |