Commit 60101093 authored by Guillaume Tucker's avatar Guillaume Tucker Committed by Ricardo Cañuelo Navarro

net: add ramdisk argument to netboot()

While arm/arm64 have support for the FIT format which can include a
ramdisk separate from the main kernel image, other architectures such
as x86 only have support for plain kernel images (bzImage) in
Depthcharge.  Loading a ramdisk over TFTP therefore needs to be done
separately.  For this purpose, add a ramdisk argument to netboot()
with the name of an optional separate file to be downloaded as a
ramdisk and pass it on via the boot_info structure.

BRANCH=none
BUG=b:154536870
TEST=boot on x86
Signed-off-by: Guillaume Tucker's avatarGuillaume Tucker <guillaume.tucker@collabora.com>
Change-Id: I251df7a56589c0240761dd5caab174f535bf9ce9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/depthcharge/+/2288612Reviewed-by: default avatarJulius Werner <jwerner@chromium.org>
Commit-Queue: Guenter Roeck <groeck@chromium.org>
Tested-by: default avatarGuenter Roeck <groeck@chromium.org>
parent dc19be27
......@@ -52,7 +52,7 @@ int do_tftpboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
tftp_ip_arg = &tftp_ip;
}
netboot(tftp_ip_arg, bootfile, argsfile, NULL);
netboot(tftp_ip_arg, bootfile, argsfile, NULL, NULL);
/* netboot() only returns if it failed */
......
......@@ -44,5 +44,5 @@ void dc_dev_netboot(void)
&bootfile, &argsfile))
printf("ERROR: Failed to read netboot parameters from flash\n");
netboot(tftp_ip, bootfile, argsfile, NULL);
netboot(tftp_ip, bootfile, argsfile, NULL, NULL);
}
......@@ -110,7 +110,8 @@ int try_dhcp(uip_ipaddr_t *my_ip,
return 0;
}
void netboot(uip_ipaddr_t *tftp_ip, char *bootfile, char *argsfile, char *args)
void netboot(uip_ipaddr_t *tftp_ip, char *bootfile, char *argsfile, char *args,
char *ramdiskfile)
{
net_wait_for_link();
......@@ -149,6 +150,26 @@ void netboot(uip_ipaddr_t *tftp_ip, char *bootfile, char *argsfile, char *args)
}
printf("The bootfile was %d bytes long.\n", size);
void *ramdisk = NULL;
uint32_t ramdisk_size = 0;
if (ramdiskfile) {
ramdisk = (void *)(uintptr_t)ALIGN_UP(
CONFIG_KERNEL_START + size, 4096);
size = (uintptr_t)ramdisk - CONFIG_KERNEL_START;
if (size >= MaxPayloadSize) {
printf("No space left for ramdisk\n");
ramdisk = NULL;
} else if (tftp_read(ramdisk, tftp_ip, ramdiskfile,
&ramdisk_size, MaxPayloadSize - size)) {
printf("TFTP failed for ramdisk.\n");
ramdisk = NULL;
ramdisk_size = 0;
}
}
// Try to download command line file via TFTP if argsfile is specified
if (argsfile && !(tftp_read(cmd_line, tftp_ip, argsfile, &size,
sizeof(cmd_line) - 1))) {
......@@ -189,6 +210,8 @@ void netboot(uip_ipaddr_t *tftp_ip, char *bootfile, char *argsfile, char *args)
struct boot_info bi = {
.kernel = payload,
.cmd_line = cmd_line,
.ramdisk_addr = ramdisk,
.ramdisk_size = ramdisk_size,
};
boot(&bi);
......@@ -224,7 +247,7 @@ int netboot_entry(void)
&bootfile, &argsfile))
printf("ERROR: Failed to read netboot parameters from flash\n");
netboot(tftp_ip, bootfile, argsfile, cmd_line);
netboot(tftp_ip, bootfile, argsfile, cmd_line, NULL);
// We should never get here.
printf("Got to the end!\n");
......
......@@ -18,7 +18,8 @@
#include "net/uip.h"
/* argsfile takes precedence before args. All parameters can be NULL. */
void netboot(uip_ipaddr_t *tftp_ip, char *bootfile, char *argsfile, char *args);
void netboot(uip_ipaddr_t *tftp_ip, char *bootfile, char *argsfile, char *args,
char *ramdiskfile);
int netboot_entry(void);
int try_dhcp(uip_ipaddr_t *my_ip,
uip_ipaddr_t *next_ip,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment