From: Alexander Graf <agraf@suse.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 7/7] distro: Add efi pxe boot code
Date: Fri, 6 May 2016 21:01:07 +0200 [thread overview]
Message-ID: <1462561267-92773-8-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1462561267-92773-1-git-send-email-agraf@suse.de>
Now that we can expose network functionality to EFI applications,
the logical next step is to load them via pxe to execute them as
well.
This patch adds the necessary bits to the distro script to automatically
load and execute EFI payloads. It identifies the dhcp client as a uEFI
capable PXE client, hoping the server returns a tftp path to a workable
EFI binary that we can then execute.
To enable boards that don't come with a working device tree preloaded,
this patch also adds support to load a device tree from the /dtb directory
on the remote tftp server.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
v1 -> v2:
- Error out for unknown arch
- Also set client arch variable
---
include/config_distro_bootcmd.h | 47 ++++++++++++++++++++++++++++++++++++++++-
net/bootp.c | 13 ++++++++++--
2 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 7f67344..e06c9eb 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -230,13 +230,58 @@
#endif
#if defined(CONFIG_CMD_DHCP)
+#if defined(CONFIG_EFI_LOADER)
+#if defined(CONFIG_ARM64)
+#define BOOTENV_EFI_PXE_ARCH "0xb"
+#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00011:UNDI:003000"
+#elif defined(CONFIG_ARM)
+#define BOOTENV_EFI_PXE_ARCH "0xa"
+#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00010:UNDI:003000"
+#elif defined(CONFIG_X86)
+/* Always assume we're running 64bit */
+#define BOOTENV_EFI_PXE_ARCH "0x7"
+#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000"
+#else
+#error Please specify an EFI client identifier
+#endif
+
+/*
+ * Ask the dhcp server for an EFI binary. If we get one, check for a
+ * device tree in the same folder. Then boot everything. If the file was
+ * not an EFI binary, we just return from the bootefi command and continue.
+ */
+#define BOOTENV_EFI_RUN_DHCP \
+ "setenv efi_fdtfile ${fdtfile}; " \
+ BOOTENV_EFI_SET_FDTFILE_FALLBACK \
+ "setenv efi_old_vci ${bootp_vci};" \
+ "setenv efi_old_arch ${bootp_arch};" \
+ "setenv bootp_vci " BOOTENV_EFI_PXE_VCI ";" \
+ "setenv bootp_arch " BOOTENV_EFI_PXE_ARCH ";" \
+ "if dhcp ${kernel_addr_r}; then " \
+ "tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};" \
+ "if fdt addr ${fdt_addr_r}; then " \
+ "bootefi ${kernel_addr_r} ${fdt_addr_r}; " \
+ "else " \
+ "bootefi ${kernel_addr_r} ${fdtcontroladdr};" \
+ "fi;" \
+ "fi;" \
+ "setenv bootp_vci ${efi_old_vci};" \
+ "setenv bootp_arch ${efi_old_arch};" \
+ "setenv efi_fdtfile;" \
+ "setenv efi_old_arch;" \
+ "setenv efi_old_vci;"
+#else
+#define BOOTENV_EFI_RUN_DHCP
+#endif
#define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \
"bootcmd_dhcp=" \
BOOTENV_RUN_NET_USB_START \
BOOTENV_RUN_NET_PCI_ENUM \
"if dhcp ${scriptaddr} ${boot_script_dhcp}; then " \
"source ${scriptaddr}; " \
- "fi\0"
+ "fi;" \
+ BOOTENV_EFI_RUN_DHCP \
+ "\0"
#define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \
"dhcp "
#else
diff --git a/net/bootp.c b/net/bootp.c
index 1f2d0aa..e36793c 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -413,12 +413,21 @@ static void bootp_timeout_handler(void)
static u8 *add_vci(u8 *e)
{
+ char *vci = NULL;
+ char *env_vci = getenv("bootp_vci");
+
#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_NET_VCI_STRING)
- put_vci(e, CONFIG_SPL_NET_VCI_STRING);
+ vci = CONFIG_SPL_NET_VCI_STRING;
#elif defined(CONFIG_BOOTP_VCI_STRING)
- put_vci(e, CONFIG_BOOTP_VCI_STRING);
+ vci = CONFIG_BOOTP_VCI_STRING;
#endif
+ if (env_vci)
+ vci = env_vci;
+
+ if (vci)
+ put_vci(e, vci);
+
return e;
}
--
1.8.5.6
next prev parent reply other threads:[~2016-05-06 19:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-06 19:01 [U-Boot] [PATCH v2 0/7] efi_loader: PXE boot support Alexander Graf
2016-05-06 19:01 ` [U-Boot] [PATCH v2 1/7] efi_loader: Add network access support Alexander Graf
2016-05-10 21:25 ` [U-Boot] [PATCH v3 " Alexander Graf
2016-05-14 19:49 ` Simon Glass
2016-05-14 20:34 ` Alexander Graf
2016-05-16 13:24 ` Simon Glass
2016-05-16 18:06 ` Alexander Graf
2016-05-18 17:21 ` Simon Glass
2016-05-19 16:18 ` Alexander Graf
2016-05-19 16:34 ` Simon Glass
2016-05-30 17:56 ` [U-Boot] [U-Boot, v2, " Tom Rini
2016-05-06 19:01 ` [U-Boot] [PATCH v2 2/7] bootp: Move vendor class identifier set to function Alexander Graf
2016-05-06 19:28 ` Tom Rini
2016-05-30 17:56 ` [U-Boot] [U-Boot, v2, " Tom Rini
2016-05-06 19:01 ` [U-Boot] [PATCH v2 3/7] net: Move the VCI and client arch values to Kconfig Alexander Graf
2016-05-06 19:28 ` Tom Rini
2016-05-30 17:56 ` [U-Boot] [U-Boot, v2, " Tom Rini
2016-05-06 19:01 ` [U-Boot] [PATCH v2 4/7] net: Fix client identifiers for ARM Alexander Graf
2016-05-06 19:28 ` Tom Rini
2016-05-30 17:56 ` [U-Boot] [U-Boot,v2,4/7] " Tom Rini
2016-05-06 19:01 ` [U-Boot] [PATCH v2 5/7] net: Move CONFIG_SPL_NET_VCI_STRING into Kconfig Alexander Graf
2016-05-06 19:28 ` Tom Rini
2016-05-30 17:57 ` [U-Boot] [U-Boot, v2, " Tom Rini
2016-05-06 19:01 ` [U-Boot] [PATCH v2 6/7] net: Optionally use pxe client arch from variable Alexander Graf
2016-05-06 19:28 ` Tom Rini
2016-05-12 13:51 ` [U-Boot] [PATCH v4 " Alexander Graf
2016-05-30 17:57 ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-05-06 19:01 ` Alexander Graf [this message]
2016-05-06 19:28 ` [U-Boot] [PATCH v2 7/7] distro: Add efi pxe boot code Tom Rini
2016-05-30 17:57 ` [U-Boot] [U-Boot,v2,7/7] " Tom Rini
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=1462561267-92773-8-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.