summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2015-11-13 13:28:41 -0800
committerJulius Werner <jwerner@chromium.org>2015-11-17 21:31:07 +0100
commitd3634c108d63d07ce004a66e3abb05e8da57d65b (patch)
treefaa8038ed49e4041d3eee01c8a2ca1add304b569 /src/include
parent0dc6a1e8987597ce234f2a4f54932219cd5e2480 (diff)
downloadcoreboot-d3634c108d63d07ce004a66e3abb05e8da57d65b.tar.xz
rules.h: Add ENV_ macros to detect current architecture
This patch expands the existing ENV_<stage> macros in <rules.h> with a set of ENV_<arch> macros which can be used to detect which architecture the current compilation unit is built for. These are more consistent than compiler-defined macros (like '#ifdef __arm__') and will make it easier to write small, architecture-dependent differences in common code (where we currently often use IS_ENABLED(CONFIG_ARCH_...), which is technically incorrect in a world where every stage can run on a different architecture, and merely kinda happened to work out for now). Also remove a vestigal <arch/rules.h> from ARM64 which was no longer used, and genericise ARM subarchitecture Makefiles a little to make things like __COREBOOT_ARM_ARCH__ available from all file types (including .ld). BUG=None TEST=Compiled Falco, Blaze, Jerry and Smaug. Change-Id: Id51aeb290b5c215c653e42a51919d0838e28621f Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: http://review.coreboot.org/12433 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Tested-by: Raptor Engineering Automated Test Stand <noreply@raptorengineeringinc.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/rules.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/include/rules.h b/src/include/rules.h
index 315a65e5d1..debb200a06 100644
--- a/src/include/rules.h
+++ b/src/include/rules.h
@@ -94,4 +94,104 @@
#define __SIMPLE_DEVICE__
#endif
+/* Define helpers about the current architecture, based on toolchain.inc. */
+
+#if defined(__ARCH_arm__)
+#define ENV_ARM 1
+#define ENV_ARM64 0
+#if __COREBOOT_ARM_ARCH__ == 4
+#define ENV_ARMV4 1
+#define ENV_ARMV7 0
+#elif __COREBOOT_ARM_ARCH__ == 7
+#define ENV_ARMV4 0
+#define ENV_ARMV7 1
+#else
+#define ENV_ARMV4 0
+#define ENV_ARMV7 0
+#endif
+#define ENV_ARMV8 0
+#define ENV_MIPS 0
+#define ENV_RISCV 0
+#define ENV_X86 0
+#define ENV_X86_32 0
+#define ENV_X86_64 0
+
+#elif defined(__ARCH_arm64__)
+#define ENV_ARM 0
+#define ENV_ARM64 1
+#define ENV_ARMV4 0
+#define ENV_ARMV7 0
+#if __COREBOOT_ARM_ARCH__ == 8
+#define ENV_ARMV8 1
+#else
+#define ENV_ARMV8 0
+#endif
+#define ENV_MIPS 0
+#define ENV_RISCV 0
+#define ENV_X86 0
+#define ENV_X86_32 0
+#define ENV_X86_64 0
+
+#elif defined(__ARCH_mips__)
+#define ENV_ARM 0
+#define ENV_ARM64 0
+#define ENV_ARMV4 0
+#define ENV_ARMV7 0
+#define ENV_ARMV8 0
+#define ENV_MIPS 1
+#define ENV_RISCV 0
+#define ENV_X86 0
+#define ENV_X86_32 0
+#define ENV_X86_64 0
+
+#elif defined(__ARCH_riscv__)
+#define ENV_ARM 0
+#define ENV_ARM64 0
+#define ENV_ARMV4 0
+#define ENV_ARMV7 0
+#define ENV_ARMV8 0
+#define ENV_MIPS 0
+#define ENV_RISCV 1
+#define ENV_X86 0
+#define ENV_X86_32 0
+#define ENV_X86_64 0
+
+#elif defined(__ARCH_x86_32__)
+#define ENV_ARM 0
+#define ENV_ARM64 0
+#define ENV_ARMV4 0
+#define ENV_ARMV7 0
+#define ENV_ARMV8 0
+#define ENV_MIPS 0
+#define ENV_RISCV 0
+#define ENV_X86 1
+#define ENV_X86_32 1
+#define ENV_X86_64 0
+
+#elif defined(__ARCH_x86_64__)
+#define ENV_ARM 0
+#define ENV_ARM64 0
+#define ENV_ARMV4 0
+#define ENV_ARMV7 0
+#define ENV_ARMV8 0
+#define ENV_MIPS 0
+#define ENV_RISCV 0
+#define ENV_X86 1
+#define ENV_X86_32 0
+#define ENV_X86_64 1
+
+#else
+#define ENV_ARM 0
+#define ENV_ARM64 0
+#define ENV_ARMV4 0
+#define ENV_ARMV7 0
+#define ENV_ARMV8 0
+#define ENV_MIPS 0
+#define ENV_RISCV 0
+#define ENV_X86 0
+#define ENV_X86_32 0
+#define ENV_X86_64 0
+
+#endif
+
#endif /* _RULES_H */