[U-Boot] [PATCH 11/11] imx: Add MAC addresses to global page to pass MAC into UEFI
Henry Beberman
Henry.Beberman at microsoft.com
Sat Jul 14 00:11:53 UTC 2018
From: Henry Beberman <henry.beberman at microsoft.com>
U-Boot already has logic for determining the platform MAC address on
many i.MX platforms, such as pulling it from fuses or SPI flash. This
configuration option saves the MAC address from the ethaddr (and
potentially ethaddr1) into the global page and marks it as valid. This
value is then picked up in UEFI which will configure the LAN driver in
Windows with the correct MAC address.
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 | 16 ++++++++++++++++
arch/arm/mach-imx/global_page.c | 26 +++++++++++++++++++++++++-
configs/cl-som-imx7_nt_defconfig | 2 ++
configs/mx6cuboxi_nt_defconfig | 2 ++
configs/mx6sabresd_nt_defconfig | 2 ++
configs/udoo_neo_nt_defconfig | 2 ++
include/global_page.h | 8 ++++++++
7 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index c88fa2ca1b..9bc0294d0c 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -85,3 +85,19 @@ config GLOBAL_PAGE
help
This option creates a global 4K page to store U-Boot environment data
to pass to another environment such as UEFI or Windows.
+
+config STORE_MAC_IN_GLOBAL
+ bool "Store MAC address information in global page"
+ depends on GLOBAL_PAGE
+ default n
+ help
+ This option informs U-Boot to read the ethaddr environment
+ variable and store it in the global page for UEFI to use.
+
+config ETH1ADDR_IN_GLOBAL
+ bool "Store MAC Address for 2nd ethernet in global page"
+ depends on STORE_MAC_IN_GLOBAL
+ default n
+ help
+ This option informs U-Boot to read the eth1addr environment
+ variable and store it in the global page for UEFI to use.
diff --git a/arch/arm/mach-imx/global_page.c b/arch/arm/mach-imx/global_page.c
index 139e18f4bc..c753452ad6 100644
--- a/arch/arm/mach-imx/global_page.c
+++ b/arch/arm/mach-imx/global_page.c
@@ -20,9 +20,33 @@ void init_global_page(void)
global_page->header.signature = 0x474c424c;
/* Set revision */
- global_page->header.revision = 0;
+ global_page->header.revision = 1;
}
void publish_to_global_page(void)
{
+#ifdef CONFIG_STORE_MAC_IN_GLOBAL
+ publish_mac_to_global_page("ethaddr", 0);
+#endif /* CONFIG_STORE_MAC_IN_GLOBAL */
+
+#ifdef CONFIG_ETH1ADDR_IN_GLOBAL
+ publish_mac_to_global_page("eth1addr", 1);
+#endif /* CONFIG_ETH1ADDR_IN_GLOBAL */
+}
+
+void publish_mac_to_global_page(const char *env_var, int mac)
+{
+ uchar mac_id[6];
+
+ if (mac > 1)
+ return;
+
+ if (!(strcmp(env_var, "ethaddr") || strcmp(env_var, "eth1addr")))
+ return;
+
+ eth_env_get_enetaddr(env_var, mac_id);
+
+ global_page->mac_entry[mac].enet_id = mac;
+ global_page->mac_entry[mac].valid = 1;
+ memcpy(global_page->mac_entry[mac].mac, mac_id, 6);
}
diff --git a/configs/cl-som-imx7_nt_defconfig b/configs/cl-som-imx7_nt_defconfig
index 4fe8233f0f..048621874c 100644
--- a/configs/cl-som-imx7_nt_defconfig
+++ b/configs/cl-som-imx7_nt_defconfig
@@ -77,4 +77,6 @@ CONFIG_MXC_USB_OTG_HACTIVE=y
CONFIG_USB_STORAGE=y
CONFIG_USB_GADGET=y
CONFIG_CI_UDC=y
+CONFIG_GLOBAL_PAGE=y
+CONFIG_STORE_MAC_IN_GLOBAL=y
CONFIG_OF_LIBFDT=y
diff --git a/configs/mx6cuboxi_nt_defconfig b/configs/mx6cuboxi_nt_defconfig
index 087569d2e9..b29084012f 100644
--- a/configs/mx6cuboxi_nt_defconfig
+++ b/configs/mx6cuboxi_nt_defconfig
@@ -59,4 +59,6 @@ CONFIG_USB_STORAGE=y
CONFIG_USB=y
CONFIG_USE_TINY_PRINTF=y
CONFIG_VIDEO=y
+CONFIG_GLOBAL_PAGE=y
+CONFIG_STORE_MAC_IN_GLOBAL=y
CONFIG_OF_LIBFDT=y
\ No newline at end of file
diff --git a/configs/mx6sabresd_nt_defconfig b/configs/mx6sabresd_nt_defconfig
index 9d858a4418..47c6568e60 100644
--- a/configs/mx6sabresd_nt_defconfig
+++ b/configs/mx6sabresd_nt_defconfig
@@ -55,4 +55,6 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
CONFIG_USB=y
CONFIG_USE_TINY_PRINTF=y
CONFIG_VIDEO=y
+CONFIG_GLOBAL_PAGE=y
+CONFIG_STORE_MAC_IN_GLOBAL=y
CONFIG_OF_LIBFDT=y
\ No newline at end of file
diff --git a/configs/udoo_neo_nt_defconfig b/configs/udoo_neo_nt_defconfig
index d5123369ca..1be3180382 100644
--- a/configs/udoo_neo_nt_defconfig
+++ b/configs/udoo_neo_nt_defconfig
@@ -52,4 +52,6 @@ CONFIG_SYS_L2CACHE_OFF=y
CONFIG_SYS_MALLOC_F_LEN=0x800
CONFIG_USE_TINY_PRINTF=y
CONFIG_PHY_MICREL=y
+CONFIG_GLOBAL_PAGE=y
+CONFIG_STORE_MAC_IN_GLOBAL=y
CONFIG_OF_LIBFDT=y
\ No newline at end of file
diff --git a/include/global_page.h b/include/global_page.h
index a9ee6b67ad..2ba291019a 100644
--- a/include/global_page.h
+++ b/include/global_page.h
@@ -14,11 +14,19 @@ struct global_page_header {
u8 reserved[3];
} __packed;
+struct global_mac_entry {
+ u8 enet_id;
+ u8 valid;
+ u8 mac[6];
+} __packed;
+
struct imx_global_page {
struct global_page_header header;
+ struct global_mac_entry mac_entry[2];
} __packed;
void init_global_page(void);
void publish_to_global_page(void);
+void publish_mac_to_global_page(const char *env_var, int mac);
#endif
--
2.16.2.gvfs.1.33.gf5370f1
More information about the U-Boot
mailing list