stos/amd64: irqchip: Detect and disable i8259s
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -8,9 +8,14 @@
|
|||||||
|
|
||||||
#include <hal/board.h>
|
#include <hal/board.h>
|
||||||
#include <machine/hpet.h>
|
#include <machine/hpet.h>
|
||||||
|
#include <machine/irqchip.h>
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
HalBoardInit(VOID)
|
HalBoardInit(VOID)
|
||||||
{
|
{
|
||||||
|
/* Initialize HPET */
|
||||||
MdHpetInit();
|
MdHpetInit();
|
||||||
|
|
||||||
|
/* Initialize IRQ chips */
|
||||||
|
MdIrqChipInit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026, Chloe M.
|
||||||
|
* Provided under the BSD-3 clause.
|
||||||
|
*
|
||||||
|
* Description: IRQ chip management
|
||||||
|
* Author: Chloe M.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MACHINE_IRQCHIP_H_
|
||||||
|
#define _MACHINE_IRQCHIP_H_ 1
|
||||||
|
|
||||||
|
#include <stdef.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enumerate and save all platform IRQ chips
|
||||||
|
*/
|
||||||
|
VOID MdIrqChipInit(VOID);
|
||||||
|
|
||||||
|
#endif /* !_MACHINE_IRQCHIP_H_ */
|
||||||
Reference in New Issue
Block a user