Index: sys/riscv/riscv/plic.c =================================================================== --- sys/riscv/riscv/plic.c +++ sys/riscv/riscv/plic.c @@ -53,10 +53,17 @@ #include "pic_if.h" #define PLIC_MAX_IRQS 1024 + +/* Convert a RISC-V hart to supervisor-mode context. */ +#define HART_TO_CONTEXT_S(h) (2 * (h) + 1) + #define PLIC_PRIORITY(n) (0x000000 + (n) * 0x4) -#define PLIC_ENABLE(n, h) (0x002000 + (h) * 0x80 + 4 * ((n) / 32)) -#define PLIC_THRESHOLD(h) (0x200000 + (h) * 0x1000 + 0x0) -#define PLIC_CLAIM(h) (0x200000 + (h) * 0x1000 + 0x4) +#define PLIC_ENABLE(n, h) \ + (0x002000 + HART_TO_CONTEXT_S(h) * 0x80 + 4 * ((n) / 32)) +#define PLIC_THRESHOLD(h) \ + (0x200000 + HART_TO_CONTEXT_S(h) * 0x1000 + 0x0) +#define PLIC_CLAIM(h) \ + (0x200000 + HART_TO_CONTEXT_S(h) * 0x1000 + 0x4) struct plic_irqsrc { struct intr_irqsrc isrc;