diff options
Diffstat (limited to 'code/fe310/eos/interrupt.c')
-rw-r--r-- | code/fe310/eos/interrupt.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/code/fe310/eos/interrupt.c b/code/fe310/eos/interrupt.c index def1a24..77ab6d5 100644 --- a/code/fe310/eos/interrupt.c +++ b/code/fe310/eos/interrupt.c @@ -1,6 +1,4 @@ -#include <stdio.h> #include <stdlib.h> -#include <string.h> #include <stdint.h> #include <unistd.h> @@ -15,15 +13,16 @@ static plic_instance_t plic; static eos_intr_fptr_t ext_interrupt_handler[PLIC_NUM_INTERRUPTS]; -void handle_m_ext_interrupt(void) { - plic_source int_num = PLIC_claim_interrupt(&plic); - if ((int_num >=1 ) && (int_num < PLIC_NUM_INTERRUPTS) && (ext_interrupt_handler[int_num])) { +uintptr_t eos_intr_handle(uintptr_t int_num) { + // plic_source int_num = PLIC_claim_interrupt(&plic); + if ((int_num >=1) && (int_num < PLIC_NUM_INTERRUPTS) && (ext_interrupt_handler[int_num])) { ext_interrupt_handler[int_num](); } else { - printf("handle_m_ext_interrupt error\n\n"); - exit(1 + (uintptr_t) int_num); + write(1, "error\n", 6); + exit(int_num); } - PLIC_complete_interrupt(&plic, int_num); + // PLIC_complete_interrupt(&plic, int_num); + return int_num; } void eos_intr_init(void) { @@ -46,8 +45,24 @@ void eos_intr_init(void) { set_csr(mstatus, MSTATUS_MIE); } -void eos_intr_set_handler(uint8_t int_num, uint8_t priority, eos_intr_fptr_t handler) { +void eos_intr_set(uint8_t int_num, uint8_t priority, eos_intr_fptr_t handler) { ext_interrupt_handler[int_num] = handler; + PLIC_set_priority(&plic, int_num, priority); PLIC_enable_interrupt(&plic, int_num); +} + +void eos_intr_set_priority(uint8_t int_num, uint8_t priority) { PLIC_set_priority(&plic, int_num, priority); } + +void eos_intr_enable(uint8_t int_num) { + PLIC_enable_interrupt(&plic, int_num); +} + +void eos_intr_disable(uint8_t int_num) { + PLIC_disable_interrupt(&plic, int_num); +} + +void eos_intr_mask(uint8_t priority) { + PLIC_set_threshold(&plic, priority); +} |