Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/pc532 Add kernel portion of siginfo for ns32k.



details:   https://anonhg.NetBSD.org/src/rev/275935dec606
branches:  trunk
changeset: 554978:275935dec606
user:      simonb <simonb%NetBSD.org@localhost>
date:      Thu Nov 06 00:41:20 2003 +0000

description:
Add kernel portion of siginfo for ns32k.

Much thanks to Christos Zoulas for doing this.

diffstat:

 sys/arch/pc532/conf/files.pc532          |    3 +-
 sys/arch/pc532/include/frame.h           |    9 +-
 sys/arch/pc532/include/mcontext.h        |    8 +-
 sys/arch/pc532/include/signal.h          |    9 +-
 sys/arch/pc532/pc532/compat_16_machdep.c |  288 +++++++++++++++++++++++++++++++
 sys/arch/pc532/pc532/locore.s            |   10 +-
 sys/arch/pc532/pc532/machdep.c           |  200 ++++++--------------
 sys/arch/pc532/pc532/trap.c              |   45 +++-
 8 files changed, 420 insertions(+), 152 deletions(-)

diffs (truncated from 805 to 300 lines):

diff -r b81a23cb7020 -r 275935dec606 sys/arch/pc532/conf/files.pc532
--- a/sys/arch/pc532/conf/files.pc532   Thu Nov 06 00:38:36 2003 +0000
+++ b/sys/arch/pc532/conf/files.pc532   Thu Nov 06 00:41:20 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.pc532,v 1.52 2003/10/27 07:26:17 simonb Exp $
+#      $NetBSD: files.pc532,v 1.53 2003/11/06 00:41:20 simonb Exp $
 #
 # new style config file for pc532 architecture
 #
@@ -75,6 +75,7 @@
 # Binary compatibility with previous NetBSD releases.
 #
 file   arch/pc532/pc532/compat_13_machdep.c    compat_13
+file   arch/pc532/pc532/compat_16_machdep.c    compat_16
 
 # egcs-1.1.2 bug fix; see doc/HACKS - egcs-pc532-ip6_mroute
 file   netinet6/ip6_mroute.c           compile-with "${CC_OPT1}"
diff -r b81a23cb7020 -r 275935dec606 sys/arch/pc532/include/frame.h
--- a/sys/arch/pc532/include/frame.h    Thu Nov 06 00:38:36 2003 +0000
+++ b/sys/arch/pc532/include/frame.h    Thu Nov 06 00:41:20 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: frame.h,v 1.10 2003/08/07 16:28:59 agc Exp $   */
+/*     $NetBSD: frame.h,v 1.11 2003/11/06 00:41:20 simonb Exp $        */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -109,4 +109,11 @@
        void*           sa_arg;
 };
 
+#ifdef _KERNEL
+void *getframe(struct lwp *, int, int *);
+#ifdef COMPAT_16
+void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *);
+#endif
+#endif
+
 #endif /* _NS532_FRAME_H_ */
diff -r b81a23cb7020 -r 275935dec606 sys/arch/pc532/include/mcontext.h
--- a/sys/arch/pc532/include/mcontext.h Thu Nov 06 00:38:36 2003 +0000
+++ b/sys/arch/pc532/include/mcontext.h Thu Nov 06 00:41:20 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mcontext.h,v 1.2 2003/10/08 22:43:01 thorpej Exp $     */
+/*     $NetBSD: mcontext.h,v 1.3 2003/11/06 00:41:20 simonb Exp $      */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -71,6 +71,12 @@
        __gregset_t     __gregs;
        __fpregset_t    __fpregs;
 } mcontext_t;
+/*
+ * mcontext extensions to handle signal delivery.
+ */
+#define        _UC_SETSTACK    0x00010000
+#define        _UC_CLRSTACK    0x00020000
+
 
 #define        _UC_MACHINE_SP(uc)      ((uc)->uc_mcontext.__gregs[_REG_SP])
 #define        _UC_MACHINE_PC(uc)      ((uc)->uc_mcontext.__gregs[_REG_PC])
diff -r b81a23cb7020 -r 275935dec606 sys/arch/pc532/include/signal.h
--- a/sys/arch/pc532/include/signal.h   Thu Nov 06 00:38:36 2003 +0000
+++ b/sys/arch/pc532/include/signal.h   Thu Nov 06 00:41:20 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: signal.h,v 1.10 2003/08/07 16:29:00 agc Exp $  */
+/*     $NetBSD: signal.h,v 1.11 2003/11/06 00:41:20 simonb Exp $       */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991 Regents of the University of California.
@@ -38,6 +38,13 @@
 
 typedef int sig_atomic_t;
 
