ptos/amd64: cpu: Add HalKpcrCurrent()

Signed-off-by: Chloe M <chloe@mensia.org>
This commit is contained in:
2026-07-13 18:13:25 -04:00
parent 6969e90db6
commit 7a8fbe7025
2 changed files with 28 additions and 0 deletions
+22
View File
@@ -7,8 +7,10 @@
*/
#include <hal/kpcr.h>
#include <ke/bugcheck.h>
#include <machine/idt.h>
#include <machine/trap.h>
#include <machine/msr.h>
/*
* Initialize interrupts for the current processor
@@ -34,8 +36,28 @@ InitInterrupts(VOID)
MdIdtLoad();
}
KPCR *
HalKpcrCurrent(VOID)
{
KPCR *Kpcr;
Kpcr = (KPCR *)MdRdmsr(IA32_GS_BASE);
if (Kpcr == NULL) {
KeBugCheck(
BUGCHECK_UNBOUND_RESRC,
"KPCR not bound in IA32_GS_BASE\n"
);
}
return Kpcr;
}
VOID
HalKpcrP1Init(KPCR *Kpcr)
{
/* Initialize interrupts for this core */
InitInterrupts();
/* Save the current KPCR */
MdWrmsr(IA32_GS_BASE, (UPTR)Kpcr);
}