1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:27:35 +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

@ -49,6 +49,12 @@ class HardwareTimerBase
public:
virtual ~HardwareTimerBase() { }
// We need to create a virtual will_be_destroyed here because we derive
// from RefCounted<HardwareTimerBase> here, which means that RefCounted<>
// will only call will_be_destroyed if we define it here. The derived
// classes then should forward this to e.g. GenericInterruptHandler.
virtual void will_be_destroyed() = 0;
virtual const char* model() const = 0;
virtual HardwareTimerType timer_type() const = 0;
virtual Function<void(const RegisterState&)> set_callback(Function<void(const RegisterState&)>) = 0;
@ -73,6 +79,11 @@ class HardwareTimer<IRQHandler>
: public HardwareTimerBase
, public IRQHandler {
public:
virtual void will_be_destroyed() override
{
IRQHandler::will_be_destroyed();
}
virtual const char* purpose() const override
{
if (TimeManagement::the().is_system_timer(*this))
@ -115,6 +126,11 @@ class HardwareTimer<GenericInterruptHandler>
: public HardwareTimerBase
, public GenericInterruptHandler {
public:
virtual void will_be_destroyed() override
{
GenericInterruptHandler::will_be_destroyed();
}
virtual const char* purpose() const override
{
return model();