mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 04:52:06 +02:00
Kernel: Add driver for interrupt controller on the Raspberry Pi
This implements the simpler IRQController class and adds a pending_interrupts() function to the class.
This commit is contained in:
committed by
Linus Groh
parent
f085903f62
commit
5eac2b9f33
Notes:
sideshowbarker
2024-07-17 10:30:45 +09:00
Author: https://github.com/FireFox317 Commit: https://github.com/SerenityOS/serenity/commit/5eac2b9f33 Pull-request: https://github.com/SerenityOS/serenity/pull/14146 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/BertalanD Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/nico ✅
69
Kernel/Arch/aarch64/RPi/InterruptController.cpp
Normal file
69
Kernel/Arch/aarch64/RPi/InterruptController.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Timon Kruiper <timonkruiper@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Format.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/InterruptController.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/MMIO.h>
|
||||
#include <Kernel/Interrupts/GenericInterruptHandler.h>
|
||||
|
||||
namespace Kernel::RPi {
|
||||
|
||||
// "7.5 Interrupts Registers"
|
||||
// https://github.com/raspberrypi/documentation/files/1888662/BCM2837-ARM-Peripherals.-.Revised.-.V2-1.pdf
|
||||
struct InterruptControllerRegisters {
|
||||
u32 irq_basic_pending;
|
||||
u32 irq_pending_1;
|
||||
u32 irq_pending_2;
|
||||
u32 fiq_control;
|
||||
|
||||
u32 enable_irqs_1;
|
||||
u32 enable_irqs_2;
|
||||
u32 enable_basic_irqs;
|
||||
|
||||
u32 disable_irqs_1;
|
||||
u32 disable_irqs_2;
|
||||
u32 disable_basic_irqs;
|
||||
};
|
||||
|
||||
InterruptController::InterruptController()
|
||||
: m_registers(MMIO::the().peripheral<InterruptControllerRegisters>(0xB200))
|
||||
{
|
||||
}
|
||||
|
||||
void InterruptController::enable(GenericInterruptHandler const& handler)
|
||||
{
|
||||
u8 interrupt_number = handler.interrupt_number();
|
||||
VERIFY(interrupt_number < 64);
|
||||
|
||||
if (interrupt_number < 32)
|
||||
m_registers->enable_irqs_1 = m_registers->enable_irqs_1 | (1 << interrupt_number);
|
||||
else
|
||||
m_registers->enable_irqs_2 = m_registers->enable_irqs_2 | (1 << (interrupt_number - 32));
|
||||
}
|
||||
|
||||
void InterruptController::disable(GenericInterruptHandler const& handler)
|
||||
{
|
||||
u8 interrupt_number = handler.interrupt_number();
|
||||
VERIFY(interrupt_number < 64);
|
||||
|
||||
if (interrupt_number < 32)
|
||||
m_registers->disable_irqs_1 = m_registers->disable_irqs_1 | (1 << interrupt_number);
|
||||
else
|
||||
m_registers->disable_irqs_2 = m_registers->disable_irqs_2 | (1 << (interrupt_number - 32));
|
||||
}
|
||||
|
||||
void InterruptController::eoi(GenericInterruptHandler const&) const
|
||||
{
|
||||
// NOTE: The interrupt controller cannot clear the interrupt, since it is basically just a big multiplexer.
|
||||
// The interrupt should be cleared by the corresponding device driver, such as a timer or uart.
|
||||
}
|
||||
|
||||
u64 InterruptController::pending_interrupts() const
|
||||
{
|
||||
return ((u64)m_registers->irq_pending_2 << 32) | (u64)m_registers->irq_pending_1;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user