Source-Changes-HG archive

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

[src/trunk]: src/sys/arch MD glue for COMPAT_NETBSD32 on SH-5.



details:   https://anonhg.NetBSD.org/src/rev/478a51af28e4
branches:  trunk
changeset: 538620:478a51af28e4
user:      scw <scw%NetBSD.org@localhost>
date:      Wed Oct 23 13:26:35 2002 +0000

description:
MD glue for COMPAT_NETBSD32 on SH-5.

diffstat:

 sys/arch/evbsh5/include/Makefile           |    3 +-
 sys/arch/evbsh5/include/netbsd32_machdep.h |    3 +
 sys/arch/sh5/include/Makefile              |    3 +-
 sys/arch/sh5/include/netbsd32_machdep.h    |   65 +++++++++++
 sys/arch/sh5/sh5/netbsd32_machdep.c        |  170 +++++++++++++++++++++++++++++
 5 files changed, 242 insertions(+), 2 deletions(-)

diffs (284 lines):

diff -r 2530e686886d -r 478a51af28e4 sys/arch/evbsh5/include/Makefile
--- a/sys/arch/evbsh5/include/Makefile  Wed Oct 23 13:25:24 2002 +0000
+++ b/sys/arch/evbsh5/include/Makefile  Wed Oct 23 13:26:35 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.6 2002/09/28 11:16:38 scw Exp $
+#      $NetBSD: Makefile,v 1.7 2002/10/23 13:26:37 scw Exp $
 
 KDIR=  /sys/arch/evbsh5/include
 INCSDIR= /usr/include/evbsh5
@@ -13,6 +13,7 @@
        int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
        limits.h lock.h \
        math.h \
+       netbsd32_machdep.h \
        param.h pcb.h pci_machdep.h pmap.h pmc.h proc.h profile.h ptrace.h \
        reg.h \
        setjmp.h signal.h stdarg.h \
diff -r 2530e686886d -r 478a51af28e4 sys/arch/evbsh5/include/netbsd32_machdep.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/evbsh5/include/netbsd32_machdep.h        Wed Oct 23 13:26:35 2002 +0000
@@ -0,0 +1,3 @@
+/*     $NetBSD: netbsd32_machdep.h,v 1.1 2002/10/23 13:26:38 scw Exp $ */
+
+#include <sh5/netbsd32_machdep.h>
diff -r 2530e686886d -r 478a51af28e4 sys/arch/sh5/include/Makefile
--- a/sys/arch/sh5/include/Makefile     Wed Oct 23 13:25:24 2002 +0000
+++ b/sys/arch/sh5/include/Makefile     Wed Oct 23 13:26:35 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.7 2002/09/28 11:16:36 scw Exp $
+#      $NetBSD: Makefile,v 1.8 2002/10/23 13:26:35 scw Exp $
 
 KDIR=  /sys/arch/sh5/include
 INCSDIR= /usr/include/sh5
@@ -13,6 +13,7 @@
        int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
        limits.h lock.h \
        math.h \
+       netbsd32_machdep.h \
        param.h pcb.h pmap.h pmc.h proc.h profile.h pte.h ptrace.h \
        pci_machdep.h \
        reg.h \
