Kernel: Add simple implementation for InterruptManagement on aarch64

This class currently hardcodes the use of the Raspberry Pi interrupt
controller.
This commit is contained in:
Timon Kruiper 2022-05-30 09:43:51 +02:00 committed by Linus Groh
parent 5eac2b9f33
commit c959344c00
Notes: sideshowbarker 2024-07-17 10:30:40 +09:00
4 changed files with 69 additions and 21 deletions

View File

@ -7,7 +7,6 @@
#include <AK/Singleton.h>
#include <AK/Types.h>
#include <Kernel/Arch/aarch64/InterruptManagement.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/KString.h>
#include <Kernel/Locking/SpinlockProtected.h>
@ -137,23 +136,3 @@ void KString::operator delete(void*)
extern "C" {
FlatPtr kernel_mapping_base;
}
// InterruptManagement.cpp
namespace Kernel {
u8 InterruptManagement::acquire_mapped_interrupt_number(u8)
{
VERIFY_NOT_REACHED();
}
InterruptManagement& InterruptManagement::the()
{
VERIFY_NOT_REACHED();
}
RefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(u8)
{
VERIFY_NOT_REACHED();
}
}

View File

@ -0,0 +1,57 @@
/*
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
* Copyright (c) 2022, Timon Kruiper <timonkruiper@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/aarch64/InterruptManagement.h>
#include <Kernel/Arch/aarch64/RPi/InterruptController.h>
namespace Kernel {
static InterruptManagement* s_interrupt_management;
bool InterruptManagement::initialized()
{
return s_interrupt_management != nullptr;
}
InterruptManagement& InterruptManagement::the()
{
VERIFY(InterruptManagement::initialized());
return *s_interrupt_management;
}
void InterruptManagement::initialize()
{
VERIFY(!InterruptManagement::initialized());
s_interrupt_management = new InterruptManagement;
the().find_controllers();
}
void InterruptManagement::find_controllers()
{
// TODO: Once device tree support is in place, find interrupt controllers using that.
m_interrupt_controllers.append(new RPi::InterruptController);
}
u8 InterruptManagement::acquire_mapped_interrupt_number(u8 interrupt_number)
{
return interrupt_number;
}
Vector<RefPtr<IRQController>> const& InterruptManagement::controllers()
{
return m_interrupt_controllers;
}
RefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(u8)
{
// TODO: Support more interrupt controllers
VERIFY(m_interrupt_controllers.size() == 1);
return m_interrupt_controllers[0];
}
}

View File

@ -6,6 +6,8 @@
#pragma once
#include <AK/RefPtr.h>
#include <AK/Vector.h>
#include <Kernel/Arch/aarch64/IRQController.h>
namespace Kernel {
@ -13,10 +15,19 @@ namespace Kernel {
class InterruptManagement {
public:
static InterruptManagement& the();
static void initialize();
static bool initialized();
static u8 acquire_mapped_interrupt_number(u8 original_irq);
Vector<RefPtr<IRQController>> const& controllers();
RefPtr<IRQController> get_responsible_irq_controller(u8 interrupt_vector);
private:
InterruptManagement() = default;
void find_controllers();
Vector<RefPtr<IRQController>> m_interrupt_controllers;
};
}

View File

@ -417,6 +417,7 @@ else()
Arch/aarch64/Dummy.cpp
Arch/aarch64/Exceptions.cpp
Arch/aarch64/init.cpp
Arch/aarch64/InterruptManagement.cpp
Arch/aarch64/Interrupts.cpp
Arch/aarch64/kprintf.cpp
Arch/aarch64/MainIdRegister.cpp