11#ifndef ZEPHYR_INCLUDE_IRQ_MULTILEVEL_H_
12#define ZEPHYR_INCLUDE_IRQ_MULTILEVEL_H_
23#if defined(CONFIG_MULTI_LEVEL_INTERRUPTS) || defined(__DOXYGEN__)
32 uint32_t l1: CONFIG_1ST_LEVEL_INTERRUPT_BITS;
34 uint32_t l2: CONFIG_2ND_LEVEL_INTERRUPT_BITS;
36 uint32_t l3: CONFIG_3RD_LEVEL_INTERRUPT_BITS;
42 uint32_t irq: CONFIG_1ST_LEVEL_INTERRUPT_BITS + CONFIG_2ND_LEVEL_INTERRUPT_BITS;
48 uint32_t irq: CONFIG_1ST_LEVEL_INTERRUPT_BITS;
52BUILD_ASSERT(
sizeof(_z_irq_t) ==
sizeof(
uint32_t),
"Size of `_z_irq_t` must equal to `uint32_t`");
54static inline uint32_t _z_l1_irq(_z_irq_t irq)
59static inline uint32_t _z_l2_irq(_z_irq_t irq)
61 return irq.bits.l2 - 1;
64static inline uint32_t _z_l3_irq(_z_irq_t irq)
66 return irq.bits.l3 - 1;
69static inline unsigned int _z_irq_get_level(_z_irq_t z_irq)
71 if (z_irq.bits.l3 != 0) {
75 if (z_irq.bits.l2 != 0) {
96 return _z_irq_get_level(z_irq);
115 return _z_l2_irq(z_irq);
125#define IRQ_TO_L2(irq) ((irq + 1) << CONFIG_1ST_LEVEL_INTERRUPT_BITS)
168 return _z_l1_irq(z_irq);
188 return _z_l3_irq(z_irq);
198#define IRQ_TO_L3(irq) \
199 ((irq + 1) << (CONFIG_1ST_LEVEL_INTERRUPT_BITS + CONFIG_2ND_LEVEL_INTERRUPT_BITS))
242 return _z_l2_irq(z_irq);
257 }
else if (level == 2) {
259 }
else if (level == 3) {
264 __ASSERT_NO_MSG(
false);
276static inline unsigned int irq_to_level(
unsigned int irq,
unsigned int level)
280 }
else if (level == 2) {
282 }
else if (level == 3) {
287 __ASSERT_NO_MSG(
false);
304 }
else if (level == 2) {
306 }
else if (level == 3) {
311 __ASSERT_NO_MSG(
false);
326 __ASSERT_NO_MSG(level <= 3);
332 return z_irq.l3_intc.irq;
333 }
else if (level == 2) {
334 return z_irq.l2_intc.irq;
354 if (z_irq.bits.l3 != 0) {
355 z_irq.bits.l3 += val;
356 }
else if (z_irq.bits.l2 != 0) {
357 z_irq.bits.l2 += val;
359 z_irq.bits.l1 += val;
static unsigned int irq_from_level(unsigned int irq, unsigned int level)
Return the interrupt number for a given level.
Definition irq_multilevel.h:253
static unsigned int irq_to_level_3(unsigned int irq)
Converts irq from level 1 to level 3 format.
Definition irq_multilevel.h:213
static unsigned int irq_from_level_3(unsigned int irq)
Return the 3rd level interrupt number.
Definition irq_multilevel.h:182
static unsigned int irq_from_level_2(unsigned int irq)
Return the 2nd level interrupt number.
Definition irq_multilevel.h:109
static unsigned int irq_get_level(unsigned int irq)
Return IRQ level This routine returns the interrupt level number of the provided interrupt.
Definition irq_multilevel.h:90
static unsigned int irq_increment(unsigned int irq, unsigned int val)
Increments the multilevel-encoded irq by val.
Definition irq_multilevel.h:348
static unsigned int irq_to_level_2(unsigned int irq)
Converts irq from level 1 to level 2 format.
Definition irq_multilevel.h:139
static unsigned int irq_parent_level(unsigned int irq, unsigned int level)
Returns the parent IRQ of the given level raw IRQ number.
Definition irq_multilevel.h:299
static unsigned int irq_get_intc_irq(unsigned int irq)
Returns the parent interrupt controller IRQ of the given IRQ number.
Definition irq_multilevel.h:322
static unsigned int irq_parent_level_2(unsigned int irq)
Returns the parent IRQ of the level 2 raw IRQ number.
Definition irq_multilevel.h:162
static unsigned int irq_parent_level_3(unsigned int irq)
Returns the parent IRQ of the level 3 raw IRQ number.
Definition irq_multilevel.h:236
static unsigned int irq_to_level(unsigned int irq, unsigned int level)
Converts irq from level 1 to a given level.
Definition irq_multilevel.h:276
__UINT32_TYPE__ uint32_t
Definition stdint.h:90