Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm Switch earmv6{,hf}eb to BE8 in kernel side.
details: https://anonhg.NetBSD.org/src/rev/d10212441f98
branches: trunk
changeset: 946548:d10212441f98
user: rin <rin%NetBSD.org@localhost>
date: Tue Dec 01 02:43:13 2020 +0000
description:
Switch earmv6{,hf}eb to BE8 in kernel side.
My strategy here is to define _ARM_ARCH_BE8 macro in arm/cdefs.h, if
__ARMEB__ && _ARM_ARCH_6.
Use this macro to determine whether system is compiled for and running on
BE8 mode or not.
Note that, for __ARMEB__, some conditions become compile-time constants
determined by _ARM_ARCH_BE8 macro, e.g., whether BE8 or BE32 are accepted
as a userland binary, or unaligned memory access is possible or not.
diffstat:
sys/arch/arm/arm/arm_machdep.c | 17 ++++++++---------
sys/arch/arm/arm/cpu_exec.c | 20 +++++++++++++++-----
sys/arch/arm/arm32/arm32_boot.c | 9 ++++-----
sys/arch/arm/arm32/arm32_machdep.c | 18 ++++++++++++------
sys/arch/arm/arm32/kobj_machdep.c | 10 +++++-----
sys/arch/arm/include/cdefs.h | 6 +++++-
6 files changed, 49 insertions(+), 31 deletions(-)
diffs (224 lines):
diff -r e8570263e861 -r d10212441f98 sys/arch/arm/arm/arm_machdep.c
--- a/sys/arch/arm/arm/arm_machdep.c Tue Dec 01 02:39:48 2020 +0000
+++ b/sys/arch/arm/arm/arm_machdep.c Tue Dec 01 02:43:13 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_machdep.c,v 1.64 2020/08/14 16:18:36 skrll Exp $ */
+/* $NetBSD: arm_machdep.c,v 1.65 2020/12/01 02:43:13 rin Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
#include <sys/param.h>
-__KERNEL_RCSID(0, "$NetBSD: arm_machdep.c,v 1.64 2020/08/14 16:18:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_machdep.c,v 1.65 2020/12/01 02:43:13 rin Exp $");
#include <sys/atomic.h>
#include <sys/cpu.h>
@@ -176,15 +176,14 @@
tf->tf_usr_lr = pack->ep_entry;
tf->tf_svc_lr = 0x77777777; /* Something we can see */
tf->tf_pc = pack->ep_entry;
-#if defined(__ARMEB__)
+ tf->tf_spsr = PSR_USR32_MODE;
+#ifdef _ARM_ARCH_BE8
/*
- * If we are running on ARMv7, we need to set the E bit to force
- * programs to start as big endian.
+ * If we are running on BE8 mode, we need to set the E bit to
+ * force programs to start as big endian.
*/
- tf->tf_spsr = PSR_USR32_MODE | (CPU_IS_ARMV7_P() ? PSR_E_BIT : 0);
-#else
- tf->tf_spsr = PSR_USR32_MODE;
-#endif /* __ARMEB__ */
+ tf->tf_spsr |= PSR_E_BIT;
+#endif
#ifdef THUMB_CODE
if (pack->ep_entry & 1)
diff -r e8570263e861 -r d10212441f98 sys/arch/arm/arm/cpu_exec.c
--- a/sys/arch/arm/arm/cpu_exec.c Tue Dec 01 02:39:48 2020 +0000
+++ b/sys/arch/arm/arm/cpu_exec.c Tue Dec 01 02:43:13 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_exec.c,v 1.12 2020/11/12 01:03:22 rin Exp $ */
+/* $NetBSD: cpu_exec.c,v 1.13 2020/12/01 02:43:13 rin Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_exec.c,v 1.12 2020/11/12 01:03:22 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_exec.c,v 1.13 2020/12/01 02:43:13 rin Exp $");
#include "opt_compat_netbsd.h"
@@ -72,8 +72,11 @@
* If the BE-8 model is supported, CPSR[7] will be clear.
* If the BE-32 model is supported, CPSR[7] will be set.
*/
- register_t ctl = armreg_sctlr_read();
- if (((ctl & CPU_CONTROL_BEND_ENABLE) != 0) == be8_p)
+#ifdef _ARM_ARCH_BE8
+ if (!be8_p)
+#else
+ if (be8_p)
+#endif
return ENOEXEC;
#endif /* __ARMEB__ */
@@ -111,7 +114,14 @@
* If we are AAPCS (EABI) and armv6/armv7, we want alignment faults
* to be off.
*/
- if (aapcs_p && (CPU_IS_ARMV7_P() || CPU_IS_ARMV6_P())) {
+#if defined(__ARMEL__)
+ if (aapcs_p && (CPU_IS_ARMV7_P() || CPU_IS_ARMV6_P()))
+#elif defined(_ARM_ARCH_BE8)
+ if (aapcs_p)
+#else
+ if (false /* CONSTCOND */)
+#endif
+ {
l->l_md.md_flags |= MDLWP_NOALIGNFLT;
} else {
l->l_md.md_flags &= ~MDLWP_NOALIGNFLT;
diff -r e8570263e861 -r d10212441f98 sys/arch/arm/arm32/arm32_boot.c
--- a/sys/arch/arm/arm32/arm32_boot.c Tue Dec 01 02:39:48 2020 +0000
+++ b/sys/arch/arm/arm32/arm32_boot.c Tue Dec 01 02:43:13 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arm32_boot.c,v 1.40 2020/09/11 06:40:25 skrll Exp $ */
+/* $NetBSD: arm32_boot.c,v 1.41 2020/12/01 02:43:14 rin Exp $ */
/*
* Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
@@ -122,7 +122,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.40 2020/09/11 06:40:25 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.41 2020/12/01 02:43:14 rin Exp $");
#include "opt_arm_debug.h"
#include "opt_cputypes.h"
@@ -191,10 +191,9 @@
memset(tf, 0, sizeof(*tf));
lwp_settrapframe(l, tf);
-#if defined(__ARMEB__)
- tf->tf_spsr = PSR_USR32_MODE | (CPU_IS_ARMV7_P() ? PSR_E_BIT : 0);
-#else
tf->tf_spsr = PSR_USR32_MODE;
+#ifdef _ARM_ARCH_BE8
+ tf->tf_spsr |= PSR_E_BIT;
#endif
VPRINTF("bootstrap done.\n");
diff -r e8570263e861 -r d10212441f98 sys/arch/arm/arm32/arm32_machdep.c
--- a/sys/arch/arm/arm32/arm32_machdep.c Tue Dec 01 02:39:48 2020 +0000
+++ b/sys/arch/arm/arm32/arm32_machdep.c Tue Dec 01 02:43:13 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arm32_machdep.c,v 1.138 2020/10/30 18:54:36 skrll Exp $ */
+/* $NetBSD: arm32_machdep.c,v 1.139 2020/12/01 02:43:14 rin Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.138 2020/10/30 18:54:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.139 2020/12/01 02:43:14 rin Exp $");
#include "opt_arm_debug.h"
#include "opt_arm_start.h"
@@ -348,10 +348,9 @@
memset(tf, 0, sizeof(*tf));
lwp_settrapframe(l, tf);
-#if defined(__ARMEB__)
- tf->tf_spsr = PSR_USR32_MODE | (CPU_IS_ARMV7_P() ? PSR_E_BIT : 0);
-#else
tf->tf_spsr = PSR_USR32_MODE;
+#ifdef _ARM_ARCH_BE8
+ tf->tf_spsr |= PSR_E_BIT;
#endif
cpu_startup_hook();
@@ -538,7 +537,14 @@
CTLTYPE_INT, "printfataltraps", NULL,
NULL, 0, &cpu_printfataltraps, 0,
CTL_MACHDEP, CTL_CREATE, CTL_EOL);
- cpu_unaligned_sigbus = !CPU_IS_ARMV6_P() && !CPU_IS_ARMV7_P();
+ cpu_unaligned_sigbus =
+#if defined(__ARMEL__)
+ !CPU_IS_ARMV6_P() && !CPU_IS_ARMV7_P();
+#elif defined(_ARM_ARCH_BE8)
+ 0;
+#else
+ 1;
+#endif
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_READONLY,
CTLTYPE_INT, "unaligned_sigbus",
diff -r e8570263e861 -r d10212441f98 sys/arch/arm/arm32/kobj_machdep.c
--- a/sys/arch/arm/arm32/kobj_machdep.c Tue Dec 01 02:39:48 2020 +0000
+++ b/sys/arch/arm/arm32/kobj_machdep.c Tue Dec 01 02:43:13 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kobj_machdep.c,v 1.14 2020/06/20 07:10:36 skrll Exp $ */
+/* $NetBSD: kobj_machdep.c,v 1.15 2020/12/01 02:43:14 rin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.14 2020/06/20 07:10:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.15 2020/12/01 02:43:14 rin Exp $");
#define ELFSIZE ARCH_ELFSIZE
@@ -209,7 +209,7 @@
return -1;
}
-#if __ARMEB__
+#ifdef _ARM_ARCH_BE8
enum be8_magic_sym_type {
Other, ArmStart, ThumbStart, DataStart
@@ -400,8 +400,8 @@
{
if (load) {
-#if __ARMEB__
- if (CPU_IS_ARMV7_P() && base == (void*)ko->ko_text_address)
+#ifdef _ARM_ARCH_BE8
+ if (base == (void*)ko->ko_text_address)
kobj_be8_fixup(ko);
#endif
#ifndef _RUMPKERNEL
diff -r e8570263e861 -r d10212441f98 sys/arch/arm/include/cdefs.h
--- a/sys/arch/arm/include/cdefs.h Tue Dec 01 02:39:48 2020 +0000
+++ b/sys/arch/arm/include/cdefs.h Tue Dec 01 02:43:13 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cdefs.h,v 1.18 2020/11/03 08:34:17 skrll Exp $ */
+/* $NetBSD: cdefs.h,v 1.19 2020/12/01 02:43:14 rin Exp $ */
#ifndef _ARM_CDEFS_H_
#define _ARM_CDEFS_H_
@@ -55,6 +55,10 @@
#define _ARM_ARCH_DWORD_OK
#endif
+#if defined (__ARMEB__) && defined (_ARM_ARCH_6)
+#define _ARM_ARCH_BE8
+#endif
+
#if defined(__ARM_PCS_AAPCS64)
#define __ALIGNBYTES (sizeof(__int128_t) - 1)
#elif defined(__ARM_EABI__)
Home |
Main Index |
Thread Index |
Old Index