Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm COMPAT_NETBSD32 support for ARM. Which is stra...
details: https://anonhg.NetBSD.org/src/rev/f2478c57902d
branches: trunk
changeset: 780674:f2478c57902d
user: matt <matt%NetBSD.org@localhost>
date: Fri Aug 03 07:59:22 2012 +0000
description:
COMPAT_NETBSD32 support for ARM. Which is strange since ARM is already
32-bits. But the newer ARM ABI AAPCS changes the alignment of 64-bit
fields so structures need to copied in and out to deal with the alignment
change. This is a kludge but makes debugging of AAPCS support much easier.
diffstat:
sys/arch/arm/arm/cpu_exec.c | 93 +++++++++++++++++++++++++++++++
sys/arch/arm/arm32/netbsd32_machdep.c | 96 +++++++++++++++++++++++++++++++++
sys/arch/arm/arm32/vm_machdep.c | 9 +-
sys/arch/arm/conf/files.arm | 7 ++-
sys/arch/arm/include/elf_machdep.h | 18 +++++-
sys/arch/arm/include/mcontext.h | 4 +-
sys/arch/arm/include/netbsd32_machdep.h | 69 +++++++++++++++++++++++
sys/arch/arm/include/param.h | 3 +-
sys/arch/arm/include/types.h | 4 +-
9 files changed, 292 insertions(+), 11 deletions(-)
diffs (truncated from 412 to 300 lines):
diff -r a2b25673d5dc -r f2478c57902d sys/arch/arm/arm/cpu_exec.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/arm/cpu_exec.c Fri Aug 03 07:59:22 2012 +0000
@@ -0,0 +1,93 @@
+/* $NetBSD: cpu_exec.c,v 1.1 2012/08/03 07:59:22 matt Exp $ */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * 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: cpu_exec.c,v 1.1 2012/08/03 07:59:22 matt Exp $");
+
+#include "opt_compat_netbsd.h"
+#include "opt_compat_netbsd32.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/exec.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <compat/common/compat_util.h>
+#include <sys/exec_elf.h> /* mandatory */
+
+#ifdef COMPAT_NETBSD32
+#include <compat/netbsd32/netbsd32_exec.h>
+#endif
+
+#if EXEC_ELF32
+int
+arm_netbsd_elf32_probe(struct lwp *l, struct exec_package *epp, void *eh0,
+ char *itp, vaddr_t *start_p)
+{
+ const char *itp_suffix = NULL;
+ const bool elf_aapcs_p = (epp->ep_flags & EXEC_ARM_AAPCS) != 0;
+#ifdef COMPAT_NETBSD32
+ const bool netbsd32_p = (epp->ep_esch->es_emul == &emul_netbsd32);
+#else
+ const bool netbsd32_p = false;
+#endif
+#ifdef __ARM_EABI__
+ const bool aapcs_p = true;
+#else
+ const bool aapcs_p = false;
+#endif
+
+ /*
+ * This is subtle. If are netbsd32, then we don't want to match the
+ * same ABI as the kernel. If we aren't (netbsd32 == false), then we
+ * don't want to be different from the kernel's ABI.
+ * true true true ENOEXEC
+ * true false true 0
+ * true true false 0
+ * true false false ENOEXEC
+ * false true true 0
+ * false false true ENOEXEC
+ * false true false ENOEXEC
+ * false false false 0
+ */
+ if (netbsd32_p ^ elf_aapcs_p ^ aapcs_p)
+ return ENOEXEC;
+
+ if (netbsd32_p)
+ itp_suffix = (elf_aapcs_p) ? "eabi" : "apcs32";
+
+ if (itp_suffix != NULL)
+ (void)compat_elf_check_interp(epp, itp, itp_suffix);
+ return 0;
+}
+#endif
diff -r a2b25673d5dc -r f2478c57902d sys/arch/arm/arm32/netbsd32_machdep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/arm32/netbsd32_machdep.c Fri Aug 03 07:59:22 2012 +0000
@@ -0,0 +1,96 @@
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * 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(1, "$NetBSD: netbsd32_machdep.c,v 1.1 2012/08/03 07:59:22 matt Exp $");
+
+#include <sys/param.h>
+#include <sys/core.h>
+#include <sys/exec.h>
+#include <sys/lwp.h>
+#include <sys/signalvar.h>
+#include <sys/syscallargs.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <compat/netbsd32/netbsd32.h>
+#include <compat/netbsd32/netbsd32_exec.h>
+#include <compat/netbsd32/netbsd32_syscallargs.h>
+
+const char machine32[] = MACHINE;
+const char machine_arch32[] = MACHINE_ARCH;
+
+int
+cpu_coredump32(struct lwp *l, void *iocookie, struct core32 *chdr)
+{
+ return cpu_coredump(l, iocookie, (struct core *)chdr);
+}
+
+void
+netbsd32_sendsig (const ksiginfo_t *ksi, const sigset_t *ss)
+{
+ sendsig(ksi, ss);
+}
+
+void
+startlwp32(void *arg)
+{
+ startlwp(arg);
+}
+
+int
+cpu_mcontext32_validate(struct lwp *l, const mcontext32_t *mcp)
+{
+ return cpu_mcontext_validate(l, mcp);
+}
+void
+cpu_getmcontext32(struct lwp *l, mcontext32_t *mcp, unsigned int *flagsp)
+{
+ cpu_getmcontext(l, mcp, flagsp);
+}
+
+int
+cpu_setmcontext32(struct lwp *l, const mcontext32_t *mcp, unsigned int flags)
+{
+ return cpu_setmcontext(l, mcp, flags);
+}
+
+int
+netbsd32_sysarch(struct lwp *l, const struct netbsd32_sysarch_args *uap,
+ register_t *retval)
+{
+ return sys_sysarch(l, (const struct sys_sysarch_args *)uap, retval);
+}
+
+vaddr_t
+netbsd32_vm_default_addr(struct proc *p, vaddr_t base, vsize_t size)
+{
+ return VM_DEFAULT_ADDRESS(base, size);
+}
diff -r a2b25673d5dc -r f2478c57902d sys/arch/arm/arm32/vm_machdep.c
--- a/sys/arch/arm/arm32/vm_machdep.c Fri Aug 03 07:56:37 2012 +0000
+++ b/sys/arch/arm/arm32/vm_machdep.c Fri Aug 03 07:59:22 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.56 2012/02/19 21:06:05 rmind Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.57 2012/08/03 07:59:22 matt Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.56 2012/02/19 21:06:05 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.57 2012/08/03 07:59:22 matt Exp $");
#include "opt_armfpe.h"
#include "opt_pmap_debug.h"
@@ -184,10 +184,11 @@
*tf = *pcb1->pcb_tf;
/*
- * If specified, give the child a different stack.
+ * If specified, give the child a different stack (make sure
+ * it's 8-byte aligned).
*/
if (stack != NULL)
- tf->tf_usr_sp = (u_int)stack + stacksize;
+ tf->tf_usr_sp = ((vaddr_t)(stack) + stacksize) & -8;
sf = (struct switchframe *)tf - 1;
sf->sf_r4 = (u_int)func;
diff -r a2b25673d5dc -r f2478c57902d sys/arch/arm/conf/files.arm
--- a/sys/arch/arm/conf/files.arm Fri Aug 03 07:56:37 2012 +0000
+++ b/sys/arch/arm/conf/files.arm Fri Aug 03 07:59:22 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.arm,v 1.106 2012/07/21 12:19:15 skrll Exp $
+# $NetBSD: files.arm,v 1.107 2012/08/03 07:59:22 matt Exp $
# temporary define to allow easy moving to ../arch/arm/arm32
defflag ARM32
@@ -150,6 +150,7 @@
cpu_cortex
file arch/arm/arm/cpufunc_asm_ixp12x0.S cpu_ixp12x0
file arch/arm/arm/cpufunc_asm_sheeva.S cpu_sheeva
+file arch/arm/arm/cpu_exec.c
file arch/arm/arm/fusu.S
file arch/arm/arm/idle_machdep.c
file arch/arm/arm/lock_cas.S
@@ -187,6 +188,10 @@
# arm32 library functions
file arch/arm/arm32/bcopy_page.S arm32
+#
+include "compat/netbsd32/files.netbsd32"
+file arch/arm/arm32/netbsd32_machdep.c arm32 & compat_netbsd32
+
# Linux binary compatibility (COMPAT_LINUX)
include "compat/ossaudio/files.ossaudio"
include "compat/linux/files.linux"
diff -r a2b25673d5dc -r f2478c57902d sys/arch/arm/include/elf_machdep.h
--- a/sys/arch/arm/include/elf_machdep.h Fri Aug 03 07:56:37 2012 +0000
+++ b/sys/arch/arm/include/elf_machdep.h Fri Aug 03 07:59:22 2012 +0000
@@ -1,4 +1,7 @@
-/* $NetBSD: elf_machdep.h,v 1.8 2009/05/30 05:56:52 skrll Exp $ */
+/* $NetBSD: elf_machdep.h,v 1.9 2012/08/03 07:59:23 matt Exp $ */
+
+#ifndef _ARM_ELF_MACHDEP_H_
+#define _ARM_ELF_MACHDEP_H_
#if defined(__ARMEB__)
#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB
@@ -115,3 +118,16 @@
/* Processor specific symbol types */
#define STT_ARM_TFUNC STT_LOPROC
+
+#ifdef _KERNEL
+#ifdef ELFSIZE
+#define ELF_MD_PROBE_FUNC ELFNAME2(arm_netbsd,probe)
+#endif
+
+struct exec_package;
+
+int arm_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *,
+ vaddr_t *);
+#endif
+
+#endif /* _ARM_ELF_MACHDEP_H_ */
diff -r a2b25673d5dc -r f2478c57902d sys/arch/arm/include/mcontext.h
--- a/sys/arch/arm/include/mcontext.h Fri Aug 03 07:56:37 2012 +0000
+++ b/sys/arch/arm/include/mcontext.h Fri Aug 03 07:59:22 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.10 2012/02/13 17:07:45 matt Exp $ */
+/* $NetBSD: mcontext.h,v 1.11 2012/08/03 07:59:23 matt Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
__vfpregset_t __vfpregs;
} __fpu;
__greg_t _mc_tlsbase;
-} mcontext_t;
Home |
Main Index |
Thread Index |
Old Index