summaryrefslogtreecommitdiffstats
path: root/src/core/loader/ncch.cpp
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2017-09-27 01:17:47 +0200
committerSubv <subv2112@gmail.com>2017-09-27 01:17:47 +0200
commit7f48aa8d2580da6b3b83a389e31804e493aba69f (patch)
tree287b04f23f2d195f123fd15dca68d6a1cebf945c /src/core/loader/ncch.cpp
parentKernel/Thread: Allow specifying which process a thread belongs to when creating it. (diff)
downloadyuzu-7f48aa8d2580da6b3b83a389e31804e493aba69f.tar
yuzu-7f48aa8d2580da6b3b83a389e31804e493aba69f.tar.gz
yuzu-7f48aa8d2580da6b3b83a389e31804e493aba69f.tar.bz2
yuzu-7f48aa8d2580da6b3b83a389e31804e493aba69f.tar.lz
yuzu-7f48aa8d2580da6b3b83a389e31804e493aba69f.tar.xz
yuzu-7f48aa8d2580da6b3b83a389e31804e493aba69f.tar.zst
yuzu-7f48aa8d2580da6b3b83a389e31804e493aba69f.zip
Diffstat (limited to 'src/core/loader/ncch.cpp')
-rw-r--r--src/core/loader/ncch.cpp19
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
ResultStatus::Success);
}
-ResultStatus AppLoader_NCCH::LoadExec() {
- using Kernel::SharedPtr;
+ResultStatus AppLoader_NCCH::LoadExec(Kernel::SharedPtr<Kernel::Process>& process) {
using Kernel::CodeSet;
+ using Kernel::SharedPtr;
if (!is_loaded)
return ResultStatus::ErrorNotLoaded;
@@ -107,16 +107,15 @@ ResultStatus AppLoader_NCCH::LoadExec() {
codeset->entrypoint = codeset->code.addr;
codeset->memory = std::make_shared<std::vector<u8>>(std::move(code));
- Kernel::g_current_process = Kernel::Process::Create(std::move(codeset));
- Memory::SetCurrentPageTable(&Kernel::g_current_process->vm_manager.page_table);
+ process = Kernel::Process::Create(std::move(codeset));
// Attach a resource limit to the process based on the resource limit category
- Kernel::g_current_process->resource_limit =
+ process->resource_limit =
Kernel::ResourceLimit::GetForCategory(static_cast<Kernel::ResourceLimitCategory>(
overlay_ncch->exheader_header.arm11_system_local_caps.resource_limit_category));
// Set the default CPU core for this process
- Kernel::g_current_process->ideal_processor =
+ process->ideal_processor =
overlay_ncch->exheader_header.arm11_system_local_caps.ideal_processor;
// Copy data while converting endianness
@@ -124,11 +123,11 @@ ResultStatus AppLoader_NCCH::LoadExec() {
kernel_caps;
std::copy_n(overlay_ncch->exheader_header.arm11_kernel_caps.descriptors, kernel_caps.size(),
begin(kernel_caps));
- Kernel::g_current_process->ParseKernelCaps(kernel_caps.data(), kernel_caps.size());
+ process->ParseKernelCaps(kernel_caps.data(), kernel_caps.size());
s32 priority = overlay_ncch->exheader_header.arm11_system_local_caps.priority;
u32 stack_size = overlay_ncch->exheader_header.codeset_info.stack_size;
- Kernel::g_current_process->Run(priority, stack_size);
+ process->Run(priority, stack_size);
return ResultStatus::Success;
}
return ResultStatus::Error;
@@ -151,7 +150,7 @@ void AppLoader_NCCH::ParseRegionLockoutInfo() {
}
}
-ResultStatus AppLoader_NCCH::Load() {
+ResultStatus AppLoader_NCCH::Load(Kernel::SharedPtr<Kernel::Process>& process) {
u64_le ncch_program_id;
if (is_loaded)
@@ -183,7 +182,7 @@ ResultStatus AppLoader_NCCH::Load() {
is_loaded = true; // Set state to loaded
- result = LoadExec(); // Load the executable into memory for booting
+ result = LoadExec(process); // Load the executable into memory for booting
if (ResultStatus::Success != result)
return result;