From patchwork Sat Jan 10 20:28:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1465 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=1768077048; bh=0O0EyQ4eQIVcDPb6xIws+HjkXmlSFrY8Jj5IQQSKaNM=; 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=VEN28XY3z9FhD8R+ywprk05TFGiNh0PuH7sXCNaGCTlCcQUN5pKxGp+4JCImoBRct E5Vjdll6IeSGGAh6RMA31tZQM4ePMjzwhnERux/m3q1YgtryPkDOAiMtvQheoHktcW WY8QUhSL0BhqyLhVw9dRIfYqr5tR7irk0us4U0OMH3+cUuLyCIaV17ANCLFA+Kl5bQ +7RHy2IdWYugEFjENHwn97C1yKwx82i/wunTNTCN53MeK2vYHYTR0Q1v4d2hoH3dLP zdDin/UewN06iYmTeztOABCdOjO+2UZvslXjM2rJEgxyonzDH1rstsVlH2Ioj5l3E8 62dIfcKtZPvCg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7484369299 for ; Sat, 10 Jan 2026 13:30:48 -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 66Wu5DvGb8MX for ; Sat, 10 Jan 2026 13:30:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077048; bh=0O0EyQ4eQIVcDPb6xIws+HjkXmlSFrY8Jj5IQQSKaNM=; 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=VEN28XY3z9FhD8R+ywprk05TFGiNh0PuH7sXCNaGCTlCcQUN5pKxGp+4JCImoBRct E5Vjdll6IeSGGAh6RMA31tZQM4ePMjzwhnERux/m3q1YgtryPkDOAiMtvQheoHktcW WY8QUhSL0BhqyLhVw9dRIfYqr5tR7irk0us4U0OMH3+cUuLyCIaV17ANCLFA+Kl5bQ +7RHy2IdWYugEFjENHwn97C1yKwx82i/wunTNTCN53MeK2vYHYTR0Q1v4d2hoH3dLP zdDin/UewN06iYmTeztOABCdOjO+2UZvslXjM2rJEgxyonzDH1rstsVlH2Ioj5l3E8 62dIfcKtZPvCg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5FF5569291 for ; Sat, 10 Jan 2026 13:30:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077046; bh=WtBunDvvKMcvsyAuUVn+HvptxZ8oDY86x1FEh+60Ws4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hGC584EoHRQ45m0fDEVgvFkSbRGyMT6z/5pMQyjRFMyMfcn3MkuJSvM1gw2/j825x TeGyb6/hKSiaRylJDMnmMkpUKO/gRWPKQyeXh61YS9kZjWnm/sktWAElXeL+2Ld8vp x7EOdPw70o+IiJ00A/MDiGgWEtx46O4CZ+V4zEZG7AMQYog2Fn89dTcCpqmgcx+t75 OYVE6Dwc2pqD5CwxscNiVPKXzF+lHjKFlshcIPtdYCvCsnowAlLcn+LFJbi5qEZabd lFlXobz6XFtSNjCp6656sJilsWB/qR3iZ4OQZyAQFuV1fDs3sE436Iv3mBgHHNg2lP rgkv/53J0MMyw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4BD8B6927E; Sat, 10 Jan 2026 13:30:46 -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 XzQd_hEH9hlU; Sat, 10 Jan 2026 13:30:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768077042; bh=+8bzvZD2Guk0oPKaEI+lkvSI6qFb1tHmCRX3F2pxasM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ri8AX52Cg63rcqhb9CGGDVLyKjvFLdr7gpb+9Aq6l67p1oz9RwwCsj2kl880WKOKT 3FmITYssSzXsUbRO0HI4aImlvrDoYtTkSn9tZ6+OLuhkJ9Po+f1SVZZvzNPuOzs/d+ X3wIZc5T5NH38s6VODy7rENDD+T4VxtTD0UwCcBGDpPPvgxQZ40WiFWKQJsLeWeSpv WYr67bfDcWp9S2CUO9N8IIgSaB9QwjmO/h/DXeIjO/HMB/D9ubJrmHa+i7afO27DVa BdEVKarZVLhuQRWKxGWIncrEKLUifiXWFWCNoV/rceFI0mk8BRgNVuybr3QgkwALeR JNlktUyQwy/cg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id DCC1C69186; Sat, 10 Jan 2026 13:30:41 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 13:28:51 -0700 Message-ID: <20260110202906.187370-20-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260110202906.187370-1-sjg@u-boot.org> References: <20260110202906.187370-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YRCOQSRMQWM6BWSDFWJPPBEKMN6XQ7TO X-Message-ID-Hash: YRCOQSRMQWM6BWSDFWJPPBEKMN6XQ7TO 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 19/26] boot: pxe: Update parse_pxefile() to take struct abuf 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 Change parse_pxefile() to accept a struct abuf instead of separate address and size parameters. This provides a cleaner interface and allows the function to use abuf_data() directly without needing to call map_sysmem(). Callers now create an abuf with abuf_map_sysmem() to wrap the memory region before calling parse_pxefile(). Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 12 +++++------- include/pxe_utils.h | 9 ++++----- test/boot/pxe.c | 20 +++++++++++++++----- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 3f751f25bea..d2ba0412906 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1004,20 +1004,16 @@ void pxe_menu_uninit(struct pxe_menu *cfg) free(cfg); } -struct pxe_menu *parse_pxefile(struct pxe_context *ctx, unsigned long menucfg, - ulong size) +struct pxe_menu *parse_pxefile(struct pxe_context *ctx, struct abuf *buf) { struct pxe_menu *cfg; - char *buf; int r; cfg = pxe_menu_init(); if (!cfg) return NULL; - buf = map_sysmem(menucfg, size); - r = parse_pxefile_top(ctx, buf, menucfg, cfg, 1); - unmap_sysmem(buf); + r = parse_pxefile_top(ctx, abuf_data(buf), abuf_addr(buf), cfg, 1); if (r < 0) { pxe_menu_uninit(cfg); @@ -1305,9 +1301,11 @@ static struct pxe_menu *pxe_prepare(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt) { struct pxe_menu *cfg; + struct abuf buf; int ret; - cfg = parse_pxefile(ctx, pxefile_addr_r, ctx->pxe_file_size); + abuf_init_addr(&buf, pxefile_addr_r, ctx->pxe_file_size); + cfg = parse_pxefile(ctx, &buf); if (!cfg) { printf("Error parsing config file\n"); return NULL; diff --git a/include/pxe_utils.h b/include/pxe_utils.h index e8045511c6a..9682956932b 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -3,6 +3,7 @@ #ifndef __PXE_UTILS_H #define __PXE_UTILS_H +#include #include #include #include @@ -292,19 +293,17 @@ int get_pxelinux_path(struct pxe_context *ctx, const char *file, void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg); /** - * parse_pxefile() - Parse a pxe file + * parse_pxefile() - Parse a PXE file * * Parse the top-level file. Any includes are stored in cfg->includes and * should be processed by calling pxe_process_includes(). * * @ctx: PXE context (provided by the caller) - * @menucfg: Address of the PXE file in memory - * @size: Size of file in bytes + * @buf: Buffer containing the PXE file * Return: NULL on error, otherwise a pointer to a pxe_menu struct. Use * pxe_menu_uninit() to free it. */ -struct pxe_menu *parse_pxefile(struct pxe_context *ctx, ulong menucfg, - ulong size); +struct pxe_menu *parse_pxefile(struct pxe_context *ctx, struct abuf *buf); /** * pxe_process_includes() - Process include files in a parsed menu diff --git a/test/boot/pxe.c b/test/boot/pxe.c index 1a990a8e348..56b1dfb4c49 100644 --- a/test/boot/pxe.c +++ b/test/boot/pxe.c @@ -139,6 +139,7 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) struct pxe_context ctx; struct pxe_label *label; struct pxe_menu *cfg; + struct abuf buf; char name[16]; uint i; int ret; @@ -161,7 +162,8 @@ static int pxe_test_parse_norun(struct unit_test_state *uts) ut_asserteq(1, ret); /* get_pxe_file returns 1 on success */ /* Parse the config file */ - cfg = parse_pxefile(&ctx, addr, ctx.pxe_file_size); + abuf_init_addr(&buf, addr, ctx.pxe_file_size); + cfg = parse_pxefile(&ctx, &buf); ut_assertnonnull(cfg); /* Process any include files */ @@ -448,6 +450,7 @@ static int pxe_test_fdtdir_norun(struct unit_test_state *uts) struct pxe_label *label; struct pxe_menu *cfg; ulong addr = PXE_LOAD_ADDR; + struct abuf buf; void *fdt; ut_assertnonnull(fs_image); @@ -465,7 +468,8 @@ static int pxe_test_fdtdir_norun(struct unit_test_state *uts) /* Read and parse the config file */ ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); - cfg = parse_pxefile(&ctx, addr, ctx.pxe_file_size); + abuf_init_addr(&buf, addr, ctx.pxe_file_size); + cfg = parse_pxefile(&ctx, &buf); ut_assertnonnull(cfg); /* Consume parsing output */ @@ -557,6 +561,7 @@ static int pxe_test_errors_norun(struct unit_test_state *uts) struct pxe_label *label; struct pxe_menu *cfg; ulong addr = PXE_LOAD_ADDR; + struct abuf buf; void *fdt; ut_assertnonnull(fs_image); @@ -574,7 +579,8 @@ static int pxe_test_errors_norun(struct unit_test_state *uts) /* Read and parse the config file */ ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); - cfg = parse_pxefile(&ctx, addr, ctx.pxe_file_size); + abuf_init_addr(&buf, addr, ctx.pxe_file_size); + cfg = parse_pxefile(&ctx, &buf); ut_assertnonnull(cfg); /* Consume parsing output */ @@ -675,6 +681,7 @@ static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts) struct pxe_label *label; struct pxe_menu *cfg; ulong addr = PXE_LOAD_ADDR; + struct abuf buf; void *fdt; ut_assertnonnull(fs_image); @@ -693,7 +700,8 @@ static int pxe_test_overlay_no_addr_norun(struct unit_test_state *uts) ctx.quiet = true; ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); - cfg = parse_pxefile(&ctx, addr, ctx.pxe_file_size); + abuf_init_addr(&buf, addr, ctx.pxe_file_size); + cfg = parse_pxefile(&ctx, &buf); ut_assertnonnull(cfg); /* Process any include files */ @@ -1248,6 +1256,7 @@ static int pxe_test_fit_embedded_fdt_norun(struct unit_test_state *uts) struct pxe_label *label; struct pxe_menu *cfg; ulong addr = PXE_LOAD_ADDR; + struct abuf buf; ut_assertnonnull(fs_image); ut_assertnonnull(cfg_path); @@ -1268,7 +1277,8 @@ static int pxe_test_fit_embedded_fdt_norun(struct unit_test_state *uts) /* Read and parse the config file */ ut_asserteq(1, get_pxe_file(&ctx, cfg_path, addr)); - cfg = parse_pxefile(&ctx, addr, ctx.pxe_file_size); + abuf_init_addr(&buf, addr, ctx.pxe_file_size); + cfg = parse_pxefile(&ctx, &buf); ut_assertnonnull(cfg); /* Consume parsing output */