summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2019-06-09 18:20:20 -0400
committerGravatar Lioncash2019-06-09 18:22:30 -0400
commit3f87664d8fac06b024b0a59adfdfe570ab6195e5 (patch)
tree59b7c0e6fa849694b5e4c34f573310589e342496 /src
parentkernel/svc: Amend naming for TotalMemoryUsage in svcGetInfo() (diff)
downloadyuzu-3f87664d8fac06b024b0a59adfdfe570ab6195e5.tar.gz
yuzu-3f87664d8fac06b024b0a59adfdfe570ab6195e5.tar.xz
yuzu-3f87664d8fac06b024b0a59adfdfe570ab6195e5.zip
kernel/svc: Implement TotalMemoryUsedWithoutMmHeap/TotalMemoryAvailableWithoutMmHeap
Given we don't currently implement the personal heap yet, the existing memory querying functions are essentially doing what the memory querying types introduced in 6.0.0 do. So, we can build the necessary machinery over the top of those and just use them as part of info types.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/process.cpp16
-rw-r--r--src/core/hle/kernel/process.h11
-rw-r--r--src/core/hle/kernel/svc.cpp17
3 files changed, 42 insertions, 2 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index 0775a89fb..63a3707b2 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -72,10 +72,26 @@ SharedPtr<ResourceLimit> Process::GetResourceLimit() const {
72 return resource_limit; 72 return resource_limit;
73} 73}
74 74
75u64 Process::GetTotalPhysicalMemoryAvailable() const {
76 return vm_manager.GetTotalPhysicalMemoryAvailable();
77}
78
79u64 Process::GetTotalPhysicalMemoryAvailableWithoutMmHeap() const {
80 // TODO: Subtract the personal heap size from this when the
81 // personal heap is implemented.
82 return GetTotalPhysicalMemoryAvailable();
83}
84
75u64 Process::GetTotalPhysicalMemoryUsed() const { 85u64 Process::GetTotalPhysicalMemoryUsed() const {
76 return vm_manager.GetCurrentHeapSize() + main_thread_stack_size + code_memory_size; 86 return vm_manager.GetCurrentHeapSize() + main_thread_stack_size + code_memory_size;
77} 87}
78 88
89u64 Process::GetTotalPhysicalMemoryUsedWithoutMmHeap() const {
90 // TODO: Subtract the personal heap size from this when the
91 // personal heap is implemented.
92 return GetTotalPhysicalMemoryUsed();
93}
94
79void Process::RegisterThread(const Thread* thread) { 95void Process::RegisterThread(const Thread* thread) {
80 thread_list.push_back(thread); 96 thread_list.push_back(thread);
81} 97}
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index f027fafa3..9c20eb7f8 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -186,9 +186,20 @@ public:
186 return random_entropy.at(index); 186 return random_entropy.at(index);
187 } 187 }
188 188
189 /// Retrieves the total physical memory available to this process in bytes.
190 u64 GetTotalPhysicalMemoryAvailable() const;
191
192 /// Retrieves the total physical memory available to this process in bytes,
193 /// without the size of the personal heap added to it.
194 u64 GetTotalPhysicalMemoryAvailableWithoutMmHeap() const;
195
189 /// Retrieves the total physical memory used by this process in bytes. 196 /// Retrieves the total physical memory used by this process in bytes.
190 u64 GetTotalPhysicalMemoryUsed() const; 197 u64 GetTotalPhysicalMemoryUsed() const;
191 198
199 /// Retrieves the total physical memory used by this process in bytes,
200 /// without the size of the personal heap added to it.
201 u64 GetTotalPhysicalMemoryUsedWithoutMmHeap() const;
202
192 /// Gets the list of all threads created with this process as their owner. 203 /// Gets the list of all threads created with this process as their owner.
193 const std::list<const Thread*>& GetThreadList() const { 204 const std::list<const Thread*>& GetThreadList() const {
194 return thread_list; 205 return thread_list;
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 377a9bf48..f9c606bc5 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -730,6 +730,9 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
730 PrivilegedProcessId = 19, 730 PrivilegedProcessId = 19,
731 // 5.0.0+ 731 // 5.0.0+
732 UserExceptionContextAddr = 20, 732 UserExceptionContextAddr = 20,
733 // 6.0.0+
734 TotalPhysicalMemoryAvailableWithoutMmHeap = 21,
735 TotalPhysicalMemoryUsedWithoutMmHeap = 22,
733 }; 736 };
734 737
735 const auto info_id_type = static_cast<GetInfoType>(info_id); 738 const auto info_id_type = static_cast<GetInfoType>(info_id);
@@ -750,7 +753,9 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
750 case GetInfoType::IsVirtualAddressMemoryEnabled: 753 case GetInfoType::IsVirtualAddressMemoryEnabled:
751 case GetInfoType::PersonalMmHeapUsage: 754 case GetInfoType::PersonalMmHeapUsage:
752 case GetInfoType::TitleId: 755 case GetInfoType::TitleId:
753 case GetInfoType::UserExceptionContextAddr: { 756 case GetInfoType::UserExceptionContextAddr:
757 case GetInfoType::TotalPhysicalMemoryAvailableWithoutMmHeap:
758 case GetInfoType::TotalPhysicalMemoryUsedWithoutMmHeap: {
754 if (info_sub_id != 0) { 759 if (info_sub_id != 0) {
755 return ERR_INVALID_ENUM_VALUE; 760 return ERR_INVALID_ENUM_VALUE;
756 } 761 }
@@ -804,7 +809,7 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
804 return RESULT_SUCCESS; 809 return RESULT_SUCCESS;
805 810
806 case GetInfoType::TotalPhysicalMemoryAvailable: 811 case GetInfoType::TotalPhysicalMemoryAvailable:
807 *result = process->VMManager().GetTotalPhysicalMemoryAvailable(); 812 *result = process->GetTotalPhysicalMemoryAvailable();
808 return RESULT_SUCCESS; 813 return RESULT_SUCCESS;
809 814
810 case GetInfoType::TotalPhysicalMemoryUsed: 815 case GetInfoType::TotalPhysicalMemoryUsed:
@@ -825,6 +830,14 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
825 *result = 0; 830 *result = 0;
826 return RESULT_SUCCESS; 831 return RESULT_SUCCESS;
827 832
833 case GetInfoType::TotalPhysicalMemoryAvailableWithoutMmHeap:
834 *result = process->GetTotalPhysicalMemoryAvailable();
835 return RESULT_SUCCESS;
836
837 case GetInfoType::TotalPhysicalMemoryUsedWithoutMmHeap:
838 *result = process->GetTotalPhysicalMemoryUsedWithoutMmHeap();
839 return RESULT_SUCCESS;
840
828 default: 841 default:
829 break; 842 break;
830 } 843 }