xref: /DragonOS/kernel/src/arch/x86_64/asm/irqflags.rs (revision 7f439c5ddbd2ecffc112149d16983975f523052c)
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