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