[U-Boot] [PATCH 10/11] imx: Reserve a global page in memory to pass configuration to UEFI

Henry Beberman Henry.Beberman at microsoft.com
Sat Jul 14 00:11:53 UTC 2018


From: Henry Beberman <henry.beberman at microsoft.com>

This patch is to enable U-Boot to pass configuration information
available during U-Boot Proper into a subsequent OS. This is required
for Windows because it lacks device tree support.

When CONFIG_GLOBAL_PAGE and CONFIG_UEFI_BOOT are set on an i.MX6 or
i.MX7 platform the go command will initialize a 4k page at a hardcoded
offset to zero. Then it will set a signature and revision number at the
start of the page so the consumer of the configuration can verify that
the page has been initialized to the expected format.

Signed-off-by: Henry Beberman <henry.beberman at microsoft.com>
Cc: Stefano Babic <sbabic at denx.de>
Cc: Fabio Estevam <fabio.estevam at nxp.com>
---
 arch/arm/mach-imx/Kconfig       |  7 +++++++
 arch/arm/mach-imx/Makefile      |  1 +
 arch/arm/mach-imx/boot.c        |  6 ++++++
 arch/arm/mach-imx/global_page.c | 28 ++++++++++++++++++++++++++++
 include/configs/mx6_common.h    | 11 +++++++++++
 include/configs/mx7_common.h    |  5 +++++
 include/global_page.h           | 24 ++++++++++++++++++++++++
 7 files changed, 82 insertions(+)
 create mode 100644 arch/arm/mach-imx/global_page.c
 create mode 100644 include/global_page.h

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 3aec89d440..c88fa2ca1b 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -78,3 +78,10 @@ config NXP_BOARD_REVISION
 	  NXP boards based on i.MX6/7 contain the board revision information
 	  stored in the fuses. Select this option if you want to be able to
 	  retrieve the board revision information.
+
+config GLOBAL_PAGE
+	bool "Enable global 4K page for configuration sharing"
+	default n
+	help
+	  This option creates a global 4K page to store U-Boot environment data
+	  to pass to another environment such as UEFI or Windows.
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index a81af51f03..be095d71a2 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -43,6 +43,7 @@ obj-$(CONFIG_SATA) += sata.o
 obj-$(CONFIG_SECURE_BOOT)    += hab.o
 obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
 obj-$(CONFIG_UEFI_BOOT) += boot.o
+obj-$(CONFIG_GLOBAL_PAGE) += global_page.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
index 457a323fa2..2dbde8d8ee 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <global_page.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -12,6 +13,11 @@ DECLARE_GLOBAL_DATA_PTR;
 unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
 			 char * const argv[])
 {
+#ifdef CONFIG_GLOBAL_PAGE
+	init_global_page();
+	publish_to_global_page();
+#endif
+
 	cleanup_before_linux();
 
 	return entry(argc, argv);
diff --git a/arch/arm/mach-imx/global_page.c b/arch/arm/mach-imx/global_page.c
new file mode 100644
index 0000000000..139e18f4bc
--- /dev/null
+++ b/arch/arm/mach-imx/global_page.c
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+#include <global_page.h>
+#include <environment.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct imx_global_page *global_page =
+	(struct imx_global_page *)GLOBAL_PAGE_BASE_ADDRESS;
+
+void init_global_page(void)
+{
+	/* Clear global page */
+	memset(global_page, 0, 0x1000);
+
+	/* Set signature to 'GLBL' */
+	global_page->header.signature = 0x474c424c;
+
+	/* Set revision */
+	global_page->header.revision = 0;
+}
+
+void publish_to_global_page(void)
+{
+}
diff --git a/include/configs/mx6_common.h b/include/configs/mx6_common.h
index 756db4da61..6571787e50 100644
--- a/include/configs/mx6_common.h
+++ b/include/configs/mx6_common.h
@@ -74,4 +74,15 @@
 #define CONFIG_SYS_NORMAL_WORLD
 #endif
 
+/* Define global page address */
+#if defined(CONFIG_GLOBAL_PAGE)
+#if defined(CONFIG_MX6SL) || defined(CONFIG_MX6SLL) || \
+	defined(CONFIG_MX6SX) || \
+	defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL)
+#define GLOBAL_PAGE_BASE_ADDRESS 0x82003000
+#else
+#define GLOBAL_PAGE_BASE_ADDRESS 0x10817000
+#endif
+#endif
+
 #endif
diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
index 4864df5108..a26805e93c 100644
--- a/include/configs/mx7_common.h
+++ b/include/configs/mx7_common.h
@@ -63,4 +63,9 @@
 #define CONFIG_SYS_NORMAL_WORLD
 #endif
 
+/* Define global page address */
+#if defined(CONFIG_GLOBAL_PAGE)
+#define GLOBAL_PAGE_BASE_ADDRESS 0x82003000
+#endif
+
 #endif
diff --git a/include/global_page.h b/include/global_page.h
new file mode 100644
index 0000000000..a9ee6b67ad
--- /dev/null
+++ b/include/global_page.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+*/
+/*
+ * Copyright (C) 2018 Microsoft Corporation
+ */
+
+#ifndef _GLOBAL_PAGE_H
+#define _GLOBAL_PAGE_H
+
+#include <common.h>
+
+struct global_page_header {
+	u32 signature;
+	u8 revision;
+	u8 reserved[3];
+} __packed;
+
+struct imx_global_page {
+	struct global_page_header header;
+} __packed;
+
+void init_global_page(void);
+void publish_to_global_page(void);
+
+#endif
-- 
2.16.2.gvfs.1.33.gf5370f1



More information about the U-Boot mailing list