xref: /DragonOS/kernel/src/exception/handle.rs (revision d2b28acb4d1f160779b25d76afca49ed60ad5d48)
1 use alloc::sync::Arc;
2 
3 use crate::arch::CurrentIrqArch;
4 
5 use super::{
6     irqdesc::{IrqDesc, IrqFlowHandler},
7     InterruptArch,
8 };
9 
10 /// 获取用于处理错误的中断的处理程序
11 #[inline(always)]
12 pub fn bad_irq_handler() -> &'static dyn IrqFlowHandler {
13     &HandleBadIrq
14 }
15 
16 /// handle spurious and unhandled irqs
17 #[derive(Debug)]
18 struct HandleBadIrq;
19 
20 impl IrqFlowHandler for HandleBadIrq {
21     /// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/kernel/irq/handle.c?fi=handle_bad_irq#33
22     fn handle(&self, irq_desc: &Arc<IrqDesc>) {
23         // todo: print_irq_desc
24         // todo: 增加kstat计数
25         CurrentIrqArch::ack_bad_irq(irq_desc.irq());
26     }
27 }
28