MCPcopy Create free account
hub / github.com/F-Stack/f-stack / trap

Function trap

freebsd/mips/mips/trap.c:510–1121  ·  view source on GitHub ↗

* Handle an exception. * Called from MipsKernGenException() or MipsUserGenException() * when a processor trap occurs. * In the case of a kernel trap, we return the pc where to resume if * p->p_addr->u_pcb.pcb_onfault is set, otherwise, return old pc. */

Source from the content-addressed store, hash-verified

508 * p->p_addr->u_pcb.pcb_onfault is set, otherwise, return old pc.
509 */
510register_t
511trap(struct trapframe *trapframe)
512{
513 int type, usermode;
514 int i = 0;
515 unsigned ucode = 0;
516 struct thread *td = curthread;
517 struct proc *p = curproc;
518 vm_prot_t ftype;
519 pmap_t pmap;
520 int access_type;
521 ksiginfo_t ksi;
522 char *msg = NULL;
523 intptr_t addr = 0;
524 register_t pc;
525 int cop, error;
526 register_t *frame_regs;
527#ifdef KDB
528 bool handled;
529#endif
530
531 trapdebug_enter(trapframe, 0);
532#ifdef KDB
533 if (kdb_active) {
534 kdb_reenter();
535 return (0);
536 }
537#endif
538 type = (trapframe->cause & MIPS_CR_EXC_CODE) >> MIPS_CR_EXC_CODE_SHIFT;
539 if (TRAPF_USERMODE(trapframe)) {
540 type |= T_USER;
541 usermode = 1;
542 } else {
543 usermode = 0;
544 }
545
546 /*
547 * Enable hardware interrupts if they were on before the trap. If it
548 * was off disable all so we don't accidently enable it when doing a
549 * return to userland.
550 */
551 if (trapframe->sr & MIPS_SR_INT_IE) {
552 set_intr_mask(trapframe->sr & MIPS_SR_INT_MASK);
553 intr_enable();
554 } else {
555 intr_disable();
556 }
557
558#ifdef TRAP_DEBUG
559 if (trap_debug) {
560 static vm_offset_t last_badvaddr = 0;
561 static vm_offset_t this_badvaddr = 0;
562 static int count = 0;
563 u_int32_t pid;
564
565 printf("trap type %x (%s - ", type,
566 trap_type[type & (~T_USER)]);
567

Callers

nothing calls this directly

Calls 15

kdb_reenterFunction · 0.85
set_intr_maskFunction · 0.85
trap_frame_dumpFunction · 0.85
kdb_trapFunction · 0.85
pmap_emulate_modifiedFunction · 0.85
vm_fault_trapFunction · 0.85
log_bad_page_faultFunction · 0.85
emulate_unaligned_accessFunction · 0.85
syscallenterFunction · 0.85
syscallretFunction · 0.85
fuword32Function · 0.85
MipsEmulateBranchFunction · 0.85

Tested by

no test coverage detected