From 289ba7104e988d4e9feeb29a40b233a21440b94d Mon Sep 17 00:00:00 2001 From: Alula Date: Tue, 15 Sep 2026 16:57:27 +0200 Subject: [PATCH] kern: add new unknown DebugThreadParam --- libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp | 4 ++++ libraries/libmesosphere/source/kern_k_process.cpp | 3 +++ libraries/libmesosphere/source/svc/kern_svc_debug.cpp | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp index 8904a6a92..7e294473c 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp @@ -341,6 +341,7 @@ namespace ams::kern { bool m_debug_attached; s8 m_priority_inheritance_count; bool m_resource_limit_release_hint; + bool m_debug_unknown5; public: constexpr explicit KThread(util::ConstantInitializeTag) : KAutoObjectWithSlabHeapAndContainer(util::ConstantInitialize), KTimerTask(util::ConstantInitialize), @@ -683,6 +684,9 @@ namespace ams::kern { constexpr void SetDebugAttached() { m_debug_attached = true; } constexpr bool IsAttachedToDebugger() const { return m_debug_attached; } + constexpr void SetDebugUnknown5(bool value) { m_debug_unknown5 = value; } + constexpr bool IsDebugUnknown5() const { return m_debug_unknown5; } + void AddCpuTime(s32 core_id, s64 amount) { m_cpu_time += amount; /* TODO: Debug kernels track per-core tick counts. Should we? */ diff --git a/libraries/libmesosphere/source/kern_k_process.cpp b/libraries/libmesosphere/source/kern_k_process.cpp index 91048f4f6..7d1b0d0f4 100644 --- a/libraries/libmesosphere/source/kern_k_process.cpp +++ b/libraries/libmesosphere/source/kern_k_process.cpp @@ -970,6 +970,9 @@ namespace ams::kern { /* Initialize the thread. */ R_TRY(KThread::InitializeUserThread(main_thread, reinterpret_cast(GetVoidPointer(this->GetEntryPoint())), 0, stack_top, priority, m_ideal_core_id, this)); + /* TODO: what is this? */ + main_thread->SetDebugUnknown5(true); + /* Register the thread, and commit our reservation. */ KThread::Register(main_thread); thread_reservation.Commit(); diff --git a/libraries/libmesosphere/source/svc/kern_svc_debug.cpp b/libraries/libmesosphere/source/svc/kern_svc_debug.cpp index 986654ce4..635b91cbe 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_debug.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_debug.cpp @@ -429,6 +429,11 @@ namespace ams::kern::svc { *out_32 = affinity_mask; } break; + case ams::svc::DebugThreadParam_Unknown5: + { + *out_32 = thread->IsDebugUnknown5(); + } + break; default: R_THROW(ams::svc::ResultInvalidEnumValue()); }