diff --git a/kernel/include/arch.hpp b/kernel/include/arch.hpp index 2cd02e90..2e3f1805 100644 --- a/kernel/include/arch.hpp +++ b/kernel/include/arch.hpp @@ -9,4 +9,23 @@ namespace arch { void enable_sse(); +inline size_t get_rflags(){ + size_t rflags; + asm volatile("pushfq; pop %0;" : "=g" (rflags)); + return rflags; +} + +inline void disable_hwint(size_t& rflags){ + asm volatile("pushfq; pop %0; cli;" : "=g" (rflags)); +} + +inline void enable_hwint(size_t& rflags){ + asm volatile("push %0; popfq; " :: "g" (rflags)); +} + +inline bool interrupts_enabled(){ + auto flags = get_rflags(); + return flags & 0x200; +} + } //enf of arch namespace