agra-uni-bremen / riscv-vp

RISC-V Virtual Prototype
MIT License
139 stars 49 forks source link

fu540_plic: fixed off-by-one error for interrupt priorities #23

Closed mschlaegl closed 2 years ago

mschlaegl commented 2 years ago

In next_pending_irq, the interrupt number (interval [1:NUMIRQ]) was used as index to access the interrupt_priorities array (organized as [0:NUMIRQ-1]). As a result, next_pending_irq used the wrong priority for a given interrupt. This fix simply adjusts the index in next_pending_irq.

The problem was discovered while (unsuccessfully) testing slip on linux-vp: Communication on uart1 never triggered a corresponding interrupt (hwirq 4) in the Linux kernel. The reason: When the two uarts are initialized, the Linux kernel enables hwirq 3 and 4 (uart0 and uart1) by setting the corresponding priorities from 0 to 1. With the off-by-one error it in fact enabled hwirq 2 and 3. This explains why uart0(console) was still working, while uart1 was not. With this fix, these issues are resolved and slip networking is working again.

nmeum commented 2 years ago

Thanks a lot! :tada: Pushed to master in da864810d9034ab6c4be2e084ce6511b35676e61.

Glad to hear that you got SLIP working. Let us know if you encounter any additional issues.