7 #include <arch/exception.h>
15 "Instruction address misaligned",
16 "Instruction access fault",
17 "Illegal instruction",
19 "Load address misaligned",
21 "Store address misaligned",
23 "Environment call from U-mode",
24 "Environment call from S-mode",
26 "Environment call from M-mode",
27 "Instruction page fault",
36 case 0x00000000:
return "user";
37 case 0x00000800:
return "supervisor";
38 case 0x00001000:
return "hypervisor";
39 case 0x00001800:
return "machine";
47 const char *previous_mode;
49 int hart_id = read_csr(mhartid);
64 previous_mode, mprv?
" (MPRV)":
"");
92 asm volatile(
"fence.i");
94 asm volatile(
"sfence.vma");
96 asm volatile(
"sfence.vma");
113 write_csr(mscratch, tf);
114 if (tf->
cause & 0x8000000000000000ULL) {
147 die(
"Can't recover from trap. Halting.\n");
153 write_csr(sbadaddr, read_csr(mbadaddr));
154 write_csr(sepc, read_csr(mepc));
155 write_csr(scause, read_csr(mcause));
156 write_csr(mepc, read_csr(stvec));
162 write_csr(mstatus, status);
#define printk(level,...)
void __noreturn die(const char *fmt,...)
#define CAUSE_ILLEGAL_INSTRUCTION
#define CAUSE_MISALIGNED_LOAD
#define CAUSE_MACHINE_ECALL
#define CAUSE_STORE_ACCESS
#define CAUSE_HYPERVISOR_ECALL
#define CAUSE_MISALIGNED_FETCH
#define CAUSE_LOAD_ACCESS
#define CAUSE_FETCH_ACCESS
#define CAUSE_SUPERVISOR_ECALL
#define CAUSE_MISALIGNED_STORE
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_EMERG
BIOS_EMERG - Emergency / Fatal.
void handle_misaligned(trapframe *tf)
void handle_sbi(trapframe *tf)
#define IPI_SFENCE_VMA_ASID
unsigned long long uint64_t
void trap_handler(trapframe *tf)
static const char *const exception_names[]
static const char * mstatus_to_previous_mode(uintptr_t ms)
static void interrupt_handler(trapframe *tf)
static void print_trap_information(const trapframe *tf)
#define INSERT_FIELD(val, which, fieldval)
#define EXTRACT_FIELD(val, which)