Module Name: src
Committed By: pgoyette
Date: Sat Sep 29 06:31:02 UTC 2018
Modified Files:
src/sys/arch/mips/conf [pgoyette-compat]: files.mips
src/sys/arch/mips/mips [pgoyette-compat]: netbsd32_machdep.c
Added Files:
src/sys/arch/mips/mips [pgoyette-compat]: netbsd32_machdep_13.c
netbsd32_machdep_16.c
Log Message:
Add glue for netbsd32 compat_13 and _16 modules
To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.75.16.1 src/sys/arch/mips/conf/files.mips
cvs rdiff -u -r1.15 -r1.15.2.1 src/sys/arch/mips/mips/netbsd32_machdep.c
cvs rdiff -u -r0 -r1.1.2.1 src/sys/arch/mips/mips/netbsd32_machdep_13.c \
src/sys/arch/mips/mips/netbsd32_machdep_16.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/mips/conf/files.mips
diff -u src/sys/arch/mips/conf/files.mips:1.75 src/sys/arch/mips/conf/files.mips:1.75.16.1
--- src/sys/arch/mips/conf/files.mips:1.75 Mon Jul 11 23:06:53 2016
+++ src/sys/arch/mips/conf/files.mips Sat Sep 29 06:31:02 2018
@@ -1,4 +1,4 @@
-# $NetBSD: files.mips,v 1.75 2016/07/11 23:06:53 matt Exp $
+# $NetBSD: files.mips,v 1.75.16.1 2018/09/29 06:31:02 pgoyette Exp $
#
defflag opt_cputype.h NOFPU FPEMUL
@@ -91,13 +91,20 @@ file arch/mips/mips/bds_emul.S fpemul
file arch/mips/mips/procfs_machdep.c procfs
+#
+# Compatibility modules
+#
+# Binary compatibility with previous NetBSD releases (COMPAT_XX)
+file arch/mips/mips/compat_13_machdep.c compat_13 | compat_ultrix
+file arch/mips/mips/compat_16_machdep.c compat_16 | compat_ultrix
+
# Binary compatibility with 32bit NetBSD (COMPAT_NETBSD32)
file arch/mips/mips/netbsd32_machdep.c compat_netbsd32
+file arch/mips/mips/netbsd32_machdep_13.c compat_netbsd32 & compat_13
+file arch/mips/mips/netbsd32_machdep_16.c compat_netbsd32 & compat_16
include "compat/netbsd32/files.netbsd32"
# Binary compatibility with previous NetBSD releases (COMPAT_XX)
-file arch/mips/mips/compat_13_machdep.c compat_13 | compat_ultrix
-file arch/mips/mips/compat_16_machdep.c compat_16 | compat_ultrix
# Ultrix Binary Compatibility (COMPAT_ULTRIX)
include "compat/ultrix/files.ultrix"
Index: src/sys/arch/mips/mips/netbsd32_machdep.c
diff -u src/sys/arch/mips/mips/netbsd32_machdep.c:1.15 src/sys/arch/mips/mips/netbsd32_machdep.c:1.15.2.1
--- src/sys/arch/mips/mips/netbsd32_machdep.c:1.15 Tue Oct 31 12:37:23 2017
+++ src/sys/arch/mips/mips/netbsd32_machdep.c Sat Sep 29 06:31:02 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.15 2017/10/31 12:37:23 martin Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.15.2.1 2018/09/29 06:31:02 pgoyette Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.15 2017/10/31 12:37:23 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.15.2.1 2018/09/29 06:31:02 pgoyette Exp $");
#include "opt_compat_netbsd.h"
#include "opt_coredump.h"
@@ -343,3 +343,17 @@ cpu_coredump32(struct lwp *l, struct cor
chdr->c_cpusize);
}
#endif
+
+void
+netbsd32_machdep_md_init(void)
+{
+
+ /* nothing to do */
+}
+
+void
+netbsd32_machdep_md_fini(void)
+{
+
+ /* nothing to do */
+}
Added files:
Index: src/sys/arch/mips/mips/netbsd32_machdep_13.c
diff -u /dev/null src/sys/arch/mips/mips/netbsd32_machdep_13.c:1.1.2.1
--- /dev/null Sat Sep 29 06:31:02 2018
+++ src/sys/arch/mips/mips/netbsd32_machdep_13.c Sat Sep 29 06:31:02 2018
@@ -0,0 +1,104 @@
+/* $NetBSD: netbsd32_machdep_13.c,v 1.1.2.1 2018/09/29 06:31:02 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas <[email protected]>.
+ *
+ * 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.
+ *
+ * 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: netbsd32_machdep_13.c,v 1.1.2.1 2018/09/29 06:31:02 pgoyette Exp $");
+
+#include "opt_compat_netbsd.h"
+#include "opt_coredump.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/ioctl.h>
+#include <sys/exec.h>
+#include <sys/cpu.h>
+#include <sys/core.h>
+#include <sys/file.h>
+#include <sys/time.h>
+#include <sys/proc.h>
+#include <sys/uio.h>
+#include <sys/kernel.h>
+#include <sys/buf.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <compat/netbsd32/netbsd32.h>
+#include <compat/netbsd32/netbsd32_exec.h>
+#include <compat/netbsd32/netbsd32_syscallargs.h>
+
+#include <mips/cache.h>
+#include <mips/sysarch.h>
+#include <mips/cachectl.h>
+#include <mips/locore.h>
+#include <mips/frame.h>
+#include <mips/regnum.h>
+#include <mips/pcb.h>
+
+#include <uvm/uvm_extern.h>
+
+const char machine32[] = MACHINE;
+const char machine_arch32[] = MACHINE32_ARCH;
+
+#if 0
+cpu_coredump32
+netbsd32_cpu_upcall
+netbsd32_vm_default_addr
+#endif
+
+#ifdef COMPAT_13
+int
+compat_13_netbsd32_sigreturn(struct lwp *l,
+ const struct compat_13_netbsd32_sigreturn_args *uap,
+ register_t *retval)
+{
+ struct compat_13_sys_sigreturn_args ua;
+
+ NETBSD32TOP_UAP(sigcntxp, struct sigcontext13 *);
+
+ return compat_13_sys_sigreturn(l, &ua, retval);
+}
+#endif
+
+void
+netbsd32_machdep_md_13_init(void)
+{
+
+ /* nothing to do */
+}
+
+void
+netbsd32_machdep_md_13_fini(void)
+{
+
+ /* nothing to do */
+}
Index: src/sys/arch/mips/mips/netbsd32_machdep_16.c
diff -u /dev/null src/sys/arch/mips/mips/netbsd32_machdep_16.c:1.1.2.1
--- /dev/null Sat Sep 29 06:31:02 2018
+++ src/sys/arch/mips/mips/netbsd32_machdep_16.c Sat Sep 29 06:31:02 2018
@@ -0,0 +1,192 @@
+/* $NetBSD: netbsd32_machdep_16.c,v 1.1.2.1 2018/09/29 06:31:02 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas <[email protected]>.
+ *
+ * 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.
+ *
+ * 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: netbsd32_machdep_16.c,v 1.1.2.1 2018/09/29 06:31:02 pgoyette Exp $");
+
+#include "opt_compat_netbsd.h"
+#include "opt_coredump.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/ioctl.h>
+#include <sys/exec.h>
+#include <sys/cpu.h>
+#include <sys/core.h>
+#include <sys/file.h>
+#include <sys/time.h>
+#include <sys/proc.h>
+#include <sys/uio.h>
+#include <sys/kernel.h>
+#include <sys/buf.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <compat/netbsd32/netbsd32.h>
+#include <compat/netbsd32/netbsd32_exec.h>
+#include <compat/netbsd32/netbsd32_syscallargs.h>
+
+#include <mips/cache.h>
+#include <mips/sysarch.h>
+#include <mips/cachectl.h>
+#include <mips/locore.h>
+#include <mips/frame.h>
+#include <mips/regnum.h>
+#include <mips/pcb.h>
+
+#include <uvm/uvm_extern.h>
+
+#ifdef COMPAT_16
+int
+compat_16_netbsd32___sigreturn14(struct lwp *l,
+ const struct compat_16_netbsd32___sigreturn14_args *uap,
+ register_t *retval)
+{
+ struct compat_16_sys___sigreturn14_args ua;
+
+ NETBSD32TOP_UAP(sigcntxp, struct sigcontext *);
+
+ return compat_16_sys___sigreturn14(l, &ua, retval);
+}
+#endif
+
+struct sigframe_siginfo32 {
+ siginfo32_t sf_si;
+ ucontext32_t sf_uc;
+};
+
+/*
+ * Send a signal to process.
+ */
+static void
+netbsd32_sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
+{
+ struct lwp * const l = curlwp;
+ struct proc * const p = l->l_proc;
+ struct sigacts * const ps = p->p_sigacts;
+ int onstack, error;
+ int sig = ksi->ksi_signo;
+ struct sigframe_siginfo32 *sfp = getframe(l, sig, &onstack);
+ struct sigframe_siginfo32 sf;
+ struct trapframe * const tf = l->l_md.md_utf;
+ size_t sfsz;
+ sig_t catcher = SIGACTION(p, sig).sa_handler;
+
+ sfp--;
+
+ netbsd32_si_to_si32(&sf.sf_si, (const siginfo_t *)&ksi->ksi_info);
+
+ /* Build stack frame for signal trampoline. */
+ switch (ps->sa_sigdesc[sig].sd_vers) {
+ case 0: /* handled by sendsig_sigcontext */
+ case 1: /* handled by sendsig_sigcontext */
+ default: /* unknown version */
+ printf("sendsig_siginfo: bad version %d\n",
+ ps->sa_sigdesc[sig].sd_vers);
+ sigexit(l, SIGILL);
+ case 2:
+ break;
+ }
+
+ sf.sf_uc.uc_flags = _UC_SIGMASK
+ | ((l->l_sigstk.ss_flags & SS_ONSTACK)
+ ? _UC_SETSTACK : _UC_CLRSTACK);
+ sf.sf_uc.uc_sigmask = *mask;
+ sf.sf_uc.uc_link = (intptr_t)l->l_ctxlink;
+ memset(&sf.sf_uc.uc_stack, 0, sizeof(sf.sf_uc.uc_stack));
+ sfsz = offsetof(struct sigframe_siginfo32, sf_uc.uc_mcontext);
+ if (p->p_md.md_abi == _MIPS_BSD_API_O32)
+ sfsz += sizeof(mcontext_o32_t);
+ else
+ sfsz += sizeof(mcontext32_t);
+ sendsig_reset(l, sig);
+ mutex_exit(p->p_lock);
+ cpu_getmcontext32(l, &sf.sf_uc.uc_mcontext, &sf.sf_uc.uc_flags);
+ error = copyout(&sf, sfp, sfsz);
+ mutex_enter(p->p_lock);
+
+ if (error != 0) {
+ /*
+ * Process has trashed its stack; give it an illegal
+ * instruction to halt it in its tracks.
+ */
+ sigexit(l, SIGILL);
+ /* NOTREACHED */
+ }
+
+ /*
+ * Set up the registers to directly invoke the signal
+ * handler. The return address will be set up to point
+ * to the signal trampoline to bounce us back.
+ */
+ tf->tf_regs[_R_A0] = sig;
+ tf->tf_regs[_R_A1] = (intptr_t)&sfp->sf_si;
+ tf->tf_regs[_R_A2] = (intptr_t)&sfp->sf_uc;
+
+ tf->tf_regs[_R_PC] = (intptr_t)catcher;
+ tf->tf_regs[_R_T9] = (intptr_t)catcher;
+ tf->tf_regs[_R_SP] = (intptr_t)sfp;
+ tf->tf_regs[_R_RA] = (intptr_t)ps->sa_sigdesc[sig].sd_tramp;
+
+ /* Remember that we're now on the signal stack. */
+ if (onstack)
+ l->l_sigstk.ss_flags |= SS_ONSTACK;
+}
+
+void
+netbsd32_sendsig_16(const ksiginfo_t *ksi, const sigset_t *mask)
+{
+#ifdef COMPAT_16
+ if (curproc->p_sigacts->sa_sigdesc[ksi->ksi_signo].sd_vers < 2)
+ netbsd32_sendsig_sigcontext(ksi, mask);
+ else
+#endif
+ netbsd32_sendsig_siginfo(ksi, mask);
+}
+
+MODULE_SET_HOOK(netbsd32_sendsig_hook, "nb32_16", netbsd32_sendsig_16);
+MODULE_UNSET_HOOK(netbsd32_sendsig_hook);
+
+void
+netbsd32_machdep_md_init(void)
+{
+
+ netbsd32_sendsig_hook_set();
+}
+
+void
+netbsd32_machdep_md_fini(void)
+{
+
+ netbsd32_sendsig_hook_unset();
+}