summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-10-25 18:42:50 -0400
committerGravatar Lioncash2018-10-26 12:49:11 -0400
commit6594853eb112f265fe2354723160c0d4e1cb761a (patch)
tree60e67d4d7f38d8f1fe5bebe01f3ef0d87881c570 /src/core/hle/kernel/svc.cpp
parentMerge pull request #1533 from FernandoS27/lmem (diff)
downloadyuzu-6594853eb112f265fe2354723160c0d4e1cb761a.tar.gz
yuzu-6594853eb112f265fe2354723160c0d4e1cb761a.tar.xz
yuzu-6594853eb112f265fe2354723160c0d4e1cb761a.zip
svc: Implement svcGetInfo command 0xF0000002
This retrieves: if (curr_thread == handle_thread) { result = total_thread_ticks + (hardware_tick_count - last_context_switch_ticks); } else if (curr_thread == handle_thread && sub_id == current_core_index) { result = hardware_tick_count - last_context_switch_ticks; }
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index a5302d924..110f042d7 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -529,6 +529,36 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
529 "(STUBBED) Attempted to query user exception context address, returned 0"); 529 "(STUBBED) Attempted to query user exception context address, returned 0");
530 *result = 0; 530 *result = 0;
531 break; 531 break;
532 case GetInfoType::ThreadTickCount: {
533 constexpr u64 num_cpus = 4;
534 if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) {
535 return ERR_INVALID_COMBINATION_KERNEL;
536 }
537
538 const auto thread =
539 current_process->GetHandleTable().Get<Thread>(static_cast<Handle>(handle));
540 if (!thread) {
541 return ERR_INVALID_HANDLE;
542 }
543
544 auto& system = Core::System::GetInstance();
545 const auto& scheduler = system.CurrentScheduler();
546 const auto* const current_thread = scheduler.GetCurrentThread();
547 const bool same_thread = current_thread == thread;
548
549 const u64 prev_ctx_ticks = scheduler.GetLastContextSwitchTicks();
550 u64 out_ticks = 0;
551 if (same_thread && info_sub_id == 0xFFFFFFFFFFFFFFFF) {
552 const u64 thread_ticks = current_thread->GetTotalCPUTimeTicks();
553
554 out_ticks = thread_ticks + (CoreTiming::GetTicks() - prev_ctx_ticks);
555 } else if (same_thread && info_sub_id == system.CurrentCoreIndex()) {
556 out_ticks = CoreTiming::GetTicks() - prev_ctx_ticks;
557 }
558
559 *result = out_ticks;
560 break;
561 }
532 default: 562 default:
533 UNIMPLEMENTED(); 563 UNIMPLEMENTED();
534 } 564 }