Kernel: Use AK::NeverDestroyed<Timer> to store the timer class

For an upcoming change to support interrupts in this driver, this class
has to inherit from IRQHandler. That in turn will make this class
virtual, which will then actually call the destructor of the class. We
don't want this to happen, thus we have to wrap the class in a
AK::NeverDestroyed.
This commit is contained in:
Timon Kruiper 2022-05-17 10:19:16 +02:00 committed by Linus Groh
parent a0b0c4e723
commit 8b77c61e7d
Notes: sideshowbarker 2024-07-17 10:30:27 +09:00
2 changed files with 4 additions and 4 deletions

View file

@ -5,6 +5,7 @@
*/
#include <AK/Format.h>
#include <AK/NeverDestroyed.h>
#include <Kernel/Arch/aarch64/RPi/MMIO.h>
#include <Kernel/Arch/aarch64/RPi/Mailbox.h>
#include <Kernel/Arch/aarch64/RPi/Timer.h>
@ -35,8 +36,8 @@ Timer::Timer()
Timer& Timer::the()
{
static Timer instance;
return instance;
static AK::NeverDestroyed<Timer> instance;
return *instance;
}
u64 Timer::microseconds_since_boot()

View file

@ -14,6 +14,7 @@ struct TimerRegisters;
class Timer {
public:
Timer();
static Timer& the();
u64 microseconds_since_boot();
@ -38,8 +39,6 @@ public:
static u32 set_clock_rate(ClockID, u32 rate_hz, bool skip_setting_turbo = true);
private:
Timer();
TimerRegisters volatile* m_registers;
};