Browse Source

[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>
test2
Maufeat 4 days ago
committed by crueter
parent
commit
1d629fe83c
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 44
      src/core/hle/kernel/svc/svc_info.cpp

44
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,

Loading…
Cancel
Save