From 476476e73b14696563524cbc2627a4c033ea64da Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 4 Aug 2015 12:33:52 -0600 Subject: efi: Add support for loading U-Boot through an EFI stub It is useful to be able to load U-Boot onto a board even if is it already running EFI. This can allow access to the U-Boot command interface, flexible booting options and easier development. The easiest way to do this is to build U-Boot as a binary blob and have an EFI stub copy it into RAM. Add support for this feature, targeting 32-bit initially. Also add a way to detect when U-Boot has been loaded via a stub. This goes in common.h since it needs to be widely available so that we avoid redoing initialisation that should be skipped. Signed-off-by: Simon Glass Improvements to how the payload is built: Signed-off-by: Bin Meng Reviewed-by: Bin Meng Tested-by: Bin Meng --- Makefile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 620c18f1e7..752ee0dbea 100644 --- a/Makefile +++ b/Makefile @@ -755,6 +755,7 @@ ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%) endif ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf ALL-$(CONFIG_EFI_APP) += u-boot-app.efi +ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi ifneq ($(BUILD_ROM),) ALL-$(CONFIG_X86_RESET_VECTOR) += u-boot.rom @@ -790,6 +791,9 @@ cmd_objcopy = $(OBJCOPY) --gap-fill=0xff $(OBJCOPYFLAGS) \ quiet_cmd_zobjcopy = OBJCOPY $@ cmd_zobjcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ +quiet_cmd_efipayload = OBJCOPY $@ +cmd_efipayload = $(OBJCOPY) -I binary -O $(EFIPAYLOAD_BFDTARGET) -B $(EFIPAYLOAD_BFDARCH) $< $@ + quiet_cmd_mkimage = MKIMAGE $@ cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \ $(if $(KBUILD_VERBOSE:1=), >/dev/null) @@ -1087,6 +1091,26 @@ OBJCOPYFLAGS_u-boot-app.efi := $(OBJCOPYFLAGS_EFI) u-boot-app.efi: u-boot FORCE $(call if_changed,zobjcopy) +u-boot-dtb.bin.o: u-boot-dtb.bin FORCE + $(call if_changed,efipayload) + +u-boot-payload.lds: $(LDSCRIPT_EFI) FORCE + $(call if_changed_dep,cpp_lds) + +# Rule to link the EFI payload which contains a stub and a U-Boot binary +quiet_cmd_u-boot_payload ?= LD $@ + cmd_u-boot_payload ?= $(LD) $(LDFLAGS_EFI_PAYLOAD) -o $@ \ + -T u-boot-payload.lds \ + lib/efi/efi.o lib/efi/efi_stub.o u-boot-dtb.bin.o \ + $(addprefix arch/$(ARCH)/lib/efi/,$(EFISTUB)) + +u-boot-payload: u-boot-dtb.bin.o u-boot-payload.lds FORCE + $(call if_changed,u-boot_payload) + +OBJCOPYFLAGS_u-boot-payload.efi := $(OBJCOPYFLAGS_EFI) +u-boot-payload.efi: u-boot-payload FORCE + $(call if_changed,zobjcopy) + u-boot-img.bin: spl/u-boot-spl.bin u-boot.img FORCE $(call if_changed,cat) -- cgit v1.2.1