From patchwork Sun Mar 22 23:57:08 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2042 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223875; bh=l7rRpD8akjBf338iXyYruN+b9RuXDB/tGk4G5psJVfg=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=DUmmLDEStYogRQwJmpMJc+SLfg7F9bboYyDnkyGD9q8M2dr/OZvLNGVslYTGzMvT6 CeGBwoRlsuHUGCsOd+2yWiccb8Suola/ED4jHlqHGnkDprMje+CvyN4Ip6vv5l5UND zmSyRmRvyqTM60o4Lze+c5SKjV5Nk9svQb4qBa7aUw4pxjk2j2hEq8sJhhpUbDOoiX ADCATWKkRSx/FkWvp5AMsI9ZNy3iG8ajMUxJyaTqVdg/FyyHauCr/R1zKlrOyI9uZI wflwBwXO0sQdMEG54RCiCjt6c8aF5MxZR1tjE4kGlG7XV0B1Luzbd0c5eNrNF1GkvO ayNcsgiEU5olw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5DE336A1DC for ; Sun, 22 Mar 2026 17:57:55 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id PGfrf_fBgjix for ; Sun, 22 Mar 2026 17:57:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223870; bh=l7rRpD8akjBf338iXyYruN+b9RuXDB/tGk4G5psJVfg=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Vq+SDevtgxQaYoT40vGtY8htBOTYqgSPVVR9CtF1pJMDNhR8t6GOMGREa+M30Iryi ZEs1v0PEChPZiUtfQtNtPrlqaTA45u6iItChBK/4DvdOaXx9ankLjxImeGx3bISHd7 214Gtl6APaAmqK9GrQ9TtCaJ0HVR3ZeUsj9foJro0p4aOWMKHiegkvv5LTfYXAHDNK v/GORSSCzTh8vgCCIc44jlqHbtuYmqjhIb2dYGhytTCt/OrZzDhIrqX/P1Ds/QS0IP hx20wUSUpmEWCttC1f0Sy2iwofXoiCkXpPJIxMRtohb1miqv2VFsYJAealPqCo2NWt 8WpD5bLsS34xw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ECEFB6A1FE for ; Sun, 22 Mar 2026 17:57:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223865; bh=DDVBbumoqv8EwAW3uTLrTPuj88SmPnEPD35uie/3zww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fn5FEiN1ZvUkGSfSZQvJzpedhjysq0Hle1tCNHOqDFI3TxiggMlYZmAZH/VilcP6x QesvQN2QtFQAT9Hgi8VFfhjvNAMoozigFGVDceOON57qxkayGijjnd2ekGUcCE7q3a dgA1fuoX6JUMkH9GkLb6vr1RzduYJdbvrgEih4eYFep0ZTaGBy2XUHL4lOr8+VhgDe Gi+JhEIJJUCTJZ3vEyoHel3juQIKq6P+DInvn0wgY7VehW2vofmR8K4fvPYxiNYBL+ q0SJM3fpnPOc2gbVIH041CRsrS3IJkSaNkkPOfdgW+M55AgthUfDiXtNqKB01qQyzA cyezyQAqmOBlg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6D2216A1DF; Sun, 22 Mar 2026 17:57:45 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id p7YfhzIhXzQV; Sun, 22 Mar 2026 17:57:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223864; bh=zxad+suMavaVI6BkBKPEvBvPpuddtveRIHpF5XwBQso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3V8Qs6lnnmPX6/gxw4yWjoBSuhFExlQ9ZVAbAAzPZuQn3rH8QRiPTy4kgcfDTgr8 U5WG6FfeFZunpYFsmBoHQQ/aXYsvWoiqV7Am4DPZlq4Dd/0EPzUTKgFtnvanjeybGz pdXzcnLSZZLS99vIemqGh3rvWmS+xJrrJu4OeoIWlS/aCT8hgq+5xFWjml66teAa9v klP+DLv07C2R7u+vwxVEzECL+HzWMQCsIiP3BeGKO725e40LT6igHTd4Ql4IpMm2V6 HQqTBkd4El/7B+g0x7ZcDOQe7mIkQJ4ZiPVCloQhNIhWlSUwED4uHARI2BPppaE0my 4S9GOpTgyJu7Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8A5196A1DA; Sun, 22 Mar 2026 17:57:44 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:08 -0600 Message-ID: <20260322235719.1729267-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UCUNKVZMU4XCTBFUDQAMK5UTKY4YQTKK X-Message-ID-Hash: UCUNKVZMU4XCTBFUDQAMK5UTKY4YQTKK X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/14] extlinux: Pass pxe_context to extlinux_boot() and extlinux_read_all() List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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 --- 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