summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-10-26 00:42:50 +0200
committerLioncash <mathew1800@gmail.com>2018-10-26 18:49:11 +0200
commit6594853eb112f265fe2354723160c0d4e1cb761a (patch)
tree60e67d4d7f38d8f1fe5bebe01f3ef0d87881c570 /src/core/hle/kernel/svc.cpp
parentMerge pull request #1533 from FernandoS27/lmem (diff)
downloadyuzu-6594853eb112f265fe2354723160c0d4e1cb761a.tar
yuzu-6594853eb112f265fe2354723160c0d4e1cb761a.tar.gz
yuzu-6594853eb112f265fe2354723160c0d4e1cb761a.tar.bz2
yuzu-6594853eb112f265fe2354723160c0d4e1cb761a.tar.lz
yuzu-6594853eb112f265fe2354723160c0d4e1cb761a.tar.xz
yuzu-6594853eb112f265fe2354723160c0d4e1cb761a.tar.zst
yuzu-6594853eb112f265fe2354723160c0d4e1cb761a.zip
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)
"(STUBBED) Attempted to query user exception context address, returned 0");
*result = 0;
break;
+ case GetInfoType::ThreadTickCount: {
+ constexpr u64 num_cpus = 4;
+ if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) {
+ return ERR_INVALID_COMBINATION_KERNEL;
+ }
+
+ const auto thread =
+ current_process->GetHandleTable().Get<Thread>(static_cast<Handle>(handle));
+ if (!thread) {
+ return ERR_INVALID_HANDLE;
+ }
+
+ auto& system = Core::System::GetInstance();
+ const auto& scheduler = system.CurrentScheduler();
+ const auto* const current_thread = scheduler.GetCurrentThread();
+ const bool same_thread = current_thread == thread;
+
+ const u64 prev_ctx_ticks = scheduler.GetLastContextSwitchTicks();
+ u64 out_ticks = 0;
+ if (same_thread && info_sub_id == 0xFFFFFFFFFFFFFFFF) {
+ const u64 thread_ticks = current_thread->GetTotalCPUTimeTicks();
+
+ out_ticks = thread_ticks + (CoreTiming::GetTicks() - prev_ctx_ticks);
+ } else if (same_thread && info_sub_id == system.CurrentCoreIndex()) {
+ out_ticks = CoreTiming::GetTicks() - prev_ctx_ticks;
+ }
+
+ *result = out_ticks;
+ break;
+ }
default:
UNIMPLEMENTED();
}