From 15d2ab1b33e8ef579d15bb6f20e6c625a58fb166 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 26 May 2014 20:55:48 -0400 Subject: svc: added stub for DuplicateHandle SVC call --- src/core/hle/svc.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 90c05cb74..0c647b86f 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -226,6 +226,13 @@ Result CreateEvent(void* _event, u32 reset_type) { return 0; } +/// Duplicates a kernel handle +Result DuplicateHandle(void* _out, Handle handle) { + Handle* out = (Handle*)_out; + DEBUG_LOG(SVC, "(UNIMPLEMENTED) DuplicateHandle called handle=0x%08X", handle); + return 0; +} + const HLE::FunctionDef SVC_Table[] = { {0x00, NULL, "Unknown"}, {0x01, WrapI_VUUUUU, "ControlMemory"}, @@ -266,7 +273,7 @@ const HLE::FunctionDef SVC_Table[] = { {0x24, WrapI_US64, "WaitSynchronization1"}, {0x25, WrapI_VVUUS64, "WaitSynchronizationN"}, {0x26, NULL, "SignalAndWait"}, - {0x27, NULL, "DuplicateHandle"}, + {0x27, WrapI_VU, "DuplicateHandle"}, {0x28, NULL, "GetSystemTick"}, {0x29, NULL, "GetHandleInfo"}, {0x2A, NULL, "GetSystemInfo"}, -- cgit v1.2.3 From 9f7ed2d027462b6f2f9e1cb96eb586419f5351a8 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 26 May 2014 21:17:10 -0400 Subject: svc: changed SendSyncRequest to use Kernel::Object SyncRequest (instead of just service Interface class) --- src/core/hle/svc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 0c647b86f..ac016a966 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -96,8 +96,8 @@ Result ConnectToPort(void* out, const char* port_name) { /// Synchronize to an OS service Result SendSyncRequest(Handle handle) { DEBUG_LOG(SVC, "SendSyncRequest called handle=0x%08X"); - Service::Interface* service = Service::g_manager->FetchFromHandle(handle); - service->Sync(); + Kernel::Object* object = Kernel::g_object_pool.GetFast(handle); + object->SyncRequest(); return 0; } -- cgit v1.2.3 From 6e51c56fe41c3ff38db3a13e8773a9e9b2103377 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 26 May 2014 21:57:10 -0400 Subject: svc: added some assertions --- src/core/hle/svc.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index ac016a966..6f72a6eb7 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -84,19 +84,17 @@ 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) { Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); - if (service) { - Core::g_app_core->SetReg(1, service->GetHandle()); - } else { - PanicYesNo("ConnectToPort called port_name=%s, but it is not implemented!", port_name); - } DEBUG_LOG(SVC, "ConnectToPort called port_name=%s", port_name); + _assert_msg_(KERNEL, service, "ConnectToPort called, but service is not implemented!"); + Core::g_app_core->SetReg(1, service->GetHandle()); return 0; } /// Synchronize to an OS service Result SendSyncRequest(Handle handle) { - DEBUG_LOG(SVC, "SendSyncRequest called handle=0x%08X"); Kernel::Object* object = Kernel::g_object_pool.GetFast(handle); + DEBUG_LOG(SVC, "SendSyncRequest called handle=0x%08X"); + _assert_msg_(KERNEL, object, "SendSyncRequest called, but kernel object is NULL!"); object->SyncRequest(); return 0; } -- cgit v1.2.3 From 58a3adcdd2eed9d31cd441186af872a0a8924e73 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 26 May 2014 22:12:46 -0400 Subject: kernel: updated SyncRequest to take boolean thread wait result as a parameter --- src/core/hle/svc.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 6f72a6eb7..e566036e5 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -92,11 +92,18 @@ Result ConnectToPort(void* out, const char* port_name) { /// Synchronize to an OS service Result SendSyncRequest(Handle handle) { + bool wait = false; Kernel::Object* object = Kernel::g_object_pool.GetFast(handle); + DEBUG_LOG(SVC, "SendSyncRequest called handle=0x%08X"); _assert_msg_(KERNEL, object, "SendSyncRequest called, but kernel object is NULL!"); - object->SyncRequest(); - return 0; + + Result res = object->SyncRequest(&wait); + if (wait) { + Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? + } + + return res; } /// Close a handle -- cgit v1.2.3 From 47e781e80a4bc0f37eb431a89aa36b27224185e7 Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 27 May 2014 22:41:09 -0400 Subject: svc: implemented WaitSynchronization1, WaitSynchronizationN, and CreateEvent --- src/core/hle/svc.cpp | 68 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 14 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index e566036e5..8468c4fab 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -9,6 +9,7 @@ #include "core/mem_map.h" +#include "core/hle/kernel/event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/mutex.h" #include "core/hle/kernel/thread.h" @@ -16,7 +17,6 @@ #include "core/hle/function_wrappers.h" #include "core/hle/svc.h" #include "core/hle/service/service.h" -#include "core/hle/kernel/thread.h" //////////////////////////////////////////////////////////////////////////////////////////////////// // Namespace SVC @@ -95,7 +95,7 @@ Result SendSyncRequest(Handle handle) { bool wait = false; Kernel::Object* object = Kernel::g_object_pool.GetFast(handle); - DEBUG_LOG(SVC, "SendSyncRequest called handle=0x%08X"); + DEBUG_LOG(SVC, "SendSyncRequest called handle=0x%08X", handle); _assert_msg_(KERNEL, object, "SendSyncRequest called, but kernel object is NULL!"); Result res = object->SyncRequest(&wait); @@ -115,24 +115,62 @@ Result CloseHandle(Handle handle) { /// Wait for a handle to synchronize, timeout after the specified nanoseconds Result WaitSynchronization1(Handle handle, s64 nano_seconds) { - DEBUG_LOG(SVC, "(UNIMPLEMENTED) WaitSynchronization1 called handle=0x%08X, nanoseconds=%d", - handle, nano_seconds); - Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? - return 0; + // TODO(bunnei): Do something with nano_seconds, currently ignoring this + bool wait = false; + + Kernel::Object* object = Kernel::g_object_pool.GetFast(handle); + + DEBUG_LOG(SVC, "WaitSynchronization1 called handle=0x%08X, nanoseconds=%d", handle, + nano_seconds); + _assert_msg_(KERNEL, object, "WaitSynchronization1 called, but kernel object is NULL!"); + + Result res = object->WaitSynchronization(&wait); + + if (wait) { + Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? + } + + return res; } /// Wait for the given handles to synchronize, timeout after the specified nanoseconds -Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wait_all, s64 nano_seconds) { +Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 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; - DEBUG_LOG(SVC, "(UNIMPLEMENTED) WaitSynchronizationN called handle_count=%d, wait_all=%s, nanoseconds=%d %s", + DEBUG_LOG(SVC, "WaitSynchronizationN called handle_count=%d, wait_all=%s, nanoseconds=%d", handle_count, (wait_all ? "true" : "false"), nano_seconds); + // Iterate through each handle, synchronize kernel object for (u32 i = 0; i < handle_count; i++) { - DEBUG_LOG(SVC, "\thandle[%d]=0x%08X", i, handles[i]); + bool wait = false; + Kernel::Object* object = Kernel::g_object_pool.GetFast(handles[i]); // 0 handle + + _assert_msg_(KERNEL, object, "WaitSynchronizationN called handle=0x%08X, but kernel object " + "is NULL!", handles[i]); + + Result res = object->WaitSynchronization(&wait); + + if (!wait && !wait_all) { + Core::g_app_core->SetReg(1, i); + return 0; + } else { + unlock_all = false; + } + } + + if (wait_all && unlock_all) { + Core::g_app_core->SetReg(1, handle_count); + return 0; } + + // Set current thread to wait state if not all handles were unlocked Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? + return 0; } @@ -195,16 +233,17 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p /// Create a mutex Result CreateMutex(void* _mutex, u32 initial_locked) { Handle* mutex = (Handle*)_mutex; - *mutex = Kernel::CreateMutex((initial_locked != 0)); - Core::g_app_core->SetReg(1, *mutex); DEBUG_LOG(SVC, "CreateMutex called initial_locked=%s : created handle 0x%08X", initial_locked ? "true" : "false", *mutex); + *mutex = Kernel::CreateMutex((initial_locked != 0)); + Core::g_app_core->SetReg(1, *mutex); return 0; } /// Release a mutex Result ReleaseMutex(Handle handle) { DEBUG_LOG(SVC, "ReleaseMutex called handle=0x%08X", handle); + _assert_msg_(KERNEL, handle, "ReleaseMutex called, but handle is NULL!"); Kernel::ReleaseMutex(handle); return 0; } @@ -225,9 +264,10 @@ Result QueryMemory(void *_info, void *_out, u32 addr) { /// Create an event Result CreateEvent(void* _event, u32 reset_type) { - Handle* event = (Handle*)_event; - DEBUG_LOG(SVC, "(UNIMPLEMENTED) CreateEvent called reset_type=0x%08X", reset_type); - Core::g_app_core->SetReg(1, 0xBADC0DE0); + Handle* evt = (Handle*)_event; + DEBUG_LOG(SVC, "CreateEvent called reset_type=0x%08X", reset_type); + *evt = Kernel::CreateEvent((ResetType)reset_type); + Core::g_app_core->SetReg(1, *evt); return 0; } -- cgit v1.2.3 From 58af0da792adab4bfd77699f9431050290a75b7c Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 29 May 2014 20:24:51 -0400 Subject: svc: added svcClearEvent, stubbed function for svcArbitrateAddress, and various fixes - force kernel reschedule after svcWaitSynchronization - fixed some bugs with passing in pointer arguments - cleaned up some comments and log messages --- src/core/hle/svc.cpp | 54 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 8468c4fab..8ef894e68 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -35,7 +35,6 @@ enum MapMemoryPermission { /// Map application or GSP heap memory Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { - u32* outaddr = (u32*)_outaddr; u32 virtual_address = 0x00000000; DEBUG_LOG(SVC, "ControlMemory called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", @@ -57,9 +56,7 @@ Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 si default: ERROR_LOG(SVC, "ControlMemory unknown operation=0x%08X", operation); } - if (NULL != outaddr) { - *outaddr = virtual_address; - } + Core::g_app_core->SetReg(1, virtual_address); return 0; @@ -82,7 +79,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) { +Result ConnectToPort(void* _out, const char* port_name) { Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); DEBUG_LOG(SVC, "ConnectToPort called port_name=%s", port_name); _assert_msg_(KERNEL, service, "ConnectToPort called, but service is not implemented!"); @@ -128,6 +125,7 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) { if (wait) { Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? + Kernel::Reschedule(); } return res; @@ -138,7 +136,6 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa 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; @@ -153,6 +150,8 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa _assert_msg_(KERNEL, object, "WaitSynchronizationN called handle=0x%08X, but kernel object " "is NULL!", handles[i]); + DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X", i, handles[i]); + Result res = object->WaitSynchronization(&wait); if (!wait && !wait_all) { @@ -170,18 +169,26 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa // Set current thread to wait state if not all handles were unlocked Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? + Kernel::Reschedule(); return 0; } /// Create an address arbiter (to allocate access to shared resources) Result CreateAddressArbiter(void* arbiter) { - // ImplementMe DEBUG_LOG(SVC, "(UNIMPLEMENTED) CreateAddressArbiter called"); Core::g_app_core->SetReg(1, 0xFABBDADD); return 0; } +/// Arbitrate address +Result ArbitrateAddress(Handle arbiter, u32 addr, u32 _type, u32 value, s64 nanoseconds) { + DEBUG_LOG(SVC, "(UNIMPLEMENTED) ArbitrateAddress called"); + ArbitrationType type = (ArbitrationType)_type; + Memory::Write32(addr, type); + return 0; +} + /// Used to output a message on a debug hardware unit - does nothing on a retail unit void OutputDebugString(const char* string) { NOTICE_LOG(SVC, "## OSDEBUG: %08X %s", Core::g_app_core->GetPC(), string); @@ -199,7 +206,6 @@ Result GetResourceLimit(void* resource_limit, Handle process) { /// Get resource limit current values Result GetResourceLimitCurrentValues(void* _values, Handle resource_limit, void* names, s32 name_count) { - //s64* values = (s64*)_values; DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimitCurrentValues called resource_limit=%08X, names=%s, name_count=%d", resource_limit, names, name_count); Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now @@ -224,7 +230,7 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p Core::g_app_core->SetReg(1, thread); DEBUG_LOG(SVC, "CreateThread called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " - "threadpriority=0x%08X, processorid=0x%08X : created handle 0x%08X", entry_point, + "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point, name.c_str(), arg, stack_top, priority, processor_id, thread); return 0; @@ -232,11 +238,10 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p /// Create a mutex Result CreateMutex(void* _mutex, u32 initial_locked) { - Handle* mutex = (Handle*)_mutex; - DEBUG_LOG(SVC, "CreateMutex called initial_locked=%s : created handle 0x%08X", - initial_locked ? "true" : "false", *mutex); - *mutex = Kernel::CreateMutex((initial_locked != 0)); - Core::g_app_core->SetReg(1, *mutex); + Handle mutex = Kernel::CreateMutex((initial_locked != 0)); + Core::g_app_core->SetReg(1, mutex); + DEBUG_LOG(SVC, "CreateMutex called initial_locked=%s : created handle=0x%08X", + initial_locked ? "true" : "false", mutex); return 0; } @@ -256,18 +261,16 @@ Result GetThreadId(void* thread_id, u32 thread) { /// Query memory Result QueryMemory(void *_info, void *_out, u32 addr) { - MemoryInfo* info = (MemoryInfo*) _info; - PageInfo* out = (PageInfo*) _out; DEBUG_LOG(SVC, "(UNIMPLEMENTED) QueryMemory called addr=0x%08X", addr); return 0; } /// Create an event Result CreateEvent(void* _event, u32 reset_type) { - Handle* evt = (Handle*)_event; - DEBUG_LOG(SVC, "CreateEvent called reset_type=0x%08X", reset_type); - *evt = Kernel::CreateEvent((ResetType)reset_type); - Core::g_app_core->SetReg(1, *evt); + Handle evt = Kernel::CreateEvent((ResetType)reset_type); + Core::g_app_core->SetReg(1, evt); + DEBUG_LOG(SVC, "CreateEvent called reset_type=0x%08X : created handle=0x%08X", + reset_type, evt); return 0; } @@ -278,6 +281,13 @@ Result DuplicateHandle(void* _out, Handle handle) { return 0; } +/// Clears an event +Result ClearEvent(Handle evt) { + Result res = Kernel::ClearEvent(evt); + DEBUG_LOG(SVC, "ClearEvent called event=0x%08X", evt); + return res; +} + const HLE::FunctionDef SVC_Table[] = { {0x00, NULL, "Unknown"}, {0x01, WrapI_VUUUUU, "ControlMemory"}, @@ -304,7 +314,7 @@ const HLE::FunctionDef SVC_Table[] = { {0x16, NULL, "ReleaseSemaphore"}, {0x17, WrapI_VU, "CreateEvent"}, {0x18, NULL, "SignalEvent"}, - {0x19, NULL, "ClearEvent"}, + {0x19, WrapI_U, "ClearEvent"}, {0x1A, NULL, "CreateTimer"}, {0x1B, NULL, "SetTimer"}, {0x1C, NULL, "CancelTimer"}, @@ -313,7 +323,7 @@ const HLE::FunctionDef SVC_Table[] = { {0x1F, WrapI_UUUU, "MapMemoryBlock"}, {0x20, NULL, "UnmapMemoryBlock"}, {0x21, WrapI_V, "CreateAddressArbiter"}, - {0x22, NULL, "ArbitrateAddress"}, + {0x22, WrapI_UUUUS64, "ArbitrateAddress"}, {0x23, WrapI_U, "CloseHandle"}, {0x24, WrapI_US64, "WaitSynchronization1"}, {0x25, WrapI_VVUUS64, "WaitSynchronizationN"}, -- cgit v1.2.3 From 6d267142ad42ed09e475742cab463b55d9176c29 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 29 May 2014 20:26:27 -0400 Subject: svc: changed unimplemented SVC log messages from "debug" messages to "error" messages --- src/core/hle/svc.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 8ef894e68..6df0309e6 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -106,7 +106,7 @@ Result SendSyncRequest(Handle handle) { /// Close a handle Result CloseHandle(Handle handle) { // ImplementMe - DEBUG_LOG(SVC, "(UNIMPLEMENTED) CloseHandle called handle=0x%08X", handle); + ERROR_LOG(SVC, "(UNIMPLEMENTED) CloseHandle called handle=0x%08X", handle); return 0; } @@ -176,14 +176,14 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa /// Create an address arbiter (to allocate access to shared resources) Result CreateAddressArbiter(void* arbiter) { - DEBUG_LOG(SVC, "(UNIMPLEMENTED) CreateAddressArbiter called"); + ERROR_LOG(SVC, "(UNIMPLEMENTED) CreateAddressArbiter called"); Core::g_app_core->SetReg(1, 0xFABBDADD); return 0; } /// Arbitrate address Result ArbitrateAddress(Handle arbiter, u32 addr, u32 _type, u32 value, s64 nanoseconds) { - DEBUG_LOG(SVC, "(UNIMPLEMENTED) ArbitrateAddress called"); + ERROR_LOG(SVC, "(UNIMPLEMENTED) ArbitrateAddress called"); ArbitrationType type = (ArbitrationType)_type; Memory::Write32(addr, type); return 0; @@ -199,14 +199,14 @@ Result GetResourceLimit(void* 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. - DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimit called process=0x%08X", process); + ERROR_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimit called process=0x%08X", process); Core::g_app_core->SetReg(1, 0xDEADBEEF); return 0; } /// Get resource limit current values Result GetResourceLimitCurrentValues(void* _values, Handle resource_limit, void* names, s32 name_count) { - DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimitCurrentValues called resource_limit=%08X, names=%s, name_count=%d", + ERROR_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimitCurrentValues called resource_limit=%08X, names=%s, name_count=%d", resource_limit, names, name_count); Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now return 0; @@ -255,13 +255,13 @@ Result ReleaseMutex(Handle handle) { /// Get current thread ID Result GetThreadId(void* thread_id, u32 thread) { - DEBUG_LOG(SVC, "(UNIMPLEMENTED) GetThreadId called thread=0x%08X", thread); + ERROR_LOG(SVC, "(UNIMPLEMENTED) GetThreadId called thread=0x%08X", thread); return 0; } /// Query memory Result QueryMemory(void *_info, void *_out, u32 addr) { - DEBUG_LOG(SVC, "(UNIMPLEMENTED) QueryMemory called addr=0x%08X", addr); + ERROR_LOG(SVC, "(UNIMPLEMENTED) QueryMemory called addr=0x%08X", addr); return 0; } @@ -277,7 +277,7 @@ Result CreateEvent(void* _event, u32 reset_type) { /// Duplicates a kernel handle Result DuplicateHandle(void* _out, Handle handle) { Handle* out = (Handle*)_out; - DEBUG_LOG(SVC, "(UNIMPLEMENTED) DuplicateHandle called handle=0x%08X", handle); + ERROR_LOG(SVC, "(UNIMPLEMENTED) DuplicateHandle called handle=0x%08X", handle); return 0; } -- cgit v1.2.3 From b0bad47c0e25717bb1c69bc9a286e57f39064238 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 29 May 2014 23:04:18 -0400 Subject: svc: updated OutputDebugString to use OS_LOG --- src/core/hle/svc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 6df0309e6..27f2b2315 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -191,7 +191,7 @@ Result ArbitrateAddress(Handle arbiter, u32 addr, u32 _type, u32 value, s64 nano /// Used to output a message on a debug hardware unit - does nothing on a retail unit void OutputDebugString(const char* string) { - NOTICE_LOG(SVC, "## OSDEBUG: %08X %s", Core::g_app_core->GetPC(), string); + OS_LOG(SVC, "%s", string); } /// Get resource limit -- cgit v1.2.3 From c404d22036e16d20d91fca0cf29d56785656c0f5 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 29 May 2014 23:26:58 -0400 Subject: hle: cleaned up log messages --- src/core/hle/svc.cpp | 55 ++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 27f2b2315..01fb647e7 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -37,7 +37,7 @@ enum MapMemoryPermission { Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { u32 virtual_address = 0x00000000; - DEBUG_LOG(SVC, "ControlMemory called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", + DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", operation, addr0, addr1, size, permissions); switch (operation) { @@ -54,7 +54,7 @@ Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 si // Unknown ControlMemory operation default: - ERROR_LOG(SVC, "ControlMemory unknown operation=0x%08X", operation); + ERROR_LOG(SVC, "unknown operation=0x%08X", operation); } Core::g_app_core->SetReg(1, virtual_address); @@ -64,7 +64,7 @@ Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 si /// Maps a memory block to specified address Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherpermission) { - DEBUG_LOG(SVC, "MapMemoryBlock called memblock=0x08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", + DEBUG_LOG(SVC, "called memblock=0x08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", memblock, addr, mypermissions, otherpermission); switch (mypermissions) { case MEMORY_PERMISSION_NORMAL: @@ -73,7 +73,7 @@ Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherper Memory::MapBlock_Shared(memblock, addr, mypermissions); break; default: - ERROR_LOG(OSHLE, "MapMemoryBlock unknown permissions=0x%08X", mypermissions); + ERROR_LOG(OSHLE, "unknown permissions=0x%08X", mypermissions); } return 0; } @@ -81,8 +81,8 @@ 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) { Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); - DEBUG_LOG(SVC, "ConnectToPort called port_name=%s", port_name); - _assert_msg_(KERNEL, service, "ConnectToPort called, but service is not implemented!"); + DEBUG_LOG(SVC, "called port_name=%s", port_name); + _assert_msg_(KERNEL, service, "called, but service is not implemented!"); Core::g_app_core->SetReg(1, service->GetHandle()); return 0; } @@ -92,8 +92,8 @@ Result SendSyncRequest(Handle handle) { bool wait = false; Kernel::Object* object = Kernel::g_object_pool.GetFast(handle); - DEBUG_LOG(SVC, "SendSyncRequest called handle=0x%08X", handle); - _assert_msg_(KERNEL, object, "SendSyncRequest called, but kernel object is NULL!"); + DEBUG_LOG(SVC, "called handle=0x%08X", handle); + _assert_msg_(KERNEL, object, "called, but kernel object is NULL!"); Result res = object->SyncRequest(&wait); if (wait) { @@ -106,7 +106,7 @@ Result SendSyncRequest(Handle handle) { /// Close a handle Result CloseHandle(Handle handle) { // ImplementMe - ERROR_LOG(SVC, "(UNIMPLEMENTED) CloseHandle called handle=0x%08X", handle); + ERROR_LOG(SVC, "(UNIMPLEMENTED) called handle=0x%08X", handle); return 0; } @@ -117,9 +117,9 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) { Kernel::Object* object = Kernel::g_object_pool.GetFast(handle); - DEBUG_LOG(SVC, "WaitSynchronization1 called handle=0x%08X, nanoseconds=%d", handle, + DEBUG_LOG(SVC, "called handle=0x%08X, nanoseconds=%d", handle, nano_seconds); - _assert_msg_(KERNEL, object, "WaitSynchronization1 called, but kernel object is NULL!"); + _assert_msg_(KERNEL, object, "called, but kernel object is NULL!"); Result res = object->WaitSynchronization(&wait); @@ -139,7 +139,7 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa Handle* handles = (Handle*)_handles; bool unlock_all = true; - DEBUG_LOG(SVC, "WaitSynchronizationN called handle_count=%d, wait_all=%s, nanoseconds=%d", + DEBUG_LOG(SVC, "called handle_count=%d, wait_all=%s, nanoseconds=%d", handle_count, (wait_all ? "true" : "false"), nano_seconds); // Iterate through each handle, synchronize kernel object @@ -147,7 +147,7 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa bool wait = false; Kernel::Object* object = Kernel::g_object_pool.GetFast(handles[i]); // 0 handle - _assert_msg_(KERNEL, object, "WaitSynchronizationN called handle=0x%08X, but kernel object " + _assert_msg_(KERNEL, object, "called handle=0x%08X, but kernel object " "is NULL!", handles[i]); DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X", i, handles[i]); @@ -176,14 +176,14 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa /// Create an address arbiter (to allocate access to shared resources) Result CreateAddressArbiter(void* arbiter) { - ERROR_LOG(SVC, "(UNIMPLEMENTED) CreateAddressArbiter called"); + ERROR_LOG(SVC, "(UNIMPLEMENTED) called"); Core::g_app_core->SetReg(1, 0xFABBDADD); return 0; } /// Arbitrate address Result ArbitrateAddress(Handle arbiter, u32 addr, u32 _type, u32 value, s64 nanoseconds) { - ERROR_LOG(SVC, "(UNIMPLEMENTED) ArbitrateAddress called"); + ERROR_LOG(SVC, "(UNIMPLEMENTED) called"); ArbitrationType type = (ArbitrationType)_type; Memory::Write32(addr, type); return 0; @@ -199,14 +199,15 @@ Result GetResourceLimit(void* 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. - ERROR_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimit called process=0x%08X", process); + ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process); Core::g_app_core->SetReg(1, 0xDEADBEEF); return 0; } /// Get resource limit current values -Result GetResourceLimitCurrentValues(void* _values, Handle resource_limit, void* names, s32 name_count) { - ERROR_LOG(SVC, "(UNIMPLEMENTED) GetResourceLimitCurrentValues called resource_limit=%08X, names=%s, name_count=%d", +Result GetResourceLimitCurrentValues(void* _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); Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now return 0; @@ -229,7 +230,7 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p Core::g_app_core->SetReg(1, thread); - DEBUG_LOG(SVC, "CreateThread called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " + DEBUG_LOG(SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point, name.c_str(), arg, stack_top, priority, processor_id, thread); @@ -240,28 +241,28 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p Result CreateMutex(void* _mutex, u32 initial_locked) { Handle mutex = Kernel::CreateMutex((initial_locked != 0)); Core::g_app_core->SetReg(1, mutex); - DEBUG_LOG(SVC, "CreateMutex called initial_locked=%s : created handle=0x%08X", + DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X", initial_locked ? "true" : "false", mutex); return 0; } /// Release a mutex Result ReleaseMutex(Handle handle) { - DEBUG_LOG(SVC, "ReleaseMutex called handle=0x%08X", handle); - _assert_msg_(KERNEL, handle, "ReleaseMutex called, but handle is NULL!"); + DEBUG_LOG(SVC, "called handle=0x%08X", handle); + _assert_msg_(KERNEL, handle, "called, but handle is NULL!"); Kernel::ReleaseMutex(handle); return 0; } /// Get current thread ID Result GetThreadId(void* thread_id, u32 thread) { - ERROR_LOG(SVC, "(UNIMPLEMENTED) GetThreadId called thread=0x%08X", thread); + ERROR_LOG(SVC, "(UNIMPLEMENTED) called thread=0x%08X", thread); return 0; } /// Query memory Result QueryMemory(void *_info, void *_out, u32 addr) { - ERROR_LOG(SVC, "(UNIMPLEMENTED) QueryMemory called addr=0x%08X", addr); + ERROR_LOG(SVC, "(UNIMPLEMENTED) called addr=0x%08X", addr); return 0; } @@ -269,7 +270,7 @@ Result QueryMemory(void *_info, void *_out, u32 addr) { Result CreateEvent(void* _event, u32 reset_type) { Handle evt = Kernel::CreateEvent((ResetType)reset_type); Core::g_app_core->SetReg(1, evt); - DEBUG_LOG(SVC, "CreateEvent called reset_type=0x%08X : created handle=0x%08X", + DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type, evt); return 0; } @@ -277,14 +278,14 @@ Result CreateEvent(void* _event, u32 reset_type) { /// Duplicates a kernel handle Result DuplicateHandle(void* _out, Handle handle) { Handle* out = (Handle*)_out; - ERROR_LOG(SVC, "(UNIMPLEMENTED) DuplicateHandle called handle=0x%08X", handle); + ERROR_LOG(SVC, "(UNIMPLEMENTED) called handle=0x%08X", handle); return 0; } /// Clears an event Result ClearEvent(Handle evt) { Result res = Kernel::ClearEvent(evt); - DEBUG_LOG(SVC, "ClearEvent called event=0x%08X", evt); + DEBUG_LOG(SVC, "called event=0x%08X", evt); return res; } -- cgit v1.2.3 From f2f638492b1585739d193b400e34ede91c256462 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 1 Jun 2014 10:37:19 -0400 Subject: svc: updated waitSychronization to not overwrite handle on return, added stub for SleepThread (does nothing) --- src/core/hle/svc.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 01fb647e7..5ba42973a 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -126,6 +126,14 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) { if (wait) { Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? Kernel::Reschedule(); + + // Context switch - Function blocked, is not actually returning (will be "called" again) + + // TODO(bunnei): This saves handle to R0 so that it's correctly reloaded on context switch + // (otherwise R0 will be set to whatever is returned, and handle will be invalid when this + // thread is resumed). There is probably a better way of keeping track of state so that we + // don't necessarily have to do this. + return (Result)PARAM(0); } return res; @@ -171,7 +179,13 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? Kernel::Reschedule(); - return 0; + // Context switch - Function blocked, is not actually returning (will be "called" again) + + // TODO(bunnei): This saves handle to R0 so that it's correctly reloaded on context switch + // (otherwise R0 will be set to whatever is returned, and handle will be invalid when this + // thread is resumed). There is probably a better way of keeping track of state so that we + // don't necessarily have to do this. + return (Result)PARAM(0); } /// Create an address arbiter (to allocate access to shared resources) @@ -289,6 +303,11 @@ Result ClearEvent(Handle evt) { return res; } +/// Sleep the current thread +void SleepThread(s64 nanoseconds) { + DEBUG_LOG(SVC, "called nanoseconds=%d", nanoseconds); +} + const HLE::FunctionDef SVC_Table[] = { {0x00, NULL, "Unknown"}, {0x01, WrapI_VUUUUU, "ControlMemory"}, @@ -300,7 +319,7 @@ const HLE::FunctionDef SVC_Table[] = { {0x07, NULL, "SetProcessIdealProcessor"}, {0x08, WrapI_UUUUU, "CreateThread"}, {0x09, NULL, "ExitThread"}, - {0x0A, NULL, "SleepThread"}, + {0x0A, WrapV_S64, "SleepThread"}, {0x0B, NULL, "GetThreadPriority"}, {0x0C, NULL, "SetThreadPriority"}, {0x0D, NULL, "GetThreadAffinityMask"}, -- cgit v1.2.3 From 15c7d8170669cadce685471fea48c215687d6622 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 1 Jun 2014 20:48:29 -0400 Subject: svc: cleaned up function_wrappers, updated various SVCs to make use of pointer arguments --- src/core/hle/svc.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 5ba42973a..11b77e2c5 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -34,8 +34,8 @@ enum MapMemoryPermission { }; /// Map application or GSP heap memory -Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { - u32 virtual_address = 0x00000000; +Result ControlMemory(void* _out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { + u32* out_addr = (u32*)_out_addr; DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", operation, addr0, addr1, size, permissions); @@ -44,21 +44,18 @@ Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 si // Map normal heap memory case MEMORY_OPERATION_HEAP: - virtual_address = Memory::MapBlock_Heap(size, operation, permissions); + *out_addr = Memory::MapBlock_Heap(size, operation, permissions); break; // Map GSP heap memory case MEMORY_OPERATION_GSP_HEAP: - virtual_address = Memory::MapBlock_HeapGSP(size, operation, permissions); + *out_addr = Memory::MapBlock_HeapGSP(size, operation, permissions); break; // Unknown ControlMemory operation default: ERROR_LOG(SVC, "unknown operation=0x%08X", operation); } - - Core::g_app_core->SetReg(1, virtual_address); - return 0; } @@ -80,10 +77,14 @@ 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; Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); + DEBUG_LOG(SVC, "called port_name=%s", port_name); _assert_msg_(KERNEL, service, "called, but service is not implemented!"); - Core::g_app_core->SetReg(1, service->GetHandle()); + + *out = service->GetHandle(); + return 0; } @@ -209,12 +210,13 @@ void OutputDebugString(const char* string) { } /// Get resource limit -Result GetResourceLimit(void* resource_limit, Handle process) { +Result GetResourceLimit(void* _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); - Core::g_app_core->SetReg(1, 0xDEADBEEF); return 0; } @@ -253,10 +255,10 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p /// Create a mutex Result CreateMutex(void* _mutex, u32 initial_locked) { - Handle mutex = Kernel::CreateMutex((initial_locked != 0)); - Core::g_app_core->SetReg(1, mutex); + Handle* mutex = (Handle*)_mutex; + *mutex = Kernel::CreateMutex((initial_locked != 0)); DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X", - initial_locked ? "true" : "false", mutex); + initial_locked ? "true" : "false", *mutex); return 0; } @@ -282,10 +284,10 @@ Result QueryMemory(void *_info, void *_out, u32 addr) { /// Create an event Result CreateEvent(void* _event, u32 reset_type) { - Handle evt = Kernel::CreateEvent((ResetType)reset_type); - Core::g_app_core->SetReg(1, evt); + Handle* evt = (Handle*)_event; + *evt = Kernel::CreateEvent((ResetType)reset_type); DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X", - reset_type, evt); + reset_type, *evt); return 0; } -- cgit v1.2.3 From 10447d1f4831b495d7bef7711681ddd548f847a6 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 1 Jun 2014 21:42:50 -0400 Subject: kernel: changed main thread priority to default, updated Kernel::Reschedule to use PrepareReschedule --- src/core/hle/svc.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 11b77e2c5..0c2412a65 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -125,8 +125,11 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) { Result res = object->WaitSynchronization(&wait); if (wait) { + // Set current thread to wait state if handle was not unlocked Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? - Kernel::Reschedule(); + + // Check for next thread to schedule + HLE::Reschedule(__func__); // Context switch - Function blocked, is not actually returning (will be "called" again) @@ -178,7 +181,9 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa // Set current thread to wait state if not all handles were unlocked Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? - Kernel::Reschedule(); + + // Check for next thread to schedule + HLE::Reschedule(__func__); // Context switch - Function blocked, is not actually returning (will be "called" again) -- cgit v1.2.3 From 3fb31fbc57fd1d537db79af898ef26c92b0e0867 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 1 Jun 2014 22:12:54 -0400 Subject: svc: added GetThreadPriority and SetThreadPriority, added (incomplete) DuplicateHandle support --- src/core/hle/svc.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 0c2412a65..2384b7936 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -258,6 +258,18 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p return 0; } +/// Gets the priority for the specified thread +Result GetThreadPriority(void* _priority, Handle handle) { + s32* priority = (s32*)_priority; + *priority = Kernel::GetThreadPriority(handle); + return 0; +} + +/// Sets the priority for the specified thread +Result SetThreadPriority(Handle handle, s32 priority) { + return Kernel::SetThreadPriority(handle, priority); +} + /// Create a mutex Result CreateMutex(void* _mutex, u32 initial_locked) { Handle* mutex = (Handle*)_mutex; @@ -299,7 +311,18 @@ Result CreateEvent(void* _event, u32 reset_type) { /// Duplicates a kernel handle Result DuplicateHandle(void* _out, Handle handle) { Handle* out = (Handle*)_out; - ERROR_LOG(SVC, "(UNIMPLEMENTED) called handle=0x%08X", handle); + ERROR_LOG(SVC, "called handle=0x%08X", handle); + + // Translate kernel handles -> real handles + if (handle == Kernel::CurrentThread) { + handle = Kernel::GetCurrentThreadHandle(); + } + _assert_msg_(KERNEL, (handle != Kernel::CurrentProcess), + "(UNIMPLEMENTED) process handle duplication!"); + + // TODO(bunnei): FixMe - This is a hack to return the handle that we were asked to duplicate. + *out = handle; + return 0; } @@ -327,8 +350,8 @@ const HLE::FunctionDef SVC_Table[] = { {0x08, WrapI_UUUUU, "CreateThread"}, {0x09, NULL, "ExitThread"}, {0x0A, WrapV_S64, "SleepThread"}, - {0x0B, NULL, "GetThreadPriority"}, - {0x0C, NULL, "SetThreadPriority"}, + {0x0B, WrapI_VU, "GetThreadPriority"}, + {0x0C, WrapI_UI, "SetThreadPriority"}, {0x0D, NULL, "GetThreadAffinityMask"}, {0x0E, NULL, "SetThreadAffinityMask"}, {0x0F, NULL, "GetThreadIdealProcessor"}, -- cgit v1.2.3 From 4819e9a60f36ac4ec1a7cb3d30008353ab03bf14 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 1 Jun 2014 22:33:53 -0400 Subject: svc: changed DuplicateHandle log message from "error" to "debug" --- src/core/hle/svc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 2384b7936..1f36c7ac5 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -311,7 +311,7 @@ Result CreateEvent(void* _event, u32 reset_type) { /// Duplicates a kernel handle Result DuplicateHandle(void* _out, Handle handle) { Handle* out = (Handle*)_out; - ERROR_LOG(SVC, "called handle=0x%08X", handle); + DEBUG_LOG(SVC, "called handle=0x%08X", handle); // Translate kernel handles -> real handles if (handle == Kernel::CurrentThread) { -- cgit v1.2.3 From 477b0caca4f0db084ab2d2dfb866fd81e5839228 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 2 Jun 2014 17:54:07 -0400 Subject: svc: updated WaitSynchronizationN to properly use first pointer argument --- src/core/hle/svc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 1f36c7ac5..c8eb8ea80 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -147,7 +147,7 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) { Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 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; @@ -167,7 +167,7 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa Result res = object->WaitSynchronization(&wait); if (!wait && !wait_all) { - Core::g_app_core->SetReg(1, i); + *out = i; return 0; } else { unlock_all = false; @@ -175,7 +175,7 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa } if (wait_all && unlock_all) { - Core::g_app_core->SetReg(1, handle_count); + *out = handle_count; return 0; } -- cgit v1.2.3 From f5c7c1543434e25a215286e6db5e71c055ba48cf Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 5 Jun 2014 22:35:36 -0400 Subject: Kernel: Added real support for thread and event blocking - SVC: Added ExitThread support - SVC: Added SignalEvent support - Thread: Added WAITTYPE_EVENT for waiting threads for event signals - Thread: Added support for blocking on other threads to finish (e.g. Thread::Join) - Thread: Added debug function for printing current threads ready for execution - Thread: Removed hack/broken thread ready state code from Kernel::Reschedule - Mutex: Moved WaitCurrentThread from SVC to Mutex::WaitSynchronization - Event: Added support for blocking threads on event signalling Kernel: Added missing algorithm #include for use of std::find on non-Windows platforms. --- src/core/hle/svc.cpp | 59 +++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index c8eb8ea80..0ce831103 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -93,8 +93,8 @@ Result SendSyncRequest(Handle handle) { bool wait = false; Kernel::Object* object = Kernel::g_object_pool.GetFast(handle); - DEBUG_LOG(SVC, "called handle=0x%08X", handle); _assert_msg_(KERNEL, object, "called, but kernel object is NULL!"); + DEBUG_LOG(SVC, "called handle=0x%08X(%s)", handle, object->GetTypeName()); Result res = object->SyncRequest(&wait); if (wait) { @@ -115,29 +115,21 @@ Result CloseHandle(Handle handle) { Result WaitSynchronization1(Handle handle, s64 nano_seconds) { // TODO(bunnei): Do something with nano_seconds, currently ignoring this bool wait = false; + bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated Kernel::Object* object = Kernel::g_object_pool.GetFast(handle); - DEBUG_LOG(SVC, "called handle=0x%08X, nanoseconds=%d", handle, - nano_seconds); + DEBUG_LOG(SVC, "called handle=0x%08X(%s:%s), nanoseconds=%d", handle, object->GetTypeName(), + object->GetName(), nano_seconds); + _assert_msg_(KERNEL, object, "called, but kernel object is NULL!"); Result res = object->WaitSynchronization(&wait); + // Check for next thread to schedule if (wait) { - // Set current thread to wait state if handle was not unlocked - Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? - - // Check for next thread to schedule HLE::Reschedule(__func__); - - // Context switch - Function blocked, is not actually returning (will be "called" again) - - // TODO(bunnei): This saves handle to R0 so that it's correctly reloaded on context switch - // (otherwise R0 will be set to whatever is returned, and handle will be invalid when this - // thread is resumed). There is probably a better way of keeping track of state so that we - // don't necessarily have to do this. - return (Result)PARAM(0); + return 0; } return res; @@ -150,6 +142,7 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa 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 DEBUG_LOG(SVC, "called handle_count=%d, wait_all=%s, nanoseconds=%d", handle_count, (wait_all ? "true" : "false"), nano_seconds); @@ -162,7 +155,8 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa _assert_msg_(KERNEL, object, "called handle=0x%08X, but kernel object " "is NULL!", handles[i]); - DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X", i, handles[i]); + DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName(), + object->GetName()); Result res = object->WaitSynchronization(&wait); @@ -179,19 +173,10 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa return 0; } - // Set current thread to wait state if not all handles were unlocked - Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? - // Check for next thread to schedule HLE::Reschedule(__func__); - // Context switch - Function blocked, is not actually returning (will be "called" again) - - // TODO(bunnei): This saves handle to R0 so that it's correctly reloaded on context switch - // (otherwise R0 will be set to whatever is returned, and handle will be invalid when this - // thread is resumed). There is probably a better way of keeping track of state so that we - // don't necessarily have to do this. - return (Result)PARAM(0); + return 0; } /// Create an address arbiter (to allocate access to shared resources) @@ -258,6 +243,17 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p return 0; } +/// Called when a thread exits +u32 ExitThread() { + Handle thread = Kernel::GetCurrentThreadHandle(); + + DEBUG_LOG(SVC, "called, pc=0x%08X", Core::g_app_core->GetPC()); // PC = 0x0010545C + + Kernel::StopThread(thread, __func__); + HLE::Reschedule(__func__); + return 0; +} + /// Gets the priority for the specified thread Result GetThreadPriority(void* _priority, Handle handle) { s32* priority = (s32*)_priority; @@ -326,6 +322,13 @@ Result DuplicateHandle(void* _out, Handle handle) { return 0; } +/// Signals an event +Result SignalEvent(Handle evt) { + Result res = Kernel::SignalEvent(evt); + DEBUG_LOG(SVC, "called event=0x%08X", evt); + return res; +} + /// Clears an event Result ClearEvent(Handle evt) { Result res = Kernel::ClearEvent(evt); @@ -348,7 +351,7 @@ const HLE::FunctionDef SVC_Table[] = { {0x06, NULL, "GetProcessIdealProcessor"}, {0x07, NULL, "SetProcessIdealProcessor"}, {0x08, WrapI_UUUUU, "CreateThread"}, - {0x09, NULL, "ExitThread"}, + {0x09, WrapU_V, "ExitThread"}, {0x0A, WrapV_S64, "SleepThread"}, {0x0B, WrapI_VU, "GetThreadPriority"}, {0x0C, WrapI_UI, "SetThreadPriority"}, @@ -363,7 +366,7 @@ const HLE::FunctionDef SVC_Table[] = { {0x15, NULL, "CreateSemaphore"}, {0x16, NULL, "ReleaseSemaphore"}, {0x17, WrapI_VU, "CreateEvent"}, - {0x18, NULL, "SignalEvent"}, + {0x18, WrapI_U, "SignalEvent"}, {0x19, WrapI_U, "ClearEvent"}, {0x1A, NULL, "CreateTimer"}, {0x1B, NULL, "SetTimer"}, -- cgit v1.2.3 From d7363322c79d6e7598e0d80cf1af9c05b652cecb Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 6 Jun 2014 00:19:40 -0400 Subject: HLE: Updated various handle debug assertions to be more clear. --- src/core/hle/svc.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 0ce831103..c389bbaac 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -81,7 +81,7 @@ Result ConnectToPort(void* _out, const char* port_name) { Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); DEBUG_LOG(SVC, "called port_name=%s", port_name); - _assert_msg_(KERNEL, service, "called, but service is not implemented!"); + _assert_msg_(KERNEL, (service != NULL), "called, but service is not implemented!"); *out = service->GetHandle(); @@ -93,7 +93,7 @@ Result SendSyncRequest(Handle handle) { bool wait = false; Kernel::Object* object = Kernel::g_object_pool.GetFast(handle); - _assert_msg_(KERNEL, object, "called, but kernel object is NULL!"); + _assert_msg_(KERNEL, (object != NULL), "called, but kernel object is NULL!"); DEBUG_LOG(SVC, "called handle=0x%08X(%s)", handle, object->GetTypeName()); Result res = object->SyncRequest(&wait); @@ -122,7 +122,7 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) { DEBUG_LOG(SVC, "called handle=0x%08X(%s:%s), nanoseconds=%d", handle, object->GetTypeName(), object->GetName(), nano_seconds); - _assert_msg_(KERNEL, object, "called, but kernel object is NULL!"); + _assert_msg_(KERNEL, (object != NULL), "called, but kernel object is NULL!"); Result res = object->WaitSynchronization(&wait); @@ -150,9 +150,9 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa // Iterate through each handle, synchronize kernel object for (u32 i = 0; i < handle_count; i++) { bool wait = false; - Kernel::Object* object = Kernel::g_object_pool.GetFast(handles[i]); // 0 handle + Kernel::Object* object = Kernel::g_object_pool.GetFast(handles[i]); - _assert_msg_(KERNEL, object, "called handle=0x%08X, but kernel object " + _assert_msg_(KERNEL, (object != NULL), "called handle=0x%08X, but kernel object " "is NULL!", handles[i]); DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName(), @@ -278,7 +278,7 @@ Result CreateMutex(void* _mutex, u32 initial_locked) { /// Release a mutex Result ReleaseMutex(Handle handle) { DEBUG_LOG(SVC, "called handle=0x%08X", handle); - _assert_msg_(KERNEL, handle, "called, but handle is NULL!"); + _assert_msg_(KERNEL, (handle != 0), "called, but handle is NULL!"); Kernel::ReleaseMutex(handle); return 0; } -- cgit v1.2.3 From c95972275e276abe3afcac79d956ea29a0879c8e Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 6 Jun 2014 00:35:49 -0400 Subject: HLE: Updated all uses of NULL to nullptr (to be C++11 compliant) --- src/core/hle/svc.cpp | 214 +++++++++++++++++++++++++-------------------------- 1 file changed, 107 insertions(+), 107 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index c389bbaac..01fc056a1 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -81,7 +81,7 @@ Result ConnectToPort(void* _out, const char* port_name) { Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); DEBUG_LOG(SVC, "called port_name=%s", port_name); - _assert_msg_(KERNEL, (service != NULL), "called, but service is not implemented!"); + _assert_msg_(KERNEL, (service != nullptr), "called, but service is not implemented!"); *out = service->GetHandle(); @@ -93,7 +93,7 @@ Result SendSyncRequest(Handle handle) { bool wait = false; Kernel::Object* object = Kernel::g_object_pool.GetFast(handle); - _assert_msg_(KERNEL, (object != NULL), "called, but kernel object is NULL!"); + _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!"); DEBUG_LOG(SVC, "called handle=0x%08X(%s)", handle, object->GetTypeName()); Result res = object->SyncRequest(&wait); @@ -122,7 +122,7 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) { DEBUG_LOG(SVC, "called handle=0x%08X(%s:%s), nanoseconds=%d", handle, object->GetTypeName(), object->GetName(), nano_seconds); - _assert_msg_(KERNEL, (object != NULL), "called, but kernel object is NULL!"); + _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!"); Result res = object->WaitSynchronization(&wait); @@ -152,8 +152,8 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa bool wait = false; Kernel::Object* object = Kernel::g_object_pool.GetFast(handles[i]); - _assert_msg_(KERNEL, (object != NULL), "called handle=0x%08X, but kernel object " - "is NULL!", handles[i]); + _assert_msg_(KERNEL, (object != nullptr), "called handle=0x%08X, but kernel object " + "is nullptr!", handles[i]); DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName(), object->GetName()); @@ -278,7 +278,7 @@ Result CreateMutex(void* _mutex, u32 initial_locked) { /// Release a mutex Result ReleaseMutex(Handle handle) { DEBUG_LOG(SVC, "called handle=0x%08X", handle); - _assert_msg_(KERNEL, (handle != 0), "called, but handle is NULL!"); + _assert_msg_(KERNEL, (handle != 0), "called, but handle is nullptr!"); Kernel::ReleaseMutex(handle); return 0; } @@ -342,132 +342,132 @@ void SleepThread(s64 nanoseconds) { } const HLE::FunctionDef SVC_Table[] = { - {0x00, NULL, "Unknown"}, + {0x00, nullptr, "Unknown"}, {0x01, WrapI_VUUUUU, "ControlMemory"}, {0x02, WrapI_VVU, "QueryMemory"}, - {0x03, NULL, "ExitProcess"}, - {0x04, NULL, "GetProcessAffinityMask"}, - {0x05, NULL, "SetProcessAffinityMask"}, - {0x06, NULL, "GetProcessIdealProcessor"}, - {0x07, NULL, "SetProcessIdealProcessor"}, + {0x03, nullptr, "ExitProcess"}, + {0x04, nullptr, "GetProcessAffinityMask"}, + {0x05, nullptr, "SetProcessAffinityMask"}, + {0x06, nullptr, "GetProcessIdealProcessor"}, + {0x07, nullptr, "SetProcessIdealProcessor"}, {0x08, WrapI_UUUUU, "CreateThread"}, {0x09, WrapU_V, "ExitThread"}, {0x0A, WrapV_S64, "SleepThread"}, {0x0B, WrapI_VU, "GetThreadPriority"}, {0x0C, WrapI_UI, "SetThreadPriority"}, - {0x0D, NULL, "GetThreadAffinityMask"}, - {0x0E, NULL, "SetThreadAffinityMask"}, - {0x0F, NULL, "GetThreadIdealProcessor"}, - {0x10, NULL, "SetThreadIdealProcessor"}, - {0x11, NULL, "GetCurrentProcessorNumber"}, - {0x12, NULL, "Run"}, + {0x0D, nullptr, "GetThreadAffinityMask"}, + {0x0E, nullptr, "SetThreadAffinityMask"}, + {0x0F, nullptr, "GetThreadIdealProcessor"}, + {0x10, nullptr, "SetThreadIdealProcessor"}, + {0x11, nullptr, "GetCurrentProcessorNumber"}, + {0x12, nullptr, "Run"}, {0x13, WrapI_VU, "CreateMutex"}, {0x14, WrapI_U, "ReleaseMutex"}, - {0x15, NULL, "CreateSemaphore"}, - {0x16, NULL, "ReleaseSemaphore"}, + {0x15, nullptr, "CreateSemaphore"}, + {0x16, nullptr, "ReleaseSemaphore"}, {0x17, WrapI_VU, "CreateEvent"}, {0x18, WrapI_U, "SignalEvent"}, {0x19, WrapI_U, "ClearEvent"}, - {0x1A, NULL, "CreateTimer"}, - {0x1B, NULL, "SetTimer"}, - {0x1C, NULL, "CancelTimer"}, - {0x1D, NULL, "ClearTimer"}, - {0x1E, NULL, "CreateMemoryBlock"}, + {0x1A, nullptr, "CreateTimer"}, + {0x1B, nullptr, "SetTimer"}, + {0x1C, nullptr, "CancelTimer"}, + {0x1D, nullptr, "ClearTimer"}, + {0x1E, nullptr, "CreateMemoryBlock"}, {0x1F, WrapI_UUUU, "MapMemoryBlock"}, - {0x20, NULL, "UnmapMemoryBlock"}, + {0x20, nullptr, "UnmapMemoryBlock"}, {0x21, WrapI_V, "CreateAddressArbiter"}, {0x22, WrapI_UUUUS64, "ArbitrateAddress"}, {0x23, WrapI_U, "CloseHandle"}, {0x24, WrapI_US64, "WaitSynchronization1"}, {0x25, WrapI_VVUUS64, "WaitSynchronizationN"}, - {0x26, NULL, "SignalAndWait"}, + {0x26, nullptr, "SignalAndWait"}, {0x27, WrapI_VU, "DuplicateHandle"}, - {0x28, NULL, "GetSystemTick"}, - {0x29, NULL, "GetHandleInfo"}, - {0x2A, NULL, "GetSystemInfo"}, - {0x2B, NULL, "GetProcessInfo"}, - {0x2C, NULL, "GetThreadInfo"}, + {0x28, nullptr, "GetSystemTick"}, + {0x29, nullptr, "GetHandleInfo"}, + {0x2A, nullptr, "GetSystemInfo"}, + {0x2B, nullptr, "GetProcessInfo"}, + {0x2C, nullptr, "GetThreadInfo"}, {0x2D, WrapI_VC, "ConnectToPort"}, - {0x2E, NULL, "SendSyncRequest1"}, - {0x2F, NULL, "SendSyncRequest2"}, - {0x30, NULL, "SendSyncRequest3"}, - {0x31, NULL, "SendSyncRequest4"}, + {0x2E, nullptr, "SendSyncRequest1"}, + {0x2F, nullptr, "SendSyncRequest2"}, + {0x30, nullptr, "SendSyncRequest3"}, + {0x31, nullptr, "SendSyncRequest4"}, {0x32, WrapI_U, "SendSyncRequest"}, - {0x33, NULL, "OpenProcess"}, - {0x34, NULL, "OpenThread"}, - {0x35, NULL, "GetProcessId"}, - {0x36, NULL, "GetProcessIdOfThread"}, + {0x33, nullptr, "OpenProcess"}, + {0x34, nullptr, "OpenThread"}, + {0x35, nullptr, "GetProcessId"}, + {0x36, nullptr, "GetProcessIdOfThread"}, {0x37, WrapI_VU, "GetThreadId"}, {0x38, WrapI_VU, "GetResourceLimit"}, - {0x39, NULL, "GetResourceLimitLimitValues"}, + {0x39, nullptr, "GetResourceLimitLimitValues"}, {0x3A, WrapI_VUVI, "GetResourceLimitCurrentValues"}, - {0x3B, NULL, "GetThreadContext"}, - {0x3C, NULL, "Break"}, + {0x3B, nullptr, "GetThreadContext"}, + {0x3C, nullptr, "Break"}, {0x3D, WrapV_C, "OutputDebugString"}, - {0x3E, NULL, "ControlPerformanceCounter"}, - {0x3F, NULL, "Unknown"}, - {0x40, NULL, "Unknown"}, - {0x41, NULL, "Unknown"}, - {0x42, NULL, "Unknown"}, - {0x43, NULL, "Unknown"}, - {0x44, NULL, "Unknown"}, - {0x45, NULL, "Unknown"}, - {0x46, NULL, "Unknown"}, - {0x47, NULL, "CreatePort"}, - {0x48, NULL, "CreateSessionToPort"}, - {0x49, NULL, "CreateSession"}, - {0x4A, NULL, "AcceptSession"}, - {0x4B, NULL, "ReplyAndReceive1"}, - {0x4C, NULL, "ReplyAndReceive2"}, - {0x4D, NULL, "ReplyAndReceive3"}, - {0x4E, NULL, "ReplyAndReceive4"}, - {0x4F, NULL, "ReplyAndReceive"}, - {0x50, NULL, "BindInterrupt"}, - {0x51, NULL, "UnbindInterrupt"}, - {0x52, NULL, "InvalidateProcessDataCache"}, - {0x53, NULL, "StoreProcessDataCache"}, - {0x54, NULL, "FlushProcessDataCache"}, - {0x55, NULL, "StartInterProcessDma"}, - {0x56, NULL, "StopDma"}, - {0x57, NULL, "GetDmaState"}, - {0x58, NULL, "RestartDma"}, - {0x59, NULL, "Unknown"}, - {0x5A, NULL, "Unknown"}, - {0x5B, NULL, "Unknown"}, - {0x5C, NULL, "Unknown"}, - {0x5D, NULL, "Unknown"}, - {0x5E, NULL, "Unknown"}, - {0x5F, NULL, "Unknown"}, - {0x60, NULL, "DebugActiveProcess"}, - {0x61, NULL, "BreakDebugProcess"}, - {0x62, NULL, "TerminateDebugProcess"}, - {0x63, NULL, "GetProcessDebugEvent"}, - {0x64, NULL, "ContinueDebugEvent"}, - {0x65, NULL, "GetProcessList"}, - {0x66, NULL, "GetThreadList"}, - {0x67, NULL, "GetDebugThreadContext"}, - {0x68, NULL, "SetDebugThreadContext"}, - {0x69, NULL, "QueryDebugProcessMemory"}, - {0x6A, NULL, "ReadProcessMemory"}, - {0x6B, NULL, "WriteProcessMemory"}, - {0x6C, NULL, "SetHardwareBreakPoint"}, - {0x6D, NULL, "GetDebugThreadParam"}, - {0x6E, NULL, "Unknown"}, - {0x6F, NULL, "Unknown"}, - {0x70, NULL, "ControlProcessMemory"}, - {0x71, NULL, "MapProcessMemory"}, - {0x72, NULL, "UnmapProcessMemory"}, - {0x73, NULL, "Unknown"}, - {0x74, NULL, "Unknown"}, - {0x75, NULL, "Unknown"}, - {0x76, NULL, "TerminateProcess"}, - {0x77, NULL, "Unknown"}, - {0x78, NULL, "CreateResourceLimit"}, - {0x79, NULL, "Unknown"}, - {0x7A, NULL, "Unknown"}, - {0x7B, NULL, "Unknown"}, - {0x7C, NULL, "KernelSetState"}, - {0x7D, NULL, "QueryProcessMemory"}, + {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() { -- cgit v1.2.3 From 4d6c96b7d8d77b87fcc137aa03cd6a4e4313bdc7 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 6 Jun 2014 00:44:44 -0400 Subject: SVC: Moved declaration of "wait" variable in SendSyncRequest for improved readability. --- src/core/hle/svc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 01fc056a1..76c6a0771 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -90,12 +90,12 @@ Result ConnectToPort(void* _out, const char* port_name) { /// Synchronize to an OS service Result SendSyncRequest(Handle handle) { - bool wait = false; Kernel::Object* object = Kernel::g_object_pool.GetFast(handle); _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!"); DEBUG_LOG(SVC, "called handle=0x%08X(%s)", handle, object->GetTypeName()); + bool wait = false; Result res = object->SyncRequest(&wait); if (wait) { Kernel::WaitCurrentThread(WAITTYPE_SYNCH); // TODO(bunnei): Is this correct? -- cgit v1.2.3 From 862db811f02f8d28c4537a6be7b6a8f6c8fec812 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 6 Jun 2014 23:31:29 -0400 Subject: SVC: Cleaned up function wrappers to pass in correct argument types. --- src/core/hle/svc.cpp | 286 +++++++++++++++++++++++++-------------------------- 1 file changed, 138 insertions(+), 148 deletions(-) (limited to 'src/core/hle/svc.cpp') 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(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"}, - {0x02, WrapI_VVU, "QueryMemory"}, - {0x03, nullptr, "ExitProcess"}, - {0x04, nullptr, "GetProcessAffinityMask"}, - {0x05, nullptr, "SetProcessAffinityMask"}, - {0x06, nullptr, "GetProcessIdealProcessor"}, - {0x07, nullptr, "SetProcessIdealProcessor"}, - {0x08, WrapI_UUUUU, "CreateThread"}, - {0x09, WrapU_V, "ExitThread"}, - {0x0A, WrapV_S64, "SleepThread"}, - {0x0B, WrapI_VU, "GetThreadPriority"}, - {0x0C, WrapI_UI, "SetThreadPriority"}, - {0x0D, nullptr, "GetThreadAffinityMask"}, - {0x0E, nullptr, "SetThreadAffinityMask"}, - {0x0F, nullptr, "GetThreadIdealProcessor"}, - {0x10, nullptr, "SetThreadIdealProcessor"}, - {0x11, nullptr, "GetCurrentProcessorNumber"}, - {0x12, nullptr, "Run"}, - {0x13, WrapI_VU, "CreateMutex"}, - {0x14, WrapI_U, "ReleaseMutex"}, - {0x15, nullptr, "CreateSemaphore"}, - {0x16, nullptr, "ReleaseSemaphore"}, - {0x17, WrapI_VU, "CreateEvent"}, - {0x18, WrapI_U, "SignalEvent"}, - {0x19, WrapI_U, "ClearEvent"}, - {0x1A, nullptr, "CreateTimer"}, - {0x1B, nullptr, "SetTimer"}, - {0x1C, nullptr, "CancelTimer"}, - {0x1D, nullptr, "ClearTimer"}, - {0x1E, nullptr, "CreateMemoryBlock"}, - {0x1F, WrapI_UUUU, "MapMemoryBlock"}, - {0x20, nullptr, "UnmapMemoryBlock"}, - {0x21, WrapI_V, "CreateAddressArbiter"}, - {0x22, WrapI_UUUUS64, "ArbitrateAddress"}, - {0x23, WrapI_U, "CloseHandle"}, - {0x24, WrapI_US64, "WaitSynchronization1"}, - {0x25, WrapI_VVUUS64, "WaitSynchronizationN"}, - {0x26, nullptr, "SignalAndWait"}, - {0x27, WrapI_VU, "DuplicateHandle"}, - {0x28, nullptr, "GetSystemTick"}, - {0x29, nullptr, "GetHandleInfo"}, - {0x2A, nullptr, "GetSystemInfo"}, - {0x2B, nullptr, "GetProcessInfo"}, - {0x2C, nullptr, "GetThreadInfo"}, - {0x2D, WrapI_VC, "ConnectToPort"}, - {0x2E, nullptr, "SendSyncRequest1"}, - {0x2F, nullptr, "SendSyncRequest2"}, - {0x30, nullptr, "SendSyncRequest3"}, - {0x31, nullptr, "SendSyncRequest4"}, - {0x32, WrapI_U, "SendSyncRequest"}, - {0x33, nullptr, "OpenProcess"}, - {0x34, nullptr, "OpenThread"}, - {0x35, nullptr, "GetProcessId"}, - {0x36, nullptr, "GetProcessIdOfThread"}, - {0x37, WrapI_VU, "GetThreadId"}, - {0x38, WrapI_VU, "GetResourceLimit"}, - {0x39, nullptr, "GetResourceLimitLimitValues"}, - {0x3A, WrapI_VUVI, "GetResourceLimitCurrentValues"}, - {0x3B, nullptr, "GetThreadContext"}, - {0x3C, nullptr, "Break"}, - {0x3D, WrapV_C, "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"}, + {0x02, Wrap::S32::VoidP_VoidP_U32, "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"}, + {0x09, Wrap::U32::Void, "ExitThread"}, + {0x0A, Wrap::Void::S64, "SleepThread"}, + {0x0B, Wrap::S32::S32P_U32, "GetThreadPriority"}, + {0x0C, Wrap::S32::U32_S32, "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"}, + {0x14, Wrap::S32::U32, "ReleaseMutex"}, + {0x15, nullptr, "CreateSemaphore"}, + {0x16, nullptr, "ReleaseSemaphore"}, + {0x17, Wrap::S32::U32P_U32, "CreateEvent"}, + {0x18, Wrap::S32::U32, "SignalEvent"}, + {0x19, Wrap::S32::U32, "ClearEvent"}, + {0x1A, nullptr, "CreateTimer"}, + {0x1B, nullptr, "SetTimer"}, + {0x1C, nullptr, "CancelTimer"}, + {0x1D, nullptr, "ClearTimer"}, + {0x1E, nullptr, "CreateMemoryBlock"}, + {0x1F, Wrap::S32::U32_U32_U32_U32, "MapMemoryBlock"}, + {0x20, nullptr, "UnmapMemoryBlock"}, + {0x21, Wrap::S32::U32P, "CreateAddressArbiter"}, + {0x22, Wrap::S32::U32_U32_U32_U32_S64, "ArbitrateAddress"}, + {0x23, Wrap::S32::U32, "CloseHandle"}, + {0x24, Wrap::S32::U32_S64, "WaitSynchronization1"}, + {0x25, Wrap::S32::S32P_U32P_S32_Bool_S64, "WaitSynchronizationN"}, + {0x26, nullptr, "SignalAndWait"}, + {0x27, Wrap::S32::U32P_U32, "DuplicateHandle"}, + {0x28, nullptr, "GetSystemTick"}, + {0x29, nullptr, "GetHandleInfo"}, + {0x2A, nullptr, "GetSystemInfo"}, + {0x2B, nullptr, "GetProcessInfo"}, + {0x2C, nullptr, "GetThreadInfo"}, + {0x2D, Wrap::S32::U32P_CharP, "ConnectToPort"}, + {0x2E, nullptr, "SendSyncRequest1"}, + {0x2F, nullptr, "SendSyncRequest2"}, + {0x30, nullptr, "SendSyncRequest3"}, + {0x31, nullptr, "SendSyncRequest4"}, + {0x32, Wrap::S32::U32, "SendSyncRequest"}, + {0x33, nullptr, "OpenProcess"}, + {0x34, nullptr, "OpenThread"}, + {0x35, nullptr, "GetProcessId"}, + {0x36, nullptr, "GetProcessIdOfThread"}, + {0x37, Wrap::S32::U32P_U32, "GetThreadId"}, + {0x38, Wrap::S32::U32P_U32, "GetResourceLimit"}, + {0x39, nullptr, "GetResourceLimitLimitValues"}, + {0x3A, Wrap::S32::S64P_U32_VoidP_S32, "GetResourceLimitCurrentValues"}, + {0x3B, nullptr, "GetThreadContext"}, + {0x3C, nullptr, "Break"}, + {0x3D, Wrap::Void::CharP, "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() { -- cgit v1.2.3 From 8957622d10784d5f04571e9ae01dbae13ed64c3e Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 9 Jun 2014 22:30:39 -0400 Subject: SVC: Renamed all function wrapper templates to Wrap, moved to HLE namespace. --- src/core/hle/svc.cpp | 252 +++++++++++++++++++++++++-------------------------- 1 file changed, 126 insertions(+), 126 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index d964d062e..441d8ce8d 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -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"}, - {0x02, Wrap::S32::VoidP_VoidP_U32, "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"}, - {0x09, Wrap::U32::Void, "ExitThread"}, - {0x0A, Wrap::Void::S64, "SleepThread"}, - {0x0B, Wrap::S32::S32P_U32, "GetThreadPriority"}, - {0x0C, Wrap::S32::U32_S32, "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"}, - {0x14, Wrap::S32::U32, "ReleaseMutex"}, - {0x15, nullptr, "CreateSemaphore"}, - {0x16, nullptr, "ReleaseSemaphore"}, - {0x17, Wrap::S32::U32P_U32, "CreateEvent"}, - {0x18, Wrap::S32::U32, "SignalEvent"}, - {0x19, Wrap::S32::U32, "ClearEvent"}, - {0x1A, nullptr, "CreateTimer"}, - {0x1B, nullptr, "SetTimer"}, - {0x1C, nullptr, "CancelTimer"}, - {0x1D, nullptr, "ClearTimer"}, - {0x1E, nullptr, "CreateMemoryBlock"}, - {0x1F, Wrap::S32::U32_U32_U32_U32, "MapMemoryBlock"}, - {0x20, nullptr, "UnmapMemoryBlock"}, - {0x21, Wrap::S32::U32P, "CreateAddressArbiter"}, - {0x22, Wrap::S32::U32_U32_U32_U32_S64, "ArbitrateAddress"}, - {0x23, Wrap::S32::U32, "CloseHandle"}, - {0x24, Wrap::S32::U32_S64, "WaitSynchronization1"}, - {0x25, Wrap::S32::S32P_U32P_S32_Bool_S64, "WaitSynchronizationN"}, - {0x26, nullptr, "SignalAndWait"}, - {0x27, Wrap::S32::U32P_U32, "DuplicateHandle"}, - {0x28, nullptr, "GetSystemTick"}, - {0x29, nullptr, "GetHandleInfo"}, - {0x2A, nullptr, "GetSystemInfo"}, - {0x2B, nullptr, "GetProcessInfo"}, - {0x2C, nullptr, "GetThreadInfo"}, - {0x2D, Wrap::S32::U32P_CharP, "ConnectToPort"}, - {0x2E, nullptr, "SendSyncRequest1"}, - {0x2F, nullptr, "SendSyncRequest2"}, - {0x30, nullptr, "SendSyncRequest3"}, - {0x31, nullptr, "SendSyncRequest4"}, - {0x32, Wrap::S32::U32, "SendSyncRequest"}, - {0x33, nullptr, "OpenProcess"}, - {0x34, nullptr, "OpenThread"}, - {0x35, nullptr, "GetProcessId"}, - {0x36, nullptr, "GetProcessIdOfThread"}, - {0x37, Wrap::S32::U32P_U32, "GetThreadId"}, - {0x38, Wrap::S32::U32P_U32, "GetResourceLimit"}, - {0x39, nullptr, "GetResourceLimitLimitValues"}, - {0x3A, Wrap::S32::S64P_U32_VoidP_S32, "GetResourceLimitCurrentValues"}, - {0x3B, nullptr, "GetThreadContext"}, - {0x3C, nullptr, "Break"}, - {0x3D, Wrap::Void::CharP, "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"}, + {0x02, HLE::Wrap, "QueryMemory"}, + {0x03, nullptr, "ExitProcess"}, + {0x04, nullptr, "GetProcessAffinityMask"}, + {0x05, nullptr, "SetProcessAffinityMask"}, + {0x06, nullptr, "GetProcessIdealProcessor"}, + {0x07, nullptr, "SetProcessIdealProcessor"}, + {0x08, HLE::Wrap, "CreateThread"}, + {0x09, HLE::Wrap, "ExitThread"}, + {0x0A, HLE::Wrap, "SleepThread"}, + {0x0B, HLE::Wrap, "GetThreadPriority"}, + {0x0C, HLE::Wrap, "SetThreadPriority"}, + {0x0D, nullptr, "GetThreadAffinityMask"}, + {0x0E, nullptr, "SetThreadAffinityMask"}, + {0x0F, nullptr, "GetThreadIdealProcessor"}, + {0x10, nullptr, "SetThreadIdealProcessor"}, + {0x11, nullptr, "GetCurrentProcessorNumber"}, + {0x12, nullptr, "Run"}, + {0x13, HLE::Wrap, "CreateMutex"}, + {0x14, HLE::Wrap, "ReleaseMutex"}, + {0x15, nullptr, "CreateSemaphore"}, + {0x16, nullptr, "ReleaseSemaphore"}, + {0x17, HLE::Wrap, "CreateEvent"}, + {0x18, HLE::Wrap, "SignalEvent"}, + {0x19, HLE::Wrap, "ClearEvent"}, + {0x1A, nullptr, "CreateTimer"}, + {0x1B, nullptr, "SetTimer"}, + {0x1C, nullptr, "CancelTimer"}, + {0x1D, nullptr, "ClearTimer"}, + {0x1E, nullptr, "CreateMemoryBlock"}, + {0x1F, HLE::Wrap, "MapMemoryBlock"}, + {0x20, nullptr, "UnmapMemoryBlock"}, + {0x21, HLE::Wrap, "CreateAddressArbiter"}, + {0x22, HLE::Wrap, "ArbitrateAddress"}, + {0x23, HLE::Wrap, "CloseHandle"}, + {0x24, HLE::Wrap, "WaitSynchronization1"}, + {0x25, HLE::Wrap, "WaitSynchronizationN"}, + {0x26, nullptr, "SignalAndWait"}, + {0x27, HLE::Wrap, "DuplicateHandle"}, + {0x28, nullptr, "GetSystemTick"}, + {0x29, nullptr, "GetHandleInfo"}, + {0x2A, nullptr, "GetSystemInfo"}, + {0x2B, nullptr, "GetProcessInfo"}, + {0x2C, nullptr, "GetThreadInfo"}, + {0x2D, HLE::Wrap, "ConnectToPort"}, + {0x2E, nullptr, "SendSyncRequest1"}, + {0x2F, nullptr, "SendSyncRequest2"}, + {0x30, nullptr, "SendSyncRequest3"}, + {0x31, nullptr, "SendSyncRequest4"}, + {0x32, HLE::Wrap, "SendSyncRequest"}, + {0x33, nullptr, "OpenProcess"}, + {0x34, nullptr, "OpenThread"}, + {0x35, nullptr, "GetProcessId"}, + {0x36, nullptr, "GetProcessIdOfThread"}, + {0x37, HLE::Wrap, "GetThreadId"}, + {0x38, HLE::Wrap, "GetResourceLimit"}, + {0x39, nullptr, "GetResourceLimitLimitValues"}, + {0x3A, HLE::Wrap, "GetResourceLimitCurrentValues"}, + {0x3B, nullptr, "GetThreadContext"}, + {0x3C, nullptr, "Break"}, + {0x3D, HLE::Wrap, "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() { -- cgit v1.2.3