Merge pull request #2570 from lioncash/svc

kernel/svc: Handle TotalPhysicalMemoryAvailableWithoutMmHeap and TotalPhysicalMemoryUsedWithoutMmHeap
This commit is contained in:
Zach Hilman 2019-06-09 20:43:03 -04:00 committed by GitHub
commit 4486103e1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 9 deletions

View file

@ -72,10 +72,26 @@ SharedPtr<ResourceLimit> Process::GetResourceLimit() const {
return resource_limit; 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 { u64 Process::GetTotalPhysicalMemoryUsed() const {
return vm_manager.GetCurrentHeapSize() + main_thread_stack_size + code_memory_size; 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) { void Process::RegisterThread(const Thread* thread) {
thread_list.push_back(thread); thread_list.push_back(thread);
} }

View file

@ -186,9 +186,20 @@ public:
return random_entropy.at(index); 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. /// Retrieves the total physical memory used by this process in bytes.
u64 GetTotalPhysicalMemoryUsed() const; 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. /// Gets the list of all threads created with this process as their owner.
const std::list<const Thread*>& GetThreadList() const { const std::list<const Thread*>& GetThreadList() const {
return thread_list; return thread_list;

View file

@ -710,13 +710,13 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
MapRegionSize = 3, MapRegionSize = 3,
HeapRegionBaseAddr = 4, HeapRegionBaseAddr = 4,
HeapRegionSize = 5, HeapRegionSize = 5,
TotalMemoryUsage = 6, TotalPhysicalMemoryAvailable = 6,
TotalPhysicalMemoryUsed = 7, TotalPhysicalMemoryUsed = 7,
IsCurrentProcessBeingDebugged = 8, IsCurrentProcessBeingDebugged = 8,
RegisterResourceLimit = 9, RegisterResourceLimit = 9,
IdleTickCount = 10, IdleTickCount = 10,
RandomEntropy = 11, RandomEntropy = 11,
PerformanceCounter = 0xF0000002, ThreadTickCount = 0xF0000002,
// 2.0.0+ // 2.0.0+
ASLRRegionBaseAddr = 12, ASLRRegionBaseAddr = 12,
ASLRRegionSize = 13, ASLRRegionSize = 13,
@ -730,7 +730,9 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
PrivilegedProcessId = 19, PrivilegedProcessId = 19,
// 5.0.0+ // 5.0.0+
UserExceptionContextAddr = 20, UserExceptionContextAddr = 20,
ThreadTickCount = 0xF0000002, // 6.0.0+
TotalPhysicalMemoryAvailableWithoutMmHeap = 21,
TotalPhysicalMemoryUsedWithoutMmHeap = 22,
}; };
const auto info_id_type = static_cast<GetInfoType>(info_id); const auto info_id_type = static_cast<GetInfoType>(info_id);
@ -746,12 +748,14 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
case GetInfoType::ASLRRegionSize: case GetInfoType::ASLRRegionSize:
case GetInfoType::NewMapRegionBaseAddr: case GetInfoType::NewMapRegionBaseAddr:
case GetInfoType::NewMapRegionSize: case GetInfoType::NewMapRegionSize:
case GetInfoType::TotalMemoryUsage: case GetInfoType::TotalPhysicalMemoryAvailable:
case GetInfoType::TotalPhysicalMemoryUsed: case GetInfoType::TotalPhysicalMemoryUsed:
case GetInfoType::IsVirtualAddressMemoryEnabled: case GetInfoType::IsVirtualAddressMemoryEnabled:
case GetInfoType::PersonalMmHeapUsage: case GetInfoType::PersonalMmHeapUsage:
case GetInfoType::TitleId: case GetInfoType::TitleId:
case GetInfoType::UserExceptionContextAddr: { case GetInfoType::UserExceptionContextAddr:
case GetInfoType::TotalPhysicalMemoryAvailableWithoutMmHeap:
case GetInfoType::TotalPhysicalMemoryUsedWithoutMmHeap: {
if (info_sub_id != 0) { if (info_sub_id != 0) {
return ERR_INVALID_ENUM_VALUE; return ERR_INVALID_ENUM_VALUE;
} }
@ -804,8 +808,8 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
*result = process->VMManager().GetNewMapRegionSize(); *result = process->VMManager().GetNewMapRegionSize();
return RESULT_SUCCESS; return RESULT_SUCCESS;
case GetInfoType::TotalMemoryUsage: case GetInfoType::TotalPhysicalMemoryAvailable:
*result = process->VMManager().GetTotalMemoryUsage(); *result = process->GetTotalPhysicalMemoryAvailable();
return RESULT_SUCCESS; return RESULT_SUCCESS;
case GetInfoType::TotalPhysicalMemoryUsed: case GetInfoType::TotalPhysicalMemoryUsed:
@ -826,6 +830,14 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
*result = 0; *result = 0;
return RESULT_SUCCESS; return RESULT_SUCCESS;
case GetInfoType::TotalPhysicalMemoryAvailableWithoutMmHeap:
*result = process->GetTotalPhysicalMemoryAvailable();
return RESULT_SUCCESS;
case GetInfoType::TotalPhysicalMemoryUsedWithoutMmHeap:
*result = process->GetTotalPhysicalMemoryUsedWithoutMmHeap();
return RESULT_SUCCESS;
default: default:
break; break;
} }

View file

@ -758,7 +758,7 @@ VMManager::CheckResults VMManager::CheckRangeState(VAddr address, u64 size, Memo
std::make_tuple(initial_state, initial_permissions, initial_attributes & ~ignore_mask)); std::make_tuple(initial_state, initial_permissions, initial_attributes & ~ignore_mask));
} }
u64 VMManager::GetTotalMemoryUsage() const { u64 VMManager::GetTotalPhysicalMemoryAvailable() const {
LOG_WARNING(Kernel, "(STUBBED) called"); LOG_WARNING(Kernel, "(STUBBED) called");
return 0xF8000000; return 0xF8000000;
} }

View file

@ -499,7 +499,7 @@ public:
void LogLayout() const; void LogLayout() const;
/// Gets the total memory usage, used by svcGetInfo /// Gets the total memory usage, used by svcGetInfo
u64 GetTotalMemoryUsage() const; u64 GetTotalPhysicalMemoryAvailable() const;
/// Gets the address space base address /// Gets the address space base address
VAddr GetAddressSpaceBaseAddress() const; VAddr GetAddressSpaceBaseAddress() const;