xref: /DragonOS/kernel/src/arch/x86_64/asm/irqflags.rs (revision 36fd013004ee0bd5fc7cfb452ba22531a83a859c)
1 use core::arch::asm;
2 
3 #[inline]
4 pub fn local_irq_save() -> usize {
5     let x: usize;
6     unsafe {
7         asm!("pushfq ; pop {} ; cli", out(reg) x, options(nostack));
8     }
9     x
10 }
11 
12 #[inline]
13 // 恢复先前保存的rflags的值x
14 pub fn local_irq_restore(x: usize) {
15     unsafe {
16         asm!("push {} ; popfq", in(reg) x, options(nostack));
17     }
18 }
19