stos/amd64: lapic: Detect if x2APIC mode is present

Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
Chloe M.
2026-06-26 20:46:27 +00:00
parent fd30fc5e04
commit 74d68ead72
2 changed files with 16 additions and 0 deletions
+14
View File
@@ -43,6 +43,19 @@ LapicIsSupported(VOID)
return ISSET(Edx, BIT(9)) != 0;
}
/*
* Returns true if the CPU can operate its Local APIC unit
* in the newer x2APIC mode.
*/
static BOOLEAN
LapicHasX2Apic(VOID)
{
ULONG Ecx, Unused;
CPUID(1, Unused, Unused, Ecx, Unused);
return ISSET(Ecx, BIT(21)) != 0;
}
/*
* Enable the Local APIC unit
*/
@@ -85,6 +98,7 @@ MdLapicInit(KPCR *Kpcr)
Mcb = &Kpcr->Mcb;
Mcb->LapicBase = PMA_TO_VMA((UPTR)Madt->LapicAddr);
Mcb->HasX2Apic = LapicHasX2Apic();
/* Enable the Local APIC */
LapicEnable();