From 2450a1f910a51362b7ca01555a10ddcc5de18d4b Mon Sep 17 00:00:00 2001 From: Axel Heider Date: Sun, 25 Jul 2021 17:56:00 +0200 Subject: [PATCH] risc-v: initialize active_irq during PLIC init - Initialize all elements active_irq during PLIC init and done't assume implicitly that irqInvalid is zero. - make active_irq hold elements of the type irq_t and not uint32_t. Signed-off-by: Axel Heider --- src/arch/riscv/machine/hardware.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/arch/riscv/machine/hardware.c b/src/arch/riscv/machine/hardware.c index eb86f9b83..bca5c7a64 100644 --- a/src/arch/riscv/machine/hardware.c +++ b/src/arch/riscv/machine/hardware.c @@ -103,7 +103,7 @@ static irq_t getNewActiveIRQ(void) return irqInvalid; } -static uint32_t active_irq[CONFIG_MAX_NUM_NODES] = { irqInvalid }; +static irq_t active_irq[CONFIG_MAX_NUM_NODES]; /** @@ -267,6 +267,15 @@ BOOT_CODE void initIRQController(void) { printf("Initializing PLIC...\n"); + /* Initialize active_irq[] properly to stick to the semantics and play safe. + * Effectively this is not needed if irqInvalid is zero (which is currently + * the case) and the array is in the BSS, that is filled with zeros (which + * the a kernel loader is supposed to do and which the ELF-Loader does). + */ + for (word_t i = 0; i < ARRAY_SIZE(active_irq); i++) { + active_irq[i] = irqInvalid; + } + plic_init_controller(); }