diff options
| author | 2017-10-23 00:15:45 -0400 | |
|---|---|---|
| committer | 2017-10-23 00:15:45 -0400 | |
| commit | 266c1c802039548b5dc242c8c2312289918b323f (patch) | |
| tree | ee3ee186beac0bbbbb7e78d087142d551828fec7 /src | |
| parent | logging: Rename category "Core_ARM11" to "Core_ARM". (diff) | |
| download | yuzu-266c1c802039548b5dc242c8c2312289918b323f.tar.gz yuzu-266c1c802039548b5dc242c8c2312289918b323f.tar.xz yuzu-266c1c802039548b5dc242c8c2312289918b323f.zip | |
svc: Implement GetThreadId and GetProcessId.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/function_wrappers.h | 8 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 31 |
2 files changed, 37 insertions, 2 deletions
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h index 3e886fdba..abc2b96a8 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/function_wrappers.h | |||
| @@ -161,6 +161,14 @@ void Wrap() { | |||
| 161 | FuncReturn(retval); | 161 | FuncReturn(retval); |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | template <ResultCode func(u32*, Kernel::Handle)> | ||
| 165 | void Wrap() { | ||
| 166 | u32 param_1 = 0; | ||
| 167 | u32 retval = func(¶m_1, PARAM(1)).raw; | ||
| 168 | Core::CPU().SetReg(1, param_1); | ||
| 169 | FuncReturn(retval); | ||
| 170 | } | ||
| 171 | |||
| 164 | template <ResultCode func(u32)> | 172 | template <ResultCode func(u32)> |
| 165 | void Wrap() { | 173 | void Wrap() { |
| 166 | FuncReturn(func(PARAM(0)).raw); | 174 | FuncReturn(func(PARAM(0)).raw); |
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 0401f763b..4b5c1dff3 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -71,6 +71,33 @@ static ResultCode SendSyncRequest(Kernel::Handle handle) { | |||
| 71 | return session->SendSyncRequest(Kernel::GetCurrentThread()); | 71 | return session->SendSyncRequest(Kernel::GetCurrentThread()); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | /// Get the ID for the specified thread. | ||
| 75 | static ResultCode GetThreadId(u32* thread_id, Kernel::Handle handle) { | ||
| 76 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); | ||
| 77 | |||
| 78 | const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); | ||
| 79 | if (thread == nullptr) { | ||
| 80 | return ERR_INVALID_HANDLE; | ||
| 81 | } | ||
| 82 | |||
| 83 | *thread_id = thread->GetThreadId(); | ||
| 84 | return RESULT_SUCCESS; | ||
| 85 | } | ||
| 86 | |||
| 87 | /// Get the ID of the specified process | ||
| 88 | static ResultCode GetProcessId(u32* process_id, Kernel::Handle process_handle) { | ||
| 89 | LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); | ||
| 90 | |||
| 91 | const SharedPtr<Kernel::Process> process = | ||
| 92 | Kernel::g_handle_table.Get<Kernel::Process>(process_handle); | ||
| 93 | if (process == nullptr) { | ||
| 94 | return ERR_INVALID_HANDLE; | ||
| 95 | } | ||
| 96 | |||
| 97 | *process_id = process->process_id; | ||
| 98 | return RESULT_SUCCESS; | ||
| 99 | } | ||
| 100 | |||
| 74 | /// Break program execution | 101 | /// Break program execution |
| 75 | static void Break(u64 unk_0, u64 unk_1, u64 unk_2) { | 102 | static void Break(u64 unk_0, u64 unk_1, u64 unk_2) { |
| 76 | LOG_CRITICAL(Debug_Emulated, "Emulated program broke execution!"); | 103 | LOG_CRITICAL(Debug_Emulated, "Emulated program broke execution!"); |
| @@ -213,8 +240,8 @@ static const FunctionDef SVC_Table[] = { | |||
| 213 | {0x21, HLE::Wrap<SendSyncRequest>, "svcSendSyncRequest"}, | 240 | {0x21, HLE::Wrap<SendSyncRequest>, "svcSendSyncRequest"}, |
| 214 | {0x22, nullptr, "svcSendSyncRequestWithUserBuffer"}, | 241 | {0x22, nullptr, "svcSendSyncRequestWithUserBuffer"}, |
| 215 | {0x23, nullptr, "svcSendAsyncRequestWithUserBuffer"}, | 242 | {0x23, nullptr, "svcSendAsyncRequestWithUserBuffer"}, |
| 216 | {0x24, nullptr, "svcGetProcessId"}, | 243 | {0x24, HLE::Wrap<GetProcessId>, "svcGetProcessId"}, |
| 217 | {0x25, nullptr, "svcGetThreadId"}, | 244 | {0x25, HLE::Wrap<GetThreadId>, "svcGetThreadId"}, |
| 218 | {0x26, HLE::Wrap<Break>, "svcBreak"}, | 245 | {0x26, HLE::Wrap<Break>, "svcBreak"}, |
| 219 | {0x27, HLE::Wrap<OutputDebugString>, "svcOutputDebugString"}, | 246 | {0x27, HLE::Wrap<OutputDebugString>, "svcOutputDebugString"}, |
| 220 | {0x28, nullptr, "svcReturnFromException"}, | 247 | {0x28, nullptr, "svcReturnFromException"}, |