-/* $OpenBSD: machdep.c,v 1.15 1997/01/28 09:01:31 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.16 1997/02/02 00:43:20 deraadt Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
* Send an interrupt to process.
*/
void
-sendsig(catcher, sig, mask, code, addr)
+sendsig(catcher, sig, mask, code, type, val)
sig_t catcher;
int sig, mask;
u_long code;
- caddr_t addr;
+ int type;
+ union sigval val;
{
register struct proc *p = curproc;
register struct sigframe *fp, *kfp;
if (psp->ps_siginfo & sigmask(sig)) {
kfp->sf_sip = &kfp->sf_si;
- initsiginfo(kfp->sf_sip, sig);
- fixsiginfo(kfp->sf_sip, sig, code, addr);
- if (sig == SIGSEGV) {
- /* try to be more specific about read or write */
-#if 0
- if (WRFAULT(frame->f_pad))
- kfp->sf_si.si_code |= SEGV_ACCERR;
- else
- kfp->sf_si.si_code |= SEGV_MAPERR;
-#endif
- }
+ initsiginfo(kfp->sf_sip, sig, code, type, val);
}
#ifdef COMPAT_HPUX
return (EJUSTRETURN);
}
-void
-fixsiginfo(si, sig, code, addr)
- siginfo_t *si;
- int sig;
- u_long code;
- caddr_t addr;
-{
- si->si_addr = addr;
-
- switch (code) {
-#if 0
- case T_PRIVINFLT:
- si->si_code = ILL_PRVOPC;
- si->si_trapno = T_PRIVINFLT;
- break;
- case T_BREAKPOINT:
- si->si_code = TRAP_BRKPT;
- si->si_trapno = T_BREAKPOINT;
- break;
- case T_ARITHTRAP:
- si->si_code = FPE_INTOVF;
- si->si_trapno = T_DIVIDE;
- break;
- case T_PROTFLT:
- si->si_code = SEGV_ACCERR;
- si->si_trapno = T_PROTFLT;
- break;
- case T_TRCTRAP:
- si->si_code = TRAP_TRACE;
- si->si_trapno = T_TRCTRAP;
- break;
- case T_PAGEFLT:
- si->si_code = SEGV_ACCERR;
- si->si_trapno = T_PAGEFLT;
- break;
- case T_ALIGNFLT:
- si->si_code = BUS_ADRALN;
- si->si_trapno = T_ALIGNFLT;
- break;
- case T_DIVIDE:
- si->si_code = FPE_FLTDIV;
- si->si_trapno = T_DIVIDE;
- break;
- case T_OFLOW:
- si->si_code = FPE_FLTOVF;
- si->si_trapno = T_DIVIDE;
- break;
- case T_BOUND:
- si->si_code = FPE_FLTSUB;
- si->si_trapno = T_BOUND;
- break;
- case T_DNA:
- si->si_code = FPE_FLTINV;
- si->si_trapno = T_DNA;
- break;
- case T_FPOPFLT:
- si->si_code = FPE_FLTINV;
- si->si_trapno = T_FPOPFLT;
- break;
- case T_SEGNPFLT:
- si->si_code = SEGV_MAPERR;
- si->si_trapno = T_SEGNPFLT;
- break;
- case T_STKFLT:
- si->si_code = ILL_BADSTK;
- si->si_trapno = T_STKFLT;
- break;
-#endif
- }
-}
-
int waittime = -1;
static struct haltvec *halts;
-/* $OpenBSD: trap.c,v 1.9 1997/01/27 22:48:17 deraadt Exp $ */
+/* $OpenBSD: trap.c,v 1.10 1997/02/02 00:43:21 deraadt Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
} else if (sig = writeback(fp, fromtrap)) {
beenhere = 1;
oticks = p->p_sticks;
- trapsignal(p, sig, T_MMUFLT, (caddr_t)faultaddr);
+ trapsignal(p, sig, T_MMUFLT, SEGV_MAPERR, (caddr_t)faultaddr);
goto again;
}
}
register int i;
u_int ucode;
u_quad_t sticks;
+ int typ = 0, bit;
#ifdef COMPAT_HPUX
extern struct emul emul_hpux;
#endif
- int bit;
#ifdef COMPAT_SUNOS
extern struct emul emul_sunos;
#endif
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 */
+ typ = BUS_ADRALN;
ucode = code & ~T_USER;
i = SIGBUS;
break;
p->p_sigmask &= ~i;
i = SIGILL;
ucode = frame.f_format; /* XXX was ILL_RESAD_FAULT */
+ typ = ILL_COPROC;
break;
#ifdef FPCOPROC
case T_COPERR|T_USER: /* user coprocessor violation */
/* What is a proper response here? */
+ typ = FPE_FLTINV;
ucode = 0;
i = SIGFPE;
break;
* 3 bits of the status register are defined as 0 so there is
* no clash.
*/
+ typ = FPE_FLTRES;
ucode = code;
i = SIGFPE;
break;
frame.f_format == 2 ? "instruction" : "data type",
frame.f_pc, frame.f_fmt2.f_iaddr);
/* XXX need to FRESTORE */
+ typ = FPE_FLTINV;
i = SIGFPE;
break;
#endif
case T_ILLINST|T_USER: /* illegal instruction fault */
#ifdef COMPAT_HPUX
if (p->p_emul == &emul_hpux) {
+ typ = 0;
ucode = HPUX_ILL_ILLINST_TRAP;
i = SIGILL;
break;
}
- /* fall through */
#endif
+ ucode = frame.f_format; /* XXX was ILL_PRIVIN_FAULT */
+ typ = ILL_ILLOPC;
+ i = SIGILL;
+ break;
case T_PRIVINST|T_USER: /* privileged instruction fault */
#ifdef COMPAT_HPUX
if (p->p_emul == &emul_hpux)
else
#endif
ucode = frame.f_format; /* XXX was ILL_PRIVIN_FAULT */
+ typ = ILL_PRVOPC;
i = SIGILL;
break;
else
#endif
ucode = frame.f_format; /* XXX was FPE_INTDIV_TRAP */
+ typ = FPE_INTDIV;
i = SIGFPE;
break;
}
#endif
ucode = frame.f_format; /* XXX was FPE_SUBRNG_TRAP */
+ typ = FPE_FLTSUB;
i = SIGFPE;
break;
}
#endif
ucode = frame.f_format; /* XXX was FPE_INTOVF_TRAP */
+ typ = FPE_FLTOVF;
i = SIGFPE;
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 */
}
frame.f_pad = code & 0xffff;
ucode = T_MMUFLT;
+ typ = SEGV_MAPERR;
i = SIGSEGV;
break;
}
}
- trapsignal(p, i, ucode, (caddr_t)v);
+ trapsignal(p, i, ucode, typ, (caddr_t)v);
if ((type & T_USER) == 0)
return;
out: