From da6673e79acf26d728d347edc15c123d6c96a42f Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sat, 16 Oct 2021 11:54:09 +0200 Subject: SVC: Implement svcInfo:IdleTickCount Used by the Witcher 3 --- src/core/hle/kernel/svc.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/core/hle/kernel/svc.cpp') diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index f98f24a60..7f38ade1c 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -886,7 +886,24 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle *result = out_ticks; return ResultSuccess; } + case GetInfoType::IdleTickCount: { + if (handle == 0) { + LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", + static_cast(handle)); + return ResultInvalidHandle; + } + if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id != system.CurrentCoreIndex()) { + LOG_ERROR(Kernel_SVC, "Core is not the current core, got {}", info_sub_id); + return ResultInvalidCombination; + } + + const auto& scheduler = *system.Kernel().CurrentScheduler(); + const auto* const idle_thread = scheduler.GetIdleThread(); + + *result = idle_thread->GetCpuTime(); + return ResultSuccess; + } default: LOG_ERROR(Kernel_SVC, "Unimplemented svcGetInfo id=0x{:016X}", info_id); return ResultInvalidEnumValue; -- cgit v1.2.3