]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
fix: add IOAPIC route for IRQ 15 (secondary ATA channel)
authorTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 08:22:35 +0000 (05:22 -0300)
committerTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 08:22:35 +0000 (05:22 -0300)
The secondary ATA channel (IRQ 15, vector 47) was not routed through
the IOAPIC. After the multi-drive ATA refactor, ata_pio_init() probes
the secondary channel, which can generate IRQ 15 (e.g. IDENTIFY to
QEMU's ATAPI CD-ROM). Without a proper IOAPIC route:

1. The interrupt was lost (PIC disabled, IOAPIC not routing it)
2. The IOAPIC pin 15 remained in an undefined state
3. Depending on timing, this could cause spurious behavior

This was the likely root cause of intermittent kernel panics/reboots
when booting without the 'ring3' cmdline flag — the timing difference
meant the secondary ATA probe's unhandled IRQ could manifest as an
unrecoverable interrupt state.

Build: clean, cppcheck: clean, smoke: 19/19 pass

src/arch/x86/arch_platform.c

index cccb24202b53778a2d7643805efeeb69d6267ff7..6775767d8e80a2e7c5e021c3ac55916e9ae9c5cf 100644 (file)
@@ -118,13 +118,16 @@ int arch_platform_setup(const struct boot_info* bi) {
         if (ioapic_init()) {
             uint32_t bsp_id = lapic_get_id();
             /* Route ISA IRQs through IOAPIC:
-             * IRQ 0 (PIT/Timer)    -> IDT vector 32
-             * IRQ 1 (Keyboard)     -> IDT vector 33
-             * IRQ 14 (ATA primary) -> IDT vector 46 */
+             * IRQ 0  (PIT/Timer)      -> IDT vector 32
+             * IRQ 1  (Keyboard)       -> IDT vector 33
+             * IRQ 11 (E1000 NIC)      -> IDT vector 43
+             * IRQ 14 (ATA primary)    -> IDT vector 46
+             * IRQ 15 (ATA secondary)  -> IDT vector 47 */
             ioapic_route_irq(0,  32, (uint8_t)bsp_id);
             ioapic_route_irq(1,  33, (uint8_t)bsp_id);
             ioapic_route_irq(11, 43, (uint8_t)bsp_id); /* E1000 NIC */
-            ioapic_route_irq(14, 46, (uint8_t)bsp_id);
+            ioapic_route_irq(14, 46, (uint8_t)bsp_id); /* ATA primary */
+            ioapic_route_irq(15, 47, (uint8_t)bsp_id); /* ATA secondary */
 
             /* Now that IOAPIC routes are live, disable the legacy PIC.
              * This must happen AFTER IOAPIC is configured to avoid