Subject: Re: linux emulation layer
To: syamajala@gamebox.net <syamajala@gamebox.net>
From: Matthew Orgass <darkstar@city-net.com>
List: port-hpcmips
Date: 06/12/2007 15:50:57
On 2007-06-03 syamajala@gamebox.net wrote:

> I've been wondering, would it be possible to run debian mipsel
> packages on the hpcmips port if it had a linux emulation layer? It
> would give us access to a lot of prebuilt packages. Also does the
> hpcmips port not have a linux emulation because from what I found
> from searching around it doesn't seem to, but I just want to get this
> confirmed.

  There is mips support in linux compat code under
src/sys/compat/arch/mips.  I tried building a kernel with "options
COMPAT_LINUX" and it needed a few changes to build, so apparently it is
not used much and comments indicate that it is incomplete.  There is quite
a bit of common code so it might work for some binaries.  Patch attached
below and at: http://www.city-net.com/~darkstar/netbsd/mipslinux.diff

Matthew Orgass
darkstar@city-net.com

Index: sys/compat/linux/arch/mips/linux_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/arch/mips/linux_machdep.c,v
retrieving revision 1.30
diff -u -p -r1.30 linux_machdep.c
--- sys/compat/linux/arch/mips/linux_machdep.c	4 Mar 2007 06:01:22 -0000	1.30
+++ sys/compat/linux/arch/mips/linux_machdep.c	12 Jun 2007 18:52:31 -0000
@@ -157,7 +157,7 @@ linux_sendsig(ksi, mask)
 	 */
 	if (onstack)
 		fp = (struct linux_sigframe *)
-		    ((void *)l->l_sigstk.ss_sp
+		    ((uint8_t *)l->l_sigstk.ss_sp
 		    + l->l_sigstk.ss_size);
 	else
 		/* cast for _MIPS_BSD_API == _MIPS_BSD_API_LP32_64CLEAN case */
@@ -197,7 +197,7 @@ linux_sendsig(ksi, mask)
 	 */
 	fp -= sizeof(struct linux_sigframe);
 	mutex_exit(&p->p_smutex);
-	error = copyout(&sf, fp, sizeof(sf);
+	error = copyout(&sf, fp, sizeof(sf));
 	mutex_enter(&p->p_smutex);

 	if (error != 0) {
@@ -337,8 +337,8 @@ linux_fakedev(dev, raw)
  * We come here in a last attempt to satisfy a Linux ioctl() call
  */
 int
-linux_machdepioctl(p, v, retval)
-	struct proc *p;
+linux_machdepioctl(l, v, retval)
+	struct lwp *l;
 	void *v;
 	register_t *retval;
 {
Index: sys/arch/mips/mips/linux_trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/mips/linux_trap.c,v
retrieving revision 1.7
diff -u -p -r1.7 linux_trap.c
--- sys/arch/mips/mips/linux_trap.c	11 Dec 2005 12:18:09 -0000	1.7
+++ sys/arch/mips/mips/linux_trap.c	12 Jun 2007 18:52:32 -0000
@@ -51,7 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_trap.c
 #include <compat/linux/common/linux_exec.h>

 void
-linux_trapsignal(struct lwp *l, const ksiginfo_t *ksi)
+linux_trapsignal(struct lwp *l, ksiginfo_t *ksi)
 {

 	(*l->l_proc->p_emul->e_trapsignal)(l, ksi);