fe310: Only retrieve mepc and mtval on exception
This commit is contained in:
parent
503806cbb3
commit
acf948a296
@ -97,12 +97,8 @@ void external_isr(void)
|
|||||||
/**
|
/**
|
||||||
* @brief Global trap and interrupt handler
|
* @brief Global trap and interrupt handler
|
||||||
*/
|
*/
|
||||||
int handle_trap(unsigned int mcause, unsigned int mepc, unsigned int mtval)
|
int handle_trap(unsigned int mcause)
|
||||||
{
|
{
|
||||||
#ifndef DEVELHELP
|
|
||||||
(void) mepc;
|
|
||||||
(void) mtval;
|
|
||||||
#endif
|
|
||||||
int res = 0;
|
int res = 0;
|
||||||
/* Tell RIOT to set sched_context_switch_request instead of
|
/* Tell RIOT to set sched_context_switch_request instead of
|
||||||
* calling thread_yield(). */
|
* calling thread_yield(). */
|
||||||
@ -139,8 +135,8 @@ int handle_trap(unsigned int mcause, unsigned int mepc, unsigned int mtval)
|
|||||||
#ifdef DEVELHELP
|
#ifdef DEVELHELP
|
||||||
printf("Unhandled trap:\n");
|
printf("Unhandled trap:\n");
|
||||||
printf(" mcause: 0x%08x\n", mcause);
|
printf(" mcause: 0x%08x\n", mcause);
|
||||||
printf(" mepc: 0x%08x\n", mepc);
|
printf(" mepc: 0x%"PRIx32"\n", read_csr(mepc));
|
||||||
printf(" mtval: 0x%08x\n", mtval);
|
printf(" mtval: 0x%"PRIx32"\n", read_csr(mtval));
|
||||||
#endif
|
#endif
|
||||||
/* Unknown trap */
|
/* Unknown trap */
|
||||||
core_panic(PANIC_GENERAL_ERROR, "Unhandled trap");
|
core_panic(PANIC_GENERAL_ERROR, "Unhandled trap");
|
||||||
@ -194,9 +190,7 @@ static void __attribute((aligned(4))) __attribute__((interrupt)) trap_entry(void
|
|||||||
|
|
||||||
/* Get the interrupt cause, PC and trap vector */
|
/* Get the interrupt cause, PC and trap vector */
|
||||||
"csrr a0, mcause \n"
|
"csrr a0, mcause \n"
|
||||||
"csrr a1, mepc \n"
|
/* Call trap handler, a0 contains the return value */
|
||||||
"csrr a2, mtval \n"
|
|
||||||
/* Call trap handler */
|
|
||||||
"call handle_trap \n"
|
"call handle_trap \n"
|
||||||
|
|
||||||
/* Move stack pointer back */
|
/* Move stack pointer back */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user