stos/amd64: cpu: Save Local APIC base in MCB
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
#include <machine/lapicreg.h>
|
||||
#include <machine/msr.h>
|
||||
#include <machine/cpuid.h>
|
||||
#include <drivers/acpi/tables.h>
|
||||
#include <drivers/acpi/acpi.h>
|
||||
#include <mm/vmm.h>
|
||||
#include <ex/trace.h>
|
||||
#include <ke/knot.h>
|
||||
#include <stdef.h>
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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_ */
|
||||
|
||||
Reference in New Issue
Block a user