The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=d48e9bff8c0216e66c5d789266c8800dc18d51e0
commit d48e9bff8c0216e66c5d789266c8800dc18d51e0 Author: Warner Losh <[email protected]> AuthorDate: 2026-09-11 04:14:24 +0000 Commit: Warner Losh <[email protected]> CommitDate: 2026-09-11 04:15:29 +0000 loader.efi: fetch initmd specified by DHCP Configure net0, read the DHCP-provided initmd URL, and download it through the file API so directly booted loader.efi can construct its root memory disk. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D59432 --- stand/efi/loader/loader_efi.h | 1 + stand/efi/loader/memdisk.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/stand/efi/loader/loader_efi.h b/stand/efi/loader/loader_efi.h index 6fe547b83453..d6a45e04e27c 100644 --- a/stand/efi/loader/loader_efi.h +++ b/stand/efi/loader/loader_efi.h @@ -61,6 +61,7 @@ void efi_copy_finish_nop(void); void maybe_download_ramdisk(int argc, CHAR16 **argv); int download_md_image(const char *url); +void maybe_download_initmd(void); #if defined(__amd64__) || defined(__i386__) /* Need this to setup page tables */ diff --git a/stand/efi/loader/memdisk.c b/stand/efi/loader/memdisk.c index d02b99a0677c..ce509e50c71c 100644 --- a/stand/efi/loader/memdisk.c +++ b/stand/efi/loader/memdisk.c @@ -10,6 +10,7 @@ #include "loader_efi.h" #include <bootstrap.h> +#include <dev_net.h> #include <efilib.h> #include <Protocol/RamDisk.h> #include "decompress.h" @@ -197,6 +198,36 @@ out_close: return (error); } +void +maybe_download_initmd(void) +{ + struct devdesc dev; + const char *url; + int error; + + if (efi_find_handle(&efinet_dev, 0) == NULL) + return; + + memset(&dev, 0, sizeof(dev)); + dev.d_dev = &efinet_dev; + dev.d_unit = 0; + error = net_configure(&dev); + if (error != 0) { + printf("Could not configure net0 for initmd: %s\n", + strerror(error)); + return; + } + + url = getenv("dhcp.initmd"); + if (url == NULL || *url == '\0') + return; + + printf("Downloading initmd from %s\n", url); + error = download_md_image(url); + if (error != 0) + printf("Could not download initmd: %s\n", strerror(error)); +} + static void do_download_ramdisk(CHAR8 *url, bool is_disk) {
