55e12ce62d
Signed-off-by: Chloe M. <chloe@mensia.org>
50 lines
1.1 KiB
C
50 lines
1.1 KiB
C
/*
|
|
* Copyright (c) 2026, Chloe M.
|
|
* Provided under the BSD-3 clause.
|
|
*
|
|
* Description: IRQ chip management
|
|
* Author: Chloe M.
|
|
*/
|
|
|
|
#include <drivers/acpi/tables.h>
|
|
#include <drivers/acpi/acpi.h>
|
|
#include <machine/irqchip.h>
|
|
#include <machine/pio.h>
|
|
#include <ke/knot.h>
|
|
#include <ex/trace.h>
|
|
|
|
/* 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);
|
|
}
|
|
}
|