diff options
author | Lioncash <mathew1800@gmail.com> | 2018-08-28 12:30:33 -0400 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2018-08-28 22:31:51 -0400 |
commit | 0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5 (patch) | |
tree | 2d7bb143d490c3984bff6deda426b818bf27d552 /src/core/hle/kernel/process.h | |
parent | 4d7e1662c84ef65f7da5a27b0473125cc6759d5c (diff) |
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/hle/kernel/process.h')
-rw-r--r-- | src/core/hle/kernel/process.h | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 9926891864..1587d40c1e 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -19,6 +19,8 @@ namespace Kernel { +class KernelCore; + struct AddressMapping { // Address and size must be page-aligned VAddr address; @@ -62,7 +64,7 @@ struct CodeSet final : public Object { u32 size = 0; }; - static SharedPtr<CodeSet> Create(std::string name); + static SharedPtr<CodeSet> Create(KernelCore& kernel, std::string name); std::string GetTypeName() const override { return "CodeSet"; @@ -109,13 +111,13 @@ struct CodeSet final : public Object { std::string name; private: - CodeSet(); + explicit CodeSet(KernelCore& kernel); ~CodeSet() override; }; class Process final : public Object { public: - static SharedPtr<Process> Create(std::string&& name); + static SharedPtr<Process> Create(KernelCore& kernel, std::string&& name); std::string GetTypeName() const override { return "Process"; @@ -129,8 +131,6 @@ public: return HANDLE_TYPE; } - static u32 next_process_id; - /// Title ID corresponding to the process u64 program_id; @@ -157,8 +157,8 @@ public: /// Current status of the process ProcessStatus status; - /// The id of this process - u32 process_id = next_process_id++; + /// The ID of this process + u32 process_id = 0; /** * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them @@ -206,13 +206,8 @@ public: ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size); private: - Process(); + explicit Process(KernelCore& kernel); ~Process() override; }; -void ClearProcessList(); - -/// Retrieves a process from the current list of processes. -SharedPtr<Process> GetProcessById(u32 process_id); - } // namespace Kernel |