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 <hal/kpcr.h>
#include <ke/bugcheck.h>
#include <machine/idt.h> #include <machine/idt.h>
#include <machine/trap.h> #include <machine/trap.h>
#include <machine/msr.h>
/* /*
* Initialize interrupts for the current processor * Initialize interrupts for the current processor
@@ -34,8 +36,28 @@ InitInterrupts(VOID)
MdIdtLoad(); 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 VOID
HalKpcrP1Init(KPCR *Kpcr) HalKpcrP1Init(KPCR *Kpcr)
{ {
/* Initialize interrupts for this core */
InitInterrupts(); InitInterrupts();
/* Save the current KPCR */
MdWrmsr(IA32_GS_BASE, (UPTR)Kpcr);
} }
+6
View File
@@ -28,4 +28,10 @@ typedef struct {
*/ */
VOID HalKpcrP1Init(KPCR *Kpcr); VOID HalKpcrP1Init(KPCR *Kpcr);
/*
* Obtain the KPCR of the current processor
* core
*/
KPCR *HalKpcrCurrent(VOID);
#endif /* !_HAL_KPCR_H_ */ #endif /* !_HAL_KPCR_H_ */