You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
peari9jp6/kernel/src/arch/aarch64/interrupt/mod.rs

52 lines
945 B

//! Interrupt and exception for aarch64.
mod handler;
mod context;
mod syndrome;
use aarch64::regs::*;
pub use self::context::*;
pub use self::handler::*;
/// Set the exception vector address
pub fn init() {
unsafe {
asm!(
"adr x0, __vectors;
msr vbar_el1, x0"
);
}
}
/// Enable the interrupt (only IRQ).
#[inline(always)]
pub unsafe fn enable() {
asm!("msr daifclr, #2");
}
/// Disable the interrupt (only IRQ).
#[inline(always)]
pub unsafe fn disable() {
asm!("msr daifset, #2");
}
/// Disable the interrupt and store the status.
///
/// return: status(usize)
#[inline(always)]
pub unsafe fn disable_and_store() -> usize {
let daif = DAIF.get() as usize;
disable();
daif
}
/// Use the original status to restore the process
///
/// Arguments:
/// * flags: original status(usize)
#[inline(always)]
pub unsafe fn restore(flags: usize) {
DAIF.set(flags as u32);
}