svn commit: r205725 - in user/jmallett/octeon/sys: conf mips/conf
mips/include mips/mips sys
Juli Mallett
jmallett at FreeBSD.org
Sat Mar 27 04:39:59 UTC 2010
Author: jmallett
Date: Sat Mar 27 04:39:59 2010
New Revision: 205725
URL: http://svn.freebsd.org/changeset/base/205725
Log:
Add not-quite-tested support for running N32 binaries on N64 kernels.
N64 and N32 /sbin/init both blow up in pmap_remove_entry, which I've not yet
tracked down, on N64 kernels.
Remove unused elf64_machdep file.
Added:
user/jmallett/octeon/sys/mips/mips/freebsd32_machdep.c
Deleted:
user/jmallett/octeon/sys/mips/mips/elf64_machdep.c
Modified:
user/jmallett/octeon/sys/conf/files.mips
user/jmallett/octeon/sys/conf/options.mips
user/jmallett/octeon/sys/mips/conf/OCTEON1
user/jmallett/octeon/sys/mips/include/elf.h
user/jmallett/octeon/sys/mips/include/reg.h
user/jmallett/octeon/sys/mips/include/vmparam.h
user/jmallett/octeon/sys/mips/mips/elf_machdep.c
user/jmallett/octeon/sys/sys/sysctl.h
Modified: user/jmallett/octeon/sys/conf/files.mips
==============================================================================
--- user/jmallett/octeon/sys/conf/files.mips Sat Mar 27 03:17:39 2010 (r205724)
+++ user/jmallett/octeon/sys/conf/files.mips Sat Mar 27 04:39:59 2010 (r205725)
@@ -104,3 +104,10 @@ dev/siba/siba_pcib.c optional siba pci
dev/hwpmc/hwpmc_mips.c optional hwpmc
dev/hwpmc/hwpmc_mips24k.c optional hwpmc
+
+compat/freebsd32/freebsd32_ioctl.c optional compat_freebsd32
+compat/freebsd32/freebsd32_misc.c optional compat_freebsd32
+compat/freebsd32/freebsd32_syscalls.c optional compat_freebsd32
+compat/freebsd32/freebsd32_sysent.c optional compat_freebsd32
+mips/mips/freebsd32_machdep.c optional compat_freebsd32
+kern/imgact_elf32.c optional compat_freebsd32
Modified: user/jmallett/octeon/sys/conf/options.mips
==============================================================================
--- user/jmallett/octeon/sys/conf/options.mips Sat Mar 27 03:17:39 2010 (r205724)
+++ user/jmallett/octeon/sys/conf/options.mips Sat Mar 27 04:39:59 2010 (r205725)
@@ -57,6 +57,8 @@ TARGET_XLR_XLS opt_global.h
TICK_USE_YAMON_FREQ opt_global.h
TICK_USE_MALTA_RTC opt_global.h
+COMPAT_FREEBSD32 opt_compat.h
+
#
# The highest memory address that can be used by the kernel in units of KB.
#
Modified: user/jmallett/octeon/sys/mips/conf/OCTEON1
==============================================================================
--- user/jmallett/octeon/sys/mips/conf/OCTEON1 Sat Mar 27 03:17:39 2010 (r205724)
+++ user/jmallett/octeon/sys/mips/conf/OCTEON1 Sat Mar 27 04:39:59 2010 (r205725)
@@ -56,10 +56,12 @@ options _KPOSIX_PRIORITY_SCHEDULING #Po
#options ROOTDEVNAME=\"ufs:ad0s1a\" # Original
options NO_SWAPPING
-options BOOTP
-options BOOTP_NFSROOT
-options BOOTP_NFSV3
-options BOOTP_COMPAT
+options COMPAT_FREEBSD32
+
+#options BOOTP
+#options BOOTP_NFSROOT
+#options BOOTP_NFSV3
+#options BOOTP_COMPAT
options FFS #Berkeley Fast Filesystem
options SOFTUPDATES #Enable FFS soft updates support
Modified: user/jmallett/octeon/sys/mips/include/elf.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/elf.h Sat Mar 27 03:17:39 2010 (r205724)
+++ user/jmallett/octeon/sys/mips/include/elf.h Sat Mar 27 04:39:59 2010 (r205725)
@@ -38,6 +38,10 @@
#ifndef _MACHINE_ELF_H_
#define _MACHINE_ELF_H_
+#if defined(_KERNEL) && !defined(_STANDALONE)
+#include "opt_compat.h"
+#endif
+
/* Information taken from MIPS ABI supplemental */
#ifndef __ELF_WORD_SIZE
@@ -52,6 +56,9 @@
#include <sys/elf_generic.h>
#define ELF_ARCH EM_MIPS
+#if defined(COMPAT_FREEBSD32)
+#define ELF_ARCH32 ELF_ARCH
+#endif
#define ELF_MACHINE_OK(x) ((x) == EM_MIPS || (x) == EM_MIPS_RS4_BE)
/* Architecture dependent Segment types - p_type */
Modified: user/jmallett/octeon/sys/mips/include/reg.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/reg.h Sat Mar 27 03:17:39 2010 (r205724)
+++ user/jmallett/octeon/sys/mips/include/reg.h Sat Mar 27 04:39:59 2010 (r205725)
@@ -42,6 +42,10 @@
#ifndef _MACHINE_REG_H_
#define _MACHINE_REG_H_
+#if defined(_KERNEL) && !defined(_STANDALONE)
+#include "opt_compat.h"
+#endif
+
/*
* Location of the users' stored registers relative to ZERO.
* must be visible to assembly code.
@@ -66,6 +70,20 @@ struct dbreg {
unsigned long junk;
};
+#if defined(COMPAT_FREEBSD32)
+struct reg32 {
+ register_t r_regs[NUMSAVEREGS]; /* numbered as above */
+};
+
+struct fpreg32 {
+ f_register_t r_regs[NUMFPREGS];
+};
+
+struct dbreg32 {
+ unsigned long junk;
+};
+#endif
+
#ifdef _KERNEL
int fill_fpregs(struct thread *, struct fpreg *);
int fill_regs(struct thread *, struct reg *);
@@ -73,6 +91,15 @@ int set_fpregs(struct thread *, struct f
int set_regs(struct thread *, struct reg *);
int fill_dbregs(struct thread *, struct dbreg *);
int set_dbregs(struct thread *, struct dbreg *);
+
+#ifdef COMPAT_FREEBSD32
+int fill_fpregs32(struct thread *, struct fpreg32 *);
+int fill_regs32(struct thread *, struct reg32 *);
+int set_fpregs32(struct thread *, struct fpreg32 *);
+int set_regs32(struct thread *, struct reg32 *);
+int fill_dbregs32(struct thread *, struct dbreg32 *);
+int set_dbregs32(struct thread *, struct dbreg32 *);
+#endif
#endif
#endif /* !_MACHINE_REG_H_ */
Modified: user/jmallett/octeon/sys/mips/include/vmparam.h
==============================================================================
--- user/jmallett/octeon/sys/mips/include/vmparam.h Sat Mar 27 03:17:39 2010 (r205724)
+++ user/jmallett/octeon/sys/mips/include/vmparam.h Sat Mar 27 04:39:59 2010 (r205725)
@@ -43,6 +43,10 @@
#ifndef _MACHINE_VMPARAM_H_
#define _MACHINE_VMPARAM_H_
+#if defined(_KERNEL) && !defined(_STANDALONE)
+#include "opt_compat.h"
+#endif
+
/*
* Machine dependent constants mips processors.
*/
@@ -57,6 +61,9 @@
* offset is calculated.
*/
#define USRSTACK 0x7ffff000 /* Start of user stack */
+#if defined(COMPAT_FREEBSD32)
+#define FREEBSD32_USRSTACK USRSTACK
+#endif
/*
* Virtual memory related constants, all in bytes
Modified: user/jmallett/octeon/sys/mips/mips/elf_machdep.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/elf_machdep.c Sat Mar 27 03:17:39 2010 (r205724)
+++ user/jmallett/octeon/sys/mips/mips/elf_machdep.c Sat Mar 27 04:39:59 2010 (r205725)
@@ -80,7 +80,7 @@ struct sysentvec elf64_freebsd_sysvec =
.sv_flags = SV_ABI_FREEBSD | SV_LP64
};
-static Elf64_Brandinfo freebsd_brand_info = {
+static Elf64_Brandinfo freebsd64_brand_info = {
.brand = ELFOSABI_FREEBSD,
.machine = EM_MIPS,
.compat_3_brand = "FreeBSD",
@@ -93,7 +93,7 @@ static Elf64_Brandinfo freebsd_brand_inf
SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
(sysinit_cfunc_t) elf64_insert_brand_entry,
- &freebsd_brand_info);
+ &freebsd64_brand_info);
void
elf64_dump_thread(struct thread *td __unused, void *dst __unused,
@@ -101,6 +101,10 @@ elf64_dump_thread(struct thread *td __un
{
}
#else
+/*
+ * XXX
+ * Add a mechanism to distinguish between n32 and o32.
+ */
struct sysentvec elf32_freebsd_sysvec = {
.sv_size = SYS_MAXSYSCALL,
.sv_table = sysent,
@@ -132,7 +136,7 @@ struct sysentvec elf32_freebsd_sysvec =
.sv_flags = SV_ABI_FREEBSD | SV_ILP32
};
-static Elf32_Brandinfo freebsd_brand_info = {
+static Elf32_Brandinfo freebsd32_brand_info = {
.brand = ELFOSABI_FREEBSD,
.machine = EM_MIPS,
.compat_3_brand = "FreeBSD",
@@ -145,7 +149,7 @@ static Elf32_Brandinfo freebsd_brand_inf
SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_FIRST,
(sysinit_cfunc_t) elf32_insert_brand_entry,
- &freebsd_brand_info);
+ &freebsd32_brand_info);
void
elf32_dump_thread(struct thread *td __unused, void *dst __unused,
Added: user/jmallett/octeon/sys/mips/mips/freebsd32_machdep.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/jmallett/octeon/sys/mips/mips/freebsd32_machdep.c Sat Mar 27 04:39:59 2010 (r205725)
@@ -0,0 +1,265 @@
+/*-
+ * Copyright 2010 Juli Mallett.
+ * Copyright 1996-1998 John D. Polstra.
+ * All rights reserved.
+ *
+ * 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 AUTHOR ``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 AUTHOR 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.
+ *
+ * from: src/sys/i386/i386/elf_machdep.c,v 1.20 2004/08/11 02:35:05 marcel
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: user/jmallett/octeon/sys/mips/mips/elf_machdep.c 204031 2010-02-18 05:49:52Z neel $");
+
+#define __ELF_WORD_SIZE 32
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/exec.h>
+#include <sys/imgact.h>
+#include <sys/linker.h>
+#include <sys/sysent.h>
+#include <sys/proc.h>
+#include <sys/imgact_elf.h>
+#include <sys/syscall.h>
+#include <sys/sysproto.h>
+#include <sys/signalvar.h>
+#include <sys/vnode.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+#include <vm/vm_param.h>
+
+#include <compat/freebsd32/freebsd32_signal.h>
+#include <compat/freebsd32/freebsd32_util.h>
+#include <compat/freebsd32/freebsd32_proto.h>
+#include <machine/elf.h>
+#include <machine/md_var.h>
+#include <machine/cache.h>
+
+/*
+ * XXX
+ * Add a mechanism to distinguish between n32 and o32.
+ */
+struct sysentvec elf32_freebsd_sysvec = {
+ .sv_size = SYS_MAXSYSCALL,
+ .sv_table = sysent,
+ .sv_mask = 0,
+ .sv_sigsize = 0,
+ .sv_sigtbl = NULL,
+ .sv_errsize = 0,
+ .sv_errtbl = NULL,
+ .sv_transtrap = NULL,
+ .sv_fixup = __elfN(freebsd_fixup),
+ .sv_sendsig = sendsig,
+ .sv_sigcode = sigcode,
+ .sv_szsigcode = &szsigcode,
+ .sv_prepsyscall = NULL,
+ .sv_name = "FreeBSD ELF32",
+ .sv_coredump = __elfN(coredump),
+ .sv_imgact_try = NULL,
+ .sv_minsigstksz = MINSIGSTKSZ,
+ .sv_pagesize = PAGE_SIZE,
+ .sv_minuser = VM_MIN_ADDRESS,
+ .sv_maxuser = VM_MAXUSER_ADDRESS,
+ .sv_usrstack = FREEBSD32_USRSTACK,
+ .sv_psstrings = PS_STRINGS,
+ .sv_stackprot = VM_PROT_ALL,
+ .sv_copyout_strings = exec_copyout_strings,
+ .sv_setregs = exec_setregs,
+ .sv_fixlimit = NULL,
+ .sv_maxssiz = NULL,
+ .sv_flags = SV_ABI_FREEBSD | SV_ILP32
+};
+
+static Elf32_Brandinfo freebsd32_brand_info = {
+ .brand = ELFOSABI_FREEBSD,
+ .machine = EM_MIPS,
+ .compat_3_brand = "FreeBSD",
+ .emul_path = NULL,
+ .interp_path = "/libexec/ld-elf.so.1",
+ .sysvec = &elf32_freebsd_sysvec,
+ .interp_newpath = NULL,
+ .flags = 0
+};
+
+SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_FIRST,
+ (sysinit_cfunc_t) elf32_insert_brand_entry,
+ &freebsd32_brand_info);
+
+void
+elf32_dump_thread(struct thread *td __unused, void *dst __unused,
+ size_t *off __unused)
+{
+}
+
+int
+fill_fpregs32(struct thread *td, struct fpreg32 *fpr32)
+{
+ struct fpreg fpr;
+ unsigned i;
+ int error;
+
+ error = fill_fpregs(td, &fpr);
+ if (error != 0)
+ return (error);
+
+ for (i = 0; i < NUMFPREGS; i++) {
+ fpr32->r_regs[i] = fpr.r_regs[i];
+ }
+
+ return (0);
+}
+
+int
+fill_regs32(struct thread *td, struct reg32 *r32)
+{
+ struct reg r;
+ unsigned i;
+ int error;
+
+ error = fill_regs(td, &r);
+ if (error != 0)
+ return (error);
+
+ for (i = 0; i < NUMSAVEREGS; i++) {
+ r32->r_regs[i] = r.r_regs[i];
+ }
+
+ return (0);
+}
+
+int
+set_fpregs32(struct thread *td, struct fpreg32 *fpr32)
+{
+ struct fpreg fpr;
+ unsigned i;
+ int error;
+
+ for (i = 0; i < NUMFPREGS; i++) {
+ fpr.r_regs[i] = fpr32->r_regs[i];
+ }
+
+ error = set_fpregs(td, &fpr);
+ if (error != 0)
+ return (error);
+ return (0);
+}
+
+int
+set_regs32(struct thread *td, struct reg32 *r32)
+{
+ struct reg r;
+ unsigned i;
+ int error;
+
+ for (i = 0; i < NUMSAVEREGS; i++) {
+ r.r_regs[i] = r32->r_regs[i];
+ }
+
+ error = set_regs(td, &r);
+ if (error != 0)
+ return (error);
+ return (0);
+}
+
+int
+fill_dbregs32(struct thread *td, struct dbreg32 *dbr32)
+{
+ return (ENOSYS);
+}
+
+int
+set_dbregs32(struct thread *td, struct dbreg32 *dbr32)
+{
+ return (ENOSYS);
+}
+
+int
+freebsd32_sigreturn(struct thread *td, struct freebsd32_sigreturn_args *uap)
+{
+ struct sigreturn_args sa;
+ int error;
+
+ sa.sigcntxp = (void *)(intptr_t)(int32_t)(intptr_t)uap->sigcntxp;
+
+ error = sigreturn(td, &sa);
+ if (error != 0)
+ return (error);
+ return (0);
+}
+
+int
+freebsd32_getcontext(struct thread *td, struct freebsd32_getcontext_args *uap)
+{
+ struct getcontext_args gca;
+ int error;
+
+ gca.ucp = (void *)(intptr_t)(int32_t)(intptr_t)uap->ucp;
+
+ error = getcontext(td, &gca);
+ if (error != 0)
+ return (error);
+ return (0);
+}
+
+int
+freebsd32_setcontext(struct thread *td, struct freebsd32_setcontext_args *uap)
+{
+ struct setcontext_args sca;
+ int error;
+
+ sca.ucp = (void *)(intptr_t)(int32_t)(intptr_t)uap->ucp;
+
+ error = setcontext(td, &sca);
+ if (error != 0)
+ return (error);
+ return (0);
+}
+
+int
+freebsd32_swapcontext(struct thread *td, struct freebsd32_swapcontext_args *uap)
+{
+ struct swapcontext_args sca;
+ int error;
+
+ sca.ucp = (void *)(intptr_t)(int32_t)(intptr_t)uap->ucp;
+
+ error = swapcontext(td, &sca);
+ if (error != 0)
+ return (error);
+ return (0);
+}
+
+int
+freebsd32_sysarch(struct thread *td, struct freebsd32_sysarch_args *uap)
+{
+ struct sysarch_args saa;
+ int error;
+
+ saa.op = uap->op;
+ saa.parms = (void *)(intptr_t)(int32_t)(intptr_t)uap->parms;
+
+ error = sysarch(td, &saa);
+ if (error != 0)
+ return (error);
+ return (0);
+}
Modified: user/jmallett/octeon/sys/sys/sysctl.h
==============================================================================
--- user/jmallett/octeon/sys/sys/sysctl.h Sat Mar 27 03:17:39 2010 (r205724)
+++ user/jmallett/octeon/sys/sys/sysctl.h Sat Mar 27 04:39:59 2010 (r205725)
@@ -123,7 +123,7 @@ struct ctlname {
#define REQ_WIRED 2 /* locked and wired */
/* definitions for sysctl_req 'flags' member */
-#if defined(__amd64__) || defined(__ia64__)
+#if defined(__amd64__) || defined(__ia64__) || defined(__mips__)
#define SCTL_MASK32 1 /* 32 bit emulation */
#endif
More information about the svn-src-user
mailing list