xref: /DragonOS/kernel/src/arch/x86_64/asm/irqflags.rs (revision 2291ffdece1dc5a703602f79f74df8a4854d215b)
1 use core::{arch::asm, ptr::read_volatile};
2 
3 #[inline]
4 pub fn local_irq_save(flags: &mut u64) {
5     unsafe {
6         asm!("pushfq", "pop rax", "mov rax, {0}", "cli", out(reg)(*flags),);
7     }
8 }
9 
10 #[inline]
11 pub fn local_irq_restore(flags: &u64) {
12     let x = unsafe { read_volatile(flags) };
13 
14     unsafe {
15         asm!("push r15",
16             "popfq", in("r15")(x));
17     }
18 }
19