From 1430f1c4c2839485440ef0494ad2cd72640885a0 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Tue, 2 Jan 2024 17:18:47 +0200 Subject: [PATCH] Implement SVC 0x3B (GetThreadContext) --- include/kernel/kernel.hpp | 1 + src/core/kernel/kernel.cpp | 1 + src/core/kernel/threads.cpp | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/include/kernel/kernel.hpp b/include/kernel/kernel.hpp index 30f1310e7..3f09bf12f 100644 --- a/include/kernel/kernel.hpp +++ b/include/kernel/kernel.hpp @@ -146,6 +146,7 @@ class Kernel { void getResourceLimitCurrentValues(); void getSystemInfo(); void getSystemTick(); + void getThreadContext(); void getThreadID(); void getThreadIdealProcessor(); void getThreadPriority(); diff --git a/src/core/kernel/kernel.cpp b/src/core/kernel/kernel.cpp index 04af5096e..2e4fffff5 100644 --- a/src/core/kernel/kernel.cpp +++ b/src/core/kernel/kernel.cpp @@ -66,6 +66,7 @@ void Kernel::serviceSVC(u32 svc) { case 0x38: getResourceLimit(); break; case 0x39: getResourceLimitLimitValues(); break; case 0x3A: getResourceLimitCurrentValues(); break; + case 0x3B: getThreadContext(); break; case 0x3D: outputDebugString(); break; default: Helpers::panic("Unimplemented svc: %X @ %08X", svc, regs[15]); break; } diff --git a/src/core/kernel/threads.cpp b/src/core/kernel/threads.cpp index 5c21d5076..239a66176 100644 --- a/src/core/kernel/threads.cpp +++ b/src/core/kernel/threads.cpp @@ -462,6 +462,13 @@ void Kernel::getThreadIdealProcessor() { regs[1] = static_cast(ProcessorID::AppCore); } +void Kernel::getThreadContext() { + Helpers::warn("Stubbed Kernel::GetThreadContext"); + + // TODO: Decompile this from Kernel11. 3DBrew says function is stubbed. + regs[0] = Result::Success; +} + void Kernel::setThreadPriority() { const Handle handle = regs[0]; const u32 priority = regs[1];