ptos/amd64: cpu: Add HalKpcrCurrent()
Signed-off-by: Chloe M <chloe@mensia.org>
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user