diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/kernel/k_process.cpp | 11 | ||||
-rw-r--r-- | src/core/hle/kernel/k_process.h | 3 | ||||
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 15 |
3 files changed, 28 insertions, 1 deletions
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index d1dc62401..a1abf5d68 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp @@ -285,6 +285,17 @@ void KProcess::UnregisterThread(KThread* thread) { thread_list.remove(thread); } +u64 KProcess::GetFreeThreadCount() const { + if (resource_limit != nullptr) { + const auto current_value = + resource_limit->GetCurrentValue(LimitableResource::ThreadCountMax); + const auto limit_value = resource_limit->GetLimitValue(LimitableResource::ThreadCountMax); + return limit_value - current_value; + } else { + return 0; + } +} + Result KProcess::Reset() { // Lock the process and the scheduler. KScopedLightLock lk(state_lock); diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h index 2e0cc3d0b..09bf2f1d0 100644 --- a/src/core/hle/kernel/k_process.h +++ b/src/core/hle/kernel/k_process.h @@ -304,6 +304,9 @@ public: /// from this process' thread list. void UnregisterThread(KThread* thread); + /// Retrieves the number of available threads for this process. + u64 GetFreeThreadCount() const; + /// Clears the signaled state of the process if and only if it's signaled. /// /// @pre The process must not be already terminated. If this is called on a diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index e520cab47..9fd7aae81 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -815,8 +815,15 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han // 6.0.0+ TotalPhysicalMemoryAvailableWithoutSystemResource = 21, TotalPhysicalMemoryUsedWithoutSystemResource = 22, + // 10.0.0+ + IsApplication = 23, + // 13.0.0+ + FreeThreadCount = 24, + // 14.0.0+ + IsSvcPermitted = 26, // Homebrew only + MesosphereMeta = 65000, MesosphereCurrentProcess = 65001, }; @@ -840,7 +847,9 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han case GetInfoType::TitleId: case GetInfoType::UserExceptionContextAddr: case GetInfoType::TotalPhysicalMemoryAvailableWithoutSystemResource: - case GetInfoType::TotalPhysicalMemoryUsedWithoutSystemResource: { + case GetInfoType::TotalPhysicalMemoryUsedWithoutSystemResource: + case GetInfoType::IsApplication: + case GetInfoType::FreeThreadCount: { if (info_sub_id != 0) { LOG_ERROR(Kernel_SVC, "Info sub id is non zero! info_id={}, info_sub_id={}", info_id, info_sub_id); @@ -929,6 +938,10 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han *result = process->GetTotalPhysicalMemoryUsedWithoutSystemResource(); return ResultSuccess; + case GetInfoType::FreeThreadCount: + *result = process->GetFreeThreadCount(); + return ResultSuccess; + default: break; } |