From 22a79e03a60bed3df7ba24015564c4b48bb811cb Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 24 Nov 2019 18:25:18 +0100 Subject: fixed evt msg get; cleanup --- code/fe310/eos/interrupt.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'code/fe310/eos/interrupt.c') 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) { -- cgit v1.2.3