public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Henry Beberman <Henry.Beberman@microsoft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc
Date: Sat, 14 Jul 2018 00:11:46 +0000	[thread overview]
Message-ID: <20180714001117.14584-2-hebeberm@microsoft.com> (raw)
In-Reply-To: <20180714001117.14584-1-hebeberm@microsoft.com>

From: Henry Beberman <henry.beberman@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.beberman@microsoft.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Tom Rini <trini@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

  reply	other threads:[~2018-07-14  0:11 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-14  0:11 [U-Boot] [PATCH 00/11] Enable Windows 10 IoT Core on i.MX6 and i.MX7 Henry Beberman
2018-07-14  0:11 ` Henry Beberman [this message]
2018-07-16 17:16   ` [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc Trent Piepho
2018-07-16 22:28     ` Henry Beberman
2018-07-16 22:45       ` Trent Piepho
2018-07-16 23:56         ` Henry Beberman
2018-07-17 17:24           ` Trent Piepho
2018-07-18  0:52             ` Henry Beberman
2018-07-17 17:09     ` Fabio Estevam
2018-07-17 17:20       ` Henry Beberman
2018-08-07 11:11   ` Stefano Babic
2018-08-07 11:16     ` Tom Rini
2018-08-07 13:45       ` Alexander Graf
2018-08-08  2:24         ` Henry Beberman
2018-08-15 14:46           ` Alexander Graf
2018-07-14  0:11 ` [U-Boot] [PATCH 03/11] spl: Add FIT boot into OP-TEE then U-Boot proper Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 02/11] arm: Allow U-Boot Proper to run in normal world Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 04/11] spl: imx: Add optional lds to keep SPL entirely in on-chip RAM Henry Beberman
2018-07-16 17:32   ` Trent Piepho
2018-07-16 22:48     ` Henry Beberman
2018-08-07 12:17   ` Stefano Babic
2018-08-08  3:22     ` Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 05/11] mx6sabresd: Add Windows boot support for iMX6 Sabre Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 07/11] mx6cuboxi: Add Windows boot support for mx6cuboxi Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre Henry Beberman
2018-07-16 18:22   ` Trent Piepho
2018-07-17  1:41     ` Henry Beberman
2018-07-17 17:02       ` Trent Piepho
2018-07-17 21:31         ` Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 08/11] udoo_neo: Add Windows boot support for UDOO Neo Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 09/11] cl-som-imx7: Add Windows boot support for cl-som-imx7 Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 11/11] imx: Add MAC addresses to global page to pass MAC into UEFI Henry Beberman
2018-07-14  0:11 ` [U-Boot] [PATCH 10/11] imx: Reserve a global page in memory to pass configuration to UEFI Henry Beberman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180714001117.14584-2-hebeberm@microsoft.com \
    --to=henry.beberman@microsoft.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox