According to the FU540 manual the PLIC source priority address starts at an offset of 0x04 and not 0x00. The same manual also specifies that the PLIC only has 53 source priorities. Fix these two incorrect header files.
We also need to over extend the plic_gpios[] array as the PLIC sources count from 1 and not 0. Signed-off-by: Alistair Francis <alistair.fran...@wdc.com> --- hw/riscv/sifive_u.c | 2 +- include/hw/riscv/sifive_u.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 5ecc47cea3..88381a7507 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -340,7 +340,7 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp) const struct MemmapEntry *memmap = sifive_u_memmap; MemoryRegion *system_memory = get_system_memory(); MemoryRegion *mask_rom = g_new(MemoryRegion, 1); - qemu_irq plic_gpios[SIFIVE_U_PLIC_NUM_SOURCES]; + qemu_irq plic_gpios[SIFIVE_U_PLIC_NUM_SOURCES + 1]; int i; Error *err = NULL; NICInfo *nd = &nd_table[0]; diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index be13cc1304..d859ea20f6 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -68,9 +68,9 @@ enum { }; #define SIFIVE_U_PLIC_HART_CONFIG "MS" -#define SIFIVE_U_PLIC_NUM_SOURCES 127 +#define SIFIVE_U_PLIC_NUM_SOURCES 53 #define SIFIVE_U_PLIC_NUM_PRIORITIES 7 -#define SIFIVE_U_PLIC_PRIORITY_BASE 0x0 +#define SIFIVE_U_PLIC_PRIORITY_BASE 0x04 #define SIFIVE_U_PLIC_PENDING_BASE 0x1000 #define SIFIVE_U_PLIC_ENABLE_BASE 0x2000 #define SIFIVE_U_PLIC_ENABLE_STRIDE 0x80 -- 2.21.0