[U-Boot] [PATCH 0/3] 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.
Further work will be needed to accomodate EFI payloads built out of multiple source files.
Heinrich Schuchardt (3): efi_loader: rename __efi_hello_world_* scripts/Makefile.lib: generalize building built in EFI app efi_loader: usage of always in Makefile
cmd/bootefi.c | 4 ++-- include/asm-generic/sections.h | 4 ++-- lib/efi_loader/Makefile | 5 +++-- scripts/Makefile.lib | 28 +++++++++++++++------------- 4 files changed, 22 insertions(+), 19 deletions(-)

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 --- 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'; \ ) > $@

On 4 September 2017 at 19:19, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
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
cmd/bootefi.c | 4 ++-- include/asm-generic/sections.h | 4 ++-- scripts/Makefile.lib | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

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 --- scripts/Makefile.lib | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 164c234b4c..c73464b854 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 $(%_deps) arch/$(ARCH)/lib/$(EFI_CRT0) \ arch/$(ARCH)/lib/$(EFI_RELOC) $(call cmd,efi_ld)

On 4 September 2017 at 19:19, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
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
scripts/Makefile.lib | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

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 --- 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

On 4 September 2017 at 19:19, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
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
lib/efi_loader/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Tue, 2017-09-05 at 03:19 +0200, Heinrich Schuchardt wrote:
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.
Further work will be needed to accomodate EFI payloads built out of multiple source files.
Please, amend .gitignore, if needed, according to the changes.
Heinrich Schuchardt (3): efi_loader: rename __efi_hello_world_* scripts/Makefile.lib: generalize building built in EFI app efi_loader: usage of always in Makefile
cmd/bootefi.c | 4 ++-- include/asm-generic/sections.h | 4 ++-- lib/efi_loader/Makefile | 5 +++-- scripts/Makefile.lib | 28 +++++++++++++++------------- 4 files changed, 22 insertions(+), 19 deletions(-)

On 09/05/2017 04:23 PM, Andy Shevchenko wrote:
On Tue, 2017-09-05 at 03:19 +0200, Heinrich Schuchardt wrote:
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.
Further work will be needed to accomodate EFI payloads built out of multiple source files.
Please, amend .gitignore, if needed, according to the changes.
In this old version of the patch series no new files are created.
In the v2 version dependency files are created/updated which we want to add to the source repository keep.
Best regards
Heinrich
Heinrich Schuchardt (3): efi_loader: rename __efi_hello_world_* scripts/Makefile.lib: generalize building built in EFI app efi_loader: usage of always in Makefile
cmd/bootefi.c | 4 ++-- include/asm-generic/sections.h | 4 ++-- lib/efi_loader/Makefile | 5 +++-- scripts/Makefile.lib | 28 +++++++++++++++------------- 4 files changed, 22 insertions(+), 19 deletions(-)
participants (3)
-
Andy Shevchenko
-
Heinrich Schuchardt
-
Simon Glass