use handler_table::HandlerTable;
use crate::platform::irq::MAX_IRQ_COUNT;
pub use crate::platform::irq::{dispatch_irq, register_handler, set_enable};
pub type IrqHandler = handler_table::Handler;
static IRQ_HANDLER_TABLE: HandlerTable<MAX_IRQ_COUNT> = HandlerTable::new();
#[allow(dead_code)]
pub(crate) fn dispatch_irq_common(irq_num: usize) {
trace!("IRQ {}", irq_num);
if !IRQ_HANDLER_TABLE.handle(irq_num) {
warn!("Unhandled IRQ {}", irq_num);
}
}
#[allow(dead_code)]
pub(crate) fn register_handler_common(irq_num: usize, handler: IrqHandler) -> bool {
if irq_num < MAX_IRQ_COUNT && IRQ_HANDLER_TABLE.register_handler(irq_num, handler) {
set_enable(irq_num, true);
return true;
}
warn!("register handler for IRQ {} failed", irq_num);
false
}