diff options
author | kstailey <kstailey@cvs.openbsd.org> | 1999-09-14 01:05:26 +0000 |
---|---|---|
committer | kstailey <kstailey@cvs.openbsd.org> | 1999-09-14 01:05:26 +0000 |
commit | f234ea2e1ab44ed800dc636a8a4e16aac89d3f4b (patch) | |
tree | 9a15430d28de19d79afbee41637dd621b0f1e9f3 /sys/arch | |
parent | 34bfe0b0e61bf1ae13f4a08a270a72b4e26db92d (diff) |
signals
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/alpha/alpha/netbsd_machdep.c | 138 | ||||
-rw-r--r-- | sys/arch/alpha/conf/files.alpha | 3 | ||||
-rw-r--r-- | sys/arch/alpha/include/netbsd_machdep.h | 191 |
3 files changed, 180 insertions, 152 deletions
diff --git a/sys/arch/alpha/alpha/netbsd_machdep.c b/sys/arch/alpha/alpha/netbsd_machdep.c new file mode 100644 index 00000000000..2c6272b9119 --- /dev/null +++ b/sys/arch/alpha/alpha/netbsd_machdep.c @@ -0,0 +1,138 @@ +/* $OpenBSD: netbsd_machdep.c,v 1.1 1999/09/14 01:05:24 kstailey Exp $ */ + +/* + * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/signalvar.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/buf.h> +#include <sys/mount.h> +#include <sys/syscallargs.h> +#include <sys/user.h> + +#include <vm/vm.h> + +#include <compat/netbsd/netbsd_signal.h> +#include <compat/netbsd/netbsd_syscallargs.h> + +#include <machine/netbsd_machdep.h> +#include <machine/signal.h> +#include <machine/reg.h> + +#ifdef DEBUG +extern int sigdebug; +extern int sigpid; +#define SDB_FOLLOW 0x01 +#define SDB_KSTACK 0x02 +#endif + +static void netbsd_to_openbsd_sigcontext __P ((struct netbsd_sigcontext *, + struct sigcontext *)); + +static void +netbsd_to_openbsd_sigcontext(nbsc, obsc) + struct netbsd_sigcontext *nbsc; + struct sigcontext *obsc; +{ + memset(obsc, 0, sizeof(obsc)); + obsc->sc_onstack = nbsc->sc_onstack; + memcpy(&obsc->sc_mask, &nbsc->sc_mask.__bits[0], sizeof(sigset_t)); + obsc->sc_pc = nbsc->sc_pc; + obsc->sc_ps = nbsc->sc_ps; + memcpy(obsc->sc_regs, nbsc->sc_regs, sizeof(obsc->sc_regs)); + obsc->sc_ownedfp = nbsc->sc_ownedfp; + memcpy(obsc->sc_fpregs, nbsc->sc_fpregs, sizeof(obsc->sc_fpregs)); + obsc->sc_fpcr = nbsc->sc_fpcr; + obsc->sc_fp_control = nbsc->sc_fp_control; +} + +/* ARGSUSED */ +int +netbsd_sys___sigreturn14(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct netbsd_sys___sigreturn14_args /* { + syscallarg(struct netbsd_sigcontext *) sigcntxp; + } */ *uap = v; + struct netbsd_sigcontext *nbscp; + struct sigcontext *scp, ksc; + extern struct proc *fpcurproc; + + nbscp = SCARG(uap, sigcntxp); + netbsd_to_openbsd_sigcontext(nbscp, scp); +#ifdef DEBUG + if (sigdebug & SDB_FOLLOW) + printf("sigreturn: pid %d, scp %p\n", p->p_pid, scp); +#endif + + if (ALIGN(scp) != (u_int64_t)scp) + return (EINVAL); + + /* + * Test and fetch the context structure. + * We grab it all at once for speed. + */ + if (useracc((caddr_t)scp, sizeof (*scp), B_WRITE) == 0 || + copyin((caddr_t)scp, (caddr_t)&ksc, sizeof ksc)) + return (EINVAL); + + if (ksc.sc_regs[R_ZERO] != 0xACEDBADE) /* magic number */ + return (EINVAL); + /* + * Restore the user-supplied information + */ + if (ksc.sc_onstack) + p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK; + else + p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK; + p->p_sigmask = ksc.sc_mask &~ sigcantmask; + + p->p_md.md_tf->tf_regs[FRAME_PC] = ksc.sc_pc; + p->p_md.md_tf->tf_regs[FRAME_PS] = + (ksc.sc_ps | ALPHA_PSL_USERSET) & ~ALPHA_PSL_USERCLR; + + regtoframe((struct reg *)ksc.sc_regs, p->p_md.md_tf); + alpha_pal_wrusp(ksc.sc_regs[R_SP]); + + /* XXX ksc.sc_ownedfp ? */ + if (p == fpcurproc) + fpcurproc = NULL; + bcopy((struct fpreg *)ksc.sc_fpregs, &p->p_addr->u_pcb.pcb_fp, + sizeof(struct fpreg)); + /* XXX ksc.sc_fp_control ? */ + +#ifdef DEBUG + if (sigdebug & SDB_FOLLOW) + printf("sigreturn(%d): returns\n", p->p_pid); +#endif + return (EJUSTRETURN); +} diff --git a/sys/arch/alpha/conf/files.alpha b/sys/arch/alpha/conf/files.alpha index 0d458e86660..454c60b4f80 100644 --- a/sys/arch/alpha/conf/files.alpha +++ b/sys/arch/alpha/conf/files.alpha @@ -1,4 +1,4 @@ -# $OpenBSD: files.alpha,v 1.28 1999/09/12 14:15:16 kstailey Exp $ +# $OpenBSD: files.alpha,v 1.29 1999/09/14 01:05:24 kstailey Exp $ # $NetBSD: files.alpha,v 1.32 1996/11/25 04:03:21 cgd Exp $ # # alpha-specific configuration info @@ -297,3 +297,4 @@ include "compat/osf1/files.osf1" # NetBSD binary compatibility (COMPAT_NETBSD) include "../../../compat/netbsd/files.netbsd" +file arch/alpha/alpha/netbsd_machdep.c compat_netbsd diff --git a/sys/arch/alpha/include/netbsd_machdep.h b/sys/arch/alpha/include/netbsd_machdep.h index c338e2642d1..2ae9917ec8e 100644 --- a/sys/arch/alpha/include/netbsd_machdep.h +++ b/sys/arch/alpha/include/netbsd_machdep.h @@ -1,164 +1,53 @@ -/* $NetBSD: freebsd_machdep.h,v 1.1 1995/10/10 01:22:35 mycroft Exp $ */ +/* $OpenBSD: netbsd_machdep.h,v 1.2 1999/09/14 01:05:24 kstailey Exp $ */ /* - * Copyright (c) 1986, 1989, 1991, 1993 - * The Regents of the University of California. All rights reserved. + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. * - * This code is derived from software contributed to Berkeley by - * William Jolitz. + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)signal.h 8.1 (Berkeley) 6/11/93 - * from: Id: signal.h,v 1.4 1994/08/21 04:55:30 paul Exp - * - * from: @(#)frame.h 5.2 (Berkeley) 1/18/91 - * from: Id: frame.h,v 1.10 1995/03/16 18:11:42 bde Exp + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. */ -#ifndef _FREEBSD_MACHDEP_H -#define _FREEBSD_MACHDEP_H -/* - * signal support - */ - -struct freebsd_sigcontext { - int sc_onstack; /* sigstack state to restore */ - int sc_mask; /* signal mask to restore */ - int sc_esp; /* machine state */ - int sc_ebp; - int sc_isp; - int sc_eip; - int sc_eflags; - int sc_es; - int sc_ds; - int sc_cs; - int sc_ss; - int sc_edi; - int sc_esi; - int sc_ebx; - int sc_edx; - int sc_ecx; - int sc_eax; -}; - -struct freebsd_sigframe { - int sf_signum; - int sf_code; - struct freebsd_sigcontext *sf_scp; - char *sf_addr; - sig_t sf_handler; - struct freebsd_sigcontext sf_sc; -}; +#ifndef _NETBSD_MACHDEP_H +#define _NETBSD_MACHDEP_H /* - * freebsd_ptrace(2) support + * signal support */ -#define FREEBSD_USRSTACK 0xefbfe000 /* USRSTACK */ -#define FREEBSD_U_AR0_OFFSET 0x0000045c /* offsetof(struct user, u_ar0) */ -#define FREEBSD_U_SAVEFP_OFFSET 0x00000070 - /* offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_savefpu) */ - -/* Exception/Trap Stack Frame */ -struct freebsd_trapframe { - int tf_es; - int tf_ds; - int tf_edi; - int tf_esi; - int tf_ebp; - int tf_isp; - int tf_ebx; - int tf_edx; - int tf_ecx; - int tf_eax; - int tf_trapno; - /* below portion defined in 386 hardware */ - int tf_err; - int tf_eip; - int tf_cs; - int tf_eflags; - /* below only when transitting rings (e.g. user to kernel) */ - int tf_esp; - int tf_ss; +struct netbsd_sigcontext { + long sc_onstack; /* sigstack state to restore */ + long __sc_mask13; /* signal mask to restore (old style) */ + long sc_pc; /* pc to restore */ + long sc_ps; /* ps to restore */ + unsigned long sc_regs[32]; /* integer register set (see above) */ +#define sc_sp sc_regs[R_SP] + long sc_ownedfp; /* fp has been used */ + unsigned long sc_fpregs[32]; /* FP register set (see above) */ + unsigned long sc_fpcr; /* FP control register (see above) */ + unsigned long sc_fp_control; /* FP software control word */ + long sc_reserved[2]; /* XXX */ + long sc_xxx[8]; /* XXX */ + netbsd_sigset_t sc_mask; /* signal mask to restore (new style) */ }; -/* Environment information of floating point unit */ -struct freebsd_env87 { - long en_cw; /* control word (16bits) */ - long en_sw; /* status word (16bits) */ - long en_tw; /* tag word (16bits) */ - long en_fip; /* floating point instruction pointer */ - u_short en_fcs; /* floating code segment selector */ - u_short en_opcode; /* opcode last executed (11 bits ) */ - long en_foo; /* floating operand offset */ - long en_fos; /* floating operand segment selector */ -}; - -/* Contents of each floating point accumulator */ -struct freebsd_fpacc87 { -#ifdef dontdef /* too unportable */ - u_long fp_mantlo; /* mantissa low (31:0) */ - u_long fp_manthi; /* mantissa high (63:32) */ - int fp_exp:15; /* exponent */ - int fp_sgn:1; /* mantissa sign */ -#else - u_char fp_bytes[10]; -#endif -}; - -/* Floating point context */ -struct freebsd_save87 { - struct freebsd_env87 sv_env; /* floating point control/status */ - struct freebsd_fpacc87 sv_ac[8]; /* accumulator contents, 0-7 */ - u_long sv_ex_sw; /* status word for last exception */ - /* - * Bogus padding for emulators. Emulators should use their own - * struct and arrange to store into this struct (ending here) - * before it is inspected for ptracing or for core dumps. Some - * emulators overwrite the whole struct. We have no good way of - * knowing how much padding to leave. Leave just enough for the - * GPL emulator's i387_union (176 bytes total). - */ - u_char sv_pad[64]; /* padding; used by emulators */ -}; - -struct freebsd_ptrace_reg { - struct freebsd_trapframe freebsd_ptrace_regs; - struct freebsd_save87 freebsd_ptrace_fpregs; -}; - -/* sys/i386/include/exec.h */ -#define FREEBSD___LDPGSZ 4096 - -#ifdef _KERNEL -void freebsd_sendsig __P((sig_t, int, int, u_long, int, union sigval)); -#endif - -#endif /* _FREEBSD_MACHDEP_H */ +#endif /* _NETBSD_MACHDEP_H */ |