Support separate DTB files with the UEFI app

The UEFI app is an actual executable with things like section headers,
so just gluing the DTB onto the end of it won't work. Add an additional
section to contain this and allocate some space, and then during build
copy the DTB into that section.

Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Matthew Garrett
2024-11-23 11:55:06 -08:00
committed by Simon Glass
parent f07b9497ba
commit 2e7bf25f6b
7 changed files with 22 additions and 3 deletions

View File

@@ -1067,6 +1067,10 @@ quiet_cmd_objcopy = OBJCOPY $@
cmd_objcopy = $(OBJCOPY) --gap-fill=0xff $(OBJCOPYFLAGS) \
$(OBJCOPYFLAGS_$(@F)) $< $@
# Inject the DTB into u-boot
quiet_cmd_embeddtb = OBJCOPY $@
cmd_embeddtb = $(OBJCOPY) --update-section .embedded_dtb=dts/dt.dtb --set-section-flags .embedded_dtb=contents,alloc,load,data $<
# Provide a version which does not do this, for use by EFI
quiet_cmd_zobjcopy = OBJCOPY $@
cmd_zobjcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
@@ -1673,7 +1677,8 @@ u-boot-x86-reset16.bin: u-boot FORCE
endif # CONFIG_X86
OBJCOPYFLAGS_u-boot-app.efi := $(OBJCOPYFLAGS_EFI)
u-boot-app.efi: u-boot FORCE
u-boot-app.efi: u-boot dts/dt.dtb FORCE
$(call if_changed,embeddtb)
$(call if_changed,zobjcopy)
u-boot.bin.o: u-boot.bin FORCE

View File

@@ -45,7 +45,7 @@ LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined \
-s -zexecstack
OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
-j .rel -j .rela -j .reloc --strip-all
-j .rel -j .rela -j .reloc -j .embedded_dtb --strip-all
# Compiler flags to be added when building UEFI applications
CFLAGS_EFI := -fpic -fshort-wchar

View File

@@ -79,5 +79,9 @@ SECTIONS
*(.note.GNU-stack)
}
.embedded_dtb : {
*(.embedded_dtb)
}
.comment 0 : { *(.comment) }
}

View File

@@ -70,6 +70,7 @@ extern char __image_copy_start[], __image_copy_end[];
extern char __bss_end[];
extern char __rel_dyn_start[], __rel_dyn_end[];
extern char _image_binary_end[];
extern char _dtb[];
/*
* This is the U-Boot entry point - prior to relocation it should be same

View File

@@ -2,7 +2,7 @@
#
# (C) Copyright 2015 Google, Inc
obj-$(CONFIG_EFI_APP) += efi_app.o efi.o efi_app_init.o efi_vars.o
obj-$(CONFIG_EFI_APP) += efi_app.o efi.o efi_app_init.o efi_vars.o efi_dtb.o
obj-$(CONFIG_EFI_STUB) += efi_info.o
CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \

6
lib/efi/efi_dtb.S Normal file
View File

@@ -0,0 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0+ */
#ifdef CONFIG_OF_SEPARATE
.section .embedded_dtb, "a"
.globl __dtb
__dtb: .fill 1024*1024
#endif

View File

@@ -1236,6 +1236,9 @@ static void *fdt_find_separate(void)
fdt_blob = (ulong *)_image_binary_end;
else
fdt_blob = (ulong *)__bss_end;
#elif defined CONFIG_EFI_APP
/* FDT is in a separate section */
fdt_blob = (ulong *)__dtb;
#else
/* FDT is at end of image */
fdt_blob = (ulong *)_end;