From patchwork Tue Mar 24 22:19:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2052 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=1774390790; bh=w4lzqRxRDMg3DPc85i1etscslmNvPNkZaQYfHb1orQo=; 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=F+SfdaLGsplyuTTYyIuS5klEOkVePtlEtTDZZZbEt6zTJ1lFqGVScHgs9vOhOseNB Ld2OxIpmod2phya1tBTllmZrk/r5wG8HHfQd5MTnLR1EQuNHNp43Pb6+fRnIagpt+l /L4Yv7q9cp7LRTR0tMV20hC5S/Usi4GfnxcBSVOUUMJ7P6wMWjz8rOP7M0iscSAJpH DkTeVKO3JDvyS9szLZDmnSvzCXiNSKUi3ba4wsQnBosN+ugrIE7lnqBIiujJ2Ei+HF s3LcOXDPm3sgB1ws/4+9Fpe6c3XG/E08mid5LC8m+a4LsCCNs8EykpxQZIed/hgbGZ fE48MN2qYBfkg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 25D756A228 for ; Tue, 24 Mar 2026 16:19:50 -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 lyXrQjj2_Es5 for ; Tue, 24 Mar 2026 16:19:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774390790; bh=w4lzqRxRDMg3DPc85i1etscslmNvPNkZaQYfHb1orQo=; 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=F+SfdaLGsplyuTTYyIuS5klEOkVePtlEtTDZZZbEt6zTJ1lFqGVScHgs9vOhOseNB Ld2OxIpmod2phya1tBTllmZrk/r5wG8HHfQd5MTnLR1EQuNHNp43Pb6+fRnIagpt+l /L4Yv7q9cp7LRTR0tMV20hC5S/Usi4GfnxcBSVOUUMJ7P6wMWjz8rOP7M0iscSAJpH DkTeVKO3JDvyS9szLZDmnSvzCXiNSKUi3ba4wsQnBosN+ugrIE7lnqBIiujJ2Ei+HF s3LcOXDPm3sgB1ws/4+9Fpe6c3XG/E08mid5LC8m+a4LsCCNs8EykpxQZIed/hgbGZ fE48MN2qYBfkg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0D9986A23D for ; Tue, 24 Mar 2026 16:19:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774390787; bh=VH89sRX5OMUW6+eAv452hkO4wjNfc+vAyclWEQ9bYBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W98wGCWr+6pV2Y1iMrC8+Y5w4ZOPGJVMTYrI7j6Bo0NMc2qliE3ZyZM+c7qyFCvae wsAhL1JJTBzCAVwqP1xu0mpDpF1drXDi1XqPOunuKjYAM6TSe7NfRYBWLklEPLv9vi hCco7qNrRrlv7Xss31SoR7SXagBcGmtyeaNLs790xH0yer3x+9qEfFmwzOpCJzYK9L DNY5fwdqkle64vnFgdOiz+KCbcz8cVPhGH3fCL+d6cEI8YshzQbLsS146dJegg7ha4 31QXoI5QTlUS9FhK+TiSlQmQ7OA2xGKLQxWw9TPWwpZ0hu+XeCRy4KlplgaWZd1G/t KvP7w0YDmTE7A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3EC746A23E; Tue, 24 Mar 2026 16:19:47 -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 9eDC3o7Hs0eV; Tue, 24 Mar 2026 16:19:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774390783; bh=Qhx3nnT0VQyiGKh8nhIbVcdzGTczWWzVzArpgqcEZ8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=peR3aBFnB8B06y5NcaxcAW+PIEEw7/OwSEFJvb4Qqjruw8oDuvUVuL7af9nHy9DcN yVW1fQpKIlQQJKpkvtRbf0XWuPKnHG5ZW80l/GV761dRtM0R9ouj0YBJsk5Q87rYfk hCnBnQ9/j2qcNtgTW2mxzTVM7UOqSGnlF4zsqwALweEvTjAwnJ2qsfwtmxRCHnBv8r 85LaiuvhVAO27ZAqCH6lAfA4TaOiup1njKHDwc/vtWg2RFqxIukpBZF4JcLQ+YHxuy 4rIlm9t8UXpiNaxHUgCM6h+IBTBTnZb92x6ghZOWMXPnGBkT/W4ATiA7nQQj8nWBSR 3302LXvT73GNw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D77D56A1DD; Tue, 24 Mar 2026 16:19:42 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 24 Mar 2026 16:19:00 -0600 Message-ID: <20260324221911.3678307-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260324221911.3678307-1-sjg@u-boot.org> References: <20260324221911.3678307-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: SC7VAIDZ6JRQ65GXBSFG5KWEN7BNZR6S X-Message-ID-Hash: SC7VAIDZ6JRQ65GXBSFG5KWEN7BNZR6S 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 06/12] pxe: Add pxe_boot_entry() to boot a specific label by index 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 pxe_boot_entry() which parses a PXE config, walks to the Nth label, loads its files and boots it. This is used by multi-entry bootmeths to boot the specific label that was selected during scanning, rather than presenting the full menu. Update extlinux_boot() to always use pxe_boot_entry(), so that each entry (including entry 0) boots its label directly without a menu. Signed-off-by: Simon Glass --- boot/ext_pxe_common.c | 3 ++- boot/pxe_utils.c | 30 ++++++++++++++++++++++++++++++ include/pxe_utils.h | 14 ++++++++++++++ test/boot/bootflow.c | 6 ++++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c index 8a59b29ead8..4ea7f8f455d 100644 --- a/boot/ext_pxe_common.c +++ b/boot/ext_pxe_common.c @@ -136,7 +136,8 @@ int extlinux_boot(struct udevice *dev, struct bootflow *bflow, return log_msg_ret("elb", ret); ctx->restart = restart; addr = map_to_sysmem(bflow->buf); - ret = pxe_process_str(ctx, addr, false); + + ret = pxe_boot_entry(ctx, addr, bflow->entry); } if (ret) return log_msg_ret("elb", -EFAULT); diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index f5f8e38de2e..a7c5e87bef0 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1510,3 +1510,33 @@ int pxe_boot(struct pxe_context *ctx) return 0; } + +int pxe_boot_entry(struct pxe_context *ctx, ulong addr, int entry) +{ + struct pxe_label *label; + struct pxe_menu *cfg; + int ret, i = 0; + void *ptr; + + ptr = map_sysmem(addr, 0); + ctx->pxe_file_size = strnlen(ptr, SZ_64K); + unmap_sysmem(ptr); + + cfg = pxe_prepare(ctx, addr, false); + if (!cfg) + return log_msg_ret("prp", -EINVAL); + + list_for_each_entry(label, &cfg->labels, list) { + if (i == entry) + goto found; + i++; + } + pxe_menu_uninit(cfg); + return log_msg_ret("lab", -ENOENT); + +found: + ret = label_boot(ctx, label); + pxe_menu_uninit(cfg); + + return ret; +} diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 3367230eb1c..8b607095721 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -611,4 +611,18 @@ void pxe_load(struct pxe_file *file, ulong addr, ulong size); */ void pxe_cleanup(struct pxe_context *ctx); +/** + * pxe_boot_entry() - Parse a PXE config and boot a specific entry by index + * + * This parses the config file, walks to the Nth label, loads its files and + * boots it. Used by multi-entry bootmeths to boot a specific label that was + * selected during scanning. + * + * @ctx: PXE context (must be set up with pxe_setup_ctx()) + * @addr: Address where config file is loaded + * @entry: Entry index (0 for first label, 1 for second, etc.) + * Return: Does not return on success, -ve on error + */ +int pxe_boot_entry(struct pxe_context *ctx, ulong addr, int entry); + #endif /* __PXE_UTILS_H */ diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 73ea1102af5..2ff203c186c 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1962,6 +1962,12 @@ static int bootflow_multi(struct unit_test_state *uts) bflow->os_name); ut_asserteq(1, bflow->entry); + /* Try booting the second entry (rescue) - exercises pxe_boot_entry() */ + ut_assertok(env_set("kernel_addr_r", "1000000")); + ut_assertok(env_set("ramdisk_addr_r", "2000000")); + std->cur_bootflow = bflow; + ut_asserteq(-EFAULT, bootflow_boot(bflow)); + return 0; } BOOTSTD_TEST(bootflow_multi, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE);