From 6c6bdbf60e3d5f044632be88839327692bb961c8 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sat, 6 Dec 2025 14:58:40 -0500 Subject: [PATCH] configure: Revamp MIPS architecture version+revision detection This allows us to easily distinguish between mips32 and mips32r2 (Works at least as far back as gcc 4.9) Change-Id: I2bcba194fd9cbeedf76cea739252271908bf73d0 --- firmware/asm/mips/thread.c | 2 +- firmware/export/config.h | 2 +- tools/configure | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/firmware/asm/mips/thread.c b/firmware/asm/mips/thread.c index 37480da10a..a543f3a348 100644 --- a/firmware/asm/mips/thread.c +++ b/firmware/asm/mips/thread.c @@ -1,4 +1,4 @@ -#if CPU_MIPS == 32 +#if (CPU_MIPS == 32) || (CPU_MIPS == 32r2) #include "thread-mips32.c" #else #error Missing thread impl diff --git a/firmware/export/config.h b/firmware/export/config.h index 8fd1e8c0c6..5e4994e137 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -729,7 +729,7 @@ Lyre prototype 1 */ #endif #if ARCH == ARCH_MIPS -#define CPU_MIPS ARCH_VERSION /* 32, 64 */ +#define CPU_MIPS ARCH_VERSION /* 32, 32r2, 64 */ #endif #endif /*__PCTOOL__*/ diff --git a/tools/configure b/tools/configure index a6109cd43c..654bdab807 100755 --- a/tools/configure +++ b/tools/configure @@ -4784,7 +4784,11 @@ if [ -z "$arch" ]; then esac elif [ -n "$(echo $cpp_defines | grep -w __mips__)" ]; then arch="mips" - arch_version="$(echo $cpp_defines | tr ' ' '\012' | grep _MIPS_ARCH_MIPS | sed -e 's,.*\([0-9][0-9]\).*,\1,' | grep -v _MIPS_ARCH_MIPS)" + arch_version="$(echo "$cpp_defines" | grep 'define __mips ' | sed -e 's,.* \([0-9]\+\).*,\1,')" + arch_revision="$(echo "$cpp_defines" | grep 'define __mips_isa_rev ' | sed -e 's,.* \([0-9]\+\).*,\1,')" + if [ -n "$arch_revision" ] ; then + arch_version="${arch_version}r${arch_revision}" + fi elif [ -n "$(echo $cpp_defines | grep -w __i386__)" ]; then arch="x86" elif [ -n "$(echo $cpp_defines | grep -w __x86_64__)" ]; then