@@ -16,29 +16,6 @@ NAME =
# (this increases performance and avoids hard-to-debug behaviour)
MAKEFLAGS += -rR
-# Determine target architecture for the sandbox
-include include/host_arch.h
-ifeq ("", "$(CROSS_COMPILE)")
- MK_ARCH="${shell uname -m}"
-else
- MK_ARCH="${shell echo $(CROSS_COMPILE) | sed -n 's/^[[:space:]]*\([^\/]*\/\)*\([^-]*\)-[^[:space:]]*/\2/p'}"
-endif
-unexport HOST_ARCH
-ifeq ("x86_64", $(MK_ARCH))
- export HOST_ARCH=$(HOST_ARCH_X86_64)
-else ifneq (,$(findstring $(MK_ARCH), "i386" "i486" "i586" "i686"))
- export HOST_ARCH=$(HOST_ARCH_X86)
-else ifneq (,$(findstring $(MK_ARCH), "aarch64" "armv8l"))
- export HOST_ARCH=$(HOST_ARCH_AARCH64)
-else ifneq (,$(findstring $(MK_ARCH), "arm" "armv7" "armv7a" "armv7l"))
- export HOST_ARCH=$(HOST_ARCH_ARM)
-else ifeq ("riscv32", $(MK_ARCH))
- export HOST_ARCH=$(HOST_ARCH_RISCV32)
-else ifeq ("riscv64", $(MK_ARCH))
- export HOST_ARCH=$(HOST_ARCH_RISCV64)
-endif
-undefine MK_ARCH
-
# Avoid funny character set dependencies
unexport LC_ALL
LC_COLLATE=C
@@ -1963,7 +1940,6 @@ define filechk_version.h
echo \#define U_BOOT_VERSION_NUM $(VERSION); \
echo \#define U_BOOT_VERSION_NUM_PATCH $$(echo $(PATCHLEVEL) | \
sed -e "s/^0*//"); \
- echo \#define HOST_ARCH $(HOST_ARCH); \
echo \#define CC_VERSION_STRING \"$$(LC_ALL=C $(CC) --version | head -n 1)\"; \
echo \#define LD_VERSION_STRING \"$$(LC_ALL=C $(LD) --version | head -n 1)\"; )
endef
@@ -47,6 +47,29 @@ config HOST_32BIT
config HOST_64BIT
def_bool $(cc-define,_LP64)
+config HOST_ARCH_X86
+ def_bool $(cc-define,__i386__)
+
+config HOST_ARCH_X86_64
+ def_bool $(cc-define,__x86_64__)
+
+config HOST_ARCH_ARM
+ def_bool $(cc-define,__arm__)
+
+config HOST_ARCH_AARCH64
+ def_bool $(cc-define,__aarch64__)
+
+config HOST_ARCH_RISCV32
+ def_bool $(cc-define,__riscv_xlen 32)
+
+config HOST_ARCH_RISCV64
+ def_bool $(cc-define,__riscv_xlen 64)
+
+config HOST_ARCH_UNKNOWN
+ def_bool !HOST_ARCH_X86 && !HOST_ARCH_X86_64 && \
+ !HOST_ARCH_ARM && !HOST_ARCH_AARCH64 && \
+ !HOST_ARCH_RISCV32 && !HOST_ARCH_RISCV64
+
config HOST_HAS_SDL
def_bool $(success,sdl2-config --version)
@@ -44,27 +44,27 @@ cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \
-Wl,--no-whole-archive \
$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections)
-ifeq ($(HOST_ARCH),$(HOST_ARCH_X86_64))
+ifeq ($(CONFIG_HOST_ARCH_X86_64),y)
EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_x86_64_efi.lds
EFI_TARGET := --target=efi-app-x86_64
-else ifeq ($(HOST_ARCH),$(HOST_ARCH_X86))
+else ifeq ($(CONFIG_HOST_ARCH_X86),y)
EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_ia32_efi.lds
EFI_TARGET := --target=efi-app-ia32
-else ifeq ($(HOST_ARCH),$(HOST_ARCH_AARCH64))
+else ifeq ($(CONFIG_HOST_ARCH_AARCH64),y)
EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_aarch64_efi.lds
OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
-j __u_boot_list -j .rela.dyn -j .got -j .got.plt \
-j .binman_sym_table -j .text_rest \
-j .efi_runtime -j .efi_runtime_rel
-else ifeq ($(HOST_ARCH),$(HOST_ARCH_ARM))
+else ifeq ($(CONFIG_HOST_ARCH_ARM),y)
EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_arm_efi.lds
OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
-j .data -j .got -j .got.plt -j __u_boot_list -j .rel.dyn \
-j .binman_sym_table -j .text_rest \
-j .efi_runtime -j .efi_runtime_rel
-else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV32))
+else ifeq ($(CONFIG_HOST_ARCH_RISCV32),y)
EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv32_efi.lds
-else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV64))
+else ifeq ($(CONFIG_HOST_ARCH_RISCV64),y)
EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv64_efi.lds
endif
EFI_CRT0 := crt0_sandbox_efi.o
@@ -5,28 +5,28 @@
* Copyright (c) 2019 Heinrich Schuchardt
*/
-#include <host_arch.h>
+#include <config.h>
-#if HOST_ARCH == HOST_ARCH_X86_64
+#if CONFIG_IS_ENABLED(HOST_ARCH_X86_64)
#include "../../../arch/x86/lib/crt0_x86_64_efi.S"
#endif
-#if HOST_ARCH == HOST_ARCH_X86
+#if CONFIG_IS_ENABLED(HOST_ARCH_X86)
#include "../../../arch/x86/lib/crt0_ia32_efi.S"
#endif
-#if HOST_ARCH == HOST_ARCH_AARCH64
+#if CONFIG_IS_ENABLED(HOST_ARCH_AARCH64)
#include "../../../arch/arm/lib/crt0_aarch64_efi.S"
#endif
-#if HOST_ARCH == HOST_ARCH_ARM
+#if CONFIG_IS_ENABLED(HOST_ARCH_ARM)
#include "../../../arch/arm/lib/crt0_arm_efi.S"
#endif
-#if HOST_ARCH == HOST_ARCH_RISCV32
+#if CONFIG_IS_ENABLED(HOST_ARCH_RISCV32)
#include "../../../arch/riscv/lib/crt0_riscv_efi.S"
#endif
-#if HOST_ARCH == HOST_ARCH_RISCV64
+#if CONFIG_IS_ENABLED(HOST_ARCH_RISCV64)
#include "../../../arch/riscv/lib/crt0_riscv_efi.S"
#endif
@@ -5,28 +5,28 @@
* Copyright (c) 2019 Heinrich Schuchardt
*/
-#include <host_arch.h>
+#include <config.h>
-#if HOST_ARCH == HOST_ARCH_X86_64
+#if CONFIG_IS_ENABLED(HOST_ARCH_X86_64)
#include "../../../arch/x86/lib/reloc_x86_64_efi.c"
#endif
-#if HOST_ARCH == HOST_ARCH_X86
+#if CONFIG_IS_ENABLED(HOST_ARCH_X86)
#include "../../../arch/x86/lib/reloc_ia32_efi.c"
#endif
-#if HOST_ARCH == HOST_ARCH_AARCH64
+#if CONFIG_IS_ENABLED(HOST_ARCH_AARCH64)
#include "../../../arch/arm/lib/reloc_aarch64_efi.c"
#endif
-#if HOST_ARCH == HOST_ARCH_ARM
+#if CONFIG_IS_ENABLED(HOST_ARCH_ARM)
#include "../../../arch/arm/lib/reloc_arm_efi.c"
#endif
-#if HOST_ARCH == HOST_ARCH_RISCV32
+#if CONFIG_IS_ENABLED(HOST_ARCH_RISCV32)
#include "../../../arch/riscv/lib/reloc_riscv_efi.c"
#endif
-#if HOST_ARCH == HOST_ARCH_RISCV64
+#if CONFIG_IS_ENABLED(HOST_ARCH_RISCV64)
#include "../../../arch/riscv/lib/reloc_riscv_efi.c"
#endif
@@ -11,23 +11,23 @@
#ifndef _EFI_DEFAULT_FILENAME_H
#define _EFI_DEFAULT_FILENAME_H
-#include <host_arch.h>
+#include <config.h>
#undef BOOTEFI_NAME
#ifdef CONFIG_SANDBOX
-#if HOST_ARCH == HOST_ARCH_X86_64
+#if CONFIG_IS_ENABLED(HOST_ARCH_X86_64)
#define BOOTEFI_NAME "BOOTX64.EFI"
-#elif HOST_ARCH == HOST_ARCH_X86
+#elif CONFIG_IS_ENABLED(HOST_ARCH_X86)
#define BOOTEFI_NAME "BOOTIA32.EFI"
-#elif HOST_ARCH == HOST_ARCH_AARCH64
+#elif CONFIG_IS_ENABLED(HOST_ARCH_AARCH64)
#define BOOTEFI_NAME "BOOTAA64.EFI"
-#elif HOST_ARCH == HOST_ARCH_ARM
+#elif CONFIG_IS_ENABLED(HOST_ARCH_ARM)
#define BOOTEFI_NAME "BOOTARM.EFI"
-#elif HOST_ARCH == HOST_ARCH_RISCV32
+#elif CONFIG_IS_ENABLED(HOST_ARCH_RISCV32)
#define BOOTEFI_NAME "BOOTRISCV32.EFI"
-#elif HOST_ARCH == HOST_ARCH_RISCV64
+#elif CONFIG_IS_ENABLED(HOST_ARCH_RISCV64)
#define BOOTEFI_NAME "BOOTRISCV64.EFI"
#else
#error Unsupported UEFI architecture
deleted file mode 100644
@@ -1,26 +0,0 @@
-#if 0
-# SPDX SPDX-License-Identifier: GPL-2.0+
-#
-# Constants defining the host architecture in assembler, C, and make files.
-# The values are arbitrary.
-#
-# Copyright 2019 Heinrich Schuchardt <xypron.glpk@gmx.de>
-#endif
-
-#if 0
-export HOST_ARCH_AARCH64=0xaa64
-export HOST_ARCH_ARM=0x00a7
-export HOST_ARCH_RISCV32=0x5032
-export HOST_ARCH_RISCV64=0x5064
-export HOST_ARCH_X86=0x0386
-export HOST_ARCH_X86_64=0x8664
-#endif
-
-#include <version.h>
-
-#define HOST_ARCH_AARCH64 0xaa64
-#define HOST_ARCH_ARM 0x00a7
-#define HOST_ARCH_RISCV32 0x5032
-#define HOST_ARCH_RISCV64 0x5064
-#define HOST_ARCH_X86 0x0386
-#define HOST_ARCH_X86_64 0x8664
@@ -36,11 +36,11 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
#elif defined(CONFIG_X86)
asm volatile (".word 0xffff\n");
#elif defined(CONFIG_SANDBOX)
-#if (HOST_ARCH == HOST_ARCH_ARM || HOST_ARCH == HOST_ARCH_AARCH64)
+#if (CONFIG_IS_ENABLED(HOST_ARCH_ARM) || CONFIG_IS_ENABLED(HOST_ARCH_AARCH64))
asm volatile (".word 0xe7f7defb\n");
-#elif (HOST_ARCH == HOST_ARCH_RISCV32 || HOST_ARCH == HOST_ARCH_RISCV64)
+#elif (CONFIG_IS_ENABLED(HOST_ARCH_RISCV32) || CONFIG_IS_ENABLED(HOST_ARCH_RISCV64))
asm volatile (".word 0xffffffff\n");
-#elif (HOST_ARCH == HOST_ARCH_X86 || HOST_ARCH == HOST_ARCH_X86_64)
+#elif (CONFIG_IS_ENABLED(HOST_ARCH_X86) || CONFIG_IS_ENABLED(HOST_ARCH_X86_64))
asm volatile (".word 0xffff\n");
#endif
#endif
Move host arch detection to Kconfig so we can make some options depend on HOST_ARCH. Also now we are using compiler macros to detect target arch, which is more robust than looking at uname -a. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> --- Makefile | 24 --------------------- arch/sandbox/Kconfig | 23 ++++++++++++++++++++ arch/sandbox/config.mk | 12 +++++------ arch/sandbox/lib/crt0_sandbox_efi.S | 14 ++++++------ arch/sandbox/lib/reloc_sandbox_efi.c | 14 ++++++------ include/efi_default_filename.h | 14 ++++++------ include/host_arch.h | 26 ----------------------- lib/efi_selftest/efi_selftest_miniapp_exception.c | 6 +++--- 8 files changed, 53 insertions(+), 80 deletions(-)