+#define __HAVE_SIGINFO
+#ifdef COMPAT_16
+#define SIGTRAMP_VALID(vers) ((unsigned)(vers) <= 2)
+#else
+#define SIGTRAMP_VALID(vers) ((vers) == 2)
+#endif
+
 #if defined(_NETBSD_SOURCE)
 /*
  * Get the "code" values
diff -r b81a23cb7020 -r 275935dec606 sys/arch/pc532/pc532/compat_16_machdep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/pc532/pc532/compat_16_machdep.c  Thu Nov 06 00:41:20 2003 +0000
@@ -0,0 +1,288 @@
+/*     $NetBSD: compat_16_machdep.c,v 1.1 2003/11/06 00:41:20 simonb Exp $     */
+
+/*-
+ * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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. 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.
+ *
+ *     @(#)machdep.c   7.4 (Berkeley) 6/3/91
+ */
+
+/*-
+ * Copyright (c) 1996 Matthias Pfaller.
+ * Copyright (c) 1993, 1994, 1995 Charles M. Hannum.  All rights reserved.
+ * Copyright (c) 1993 Philip A. Nelson.
+ * Copyright (c) 1992 Terrence R. Lambert.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ *
+ *     @(#)machdep.c   7.4 (Berkeley) 6/3/91
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.1 2003/11/06 00:41:20 simonb Exp $");
+
+#include "opt_ddb.h"
+#include "opt_kgdb.h"
+#include "opt_compat_netbsd.h"
+#include "opt_ns381.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signalvar.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+#include <sys/exec.h>
+#include <sys/buf.h>
+#include <sys/reboot.h>
+#include <sys/conf.h>
+#include <sys/file.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/msgbuf.h>
+#include <sys/mount.h>
+#include <sys/vnode.h>
+#include <sys/device.h>
+#include <sys/sa.h>
+#include <sys/savar.h>
+#include <sys/syscallargs.h>
+#include <sys/core.h>
+#include <sys/kcore.h>
+#include <sys/ucontext.h>
+#include <sys/ksyms.h>
+
+#include <dev/cons.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <sys/sysctl.h>
+
+#include <machine/cpu.h>
+#include <machine/cpufunc.h>
+#include <machine/psl.h>
+#include <machine/fpu.h>
+#include <machine/pmap.h>
+#include <machine/icu.h>
+#include <machine/kcore.h>
+
+#ifdef COMPAT_16
+/*
+ * 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, psl.
+ */
+void
+sendsig_sigcontext(const ksiginfo_t *ksi, const sigset_t *mask)
+{
+       struct lwp *l = curlwp;
+       struct proc *p = l->l_proc;
+       struct sigacts *ps = p->p_sigacts;
+       struct reg *regs;
+       int sig = ksi->ksi_signo;
+       int onstack;
+       struct sigframe *fp = getframe(l, sig, &onstack), frame;
+       sig_t catcher = SIGACTION(p, sig).sa_handler;
+
+       regs = l->l_md.md_regs;
+
+       fp--;
+
+       /* Build stack frame for signal trampoline. */
+       switch (ps->sa_sigdesc[sig].sd_vers) {
+       case 0:
+               frame.sf_ra = (int)p->p_sigctx.ps_sigcode;
+               break;
+
+       case 1:
+               frame.sf_ra = (int)ps->sa_sigdesc[sig].sd_tramp;
+               break;
+
+       default:
+               /* Don't know what trampoline version; kill it. */
+               sigexit(l, SIGILL);
+       }
+       frame.sf_signum = sig;
+       frame.sf_code = ksi->ksi_trap;
+       frame.sf_scp = &fp->sf_sc;
+
+       /* Save the register context. */
+       frame.sf_sc.sc_fp = regs->r_fp;
+       frame.sf_sc.sc_sp = regs->r_sp;
+       frame.sf_sc.sc_pc = regs->r_pc;
+       frame.sf_sc.sc_ps = regs->r_psr;
+       frame.sf_sc.sc_sb = regs->r_sb;
+       frame.sf_sc.sc_reg[REG_R7] = regs->r_r7;
+       frame.sf_sc.sc_reg[REG_R6] = regs->r_r6;
+       frame.sf_sc.sc_reg[REG_R5] = regs->r_r5;
+       frame.sf_sc.sc_reg[REG_R4] = regs->r_r4;
+       frame.sf_sc.sc_reg[REG_R3] = regs->r_r3;
+       frame.sf_sc.sc_reg[REG_R2] = regs->r_r2;
+       frame.sf_sc.sc_reg[REG_R1] = regs->r_r1;
+       frame.sf_sc.sc_reg[REG_R0] = regs->r_r0;
+
+       /* Save signal stack. */
+       frame.sf_sc.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK;
+
+       /* Save the 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(l, SIGILL);
+               /* NOTREACHED */
+       }
+
+       /*
+        * Build context to run handler in.  We invoke the handler
+        * directly, only returning via the trampoline.  Note the
+        * trampoline version numbers are coordinated with machine-
+        * dependent code in libc.



Home | Main Index | Thread Index | Old Index