From afe128f4cc19d61e5d67930ca4b0846d488720b7 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Thu, 4 Dec 2025 20:20:35 -0500 Subject: [PATCH] arm: Profile/variation detection improvements * Detection of 64-bit Arm v8-a * Proper detection of integer division support * always on v7-m, v8-a, v9-a, v8-m.main * sometimes on v7-a, v7-r, v8-r * never on v8-m.base v6-m, v6 and older "classic" * tl;dr: Rely on toolchain preprocessor definition For the most part these additional variations won't acutally work for native target builds, but sane -A detection is needed for "local" builds now. -R detection is left out as it's not likely to matter. Change-Id: I8f6a52edc4d14490fc00e2f487406eca701eef02 --- firmware/export/config.h | 13 ++-- .../codecs/libwmavoice/libavutil/bswap.h | 2 - tools/configure | 31 ++++++-- utils/mks5lboot/dualboot/autoconf.h | 74 ------------------- 4 files changed, 30 insertions(+), 90 deletions(-) delete mode 100644 utils/mks5lboot/dualboot/autoconf.h diff --git a/firmware/export/config.h b/firmware/export/config.h index 168334228a..8fd1e8c0c6 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -711,21 +711,18 @@ Lyre prototype 1 */ /* define for all cpus from ARM family */ #if ARCH == ARCH_ARM #define CPU_ARM -#define ARM_ARCH ARCH_VERSION /* ARMv{4,5,6,7} */ -#define ARM_PROFILE ARCH_PROFILE /* Classic, Microcontroller */ +#define ARM_ARCH ARCH_VERSION /* ARMv{4,5,6,7,8,9} */ +#define ARM_PROFILE ARCH_PROFILE /* Classic, Microcontroller, Application [,Realtime] */ # if ARM_PROFILE == ARM_PROFILE_MICRO # define CPU_ARM_MICRO -# if (ARM_ARCH >= 7) -# define ARM_HAVE_HW_DIV -# endif # elif ARM_PROFILE == ARM_PROFILE_CLASSIC # define CPU_ARM_CLASSIC # elif ARM_PROFILE == ARM_PROFILE_APPLICATION # define CPU_ARM_APPLICATION -# if defined(__ARM_FEATURE_IDIV) // Some v7-a, all v8-a -# define ARM_HAVE_HW_DIV -# endif # endif +#if defined(__ARM_FEATURE_IDIV) +# define ARM_HAVE_HW_DIV +#endif # if (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(ARM_HAVE_HW_DIV) # define ARM_NEED_DIV0 # endif diff --git a/lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h b/lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h index 303bcf3532..7679fef67a 100644 --- a/lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h +++ b/lib/rbcodec/codecs/libwmavoice/libavutil/bswap.h @@ -40,8 +40,6 @@ # include "avr32/bswap.h" #elif ARCH_BFIN # include "bfin/bswap.h" -#elif ARCH_SH4 -# include "sh4/bswap.h" #elif ARCH_X86 # include "x86/bswap.h" #endif diff --git a/tools/configure b/tools/configure index 43356cfd93..571cc8de6b 100755 --- a/tools/configure +++ b/tools/configure @@ -4760,11 +4760,30 @@ if [ -z "$arch" ]; then ;; *) # On classic ARM we expect an empty string, so only warn if it's nonempty - if [ -n "$arch_profile" ]; then - echo "Warning: Cannot determine target ARM profile, assuming classic" + if [ -z "$arch_profile" ]; then + arch_profile=classic + else + echo "Error: Unsupported target ARM profile ($arch_profile)" + exit 1 fi - - arch_profile=classic + ;; + esac + elif [ -n "$(echo $cpp_defines | grep -w __aarch64__)" ]; then + arch="arm64" + # cpp defines like "#define __ARM_ARCH_8A__ 1" (where we want to extract the 8) + arch_version="$(echo $cpp_defines | tr ' ' '\012' | grep __ARM_ARCH | sed -e 's,.*\([0-9]\).*,\1,' | grep -v __ARM_ARCH | head -1)" + arch_profile="$(echo "$cpp_defines" | grep 'define __ARM_ARCH_PROFILE' | sed -e 's,.* \([0-9]\+\)$,\1,')" + if test "$gccnum" -ge "800"; then + # GCC8+ can natively emit unified asm syntax + GCCOPTS="$GCCOPTS -masm-syntax-unified" + fi + case "$arch_profile" in + 65) # Cortex-A + arch_profile=application + ;; + *) + echo "Error: Unsupported target AARCH64 profile ($arch_profile)" + exit 1 ;; esac elif [ -n "$(echo $cpp_defines | grep -w __mips__)" ]; then @@ -4840,8 +4859,8 @@ cat > autoconf.h.new < ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id:$ - * - * Copyright (C) 2012 by Andrew Ryabinin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef __BUILD_AUTOCONF_H -#define __BUILD_AUTOCONF_H - -/* lower case names match the what's exported in the Makefile - * upper case name looks nicer in the code */ - -#define arch_none 0 -#define ARCH_NONE 0 - -#define arch_sh 1 -#define ARCH_SH 1 - -#define arch_m68k 2 -#define ARCH_M68K 2 - -#define arch_arm 3 -#define ARCH_ARM 3 - -#define arch_mips 4 -#define ARCH_MIPS 4 - -#define arch_x86 5 -#define ARCH_X86 5 - -#define arch_amd64 6 -#define ARCH_AMD64 6 - -/* Define target machine architecture */ -#define ARCH arch_arm -/* Optionally define architecture version */ -#define ARCH_VERSION 5 - -/* Define endianess for the target or simulator platform */ -#define ROCKBOX_LITTLE_ENDIAN 1 - -/* Define this if you build rockbox to support the logf logging and display */ -#undef ROCKBOX_HAS_LOGF - -/* Define this if you want logf to output to the serial port */ -#undef LOGF_SERIAL - -/* Define this to record a chart with timings for the stages of boot */ -#undef DO_BOOTCHART - -/* the threading backend we use */ -#define ASSEMBLER_THREADS - -/* root of Rockbox */ -#define ROCKBOX_DIR "/.rockbox" -#define ROCKBOX_SHARE_PATH "" -#define ROCKBOX_BINARY_PATH "" -#define ROCKBOX_LIBRARY_PATH "" - -#endif /* __BUILD_AUTOCONF_H */