summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/process.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2019-04-19 19:09:20 -0400
committerGravatar GitHub2019-04-19 19:09:20 -0400
commit40dc893c372c81c687eca2d0b964220a8f8aeab4 (patch)
tree1c05675d446978752a749f2cb18a797c6b737998 /src/core/hle/kernel/process.cpp
parentMerge pull request #2397 from lioncash/thread-unused (diff)
parentcore/core: Move process execution start to System's Load() (diff)
downloadyuzu-40dc893c372c81c687eca2d0b964220a8f8aeab4.tar.gz
yuzu-40dc893c372c81c687eca2d0b964220a8f8aeab4.tar.xz
yuzu-40dc893c372c81c687eca2d0b964220a8f8aeab4.zip
Merge pull request #2374 from lioncash/pagetable
core: Reorganize boot order
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
-rw-r--r--src/core/hle/kernel/process.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index 8b2b3877d..6d7a7e754 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -28,12 +28,12 @@ namespace {
28 * 28 *
29 * @param owner_process The parent process for the main thread 29 * @param owner_process The parent process for the main thread
30 * @param kernel The kernel instance to create the main thread under. 30 * @param kernel The kernel instance to create the main thread under.
31 * @param entry_point The address at which the thread should start execution
32 * @param priority The priority to give the main thread 31 * @param priority The priority to give the main thread
33 */ 32 */
34void SetupMainThread(Process& owner_process, KernelCore& kernel, VAddr entry_point, u32 priority) { 33void SetupMainThread(Process& owner_process, KernelCore& kernel, u32 priority) {
35 // Initialize new "main" thread 34 const auto& vm_manager = owner_process.VMManager();
36 const VAddr stack_top = owner_process.VMManager().GetTLSIORegionEndAddress(); 35 const VAddr entry_point = vm_manager.GetCodeRegionBaseAddress();
36 const VAddr stack_top = vm_manager.GetTLSIORegionEndAddress();
37 auto thread_res = Thread::Create(kernel, "main", entry_point, priority, 0, 37 auto thread_res = Thread::Create(kernel, "main", entry_point, priority, 0,
38 owner_process.GetIdealCore(), stack_top, owner_process); 38 owner_process.GetIdealCore(), stack_top, owner_process);
39 39
@@ -105,8 +105,6 @@ ResultCode Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata) {
105 is_64bit_process = metadata.Is64BitProgram(); 105 is_64bit_process = metadata.Is64BitProgram();
106 106
107 vm_manager.Reset(metadata.GetAddressSpaceType()); 107 vm_manager.Reset(metadata.GetAddressSpaceType());
108 // Ensure that the potentially resized page table is seen by CPU backends.
109 Memory::SetCurrentPageTable(&vm_manager.page_table);
110 108
111 const auto& caps = metadata.GetKernelCapabilities(); 109 const auto& caps = metadata.GetKernelCapabilities();
112 const auto capability_init_result = 110 const auto capability_init_result =
@@ -118,7 +116,7 @@ ResultCode Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata) {
118 return handle_table.SetSize(capabilities.GetHandleTableSize()); 116 return handle_table.SetSize(capabilities.GetHandleTableSize());
119} 117}
120 118
121void Process::Run(VAddr entry_point, s32 main_thread_priority, u64 stack_size) { 119void Process::Run(s32 main_thread_priority, u64 stack_size) {
122 // The kernel always ensures that the given stack size is page aligned. 120 // The kernel always ensures that the given stack size is page aligned.
123 main_thread_stack_size = Common::AlignUp(stack_size, Memory::PAGE_SIZE); 121 main_thread_stack_size = Common::AlignUp(stack_size, Memory::PAGE_SIZE);
124 122
@@ -134,7 +132,7 @@ void Process::Run(VAddr entry_point, s32 main_thread_priority, u64 stack_size) {
134 vm_manager.LogLayout(); 132 vm_manager.LogLayout();
135 ChangeStatus(ProcessStatus::Running); 133 ChangeStatus(ProcessStatus::Running);
136 134
137 SetupMainThread(*this, kernel, entry_point, main_thread_priority); 135 SetupMainThread(*this, kernel, main_thread_priority);
138} 136}
139 137
140void Process::PrepareForTermination() { 138void Process::PrepareForTermination() {
@@ -241,9 +239,6 @@ void Process::LoadModule(CodeSet module_, VAddr base_addr) {
241 MapSegment(module_.DataSegment(), VMAPermission::ReadWrite, MemoryState::CodeData); 239 MapSegment(module_.DataSegment(), VMAPermission::ReadWrite, MemoryState::CodeData);
242 240
243 code_memory_size += module_.memory.size(); 241 code_memory_size += module_.memory.size();
244
245 // Clear instruction cache in CPU JIT
246 system.InvalidateCpuInstructionCaches();
247} 242}
248 243
249Process::Process(Core::System& system) 244Process::Process(Core::System& system)