cfg_if::cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
} else if #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] {
mod riscv;
pub use self::riscv::*;
} else if #[cfg(target_arch = "aarch64")]{
mod aarch64;
pub use self::aarch64::*;
}
}
#[cfg(feature = "monolithic")]
pub fn write_trapframe_to_kstack(kstack_top: usize, trap_frame: &TrapFrame) {
let trap_frame_size = core::mem::size_of::<TrapFrame>();
let trap_frame_ptr = (kstack_top - trap_frame_size) as *mut TrapFrame;
unsafe {
*trap_frame_ptr = *trap_frame;
}
}
#[cfg(feature = "monolithic")]
pub fn read_trapframe_from_kstack(kstack_top: usize) -> TrapFrame {
let trap_frame_size = core::mem::size_of::<TrapFrame>();
let trap_frame_ptr = (kstack_top - trap_frame_size) as *mut TrapFrame;
unsafe { *trap_frame_ptr }
}