diff options
author | Ian Moffett <ian@osmora.org> | 2023-12-23 20:44:23 -0500 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2023-12-23 20:44:23 -0500 |
commit | be09d3e5351fc42426605923b0fe7bda420cba21 (patch) | |
tree | 54e1efdc2366452c55811ac00cc3556f64a5be3e | |
parent | 4642768a9f64668a9a1e4be2c92ae5a4e988e5cc (diff) |
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 <ian@osmora.org>
-rw-r--r-- | sys/include/arch/amd64/cpu.h | 20 |
1 files changed, 18 insertions, 2 deletions
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 <sys/types.h> +#include <sys/cdefs.h> #include <sys/spinlock.h> #include <machine/tss.h> -#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); |