mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
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
This commit is contained in:
1 parent
25b58eb37a
commit
d48e9bff8c
2 files changed
+32
No files matched your search
@@ -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 */
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user