1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:17:45 +00:00

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.
This commit is contained in:
Liav A 2021-06-05 09:00:18 +03:00 committed by Andreas Kling
parent 7a6d5a7b8b
commit b91df26d4a
43 changed files with 125 additions and 71 deletions

View file

@ -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()

View file

@ -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;

View file

@ -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 };

View file

@ -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

View file

@ -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;
};
}