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

Kernel: Add interrupt support to aarch64 RPi Timer driver

Since we can now build and use the IRQHandler class, we can implement
interrupt support for the Timer in the aarch64 build.
This commit is contained in:
Timon Kruiper 2022-05-30 10:22:57 +02:00 committed by Linus Groh
parent 8b77c61e7d
commit dab6dbe893
2 changed files with 56 additions and 2 deletions

View file

@ -30,7 +30,8 @@ enum FlagBits {
};
Timer::Timer()
: m_registers(MMIO::the().peripheral<TimerRegisters>(0x3000))
: IRQHandler(1)
, m_registers(MMIO::the().peripheral<TimerRegisters>(0x3000))
{
}
@ -51,6 +52,41 @@ u64 Timer::microseconds_since_boot()
return (static_cast<u64>(high) << 32) | low;
}
bool Timer::handle_irq(RegisterState const&)
{
dbgln("Timer fired: {} us", m_current_timer_value);
m_current_timer_value += m_interrupt_interval;
set_compare(TimerID::Timer1, m_current_timer_value);
clear_interrupt(TimerID::Timer1);
return true;
};
void Timer::enable_interrupt_mode()
{
m_current_timer_value = microseconds_since_boot();
m_current_timer_value += m_interrupt_interval;
set_compare(TimerID::Timer1, m_current_timer_value);
enable_irq();
}
void Timer::set_interrupt_interval_usec(u32 interrupt_interval)
{
m_interrupt_interval = interrupt_interval;
}
void Timer::clear_interrupt(TimerID id)
{
m_registers->control_and_status = 1 << to_underlying(id);
}
void Timer::set_compare(TimerID id, u32 compare)
{
m_registers->compare[to_underlying(id)] = compare;
}
class SetClockRateMboxMessage : Mailbox::Message {
public:
u32 clock_id;