8 * Interface used to manage harware IRQs on a platform.
10 * The main purpose of this interface is to allow an
11 * abstract mapping of global IRQ numbers to a chip
12 * and pin number pair. The interface provides also
13 * some global information about IRQs.
19 * Chip and pin for an IRQ pin.
23 // allow uninitialized instances
30 /// Create a chip-pin pair.
31 Irq(Irq_chip_icu *chip, Mword pin) : chip(chip), pin(pin) {}
36 /// The pin number local to \a chip.
40 /// Map legacy (IA32) IRQ numbers to valid IRQ numbers.
41 virtual unsigned legacy_override(Mword irqnum) { return irqnum; }
43 /// Get the chip-pin pair for the given global IRQ number.
44 virtual Irq chip(Mword irqnum) const = 0;
46 /// Get the highest available global IRQ number plus 1.
47 virtual unsigned nr_irqs() const = 0;
49 /// Get the number of available entry points for MSIs.
50 virtual unsigned nr_msis() const = 0;
52 /** Get the message to use for a given MSI.
53 * \pre The IRQ pin needs to be already allocated before using this function.
55 virtual Mword msg(Mword irqnum) const { (void)irqnum; return 0; }
57 virtual void set_cpu(Mword irqnum, unsigned cpu) const;
59 /// The pointer to the single global instance of the actual IRQ manager.
62 /// Prevent generation of a real virtual delete function
63 virtual ~Irq_mgr() = 0;
66 template< typename CHIP >
67 class Irq_mgr_single_chip : public Irq_mgr
70 Irq_mgr_single_chip() {}
72 template< typename... A >
73 explicit Irq_mgr_single_chip(A&&... args) : c(cxx::forward<A>(args)...) {}
75 Irq chip(Mword irqnum) const { return Irq(&c, irqnum); }
76 unsigned nr_irqs() const { return c.nr_irqs(); }
77 unsigned nr_msis() const { return 0; }
81 //--------------------------------------------------------------------------
86 Irq_mgr *Irq_mgr::mgr;
88 IMPLEMENT inline Irq_mgr::~Irq_mgr() {}
92 Irq_mgr::alloc(Irq_base *irq, Mword pin)
98 return i.chip->alloc(irq, i.pin);
103 Irq_mgr::reserve(Mword irqnum)
105 Irq i = chip(irqnum);
109 return i.chip->reserve(i.pin);
114 Irq_mgr::irq(Mword irqnum) const
116 Irq i = chip(irqnum);
120 return i.chip->irq(i.pin);
125 Irq_mgr::set_cpu(Mword irqnum, unsigned cpu) const
127 WARNX(Warning, "IRQ%ld: ignoring CPU setting (%d).\n", irqnum, cpu);