diff --git a/service/ptos/arch/amd64/cpu/init.c b/service/ptos/arch/amd64/cpu/init.c index dfb44b4..cdbf781 100644 --- a/service/ptos/arch/amd64/cpu/init.c +++ b/service/ptos/arch/amd64/cpu/init.c @@ -7,8 +7,10 @@ */ #include +#include #include #include +#include /* * 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); } diff --git a/service/ptos/head/hal/kpcr.h b/service/ptos/head/hal/kpcr.h index 0dc894b..55a52ad 100644 --- a/service/ptos/head/hal/kpcr.h +++ b/service/ptos/head/hal/kpcr.h @@ -28,4 +28,10 @@ typedef struct { */ VOID HalKpcrP1Init(KPCR *Kpcr); +/* + * Obtain the KPCR of the current processor + * core + */ +KPCR *HalKpcrCurrent(VOID); + #endif /* !_HAL_KPCR_H_ */