diff options
Diffstat (limited to 'src/core/hle/kernel/timer.cpp')
| -rw-r--r-- | src/core/hle/kernel/timer.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index b8daaeede..255cb1aca 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp | |||
| @@ -9,8 +9,8 @@ | |||
| 9 | 9 | ||
| 10 | #include "core/core_timing.h" | 10 | #include "core/core_timing.h" |
| 11 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/kernel.h" |
| 12 | #include "core/hle/kernel/timer.h" | ||
| 13 | #include "core/hle/kernel/thread.h" | 12 | #include "core/hle/kernel/thread.h" |
| 13 | #include "core/hle/kernel/timer.h" | ||
| 14 | 14 | ||
| 15 | namespace Kernel { | 15 | namespace Kernel { |
| 16 | 16 | ||
| @@ -20,8 +20,10 @@ static int timer_callback_event_type; | |||
| 20 | // us to simply use a pool index or similar. | 20 | // us to simply use a pool index or similar. |
| 21 | static Kernel::HandleTable timer_callback_handle_table; | 21 | static Kernel::HandleTable timer_callback_handle_table; |
| 22 | 22 | ||
| 23 | Timer::Timer() {} | 23 | Timer::Timer() { |
| 24 | Timer::~Timer() {} | 24 | } |
| 25 | Timer::~Timer() { | ||
| 26 | } | ||
| 25 | 27 | ||
| 26 | SharedPtr<Timer> Timer::Create(ResetType reset_type, std::string name) { | 28 | SharedPtr<Timer> Timer::Create(ResetType reset_type, std::string name) { |
| 27 | SharedPtr<Timer> timer(new Timer); | 29 | SharedPtr<Timer> timer(new Timer); |
| @@ -41,7 +43,7 @@ bool Timer::ShouldWait() { | |||
| 41 | } | 43 | } |
| 42 | 44 | ||
| 43 | void Timer::Acquire() { | 45 | void Timer::Acquire() { |
| 44 | ASSERT_MSG( !ShouldWait(), "object unavailable!"); | 46 | ASSERT_MSG(!ShouldWait(), "object unavailable!"); |
| 45 | 47 | ||
| 46 | if (reset_type == ResetType::OneShot) | 48 | if (reset_type == ResetType::OneShot) |
| 47 | signaled = false; | 49 | signaled = false; |
| @@ -55,8 +57,8 @@ void Timer::Set(s64 initial, s64 interval) { | |||
| 55 | interval_delay = interval; | 57 | interval_delay = interval; |
| 56 | 58 | ||
| 57 | u64 initial_microseconds = initial / 1000; | 59 | u64 initial_microseconds = initial / 1000; |
| 58 | CoreTiming::ScheduleEvent(usToCycles(initial_microseconds), | 60 | CoreTiming::ScheduleEvent(usToCycles(initial_microseconds), timer_callback_event_type, |
| 59 | timer_callback_event_type, callback_handle); | 61 | callback_handle); |
| 60 | 62 | ||
| 61 | HLE::Reschedule(__func__); | 63 | HLE::Reschedule(__func__); |
| 62 | } | 64 | } |
| @@ -73,7 +75,8 @@ void Timer::Clear() { | |||
| 73 | 75 | ||
| 74 | /// The timer callback event, called when a timer is fired | 76 | /// The timer callback event, called when a timer is fired |
| 75 | static void TimerCallback(u64 timer_handle, int cycles_late) { | 77 | static void TimerCallback(u64 timer_handle, int cycles_late) { |
| 76 | SharedPtr<Timer> timer = timer_callback_handle_table.Get<Timer>(static_cast<Handle>(timer_handle)); | 78 | SharedPtr<Timer> timer = |
| 79 | timer_callback_handle_table.Get<Timer>(static_cast<Handle>(timer_handle)); | ||
| 77 | 80 | ||
| 78 | if (timer == nullptr) { | 81 | if (timer == nullptr) { |
| 79 | LOG_CRITICAL(Kernel, "Callback fired for invalid timer %08" PRIx64, timer_handle); | 82 | LOG_CRITICAL(Kernel, "Callback fired for invalid timer %08" PRIx64, timer_handle); |
| @@ -91,7 +94,7 @@ static void TimerCallback(u64 timer_handle, int cycles_late) { | |||
| 91 | // Reschedule the timer with the interval delay | 94 | // Reschedule the timer with the interval delay |
| 92 | u64 interval_microseconds = timer->interval_delay / 1000; | 95 | u64 interval_microseconds = timer->interval_delay / 1000; |
| 93 | CoreTiming::ScheduleEvent(usToCycles(interval_microseconds) - cycles_late, | 96 | CoreTiming::ScheduleEvent(usToCycles(interval_microseconds) - cycles_late, |
| 94 | timer_callback_event_type, timer_handle); | 97 | timer_callback_event_type, timer_handle); |
| 95 | } | 98 | } |
| 96 | } | 99 | } |
| 97 | 100 | ||