diff --git a/paw/stos/arch/amd64/cpu/lapic.c b/paw/stos/arch/amd64/cpu/lapic.c index 3cc0bfc..00662e1 100644 --- a/paw/stos/arch/amd64/cpu/lapic.c +++ b/paw/stos/arch/amd64/cpu/lapic.c @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -57,13 +60,32 @@ LapicEnable(VOID) VOID MdLapicInit(KPCR *Kpcr) { + ACPI_MADT *Madt; + MCB *Mcb; + if (Kpcr == NULL) { - KeKnot(KNOT_MISC, "failed to initialize lapic driver\n"); + KeKnot( + KNOT_MISC, + "lapic: failed to initialize lapic driver\n" + ); } if (!LapicIsSupported()) { - KeKnot(KNOT_MISSING_HARDWARE, "local apic not supported\n"); + KeKnot( + KNOT_MISSING_HARDWARE, + "lapic: local apic not supported\n" + ); } + /* Obtain the ACPI MADT table */ + Madt = AcpiQuery("APIC"); + if (Madt == NULL) { + KeKnot(KNOT_MISC, "lapic: could not obtain MADT\n"); + } + + Mcb = &Kpcr->Mcb; + Mcb->LapicBase = PMA_TO_VMA((UPTR)Madt->LapicAddr); + + /* Enable the Local APIC */ LapicEnable(); } diff --git a/paw/stos/head/arch/amd64/mcb.h b/paw/stos/head/arch/amd64/mcb.h index e5dac0b..3722867 100644 --- a/paw/stos/head/arch/amd64/mcb.h +++ b/paw/stos/head/arch/amd64/mcb.h @@ -17,10 +17,12 @@ * * @ModelId: Processor model ID * @FamilyId: Processor family ID + * @LapicBase: Local APIC MMIO base */ typedef struct { UCHAR ModelId; USHORT FamilyId : 12; + VOID *LapicBase; } MCB; #endif /* !_MACHINE_MCB_H_ */