1 //See LICENSE for license details.
2 #include <stdint.h>
3 #include <stdio.h>
4 #include <unistd.h>
5 #include "riscv_encoding.h"
6 #include "n200_func.h"
7 
handle_nmi()8 __attribute__((weak)) uintptr_t handle_nmi()
9 {
10   write(1, "nmi\n", 5);
11   _exit(1);
12   return 0;
13 }
14 
15 
handle_trap(uintptr_t mcause,uintptr_t sp)16 __attribute__((weak)) uintptr_t handle_trap(uintptr_t mcause, uintptr_t sp)
17 {
18   if((mcause & 0xFFF) == 0xFFF) {
19       handle_nmi();
20   }
21   write(1, "trap\n", 5);
22   //printf("In trap handler, the mcause is %d\n", mcause);
23   //printf("In trap handler, the mepc is 0x%x\n", read_csr(mepc));
24   //printf("In trap handler, the mtval is 0x%x\n", read_csr(mbadaddr));
25   _exit(mcause);
26   return 0;
27 }
28 
29 
30 
31 
32 
33