aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaufeat <sahyno1996@gmail.com>2025-12-27 22:39:38 +0100
committercrueter <crueter@eden-emu.dev>2025-12-27 22:39:38 +0100
commit1d629fe83c97d1242317f36247e60a2e7bec4ffc (patch)
tree022bcd63b2c9768c239f8caa8839642c29e2287f /src
parentba3eda83d320da926e95dbf261ffa4a8e72fe1d9 (diff)
[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 <caiooliveirafarias0@gmail.com> Reviewed-by: crueter <crueter@eden-emu.dev> Co-authored-by: Maufeat <sahyno1996@gmail.com> Co-committed-by: Maufeat <sahyno1996@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/svc/svc_info.cpp44
1 files 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<u32>(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<KMemoryManager::Pool>(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,