13bc96fa4SLoGin use alloc::sync::Arc;
23bc96fa4SLoGin use system_error::SystemError;
33bc96fa4SLoGin
43bc96fa4SLoGin use crate::arch::CurrentIrqArch;
53bc96fa4SLoGin
63bc96fa4SLoGin use super::{
73bc96fa4SLoGin irqchip::{IrqChip, IrqChipFlags},
83bc96fa4SLoGin irqdata::IrqData,
93bc96fa4SLoGin InterruptArch,
103bc96fa4SLoGin };
113bc96fa4SLoGin
123bc96fa4SLoGin static mut NO_IRQ_CHIP: Option<Arc<NoIrqChip>> = None;
133bc96fa4SLoGin static mut DUMMY_IRQ_CHIP: Option<Arc<DummyIrqChip>> = None;
143bc96fa4SLoGin
153bc96fa4SLoGin #[inline(never)]
no_irq_chip() -> Arc<dyn IrqChip>163bc96fa4SLoGin pub fn no_irq_chip() -> Arc<dyn IrqChip> {
173bc96fa4SLoGin unsafe { NO_IRQ_CHIP.as_ref().unwrap().clone() }
183bc96fa4SLoGin }
193bc96fa4SLoGin
203bc96fa4SLoGin #[allow(dead_code)]
213bc96fa4SLoGin #[inline(never)]
dummy_irq_chip() -> Arc<dyn IrqChip>223bc96fa4SLoGin pub fn dummy_irq_chip() -> Arc<dyn IrqChip> {
233bc96fa4SLoGin unsafe { DUMMY_IRQ_CHIP.as_ref().unwrap().clone() }
243bc96fa4SLoGin }
253bc96fa4SLoGin
ack_bad(irq_data: &Arc<IrqData>)263bc96fa4SLoGin fn ack_bad(irq_data: &Arc<IrqData>) {
273bc96fa4SLoGin // todo: print_irq_desc
283bc96fa4SLoGin CurrentIrqArch::ack_bad_irq(irq_data.irq());
293bc96fa4SLoGin }
303bc96fa4SLoGin
313bc96fa4SLoGin #[derive(Debug)]
323bc96fa4SLoGin struct NoIrqChip;
333bc96fa4SLoGin
343bc96fa4SLoGin impl NoIrqChip {
new() -> Self353bc96fa4SLoGin pub const fn new() -> Self {
363bc96fa4SLoGin NoIrqChip
373bc96fa4SLoGin }
383bc96fa4SLoGin }
393bc96fa4SLoGin
403bc96fa4SLoGin impl IrqChip for NoIrqChip {
name(&self) -> &'static str413bc96fa4SLoGin fn name(&self) -> &'static str {
423bc96fa4SLoGin "none"
433bc96fa4SLoGin }
44*e2841179SLoGin
can_mask_ack(&self) -> bool45*e2841179SLoGin fn can_mask_ack(&self) -> bool {
46*e2841179SLoGin false
47*e2841179SLoGin }
48*e2841179SLoGin
irq_enable(&self, _irq: &Arc<IrqData>) -> Result<(), SystemError>493bc96fa4SLoGin fn irq_enable(&self, _irq: &Arc<IrqData>) -> Result<(), SystemError> {
503bc96fa4SLoGin Ok(())
513bc96fa4SLoGin }
523bc96fa4SLoGin
can_set_affinity(&self) -> bool53*e2841179SLoGin fn can_set_affinity(&self) -> bool {
54*e2841179SLoGin false
55*e2841179SLoGin }
56*e2841179SLoGin
can_set_flow_type(&self) -> bool57*e2841179SLoGin fn can_set_flow_type(&self) -> bool {
58*e2841179SLoGin false
59*e2841179SLoGin }
60*e2841179SLoGin
irq_disable(&self, _irq: &Arc<IrqData>)613bc96fa4SLoGin fn irq_disable(&self, _irq: &Arc<IrqData>) {}
623bc96fa4SLoGin
irq_ack(&self, irq: &Arc<IrqData>)633bc96fa4SLoGin fn irq_ack(&self, irq: &Arc<IrqData>) {
643bc96fa4SLoGin ack_bad(irq);
653bc96fa4SLoGin }
663bc96fa4SLoGin
irq_startup(&self, _irq: &Arc<IrqData>) -> Result<(), SystemError>673bc96fa4SLoGin fn irq_startup(&self, _irq: &Arc<IrqData>) -> Result<(), SystemError> {
683bc96fa4SLoGin Ok(())
693bc96fa4SLoGin }
703bc96fa4SLoGin
irq_shutdown(&self, _irq: &Arc<IrqData>) -> Result<(), SystemError>713bc96fa4SLoGin fn irq_shutdown(&self, _irq: &Arc<IrqData>) -> Result<(), SystemError> {
723bc96fa4SLoGin Ok(())
733bc96fa4SLoGin }
743bc96fa4SLoGin
flags(&self) -> IrqChipFlags753bc96fa4SLoGin fn flags(&self) -> IrqChipFlags {
763bc96fa4SLoGin IrqChipFlags::IRQCHIP_SKIP_SET_WAKE
773bc96fa4SLoGin }
783bc96fa4SLoGin }
793bc96fa4SLoGin
803bc96fa4SLoGin #[derive(Debug)]
813bc96fa4SLoGin struct DummyIrqChip;
823bc96fa4SLoGin
833bc96fa4SLoGin impl DummyIrqChip {
new() -> Self843bc96fa4SLoGin pub const fn new() -> Self {
853bc96fa4SLoGin DummyIrqChip
863bc96fa4SLoGin }
873bc96fa4SLoGin }
883bc96fa4SLoGin
893bc96fa4SLoGin impl IrqChip for DummyIrqChip {
name(&self) -> &'static str903bc96fa4SLoGin fn name(&self) -> &'static str {
913bc96fa4SLoGin "dummy"
923bc96fa4SLoGin }
933bc96fa4SLoGin
can_mask_ack(&self) -> bool94*e2841179SLoGin fn can_mask_ack(&self) -> bool {
95*e2841179SLoGin false
96*e2841179SLoGin }
97*e2841179SLoGin
irq_enable(&self, _irq: &Arc<IrqData>) -> Result<(), SystemError>983bc96fa4SLoGin fn irq_enable(&self, _irq: &Arc<IrqData>) -> Result<(), SystemError> {
993bc96fa4SLoGin Ok(())
1003bc96fa4SLoGin }
1013bc96fa4SLoGin
can_set_flow_type(&self) -> bool102*e2841179SLoGin fn can_set_flow_type(&self) -> bool {
103*e2841179SLoGin false
104*e2841179SLoGin }
105*e2841179SLoGin
can_set_affinity(&self) -> bool106*e2841179SLoGin fn can_set_affinity(&self) -> bool {
107*e2841179SLoGin false
108*e2841179SLoGin }
109*e2841179SLoGin
irq_disable(&self, _irq: &Arc<IrqData>)1103bc96fa4SLoGin fn irq_disable(&self, _irq: &Arc<IrqData>) {}
1113bc96fa4SLoGin
irq_ack(&self, _irq: &Arc<IrqData>)1123bc96fa4SLoGin fn irq_ack(&self, _irq: &Arc<IrqData>) {}
1133bc96fa4SLoGin
irq_startup(&self, _irq: &Arc<IrqData>) -> Result<(), SystemError>1143bc96fa4SLoGin fn irq_startup(&self, _irq: &Arc<IrqData>) -> Result<(), SystemError> {
1153bc96fa4SLoGin Ok(())
1163bc96fa4SLoGin }
1173bc96fa4SLoGin
irq_shutdown(&self, _irq: &Arc<IrqData>) -> Result<(), SystemError>1183bc96fa4SLoGin fn irq_shutdown(&self, _irq: &Arc<IrqData>) -> Result<(), SystemError> {
1193bc96fa4SLoGin Ok(())
1203bc96fa4SLoGin }
1213bc96fa4SLoGin
flags(&self) -> IrqChipFlags1223bc96fa4SLoGin fn flags(&self) -> IrqChipFlags {
1233bc96fa4SLoGin IrqChipFlags::IRQCHIP_SKIP_SET_WAKE
1243bc96fa4SLoGin }
1253bc96fa4SLoGin }
1263bc96fa4SLoGin
1273bc96fa4SLoGin #[inline(never)]
dummy_chip_init()1283bc96fa4SLoGin pub fn dummy_chip_init() {
1293bc96fa4SLoGin unsafe {
1303bc96fa4SLoGin NO_IRQ_CHIP = Some(Arc::new(NoIrqChip::new()));
1313bc96fa4SLoGin DUMMY_IRQ_CHIP = Some(Arc::new(DummyIrqChip::new()));
1323bc96fa4SLoGin }
1333bc96fa4SLoGin }
134