stos/amd64: cpu: Save KPCR in IA32_GS_BASE
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
#include <ke/knot.h>
|
#include <ke/knot.h>
|
||||||
#include <machine/cpuid.h>
|
#include <machine/cpuid.h>
|
||||||
#include <machine/idt.h>
|
#include <machine/idt.h>
|
||||||
|
#include <machine/msr.h>
|
||||||
#include <stdef.h>
|
#include <stdef.h>
|
||||||
|
|
||||||
#define DTRACE(Fmt, ...) \
|
#define DTRACE(Fmt, ...) \
|
||||||
@@ -132,6 +133,9 @@ HalKpcrP1Init(KPCR *Kpcr)
|
|||||||
: "r" ((UQUAD)IRQL_PASSIVE)
|
: "r" ((UQUAD)IRQL_PASSIVE)
|
||||||
: "memory"
|
: "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/* Save the current KPCR */
|
||||||
|
MdWrmsr(IA32_GS_BASE, (UPTR)Kpcr);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
@@ -152,3 +156,19 @@ HalKpcrP2Init(KPCR *Kpcr)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KPCR *
|
||||||
|
HalKpcrCurrent(VOID)
|
||||||
|
{
|
||||||
|
KPCR *Kpcr;
|
||||||
|
|
||||||
|
Kpcr = (KPCR *)MdRdmsr(IA32_GS_BASE);
|
||||||
|
if (Kpcr == NULL) {
|
||||||
|
KeKnot(
|
||||||
|
KNOT_UNBOUND_RSRC,
|
||||||
|
"current kpcr is NULL\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Kpcr;
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,4 +41,10 @@ VOID HalKpcrP1Init(KPCR *Kpcr);
|
|||||||
*/
|
*/
|
||||||
VOID HalKpcrP2Init(KPCR *Kpcr);
|
VOID HalKpcrP2Init(KPCR *Kpcr);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Obtain the KPCR for the current processor, it is never to
|
||||||
|
* be of a NULL value.
|
||||||
|
*/
|
||||||
|
KPCR *HalKpcrCurrent(VOID);
|
||||||
|
|
||||||
#endif /* !_HAL_KPCR_H_ */
|
#endif /* !_HAL_KPCR_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user