diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 24a7f6bd1cb..68864a1bf9b 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 fa6ae14ba89..0d572eff300 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 c9300a44d7d..3543e0cb577 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 00000000000..1131a5c7ce9 --- /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 2d3cf9af0b1..0eaa9753fc3 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 5e8005a539c..e19710493b1 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