From 64b2e8d77a8ae268599da9e6010ebef85dbe90d3 Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Wed, 2 Apr 2014 22:43:04 +0200 Subject: [PATCH] Add a way to get RFLAGS register value --- kernel/include/arch.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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