aboutsummaryrefslogtreecommitdiff
path: root/src/core/loader/elf.cpp
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2017-09-26 18:17:47 -0500
committerSubv <subv2112@gmail.com>2017-09-26 18:17:47 -0500
commit7f48aa8d2580da6b3b83a389e31804e493aba69f (patch)
tree287b04f23f2d195f123fd15dca68d6a1cebf945c /src/core/loader/elf.cpp
parent3165466b665185ecbc3e33b02b0b90e25e7248ba (diff)
Loaders: Don't automatically set the current process every time we load an application.
The loaders will now just create a Kernel::Process, construct it and return it to the caller, which is responsible for setting it as the current process and configuring the global page table.
Diffstat (limited to 'src/core/loader/elf.cpp')
-rw-r--r--src/core/loader/elf.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 2de1f4e816..e36e421200 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -13,8 +13,8 @@
#include "core/loader/elf.h"
#include "core/memory.h"
-using Kernel::SharedPtr;
using Kernel::CodeSet;
+using Kernel::SharedPtr;
////////////////////////////////////////////////////////////////////////////////////////////////////
// ELF Header Constants
@@ -375,7 +375,7 @@ FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file) {
return FileType::Error;
}
-ResultStatus AppLoader_ELF::Load() {
+ResultStatus AppLoader_ELF::Load(Kernel::SharedPtr<Kernel::Process>& process) {
if (is_loaded)
return ResultStatus::ErrorAlreadyLoaded;
@@ -394,16 +394,15 @@ ResultStatus AppLoader_ELF::Load() {
SharedPtr<CodeSet> codeset = elf_reader.LoadInto(Memory::PROCESS_IMAGE_VADDR);
codeset->name = filename;
- Kernel::g_current_process = Kernel::Process::Create(std::move(codeset));
- Kernel::g_current_process->svc_access_mask.set();
- Kernel::g_current_process->address_mappings = default_address_mappings;
- Memory::SetCurrentPageTable(&Kernel::g_current_process->vm_manager.page_table);
+ process = Kernel::Process::Create(std::move(codeset));
+ process->svc_access_mask.set();
+ process->address_mappings = default_address_mappings;
// Attach the default resource limit (APPLICATION) to the process
- Kernel::g_current_process->resource_limit =
+ process->resource_limit =
Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
- Kernel::g_current_process->Run(48, Kernel::DEFAULT_STACK_SIZE);
+ process->Run(48, Kernel::DEFAULT_STACK_SIZE);
is_loaded = true;
return ResultStatus::Success;