summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/kernel.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2019-01-31 23:05:00 -0500
committerGravatar Lioncash2019-01-31 23:05:15 -0500
commit414cc1eb1fdbaa0001938711665f47c940bed3c7 (patch)
treec3897dd1193d322b52aba555fcb422badee1520d /src/core/hle/kernel/kernel.cpp
parentMerge pull request #2072 from lioncash/service (diff)
downloadyuzu-414cc1eb1fdbaa0001938711665f47c940bed3c7.tar.gz
yuzu-414cc1eb1fdbaa0001938711665f47c940bed3c7.tar.xz
yuzu-414cc1eb1fdbaa0001938711665f47c940bed3c7.zip
kernel: Remove the Timer class
A holdover from citra, the Horizon kernel on the switch has no prominent kernel object that functions as a timer. At least not to the degree of sophistication that this class provided. As such, this can be removed entirely. This class also wasn't used at all in any meaningful way within the core, so this was just code sitting around doing nothing. This also allows removing a few things from the main KernelCore class that allows it to use slightly less resources overall (though very minor and not anything really noticeable).
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r--src/core/hle/kernel/kernel.cpp42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 67674cd47..7a524ce5a 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -18,7 +18,6 @@
18#include "core/hle/kernel/process.h" 18#include "core/hle/kernel/process.h"
19#include "core/hle/kernel/resource_limit.h" 19#include "core/hle/kernel/resource_limit.h"
20#include "core/hle/kernel/thread.h" 20#include "core/hle/kernel/thread.h"
21#include "core/hle/kernel/timer.h"
22#include "core/hle/lock.h" 21#include "core/hle/lock.h"
23#include "core/hle/result.h" 22#include "core/hle/result.h"
24 23
@@ -86,27 +85,12 @@ static void ThreadWakeupCallback(u64 thread_handle, [[maybe_unused]] int cycles_
86 } 85 }
87} 86}
88 87
89/// The timer callback event, called when a timer is fired
90static void TimerCallback(u64 timer_handle, int cycles_late) {
91 const auto proper_handle = static_cast<Handle>(timer_handle);
92 const auto& system = Core::System::GetInstance();
93 SharedPtr<Timer> timer = system.Kernel().RetrieveTimerFromCallbackHandleTable(proper_handle);
94
95 if (timer == nullptr) {
96 LOG_CRITICAL(Kernel, "Callback fired for invalid timer {:016X}", timer_handle);
97 return;
98 }
99
100 timer->Signal(cycles_late);
101}
102
103struct KernelCore::Impl { 88struct KernelCore::Impl {
104 void Initialize(KernelCore& kernel) { 89 void Initialize(KernelCore& kernel) {
105 Shutdown(); 90 Shutdown();
106 91
107 InitializeSystemResourceLimit(kernel); 92 InitializeSystemResourceLimit(kernel);
108 InitializeThreads(); 93 InitializeThreads();
109 InitializeTimers();
110 } 94 }
111 95
112 void Shutdown() { 96 void Shutdown() {
@@ -122,9 +106,6 @@ struct KernelCore::Impl {
122 thread_wakeup_callback_handle_table.Clear(); 106 thread_wakeup_callback_handle_table.Clear();
123 thread_wakeup_event_type = nullptr; 107 thread_wakeup_event_type = nullptr;
124 108
125 timer_callback_handle_table.Clear();
126 timer_callback_event_type = nullptr;
127
128 named_ports.clear(); 109 named_ports.clear();
129 } 110 }
130 111
@@ -146,11 +127,6 @@ struct KernelCore::Impl {
146 CoreTiming::RegisterEvent("ThreadWakeupCallback", ThreadWakeupCallback); 127 CoreTiming::RegisterEvent("ThreadWakeupCallback", ThreadWakeupCallback);
147 } 128 }
148 129
149 void InitializeTimers() {
150 timer_callback_handle_table.Clear();
151 timer_callback_event_type = CoreTiming::RegisterEvent("TimerCallback", TimerCallback);
152 }
153
154 std::atomic<u32> next_object_id{0}; 130 std::atomic<u32> next_object_id{0};
155 std::atomic<u64> next_process_id{Process::ProcessIDMin}; 131 std::atomic<u64> next_process_id{Process::ProcessIDMin};
156 std::atomic<u64> next_thread_id{1}; 132 std::atomic<u64> next_thread_id{1};
@@ -161,12 +137,6 @@ struct KernelCore::Impl {
161 137
162 SharedPtr<ResourceLimit> system_resource_limit; 138 SharedPtr<ResourceLimit> system_resource_limit;
163 139
164 /// The event type of the generic timer callback event
165 CoreTiming::EventType* timer_callback_event_type = nullptr;
166 // TODO(yuriks): This can be removed if Timer objects are explicitly pooled in the future,
167 // allowing us to simply use a pool index or similar.
168 Kernel::HandleTable timer_callback_handle_table;
169
170 CoreTiming::EventType* thread_wakeup_event_type = nullptr; 140 CoreTiming::EventType* thread_wakeup_event_type = nullptr;
171 // TODO(yuriks): This can be removed if Thread objects are explicitly pooled in the future, 141 // TODO(yuriks): This can be removed if Thread objects are explicitly pooled in the future,
172 // allowing us to simply use a pool index or similar. 142 // allowing us to simply use a pool index or similar.
@@ -198,10 +168,6 @@ SharedPtr<Thread> KernelCore::RetrieveThreadFromWakeupCallbackHandleTable(Handle
198 return impl->thread_wakeup_callback_handle_table.Get<Thread>(handle); 168 return impl->thread_wakeup_callback_handle_table.Get<Thread>(handle);
199} 169}
200 170
201SharedPtr<Timer> KernelCore::RetrieveTimerFromCallbackHandleTable(Handle handle) const {
202 return impl->timer_callback_handle_table.Get<Timer>(handle);
203}
204
205void KernelCore::AppendNewProcess(SharedPtr<Process> process) { 171void KernelCore::AppendNewProcess(SharedPtr<Process> process) {
206 impl->process_list.push_back(std::move(process)); 172 impl->process_list.push_back(std::move(process));
207} 173}
@@ -247,18 +213,10 @@ u64 KernelCore::CreateNewProcessID() {
247 return impl->next_process_id++; 213 return impl->next_process_id++;
248} 214}
249 215
250ResultVal<Handle> KernelCore::CreateTimerCallbackHandle(const SharedPtr<Timer>& timer) {
251 return impl->timer_callback_handle_table.Create(timer);
252}
253
254CoreTiming::EventType* KernelCore::ThreadWakeupCallbackEventType() const { 216CoreTiming::EventType* KernelCore::ThreadWakeupCallbackEventType() const {
255 return impl->thread_wakeup_event_type; 217 return impl->thread_wakeup_event_type;
256} 218}
257 219
258CoreTiming::EventType* KernelCore::TimerCallbackEventType() const {
259 return impl->timer_callback_event_type;
260}
261
262Kernel::HandleTable& KernelCore::ThreadWakeupCallbackHandleTable() { 220Kernel::HandleTable& KernelCore::ThreadWakeupCallbackHandleTable() {
263 return impl->thread_wakeup_callback_handle_table; 221 return impl->thread_wakeup_callback_handle_table;
264} 222}