diff options
| author | 2017-09-26 18:17:47 -0500 | |
|---|---|---|
| committer | 2017-09-26 18:17:47 -0500 | |
| commit | 7f48aa8d2580da6b3b83a389e31804e493aba69f (patch) | |
| tree | 287b04f23f2d195f123fd15dca68d6a1cebf945c /src/core/loader/elf.cpp | |
| parent | Kernel/Thread: Allow specifying which process a thread belongs to when creati... (diff) | |
| download | yuzu-7f48aa8d2580da6b3b83a389e31804e493aba69f.tar.gz yuzu-7f48aa8d2580da6b3b83a389e31804e493aba69f.tar.xz yuzu-7f48aa8d2580da6b3b83a389e31804e493aba69f.zip | |
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.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index 2de1f4e81..e36e42120 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp | |||
| @@ -13,8 +13,8 @@ | |||
| 13 | #include "core/loader/elf.h" | 13 | #include "core/loader/elf.h" |
| 14 | #include "core/memory.h" | 14 | #include "core/memory.h" |
| 15 | 15 | ||
| 16 | using Kernel::SharedPtr; | ||
| 17 | using Kernel::CodeSet; | 16 | using Kernel::CodeSet; |
| 17 | using Kernel::SharedPtr; | ||
| 18 | 18 | ||
| 19 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 19 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 20 | // ELF Header Constants | 20 | // ELF Header Constants |
| @@ -375,7 +375,7 @@ FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file) { | |||
| 375 | return FileType::Error; | 375 | return FileType::Error; |
| 376 | } | 376 | } |
| 377 | 377 | ||
| 378 | ResultStatus AppLoader_ELF::Load() { | 378 | ResultStatus AppLoader_ELF::Load(Kernel::SharedPtr<Kernel::Process>& process) { |
| 379 | if (is_loaded) | 379 | if (is_loaded) |
| 380 | return ResultStatus::ErrorAlreadyLoaded; | 380 | return ResultStatus::ErrorAlreadyLoaded; |
| 381 | 381 | ||
| @@ -394,16 +394,15 @@ ResultStatus AppLoader_ELF::Load() { | |||
| 394 | SharedPtr<CodeSet> codeset = elf_reader.LoadInto(Memory::PROCESS_IMAGE_VADDR); | 394 | SharedPtr<CodeSet> codeset = elf_reader.LoadInto(Memory::PROCESS_IMAGE_VADDR); |
| 395 | codeset->name = filename; | 395 | codeset->name = filename; |
| 396 | 396 | ||
| 397 | Kernel::g_current_process = Kernel::Process::Create(std::move(codeset)); | 397 | process = Kernel::Process::Create(std::move(codeset)); |
| 398 | Kernel::g_current_process->svc_access_mask.set(); | 398 | process->svc_access_mask.set(); |
| 399 | Kernel::g_current_process->address_mappings = default_address_mappings; | 399 | process->address_mappings = default_address_mappings; |
| 400 | Memory::SetCurrentPageTable(&Kernel::g_current_process->vm_manager.page_table); | ||
| 401 | 400 | ||
| 402 | // Attach the default resource limit (APPLICATION) to the process | 401 | // Attach the default resource limit (APPLICATION) to the process |
| 403 | Kernel::g_current_process->resource_limit = | 402 | process->resource_limit = |
| 404 | Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); | 403 | Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); |
| 405 | 404 | ||
| 406 | Kernel::g_current_process->Run(48, Kernel::DEFAULT_STACK_SIZE); | 405 | process->Run(48, Kernel::DEFAULT_STACK_SIZE); |
| 407 | 406 | ||
| 408 | is_loaded = true; | 407 | is_loaded = true; |
| 409 | return ResultStatus::Success; | 408 | return ResultStatus::Success; |