From 751dda8f1e2778155c572b7618bad46d4bf15d79 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Fri, 2 Sep 2011 13:51:29 -0700 Subject: [PATCH] add helper function to determine, if the interrupt flag is set --- arch/x86/include/asm/irqflags.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h index 81e3dd4c..093fb61f 100644 --- a/arch/x86/include/asm/irqflags.h +++ b/arch/x86/include/asm/irqflags.h @@ -75,6 +75,21 @@ inline static void irq_nested_enable(uint32_t flags) { irq_enable(); } +/** @brief Determines, if the interrupt flags (IF) is ser + * + * @return + * - 1 interrupt flag is set + * - 0 interrupt flag is cleared + */ +inline static uint32_t is_irq_enabled(void) +{ + uint32_t flags; + asm volatile("pushf; popl %0": "=r"(flags) : : "memory"); + if (flags & (1 << 9)) + return 1; + return 0; +} + #ifdef __cplusplus } #endif