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;
35#if defined(CONFIG_3RD_LEVEL_INTERRUPTS) || defined(__DOXYGEN__)
37 uint32_t l3: CONFIG_3RD_LEVEL_INTERRUPT_BITS;
41#if defined(CONFIG_3RD_LEVEL_INTERRUPTS) || defined(__DOXYGEN__)
45 uint32_t irq: CONFIG_1ST_LEVEL_INTERRUPT_BITS + CONFIG_2ND_LEVEL_INTERRUPT_BITS;
52 uint32_t irq: CONFIG_1ST_LEVEL_INTERRUPT_BITS;
56BUILD_ASSERT(
sizeof(_z_irq_t) ==
sizeof(
uint32_t),
"Size of `_z_irq_t` must equal to `uint32_t`");
58static inline uint32_t _z_l1_irq(_z_irq_t irq)
63static inline uint32_t _z_l2_irq(_z_irq_t irq)
65 return irq.bits.l2 - 1;
68#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
69static inline uint32_t _z_l3_irq(_z_irq_t irq)
71 return irq.bits.l3 - 1;
75static inline unsigned int _z_irq_get_level(_z_irq_t z_irq)
77#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
78 if (z_irq.bits.l3 != 0) {
83 if (z_irq.bits.l2 != 0) {
104 return _z_irq_get_level(z_irq);
123 return _z_l2_irq(z_irq);
133#define IRQ_TO_L2(irq) ((irq + 1) << CONFIG_1ST_LEVEL_INTERRUPT_BITS)
153#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
178 return _z_l1_irq(z_irq);
181#if defined(CONFIG_3RD_LEVEL_INTERRUPTS) || defined(__DOXYGEN__)
199 return _z_l3_irq(z_irq);
209#define IRQ_TO_L3(irq) \
210 ((irq + 1) << (CONFIG_1ST_LEVEL_INTERRUPT_BITS + CONFIG_2ND_LEVEL_INTERRUPT_BITS))
253 return _z_l2_irq(z_irq);
269 }
else if (level == 2) {
272#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
273 else if (level == 3) {
279 __ASSERT_NO_MSG(
false);
291static inline unsigned int irq_to_level(
unsigned int irq,
unsigned int level)
295 }
else if (level == 2) {
298#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
299 else if (level == 3) {
305 __ASSERT_NO_MSG(
false);
322 }
else if (level == 2) {
325#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
326 else if (level == 3) {
332 __ASSERT_NO_MSG(
false);
350#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
351 __ASSERT_NO_MSG(level <= 3);
353 return z_irq.l3_intc.irq;
356 __ASSERT_NO_MSG(level <= 2);
360 return z_irq.l2_intc.irq;
382#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
383 }
else if (z_irq.bits.l3 != 0) {
384 z_irq.bits.l3 += val;
386 }
else if (z_irq.bits.l2 != 0) {
387 z_irq.bits.l2 += val;
389 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:265
static unsigned int irq_to_level_3(unsigned int irq)
Converts irq from level 1 to level 3 format.
Definition irq_multilevel.h:224
static unsigned int irq_from_level_3(unsigned int irq)
Return the 3rd level interrupt number.
Definition irq_multilevel.h:193
static unsigned int irq_from_level_2(unsigned int irq)
Return the 2nd level interrupt number.
Definition irq_multilevel.h:117
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:98
static unsigned int irq_increment(unsigned int irq, unsigned int val)
Increments the multilevel-encoded irq by val.
Definition irq_multilevel.h:374
static unsigned int irq_to_level_2(unsigned int irq)
Converts irq from level 1 to level 2 format.
Definition irq_multilevel.h:147
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:317
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:343
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:172
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:247
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:291
__UINT32_TYPE__ uint32_t
Definition stdint.h:90