boot: Support restarting a bootm sequence from PXE
If a load-only FIT has already provided a devicetree, PXE boot may need to restart the bootm sequence, rather than starting an entirely new one, so that the devicetree is preserved and used for booting. Add support for this by adding a new field in the context and updating extlinux_boot() to receive the value as a new parameter. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -166,7 +166,8 @@ static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow)
|
||||
|
||||
static int extlinux_local_boot(struct udevice *dev, struct bootflow *bflow)
|
||||
{
|
||||
return extlinux_boot(dev, bflow, extlinux_getfile, true, bflow->fname);
|
||||
return extlinux_boot(dev, bflow, extlinux_getfile, true, bflow->fname,
|
||||
false);
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(BOOTSTD_FULL)
|
||||
|
||||
@@ -140,7 +140,7 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow,
|
||||
static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow)
|
||||
{
|
||||
return extlinux_boot(dev, bflow, extlinux_pxe_getfile, false,
|
||||
bflow->subdir);
|
||||
bflow->subdir, false);
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(BOOTSTD_FULL)
|
||||
|
||||
@@ -95,7 +95,7 @@ static int extlinux_setup(struct udevice *dev, struct bootflow *bflow,
|
||||
|
||||
int extlinux_boot(struct udevice *dev, struct bootflow *bflow,
|
||||
pxe_getfile_func getfile, bool allow_abs_path,
|
||||
const char *bootfile)
|
||||
const char *bootfile, bool restart)
|
||||
{
|
||||
struct extlinux_plat *plat = dev_get_plat(dev);
|
||||
ulong addr;
|
||||
@@ -109,6 +109,7 @@ int extlinux_boot(struct udevice *dev, struct bootflow *bflow,
|
||||
bootfile, &plat->ctx);
|
||||
if (ret)
|
||||
return log_msg_ret("elb", ret);
|
||||
plat->ctx.restart = restart;
|
||||
addr = map_to_sysmem(bflow->buf);
|
||||
ret = pxe_process(&plat->ctx, addr, false);
|
||||
}
|
||||
|
||||
@@ -570,8 +570,13 @@ static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label,
|
||||
|
||||
if (IS_ENABLED(CONFIG_CMD_BOOTM) && (fmt == IMAGE_FORMAT_FIT ||
|
||||
fmt == IMAGE_FORMAT_LEGACY)) {
|
||||
int states;
|
||||
|
||||
states = ctx->restart ? BOOTM_STATE_RESTART : BOOTM_STATE_START;
|
||||
log_debug("using bootm\n");
|
||||
ret = bootm_run(&bmi);
|
||||
ret = boot_run(&bmi, "ext", states | BOOTM_STATE_FINDOS |
|
||||
BOOTM_STATE_PRE_LOAD | BOOTM_STATE_FINDOTHER |
|
||||
BOOTM_STATE_LOADOS);
|
||||
/* Try booting an AArch64 Linux kernel image */
|
||||
} else if (IS_ENABLED(CONFIG_CMD_BOOTI) && fmt == IMAGE_FORMAT_BOOTI) {
|
||||
log_debug("using booti\n");
|
||||
|
||||
@@ -58,11 +58,13 @@ int extlinux_set_property(struct udevice *dev, const char *property,
|
||||
* @allow_abs_path: true to allow absolute paths
|
||||
* @bootfile: Bootfile whose directory loaded files are relative to, NULL if
|
||||
* none
|
||||
* @restart: true to use BOOTM_STATE_RESTART instead of BOOTM_STATE_START (only
|
||||
* supported with FIT / bootm)
|
||||
* Return: 0 if OK, -ve error code on failure
|
||||
*/
|
||||
int extlinux_boot(struct udevice *dev, struct bootflow *bflow,
|
||||
pxe_getfile_func getfile, bool allow_abs_path,
|
||||
const char *bootfile);
|
||||
const char *bootfile, bool restart);
|
||||
|
||||
/**
|
||||
* extlinux_read_all() - read all files for a bootflow
|
||||
|
||||
@@ -121,6 +121,8 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path,
|
||||
* @initrd_addr_str)
|
||||
* @initrd_str: initrd string to process (only used if @initrd_addr_str)
|
||||
* @conf_fdt: string containing the FDT address
|
||||
* @restart: true to use BOOTM_STATE_RESTART instead of BOOTM_STATE_START (only
|
||||
* supported with FIT / bootm)
|
||||
*/
|
||||
struct pxe_context {
|
||||
/**
|
||||
@@ -152,6 +154,7 @@ struct pxe_context {
|
||||
char *initrd_filesize;
|
||||
char *initrd_str;
|
||||
char *conf_fdt;
|
||||
bool restart;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user