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