summaryrefslogtreecommitdiff
path: root/Kernel/Time/HardwareTimer.h
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2021-02-26 17:17:57 -0700
committerAndreas Kling <kling@serenityos.org>2021-02-28 15:27:53 +0100
commit32d9534c67ab8b9cfcf2d9ad7e4762424db792ba (patch)
tree24cba62e57d3010b37f15256db56883b685d91a4 /Kernel/Time/HardwareTimer.h
parent183ebaee91a6a5b7ca2b8a91395e562070630c48 (diff)
downloadserenity-32d9534c67ab8b9cfcf2d9ad7e4762424db792ba.zip
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
Diffstat (limited to 'Kernel/Time/HardwareTimer.h')
-rw-r--r--Kernel/Time/HardwareTimer.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/Kernel/Time/HardwareTimer.h b/Kernel/Time/HardwareTimer.h
index c5998e1cb9..5790cf97ab 100644
--- a/Kernel/Time/HardwareTimer.h
+++ b/Kernel/Time/HardwareTimer.h
@@ -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();