summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2022-06-26 11:38:48 -0700
committerGravatar GitHub2022-06-26 11:38:48 -0700
commitabfd690601eaa567b60c5eb844a688fe85e7dcea (patch)
treebb7cc7e8746ffedb0f8ddf2ca82c19ae41f5c1be /src/core/hle/kernel/svc.cpp
parentMerge pull request #8500 from liamwhite/poke (diff)
parentkernel: make current thread pointer thread local (diff)
downloadyuzu-abfd690601eaa567b60c5eb844a688fe85e7dcea.tar.gz
yuzu-abfd690601eaa567b60c5eb844a688fe85e7dcea.tar.xz
yuzu-abfd690601eaa567b60c5eb844a688fe85e7dcea.zip
Merge pull request #8475 from liamwhite/x18
kernel: make current thread pointer thread local
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 2ff6d5fa6..2b34fc19d 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -327,7 +327,6 @@ static ResultCode SendSyncRequest(Core::System& system, Handle handle) {
327 327
328 LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName()); 328 LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName());
329 329
330 auto thread = kernel.CurrentScheduler()->GetCurrentThread();
331 { 330 {
332 KScopedSchedulerLock lock(kernel); 331 KScopedSchedulerLock lock(kernel);
333 332
@@ -337,7 +336,7 @@ static ResultCode SendSyncRequest(Core::System& system, Handle handle) {
337 session->SendSyncRequest(&GetCurrentThread(kernel), system.Memory(), system.CoreTiming()); 336 session->SendSyncRequest(&GetCurrentThread(kernel), system.Memory(), system.CoreTiming());
338 } 337 }
339 338
340 return thread->GetWaitResult(); 339 return GetCurrentThread(kernel).GetWaitResult();
341} 340}
342 341
343static ResultCode SendSyncRequest32(Core::System& system, Handle handle) { 342static ResultCode SendSyncRequest32(Core::System& system, Handle handle) {
@@ -624,7 +623,7 @@ static void Break(Core::System& system, u32 reason, u64 info1, u64 info2) {
624 623
625 handle_debug_buffer(info1, info2); 624 handle_debug_buffer(info1, info2);
626 625
627 auto* const current_thread = system.Kernel().CurrentScheduler()->GetCurrentThread(); 626 auto* const current_thread = GetCurrentThreadPointer(system.Kernel());
628 const auto thread_processor_id = current_thread->GetActiveCore(); 627 const auto thread_processor_id = current_thread->GetActiveCore();
629 system.ArmInterface(static_cast<std::size_t>(thread_processor_id)).LogBacktrace(); 628 system.ArmInterface(static_cast<std::size_t>(thread_processor_id)).LogBacktrace();
630 } 629 }
@@ -884,7 +883,7 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle
884 883
885 const auto& core_timing = system.CoreTiming(); 884 const auto& core_timing = system.CoreTiming();
886 const auto& scheduler = *system.Kernel().CurrentScheduler(); 885 const auto& scheduler = *system.Kernel().CurrentScheduler();
887 const auto* const current_thread = scheduler.GetCurrentThread(); 886 const auto* const current_thread = GetCurrentThreadPointer(system.Kernel());
888 const bool same_thread = current_thread == thread.GetPointerUnsafe(); 887 const bool same_thread = current_thread == thread.GetPointerUnsafe();
889 888
890 const u64 prev_ctx_ticks = scheduler.GetLastContextSwitchTicks(); 889 const u64 prev_ctx_ticks = scheduler.GetLastContextSwitchTicks();
@@ -1103,7 +1102,7 @@ static ResultCode GetThreadContext(Core::System& system, VAddr out_context, Hand
1103 if (thread->GetRawState() != ThreadState::Runnable) { 1102 if (thread->GetRawState() != ThreadState::Runnable) {
1104 bool current = false; 1103 bool current = false;
1105 for (auto i = 0; i < static_cast<s32>(Core::Hardware::NUM_CPU_CORES); ++i) { 1104 for (auto i = 0; i < static_cast<s32>(Core::Hardware::NUM_CPU_CORES); ++i) {
1106 if (thread.GetPointerUnsafe() == kernel.Scheduler(i).GetCurrentThread()) { 1105 if (thread.GetPointerUnsafe() == kernel.Scheduler(i).GetSchedulerCurrentThread()) {
1107 current = true; 1106 current = true;
1108 break; 1107 break;
1109 } 1108 }
@@ -1851,7 +1850,7 @@ static ResultCode StartThread32(Core::System& system, Handle thread_handle) {
1851static void ExitThread(Core::System& system) { 1850static void ExitThread(Core::System& system) {
1852 LOG_DEBUG(Kernel_SVC, "called, pc=0x{:08X}", system.CurrentArmInterface().GetPC()); 1851 LOG_DEBUG(Kernel_SVC, "called, pc=0x{:08X}", system.CurrentArmInterface().GetPC());
1853 1852
1854 auto* const current_thread = system.Kernel().CurrentScheduler()->GetCurrentThread(); 1853 auto* const current_thread = GetCurrentThreadPointer(system.Kernel());
1855 system.GlobalSchedulerContext().RemoveThread(current_thread); 1854 system.GlobalSchedulerContext().RemoveThread(current_thread);
1856 current_thread->Exit(); 1855 current_thread->Exit();
1857 system.Kernel().UnregisterInUseObject(current_thread); 1856 system.Kernel().UnregisterInUseObject(current_thread);
@@ -2993,7 +2992,7 @@ void Call(Core::System& system, u32 immediate) {
2993 auto& kernel = system.Kernel(); 2992 auto& kernel = system.Kernel();
2994 kernel.EnterSVCProfile(); 2993 kernel.EnterSVCProfile();
2995 2994
2996 auto* thread = kernel.CurrentScheduler()->GetCurrentThread(); 2995 auto* thread = GetCurrentThreadPointer(kernel);
2997 thread->SetIsCallingSvc(); 2996 thread->SetIsCallingSvc();
2998 2997
2999 const FunctionDef* info = system.CurrentProcess()->Is64BitProcess() ? GetSVCInfo64(immediate) 2998 const FunctionDef* info = system.CurrentProcess()->Is64BitProcess() ? GetSVCInfo64(immediate)