Skip to contentSkip to conversation

Clean up make process for EFI payload

PATCH Superseded Heinrich Schuchardt 3 participants 9 messages Sep 5, 2017 – Sep 9, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover 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(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/3 efi_loader: rename __efi_hello_world_*

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_*.

---
 cmd/bootefi.c                  | 4 ++--
 include/asm-generic/sections.h | 4 ++--
 scripts/Makefile.lib           | 8 ++++----
 3 files changed, 8 insertions(+), 8 deletions(-)
cmd/bootefi.c +2 -2
index a3768158a2..c5bfab1147 100644
@@ -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
 	{
include/asm-generic/sections.h +2 -2
index daf021b647..b6535705a5 100644
@@ -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[];
scripts/Makefile.lib +4 -4
index 7f97e8ebf3..164c234b4c 100644
@@ -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';				\
 ) > $@
 
Signature · 1 line
2.11.0
#2 lore raw

PATCH 1/3 efi_loader: rename __efi_hello_world_*

Quoted 11 lines · Heinrich Schuchardt

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_*.

Quoted 7 lines
---
 cmd/bootefi.c                  | 4 ++--
 include/asm-generic/sections.h | 4 ++--
 scripts/Makefile.lib           | 8 ++++----
 3 files changed, 8 insertions(+), 8 deletions(-)
#3 lore raw

PATCH 2/3 scripts/Makefile.lib: generalize building built in EFI app

In reply to Heinrich Schuchardt

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.

---
 scripts/Makefile.lib | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
scripts/Makefile.lib +15 -13
index 164c234b4c..c73464b854 100644
@@ -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)
 
Signature · 1 line
2.11.0
#4 lore raw

PATCH 2/3 scripts/Makefile.lib: generalize building built in EFI app

Quoted 9 lines · Heinrich Schuchardt

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.

---
 scripts/Makefile.lib | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
#5 lore raw

PATCH 3/3 efi_loader: usage of always in Makefile

In reply to Heinrich Schuchardt

Variable always should only be appended but not overwritten by lib/efi_loader/Makefile.

Remove variable efiprogs which is not otherwise used.

---
 lib/efi_loader/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/efi_loader/Makefile +3 -2
index 6bca05aeb4..5200497230 100644
@@ -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
Signature · 1 line
2.11.0
#7 lore raw

cover Clean up make process for EFI payload

In reply to Heinrich Schuchardt
Quoted 7 lines · Heinrich Schuchardt

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.

Quoted 6 lines

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.

Quoted 12 lines

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(-)
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#8 lore raw

cover Clean up make process for EFI payload

Quoted 8 lines · Andy Shevchenko
Quoted 7 lines · Heinrich Schuchardt

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.

Quoted 8 lines
Quoted 6 lines

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

Quoted 14 lines
Quoted 13 lines

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