Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Move sendsig() and sys___sigreturn14() from arm26/a...



details:   https://anonhg.NetBSD.org/src/rev/fd82a24f0342
branches:  trunk
changeset: 503782:fd82a24f0342
user:      bjh21 <bjh21%NetBSD.org@localhost>
date:      Tue Feb 13 13:19:52 2001 +0000

description:
Move sendsig() and sys___sigreturn14() from arm26/arm26/vm_machdep.c and
arm32/arm32/machdep.c into arm/arm/sig_machdep.c, merging and ANSIfying in
the process.

The code is based on the arm32 version, so I don't think anything should break
there.

diffstat:

 sys/arch/arm/arm/sig_machdep.c    |  249 ++++++++++++++++++++++++++++++++++++++
 sys/arch/arm/conf/files.arm       |    3 +-
 sys/arch/arm26/arm26/vm_machdep.c |  156 +-----------------------
 sys/arch/arm32/arm32/machdep.c    |  174 +--------------------------
 4 files changed, 254 insertions(+), 328 deletions(-)

diffs (truncated from 633 to 300 lines):

diff -r a7eab2955436 -r fd82a24f0342 sys/arch/arm/arm/sig_machdep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/arm/sig_machdep.c    Tue Feb 13 13:19:52 2001 +0000
@@ -0,0 +1,249 @@
+/*     $NetBSD: sig_machdep.c,v 1.1 2001/02/13 13:19:52 bjh21 Exp $    */
+
+/*
+ * Copyright (c) 1994-1998 Mark Brinicombe.
+ * Copyright (c) 1994 Brini.
+ * All rights reserved.
+ *
+ * This code is derived from software written for Brini by Mark Brinicombe
+ *
+ * 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 Mark Brinicombe
+ *     for the NetBSD Project.
+ * 4. The name of the company nor the name of the author may be used to
+ *    endorse or promote products derived from this software without specific
+ *    prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ * Machine dependant functions for kernel setup
+ *
+ * Created      : 17/09/94
+ */
+
+#include "opt_compat_netbsd.h"
+
+#include <sys/param.h>
+
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.1 2001/02/13 13:19:52 bjh21 Exp $");
+
+#include <sys/mount.h>         /* XXX only needed by syscallargs.h */
+#include <sys/proc.h>
+#include <sys/signal.h>
+#include <sys/syscallargs.h>
+#include <sys/systm.h>
+#include <sys/user.h>
+
+#ifdef arm26
+#include <arm/armreg.h>
+#endif
+
+#include <machine/cpu.h>
+#include <machine/frame.h>
+#include <machine/pcb.h>
+#ifdef arm32
+#include <machine/cpufunc.h>
+#endif
+
+static __inline struct trapframe *
+process_frame(struct proc *p)
+{
+
+#ifdef arm32
+       return (p->p_md.md_regs);
+#else /* arm26 */
+       return p->p_addr->u_pcb.pcb_tf;
+#endif
+}
+
+/*
+ * Send an interrupt to process.
+ *
+ * Stack is set up to allow sigcode stored
+ * in u. to call routine, followed by kcall
+ * to sigreturn routine below.  After sigreturn
+ * resets the signal mask, the stack, and the
+ * frame pointer, it returns to the user specified pc.
+ */
+void
+sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
+{
+       struct proc *p = curproc;
+       struct trapframe *tf;
+       struct sigframe *fp, frame;
+       int onstack;
+
+       tf = process_frame(p);
+
+       /* Do we need to jump onto the signal stack? */
+       onstack =
+           (p->p_sigctx.ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
+           (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
+
+       /* Allocate space for the signal handler context. */
+       if (onstack)
+               fp = (struct sigframe *)((caddr_t)p->p_sigctx.ps_sigstk.ss_sp +
+                                               p->p_sigctx.ps_sigstk.ss_size);
+       else
+               fp = (struct sigframe *)tf->tf_usr_sp;
+       fp--;
+
+       /* Build stack frame for signal trampoline. */
+       frame.sf_signum = sig;
+       frame.sf_code = code;
+       frame.sf_scp = &fp->sf_sc;
+       frame.sf_handler = catcher;
+
+       /* Save register context. */
+       frame.sf_sc.sc_r0     = tf->tf_r0;
+       frame.sf_sc.sc_r1     = tf->tf_r1;
+       frame.sf_sc.sc_r2     = tf->tf_r2;
+       frame.sf_sc.sc_r3     = tf->tf_r3;
+       frame.sf_sc.sc_r4     = tf->tf_r4;
+       frame.sf_sc.sc_r5     = tf->tf_r5;
+       frame.sf_sc.sc_r6     = tf->tf_r6;
+       frame.sf_sc.sc_r7     = tf->tf_r7;
+       frame.sf_sc.sc_r8     = tf->tf_r8;
+       frame.sf_sc.sc_r9     = tf->tf_r9;
+       frame.sf_sc.sc_r10    = tf->tf_r10;
+       frame.sf_sc.sc_r11    = tf->tf_r11;
+       frame.sf_sc.sc_r12    = tf->tf_r12;
+       frame.sf_sc.sc_usr_sp = tf->tf_usr_sp;
+       frame.sf_sc.sc_usr_lr = tf->tf_usr_lr;
+       frame.sf_sc.sc_svc_lr = tf->tf_svc_lr;
+       frame.sf_sc.sc_pc     = tf->tf_pc;
+       frame.sf_sc.sc_spsr   = tf->tf_spsr;
+
+       /* Save signal stack. */
+       frame.sf_sc.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK;
+
+       /* Save signal mask. */
+       frame.sf_sc.sc_mask = *mask;
+
+#ifdef COMPAT_13
+       /*
+        * XXX We always have to save an old style signal mask because
+        * XXX we might be delivering a signal to a process which will
+        * XXX escape from the signal in a non-standard way and invoke
+        * XXX sigreturn() directly.
+        */
+       native_sigset_to_sigset13(mask, &frame.sf_sc.__sc_mask13);
+#endif
+
+       if (copyout(&frame, fp, sizeof(frame)) != 0) {
+               /*
+                * Process has trashed its stack; give it an illegal
+                * instruction to halt it in its tracks.
+                */
+               sigexit(p, SIGILL);
+               /* NOTREACHED */
+       }
+
+       /*
+        * Build context to run handler in.
+        */
+       tf->tf_r0 = frame.sf_signum;
+       tf->tf_r1 = frame.sf_code;
+       tf->tf_r2 = (int)frame.sf_scp;
+       tf->tf_r3 = (int)frame.sf_handler;
+       tf->tf_usr_sp = (int)fp;
+       tf->tf_pc = (int)p->p_sigctx.ps_sigcode;
+#ifdef arm32
+       cpu_cache_syncI();
+#endif
+
+       /* Remember that we're now on the signal stack. */
+       if (onstack)
+               p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK;
+}
+
+
+/*
+ * 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
+ * psr to gain improper privileges or to cause
+ * a machine fault.
+ */
+int
+sys___sigreturn14(struct proc *p, void *v, register_t *retval)
+{
+       struct sys___sigreturn14_args /* {
+               syscallarg(struct sigcontext *) sigcntxp;
+       } */ *uap = v;
+       struct sigcontext *scp, context;
+       struct trapframe *tf;
+
+       /*
+        * 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 (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0)
+               return (EFAULT);
+
+       /* Make sure the processor mode has not been tampered with. */
+#ifdef arm32
+       if ((context.sc_spsr & PSR_MODE) != PSR_USR32_MODE)
+               return (EINVAL);
+#else /* arm26 */
+       if ((context.sc_pc & R15_MODE) != R15_MODE_USR ||
+           (context.sc_pc & (R15_IRQ_DISABLE | R15_FIQ_DISABLE)) != 0)
+               return EINVAL;
+#endif
+
+       /* Restore register context. */
+       tf = process_frame(p);
+       tf->tf_r0    = context.sc_r0;
+       tf->tf_r1    = context.sc_r1;
+       tf->tf_r2    = context.sc_r2;
+       tf->tf_r3    = context.sc_r3;
+       tf->tf_r4    = context.sc_r4;
+       tf->tf_r5    = context.sc_r5;
+       tf->tf_r6    = context.sc_r6;
+       tf->tf_r7    = context.sc_r7;
+       tf->tf_r8    = context.sc_r8;
+       tf->tf_r9    = context.sc_r9;
+       tf->tf_r10   = context.sc_r10;
+       tf->tf_r11   = context.sc_r11;
+       tf->tf_r12   = context.sc_r12;
+       tf->tf_usr_sp = context.sc_usr_sp;
+       tf->tf_usr_lr = context.sc_usr_lr;
+       tf->tf_svc_lr = context.sc_svc_lr;
+       tf->tf_pc    = context.sc_pc;
+       tf->tf_spsr  = context.sc_spsr;
+
+       /* Restore signal stack. */
+       if (context.sc_onstack & SS_ONSTACK)
+               p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK;
+       else
+               p->p_sigctx.ps_sigstk.ss_flags &= ~SS_ONSTACK;
+
+       /* Restore signal mask. */
+       (void) sigprocmask1(p, SIG_SETMASK, &context.sc_mask, 0);
+
+       return (EJUSTRETURN);
+}
diff -r a7eab2955436 -r fd82a24f0342 sys/arch/arm/conf/files.arm
--- a/sys/arch/arm/conf/files.arm       Tue Feb 13 13:16:37 2001 +0000
+++ b/sys/arch/arm/conf/files.arm       Tue Feb 13 13:19:52 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.arm,v 1.6 2001/02/11 17:03:05 bjh21 Exp $
+#      $NetBSD: files.arm,v 1.7 2001/02/13 13:19:52 bjh21 Exp $
 
 file   arch/arm/arm/in_cksum_arm.c             inet
 file   netinet/in4_cksum.c                     inet
@@ -11,4 +11,5 @@
 file   arch/arm/arm/disassem.c
 
 file   arch/arm/arm/process_machdep.c
+file   arch/arm/arm/sig_machdep.c
 file   arch/arm/arm/sigcode.S
diff -r a7eab2955436 -r fd82a24f0342 sys/arch/arm26/arm26/vm_machdep.c
--- a/sys/arch/arm26/arm26/vm_machdep.c Tue Feb 13 13:16:37 2001 +0000
+++ b/sys/arch/arm26/arm26/vm_machdep.c Tue Feb 13 13:19:52 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.11 2001/01/22 22:10:44 bjh21 Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.12 2001/02/13 13:19:52 bjh21 Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001 Ben Harris
@@ -66,7 +66,7 @@
 
 #include <sys/param.h>
 
-__RCSID("$NetBSD: vm_machdep.c,v 1.11 2001/01/22 22:10:44 bjh21 Exp $");
+__RCSID("$NetBSD: vm_machdep.c,v 1.12 2001/02/13 13:19:52 bjh21 Exp $");
 
 #include <sys/buf.h>
 #include <sys/exec.h>
@@ -179,158 +179,6 @@
        /* Nothing left for us to free... */
 }
 
-
-/*
- * Send an interrupt to process.
- *
- * Stack is set up to allow sigcode stored in u. to call routine,
- * followed by kcall to sigreturn routine below.  After sigreturn
- * resets the signal mask, the stack, and the frame pointer, it
- * returns to the user specified pc.
- */
-void



Home | Main Index | Thread Index | Old Index