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