diff options
Diffstat (limited to 'code/fe310/eos/interrupt.c')
-rw-r--r-- | code/fe310/eos/interrupt.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/code/fe310/eos/interrupt.c b/code/fe310/eos/interrupt.c index 0172fb8..cb513a0 100644 --- a/code/fe310/eos/interrupt.c +++ b/code/fe310/eos/interrupt.c @@ -4,7 +4,7 @@ #include "encoding.h" #include "platform.h" -#include "plic/plic_driver.h" +#include "plic_driver.h" #include "interrupt.h" @@ -15,8 +15,8 @@ static plic_instance_t plic; static eos_intr_fptr_t ext_interrupt_handler[PLIC_NUM_INTERRUPTS]; uintptr_t eos_intr_handle(uintptr_t int_num) { - if ((int_num >=1) && (int_num < PLIC_NUM_INTERRUPTS) && (ext_interrupt_handler[int_num])) { - ext_interrupt_handler[int_num](); + if ((int_num >=1) && (int_num <= PLIC_NUM_INTERRUPTS) && (ext_interrupt_handler[int_num-1])) { + ext_interrupt_handler[int_num-1](); } else { write(1, "error\n", 6); exit(int_num); @@ -24,12 +24,6 @@ uintptr_t eos_intr_handle(uintptr_t int_num) { return int_num; } -void handle_m_ext_interrupt(void) { - plic_source int_num = PLIC_claim_interrupt(&plic); - eos_intr_handle(int_num); - PLIC_complete_interrupt(&plic, int_num); -} - void eos_intr_init(void) { for (int i = 0; i < PLIC_NUM_INTERRUPTS; i++){ ext_interrupt_handler[i] = NULL; @@ -51,13 +45,13 @@ void eos_intr_init(void) { } void eos_intr_set(uint8_t int_num, uint8_t priority, eos_intr_fptr_t handler) { - ext_interrupt_handler[int_num] = handler; + ext_interrupt_handler[int_num-1] = handler; PLIC_set_priority(&plic, int_num, priority); PLIC_enable_interrupt(&plic, int_num); } void eos_intr_set_handler(uint8_t int_num, eos_intr_fptr_t handler) { - ext_interrupt_handler[int_num] = handler; + ext_interrupt_handler[int_num-1] = handler; } void eos_intr_set_priority(uint8_t int_num, uint8_t priority) { |