
From: Simon Glass <sjg@chromium.org> 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> --- boot/bootmeth_extlinux.c | 3 ++- boot/bootmeth_pxe.c | 2 +- boot/ext_pxe_common.c | 3 ++- boot/pxe_utils.c | 7 ++++++- include/extlinux.h | 4 +++- include/pxe_utils.h | 3 +++ 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index 782e5f7ec76..383f33e681c 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -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) diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 18d8ab446e0..30caadc8f3e 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -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) diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c index 2037099708a..67d7b68d310 100644 --- a/boot/ext_pxe_common.c +++ b/boot/ext_pxe_common.c @@ -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); } diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 8ff06ce6c52..f524b0a1dd3 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -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"); diff --git a/include/extlinux.h b/include/extlinux.h index f64597ebdef..4b5a8f316a8 100644 --- a/include/extlinux.h +++ b/include/extlinux.h @@ -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 diff --git a/include/pxe_utils.h b/include/pxe_utils.h index a63d0123059..28f83228167 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -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; }; /** -- 2.43.0