aboutsummaryrefslogtreecommitdiff
path: root/machine
diff options
context:
space:
mode:
authorLogan Gunthorpe <logang@deltatee.com>2018-11-20 16:36:10 -0700
committerLogan Gunthorpe <logang@deltatee.com>2018-11-20 16:38:38 -0700
commit23de87d808c615dc47620876a7daa112994bf948 (patch)
treef3fa55382e9b52582bc5c260eecaeef095c63e69 /machine
parent7bee30c1ff56975041ffc67cd0170d7477aba865 (diff)
downloadriscv-pk-23de87d808c615dc47620876a7daa112994bf948.zip
riscv-pk-23de87d808c615dc47620876a7daa112994bf948.tar.gz
riscv-pk-23de87d808c615dc47620876a7daa112994bf948.tar.bz2
Fix the calculation for the number of interrupt enable words
The number of interrupt enable words should be the number of devices divided by the number of bits per word (not the number of bytes per word) and it should round up. Without this fix, when using a larger number of interrupts, the user will see a number of errors in qemu of the form: plic: invalid register write: %08x Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Diffstat (limited to 'machine')
-rw-r--r--machine/minit.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/machine/minit.c b/machine/minit.c
index b8c9eac..4eee256 100644
--- a/machine/minit.c
+++ b/machine/minit.c
@@ -129,7 +129,8 @@ static void hart_plic_init()
if (!plic_ndevs)
return;
- size_t ie_words = plic_ndevs / sizeof(uintptr_t) + 1;
+ size_t ie_words = (plic_ndevs + 8 * sizeof(uintptr_t) - 1) /
+ (8 * sizeof(uintptr_t));
for (size_t i = 0; i < ie_words; i++) {
if (HLS()->plic_s_ie) {
// Supervisor not always present