Skip to content

Commit

Permalink
arch: common: multilevel irq: verify interrupt level bits configuration
Browse files Browse the repository at this point in the history
Add `BUILD_ASSERT`s to make sure that the interrupt bits
allocated to each levels are enough to cover the number of
IRQs in each respective level.

Signed-off-by: Yong Cong Sin <[email protected]>
  • Loading branch information
ycsin authored and cfriedt committed Dec 8, 2023
1 parent 2e37da4 commit 9bfe6ef
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions arch/common/multilevel_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include <zephyr/sys/__assert.h>
#include <zephyr/sys/util.h>

BUILD_ASSERT((CONFIG_NUM_2ND_LEVEL_AGGREGATORS * CONFIG_MAX_IRQ_PER_AGGREGATOR) <=
BIT(CONFIG_2ND_LEVEL_INTERRUPT_BITS),
"L2 bits not enough to cover the number of L2 IRQs");

/*
* Insert code if the node_id is an interrupt controller
*/
Expand Down Expand Up @@ -58,6 +62,10 @@ const struct _irq_parent_entry _lvl2_irq_list[CONFIG_NUM_2ND_LEVEL_AGGREGATORS]

#ifdef CONFIG_3RD_LEVEL_INTERRUPTS

BUILD_ASSERT((CONFIG_NUM_3RD_LEVEL_AGGREGATORS * CONFIG_MAX_IRQ_PER_AGGREGATOR) <=
BIT(CONFIG_3RD_LEVEL_INTERRUPT_BITS),
"L3 bits not enough to cover the number of L3 IRQs");

#define CAT_3RD_LVL_LIST(i, base) \
INIT_IRQ_PARENT_OFFSET(INTC_DT_IRQN_GET(CONFIG_3RD_LVL_INTR_0##i##_OFFSET), \
CONFIG_3RD_LVL_INTR_0##i##_OFFSET, IRQ_INDEX_TO_OFFSET(i, base))
Expand Down

0 comments on commit 9bfe6ef

Please sign in to comment.