Minimal interrupts, prevent deadlocks

This commit is contained in:
2025-03-02 10:03:16 -08:00
parent 18113a3f4b
commit e3bdce6065
5 changed files with 174 additions and 101 deletions

View File

@ -1,9 +1,9 @@
use bitflags::bitflags;
use core::arch::asm;
use core::{fmt, ops::Deref};
use super::VirtAddr;
use bitflags::bitflags;
bitflags! {
/// The EFLAGS register. All bit patterns are valid representations for this type.
///
@ -82,6 +82,24 @@ bitflags! {
}
}
impl EFlags {
#[inline]
pub fn read() -> EFlags {
EFlags::from_bits_truncate(EFlags::read_raw())
}
#[inline]
fn read_raw() -> u32 {
let r: u32;
unsafe {
asm!("pushfd; pop {0:e}", out(reg) r, options(nomem, preserves_flags));
}
r
}
}
/// Wrapper type for the interrupt stack frame pushed by the CPU.
///
/// This type derefs to an [`InterruptStackFrameValue`], which allows reading the actual values.