Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/irix Added IRIX signal delivery
details: https://anonhg.NetBSD.org/src/rev/c1b725e096ca
branches: trunk
changeset: 518948:c1b725e096ca
user: manu <manu%NetBSD.org@localhost>
date: Sat Dec 08 11:17:37 2001 +0000
description:
Added IRIX signal delivery
diffstat:
sys/compat/irix/files.irix | 3 +-
sys/compat/irix/irix_exec.c | 14 +-
sys/compat/irix/irix_prctl.c | 6 +-
sys/compat/irix/irix_signal.c | 284 +++++++++++++++++++++++++++++++++++++
sys/compat/irix/irix_signal.h | 82 ++++++++++
sys/compat/irix/irix_syscall.h | 22 ++-
sys/compat/irix/irix_syscallargs.h | 39 ++++-
sys/compat/irix/irix_syscalls.c | 18 +-
sys/compat/irix/irix_sysent.c | 30 +-
sys/compat/irix/irix_sysmp.c | 5 +-
sys/compat/irix/irix_syssgi.c | 55 ++++++-
sys/compat/irix/irix_syssgi.h | 106 +++++++++++++-
sys/compat/irix/irix_types.h | 10 +-
sys/compat/irix/syscalls.master | 20 +-
14 files changed, 640 insertions(+), 54 deletions(-)
diffs (truncated from 1056 to 300 lines):
diff -r 0503f2a19e8a -r c1b725e096ca sys/compat/irix/files.irix
--- a/sys/compat/irix/files.irix Sat Dec 08 11:15:43 2001 +0000
+++ b/sys/compat/irix/files.irix Sat Dec 08 11:17:37 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.irix,v 1.6 2001/12/02 16:16:57 manu Exp $
+# $NetBSD: files.irix,v 1.7 2001/12/08 11:17:37 manu Exp $
#
file arch/mips/mips/irix_syscall.c compat_irix
@@ -7,6 +7,7 @@
file compat/irix/irix_exec.c compat_irix
file compat/irix/irix_exec_elf32.c compat_irix & exec_elf32
file compat/irix/irix_prctl.c compat_irix
+file compat/irix/irix_signal.c compat_irix
file compat/irix/irix_sysent.c compat_irix
file compat/irix/irix_syssgi.c compat_irix
file compat/irix/irix_sysmp.c compat_irix
diff -r 0503f2a19e8a -r c1b725e096ca sys/compat/irix/irix_exec.c
--- a/sys/compat/irix/irix_exec.c Sat Dec 08 11:15:43 2001 +0000
+++ b/sys/compat/irix/irix_exec.c Sat Dec 08 11:17:37 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_exec.c,v 1.6 2001/12/04 22:13:41 manu Exp $ */
+/* $NetBSD: irix_exec.c,v 1.7 2001/12/08 11:17:37 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_exec.c,v 1.6 2001/12/04 22:13:41 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_exec.c,v 1.7 2001/12/08 11:17:37 manu Exp $");
#ifndef ELFSIZE
#define ELFSIZE 32 /* XXX should die */
@@ -55,13 +55,15 @@
#include <compat/irix/irix_syscall.h>
#include <compat/irix/irix_types.h>
#include <compat/irix/irix_exec.h>
+#include <compat/irix/irix_signal.h>
#include <compat/irix/irix_errno.h>
static int ELFNAME2(irix,mipsopt_signature) __P((struct proc *,
struct exec_package *epp, Elf_Ehdr *eh));
-extern char sigcode[], esigcode[];
extern struct sysent irix_sysent[];
+extern const char * const irix_syscallnames[];
+extern char irix_sigcode[], irix_esigcode[];
#ifndef __HAVE_SYSCALL_INTERN
void irix_syscall __P((void));
@@ -84,10 +86,10 @@
#else
NULL,
#endif
- sendsig,
+ irix_sendsig,
trapsignal,
- sigcode,
- esigcode,
+ irix_sigcode,
+ irix_esigcode,
setregs,
NULL,
NULL,
diff -r 0503f2a19e8a -r c1b725e096ca sys/compat/irix/irix_prctl.c
--- a/sys/compat/irix/irix_prctl.c Sat Dec 08 11:15:43 2001 +0000
+++ b/sys/compat/irix/irix_prctl.c Sat Dec 08 11:17:37 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_prctl.c,v 1.2 2001/12/02 18:06:59 manu Exp $ */
+/* $NetBSD: irix_prctl.c,v 1.3 2001/12/08 11:17:37 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,14 +37,16 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_prctl.c,v 1.2 2001/12/02 18:06:59 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_prctl.c,v 1.3 2001/12/08 11:17:37 manu Exp $");
#include <sys/errno.h>
#include <sys/types.h>
+#include <sys/signal.h>
#include <sys/systm.h>
#include <compat/svr4/svr4_types.h>
+#include <compat/irix/irix_types.h>
#include <compat/irix/irix_prctl.h>
#include <compat/irix/irix_syscallargs.h>
diff -r 0503f2a19e8a -r c1b725e096ca sys/compat/irix/irix_signal.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/irix/irix_signal.c Sat Dec 08 11:17:37 2001 +0000
@@ -0,0 +1,284 @@
+/* $NetBSD: irix_signal.c,v 1.1 2001/12/08 11:17:37 manu Exp $ */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Emmanuel Dreyfus.
+ *
+ * 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 NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: irix_signal.c,v 1.1 2001/12/08 11:17:37 manu Exp $");
+
+#include <sys/types.h>
+#include <sys/signal.h>
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/systm.h>
+
+#include <machine/regnum.h>
+
+#include <compat/svr4/svr4_types.h>
+
+#include <compat/irix/irix_signal.h>
+#include <compat/irix/irix_syscallargs.h>
+
+extern const int native_to_svr4_sig[];
+extern const int svr4_to_native_sig[];
+
+#define irix_sigmask(n) (1 << (((n) - 1) & 31))
+#define irix_sigword(n) (((n) - 1) >> 5)
+#define irix_sigemptyset(s) memset((s), 0, sizeof(*(s)))
+#define irix_sigismember(s, n) ((s)->bits[irix_sigword(n)] & irix_sigmask(n))
+#define irix_sigaddset(s, n) ((s)->bits[irix_sigword(n)] |= irix_sigmask(n))
+
+void
+native_to_irix_sigset(bss, sss)
+ const sigset_t *bss;
+ irix_sigset_t *sss;
+{
+ int i, newsig;
+
+ irix_sigemptyset(sss);
+ for (i = 1; i < NSIG; i++) {
+ if (sigismember(bss, i)) {
+ newsig = native_to_svr4_sig[i];
+ if (newsig)
+ irix_sigaddset(sss, newsig);
+ }
+ }
+}
+
+void
+irix_to_native_sigset(sss, bss)
+ const irix_sigset_t *sss;
+ sigset_t *bss;
+{
+ int i, newsig;
+
+ sigemptyset(bss);
+ for (i = 1; i < SVR4_NSIG; i++) {
+ if (irix_sigismember(sss, i)) {
+ newsig = svr4_to_native_sig[i];
+ if (newsig)
+ sigaddset(bss, newsig);
+ }
+ }
+}
+
+void
+irix_sendsig(catcher, sig, mask, code) /* XXX Check me */
+ sig_t catcher;
+ int sig;
+ sigset_t *mask;
+ u_long code;
+{
+ struct proc *p = curproc;
+ struct irix_sigframe *fp;
+ struct frame *f;
+ int i,onstack;
+ struct irix_sigframe sf;
+
+#ifdef DEBUG_IRIX
+ printf("irix_sendsig()\n");
+#endif /* DEBUG_IRIX */
+ f = (struct frame *)p->p_md.md_regs;
+
+ /*
+ * 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;
+
+ /*
+ * not sure it works yet.
+ */
+ onstack=0;
+
+ /*
+ * Allocate space for the signal handler context.
+ */
+ if (onstack)
+ fp = (struct irix_sigframe *)
+ ((caddr_t)p->p_sigctx.ps_sigstk.ss_sp
+ + p->p_sigctx.ps_sigstk.ss_size);
+ else
+ /* cast for _MIPS_BSD_API == _MIPS_BSD_API_LP32_64CLEAN case */
+ fp = (struct irix_sigframe *)(u_int32_t)f->f_regs[SP];
+
+ /*
+ * Build stack frame for signal trampoline.
+ */
+ memset(&sf, 0, sizeof sf);
+
+ native_to_irix_sigset(mask, &sf.isf_sc.isc_sigset);
+ for (i=0; i<32; i++) {
+ sf.isf_sc.isc_regs[i] = f->f_regs[i];
+ }
+ sf.isf_sc.isc_regs[0] = 0;
+ sf.isf_sc.isc_fp_rounded_result = 0;
+ sf.isf_sc.isc_regmask = ~0x1UL;
+ sf.isf_sc.isc_mdhi = f->f_regs[MULHI];
+ sf.isf_sc.isc_mdlo = f->f_regs[MULLO];
+ sf.isf_sc.isc_pc = f->f_regs[PC];
+ sf.isf_sc.isc_status = f->f_regs[SR]; /* XXX */
+ sf.isf_sc.isc_cause = f->f_regs[CAUSE];
+ sf.isf_sc.isc_badvaddr = f->f_regs[BADVADDR]; /* XXX */
+ sf.isf_sc.isc_ownedfp = 0;
+ sf.isf_sc.isc_ssflags = 0;
+
+ /*
+ * Save signal stack. XXX broken
+ */
+ /* kregs.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK; */
+
+ /*
+ * Install the sigframe onto the stack
+ */
+ fp = (struct irix_sigframe *)((unsigned long)fp
+ - sizeof(struct irix_sigframe));
+ fp = (struct irix_sigframe *)((unsigned long)fp
+ & ~0xfUL); /* 16 bytes alignement */
+ if (copyout(&sf, fp, sizeof(sf)) != 0) {
+ /*
+ * Process has trashed its stack; give it an illegal
+ * instruction to halt it in its tracks.
+ */
+#ifdef DEBUG_IRIX
+ printf("irix_sendsig: stack trashed\n");
+#endif /* DEBUG_IRIX */
+ sigexit(p, SIGILL);
+ /* NOTREACHED */
+ }
+
+ /* Set up the registers to return to sigcode. */
+ f->f_regs[A0] = native_to_svr4_sig[sig];
+ f->f_regs[A1] = 0;
+ f->f_regs[A2] = (unsigned long)&fp->isf_sc;
+
+#ifdef DEBUG_IRIX
+ printf("sigcontext is at %p\n", &fp->isf_sc);
+#endif /* DEBUG_IRIX */
+
+ f->f_regs[RA] = (unsigned long)p->p_sigctx.ps_sigcode;
+ f->f_regs[SP] = (unsigned long)fp;
+ f->f_regs[T9] = (unsigned long)catcher;
+ f->f_regs[A3] = (unsigned long)catcher;
+ f->f_regs[PC] = (unsigned long)catcher;
+
+ /* Remember that we're now on the signal stack. */
+ if (onstack)
+ p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK;
+
Home |
Main Index |
Thread Index |
Old Index