From 64115be98dda5eae8840e373c85b0c615f196dbb Mon Sep 17 00:00:00 2001 From: Drew Barbier Date: Tue, 25 Jul 2017 16:58:47 -0500 Subject: added vectored interrupt example --- bsp/env/coreplexip-e31-arty/init.c | 13 +++++++++++-- bsp/env/coreplexip-e31-arty/platform.h | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'bsp/env/coreplexip-e31-arty') diff --git a/bsp/env/coreplexip-e31-arty/init.c b/bsp/env/coreplexip-e31-arty/init.c index 84ae09e..888f04f 100644 --- a/bsp/env/coreplexip-e31-arty/init.c +++ b/bsp/env/coreplexip-e31-arty/init.c @@ -10,8 +10,14 @@ #define XSTR(x) #x #define STR(x) XSTR(x) +#ifndef VECT_IRQ + #define TRAP_ENTRY trap_entry +#else + #define TRAP_ENTRY vtrap_entry +#endif + extern int main(int argc, char** argv); -extern void trap_entry(); +extern void TRAP_ENTRY(); static unsigned long get_cpu_freq() { @@ -57,6 +63,7 @@ typedef void (*my_interrupt_function_ptr_t) (void); extern my_interrupt_function_ptr_t localISR[]; #endif +#ifndef VECT_IRQ uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc) { if (0){ @@ -81,6 +88,7 @@ uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc) } return epc; } +#endif void _init() { @@ -89,7 +97,8 @@ void _init() puts("core freq at " STR(CPU_FREQ) " Hz\n"); - write_csr(mtvec, &trap_entry); + write_csr(mtvec, ((unsigned long)&TRAP_ENTRY | MTVEC_VECTORED)); + #endif } diff --git a/bsp/env/coreplexip-e31-arty/platform.h b/bsp/env/coreplexip-e31-arty/platform.h index 42c8887..307a0c6 100644 --- a/bsp/env/coreplexip-e31-arty/platform.h +++ b/bsp/env/coreplexip-e31-arty/platform.h @@ -13,6 +13,11 @@ #define MCAUSE_CAUSE 0x7FFFFFFFFFFFFFFFUL #endif +#ifdef VECT_IRQ + #define MTVEC_VECTORED 0x01 +#else + #define MTVEC_VECTORED 0x00 +#endif #define IRQ_M_LOCAL 16 #define MIP_MLIP(x) (1 << (IRQ_M_LOCAL + x)) -- cgit v1.2.3