summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>1998-10-01 01:03:56 +0000
committerthorpej <thorpej@NetBSD.org>1998-10-01 01:03:56 +0000
commit586b0b3d1bfb7cbcc18ed82f4ab56e05d8abb63b (patch)
tree575888ca4e14b32cd666929dfa3f8447baf69842 /sys
parenta3f5b4f0e7d86a2cfa5a096f935034ab15f185f4 (diff)
Implement compat_13_sys_sigreturn().
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/m68k/conf/files.m68k4
-rw-r--r--sys/arch/m68k/m68k/compat_13_machdep.c137
2 files changed, 140 insertions, 1 deletions
diff --git a/sys/arch/m68k/conf/files.m68k b/sys/arch/m68k/conf/files.m68k
index a2aea413dc2..370b9a1b248 100644
--- a/sys/arch/m68k/conf/files.m68k
+++ b/sys/arch/m68k/conf/files.m68k
@@ -1,4 +1,4 @@
-# $NetBSD: files.m68k,v 1.22 1998/05/24 19:32:42 is Exp $
+# $NetBSD: files.m68k,v 1.23 1998/10/01 01:03:56 thorpej Exp $
#
file arch/m68k/m68k/bcopy.s
file arch/m68k/m68k/copy.s
@@ -16,4 +16,6 @@ file arch/m68k/m68k/process_machdep.c
file arch/m68k/m68k/regdump.c
file arch/m68k/m68k/sig_machdep.c
+file arch/m68k/m68k/compat_13_machdep.c compat_13
+
include "../../../compat/m68k4k/files.m68k4k"
diff --git a/sys/arch/m68k/m68k/compat_13_machdep.c b/sys/arch/m68k/m68k/compat_13_machdep.c
new file mode 100644
index 00000000000..52d4a98121e
--- /dev/null
+++ b/sys/arch/m68k/m68k/compat_13_machdep.c
@@ -0,0 +1,137 @@
+/* $NetBSD: compat_13_machdep.c,v 1.1 1998/10/01 01:03:56 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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: Utah Hdr: machdep.c 1.74 92/12/20
+ * from: @(#)machdep.c 8.10 (Berkeley) 4/20/94
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <machine/cpu.h>
+#include <machine/reg.h>
+
+extern int fputype;
+extern short exframesize[];
+void m68881_restore __P((struct fpframe *));
+
+/*
+ * System call to cleanup state after a signal
+ * has been taken. Reset signal mask and
+ * stack state from context left by sendsig (above).
+ * Return to previous pc and psl as specified by
+ * context left by sendsig. Check carefully to
+ * make sure that the user has not modified the
+ * psl to gain improper priviledges or to cause
+ * a machine fault.
+ */
+int
+compat_13_sys_sigreturn(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_13_sys_sigreturn_args /* {
+ syscallarg(struct sigcontext13 *) sigcntxp;
+ } */ *uap = v;
+ struct sigcontext13 *scp;
+ struct frame *frame;
+ struct sigcontext13 tsigc;
+ sigset_t mask;
+
+ /*
+ * The trampoline code hands us the context.
+ * It is unsafe to keep track of it ourselves, in the event that a
+ * program jumps out of a signal handler.
+ */
+ scp = SCARG(uap, sigcntxp);
+ if ((int)scp & 1)
+ return (EINVAL);
+
+ if (copyin(scp, &tsigc, sizeof(tsigc)) != 0)
+ return (EFAULT);
+ scp = &tsigc;
+
+ /* Make sure the user isn't pulling a fast one on us! */
+ if ((scp->sc_ps & (PSL_MBZ|PSL_IPL|PSL_S)) != 0)
+ return (EINVAL);
+
+ /* Restore register context. */
+ frame = (struct frame *) p->p_md.md_regs;
+
+ /*
+ * We only support restoring the sigcontext13 in this call.
+ * We are not called from the sigcode (per sendsig()), so
+ * we will not have a sigstate to restore.
+ */
+ if (scp->sc_ap != 0)
+ return (EINVAL);
+
+ /*
+ * Restore the user supplied information.
+ * This should be at the last so that the error (EINVAL)
+ * is reported to the sigreturn caller, not to the
+ * jump destination.
+ */
+
+ frame->f_regs[SP] = scp->sc_sp;
+ frame->f_regs[A6] = scp->sc_fp;
+ frame->f_pc = scp->sc_pc;
+ frame->f_sr = scp->sc_ps;
+
+ /* Restore signal stack. */
+ if (scp->sc_onstack & SS_ONSTACK)
+ p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
+ else
+ p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
+
+ /* Restore signal mask. */
+ native_sigset13_to_sigset(&scp->sc_mask, &mask);
+ (void) sigprocmask1(p, SIG_SETMASK, &mask, 0);
+
+ return (EJUSTRETURN);
+}