From: Henry Beberman <henry.beber...@microsoft.com>

This patch enables i.MX platforms to easily add a boot script to their
U-Boot Proper environment to automatically load and execute an EFI
firmware from the first FAT partition of an MMC device.

This is a portion of enabling the Windows 10 IoT Core boot path.

The go command is overridden when CONFIG_UEFI_BOOT is specified. This
new go will perform a cache flush/disable, disable interrupts, then
jump to the address where UEFI was loaded.

This patch adds two new Kconfig options:
CONFIG_UEFI_BOOT: Selects the UEFI bootcmd and overrides go to flush
caches and disable interrupts.
CONFIG_UEFI_LOAD_ADDR: Specifies the load address for the UEFI image

Signed-off-by: Henry Beberman <henry.beber...@microsoft.com>
Cc: Stefano Babic <sba...@denx.de>
Cc: Fabio Estevam <fabio.este...@nxp.com>
Cc: Tom Rini <tr...@konsulko.com>
---
 arch/arm/mach-imx/Makefile    |  1 +
 arch/arm/mach-imx/boot.c      | 19 +++++++++++++++++++
 common/Kconfig                | 17 +++++++++++++++++
 include/config_uefi_bootcmd.h | 29 +++++++++++++++++++++++++++++
 4 files changed, 66 insertions(+)
 create mode 100644 arch/arm/mach-imx/boot.c
 create mode 100644 include/config_uefi_bootcmd.h

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 733c308670..a81af51f03 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -42,6 +42,7 @@ endif
 obj-$(CONFIG_SATA) += sata.o
 obj-$(CONFIG_SECURE_BOOT)    += hab.o
 obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
+obj-$(CONFIG_UEFI_BOOT) += boot.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx7ulp))
 obj-y  += cache.o
diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
new file mode 100644
index 0000000000..457a323fa2
--- /dev/null
+++ b/arch/arm/mach-imx/boot.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+#include <common.h>
+#include <command.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#if defined(CONFIG_UEFI_BOOT)
+unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
+                        char * const argv[])
+{
+       cleanup_before_linux();
+
+       return entry(argc, argv);
+}
+#endif /* CONFIG_UEFI_BOOT */
diff --git a/common/Kconfig b/common/Kconfig
index 4c7a1a9af8..35362b629c 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -217,6 +217,23 @@ config BOOTCOMMAND
          This is the string of commands that will be used as bootcmd and if
          AUTOBOOT is set, automatically run.
 
+config UEFI_BOOT
+       bool "Boot a UEFI firmware loaded from the first FAT partition on the 
mmc"
+       default n
+       help
+         Override the CONFIG_BOOTCOMMAND to load a UEFI firmware image from the
+         first FAT partition on the mmc. Override the go command to make it 
disable
+         interrupts and flush the cache before jumping to the specified 
address.
+
+config UEFI_LOAD_ADDR
+       hex "Load address for the UEFI image"
+       depends on UEFI_BOOT
+       help
+         CONFIG_UEFI_BOOT uses this as the address to load the UEFI image.
+         The uefi_bootcmd script in the environment will fatload efi from the 
mmc
+         to this location, then use an overridden go command to disable caches 
and
+         interrupts then jump to this location.
+
 menu "Console"
 
 config MENU
diff --git a/include/config_uefi_bootcmd.h b/include/config_uefi_bootcmd.h
new file mode 100644
index 0000000000..03903abf8f
--- /dev/null
+++ b/include/config_uefi_bootcmd.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+#ifndef _CONFIG_UEFI_BOOTCMD_H
+#define _CONFIG_UEFI_BOOTCMD_H
+
+#define BOOTENV \
+       "uefi_image_name=imxboard_efi.fd\0" \
+       "uefi_addr=" __stringify(CONFIG_UEFI_LOAD_ADDR) "\0" \
+       "uefi_bootcmd=" \
+               "part list mmc ${mmcdev} -bootable devplist; " \
+               "env exists devplist || setenv devplist 1; " \
+               "for bootpart in ${devplist}; do " \
+                       "if fatload mmc ${mmcdev}:${bootpart} " \
+                       "${uefi_addr} ${uefi_image_name}; then " \
+                               "echo \"Jumping to ${uefi_image_name} at " \
+                               "${uefi_addr}\"; " \
+                               "go ${uefi_addr}; " \
+                       "fi; " \
+               "done; " \
+               "echo \"Could not find ${uefi_image_name} on mmc ${mmcdev}\";\0"
+
+#ifdef CONFIG_UEFI_BOOT
+#define CONFIG_BOOTCOMMAND "run uefi_bootcmd"
+#endif
+
+#endif  /* _CONFIG_UEFI_BOOTCMD_H */
-- 
2.16.2.gvfs.1.33.gf5370f1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to