On 12/7/21 10:42 PM, Alistair Francis wrote:
From: Alistair Francis <alistair.fran...@wdc.com>
Signed-off-by: Alistair Francis <alistair.fran...@wdc.com>
Reviewed-by: Bin Meng <bmeng...@gmail.com>
---
hw/intc/sifive_plic.c | 82 +++++++++++++++++--------------------------
1 file changed, 33 insertions(+), 49 deletions(-)
diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c
index 35f097799a..c1fa689868 100644
--- a/hw/intc/sifive_plic.c
+++ b/hw/intc/sifive_plic.c
@@ -33,6 +33,17 @@
#define RISCV_DEBUG_PLIC 0
+static bool addr_between(uint32_t addr, uint32_t base, uint32_t num)
+{
+ uint32_t end = base + num;
+
+ if (addr >= base && addr < end) {
+ return true;
+ }
+
+ return false;
+}
It may well not matter for your use case, but this will fail for addresses at the end of
the range. Better as
return addr >= base && addr - base < num;
r~