summaryrefslogtreecommitdiff
path: root/code/fe310/eos/interrupt.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2018-03-14 18:31:22 +0100
committerUros Majstorovic <majstor@majstor.org>2018-03-14 18:31:22 +0100
commit4b655364d426f8429b063d9746c754beca6f7d1f (patch)
tree73afa86876733d81cf0fc331643cb0a6cd036e5e /code/fe310/eos/interrupt.c
parent7e209672e005b911166f27b691acfc6c988e93fb (diff)
fixed concerning new asm trap entry
Diffstat (limited to 'code/fe310/eos/interrupt.c')
-rw-r--r--code/fe310/eos/interrupt.c33
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);
+}