42 lines
917 B
Rust
Raw Normal View History

#![no_std]
#![feature(effects, strict_provenance)]
use kernel_arch_interface::Architecture;
pub mod mem;
pub mod registers;
pub use mem::KernelTableManagerImpl;
pub struct ArchitectureImpl;
pub const KERNEL_VIRT_OFFSET: usize = 0xFFFFFF8000000000;
impl Architecture for ArchitectureImpl {
fn interrupt_mask() -> bool {
let mut flags: u64;
unsafe {
core::arch::asm!("pushfq; pop {0}", out(reg) flags, options(att_syntax));
}
// If IF is zero, interrupts are disabled (masked)
flags & (1 << 9) == 0
}
unsafe fn set_interrupt_mask(mask: bool) -> bool {
let old = Self::interrupt_mask();
if mask {
core::arch::asm!("cli");
} else {
core::arch::asm!("sti");
}
old
}
#[inline]
fn wait_for_interrupt() {
unsafe {
core::arch::asm!("hlt");
}
}
}