diff options
Diffstat (limited to 'src/arch/x86_64/mod.rs')
| -rw-r--r-- | src/arch/x86_64/mod.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/arch/x86_64/mod.rs b/src/arch/x86_64/mod.rs index ee51338..38b08b1 100644 --- a/src/arch/x86_64/mod.rs +++ b/src/arch/x86_64/mod.rs @@ -4,3 +4,19 @@ pub mod io_port; pub mod mem; pub mod misc; pub mod paging; +use core::arch::asm; + +pub const RFLAGS_IF_MASK: u64 = 1 << 9; +#[inline] +pub fn read_rflags() -> u64 { + let rflags; + unsafe { + asm!("pushfq; popq {}", out(reg) rflags); + } + rflags +} + +pub fn is_int_enabled() -> bool { + let rf = read_rflags(); + return (rf & RFLAGS_IF_MASK) != 0; +} |
