stos/amd64: intr: Add IRQL management

Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
Chloe M.
2026-06-23 22:01:52 +00:00
parent 22beed638d
commit 114cc434d2
4 changed files with 88 additions and 2 deletions
+57
View File
@@ -8,6 +8,7 @@
#include <hal/intr.h>
#include <machine/idt.h>
#include <ke/knot.h>
#include <stdef.h>
/* Interrupt priority level shift */
@@ -16,6 +17,20 @@
/* Globals */
static INTR_HANDLER Handlers[256];
/*
* Set a new IRQL
*/
static inline VOID
SetIrql(IRQL Irql)
{
ASMV(
"mov %0, %%cr8"
:
: "r" ((UQUAD)Irql)
: "memory"
);
}
ST_STATUS
HalRegisterIntr(const INTR_HANDLER *Handler, BOOLEAN IsUser)
{
@@ -74,3 +89,45 @@ HalRegisterIntr(const INTR_HANDLER *Handler, BOOLEAN IsUser)
/* No entry found */
return STATUS_NOT_FOUND;
}
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) {
KeKnot(IRQL_NOT_GTE, "got bad irql\n");
}
SetIrql(Irql);
return CurrentIrql;
}
IRQL
HalLowerIrql(IRQL Irql)
{
IRQL CurrentIrql;
CurrentIrql = HalGetIrql();
if (Irql > CurrentIrql) {
KeKnot(IRQL_NOT_LTE, "got bad irql\n");
}
return CurrentIrql;
}