summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/process.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2019-03-30 20:11:17 -0400
committerGravatar GitHub2019-03-30 20:11:17 -0400
commitd9b7bc44748908d49d59433870211df8e1c32581 (patch)
tree37faebdb5dcdd6fb3e6eabbd9e81290ed94396df /src/core/hle/kernel/process.cpp
parentMerge pull request #2303 from lioncash/thread (diff)
parentkernel/process: Report total physical memory used to svcGetInfo (diff)
downloadyuzu-d9b7bc44748908d49d59433870211df8e1c32581.tar.gz
yuzu-d9b7bc44748908d49d59433870211df8e1c32581.tar.xz
yuzu-d9b7bc44748908d49d59433870211df8e1c32581.zip
Merge pull request #2304 from lioncash/memsize
kernel/process: Report total physical memory used to svcGetInfo slightly better
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
-rw-r--r--src/core/hle/kernel/process.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index 0d782e4ba..b0b7af76b 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -5,6 +5,7 @@
5#include <algorithm> 5#include <algorithm>
6#include <memory> 6#include <memory>
7#include <random> 7#include <random>
8#include "common/alignment.h"
8#include "common/assert.h" 9#include "common/assert.h"
9#include "common/logging/log.h" 10#include "common/logging/log.h"
10#include "core/core.h" 11#include "core/core.h"
@@ -75,6 +76,10 @@ SharedPtr<ResourceLimit> Process::GetResourceLimit() const {
75 return resource_limit; 76 return resource_limit;
76} 77}
77 78
79u64 Process::GetTotalPhysicalMemoryUsed() const {
80 return vm_manager.GetCurrentHeapSize() + main_thread_stack_size + code_memory_size;
81}
82
78ResultCode Process::ClearSignalState() { 83ResultCode Process::ClearSignalState() {
79 if (status == ProcessStatus::Exited) { 84 if (status == ProcessStatus::Exited) {
80 LOG_ERROR(Kernel, "called on a terminated process instance."); 85 LOG_ERROR(Kernel, "called on a terminated process instance.");
@@ -107,14 +112,17 @@ ResultCode Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata) {
107 return handle_table.SetSize(capabilities.GetHandleTableSize()); 112 return handle_table.SetSize(capabilities.GetHandleTableSize());
108} 113}
109 114
110void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) { 115void Process::Run(VAddr entry_point, s32 main_thread_priority, u64 stack_size) {
116 // The kernel always ensures that the given stack size is page aligned.
117 main_thread_stack_size = Common::AlignUp(stack_size, Memory::PAGE_SIZE);
118
111 // Allocate and map the main thread stack 119 // Allocate and map the main thread stack
112 // TODO(bunnei): This is heap area that should be allocated by the kernel and not mapped as part 120 // TODO(bunnei): This is heap area that should be allocated by the kernel and not mapped as part
113 // of the user address space. 121 // of the user address space.
122 const VAddr mapping_address = vm_manager.GetTLSIORegionEndAddress() - main_thread_stack_size;
114 vm_manager 123 vm_manager
115 .MapMemoryBlock(vm_manager.GetTLSIORegionEndAddress() - stack_size, 124 .MapMemoryBlock(mapping_address, std::make_shared<std::vector<u8>>(main_thread_stack_size),
116 std::make_shared<std::vector<u8>>(stack_size, 0), 0, stack_size, 125 0, main_thread_stack_size, MemoryState::Stack)
117 MemoryState::Stack)
118 .Unwrap(); 126 .Unwrap();
119 127
120 vm_manager.LogLayout(); 128 vm_manager.LogLayout();
@@ -224,6 +232,8 @@ void Process::LoadModule(CodeSet module_, VAddr base_addr) {
224 MapSegment(module_.RODataSegment(), VMAPermission::Read, MemoryState::CodeData); 232 MapSegment(module_.RODataSegment(), VMAPermission::Read, MemoryState::CodeData);
225 MapSegment(module_.DataSegment(), VMAPermission::ReadWrite, MemoryState::CodeData); 233 MapSegment(module_.DataSegment(), VMAPermission::ReadWrite, MemoryState::CodeData);
226 234
235 code_memory_size += module_.memory->size();
236
227 // Clear instruction cache in CPU JIT 237 // Clear instruction cache in CPU JIT
228 system.InvalidateCpuInstructionCaches(); 238 system.InvalidateCpuInstructionCaches();
229} 239}