From e52ca85711e8df54c8eafe556b6ba0ca683ddea0 Mon Sep 17 00:00:00 2001 From: Subv Date: Sun, 1 Jan 2017 19:23:19 -0500 Subject: Kernel: Implemented Pulse event and timers. Closes #1904 --- src/core/hle/kernel/event.cpp | 15 ++++++++------- src/core/hle/kernel/event.h | 2 ++ src/core/hle/kernel/kernel.h | 2 +- src/core/hle/kernel/timer.cpp | 12 +++++++----- src/core/hle/kernel/timer.h | 2 ++ 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp index 3e116e3df..a515f53f9 100644 --- a/src/core/hle/kernel/event.cpp +++ b/src/core/hle/kernel/event.cpp @@ -22,11 +22,6 @@ SharedPtr Event::Create(ResetType reset_type, std::string name) { evt->reset_type = reset_type; evt->name = std::move(name); - if (reset_type == ResetType::Pulse) { - LOG_ERROR(Kernel, "Unimplemented event reset type Pulse"); - UNIMPLEMENTED(); - } - return evt; } @@ -37,8 +32,7 @@ bool Event::ShouldWait() { void Event::Acquire() { ASSERT_MSG(!ShouldWait(), "object unavailable!"); - // Release the event if it's not sticky... - if (reset_type != ResetType::Sticky) + if (reset_type == ResetType::OneShot) signaled = false; } @@ -51,4 +45,11 @@ void Event::Clear() { signaled = false; } +void Event::WakeupAllWaitingThreads() { + WaitObject::WakeupAllWaitingThreads(); + + if (reset_type == ResetType::Pulse) + signaled = false; +} + } // namespace diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h index 8dcd23edb..28d955b1e 100644 --- a/src/core/hle/kernel/event.h +++ b/src/core/hle/kernel/event.h @@ -38,6 +38,8 @@ public: bool ShouldWait() override; void Acquire() override; + void WakeupAllWaitingThreads() override; + void Signal(); void Clear(); diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 9503e7d04..1e68f9cab 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -156,7 +156,7 @@ public: * Wake up all threads waiting on this object that can be awoken, in priority order, * and set the synchronization result and output of the thread. */ - void WakeupAllWaitingThreads(); + virtual void WakeupAllWaitingThreads(); /// Obtains the highest priority thread that is ready to run from this object's waiting list. SharedPtr GetHighestPriorityReadyThread(); diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index b50cf520d..ec85b7ec8 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp @@ -31,11 +31,6 @@ SharedPtr Timer::Create(ResetType reset_type, std::string name) { timer->interval_delay = 0; timer->callback_handle = timer_callback_handle_table.Create(timer).MoveFrom(); - if (reset_type == ResetType::Pulse) { - LOG_ERROR(Kernel, "Unimplemented timer reset type Pulse"); - UNIMPLEMENTED(); - } - return timer; } @@ -70,6 +65,13 @@ void Timer::Clear() { signaled = false; } +void Timer::WakeupAllWaitingThreads() { + WaitObject::WakeupAllWaitingThreads(); + + if (reset_type == ResetType::Pulse) + signaled = false; +} + /// The timer callback event, called when a timer is fired static void TimerCallback(u64 timer_handle, int cycles_late) { SharedPtr timer = diff --git a/src/core/hle/kernel/timer.h b/src/core/hle/kernel/timer.h index 18ea0236b..2092165d4 100644 --- a/src/core/hle/kernel/timer.h +++ b/src/core/hle/kernel/timer.h @@ -42,6 +42,8 @@ public: bool ShouldWait() override; void Acquire() override; + void WakeupAllWaitingThreads() override; + /** * Starts the timer, with the specified initial delay and interval. * @param initial Delay until the timer is first fired -- cgit v1.2.3