diff -r 2530e686886d -r 478a51af28e4 sys/arch/sh5/include/netbsd32_machdep.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sh5/include/netbsd32_machdep.h   Wed Oct 23 13:26:35 2002 +0000
@@ -0,0 +1,65 @@
+/*     $NetBSD: netbsd32_machdep.h,v 1.1 2002/10/23 13:26:36 scw Exp $ */
+
+/*
+ * Copyright 2002 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Steve C. Woodford for Wasabi Systems, Inc.
+ *
+ * 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 for the NetBSD Project by
+ *      Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
+ * 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.
+ */
+
+/*
+ * The world's simplest COMPAT_NETBSD32 shim ...
+ */
+
+#ifndef _SH5_NETBSD32_MACHDEP_H
+#define _SH5_NETBSD32_MACHDEP_H
+
+#include <sys/types.h>
+#include <sys/proc.h>
+#include <compat/netbsd32/netbsd32.h>
+
+typedef int netbsd32_pointer_t;
+#define        NETBSD32PTR64(p32)      ((void *)(long)(int)(p32))
+
+#define        register32_t    register_t
+
+typedef netbsd32_pointer_t netbsd32_sigcontextp_t;
+
+#define        netbsd32_sigcontext sigcontext
+
+#define        netbsd32_sigcode        sigcode
+#define        netbsd32_esigcode       esigcode
+#define        netbsd32_sendsig        sendsig
+#define        netbsd32_syscall_intern syscall_intern
+
+extern void netbsd32_setregs(struct proc *, struct exec_package *, u_long);
+
+#endif /* _SH5_NETBSD32_MACHDEP_H */
diff -r 2530e686886d -r 478a51af28e4 sys/arch/sh5/sh5/netbsd32_machdep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sh5/sh5/netbsd32_machdep.c       Wed Oct 23 13:26:35 2002 +0000
@@ -0,0 +1,170 @@
+/*     $NetBSD: netbsd32_machdep.c,v 1.1 2002/10/23 13:26:37 scw Exp $ */
+
+/*
+ * Copyright 2002 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Steve C. Woodford for Wasabi Systems, Inc.
+ *
+ * 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 for the NetBSD Project by
+ *      Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
+ * 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.
+ */
+
+#ifdef _KERNEL_OPT
+#include "opt_compat_netbsd.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/exec.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 <net/if.h>
+#include <net/route.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/igmp.h>
+#include <netinet/igmp_var.h>
+#include <netinet/ip_mroute.h>
+
+#include <compat/netbsd32/netbsd32.h>
+#include <compat/netbsd32/netbsd32_ioctl.h>
+#include <compat/netbsd32/netbsd32_syscallargs.h>
+
+#include <machine/cpu.h>
+#include <machine/reg.h>
+
+char   machine_arch32[] = "sh5";
+
+int
+netbsd32___sigreturn14(struct proc *p, void *v, register_t *retval)
+{
+       struct netbsd32___sigreturn14_args /* {
+               syscallarg(struct sigcontext *) sigcntxp;
+       } */ *uap = v;
+       struct sys___sigreturn14_args csra;
+       netbsd32_sigcontextp_t scp;
+
+       scp = (netbsd32_sigcontextp_t) SCARG(uap, sigcntxp);
+
+       SCARG(&csra, sigcntxp) = (struct sigcontext *)(intptr_t)scp;
+
+       return (sys___sigreturn14(p, &csra, retval));
+}
+
+/*ARGSUSED*/
+int
+cpu_coredump32(struct proc *p, struct vnode *vp,
+    struct ucred *cred, struct core32 *chdr)
+{
+
+       return (0);
+}
+
+int
+netbsd32_sysarch(struct proc *p, void *v, register_t *retval)
+{
+       struct netbsd32_sysarch_args /* {
+               syscallarg(int) op;
+               syscallarg(netbsd32_voidp) parms;
+       } */ *uap = v;
+
+       switch (SCARG(uap, op)) {
+       default:
+               printf("(%s) netbsd32_sysarch(%d)\n", MACHINE, SCARG(uap, op));
+               return EINVAL;
+       }
+}
+
+void
+netbsd32_setregs(struct proc *p, struct exec_package *pack, u_long stack)
+{
+       struct trapframe *tf = p->p_md.md_regs;
+       register_t sstack;
+       int argc;
+
+       /* Ensure stack pointer is sign-extended */
+       sstack = (register_t)(long)stack;
+
+       /* This cannot fail, as copyargs() has already used copyout() on it */
+#ifdef DIAGNOSTIC
+       if (copyin((caddr_t)(uintptr_t)sstack, &argc, sizeof(argc)) != 0)
+               panic("setregs: argc copyin failed!");
+#else
+       (void) copyin((caddr_t)(uintptr_t)sstack, &argc, sizeof(argc));
+#endif
+
+       memset(tf, 0, sizeof(*tf));
+
+       tf->tf_state.sf_spc = pack->ep_entry;
+       tf->tf_state.sf_ssr = SH5_CONREG_SR_MMU;
+       tf->tf_state.sf_flags = SF_FLAGS_CALLEE_SAVED;
+
+       tf->tf_caller.r2 = (register_t) argc;                    /* argc */
+       tf->tf_caller.r3 = (register_t) (sstack + sizeof(int)); /* argv */
+       tf->tf_caller.r4 = (register_t) (sstack + ((argc + 2) * sizeof(int)));
+
+       /*
+        * r5 and r6 are reserved for the `cleanup' and `obj' parameters
+        * passed by the dynamic loader. The kernel always sets them to 0.
+        */
+
+       tf->tf_caller.r7 = (register_t)(long)p->p_psstr;
+
+       /* Align the stack as required by the SH-5 ABI */
+       tf->tf_caller.r15 = (register_t) (sstack & ~0xf);
+
+       /* Give the new process a clean set of FP regs */
+       memset(&p->p_addr->u_pcb.pcb_ctx.sf_fpregs, 0, sizeof(struct fpregs));
+
+       /*
+        * I debated with myself about the following for a wee while.
+        *
+        * Disable FPU Exceptions for arithmetic operations on de-normalised
+        * numbers. While this is contrary to the IEEE-754, it's how things
+        * work in NetBSD/i386.
+        *
+        * Since most applications are likely to have been developed on i386
+        * platforms, most application programmers would never see this
+        * fault in their code. The in-tree top(1) program is one such
+        * offender, under certain circumstances.
+        *
+        * With FPSCR.DN set, denormalised numbers are quietly flushed to zero.
+        */
+       p->p_addr->u_pcb.pcb_ctx.sf_fpregs.fpscr = 0x20000;
+
+       sh5_fprestore(SH5_CONREG_USR_FPRS_MASK << SH5_CONREG_USR_FPRS_SHIFT,
+           &p->p_addr->u_pcb);
+}



Home | Main Index | Thread Index | Old Index