/* * Copyright (c) 2026, Chloe M. * Provided under the BSD-3 clause. * * Description: IRQ chip management * Author: Chloe M. */ #include #include #include #include #include #include /* PIC data ports */ #define PIC_MASTER_DATA 0x21 #define PIC_SLAVE_DATA 0xA1 #define DTRACE(Fmt, ...) \ TRACE("[ IRQCHIP ]: " Fmt, ##__VA_ARGS__) /* Set if dual i8259 is present */ #define MADT_PCAT_COMPAT BIT(0) VOID MdIrqChipInit(VOID) { ACPI_MADT *Madt; Madt = AcpiQuery("APIC"); if (Madt == NULL) { KeKnot( KNOT_UNBOUND_RSRC, "could not locate ACPI MADT\n" ); } /* * If we have a dual-i8259 configuration present on the * machine, we'll want to disable it so it doesn't mess * up Local APIC operation and such. */ if (ISSET(Madt->Flags, MADT_PCAT_COMPAT)) { DTRACE("detected dual i8259; disabling...\n"); MdOutb(PIC_MASTER_DATA, 0xFF); MdOutb(PIC_SLAVE_DATA, 0xFF); } }