From be09d3e5351fc42426605923b0fe7bda420cba21 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 23 Dec 2023 20:44:23 -0500 Subject: kernel/amd64: cpu: Add interrupt helper routine This commit adds a helper that allows checking if maskable interrupts are disabled on the current core. Signed-off-by: Ian Moffett --- sys/include/arch/amd64/cpu.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'sys') diff --git a/sys/include/arch/amd64/cpu.h b/sys/include/arch/amd64/cpu.h index ff294de..3d73e34 100644 --- a/sys/include/arch/amd64/cpu.h +++ b/sys/include/arch/amd64/cpu.h @@ -31,11 +31,13 @@ #define _AMD64_CPU_H_ #include +#include #include #include -#define this_cpu() amd64_this_cpu() -#define get_bsp() amd64_get_bsp() +#define this_cpu() amd64_this_cpu() +#define get_bsp() amd64_get_bsp() +#define is_intr_mask() amd64_is_intr_mask() #define CPU_INFO_LOCK(info) spinlock_acquire(&(info->lock)) #define CPU_INFO_UNLOCK(info) spinlock_release(&(info->lock)) @@ -59,6 +61,20 @@ struct cpu_info { volatile struct tss_entry *tss; }; +/* + * Returns true for this core if maskable + * interrupts are masked (CLI) and false if + * they aren't (STI). + */ +static inline bool +amd64_is_intr_mask(void) +{ + uint64_t flags; + + __ASMV("pushfq; pop %0" : "=rm" (flags) :: "memory"); + return __TEST(flags, 1 << 9); +} + struct cpu_info *amd64_this_cpu(void); struct cpu_info *amd64_get_bsp(void); -- cgit v1.2.3