Skip to content

Commit

Permalink
[rte] check if handler address != 0
Browse files Browse the repository at this point in the history
  • Loading branch information
stnolting committed Jan 16, 2025
1 parent 3ef2a38 commit 00c7b4e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions sw/lib/source/neorv32_rte.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ void __attribute__((__naked__,aligned(4))) neorv32_rte_core(void) {
}

// call handler
typedef void handler_t();
handler_t* handler = (handler_t*)handler_base;
handler();
if (handler_base != 0) {
typedef void handler_t();
handler_t* handler = (handler_t*)handler_base;
handler();
}

// compute return address (for exceptions only)
// do not alter return address if instruction access exception (fatal?)
Expand Down Expand Up @@ -319,20 +321,20 @@ void neorv32_rte_debug_handler(void) {
// intro
neorv32_uart0_puts("<NEORV32-RTE> ");

// core ID
// CPU ID
if (neorv32_cpu_csr_read(CSR_MHARTID) & 1) {
neorv32_uart0_puts("[cpu1] ");
neorv32_uart0_puts("[cpu1|");
}
else {
neorv32_uart0_puts("[cpu0] ");
neorv32_uart0_puts("[cpu0|");
}

// privilege level of the CPU when the trap occurred
if (neorv32_cpu_csr_read(CSR_MSTATUS) & (3 << CSR_MSTATUS_MPP_L)) {
neorv32_uart0_puts("[M] "); // machine-mode
neorv32_uart0_puts("M] "); // machine-mode
}
else {
neorv32_uart0_puts("[U] "); // user-mode
neorv32_uart0_puts("U] "); // user-mode
}

// cause
Expand Down

0 comments on commit 00c7b4e

Please sign in to comment.