mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
kern/pm: support for 5.x under mesosphere
This commit is contained in:
parent
657470830f
commit
79c9bed528
4 changed files with 394 additions and 367 deletions
|
@ -294,6 +294,19 @@ namespace ams::kern::svc {
|
||||||
R_TRY(GetInitialProcessIdRange(out, static_cast<ams::svc::InitialProcessIdRangeInfo>(info_subtype)));
|
R_TRY(GetInitialProcessIdRange(out, static_cast<ams::svc::InitialProcessIdRangeInfo>(info_subtype)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ams::svc::SystemInfoType_IsMesosphere:
|
||||||
|
{
|
||||||
|
/* Verify the handle is invalid. */
|
||||||
|
R_UNLESS(handle == ams::svc::InvalidHandle, svc::ResultInvalidHandle());
|
||||||
|
|
||||||
|
/* Verify that the sub-type is zero. */
|
||||||
|
R_UNLESS(info_subtype == 0, svc::ResultInvalidCombination());
|
||||||
|
|
||||||
|
/* We don't actually have any data to return. */
|
||||||
|
/* Clear the output. */
|
||||||
|
*out = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return svc::ResultInvalidEnumValue();
|
return svc::ResultInvalidEnumValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,13 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX) && defined(ATMOSPHERE_ARCH_ARM64)
|
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
|
||||||
|
|
||||||
namespace ams::svc::aarch64::lp64 {
|
namespace ams::svc {
|
||||||
|
|
||||||
|
#if defined(ATMOSPHERE_ARCH_ARM64)
|
||||||
|
|
||||||
|
namespace aarch64::lp64 {
|
||||||
|
|
||||||
ALWAYS_INLINE Result SetHeapSize(::ams::svc::Address *out_address, ::ams::svc::Size size) {
|
ALWAYS_INLINE Result SetHeapSize(::ams::svc::Address *out_address, ::ams::svc::Size size) {
|
||||||
return ::svcSetHeapSize(reinterpret_cast<void **>(out_address), size);
|
return ::svcSetHeapSize(reinterpret_cast<void **>(out_address), size);
|
||||||
|
@ -493,3 +497,12 @@ namespace ams::svc::aarch64::lp64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ALWAYS_INLINE bool IsKernelMesosphere() {
|
||||||
|
uint64_t dummy;
|
||||||
|
return R_SUCCEEDED(::ams::svc::GetSystemInfo(std::addressof(dummy), ::ams::svc::SystemInfoType_IsMesosphere, ::ams::svc::InvalidHandle, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -173,6 +173,9 @@ namespace ams::svc {
|
||||||
SystemInfoType_TotalPhysicalMemorySize = 0,
|
SystemInfoType_TotalPhysicalMemorySize = 0,
|
||||||
SystemInfoType_UsedPhysicalMemorySize = 1,
|
SystemInfoType_UsedPhysicalMemorySize = 1,
|
||||||
SystemInfoType_InitialProcessIdRange = 2,
|
SystemInfoType_InitialProcessIdRange = 2,
|
||||||
|
|
||||||
|
/* NOTE: This is potentially temporary, and highly subject to change. */
|
||||||
|
SystemInfoType_IsMesosphere = 0xF0000000,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum InitialProcessIdRangeInfo : u64 {
|
enum InitialProcessIdRangeInfo : u64 {
|
||||||
|
|
|
@ -206,10 +206,8 @@ namespace ams::pm::resource {
|
||||||
g_resource_limits[ResourceLimitGroup_System][svc::LimitableResource_EventCountMax] += ExtraSystemEventCount600;
|
g_resource_limits[ResourceLimitGroup_System][svc::LimitableResource_EventCountMax] += ExtraSystemEventCount600;
|
||||||
g_resource_limits[ResourceLimitGroup_System][svc::LimitableResource_SessionCountMax] += ExtraSystemSessionCount600;
|
g_resource_limits[ResourceLimitGroup_System][svc::LimitableResource_SessionCountMax] += ExtraSystemSessionCount600;
|
||||||
}
|
}
|
||||||
if (hos_version >= hos::Version_9_0_0) {
|
if (hos_version >= hos::Version_9_2_0) {
|
||||||
/* 9.2.0 increased the system session limit. */
|
/* 9.2.0 increased the system session limit. */
|
||||||
/* NOTE: We don't currently support detection of minor version, so we will provide this increase on 9.0.0+. */
|
|
||||||
/* This shouldn't impact any existing behavior in undesirable ways. */
|
|
||||||
g_resource_limits[ResourceLimitGroup_System][svc::LimitableResource_SessionCountMax] += ExtraSystemSessionCount920;
|
g_resource_limits[ResourceLimitGroup_System][svc::LimitableResource_SessionCountMax] += ExtraSystemSessionCount920;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +230,8 @@ namespace ams::pm::resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Choose and initialize memory arrangement. */
|
/* Choose and initialize memory arrangement. */
|
||||||
if (hos_version >= hos::Version_6_0_0) {
|
const bool use_dynamic_memory_arrangement = (hos_version >= hos::Version_6_0_0) || (svc::IsKernelMesosphere() && hos_version >= hos::Version_5_0_0);
|
||||||
|
if (use_dynamic_memory_arrangement) {
|
||||||
/* 6.0.0 retrieves memory limit information from the kernel, rather than using a hardcoded profile. */
|
/* 6.0.0 retrieves memory limit information from the kernel, rather than using a hardcoded profile. */
|
||||||
g_memory_arrangement = spl::MemoryArrangement_Dynamic;
|
g_memory_arrangement = spl::MemoryArrangement_Dynamic;
|
||||||
|
|
||||||
|
@ -253,14 +252,13 @@ namespace ams::pm::resource {
|
||||||
|
|
||||||
g_memory_resource_limits[spl::MemoryArrangement_Dynamic][ResourceLimitGroup_System] = total_memory - reserved_non_system_size;
|
g_memory_resource_limits[spl::MemoryArrangement_Dynamic][ResourceLimitGroup_System] = total_memory - reserved_non_system_size;
|
||||||
} else {
|
} else {
|
||||||
|
/* Older system versions retrieve memory arrangement from spl, and use hardcoded profiles. */
|
||||||
g_memory_arrangement = spl::GetMemoryArrangement();
|
g_memory_arrangement = spl::GetMemoryArrangement();
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust memory limits for atmosphere. */
|
/* Adjust memory limits for atmosphere. */
|
||||||
/* We take memory away from applet normally, but away from application on < 3.0.0 to avoid a rare hang on boot. */
|
/* We take memory away from applet normally, but away from application on < 3.0.0 to avoid a rare hang on boot. */
|
||||||
/* NOTE: On Version 5.0.0+, we cannot set the pools so simply. We must instead modify the kernel, which we do */
|
/* NOTE: On Version 5.0.0+, we cannot set the pools so simply. We must instead modify the kernel, which we do */
|
||||||
/* via patches in fusee-secondary. */
|
/* via patches in fusee-secondary. */
|
||||||
if (hos_version < hos::Version_6_0_0) {
|
|
||||||
const size_t extra_memory_size = hos_version == hos::Version_5_0_0 ? ExtraSystemMemorySizeAtmosphere500 : ExtraSystemMemorySizeAtmosphere;
|
const size_t extra_memory_size = hos_version == hos::Version_5_0_0 ? ExtraSystemMemorySizeAtmosphere500 : ExtraSystemMemorySizeAtmosphere;
|
||||||
const auto src_group = hos_version >= hos::Version_3_0_0 ? ResourceLimitGroup_Applet : ResourceLimitGroup_Application;
|
const auto src_group = hos_version >= hos::Version_3_0_0 ? ResourceLimitGroup_Applet : ResourceLimitGroup_Application;
|
||||||
for (size_t i = 0; i < spl::MemoryArrangement_Count; i++) {
|
for (size_t i = 0; i < spl::MemoryArrangement_Count; i++) {
|
||||||
|
|
Loading…
Reference in a new issue