diff options
Diffstat (limited to 'src/core/hle/kernel/timer.cpp')
| -rw-r--r-- | src/core/hle/kernel/timer.cpp | 84 |
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 | |||
| 16 | namespace Kernel { | ||
| 17 | |||
| 18 | Timer::Timer(KernelCore& kernel) : WaitObject{kernel} {} | ||
| 19 | Timer::~Timer() = default; | ||
| 20 | |||
| 21 | SharedPtr<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 | |||
| 34 | bool Timer::ShouldWait(Thread* thread) const { | ||
| 35 | return !signaled; | ||
| 36 | } | ||
| 37 | |||
| 38 | void Timer::Acquire(Thread* thread) { | ||
| 39 | ASSERT_MSG(!ShouldWait(thread), "object unavailable!"); | ||
| 40 | |||
| 41 | if (reset_type == ResetType::OneShot) | ||
| 42 | signaled = false; | ||
| 43 | } | ||
| 44 | |||
| 45 | void 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 | |||
| 61 | void Timer::Cancel() { | ||
| 62 | CoreTiming::UnscheduleEvent(kernel.TimerCallbackEventType(), callback_handle); | ||
| 63 | } | ||
| 64 | |||
| 65 | void Timer::Clear() { | ||
| 66 | signaled = false; | ||
| 67 | } | ||
| 68 | |||
| 69 | void 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 | ||