ptos/amd64+hal: intr: Add IRQL managmenet
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <hal/intr.h>
|
||||
#include <ke/bugcheck.h>
|
||||
#include <machine/intr.h>
|
||||
#include <machine/idt.h>
|
||||
#include <ptdef.h>
|
||||
@@ -14,6 +15,20 @@
|
||||
/* Globals */
|
||||
static INTR_HANDLER HandlerTable[256];
|
||||
|
||||
/*
|
||||
* Set a new IRQL
|
||||
*/
|
||||
static inline VOID
|
||||
SetIrql(IRQL Irql)
|
||||
{
|
||||
ASMV(
|
||||
"mov %0, %%cr8"
|
||||
:
|
||||
: "r" ((UQUAD)Irql)
|
||||
: "memory"
|
||||
);
|
||||
}
|
||||
|
||||
UCHAR
|
||||
HalIntrRegister(INTR_HANDLER *Handler, BOOLEAN IsUser)
|
||||
{
|
||||
@@ -56,3 +71,45 @@ HalIntrRegister(INTR_HANDLER *Handler, BOOLEAN IsUser)
|
||||
/* No more vectors */
|
||||
return 0;
|
||||
}
|
||||
|
||||
IRQL
|
||||
HalGetIrql(VOID)
|
||||
{
|
||||
UQUAD CurrentIrql;
|
||||
|
||||
ASMV(
|
||||
"mov %%cr8, %0"
|
||||
: "=r" (CurrentIrql)
|
||||
:
|
||||
: "memory"
|
||||
);
|
||||
|
||||
return (IRQL)CurrentIrql;
|
||||
}
|
||||
|
||||
IRQL
|
||||
HalRaiseIrql(IRQL Irql)
|
||||
{
|
||||
IRQL CurrentIrql;
|
||||
|
||||
CurrentIrql = HalGetIrql();
|
||||
if (Irql < CurrentIrql) {
|
||||
KeBugCheck(BUGCHECK_IRQL_NOT_GTE, "got bad irql\n");
|
||||
}
|
||||
|
||||
SetIrql(Irql);
|
||||
return CurrentIrql;
|
||||
}
|
||||
|
||||
IRQL
|
||||
HalLowerIrql(IRQL Irql)
|
||||
{
|
||||
IRQL CurrentIrql;
|
||||
|
||||
CurrentIrql = HalGetIrql();
|
||||
if (Irql > CurrentIrql) {
|
||||
KeBugCheck(BUGCHECK_IRQL_NOT_LTE, "got bad irql\n");
|
||||
}
|
||||
|
||||
return CurrentIrql;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user