summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/timer.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/timer.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/timer.cpp')
-rw-r--r--src/core/hle/kernel/timer.cpp84
1 files changed, 0 insertions, 84 deletions
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp
deleted file mode 100644
index 3afe60469..000000000
--- a/src/core/hle/kernel/timer.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
1// Copyright 2015 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/assert.h"
6#include "common/logging/log.h"
7#include "core/core.h"
8#include "core/core_timing.h"
9#include "core/core_timing_util.h"
10#include "core/hle/kernel/handle_table.h"
11#include "core/hle/kernel/kernel.h"
12#include "core/hle/kernel/object.h"
13#include "core/hle/kernel/thread.h"
14#include "core/hle/kernel/timer.h"
15
16namespace Kernel {
17
18Timer::Timer(KernelCore& kernel) : WaitObject{kernel} {}
19Timer::~Timer() = default;
20
21SharedPtr<Timer> Timer::Create(KernelCore& kernel, ResetType reset_type, std::string name) {
22 SharedPtr<Timer> timer(new Timer(kernel));
23
24 timer->reset_type = reset_type;
25 timer->signaled = false;
26 timer->name = std::move(name);
27 timer->initial_delay = 0;
28 timer->interval_delay = 0;
29 timer->callback_handle = kernel.CreateTimerCallbackHandle(timer).Unwrap();
30
31 return timer;
32}
33
34bool Timer::ShouldWait(Thread* thread) const {
35 return !signaled;
36}
37
38void Timer::Acquire(Thread* thread) {
39 ASSERT_MSG(!ShouldWait(thread), "object unavailable!");
40
41 if (reset_type == ResetType::OneShot)
42 signaled = false;
43}
44
45void Timer::Set(s64 initial, s64 interval) {
46 // Ensure we get rid of any previous scheduled event
47 Cancel();
48
49 initial_delay = initial;
50 interval_delay = interval;
51
52 if (initial == 0) {
53 // Immediately invoke the callback
54 Signal(0);
55 } else {
56 CoreTiming::ScheduleEvent(CoreTiming::nsToCycles(initial), kernel.TimerCallbackEventType(),
57 callback_handle);
58 }
59}
60
61void Timer::Cancel() {
62 CoreTiming::UnscheduleEvent(kernel.TimerCallbackEventType(), callback_handle);
63}
64
65void Timer::Clear() {
66 signaled = false;
67}
68
69void Timer::Signal(int cycles_late) {
70 LOG_TRACE(Kernel, "Timer {} fired", GetObjectId());
71
72 signaled = true;
73
74 // Resume all waiting threads
75 WakeupAllWaitingThreads();
76
77 if (interval_delay != 0) {
78 // Reschedule the timer with the interval delay
79 CoreTiming::ScheduleEvent(CoreTiming::nsToCycles(interval_delay) - cycles_late,
80 kernel.TimerCallbackEventType(), callback_handle);
81 }
82}
83
84} // namespace Kernel