From 32ee3895e67ba079c4260ab5387681c77b23e5f8 Mon Sep 17 00:00:00 2001 From: Marvin Friedrich Date: Fri, 25 Sep 2026 18:15:26 +0200 Subject: [PATCH] send apic spurious ints to its own vector --- arch/x86_64/apic.c | 10 +++++----- arch/x86_64/include/x86_64/defs.h | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/x86_64/apic.c b/arch/x86_64/apic.c index 7492ac6..b618f0d 100644 --- a/arch/x86_64/apic.c +++ b/arch/x86_64/apic.c @@ -57,7 +57,7 @@ void lapic_init(struct local_apic* lapic) { // Reset the TPR. lapic_write_reg(lapic, APIC_REG_TPR, 0); // Enable APIC bit in the SIVR. - lapic_write_reg(lapic, APIC_REG_SIVR, lapic_read_reg(lapic, APIC_REG_SIVR) | 0x100); + lapic_write_reg(lapic, APIC_REG_SIVR, (lapic_read_reg(lapic, APIC_REG_SIVR) & ~0xFF) | 0x100 | IDT_SPURIOUS); if (lapic->xapic_regs) { lapic_write_reg(lapic, APIC_REG_DFR, 0xF000'0000); @@ -84,10 +84,10 @@ void lapic_eoi(struct local_apic* lapic) { lapic_write_reg(lapic, APIC_REG_EOI, 0); } -#define PIC1_COMMAND_PORT 0x20 -#define PIC1_DATA_PORT 0x21 -#define PIC2_COMMAND_PORT 0xA0 -#define PIC2_DATA_PORT 0xA1 +constexpr uint16_t PIC1_COMMAND_PORT = 0x20; +constexpr uint16_t PIC1_DATA_PORT = 0x21; +constexpr uint16_t PIC2_COMMAND_PORT = 0xA0; +constexpr uint16_t PIC2_DATA_PORT = 0xA1; void pic_disable() { // We initialize the PIC properly, but completely disable it and use the APIC in favor of it. diff --git a/arch/x86_64/include/x86_64/defs.h b/arch/x86_64/include/x86_64/defs.h index 652dfc6..b1782e7 100644 --- a/arch/x86_64/include/x86_64/defs.h +++ b/arch/x86_64/include/x86_64/defs.h @@ -198,4 +198,5 @@ #define CPL_KERNEL (0x0) #define IDT_PF (0xE) +#define IDT_SPURIOUS (0xFE) #define IDT_IPI_RESCHED (0xFF)