Add a way to get RFLAGS register value

This commit is contained in:
Baptiste Wicht 2014-04-02 22:43:04 +02:00
parent b3f1b9bbcc
commit 64b2e8d77a

View File

@ -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