From: Simon Glass <sjg@chromium.org> Add a struct pxe_context parameter to extlinux_boot() and extlinux_read_all() so the caller controls which context is used. This is a preparatory step towards removing the embedded ctx from struct extlinux_plat. All callers (extlinux, pxe, vbe_abrec) pass &plat->ctx, preserving the existing behaviour. Signed-off-by: Simon Glass <sjg@chromium.org> --- boot/bootmeth_extlinux.c | 12 ++++++++---- boot/bootmeth_pxe.c | 12 ++++++++---- boot/ext_pxe_common.c | 28 +++++++++++++--------------- boot/vbe_abrec_os.c | 11 +++++++---- include/extlinux.h | 10 ++++++---- 5 files changed, 42 insertions(+), 31 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index 0cc8c2bf9a5..1fd2547d2b3 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -217,15 +217,19 @@ 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, - false); + struct extlinux_plat *plat = dev_get_plat(dev); + + return extlinux_boot(dev, bflow, &plat->ctx, extlinux_getfile, true, + bflow->fname, false); } #if CONFIG_IS_ENABLED(BOOTSTD_FULL) static int extlinux_local_read_all(struct udevice *dev, struct bootflow *bflow) { - return extlinux_read_all(dev, bflow, extlinux_getfile, true, - bflow->fname); + struct extlinux_plat *plat = dev_get_plat(dev); + + return extlinux_read_all(dev, bflow, &plat->ctx, extlinux_getfile, + true, bflow->fname); } #endif diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 6c022e31688..91e05a44841 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -145,15 +145,19 @@ 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, false); + struct extlinux_plat *plat = dev_get_plat(dev); + + return extlinux_boot(dev, bflow, &plat->ctx, extlinux_pxe_getfile, + false, bflow->subdir, false); } #if CONFIG_IS_ENABLED(BOOTSTD_FULL) static int extlinux_pxe_read_all(struct udevice *dev, struct bootflow *bflow) { - return extlinux_read_all(dev, bflow, extlinux_pxe_getfile, false, - bflow->subdir); + struct extlinux_plat *plat = dev_get_plat(dev); + + return extlinux_read_all(dev, bflow, &plat->ctx, + extlinux_pxe_getfile, false, bflow->subdir); } #endif diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c index 59d878883bf..46302d3e962 100644 --- a/boot/ext_pxe_common.c +++ b/boot/ext_pxe_common.c @@ -97,25 +97,24 @@ 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, bool restart) + struct pxe_context *ctx, pxe_getfile_func getfile, + bool allow_abs_path, const char *bootfile, bool restart) { - struct extlinux_plat *plat = dev_get_plat(dev); ulong addr; int ret; /* if we have already selected a label, just boot it */ - if (plat->ctx.label) { - plat->ctx.fake_go = bflow->flags & BOOTFLOWF_FAKE_GO; - ret = pxe_boot(&plat->ctx); + if (ctx->label) { + ctx->fake_go = bflow->flags & BOOTFLOWF_FAKE_GO; + ret = pxe_boot(ctx); } else { ret = extlinux_setup(dev, bflow, getfile, allow_abs_path, - bootfile, &plat->ctx); + bootfile, ctx); if (ret) return log_msg_ret("elb", ret); - plat->ctx.restart = restart; + ctx->restart = restart; addr = map_to_sysmem(bflow->buf); - ret = pxe_process_str(&plat->ctx, addr, false); + ret = pxe_process_str(ctx, addr, false); } if (ret) return log_msg_ret("elb", -EFAULT); @@ -124,20 +123,19 @@ int extlinux_boot(struct udevice *dev, struct bootflow *bflow, } int extlinux_read_all(struct udevice *dev, struct bootflow *bflow, - pxe_getfile_func getfile, bool allow_abs_path, - const char *bootfile) + struct pxe_context *ctx, pxe_getfile_func getfile, + bool allow_abs_path, const char *bootfile) { - struct extlinux_plat *plat = dev_get_plat(dev); ulong addr; int ret; ret = extlinux_setup(dev, bflow, getfile, allow_abs_path, bootfile, - &plat->ctx); + ctx); if (ret) return log_msg_ret("era", ret); addr = map_to_sysmem(bflow->buf); - plat->ctx.pxe_file_size = bflow->size; - ret = pxe_probe(&plat->ctx, addr, false); + ctx->pxe_file_size = bflow->size; + ret = pxe_probe(ctx, addr, false); if (ret) return log_msg_ret("elb", -EFAULT); diff --git a/boot/vbe_abrec_os.c b/boot/vbe_abrec_os.c index 3bf2727a6e9..7d5c9bc9dcb 100644 --- a/boot/vbe_abrec_os.c +++ b/boot/vbe_abrec_os.c @@ -204,6 +204,7 @@ err_buf: static int vbe_abrec_boot(struct udevice *dev, struct bootflow *bflow) { + struct extlinux_plat *plat = dev_get_plat(dev); const struct bootflow_img *img; int ret; @@ -230,15 +231,17 @@ static int vbe_abrec_boot(struct udevice *dev, struct bootflow *bflow) printf("Loading OS FIT%s\n", img ? " keeping existing FDT" : ""); - return extlinux_boot(dev, bflow, vbe_abrec_getfile, true, bflow->fname, - img); + return extlinux_boot(dev, bflow, &plat->ctx, vbe_abrec_getfile, true, + bflow->fname, img); } #if CONFIG_IS_ENABLED(BOOTSTD_FULL) static int vbe_abrec_read_all(struct udevice *dev, struct bootflow *bflow) { - return extlinux_read_all(dev, bflow, vbe_abrec_getfile, true, - bflow->fname); + struct extlinux_plat *plat = dev_get_plat(dev); + + return extlinux_read_all(dev, bflow, &plat->ctx, vbe_abrec_getfile, + true, bflow->fname); } #endif diff --git a/include/extlinux.h b/include/extlinux.h index 4b5a8f316a8..cf9191874f0 100644 --- a/include/extlinux.h +++ b/include/extlinux.h @@ -54,6 +54,7 @@ int extlinux_set_property(struct udevice *dev, const char *property, * * @dev: bootmeth device * @bflow: Bootflow to boot + * @ctx: PXE context to use for booting * @getfile: Function to use to read files * @allow_abs_path: true to allow absolute paths * @bootfile: Bootfile whose directory loaded files are relative to, NULL if @@ -63,14 +64,15 @@ int extlinux_set_property(struct udevice *dev, const char *property, * 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, bool restart); + struct pxe_context *ctx, pxe_getfile_func getfile, + bool allow_abs_path, const char *bootfile, bool restart); /** * extlinux_read_all() - read all files for a bootflow * * @dev: Bootmethod device to boot * @bflow: Bootflow to read + * @ctx: PXE context to use for reading * @getfile: Function to use to read files * @allow_abs_path: true to allow absolute paths * @bootfile: Bootfile whose directory loaded files are relative to, NULL if @@ -78,7 +80,7 @@ int extlinux_boot(struct udevice *dev, struct bootflow *bflow, * Return: 0 if OK, -EIO on I/O error, other -ve on other error */ int extlinux_read_all(struct udevice *dev, struct bootflow *bflow, - pxe_getfile_func getfile, bool allow_abs_path, - const char *bootfile); + struct pxe_context *ctx, pxe_getfile_func getfile, + bool allow_abs_path, const char *bootfile); #endif -- 2.43.0