From 4e99eaa5904e6a49bcf8201e06bfb184641f1ec5 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 31 Jan 2019 03:32:47 -0800 Subject: [PATCH] pm: Update for 7.0.0 --- stratosphere/pm/source/pm_resource_limits.cpp | 3 +++ stratosphere/pm/source/pm_shell.cpp | 7 +++++++ stratosphere/pm/source/pm_shell.hpp | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/stratosphere/pm/source/pm_resource_limits.cpp b/stratosphere/pm/source/pm_resource_limits.cpp index d4649bf07..d6d5b70f3 100644 --- a/stratosphere/pm/source/pm_resource_limits.cpp +++ b/stratosphere/pm/source/pm_resource_limits.cpp @@ -122,6 +122,9 @@ void ResourceLimitUtils::InitializeLimits() { memcpy(&g_resource_limits, &g_resource_limits_deprecated, sizeof(g_resource_limits)); } + /* 7.0.0+: Nintendo restricts the number of system threads here, from 0x260 -> 0x60. */ + /* We will not do this. */ + if (kernelAbove600()) { /* NOTE: 5 is a fake type, official code does not do this. */ /* This is done for ease of backwards compatibility. */ diff --git a/stratosphere/pm/source/pm_shell.cpp b/stratosphere/pm/source/pm_shell.cpp index a1e6dbd12..0dc429a95 100644 --- a/stratosphere/pm/source/pm_shell.cpp +++ b/stratosphere/pm/source/pm_shell.cpp @@ -104,3 +104,10 @@ Result ShellService::GetApplicationProcessId(Out pid) { Result ShellService::BoostSystemMemoryResourceLimit(u64 sysmem_size) { return ResourceLimitUtils::BoostSystemMemoryResourceLimit(sysmem_size); } + +Result ShellService::BoostSystemThreadsResourceLimit() { + /* Starting in 7.0.0, Nintendo reduces the number of system threads from 0x260 to 0x60, */ + /* Until this command is called to double that amount to 0xC0. */ + /* We will simply not reduce the number of system threads available for no reason. */ + return 0x0; +} diff --git a/stratosphere/pm/source/pm_shell.hpp b/stratosphere/pm/source/pm_shell.hpp index cd707a510..3316e168c 100644 --- a/stratosphere/pm/source/pm_shell.hpp +++ b/stratosphere/pm/source/pm_shell.hpp @@ -43,7 +43,9 @@ enum ShellCmd_5X { Shell_Cmd_5X_GetProcessEventType = 4, Shell_Cmd_5X_NotifyBootFinished = 5, Shell_Cmd_5X_GetApplicationProcessId = 6, - Shell_Cmd_5X_BoostSystemMemoryResourceLimit = 7 + Shell_Cmd_5X_BoostSystemMemoryResourceLimit = 7, + + Shell_Cmd_BoostSystemThreadsResourceLimit = 8 }; class ShellService final : public IServiceObject { @@ -59,6 +61,7 @@ class ShellService final : public IServiceObject { void NotifyBootFinished(); Result GetApplicationProcessId(Out pid); Result BoostSystemMemoryResourceLimit(u64 sysmem_size); + Result BoostSystemThreadsResourceLimit(); public: DEFINE_SERVICE_DISPATCH_TABLE { /* 1.0.0-4.0.0 */ @@ -84,5 +87,8 @@ class ShellService final : public IServiceObject { MakeServiceCommandMeta(), MakeServiceCommandMeta(), MakeServiceCommandMeta(), + + /* 7.0.0-* */ + MakeServiceCommandMeta(), }; };