Skip to content

Commit

Permalink
boards: x86: depend on CONFIG_BUILD_OUTPUT_EFI
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nashif committed Jan 27, 2021
1 parent fc03bd2 commit 51c34bb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Kconfig.zephyr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion boards/x86/ehl_crb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}
Expand Down
2 changes: 2 additions & 0 deletions boards/x86/ehl_crb/ehl_crb_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions boards/x86/qemu_x86/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
endif()
2 changes: 1 addition & 1 deletion boards/x86/up_squared/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}
Expand Down
2 changes: 2 additions & 0 deletions boards/x86/up_squared/up_squared_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 51c34bb

Please sign in to comment.