summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/timer.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/timer.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/timer.h')
-rw-r--r--src/core/hle/kernel/timer.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/core/hle/kernel/timer.h b/src/core/hle/kernel/timer.h
index 4dddc67e0..12915c1b1 100644
--- a/src/core/hle/kernel/timer.h
+++ b/src/core/hle/kernel/timer.h
@@ -10,15 +10,19 @@
10 10
11namespace Kernel { 11namespace Kernel {
12 12
13class KernelCore;
14
13class Timer final : public WaitObject { 15class Timer final : public WaitObject {
14public: 16public:
15 /** 17 /**
16 * Creates a timer 18 * Creates a timer
19 * @param kernel The kernel instance to create the timer callback handle for.
17 * @param reset_type ResetType describing how to create the timer 20 * @param reset_type ResetType describing how to create the timer
18 * @param name Optional name of timer 21 * @param name Optional name of timer
19 * @return The created Timer 22 * @return The created Timer
20 */ 23 */
21 static SharedPtr<Timer> Create(ResetType reset_type, std::string name = "Unknown"); 24 static SharedPtr<Timer> Create(KernelCore& kernel, ResetType reset_type,
25 std::string name = "Unknown");
22 26
23 std::string GetTypeName() const override { 27 std::string GetTypeName() const override {
24 return "Timer"; 28 return "Timer";
@@ -68,7 +72,7 @@ public:
68 void Signal(int cycles_late); 72 void Signal(int cycles_late);
69 73
70private: 74private:
71 Timer(); 75 explicit Timer(KernelCore& kernel);
72 ~Timer() override; 76 ~Timer() override;
73 77
74 ResetType reset_type; ///< The ResetType of this timer 78 ResetType reset_type; ///< The ResetType of this timer
@@ -83,9 +87,4 @@ private:
83 Handle callback_handle; 87 Handle callback_handle;
84}; 88};
85 89
86/// Initializes the required variables for timers
87void TimersInit();
88/// Tears down the timer variables
89void TimersShutdown();
90
91} // namespace Kernel 90} // namespace Kernel