Changeset View
Changeset View
Standalone View
Standalone View
head/sys/riscv/riscv/trap.c
Show First 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | dump_regs(struct trapframe *frame) | ||||
printf("gp == 0x%016lx\n", frame->tf_gp); | printf("gp == 0x%016lx\n", frame->tf_gp); | ||||
printf("tp == 0x%016lx\n", frame->tf_tp); | printf("tp == 0x%016lx\n", frame->tf_tp); | ||||
printf("sepc == 0x%016lx\n", frame->tf_sepc); | printf("sepc == 0x%016lx\n", frame->tf_sepc); | ||||
printf("sstatus == 0x%016lx\n", frame->tf_sstatus); | printf("sstatus == 0x%016lx\n", frame->tf_sstatus); | ||||
} | } | ||||
static void | static void | ||||
svc_handler(struct trapframe *frame) | ecall_handler(struct trapframe *frame) | ||||
{ | { | ||||
struct thread *td; | struct thread *td; | ||||
td = curthread; | td = curthread; | ||||
KASSERT(td->td_frame == frame, | KASSERT(td->td_frame == frame, | ||||
("%s: td_frame %p != frame %p", __func__, td->td_frame, frame)); | ("%s: td_frame %p != frame %p", __func__, td->td_frame, frame)); | ||||
syscallenter(td); | syscallenter(td); | ||||
syscallret(td); | syscallret(td); | ||||
} | } | ||||
static void | static void | ||||
data_abort(struct trapframe *frame, int usermode) | page_fault_handler(struct trapframe *frame, int usermode) | ||||
{ | { | ||||
struct vm_map *map; | struct vm_map *map; | ||||
uint64_t stval; | uint64_t stval; | ||||
struct thread *td; | struct thread *td; | ||||
struct pcb *pcb; | struct pcb *pcb; | ||||
vm_prot_t ftype; | vm_prot_t ftype; | ||||
vm_offset_t va; | vm_offset_t va; | ||||
struct proc *p; | struct proc *p; | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | #endif | ||||
case EXCP_FAULT_LOAD: | case EXCP_FAULT_LOAD: | ||||
case EXCP_FAULT_STORE: | case EXCP_FAULT_STORE: | ||||
case EXCP_FAULT_FETCH: | case EXCP_FAULT_FETCH: | ||||
dump_regs(frame); | dump_regs(frame); | ||||
panic("Memory access exception at 0x%016lx\n", frame->tf_sepc); | panic("Memory access exception at 0x%016lx\n", frame->tf_sepc); | ||||
break; | break; | ||||
case EXCP_STORE_PAGE_FAULT: | case EXCP_STORE_PAGE_FAULT: | ||||
case EXCP_LOAD_PAGE_FAULT: | case EXCP_LOAD_PAGE_FAULT: | ||||
data_abort(frame, 0); | page_fault_handler(frame, 0); | ||||
break; | break; | ||||
case EXCP_BREAKPOINT: | case EXCP_BREAKPOINT: | ||||
#ifdef KDTRACE_HOOKS | #ifdef KDTRACE_HOOKS | ||||
if (dtrace_invop_jump_addr != NULL && | if (dtrace_invop_jump_addr != NULL && | ||||
dtrace_invop_jump_addr(frame) == 0) | dtrace_invop_jump_addr(frame) == 0) | ||||
break; | break; | ||||
#endif | #endif | ||||
#ifdef KDB | #ifdef KDB | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | do_trap_user(struct trapframe *frame) | ||||
case EXCP_FAULT_FETCH: | case EXCP_FAULT_FETCH: | ||||
call_trapsignal(td, SIGBUS, BUS_ADRERR, (void *)frame->tf_sepc, | call_trapsignal(td, SIGBUS, BUS_ADRERR, (void *)frame->tf_sepc, | ||||
exception); | exception); | ||||
userret(td, frame); | userret(td, frame); | ||||
break; | break; | ||||
case EXCP_STORE_PAGE_FAULT: | case EXCP_STORE_PAGE_FAULT: | ||||
case EXCP_LOAD_PAGE_FAULT: | case EXCP_LOAD_PAGE_FAULT: | ||||
case EXCP_INST_PAGE_FAULT: | case EXCP_INST_PAGE_FAULT: | ||||
data_abort(frame, 1); | page_fault_handler(frame, 1); | ||||
break; | break; | ||||
case EXCP_USER_ECALL: | case EXCP_USER_ECALL: | ||||
frame->tf_sepc += 4; /* Next instruction */ | frame->tf_sepc += 4; /* Next instruction */ | ||||
svc_handler(frame); | ecall_handler(frame); | ||||
break; | break; | ||||
case EXCP_ILLEGAL_INSTRUCTION: | case EXCP_ILLEGAL_INSTRUCTION: | ||||
#ifdef FPE | #ifdef FPE | ||||
if ((pcb->pcb_fpflags & PCB_FP_STARTED) == 0) { | if ((pcb->pcb_fpflags & PCB_FP_STARTED) == 0) { | ||||
/* | /* | ||||
* May be a FPE trap. Enable FPE usage | * May be a FPE trap. Enable FPE usage | ||||
* for this thread and try again. | * for this thread and try again. | ||||
*/ | */ | ||||
Show All 22 Lines |