From 1d629fe83c97d1242317f36247e60a2e7bec4ffc Mon Sep 17 00:00:00 2001 From: Maufeat Date: Sat, 27 Dec 2025 22:39:38 +0100 Subject: [PATCH] [svc] Implement GetSystemInfo (#3217) This function is a copy-cat implementation of Ryujinx's method Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3217 Reviewed-by: Caio Oliveira Reviewed-by: crueter Co-authored-by: Maufeat Co-committed-by: Maufeat --- src/core/hle/kernel/svc/svc_info.cpp | 44 ++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/core/hle/kernel/svc/svc_info.cpp b/src/core/hle/kernel/svc/svc_info.cpp index 16271883f2..9e651e1171 100644 --- a/src/core/hle/kernel/svc/svc_info.cpp +++ b/src/core/hle/kernel/svc/svc_info.cpp @@ -6,6 +6,7 @@ #include "core/core.h" #include "core/core_timing.h" +#include "core/hle/kernel/k_memory_manager.h" #include "core/hle/kernel/k_process.h" #include "core/hle/kernel/k_resource_limit.h" #include "core/hle/kernel/svc.h" @@ -271,8 +272,47 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle Result GetSystemInfo(Core::System& system, uint64_t* out, SystemInfoType info_type, Handle handle, uint64_t info_subtype) { - UNIMPLEMENTED(); - R_THROW(ResultNotImplemented); + const u32 info_id = static_cast(info_type); + + R_UNLESS(info_id <= 2, ResultInvalidEnumValue); + + R_UNLESS(handle == 0, ResultInvalidHandle); + + if (info_id < 2) { + R_UNLESS(info_subtype <= 3, ResultInvalidCombination); + + auto& memory_manager = system.Kernel().MemoryManager(); + const auto pool = static_cast(info_subtype); + + switch (info_type) { + case SystemInfoType::TotalPhysicalMemorySize: + *out = memory_manager.GetSize(pool); + break; + case SystemInfoType::UsedPhysicalMemorySize: + *out = memory_manager.GetSize(pool) - memory_manager.GetFreeSize(pool); + break; + default: + R_THROW(ResultInvalidEnumValue); + } + } else { + R_UNLESS(info_subtype <= 1, ResultInvalidCombination); + + constexpr u64 PrivilegedProcessLowestId = 1; + constexpr u64 PrivilegedProcessHighestId = 8; + + switch (info_subtype) { + case 0: + *out = PrivilegedProcessLowestId; + break; + case 1: + *out = PrivilegedProcessHighestId; + break; + default: + R_THROW(ResultInvalidCombination); + } + } + + R_SUCCEED(); } Result GetInfo64(Core::System& system, uint64_t* out, InfoType info_type, Handle handle,