From 740df726e9fb5071c58cb3081fdd283643783796 Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Fri, 17 May 2024 23:19:25 +0200 Subject: [PATCH] Implement ArInterruptsEnabled() routine --- xtoskrnl/ar/amd64/cpufunc.c | 20 ++++++++++++++++++++ xtoskrnl/ar/i686/cpufunc.c | 20 ++++++++++++++++++++ xtoskrnl/includes/amd64/ari.h | 4 ++++ xtoskrnl/includes/i686/ari.h | 4 ++++ 4 files changed, 48 insertions(+) diff --git a/xtoskrnl/ar/amd64/cpufunc.c b/xtoskrnl/ar/amd64/cpufunc.c index b38eeec..95e621f 100644 --- a/xtoskrnl/ar/amd64/cpufunc.c +++ b/xtoskrnl/ar/amd64/cpufunc.c @@ -140,6 +140,26 @@ ArHalt(VOID) asm volatile("hlt"); } +/** + * Checks whether interrupts are enabled or not. + * + * @return This routine returns TRUE if interrupts are enabled, or FALSE otherwise. + * + * @since XT 1.0 + */ +XTCDECL +BOOLEAN +ArInterruptsEnabled(VOID) +{ + ULONG_PTR Flags; + + /* Get RFLAGS register */ + Flags = ArGetCpuFlags(); + + /* Check if interrupts are enabled and return result */ + return (Flags & X86_EFLAGS_IF_MASK) ? TRUE : FALSE; +} + /** * Invalidates the TLB (Translation Lookaside Buffer) for specified virtual address. * diff --git a/xtoskrnl/ar/i686/cpufunc.c b/xtoskrnl/ar/i686/cpufunc.c index 17aeba4..b6fa66b 100644 --- a/xtoskrnl/ar/i686/cpufunc.c +++ b/xtoskrnl/ar/i686/cpufunc.c @@ -140,6 +140,26 @@ ArHalt(VOID) asm volatile("hlt"); } +/** + * Checks whether interrupts are enabled or not. + * + * @return This routine returns TRUE if interrupts are enabled, or FALSE otherwise. + * + * @since XT 1.0 + */ +XTCDECL +BOOLEAN +ArInterruptsEnabled(VOID) +{ + ULONG_PTR Flags; + + /* Get RFLAGS register */ + Flags = ArGetCpuFlags(); + + /* Check if interrupts are enabled and return result */ + return (Flags & X86_EFLAGS_IF_MASK) ? TRUE : FALSE; +} + /** * Invalidates the TLB (Translation Lookaside Buffer) for specified virtual address. * diff --git a/xtoskrnl/includes/amd64/ari.h b/xtoskrnl/includes/amd64/ari.h index 54c702a..1b63daa 100644 --- a/xtoskrnl/includes/amd64/ari.h +++ b/xtoskrnl/includes/amd64/ari.h @@ -42,6 +42,10 @@ XTAPI VOID ArInitializeProcessor(IN PVOID ProcessorStructures); +XTCDECL +BOOLEAN +ArInterruptsEnabled(VOID); + XTCDECL VOID ArInvalidateTlbEntry(IN PVOID Address); diff --git a/xtoskrnl/includes/i686/ari.h b/xtoskrnl/includes/i686/ari.h index d61a0bd..377e7f3 100644 --- a/xtoskrnl/includes/i686/ari.h +++ b/xtoskrnl/includes/i686/ari.h @@ -42,6 +42,10 @@ XTAPI VOID ArInitializeProcessor(IN PVOID ProcessorStructures); +XTCDECL +BOOLEAN +ArInterruptsEnabled(VOID); + XTCDECL VOID ArInvalidateTlbEntry(IN PVOID Address);