VERY experimental Nintendo Switch 2 emulator
C++
kernel/svc: Implement TotalMemoryUsedWithoutMmHeap/TotalMemoryAvailableWithoutMmHeap
Lioncash3a22c1270400
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cppindex 0775a89fb3..63a3707b2b 100644--- a/src/core/hle/kernel/process.cpp+++ b/src/core/hle/kernel/process.cpp@@ -72,10 +72,26 @@ SharedPtr<ResourceLimit> Process::GetResourceLimit() const {return resource_limit;}+u64 Process::GetTotalPhysicalMemoryAvailable() const {+ return vm_manager.GetTotalPhysicalMemoryAvailable();+}++u64 Process::GetTotalPhysicalMemoryAvailableWithoutMmHeap() const {+ // TODO: Subtract the personal heap size from this when the+ // personal heap is implemented.+ return GetTotalPhysicalMemoryAvailable();+}+u64 Process::GetTotalPhysicalMemoryUsed() const {return vm_manager.GetCurrentHeapSize() + main_thread_stack_size + code_memory_size;}+u64 Process::GetTotalPhysicalMemoryUsedWithoutMmHeap() const {+ // TODO: Subtract the personal heap size from this when the+ // personal heap is implemented.+ return GetTotalPhysicalMemoryUsed();+}+void Process::RegisterThread(const Thread* thread) {thread_list.push_back(thread);}diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.hindex f027fafa38..9c20eb7f87 100644--- a/src/core/hle/kernel/process.h+++ b/src/core/hle/kernel/process.h@@ -186,9 +186,20 @@ public:return random_entropy.at(index);}+ /// Retrieves the total physical memory available to this process in bytes.+ u64 GetTotalPhysicalMemoryAvailable() const;++ /// Retrieves the total physical memory available to this process in bytes,+ /// without the size of the personal heap added to it.+ u64 GetTotalPhysicalMemoryAvailableWithoutMmHeap() const;+/// Retrieves the total physical memory used by this process in bytes.u64 GetTotalPhysicalMemoryUsed() const;+ /// Retrieves the total physical memory used by this process in bytes,+ /// without the size of the personal heap added to it.+ u64 GetTotalPhysicalMemoryUsedWithoutMmHeap() const;+/// Gets the list of all threads created with this process as their owner.const std::list<const Thread*>& GetThreadList() const {return thread_list;diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cppindex 377a9bf483..f9c606bc52 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 haPrivilegedProcessId = 19,// 5.0.0+UserExceptionContextAddr = 20,+ // 6.0.0++ TotalPhysicalMemoryAvailableWithoutMmHeap = 21,+ TotalPhysicalMemoryUsedWithoutMmHeap = 22,};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 hacase GetInfoType::IsVirtualAddressMemoryEnabled:case GetInfoType::PersonalMmHeapUsage:case GetInfoType::TitleId:- case GetInfoType::UserExceptionContextAddr: {+ case GetInfoType::UserExceptionContextAddr:+ case GetInfoType::TotalPhysicalMemoryAvailableWithoutMmHeap:+ case GetInfoType::TotalPhysicalMemoryUsedWithoutMmHeap: {if (info_sub_id != 0) {return ERR_INVALID_ENUM_VALUE;}@@ -804,7 +809,7 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 hareturn RESULT_SUCCESS;case GetInfoType::TotalPhysicalMemoryAvailable:- *result = process->VMManager().GetTotalPhysicalMemoryAvailable();+ *result = process->GetTotalPhysicalMemoryAvailable();return RESULT_SUCCESS;case GetInfoType::TotalPhysicalMemoryUsed:@@ -825,6 +830,14 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha*result = 0;return RESULT_SUCCESS;+ case GetInfoType::TotalPhysicalMemoryAvailableWithoutMmHeap:+ *result = process->GetTotalPhysicalMemoryAvailable();+ return RESULT_SUCCESS;++ case GetInfoType::TotalPhysicalMemoryUsedWithoutMmHeap:+ *result = process->GetTotalPhysicalMemoryUsedWithoutMmHeap();+ return RESULT_SUCCESS;+default:break;}