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

Kernel: Fix GenericInterruptHandler problems with virtual functions

Because registering and unregistering interrupt handlers triggers
calls to virtual functions, we can't do this in the constructor
and destructor.

Fixes #5539
This commit is contained in:
Tom 2021-02-26 17:17:57 -07:00 committed by Andreas Kling
parent 183ebaee91
commit 32d9534c67
11 changed files with 112 additions and 39 deletions

View file

@ -43,9 +43,17 @@ enum class HandlerType : u8 {
class GenericInterruptHandler {
public:
static GenericInterruptHandler& from(u8 interrupt_number);
virtual ~GenericInterruptHandler();
virtual ~GenericInterruptHandler()
{
VERIFY(!m_registered);
}
virtual void handle_interrupt(const RegisterState& regs) = 0;
void will_be_destroyed();
bool is_registered() const { return m_registered; }
void register_interrupt_handler();
void unregister_interrupt_handler();
u8 interrupt_number() const { return m_interrupt_number; }
size_t get_invoking_count() const { return m_invoking_count; }
@ -74,5 +82,6 @@ private:
Atomic<u32, AK::MemoryOrder::memory_order_relaxed> m_invoking_count { 0 };
u8 m_interrupt_number { 0 };
bool m_disable_remap { false };
bool m_registered { false };
};
}