diff options
| author | 2017-09-29 14:58:42 -0400 | |
|---|---|---|
| committer | 2017-09-29 14:58:42 -0400 | |
| commit | b07af7dda822898e9c8f231c5ddcd1741d93dbef (patch) | |
| tree | d41c9221d6065b8cf9e6a2405565b675a9c83c51 /src/core/loader/ncch.cpp | |
| parent | Merge pull request #2907 from Subv/warnings3 (diff) | |
| parent | Loaders: Don't automatically set the current process every time we load an ap... (diff) | |
| download | yuzu-b07af7dda822898e9c8f231c5ddcd1741d93dbef.tar.gz yuzu-b07af7dda822898e9c8f231c5ddcd1741d93dbef.tar.xz yuzu-b07af7dda822898e9c8f231c5ddcd1741d93dbef.zip | |
Merge pull request #2961 from Subv/load_titles
Loaders: Don't automatically set the current process every time we load an application.
Diffstat (limited to 'src/core/loader/ncch.cpp')
| -rw-r--r-- | src/core/loader/ncch.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 5107135f9..66bc5823d 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp | |||
| @@ -67,9 +67,9 @@ std::pair<boost::optional<u32>, ResultStatus> AppLoader_NCCH::LoadKernelSystemMo | |||
| 67 | ResultStatus::Success); | 67 | ResultStatus::Success); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | ResultStatus AppLoader_NCCH::LoadExec() { | 70 | ResultStatus AppLoader_NCCH::LoadExec(Kernel::SharedPtr<Kernel::Process>& process) { |
| 71 | using Kernel::SharedPtr; | ||
| 72 | using Kernel::CodeSet; | 71 | using Kernel::CodeSet; |
| 72 | using Kernel::SharedPtr; | ||
| 73 | 73 | ||
| 74 | if (!is_loaded) | 74 | if (!is_loaded) |
| 75 | return ResultStatus::ErrorNotLoaded; | 75 | return ResultStatus::ErrorNotLoaded; |
| @@ -107,16 +107,15 @@ ResultStatus AppLoader_NCCH::LoadExec() { | |||
| 107 | codeset->entrypoint = codeset->code.addr; | 107 | codeset->entrypoint = codeset->code.addr; |
| 108 | codeset->memory = std::make_shared<std::vector<u8>>(std::move(code)); | 108 | codeset->memory = std::make_shared<std::vector<u8>>(std::move(code)); |
| 109 | 109 | ||
| 110 | Kernel::g_current_process = Kernel::Process::Create(std::move(codeset)); | 110 | process = Kernel::Process::Create(std::move(codeset)); |
| 111 | Memory::SetCurrentPageTable(&Kernel::g_current_process->vm_manager.page_table); | ||
| 112 | 111 | ||
| 113 | // Attach a resource limit to the process based on the resource limit category | 112 | // Attach a resource limit to the process based on the resource limit category |
| 114 | Kernel::g_current_process->resource_limit = | 113 | process->resource_limit = |
| 115 | Kernel::ResourceLimit::GetForCategory(static_cast<Kernel::ResourceLimitCategory>( | 114 | Kernel::ResourceLimit::GetForCategory(static_cast<Kernel::ResourceLimitCategory>( |
| 116 | overlay_ncch->exheader_header.arm11_system_local_caps.resource_limit_category)); | 115 | overlay_ncch->exheader_header.arm11_system_local_caps.resource_limit_category)); |
| 117 | 116 | ||
| 118 | // Set the default CPU core for this process | 117 | // Set the default CPU core for this process |
| 119 | Kernel::g_current_process->ideal_processor = | 118 | process->ideal_processor = |
| 120 | overlay_ncch->exheader_header.arm11_system_local_caps.ideal_processor; | 119 | overlay_ncch->exheader_header.arm11_system_local_caps.ideal_processor; |
| 121 | 120 | ||
| 122 | // Copy data while converting endianness | 121 | // Copy data while converting endianness |
| @@ -124,11 +123,11 @@ ResultStatus AppLoader_NCCH::LoadExec() { | |||
| 124 | kernel_caps; | 123 | kernel_caps; |
| 125 | std::copy_n(overlay_ncch->exheader_header.arm11_kernel_caps.descriptors, kernel_caps.size(), | 124 | std::copy_n(overlay_ncch->exheader_header.arm11_kernel_caps.descriptors, kernel_caps.size(), |
| 126 | begin(kernel_caps)); | 125 | begin(kernel_caps)); |
| 127 | Kernel::g_current_process->ParseKernelCaps(kernel_caps.data(), kernel_caps.size()); | 126 | process->ParseKernelCaps(kernel_caps.data(), kernel_caps.size()); |
| 128 | 127 | ||
| 129 | s32 priority = overlay_ncch->exheader_header.arm11_system_local_caps.priority; | 128 | s32 priority = overlay_ncch->exheader_header.arm11_system_local_caps.priority; |
| 130 | u32 stack_size = overlay_ncch->exheader_header.codeset_info.stack_size; | 129 | u32 stack_size = overlay_ncch->exheader_header.codeset_info.stack_size; |
| 131 | Kernel::g_current_process->Run(priority, stack_size); | 130 | process->Run(priority, stack_size); |
| 132 | return ResultStatus::Success; | 131 | return ResultStatus::Success; |
| 133 | } | 132 | } |
| 134 | return ResultStatus::Error; | 133 | return ResultStatus::Error; |
| @@ -151,7 +150,7 @@ void AppLoader_NCCH::ParseRegionLockoutInfo() { | |||
| 151 | } | 150 | } |
| 152 | } | 151 | } |
| 153 | 152 | ||
| 154 | ResultStatus AppLoader_NCCH::Load() { | 153 | ResultStatus AppLoader_NCCH::Load(Kernel::SharedPtr<Kernel::Process>& process) { |
| 155 | u64_le ncch_program_id; | 154 | u64_le ncch_program_id; |
| 156 | 155 | ||
| 157 | if (is_loaded) | 156 | if (is_loaded) |
| @@ -183,7 +182,7 @@ ResultStatus AppLoader_NCCH::Load() { | |||
| 183 | 182 | ||
| 184 | is_loaded = true; // Set state to loaded | 183 | is_loaded = true; // Set state to loaded |
| 185 | 184 | ||
| 186 | result = LoadExec(); // Load the executable into memory for booting | 185 | result = LoadExec(process); // Load the executable into memory for booting |
| 187 | if (ResultStatus::Success != result) | 186 | if (ResultStatus::Success != result) |
| 188 | return result; | 187 | return result; |
| 189 | 188 | ||