From 51c34bb60986d5db0286bf59eb10303ab10ef39c Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Tue, 26 Jan 2021 06:58:30 -0500 Subject: [PATCH] boards: x86: depend on CONFIG_BUILD_OUTPUT_EFI Add a new Kconfig CONFIG_BUILD_OUTPUT_EFI and select that for boards that want to generate an EFI application. Make qemu_x86_64 also generate an EFI file, however do not enable this by default yet. Goal is to boot qemu using EFI to be able to test this path in the future. Signed-off-by: Anas Nashif --- Kconfig.zephyr | 14 ++++++++++++++ boards/x86/ehl_crb/CMakeLists.txt | 2 +- boards/x86/ehl_crb/ehl_crb_defconfig | 2 ++ boards/x86/qemu_x86/CMakeLists.txt | 10 ++++++++++ boards/x86/up_squared/CMakeLists.txt | 2 +- boards/x86/up_squared/up_squared_defconfig | 2 ++ 6 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 boards/x86/qemu_x86/CMakeLists.txt diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 24a7f6bd1c..68864a1bf9 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -317,6 +317,20 @@ config BUILD_OUTPUT_BIN Build a "raw" binary zephyr/zephyr.bin in the build directory. The name of this file can be customized with CONFIG_KERNEL_BIN_NAME. +config BUILD_OUTPUT_EFI + bool "Build as an EFI application" + default n + depends on X86_64 + help + Build as an EFI application. + + This works by creating a "zephyr.efi" EFI binary containing a zephyr + image extracted from a built zephyr.elf file. EFI applications are + relocatable, and cannot be placed at specific locations in memory. + Instead, the stub code will copy the embedded zephyr sections to the + appropriate locations at startup, clear any zero-filled (BSS, etc...) + areas, then jump into the 64 bit entry point. + config BUILD_OUTPUT_EXE bool "Build a binary in ELF format with .exe extension" help diff --git a/boards/x86/ehl_crb/CMakeLists.txt b/boards/x86/ehl_crb/CMakeLists.txt index fa6ae14ba8..0d572eff30 100644 --- a/boards/x86/ehl_crb/CMakeLists.txt +++ b/boards/x86/ehl_crb/CMakeLists.txt @@ -1,5 +1,5 @@ # Create an EFI image -if(CONFIG_BOARD_EHL_CRB) +if(CONFIG_BOARD_EHL_CRB AND CONFIG_BUILD_OUTPUT_EFI) set_property(GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/arch/x86/zefi/zefi.py -c ${CMAKE_C_COMPILER} diff --git a/boards/x86/ehl_crb/ehl_crb_defconfig b/boards/x86/ehl_crb/ehl_crb_defconfig index c9300a44d7..3543e0cb57 100644 --- a/boards/x86/ehl_crb/ehl_crb_defconfig +++ b/boards/x86/ehl_crb/ehl_crb_defconfig @@ -10,3 +10,5 @@ CONFIG_UART_NS16550=y CONFIG_UART_CONSOLE=y CONFIG_X2APIC=y CONFIG_SMP=y +CONFIG_KERNEL_VM_SIZE=0x80800000 +CONFIG_BUILD_OUTPUT_EFI=y diff --git a/boards/x86/qemu_x86/CMakeLists.txt b/boards/x86/qemu_x86/CMakeLists.txt new file mode 100644 index 0000000000..1131a5c7ce --- /dev/null +++ b/boards/x86/qemu_x86/CMakeLists.txt @@ -0,0 +1,10 @@ +if(CONFIG_BOARD_QEMU_X86_64 AND CONFIG_BUILD_OUTPUT_EFI) +set_property(GLOBAL APPEND PROPERTY extra_post_build_commands + COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/arch/x86/zefi/zefi.py + -c ${CMAKE_C_COMPILER} + -o ${CMAKE_OBJCOPY} + -f ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.elf + $<$:--verbose> + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} +) +endif() diff --git a/boards/x86/up_squared/CMakeLists.txt b/boards/x86/up_squared/CMakeLists.txt index 2d3cf9af0b..0eaa9753fc 100644 --- a/boards/x86/up_squared/CMakeLists.txt +++ b/boards/x86/up_squared/CMakeLists.txt @@ -1,5 +1,5 @@ # Create an EFI image -if(CONFIG_BOARD_UP_SQUARED) +if(CONFIG_BOARD_UP_SQUARED AND CONFIG_BUILD_OUTPUT_EFI) set_property(GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/arch/x86/zefi/zefi.py -c ${CMAKE_C_COMPILER} diff --git a/boards/x86/up_squared/up_squared_defconfig b/boards/x86/up_squared/up_squared_defconfig index 5e8005a539..e19710493b 100644 --- a/boards/x86/up_squared/up_squared_defconfig +++ b/boards/x86/up_squared/up_squared_defconfig @@ -11,3 +11,5 @@ CONFIG_UART_CONSOLE=y CONFIG_X2APIC=y CONFIG_SMP=y CONFIG_MP_NUM_CPUS=2 +CONFIG_KERNEL_VM_SIZE=0x80800000 +CONFIG_BUILD_OUTPUT_EFI=y