-/* $OpenBSD: locore.s,v 1.17 1997/02/10 12:01:45 downsj Exp $ */
+/* $OpenBSD: locore.s,v 1.18 1997/02/21 05:49:28 briggs Exp $ */
/* $NetBSD: locore.s,v 1.73 1997/01/09 07:28:12 scottr Exp $ */
/*
* Stack looks like:
*
* sp+0 -> signal number
- * sp+4 signal specific code
+ * sp+4 pointer to siginfo (sip)
* sp+8 pointer to signal context frame (scp)
* sp+12 address of handler
* sp+16 saved hardware state
trap #0 | exit(errno) (2 bytes)
.align 2
_esigcode:
+ .text
/*
* Primitives
-/* $OpenBSD: machdep.c,v 1.27 1997/01/24 01:35:48 briggs Exp $ */
+/* $OpenBSD: machdep.c,v 1.28 1997/02/21 05:49:29 briggs Exp $ */
/* $NetBSD: machdep.c,v 1.129 1997/01/09 07:20:46 scottr Exp $ */
/*
*/
struct sigframe {
int sf_signum; /* signo for handler */
- int sf_code; /* additional info for handler */
+ siginfo_t *sf_sip;
struct sigcontext *sf_scp; /* context ptr for handler */
sig_t sf_handler; /* handler addr for u_sigc */
struct sigstate sf_state; /* state of the hardware */
struct sigcontext sf_sc;/* actual context */
+ siginfo_t sf_si;
};
#ifdef DEBUG
int sigdebug = 0x0;
* Send an interrupt to process.
*/
void
-sendsig(catcher, sig, mask, code)
+sendsig(catcher, sig, mask, code, type, val)
sig_t catcher;
int sig, mask;
u_long code;
+ int type;
+ union sigval val;
{
extern short exframesize[];
extern char sigcode[], esigcode[];
kfp = malloc(sizeof(struct sigframe), M_TEMP, M_WAITOK);
/* Build the argument list for the signal handler. */
kfp->sf_signum = sig;
- kfp->sf_code = code;
+ kfp->sf_sip = NULL;
kfp->sf_scp = &fp->sf_sc;
kfp->sf_handler = catcher;
+
/*
* Save necessary hardware state. Currently this includes:
* - general registers
kfp->sf_sc.sc_ap = (int) &fp->sf_state;
kfp->sf_sc.sc_pc = frame->f_pc;
kfp->sf_sc.sc_ps = frame->f_sr;
+
+ if (psp->ps_siginfo & sigmask(sig)) {
+ kfp->sf_sip = &fp->sf_si;
+ initsiginfo(&kfp->sf_si, sig, code, type, val);
+ }
+
+ /* XXX For perf., do not copy out siginfo if not needed */
(void) copyout((caddr_t) kfp, (caddr_t) fp, sizeof(struct sigframe));
frame->f_regs[SP] = (int) fp;
#ifdef DEBUG
if (howto & RB_HALT) {
printf("halted\n\n");
via_shutdown();
+#ifdef HWDIRECT /* adb_poweroff is available only when
+ * the HWDIRECT ADB method is used. */
+ adb_poweroff(); /* Shut down machines whose power functions
+ * are accessed via modified ADB calls. */
+#endif
} else {
if (howto & RB_DUMP) {
savectx(&dumppcb);
-/* $OpenBSD: trap.c,v 1.7 1997/01/24 01:35:53 briggs Exp $ */
+/* $OpenBSD: trap.c,v 1.8 1997/02/21 05:49:30 briggs Exp $ */
/* $NetBSD: trap.c,v 1.45 1997/01/20 04:30:05 scottr Exp $ */
/*
} else if ((sig = writeback(fp, fromtrap))) {
beenhere = 1;
oticks = p->p_sticks;
- trapsignal(p, sig, faultaddr);
+ trapsignal(p, sig, VM_PROT_WRITE, SEGV_MAPERR,
+ (caddr_t)faultaddr);
goto again;
}
}
register struct proc *p;
register int i;
u_int ucode;
+ int typ = 0;
u_quad_t sticks;
cnt.v_trap++;
return;
case T_BUSERR|T_USER: /* Bus error */
+ typ = BUS_OBJERR;
+ ucode = code & ~T_USER;
+ i = SIGBUS;
+ break;
case T_ADDRERR|T_USER: /* Address error */
- ucode = v;
+ typ = BUS_ADRALN;
+ ucode = code & ~T_USER;
i = SIGBUS;
break;
case T_ILLINST|T_USER: /* Illegal instruction fault */
+ ucode = frame.f_format; /* XXX was ILL_PRIVIN_FAULT */
+ typ = ILL_ILLOPC;
+ i = SIGILL;
+ v = frame.f_pc;
+ break;
+
case T_PRIVINST|T_USER: /* Privileged instruction fault */
ucode = frame.f_format; /* XXX was ILL_PRIVIN_FAULT */
+ typ = ILL_PRVOPC;
i = SIGILL;
+ v = frame.f_pc;
break;
/*
* divde by zero, CHK/TRAPV inst
*/
case T_ZERODIV|T_USER: /* Divide by zero trap */
+ ucode = frame.f_format;
+ type = FPE_INTDIV;
+ i = SIGFPE;
+ v = frame.f_pc;
+ break;
+
case T_CHKINST|T_USER: /* CHK instruction trap */
- case T_TRAPVINST|T_USER: /* TRAPV instruction trap */
ucode = frame.f_format;
+ type = FPE_FLTSUB;
i = SIGFPE;
+ v = frame.f_pc;
+ break;
+
+ case T_TRAPVINST|T_USER: /* TRAPV instruction trap */
+ ucode = frame.f_format;
+ type = ILL_ILLTRP;
+ i = SIGILL;
+ v = frame.f_pc;
break;
/*
* User coprocessor violation
*/
case T_COPERR|T_USER:
+ typ = FPE_FLTINV;
ucode = 0;
i = SIGFPE; /* XXX What is a proper response here? */
break;
* 3 bits of the status register are defined as 0 so
* there is no clash.
*/
+ typ = FPE_FLTRES;
ucode = code;
i = SIGFPE;
+ v = frame.f_pc;
break;
/*
p->p_pid);
i = SIGILL;
#endif
+ typ = FPE_FLTINV;
+ v = frame.f_pc;
break;
case T_COPERR: /* Kernel coprocessor violation */
p->p_sigmask &= ~i;
i = SIGILL;
ucode = frame.f_format; /* XXX was ILL_RESAD_FAULT */
+ typ = ILL_COPROC;
+ v = frame.f_pc;
break;
/*
#endif
frame.f_sr &= ~PSL_T;
i = SIGTRAP;
+ typ = TRAP_TRACE;
break;
case T_TRACE|T_USER: /* user trace trap */
#endif
frame.f_sr &= ~PSL_T;
i = SIGTRAP;
+ typ = TRAP_TRACE;
break;
case T_ASTFLT: /* System async trap, cannot happen */
register struct vmspace *vm = p->p_vmspace;
register vm_map_t map;
int rv;
- vm_prot_t ftype;
+ vm_prot_t ftype, vftype;
extern vm_map_t kernel_map;
#ifdef DEBUG
map = kernel_map;
else
map = vm ? &vm->vm_map : kernel_map;
- if (WRFAULT(code))
+ if (WRFAULT(code)) {
+ vftype = VM_PROT_WRITE;
ftype = VM_PROT_READ | VM_PROT_WRITE;
- else
- ftype = VM_PROT_READ;
+ } else
+ vftype = ftype = VM_PROT_READ;
va = trunc_page((vm_offset_t) v);
#ifdef DEBUG
if (map == kernel_map && va == 0) {
type, code);
goto dopanic;
}
- ucode = v;
+ frame.f_pad = code & 0xffff;
+ ucode = vftype;
+ typ = SEGV_MAPERR;
i = SIGSEGV;
break;
}
}
if (i)
- trapsignal(p, i, ucode);
+ trapsignal(p, i, ucode, typ, (caddr_t) v);
if ((type & T_USER) == 0)
return;
out: