Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mips/mips Added Linux emulation support to Mips port



details:   https://anonhg.NetBSD.org/src/rev/47ca35366e62
branches:  trunk
changeset: 515367:47ca35366e62
user:      manu <manu%NetBSD.org@localhost>
date:      Sat Sep 22 21:29:20 2001 +0000

description:
Added Linux emulation support to Mips port

diffstat:

 sys/arch/mips/mips/linux_syscall.c |  42 ++++++++++++++++++++++++++++++
 sys/arch/mips/mips/linux_trap.c    |  53 ++++++++++++++++++++++++++++++++++++++
 sys/arch/mips/mips/locore.S        |  15 ++++++++++-
 sys/arch/mips/mips/syscall.c       |  32 ++++++++++++++--------
 4 files changed, 129 insertions(+), 13 deletions(-)

diffs (239 lines):

diff -r bab8d0cfedbc -r 47ca35366e62 sys/arch/mips/mips/linux_syscall.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mips/mips/linux_syscall.c        Sat Sep 22 21:29:20 2001 +0000
@@ -0,0 +1,42 @@
+/*     $NetBSD: linux_syscall.c,v 1.1 2001/09/22 21:29:20 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.
+ */
+
+#define EMULNAME(x)    __CONCAT(linux_,x)
+#define SYSCALL_SHIFT  4000
+
+#include "syscall.c"
diff -r bab8d0cfedbc -r 47ca35366e62 sys/arch/mips/mips/linux_trap.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mips/mips/linux_trap.c   Sat Sep 22 21:29:20 2001 +0000
@@ -0,0 +1,53 @@
+/*     $NetBSD: linux_trap.c,v 1.1 2001/09/22 21:29:20 manu Exp $ */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas and 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/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+#include <sys/acct.h>
+#include <sys/kernel.h>
+#include <sys/signal.h>
+#include <sys/syscall.h>
+
+#include <compat/linux/common/linux_exec.h>
+
+void
+linux_trapsignal(struct proc *p, int signo, u_long type) {
+       trapsignal(p, signo, type);
+}
diff -r bab8d0cfedbc -r 47ca35366e62 sys/arch/mips/mips/locore.S
--- a/sys/arch/mips/mips/locore.S       Sat Sep 22 21:26:40 2001 +0000
+++ b/sys/arch/mips/mips/locore.S       Sat Sep 22 21:29:20 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.122 2001/07/09 01:43:26 simonb Exp $      */
+/*     $NetBSD: locore.S,v 1.123 2001/09/22 21:29:21 manu Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -57,6 +57,7 @@
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
 #include "opt_compat_ultrix.h"
+#include "opt_compat_linux.h"
 #include "opt_ns.h"
 #include "opt_ccitt.h"
 #include "opt_iso.h"
@@ -70,6 +71,9 @@
 #ifdef COMPAT_ULTRIX
 #include <compat/ultrix/ultrix_syscall.h>
 #endif
+#ifdef COMPAT_LINUX
+#include <compat/linux/linux_syscall.h>
+#endif
 
 #include <machine/param.h>
 #include <mips/asm.h>
@@ -193,6 +197,15 @@
 XLEAF(ultrix_esigcode)
 #endif
 
+#ifdef COMPAT_LINUX
+LEAF_NOPROFILE(linux_sigcode)
+       addu    a0, sp, 16              # address of sigcontext
+       li      v0, LINUX_SYS_sigreturn # sigreturn(scp)
+       syscall
+       break   0                       # just in case sigreturn fails
+END(linux_sigcode)
+XLEAF(linux_esigcode)
+#endif
 
 /*
  * The following primitives manipulate the run queues.  whichqs tells which
diff -r bab8d0cfedbc -r 47ca35366e62 sys/arch/mips/mips/syscall.c
--- a/sys/arch/mips/mips/syscall.c      Sat Sep 22 21:26:40 2001 +0000
+++ b/sys/arch/mips/mips/syscall.c      Sat Sep 22 21:29:20 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syscall.c,v 1.4 2001/05/11 01:42:32 thorpej Exp $      */
+/*     $NetBSD: syscall.c,v 1.5 2001/09/22 21:29:21 manu Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.4 2001/05/11 01:42:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.5 2001/09/22 21:29:21 manu Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_syscall_debug.h"
@@ -103,24 +103,32 @@
 #include <mips/regnum.h>                       /* symbolic register indices */
 #include <mips/userret.h>
 
-void   syscall_intern(struct proc *);
-void   syscall_plain(struct proc *, u_int, u_int, u_int);
-void   syscall_fancy(struct proc *, u_int, u_int, u_int);
+#ifndef EMULNAME
+#define EMULNAME(x)    (x)
+#endif
+
+#ifndef SYSCALL_SHIFT
+#define SYSCALL_SHIFT 0
+#endif
+
+void   EMULNAME(syscall_intern)(struct proc *);
+void   EMULNAME(syscall_plain)(struct proc *, u_int, u_int, u_int);
+void   EMULNAME(syscall_fancy)(struct proc *, u_int, u_int, u_int);
 
 vaddr_t MachEmulateBranch(struct frame *, vaddr_t, u_int, int);
 
 #define DELAYBRANCH(x) ((int)(x)<0)
 
 void
-syscall_intern(struct proc *p)
+EMULNAME(syscall_intern)(struct proc *p)
 {
 
 #ifdef KTRACE
        if (p->p_traceflag & (KTRFAC_SYSCALL | KTRFAC_SYSRET))
-               p->p_md.md_syscall = syscall_fancy;
+               p->p_md.md_syscall = EMULNAME(syscall_fancy);
        else
 #endif
-               p->p_md.md_syscall = syscall_plain;
+               p->p_md.md_syscall = EMULNAME(syscall_plain);
 }
 
 /*
@@ -135,7 +143,7 @@
  */
 
 void
-syscall_plain(struct proc *p, u_int status, u_int cause, u_int opc)
+EMULNAME(syscall_plain)(struct proc *p, u_int status, u_int cause, u_int opc)
 {
        struct frame *frame = (struct frame *)p->p_md.md_regs;
        mips_reg_t *args, copyargs[8], ov0;
@@ -152,7 +160,7 @@
 
        callp = p->p_emul->e_sysent;
        numsys = p->p_emul->e_nsysent;
-       ov0 = code = frame->f_regs[V0];
+       ov0 = code = frame->f_regs[V0] - SYSCALL_SHIFT;
 
        switch (code) {
        case SYS_syscall:
@@ -253,7 +261,7 @@
 }
 
 void
-syscall_fancy(struct proc *p, u_int status, u_int cause, u_int opc)
+EMULNAME(syscall_fancy)(struct proc *p, u_int status, u_int cause, u_int opc)
 {
        struct frame *frame = (struct frame *)p->p_md.md_regs;
        mips_reg_t *args, copyargs[8], ov0;
@@ -270,7 +278,7 @@
 
        callp = p->p_emul->e_sysent;
        numsys = p->p_emul->e_nsysent;
-       ov0 = code = frame->f_regs[V0];
+       ov0 = code = frame->f_regs[V0] - SYSCALL_SHIFT;
 
        switch (code) {
        case SYS_syscall:



Home | Main Index | Thread Index | Old Index