summaryrefslogtreecommitdiff
path: root/src/core/loader/elf.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-28 12:30:33 -0400
committerGravatar Lioncash2018-08-28 22:31:51 -0400
commit0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5 (patch)
tree2d7bb143d490c3984bff6deda426b818bf27d552 /src/core/loader/elf.cpp
parentMerge pull request #1193 from lioncash/priv (diff)
downloadyuzu-0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5.tar.gz
yuzu-0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5.tar.xz
yuzu-0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5.zip
kernel: Eliminate kernel global state
As means to pave the way for getting rid of global state within core, This eliminates kernel global state by removing all globals. Instead this introduces a KernelCore class which acts as a kernel instance. This instance lives in the System class, which keeps its lifetime contained to the lifetime of the System class. This also forces the kernel types to actually interact with the main kernel instance itself instead of having transient kernel state placed all over several translation units, keeping everything together. It also has a nice consequence of making dependencies much more explicit. This also makes our initialization a tad bit more correct. Previously we were creating a kernel process before the actual kernel was initialized, which doesn't really make much sense. The KernelCore class itself follows the PImpl idiom, which allows keeping all the implementation details sealed away from everything else, which forces the use of the exposed API and allows us to avoid any unnecessary inclusions within the main kernel header.
Diffstat (limited to 'src/core/loader/elf.cpp')
-rw-r--r--src/core/loader/elf.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 6420a7f11..3702a8478 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -9,6 +9,7 @@
9#include "common/common_types.h" 9#include "common/common_types.h"
10#include "common/file_util.h" 10#include "common/file_util.h"
11#include "common/logging/log.h" 11#include "common/logging/log.h"
12#include "core/core.h"
12#include "core/hle/kernel/process.h" 13#include "core/hle/kernel/process.h"
13#include "core/hle/kernel/resource_limit.h" 14#include "core/hle/kernel/resource_limit.h"
14#include "core/loader/elf.h" 15#include "core/loader/elf.h"
@@ -300,7 +301,8 @@ SharedPtr<CodeSet> ElfReader::LoadInto(u32 vaddr) {
300 std::vector<u8> program_image(total_image_size); 301 std::vector<u8> program_image(total_image_size);
301 size_t current_image_position = 0; 302 size_t current_image_position = 0;
302 303
303 SharedPtr<CodeSet> codeset = CodeSet::Create(""); 304 auto& kernel = Core::System::GetInstance().Kernel();
305 SharedPtr<CodeSet> codeset = CodeSet::Create(kernel, "");
304 306
305 for (unsigned int i = 0; i < header->e_phnum; ++i) { 307 for (unsigned int i = 0; i < header->e_phnum; ++i) {
306 Elf32_Phdr* p = &segments[i]; 308 Elf32_Phdr* p = &segments[i];
@@ -400,8 +402,9 @@ ResultStatus AppLoader_ELF::Load(Kernel::SharedPtr<Kernel::Process>& process) {
400 process->svc_access_mask.set(); 402 process->svc_access_mask.set();
401 403
402 // Attach the default resource limit (APPLICATION) to the process 404 // Attach the default resource limit (APPLICATION) to the process
405 auto& kernel = Core::System::GetInstance().Kernel();
403 process->resource_limit = 406 process->resource_limit =
404 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); 407 kernel.ResourceLimitForCategory(Kernel::ResourceLimitCategory::APPLICATION);
405 408
406 process->Run(codeset->entrypoint, 48, Memory::DEFAULT_STACK_SIZE); 409 process->Run(codeset->entrypoint, 48, Memory::DEFAULT_STACK_SIZE);
407 410