[U-Boot] [PATCH v2 0/4] Clean up make process for EFI payload

Currently we have a single EFI application that we can deliver integrated into U-Boot. It is a hello world application that can be called with 'bootefi hello'.
The Makefiles do not easily accomodate further EFI payloads like a unit test for the EFI API or an EFI shell.
This patch series changes Makefile.lib to allow additional EFI payloads. Required fixes to the helloworld app are provided.
This second version of the patch series accomodated EFI payloads build out of multiple source files.
Heinrich Schuchardt (4): efi_loader: rename __efi_hello_world_* scripts/Makefile.lib: generalize building built in EFI app efi_loader: usage of always in Makefile efi_loader: allow multiple source files for EFI apps
cmd/bootefi.c | 4 ++-- include/asm-generic/sections.h | 4 ++-- lib/efi_loader/Makefile | 8 ++++++-- lib/efi_loader/helloworld_efi.d | 1 + scripts/Makefile.lib | 38 ++++++++++++++++++++++++-------------- 5 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 lib/efi_loader/helloworld_efi.d

In scripts/Makefile.lib we build section including helloworld.efi. This allows to load the EFI binary with command 'bootefi hello'.
scripts/Makefile.lib contains explicit references to strings containing helloworld and hello_world. This makes it impossible to generalize the coding to accomodate additional built in EFI binaries.
Let us rename the variables __efi_hello_world_* to __efi_helloworld_*.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- v2 no change --- cmd/bootefi.c | 4 ++-- include/asm-generic/sections.h | 4 ++-- scripts/Makefile.lib | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/cmd/bootefi.c b/cmd/bootefi.c index a3768158a2..c5bfab1147 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -298,14 +298,14 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return CMD_RET_USAGE; #ifdef CONFIG_CMD_BOOTEFI_HELLO if (!strcmp(argv[1], "hello")) { - ulong size = __efi_hello_world_end - __efi_hello_world_begin; + ulong size = __efi_helloworld_end - __efi_helloworld_begin;
saddr = env_get("loadaddr"); if (saddr) addr = simple_strtoul(saddr, NULL, 16); else addr = CONFIG_SYS_LOAD_ADDR; - memcpy((char *)addr, __efi_hello_world_begin, size); + memcpy((char *)addr, __efi_helloworld_begin, size); } else #endif { diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index daf021b647..b6535705a5 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -22,8 +22,8 @@ extern char __kprobes_text_start[], __kprobes_text_end[]; extern char __entry_text_start[], __entry_text_end[]; extern char __initdata_begin[], __initdata_end[]; extern char __start_rodata[], __end_rodata[]; -extern char __efi_hello_world_begin[]; -extern char __efi_hello_world_end[]; +extern char __efi_helloworld_begin[]; +extern char __efi_helloworld_end[];
/* Start and end of .ctors section - used for constructor calls. */ extern char __ctors_start[], __ctors_end[]; diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 7f97e8ebf3..164c234b4c 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -350,11 +350,11 @@ cmd_S_efi= \ ( \ echo '.section .rodata.efi.init,"a"'; \ echo '.balign 16'; \ - echo '.global __efi_hello_world_begin'; \ - echo '__efi_hello_world_begin:'; \ + echo '.global __efi_helloworld_begin'; \ + echo '__efi_helloworld_begin:'; \ echo '.incbin "$<" '; \ - echo '__efi_hello_world_end:'; \ - echo '.global __efi_hello_world_end'; \ + echo '__efi_helloworld_end:'; \ + echo '.global __efi_helloworld_end'; \ echo '.balign 16'; \ ) > $@

