summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lioncash2019-03-28 22:59:17 -0400
committerGravatar Lioncash2019-03-28 22:59:20 -0400
commit3a846aa80f5d533a5061fcbef2736aaef8c38a66 (patch)
treea3dd29dfc5f35a4fed9d9c9855af4dbab902774f
parentkernel/process: Store the total size of the code memory loaded (diff)
downloadyuzu-3a846aa80f5d533a5061fcbef2736aaef8c38a66.tar.gz
yuzu-3a846aa80f5d533a5061fcbef2736aaef8c38a66.tar.xz
yuzu-3a846aa80f5d533a5061fcbef2736aaef8c38a66.zip
kernel/process: Report total physical memory used to svcGetInfo
Reports the (mostly) correct size through svcGetInfo now for queries to total used physical memory. This still doesn't correctly handle memory allocated via svcMapPhysicalMemory, however, we don't currently handle that case anyways.
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/process.cpp4
-rw-r--r--src/core/hle/kernel/process.h3
-rw-r--r--src/core/hle/kernel/svc.cpp8
3 files changed, 11 insertions, 4 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index 819d2cb0b..b0b7af76b 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -76,6 +76,10 @@ SharedPtr<ResourceLimit> Process::GetResourceLimit() const {
76 return resource_limit; 76 return resource_limit;
77} 77}
78 78
79u64 Process::GetTotalPhysicalMemoryUsed() const {
80 return vm_manager.GetCurrentHeapSize() + main_thread_stack_size + code_memory_size;
81}
82
79ResultCode Process::ClearSignalState() { 83ResultCode Process::ClearSignalState() {
80 if (status == ProcessStatus::Exited) { 84 if (status == ProcessStatus::Exited) {
81 LOG_ERROR(Kernel, "called on a terminated process instance."); 85 LOG_ERROR(Kernel, "called on a terminated process instance.");
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index 16193ca56..732d12170 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -186,6 +186,9 @@ public:
186 return random_entropy.at(index); 186 return random_entropy.at(index);
187 } 187 }
188 188
189 /// Retrieves the total physical memory used by this process in bytes.
190 u64 GetTotalPhysicalMemoryUsed() const;
191
189 /// Clears the signaled state of the process if and only if it's signaled. 192 /// Clears the signaled state of the process if and only if it's signaled.
190 /// 193 ///
191 /// @pre The process must not be already terminated. If this is called on a 194 /// @pre The process must not be already terminated. If this is called on a
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 09d1eadb6..17bfe10ff 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -709,7 +709,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
709 HeapRegionBaseAddr = 4, 709 HeapRegionBaseAddr = 4,
710 HeapRegionSize = 5, 710 HeapRegionSize = 5,
711 TotalMemoryUsage = 6, 711 TotalMemoryUsage = 6,
712 TotalHeapUsage = 7, 712 TotalPhysicalMemoryUsed = 7,
713 IsCurrentProcessBeingDebugged = 8, 713 IsCurrentProcessBeingDebugged = 8,
714 RegisterResourceLimit = 9, 714 RegisterResourceLimit = 9,
715 IdleTickCount = 10, 715 IdleTickCount = 10,
@@ -745,7 +745,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
745 case GetInfoType::NewMapRegionBaseAddr: 745 case GetInfoType::NewMapRegionBaseAddr:
746 case GetInfoType::NewMapRegionSize: 746 case GetInfoType::NewMapRegionSize:
747 case GetInfoType::TotalMemoryUsage: 747 case GetInfoType::TotalMemoryUsage:
748 case GetInfoType::TotalHeapUsage: 748 case GetInfoType::TotalPhysicalMemoryUsed:
749 case GetInfoType::IsVirtualAddressMemoryEnabled: 749 case GetInfoType::IsVirtualAddressMemoryEnabled:
750 case GetInfoType::PersonalMmHeapUsage: 750 case GetInfoType::PersonalMmHeapUsage:
751 case GetInfoType::TitleId: 751 case GetInfoType::TitleId:
@@ -805,8 +805,8 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
805 *result = process->VMManager().GetTotalMemoryUsage(); 805 *result = process->VMManager().GetTotalMemoryUsage();
806 return RESULT_SUCCESS; 806 return RESULT_SUCCESS;
807 807
808 case GetInfoType::TotalHeapUsage: 808 case GetInfoType::TotalPhysicalMemoryUsed:
809 *result = process->VMManager().GetCurrentHeapSize(); 809 *result = process->GetTotalPhysicalMemoryUsed();
810 return RESULT_SUCCESS; 810 return RESULT_SUCCESS;
811 811
812 case GetInfoType::IsVirtualAddressMemoryEnabled: 812 case GetInfoType::IsVirtualAddressMemoryEnabled: