kern: fix/add InfoType_(Total/Used)(NonSystem/)MemorySize

This commit is contained in:
Michael Scire 2020-07-13 12:17:28 -07:00
parent 35c1959131
commit 57867d6ced
5 changed files with 38 additions and 3 deletions

View file

@ -303,7 +303,7 @@ namespace ams::kern {
this->thread_list.erase(this->thread_list.iterator_to(*thread));
}
size_t KProcess::GetUsedNonSystemUserPhysicalMemorySize() const {
size_t KProcess::GetUsedUserPhysicalMemorySize() const {
const size_t norm_size = this->page_table.GetNormalMemorySize();
const size_t other_size = this->code_size + this->main_thread_stack_size;
const size_t sec_size = KSystemControl::CalculateRequiredSecureMemorySize(this->system_resource_num_pages * PageSize, this->memory_pool);
@ -311,10 +311,30 @@ namespace ams::kern {
return norm_size + other_size + sec_size;
}
size_t KProcess::GetTotalNonSystemUserPhysicalMemorySize() const {
size_t KProcess::GetTotalUserPhysicalMemorySize() const {
/* Get the amount of free and used size. */
const size_t free_size = this->resource_limit->GetFreeValue(ams::svc::LimitableResource_PhysicalMemoryMax);
const size_t used_size = this->GetUsedNonSystemUserPhysicalMemorySize();
const size_t max_size = this->max_process_memory;
if (used_size + free_size > max_size) {
return max_size;
} else {
return free_size + used_size;
}
}
size_t KProcess::GetUsedNonSystemUserPhysicalMemorySize() const {
const size_t norm_size = this->page_table.GetNormalMemorySize();
const size_t other_size = this->code_size + this->main_thread_stack_size;
return norm_size + other_size;
}
size_t KProcess::GetTotalNonSystemUserPhysicalMemorySize() const {
/* Get the amount of free and used size. */
const size_t free_size = this->resource_limit->GetFreeValue(ams::svc::LimitableResource_PhysicalMemoryMax);
const size_t used_size = this->GetUsedUserPhysicalMemorySize();
const size_t sec_size = KSystemControl::CalculateRequiredSecureMemorySize(this->system_resource_num_pages * PageSize, this->memory_pool);
const size_t max_size = this->max_process_memory;