Kernel/x86: Rename {=> PIC}SpuriousInterruptHandler

This class is now only used by the PIC.

Spurious interrupt vectors that can maybe actually not be spurious
are only a thing on x86 due to legacy reasons, so we don't need this
class on non-x86.
Both AArch64's and RISC-V's interrupt controller do also have a way
to communicate that there is no interrupt pending (anymore), but we
don't need a special class to handle this for these architectures,
so remove FIXMEs mentioning that SpuriousInterruptHandler should also
be used for them.
This commit is contained in:
Sönke Holz authored and Sönke Holz committed 2026-07-12 13:14:12 +02:00
1 parent d2eb593961
commit 3a70417ff0
8 files changed
+37 -41

No files matched your search

-5
View File
@@ -214,11 +214,6 @@ void register_generic_interrupt_handler(InterruptNumber interrupt_number, Generi
return;
}
if (!handler_slot->is_shared_handler()) {
if (handler_slot->type() == HandlerType::SpuriousInterruptHandler) {
// FIXME: Add support for spurious interrupts on aarch64
TODO_AARCH64();
}
VERIFY(handler_slot->type() == HandlerType::IRQHandler);
auto& previous_handler = *handler_slot;
-5
View File
@@ -215,11 +215,6 @@ void register_generic_interrupt_handler(InterruptNumber interrupt_number, Generi
return;
}
if (!handler_slot->is_shared_handler()) {
if (handler_slot->type() == HandlerType::SpuriousInterruptHandler) {
// FIXME: Add support for spurious interrupts on riscv64
TODO_RISCV64();
}
VERIFY(handler_slot->type() == HandlerType::IRQHandler);
auto& previous_handler = *handler_slot;
+5 -5
View File
@@ -11,11 +11,11 @@
#include <Kernel/Arch/x86_64/Interrupts/APIC.h>
#include <Kernel/Arch/x86_64/Interrupts/IOAPIC.h>
#include <Kernel/Arch/x86_64/Interrupts/PIC.h>
#include <Kernel/Arch/x86_64/Interrupts/PICSpuriousInterruptHandler.h>
#include <Kernel/Boot/CommandLine.h>
#include <Kernel/Firmware/ACPI/StaticParsing.h>
#include <Kernel/Interrupts/InterruptDisabler.h>
#include <Kernel/Interrupts/SharedIRQHandler.h>
#include <Kernel/Interrupts/SpuriousInterruptHandler.h>
#include <Kernel/Memory/TypedMapping.h>
#include <Kernel/Sections.h>
@@ -138,8 +138,8 @@ UNMAP_AFTER_INIT void InterruptManagement::switch_to_pic_mode()
dmesgln("Interrupts: Switch to Legacy PIC mode");
InterruptDisabler disabler;
m_interrupt_controllers.try_append(adopt_lock_ref(*new PIC())).release_value_but_fixme_should_propagate_errors();
SpuriousInterruptHandler::initialize(7);
SpuriousInterruptHandler::initialize(15);
PICSpuriousInterruptHandler::initialize(7);
PICSpuriousInterruptHandler::initialize(15);
dbgln("Interrupts: Detected {}", m_interrupt_controllers[0]->model());
}
@@ -169,8 +169,8 @@ UNMAP_AFTER_INIT void InterruptManagement::switch_to_ioapic_mode()
if (irq_controller->type() == IRQControllerType::i8259) {
irq_controller->hard_disable();
dbgln("Interrupts: Detected {} - Disabled", irq_controller->model());
SpuriousInterruptHandler::initialize_for_disabled_master_pic();
SpuriousInterruptHandler::initialize_for_disabled_slave_pic();
PICSpuriousInterruptHandler::initialize_for_disabled_master_pic();
PICSpuriousInterruptHandler::initialize_for_disabled_slave_pic();
} else {
dbgln("Interrupts: Detected {}", irq_controller->model());
}
+8 -2
View File
@@ -9,11 +9,12 @@
#include <AK/Types.h>
#include <Kernel/Arch/Interrupts.h>
#include <Kernel/Arch/x86_64/InterruptManagement.h>
#include <Kernel/Arch/x86_64/Interrupts/PIC.h>
#include <Kernel/Arch/x86_64/Interrupts/PICSpuriousInterruptHandler.h>
#include <Kernel/Interrupts/GenericInterruptHandler.h>
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Interrupts/SharedIRQHandler.h>
#include <Kernel/Interrupts/SpuriousInterruptHandler.h>
#include <Kernel/Interrupts/UnhandledInterruptHandler.h>
#include <Kernel/Library/Panic.h>
#include <Kernel/Sections.h>
@@ -429,7 +430,12 @@ void register_generic_interrupt_handler(InterruptNumber interrupt_number, Generi
}
if (!handler_slot->is_shared_handler()) {
if (handler_slot->type() == HandlerType::SpuriousInterruptHandler) {
static_cast<SpuriousInterruptHandler*>(handler_slot)->register_handler(handler);
auto controller = InterruptManagement::the().get_responsible_irq_controller(interrupt_number);
// Only PICs should ever have spurious interrupts that are shared with real interrupts.
VERIFY(controller->type() == IRQControllerType::i8259);
static_cast<PICSpuriousInterruptHandler*>(handler_slot)->register_handler(handler);
return;
}
@@ -6,42 +6,42 @@
#include <Kernel/Arch/InterruptManagement.h>
#include <Kernel/Arch/x86_64/Interrupts.h>
#include <Kernel/Interrupts/SpuriousInterruptHandler.h>
#include <Kernel/Arch/x86_64/Interrupts/PICSpuriousInterruptHandler.h>
#include <Kernel/Sections.h>
namespace Kernel {
UNMAP_AFTER_INIT void SpuriousInterruptHandler::initialize(InterruptNumber interrupt_number)
UNMAP_AFTER_INIT void PICSpuriousInterruptHandler::initialize(InterruptNumber interrupt_number)
{
auto* handler = new SpuriousInterruptHandler(interrupt_number);
auto* handler = new PICSpuriousInterruptHandler(interrupt_number);
handler->register_interrupt_handler();
}
void SpuriousInterruptHandler::initialize_for_disabled_master_pic()
void PICSpuriousInterruptHandler::initialize_for_disabled_master_pic()
{
auto* handler = new SpuriousInterruptHandler(7);
auto* handler = new PICSpuriousInterruptHandler(7);
register_disabled_interrupt_handler(7, *handler);
handler->enable_interrupt_vector_for_disabled_pic();
}
void SpuriousInterruptHandler::initialize_for_disabled_slave_pic()
void PICSpuriousInterruptHandler::initialize_for_disabled_slave_pic()
{
auto* handler = new SpuriousInterruptHandler(15);
auto* handler = new PICSpuriousInterruptHandler(15);
register_disabled_interrupt_handler(15, *handler);
handler->enable_interrupt_vector_for_disabled_pic();
}
void SpuriousInterruptHandler::register_handler(GenericInterruptHandler& handler)
void PICSpuriousInterruptHandler::register_handler(GenericInterruptHandler& handler)
{
VERIFY(!m_real_handler);
m_real_handler = adopt_own_if_nonnull(&handler);
}
void SpuriousInterruptHandler::unregister_handler(GenericInterruptHandler&)
void PICSpuriousInterruptHandler::unregister_handler(GenericInterruptHandler&)
{
TODO();
}
bool SpuriousInterruptHandler::eoi()
bool PICSpuriousInterruptHandler::eoi()
{
// Actually check if IRQ7 or IRQ15 are spurious, and if not, call EOI with the correct interrupt number.
if (m_real_irq) {
@@ -53,22 +53,22 @@ bool SpuriousInterruptHandler::eoi()
return false;
}
StringView SpuriousInterruptHandler::purpose() const
StringView PICSpuriousInterruptHandler::purpose() const
{
if (!m_real_handler)
return "Spurious Interrupt Handler"sv;
return m_real_handler->purpose();
}
SpuriousInterruptHandler::SpuriousInterruptHandler(InterruptNumber irq)
PICSpuriousInterruptHandler::PICSpuriousInterruptHandler(InterruptNumber irq)
: GenericInterruptHandler(irq)
, m_responsible_irq_controller(InterruptManagement::the().get_responsible_irq_controller(irq))
{
}
SpuriousInterruptHandler::~SpuriousInterruptHandler() = default;
PICSpuriousInterruptHandler::~PICSpuriousInterruptHandler() = default;
bool SpuriousInterruptHandler::handle_interrupt()
bool PICSpuriousInterruptHandler::handle_interrupt()
{
// Actually check if IRQ7 or IRQ15 are spurious, and if not, call the real handler to handle the IRQ.
if (m_responsible_irq_controller->get_isr() & (1 << interrupt_number().value())) {
@@ -83,13 +83,13 @@ bool SpuriousInterruptHandler::handle_interrupt()
return true;
}
void SpuriousInterruptHandler::enable_interrupt_vector_for_disabled_pic()
void PICSpuriousInterruptHandler::enable_interrupt_vector_for_disabled_pic()
{
m_enabled = true;
m_responsible_irq_controller = InterruptManagement::the().get_responsible_irq_controller(IRQControllerType::i8259, interrupt_number());
}
void SpuriousInterruptHandler::enable_interrupt_vector()
void PICSpuriousInterruptHandler::enable_interrupt_vector()
{
if (m_enabled)
return;
@@ -97,7 +97,7 @@ void SpuriousInterruptHandler::enable_interrupt_vector()
m_responsible_irq_controller->enable(*this);
}
void SpuriousInterruptHandler::disable_interrupt_vector()
void PICSpuriousInterruptHandler::disable_interrupt_vector()
{
VERIFY(!m_real_irq); // this flag should not be set when we call this method
if (!m_enabled)
@@ -106,7 +106,7 @@ void SpuriousInterruptHandler::disable_interrupt_vector()
m_responsible_irq_controller->disable(*this);
}
StringView SpuriousInterruptHandler::controller() const
StringView PICSpuriousInterruptHandler::controller() const
{
if (m_responsible_irq_controller->type() == IRQControllerType::i82093AA)
return ""sv;
@@ -13,12 +13,12 @@
namespace Kernel {
class SpuriousInterruptHandler final : public GenericInterruptHandler {
class PICSpuriousInterruptHandler final : public GenericInterruptHandler {
public:
static void initialize(InterruptNumber interrupt_number);
static void initialize_for_disabled_master_pic();
static void initialize_for_disabled_slave_pic();
virtual ~SpuriousInterruptHandler();
virtual ~PICSpuriousInterruptHandler();
virtual bool handle_interrupt() override;
void register_handler(GenericInterruptHandler&);
@@ -38,7 +38,7 @@ public:
private:
void enable_interrupt_vector();
void disable_interrupt_vector();
explicit SpuriousInterruptHandler(InterruptNumber interrupt_number);
explicit PICSpuriousInterruptHandler(InterruptNumber interrupt_number);
bool m_enabled { false };
bool m_real_irq { false };
NonnullLockRefPtr<IRQController> m_responsible_irq_controller;
+1 -3
View File
@@ -428,6 +428,7 @@ if ("${SERENITY_ARCH}" STREQUAL "x86_64")
Arch/x86_64/Interrupts/APIC.cpp
Arch/x86_64/Interrupts/IOAPIC.cpp
Arch/x86_64/Interrupts/PIC.cpp
Arch/x86_64/Interrupts/PICSpuriousInterruptHandler.cpp
Arch/x86_64/Time/APICTimer.cpp
Arch/x86_64/Time/HPET.cpp
Arch/x86_64/Time/HPETComparator.cpp
@@ -446,9 +447,6 @@ if ("${SERENITY_ARCH}" STREQUAL "x86_64")
Arch/x86_64/RTC.cpp
Arch/x86_64/Shutdown.cpp
Arch/x86_64/SmapDisabler.cpp
# TODO: Share this with the aarch64 build
Interrupts/SpuriousInterruptHandler.cpp
)
set(KERNEL_SOURCES
@@ -17,7 +17,9 @@ enum class HandlerType : u8 {
IRQHandler = 1,
SharedIRQHandler = 2,
UnhandledInterruptHandler = 3,
#if ARCH(X86_64)
SpuriousInterruptHandler = 4
#endif
};
class GenericInterruptHandler {