Replace all occurences of helloworld by generalized forms. This allows us to build additional EFI applications that are included into the U-Boot binary without loading scripts/Makefile.lib with specific filenames.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- v2 Removed superfluous reference to $($*_deps). --- scripts/Makefile.lib | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 164c234b4c..ebc74f8987 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -342,20 +342,22 @@ cmd_S_ttf= \ $(obj)/%.S: $(src)/%.ttf $(call cmd,S_ttf)
-# EFI Hello World application +# EFI applications +# A Makefile target *.efi is built as EFI application. +# A Makefile target *_efi.S wraps *.efi as built-in EFI application. # ---------------------------------------------------------------------------
# Generate an assembly file to wrap the EFI app -cmd_S_efi= \ -( \ - echo '.section .rodata.efi.init,"a"'; \ - echo '.balign 16'; \ - echo '.global __efi_helloworld_begin'; \ - echo '__efi_helloworld_begin:'; \ - echo '.incbin "$<" '; \ - echo '__efi_helloworld_end:'; \ - echo '.global __efi_helloworld_end'; \ - echo '.balign 16'; \ +cmd_S_efi= \ +( \ + echo '.section .rodata.$*.init,"a"'; \ + echo '.balign 16'; \ + echo '.global __efi_$*_begin'; \ + echo '__efi_$*_begin:'; \ + echo '.incbin "$<" '; \ + echo '__efi_$*_end:'; \ + echo '.global __efi_$*_end'; \ + echo '.balign 16'; \ ) > $@
$(obj)/%_efi.S: $(obj)/%.efi @@ -366,7 +368,7 @@ cmd_efi_objcopy = $(OBJCOPY) -j .header -j .text -j .sdata -j .data -j \ .dynamic -j .dynsym -j .rel* -j .rela* -j .reloc \ $(if $(EFI_TARGET),$(EFI_TARGET),-O binary) $^ $@
-$(obj)/%.efi: $(obj)/%.so +$(obj)/%.efi: $(obj)/%_efi.so $(call cmd,efi_objcopy)
quiet_cmd_efi_ld = LD $@ @@ -375,7 +377,7 @@ cmd_efi_ld = $(LD) -nostdlib -znocombreloc -T $(EFI_LDS_PATH) -shared \
EFI_LDS_PATH = $(srctree)/arch/$(ARCH)/lib/$(EFI_LDS)
-$(obj)/helloworld.so: $(obj)/helloworld.o arch/$(ARCH)/lib/$(EFI_CRT0) \ +$(obj)/%_efi.so: $(obj)/%.o arch/$(ARCH)/lib/$(EFI_CRT0) \ arch/$(ARCH)/lib/$(EFI_RELOC) $(call cmd,efi_ld)

Variable always should only be appended but not overwritten by lib/efi_loader/Makefile.
Remove variable efiprogs which is not otherwise used.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- v2 no change --- lib/efi_loader/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 6bca05aeb4..5200497230 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -10,8 +10,9 @@ CFLAGS_helloworld.o := $(CFLAGS_EFI) CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI)
-efiprogs-$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE) += helloworld.efi -always := $(efiprogs-y) +ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),) +always += helloworld.efi +endif
obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o obj-y += efi_image_loader.o efi_boottime.o efi_runtime.o efi_console.o

With this patch an EFI application can be built out of multiple source files.
All object files that are to be included into the EFI application %.efi must be added to variable %-objs. E.g.
helloworld-objs = helloworld.o
script/Makefile.lib automatically generates file %_efi.d containing the dependency definition.
This file is included in the next run of make. From now on all objects in %-objs are built.
The %_efi.d file should be included in the source distribution.
After adding a new file to %-objs the first make run will fail due to the outdated %_efi.d file.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- v2 new patch --- lib/efi_loader/Makefile | 3 +++ lib/efi_loader/helloworld_efi.d | 1 + scripts/Makefile.lib | 12 ++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 lib/efi_loader/helloworld_efi.d
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 5200497230..d6a9635cc8 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -10,6 +10,9 @@ CFLAGS_helloworld.o := $(CFLAGS_EFI) CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI)
+helloworld-objs = \ +helloworld.o + ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),) always += helloworld.efi endif diff --git a/lib/efi_loader/helloworld_efi.d b/lib/efi_loader/helloworld_efi.d new file mode 100644 index 0000000000..892db64c8b --- /dev/null +++ b/lib/efi_loader/helloworld_efi.d @@ -0,0 +1 @@ +lib/efi_loader/helloworld_efi.d: lib/efi_loader/helloworld.o diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index ebc74f8987..1a9f32902d 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -373,14 +373,22 @@ $(obj)/%.efi: $(obj)/%_efi.so
quiet_cmd_efi_ld = LD $@ cmd_efi_ld = $(LD) -nostdlib -znocombreloc -T $(EFI_LDS_PATH) -shared \ - -Bsymbolic $^ -o $@ + -Bsymbolic $(foreach _s, $($*-objs), $(obj)/$(_s)) -o $@
EFI_LDS_PATH = $(srctree)/arch/$(ARCH)/lib/$(EFI_LDS)
-$(obj)/%_efi.so: $(obj)/%.o arch/$(ARCH)/lib/$(EFI_CRT0) \ +.PRECIOUS: $(obj)/%_efi.d + +$(obj)/%_efi.so: $(obj)/%.o $(obj)/%.d arch/$(ARCH)/lib/$(EFI_CRT0) \ arch/$(ARCH)/lib/$(EFI_RELOC) + @echo $(obj)/$*_efi.d: $(foreach _s, $($*-objs), $(obj)/$(_s)) \ + > $(obj)/$*_efi.d $(call cmd,efi_ld)
+$(obj)/%.d:; + +include $(wildcard $(foreach _s, $(filter %_efi.o, $(obj-y)), $(_s:.o=.d))) + # ACPI # --------------------------------------------------------------------------- quiet_cmd_acpi_c_asl= ASL $<
participants (1)
-
Heinrich Schuchardt