mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-23 15:22:45 +01:00
Merge pull request #7193 from FernandoS27/idle
SVC: Implement svcInfo:IdleTickCount
This commit is contained in:
commit
63ed7d9af7
2 changed files with 22 additions and 0 deletions
|
@ -49,6 +49,11 @@ public:
|
||||||
/// Gets the current running thread
|
/// Gets the current running thread
|
||||||
[[nodiscard]] KThread* GetCurrentThread() const;
|
[[nodiscard]] KThread* GetCurrentThread() const;
|
||||||
|
|
||||||
|
/// Gets the idle thread
|
||||||
|
[[nodiscard]] KThread* GetIdleThread() const {
|
||||||
|
return idle_thread;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if the scheduler is idle
|
/// Returns true if the scheduler is idle
|
||||||
[[nodiscard]] bool IsIdle() const {
|
[[nodiscard]] bool IsIdle() const {
|
||||||
return GetCurrentThread() == idle_thread;
|
return GetCurrentThread() == idle_thread;
|
||||||
|
|
|
@ -886,7 +886,24 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle
|
||||||
*result = out_ticks;
|
*result = out_ticks;
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
case GetInfoType::IdleTickCount: {
|
||||||
|
if (handle == 0) {
|
||||||
|
LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}",
|
||||||
|
static_cast<Handle>(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:
|
default:
|
||||||
LOG_ERROR(Kernel_SVC, "Unimplemented svcGetInfo id=0x{:016X}", info_id);
|
LOG_ERROR(Kernel_SVC, "Unimplemented svcGetInfo id=0x{:016X}", info_id);
|
||||||
return ResultInvalidEnumValue;
|
return ResultInvalidEnumValue;
|
||||||
|
|
Loading…
Reference in a new issue