summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/process.h
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/hle/kernel/process.h
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/hle/kernel/process.h')
-rw-r--r--src/core/hle/kernel/process.h21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index 992689186..1587d40c1 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -19,6 +19,8 @@
19 19
20namespace Kernel { 20namespace Kernel {
21 21
22class KernelCore;
23
22struct AddressMapping { 24struct AddressMapping {
23 // Address and size must be page-aligned 25 // Address and size must be page-aligned
24 VAddr address; 26 VAddr address;
@@ -62,7 +64,7 @@ struct CodeSet final : public Object {
62 u32 size = 0; 64 u32 size = 0;
63 }; 65 };
64 66
65 static SharedPtr<CodeSet> Create(std::string name); 67 static SharedPtr<CodeSet> Create(KernelCore& kernel, std::string name);
66 68
67 std::string GetTypeName() const override { 69 std::string GetTypeName() const override {
68 return "CodeSet"; 70 return "CodeSet";
@@ -109,13 +111,13 @@ struct CodeSet final : public Object {
109 std::string name; 111 std::string name;
110 112
111private: 113private:
112 CodeSet(); 114 explicit CodeSet(KernelCore& kernel);
113 ~CodeSet() override; 115 ~CodeSet() override;
114}; 116};
115 117
116class Process final : public Object { 118class Process final : public Object {
117public: 119public:
118 static SharedPtr<Process> Create(std::string&& name); 120 static SharedPtr<Process> Create(KernelCore& kernel, std::string&& name);
119 121
120 std::string GetTypeName() const override { 122 std::string GetTypeName() const override {
121 return "Process"; 123 return "Process";
@@ -129,8 +131,6 @@ public:
129 return HANDLE_TYPE; 131 return HANDLE_TYPE;
130 } 132 }
131 133
132 static u32 next_process_id;
133
134 /// Title ID corresponding to the process 134 /// Title ID corresponding to the process
135 u64 program_id; 135 u64 program_id;
136 136
@@ -157,8 +157,8 @@ public:
157 /// Current status of the process 157 /// Current status of the process
158 ProcessStatus status; 158 ProcessStatus status;
159 159
160 /// The id of this process 160 /// The ID of this process
161 u32 process_id = next_process_id++; 161 u32 process_id = 0;
162 162
163 /** 163 /**
164 * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them 164 * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them
@@ -206,13 +206,8 @@ public:
206 ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size); 206 ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size);
207 207
208private: 208private:
209 Process(); 209 explicit Process(KernelCore& kernel);
210 ~Process() override; 210 ~Process() override;
211}; 211};
212 212
213void ClearProcessList();
214
215/// Retrieves a process from the current list of processes.
216SharedPtr<Process> GetProcessById(u32 process_id);
217
218} // namespace Kernel 213} // namespace Kernel