use linkme::distributed_slice as def_trap_handler;
use memory_addr::VirtAddr;
use page_table_entry::MappingFlags;
pub use linkme::distributed_slice as register_trap_handler;
#[def_trap_handler]
pub static IRQ: [fn(usize) -> bool];
#[def_trap_handler]
pub static PAGE_FAULT: [fn(VirtAddr, MappingFlags, bool) -> bool];
#[allow(unused_macros)]
macro_rules! handle_trap {
($trap:ident, $($args:tt)*) => {{
let mut iter = $crate::trap::$trap.iter();
if let Some(func) = iter.next() {
if iter.next().is_some() {
warn!("Multiple handlers for trap {} are not currently supported", stringify!($trap));
}
func($($args)*)
} else {
warn!("No registered handler for trap {}", stringify!($trap));
false
}
}}
}