From 2d006a4a72e5d0bab899d607a3191c4f379221a5 Mon Sep 17 00:00:00 2001 From: TheGreatRambler <31906920+TheGreatRambler@users.noreply.github.com> Date: Tue, 12 Nov 2019 20:44:59 -0500 Subject: [PATCH] Update pm_resource_manager.cpp --- .../pm/source/impl/pm_resource_manager.cpp | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/stratosphere/pm/source/impl/pm_resource_manager.cpp b/stratosphere/pm/source/impl/pm_resource_manager.cpp index 7c625b49b..a3907eca4 100644 --- a/stratosphere/pm/source/impl/pm_resource_manager.cpp +++ b/stratosphere/pm/source/impl/pm_resource_manager.cpp @@ -41,7 +41,7 @@ namespace sts::pm::resource { constexpr size_t ExtraSystemSessionCount600 = 100; constexpr size_t ReservedMemorySize600 = 5 * Megabyte; - /* Atmosphere always allocates 24 extra megabytes for system usage. */ + /* The amount of extra memory Atmosphere needs can be specified by the main settings file, but this is the default */ constexpr size_t ExtraSystemMemorySizeAtmosphere = 24 * Megabyte; /* Globals. */ @@ -267,9 +267,28 @@ namespace sts::pm::resource { /* Actually set resource limits. */ { std::scoped_lock lk(g_resource_limit_lock); - - for (size_t group = 0; group < ResourceLimitGroup_Count; group++) { - R_ASSERT(SetResourceLimitLimitValues(static_cast(group), g_memory_resource_limits[g_memory_arrangement][group])); + spl::MemoryArrangement_Standard + + u8 SetMemoryManually; + R_ASSERT(setsysGetSettingsItemValueSize("atmosphere", "manual_memory_control", &SetMemoryManually)); + if (!SetMemoryManually) { + /* Memory corresponds to the chosen `g_memory_arrangement`. */ + /* Default. */ + for (size_t group = 0; group < ResourceLimitGroup_Count; group++) { + R_ASSERT(SetResourceLimitLimitValues(static_cast(group), g_memory_resource_limits[g_memory_arrangement][group])); + } + } else { + /* Memory info was chosen by the user. */ + u64 systemSize; + u64 applicationSize; + u64 appletSize; + R_ASSERT(setsysGetSettingsItemValueSize("atmosphere", "system_memory", &systemSize)); + R_ASSERT(setsysGetSettingsItemValueSize("atmosphere", "application_memory", &applicationSize)); + R_ASSERT(setsysGetSettingsItemValueSize("atmosphere", "applet_memory", &appletSize)); + /* Set all memory values. */ + R_ASSERT(SetResourceLimitLimitValues(static_cast(ResourceLimitGroup_System), systemSize * Megabyte); + R_ASSERT(SetResourceLimitLimitValues(static_cast(ResourceLimitGroup_Application), applicationSize * Megabyte); + R_ASSERT(SetResourceLimitLimitValues(static_cast(ResourceLimitGroup_Applet), appletSize * Megabyte); } }