diff options
| author | 2021-10-16 11:54:09 +0200 | |
|---|---|---|
| committer | 2021-10-16 20:33:44 +0200 | |
| commit | da6673e79acf26d728d347edc15c123d6c96a42f (patch) | |
| tree | c2fd1dc9f2673bd7e279434f79fea2cdc5a64f70 | |
| parent | Merge pull request #7190 from Morph1984/missing-ui-main (diff) | |
| download | yuzu-da6673e79acf26d728d347edc15c123d6c96a42f.tar.gz yuzu-da6673e79acf26d728d347edc15c123d6c96a42f.tar.xz yuzu-da6673e79acf26d728d347edc15c123d6c96a42f.zip | |
SVC: Implement svcInfo:IdleTickCount
Used by the Witcher 3
| -rw-r--r-- | src/core/hle/kernel/k_scheduler.h | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 17 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h index c8ccc1ae4..7df288438 100644 --- a/src/core/hle/kernel/k_scheduler.h +++ b/src/core/hle/kernel/k_scheduler.h | |||
| @@ -49,6 +49,11 @@ public: | |||
| 49 | /// Gets the current running thread | 49 | /// Gets the current running thread |
| 50 | [[nodiscard]] KThread* GetCurrentThread() const; | 50 | [[nodiscard]] KThread* GetCurrentThread() const; |
| 51 | 51 | ||
| 52 | /// Gets the idle thread | ||
| 53 | [[nodiscard]] KThread* GetIdleThread() const { | ||
| 54 | return idle_thread; | ||
| 55 | } | ||
| 56 | |||
| 52 | /// Returns true if the scheduler is idle | 57 | /// Returns true if the scheduler is idle |
| 53 | [[nodiscard]] bool IsIdle() const { | 58 | [[nodiscard]] bool IsIdle() const { |
| 54 | return GetCurrentThread() == idle_thread; | 59 | return GetCurrentThread() == idle_thread; |
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 | |||
| 886 | *result = out_ticks; | 886 | *result = out_ticks; |
| 887 | return ResultSuccess; | 887 | return ResultSuccess; |
| 888 | } | 888 | } |
| 889 | case GetInfoType::IdleTickCount: { | ||
| 890 | if (handle == 0) { | ||
| 891 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", | ||
| 892 | static_cast<Handle>(handle)); | ||
| 893 | return ResultInvalidHandle; | ||
| 894 | } | ||
| 889 | 895 | ||
| 896 | if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id != system.CurrentCoreIndex()) { | ||
| 897 | LOG_ERROR(Kernel_SVC, "Core is not the current core, got {}", info_sub_id); | ||
| 898 | return ResultInvalidCombination; | ||
| 899 | } | ||
| 900 | |||
| 901 | const auto& scheduler = *system.Kernel().CurrentScheduler(); | ||
| 902 | const auto* const idle_thread = scheduler.GetIdleThread(); | ||
| 903 | |||
| 904 | *result = idle_thread->GetCpuTime(); | ||
| 905 | return ResultSuccess; | ||
| 906 | } | ||
| 890 | default: | 907 | default: |
| 891 | LOG_ERROR(Kernel_SVC, "Unimplemented svcGetInfo id=0x{:016X}", info_id); | 908 | LOG_ERROR(Kernel_SVC, "Unimplemented svcGetInfo id=0x{:016X}", info_id); |
| 892 | return ResultInvalidEnumValue; | 909 | return ResultInvalidEnumValue; |