kernel: Implement SystemResourceSize info type for VAMM initialization

Adds support for InfoType::SystemResourceSize (0x1C) which is required for
proper initialization of the Virtual Address Memory Manager (VAMM). This
implementation:

1. Adds SystemResourceSize to the InfoType enum in svc_types.h
2. Implements the GetInfo handler for SystemResourceSize in svc_info.cpp
3. Returns 512MB (0x20000000 bytes) as the system resource size
4. Adds debug logging for the SVC call

The 512MB value is chosen based on typical system resource allocations
needed for VAMM initialization on the Nintendo Switch.

This fixes crashes in games that rely on VAMM functionality, particularly
during nn::os::detail::VammManager::InitializeIfEnabled().
This commit is contained in:
Zephyron 2025-01-07 18:50:11 +10:00
parent 66b6d5b2da
commit dae1524eb5
No known key found for this signature in database
GPG key ID: 8DA271B6A74353F1
2 changed files with 11 additions and 0 deletions

View file

@ -228,6 +228,16 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
*result = system.Kernel().CurrentScheduler()->GetIdleThread()->GetCpuTime(); *result = system.Kernel().CurrentScheduler()->GetIdleThread()->GetCpuTime();
R_SUCCEED(); R_SUCCEED();
} }
case InfoType::SystemResourceSize: {
LOG_DEBUG(Kernel_SVC, "called info_type={:#x}, info_subtype={:#x}, handle={:#x}", info_id,
info_sub_id, handle);
// VAMM (Virtual Address Memory Manager) typically expects a larger memory size
// The value below (512MB) is based on typical system resource allocations
*result = 0x20000000; // 512MB in bytes
R_SUCCEED();
}
case InfoType::MesosphereCurrentProcess: { case InfoType::MesosphereCurrentProcess: {
// Verify the input handle is invalid. // Verify the input handle is invalid.
R_UNLESS(handle == InvalidHandle, ResultInvalidHandle); R_UNLESS(handle == InvalidHandle, ResultInvalidHandle);

View file

@ -156,6 +156,7 @@ enum class InfoType : u32 {
MesosphereMeta = 65000, MesosphereMeta = 65000,
MesosphereCurrentProcess = 65001, MesosphereCurrentProcess = 65001,
SystemResourceSize = 0x1C,
}; };
enum class BreakReason : u32 { enum class BreakReason : u32 {