From f6893969b38112a96e92f3a5f8779c4854c95365 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Thu, 29 Mar 2018 21:07:49 -0400
Subject: [PATCH] svc: Stub GetThreadCoreMask.

---
 src/core/hle/kernel/svc.cpp    | 14 +++++++++++---
 src/core/hle/kernel/svc_wrap.h | 15 +++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 311ab4187..171bbd956 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -756,8 +756,16 @@ static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32
     return RESULT_SUCCESS;
 }
 
-static ResultCode SetThreadCoreMask(u64, u64, u64) {
-    LOG_WARNING(Kernel_SVC, "(STUBBED) called");
+static ResultCode GetThreadCoreMask(Handle handle, u32* mask, u64* unknown) {
+    LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x%08X", handle);
+    *mask = 0x0;
+    *unknown = 0xf;
+    return RESULT_SUCCESS;
+}
+
+static ResultCode SetThreadCoreMask(Handle handle, u32 mask, u64 unknown) {
+    LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x%08X, mask=0x%08X, unknown=0x%lx", handle,
+                mask, unknown);
     return RESULT_SUCCESS;
 }
 
@@ -809,7 +817,7 @@ static const FunctionDef SVC_Table[] = {
     {0x0B, SvcWrap<SleepThread>, "SleepThread"},
     {0x0C, SvcWrap<GetThreadPriority>, "GetThreadPriority"},
     {0x0D, SvcWrap<SetThreadPriority>, "SetThreadPriority"},
-    {0x0E, nullptr, "GetThreadCoreMask"},
+    {0x0E, SvcWrap<GetThreadCoreMask>, "GetThreadCoreMask"},
     {0x0F, SvcWrap<SetThreadCoreMask>, "SetThreadCoreMask"},
     {0x10, SvcWrap<GetCurrentProcessorNumber>, "GetCurrentProcessorNumber"},
     {0x11, nullptr, "SignalEvent"},
diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h
index b224f5e67..5da4f5269 100644
--- a/src/core/hle/kernel/svc_wrap.h
+++ b/src/core/hle/kernel/svc_wrap.h
@@ -70,6 +70,21 @@ void SvcWrap() {
     FuncReturn(retval);
 }
 
+template <ResultCode func(u32, u32, u64)>
+void SvcWrap() {
+    FuncReturn(func((u32)(PARAM(0) & 0xFFFFFFFF), (u32)(PARAM(1) & 0xFFFFFFFF), PARAM(2)).raw);
+}
+
+template <ResultCode func(u32, u32*, u64*)>
+void SvcWrap() {
+    u32 param_1 = 0;
+    u64 param_2 = 0;
+    ResultCode retval = func((u32)(PARAM(2) & 0xFFFFFFFF), &param_1, &param_2);
+    Core::CPU().SetReg(1, param_1);
+    Core::CPU().SetReg(2, param_2);
+    FuncReturn(retval.raw);
+}
+
 template <ResultCode func(u64, u64, u32, u32)>
 void SvcWrap() {
     FuncReturn(