From patchwork Fri Jan 9 23:11:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1427 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=1768000469; bh=w7J7hTrNghNULuXnYCuuaL2RwmCf2dV3dq6RDy+rJRY=; 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=wf/sCJQOibEuwSGPJ7rFaLzQl880iiMp4SCUZLXTL+NXfrIstc5B+F9O/j/f+uCxC 9CXl8W3ilRbMfnBtBKhmxrEXxuRYrtMKgw4VBNZ/FQ0w5wTawFuCsI3bJ0EMGTmGEs 8mRelXGKbbDCUToz763+M3HK6Zi9t4w3bjPGPpJfDEPaaBvFhRK6TMF6bcCGaIXiHN oFBZmYlV6fNfZSTNPi+10MNvKih3DpCiWRSSX98HNPZLbeb4Nd9V7qtLHiOouYahiB jh4PgNii6sQbPi+prm1CCZQTZGAdRnuUBKs4uJz4OomZv+ATDYf5H4PpR3e4SMYriJ i+k3wCwYd1Jww== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 25DBF69254 for ; Fri, 9 Jan 2026 16:14:29 -0700 (MST) 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 gecwktnOPZCW for ; Fri, 9 Jan 2026 16:14:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000469; bh=w7J7hTrNghNULuXnYCuuaL2RwmCf2dV3dq6RDy+rJRY=; 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=wf/sCJQOibEuwSGPJ7rFaLzQl880iiMp4SCUZLXTL+NXfrIstc5B+F9O/j/f+uCxC 9CXl8W3ilRbMfnBtBKhmxrEXxuRYrtMKgw4VBNZ/FQ0w5wTawFuCsI3bJ0EMGTmGEs 8mRelXGKbbDCUToz763+M3HK6Zi9t4w3bjPGPpJfDEPaaBvFhRK6TMF6bcCGaIXiHN oFBZmYlV6fNfZSTNPi+10MNvKih3DpCiWRSSX98HNPZLbeb4Nd9V7qtLHiOouYahiB jh4PgNii6sQbPi+prm1CCZQTZGAdRnuUBKs4uJz4OomZv+ATDYf5H4PpR3e4SMYriJ i+k3wCwYd1Jww== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 137BE69243 for ; Fri, 9 Jan 2026 16:14:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000467; bh=uJ10JBpoISkyeppd2aJY1OIy5qIOg0NaINY3DfPPRm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k2iHcu5nZTC5FF+QXq9gwnkDyk3IGnde8Zgp7GdY/C8oWQ0VCOjqzsCNd5+oDqAKN ju3NwKbluIM++HCBINmJ8bl5zYlwVWG5u9H2amYYDh/9p0K1DvY+2/nIR8pya7Uhkz Zp5bEDkP6f9BcuVbLB9hxjPfCiBMkpvqbL0tknUCf60ZwsoJgjccvSRNiJd7yt+gDF EcUn5Fss8Z04wAzelnEMFVwd9hf3/rE4aYVw15qvsivDHAGz+jX8LCYtIBBUjxu87w Vj923V9xlpzQaABlMsadkXSEe06mgZzRAFOms9c321/A5rXoYIT8b5plrXJ4j0/0Un v3cITxFityEGg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 70FE369218; Fri, 9 Jan 2026 16:14:27 -0700 (MST) 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 Ndx5g9y65Isk; Fri, 9 Jan 2026 16:14:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000463; bh=Qd9Ska3ZK71CvU6mI3l9YObdjGlaq/jss6rxNfhyA3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mcx3nWaBQTCE+SqlNHOEjSROjCHVRmEkXcZUfy3+qicyYw8cs7WlkZuRVKlGbnGoi yDbmEXy9vu07idAJFY/7f7Xs+7fjZ+a+YprjO7NuqFMrZTMydmci/GQPs7aN9wIA0M OsYITpbSE42JmXE3uvPcgn3ZR4nOH91NQjkTwhWZk5I/2o4zJ+bWYVyxlcKoOVeucG /l54d8Yg6v7qE4v1uomWQ9J5Htj5GgX6zcsYR3cTyAZkV/lSl8t84emifUYAH47amg 1kk6o39LBC2mvwLVXYqldKW4r6IB3OImfEPscPB7uGkTxqAsrPUwajFzzQtTQ62Q85 e7U7VF2mv9t4w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1768369221; Fri, 9 Jan 2026 16:14:23 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:40 -0700 Message-ID: <20260109231151.4056804-32-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZKNKEUBEKPFI3LOIOMP5CCDZCUMAJIZD X-Message-ID-Hash: ZKNKEUBEKPFI3LOIOMP5CCDZCUMAJIZD 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: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 31/32] boot: pxe: Split pxe_load_label() into load and setup phases 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 Split pxe_load_label() into two functions to allow more flexible use: - pxe_load_label(): Handles localboot setup, FIT detection, and calls pxe_load_files() to load all files (kernel, initrd, FDT, overlays) - pxe_setup_label(): Processes the FDT (applying overlays), determines the FDT address, and saves boot parameters to the context This separation allows callers to load files without immediately setting up boot parameters, which is useful for inspection or validation before booting. Update label_boot() to call both functions in sequence. Copy fdt_addr to conf_fdt at the end of pxe_load_label() to maintain backward compatibility for callers that only call pxe_load_label() without pxe_setup_label(). Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 28 +++++++++++++++++++++++----- include/pxe_utils.h | 19 ++++++++++++++++--- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 8609d832aa6..49934d626ee 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -687,10 +687,6 @@ int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) { - char fit_addr[200]; - const char *conf_fdt_str; - ulong conf_fdt = 0; - char initrd_str[28] = ""; char *fdtfile = NULL; bool is_fit; int ret; @@ -722,6 +718,25 @@ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label) if (ret) return ret; + /* Copy fdt_addr to conf_fdt for callers that don't use pxe_setup_label */ + ctx->conf_fdt = ctx->fdt_addr; + + return 0; +} + +int pxe_setup_label(struct pxe_context *ctx, struct pxe_label *label) +{ + char fit_addr[200]; + const char *conf_fdt_str; + ulong conf_fdt = 0; + char initrd_str[28] = ""; + bool is_fit; + int ret; + + /* Check for FIT case: FDT comes from FIT image, not a separate file */ + is_fit = label->fdt && label->kernel_label && + !strcmp(label->kernel_label, label->fdt); + /* for FIT, append the configuration identifier */ snprintf(fit_addr, sizeof(fit_addr), "%lx%s", ctx->kern_addr, label->config ? label->config : ""); @@ -850,11 +865,14 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) } } - /* Load files if not already loaded */ + /* Load files and set up boot params if not already done */ if (!ctx->label) { ret = pxe_load_label(ctx, label); if (ret) return 1; + ret = pxe_setup_label(ctx, label); + if (ret) + return 1; } if (label->ipappend & 0x1) { diff --git a/include/pxe_utils.h b/include/pxe_utils.h index aa73f5ff7f0..a03e00e2a4a 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -464,9 +464,9 @@ int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, /** * pxe_load_label() - Load kernel/initrd/FDT for a label * - * Loads the files specified in the label into memory and saves the - * addresses and sizes in @ctx. Call this only when ready to boot or - * inspect loaded files. + * Loads the files specified in the label into memory. Call + * pxe_setup_label() after this to process the FDT and set up + * boot parameters. * * @ctx: PXE context with getfile callback * @label: Label whose files to load @@ -475,6 +475,19 @@ int pxe_load_files(struct pxe_context *ctx, struct pxe_label *label, */ int pxe_load_label(struct pxe_context *ctx, struct pxe_label *label); +/** + * pxe_setup_label() - Set up boot parameters for a loaded label + * + * Processes the FDT (applying overlays if needed) and saves the boot + * parameters in @ctx. Call this after pxe_load_label(). + * + * @ctx: PXE context with loaded files + * @label: Label to set up + * Return: 0 on success, -ENOSPC if initrd string too long, -ENOMEM if + * out of memory + */ +int pxe_setup_label(struct pxe_context *ctx, struct pxe_label *label); + /* * Entry point for parsing a menu file. nest_level indicates how many times * we've nested in includes. It will be 1 for the top level menu file.