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