diff options
author | Liav A <liavalb@gmail.com> | 2021-06-05 09:00:18 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-17 16:53:25 +0200 |
commit | b91df26d4a14c2721d1920e76552012864c97790 (patch) | |
tree | f9b83151fe424057cbc7bbdd1e1b389387a601b7 /Kernel/Time | |
parent | 7a6d5a7b8bae2e2058c72b662c4cccec99374b11 (diff) | |
download | serenity-b91df26d4a14c2721d1920e76552012864c97790.zip |
Kernel/Interrupts: Return boolean on whether we handled the interrupt
If we are in a shared interrupt handler, the called handlers might
indicate it was not their interrupt, so we should not increment the
call counter of these handlers.
Diffstat (limited to 'Kernel/Time')
-rw-r--r-- | Kernel/Time/HPETComparator.cpp | 5 | ||||
-rw-r--r-- | Kernel/Time/HPETComparator.h | 2 | ||||
-rw-r--r-- | Kernel/Time/HardwareTimer.h | 16 | ||||
-rw-r--r-- | Kernel/Time/RTC.cpp | 5 | ||||
-rw-r--r-- | Kernel/Time/RTC.h | 2 |
5 files changed, 20 insertions, 10 deletions
diff --git a/Kernel/Time/HPETComparator.cpp b/Kernel/Time/HPETComparator.cpp index 8292719c31..6f2aab6c17 100644 --- a/Kernel/Time/HPETComparator.cpp +++ b/Kernel/Time/HPETComparator.cpp @@ -51,11 +51,12 @@ void HPETComparator::set_non_periodic() HPET::the().disable_periodic_interrupt(*this); } -void HPETComparator::handle_irq(const RegisterState& regs) +bool HPETComparator::handle_irq(const RegisterState& regs) { - HardwareTimer::handle_irq(regs); + auto result = HardwareTimer::handle_irq(regs); if (!is_periodic()) set_new_countdown(); + return result; } void HPETComparator::set_new_countdown() diff --git a/Kernel/Time/HPETComparator.h b/Kernel/Time/HPETComparator.h index 5fa0d0cdd1..9d2bd5e141 100644 --- a/Kernel/Time/HPETComparator.h +++ b/Kernel/Time/HPETComparator.h @@ -43,7 +43,7 @@ public: private: void set_new_countdown(); - virtual void handle_irq(const RegisterState&) override; + virtual bool handle_irq(const RegisterState&) override; HPETComparator(u8 number, u8 irq, bool periodic_capable, bool is_64bit_capable); bool m_periodic : 1; bool m_periodic_capable : 1; diff --git a/Kernel/Time/HardwareTimer.h b/Kernel/Time/HardwareTimer.h index b442d377f8..ce555075e3 100644 --- a/Kernel/Time/HardwareTimer.h +++ b/Kernel/Time/HardwareTimer.h @@ -92,10 +92,14 @@ protected: { } - virtual void handle_irq(const RegisterState& regs) override + virtual bool handle_irq(const RegisterState& regs) override { - if (m_callback) + // Note: if we have an IRQ on this line, it's going to be the timer always + if (m_callback) { m_callback(regs); + return true; + } + return false; } u64 m_frequency { OPTIMAL_TICKS_PER_SECOND_RATE }; @@ -142,10 +146,14 @@ protected: { } - virtual void handle_interrupt(const RegisterState& regs) override + virtual bool handle_interrupt(const RegisterState& regs) override { - if (m_callback) + // Note: if we have an IRQ on this line, it's going to be the timer always + if (m_callback) { m_callback(regs); + return true; + } + return false; } u64 m_frequency { OPTIMAL_TICKS_PER_SECOND_RATE }; diff --git a/Kernel/Time/RTC.cpp b/Kernel/Time/RTC.cpp index 31c1f09e02..d2052b501d 100644 --- a/Kernel/Time/RTC.cpp +++ b/Kernel/Time/RTC.cpp @@ -27,10 +27,11 @@ RealTimeClock::RealTimeClock(Function<void(const RegisterState&)> callback) CMOS::write(0x8B, CMOS::read(0xB) | 0x40); reset_to_default_ticks_per_second(); } -void RealTimeClock::handle_irq(const RegisterState& regs) +bool RealTimeClock::handle_irq(const RegisterState& regs) { - HardwareTimer::handle_irq(regs); + auto result = HardwareTimer::handle_irq(regs); CMOS::read(0x8C); + return result; } size_t RealTimeClock::ticks_per_second() const diff --git a/Kernel/Time/RTC.h b/Kernel/Time/RTC.h index 1005ae7109..748f8e28a1 100644 --- a/Kernel/Time/RTC.h +++ b/Kernel/Time/RTC.h @@ -31,6 +31,6 @@ public: private: explicit RealTimeClock(Function<void(const RegisterState&)> callback); - virtual void handle_irq(const RegisterState&) override; + virtual bool handle_irq(const RegisterState&) override; }; } |