summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/svc.cpp36
-rw-r--r--src/core/hle/svc.h40
2 files changed, 41 insertions, 35 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index fa6fd9ab1..6ec151d94 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -194,16 +194,38 @@ static void OutputDebugString(VAddr address, s32 len) {
LOG_DEBUG(Debug_Emulated, "%.*s", len, string.data());
}
+/// Gets system/memory information for the current process
static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) {
- LOG_TRACE(Kernel_SVC, "called, info_id=0x%X, info_sub_id=0x%X, handle=0x%08X", info_id, info_sub_id, handle);
+ LOG_TRACE(Kernel_SVC, "called info_id=0x%X, info_sub_id=0x%X, handle=0x%08X", info_id,
+ info_sub_id, handle);
- if (!handle) {
- switch (info_id) {
- case 0xB:
- *result = 0; // Used for PRNG seed
- return RESULT_SUCCESS;
- }
+ auto& vm_manager = Kernel::g_current_process->vm_manager;
+ switch (static_cast<GetInfoType>(info_id)) {
+ case GetInfoType::TotalMemoryUsage:
+ *result = vm_manager.GetTotalMemoryUsage();
+ break;
+ case GetInfoType::TotalHeapUsage:
+ *result = vm_manager.GetTotalHeapUsage();
+ break;
+ case GetInfoType::RandomEntropy:
+ *result = 0;
+ break;
+ case GetInfoType::AddressSpaceBaseAddr:
+ *result = vm_manager.GetAddressSpaceBaseAddr();
+ break;
+ case GetInfoType::AddressSpaceSize:
+ *result = vm_manager.GetAddressSpaceSize();
+ break;
+ case GetInfoType::NewMapRegionBaseAddr:
+ *result = vm_manager.GetNewMapRegionBaseAddr();
+ break;
+ case GetInfoType::NewMapRegionSize:
+ *result = vm_manager.GetNewMapRegionSize();
+ break;
+ default:
+ UNIMPLEMENTED();
}
+
return RESULT_SUCCESS;
}
diff --git a/src/core/hle/svc.h b/src/core/hle/svc.h
index 417a1735f..fd001a38e 100644
--- a/src/core/hle/svc.h
+++ b/src/core/hle/svc.h
@@ -26,35 +26,19 @@ struct PageInfo {
namespace SVC {
-/// Values accepted by svcGetSystemInfo's type parameter.
-enum class SystemInfoType {
- /**
- * Reports total used memory for all regions or a specific one, according to the extra
- * parameter. See `SystemInfoMemUsageRegion`.
- */
- REGION_MEMORY_USAGE = 0,
- /**
- * Returns the memory usage for certain allocations done internally by the kernel.
- */
- KERNEL_ALLOCATED_PAGES = 2,
- /**
- * "This returns the total number of processes which were launched directly by the kernel.
- * For the ARM11 NATIVE_FIRM kernel, this is 5, for processes sm, fs, pm, loader, and pxi."
- */
- KERNEL_SPAWNED_PIDS = 26,
-};
-
-/**
- * Accepted by svcGetSystemInfo param with REGION_MEMORY_USAGE type. Selects a region to query
- * memory usage of.
- */
-enum class SystemInfoMemUsageRegion {
- ALL = 0,
- APPLICATION = 1,
- SYSTEM = 2,
- BASE = 3,
+/// Values accepted by svcGetInfo
+enum class GetInfoType : u64 {
+ // 1.0.0+
+ TotalMemoryUsage = 6,
+ TotalHeapUsage = 7,
+ RandomEntropy = 11,
+ // 2.0.0+
+ AddressSpaceBaseAddr = 12,
+ AddressSpaceSize = 13,
+ NewMapRegionBaseAddr = 14,
+ NewMapRegionSize = 15,
};
void CallSVC(u32 immediate);
-} // namespace
+} // namespace SVC