From: Simon Glass <simon.glass@canonical.com> Change pxe_parse_include() to take just the memory address instead of both a buffer pointer and address. The function now calls map_sysmem() internally to get the buffer, simplifying the caller interface. Move the function to the bottom of the header file while we are here, since it will form part of the new API. Also mark 'inc' const since it is not used. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- boot/pxe_utils.c | 18 +++++++++++------- include/pxe_utils.h | 31 +++++++++++++++---------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index b55d736beb8..384a4e4f8ab 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1035,7 +1035,6 @@ int pxe_process_includes(struct pxe_context *ctx, struct pxe_menu *cfg, ulong base) { struct pxe_include *inc; - char *buf; uint i; int r; @@ -1053,9 +1052,7 @@ int pxe_process_includes(struct pxe_context *ctx, struct pxe_menu *cfg, return r; } - buf = map_sysmem(base, 0); - r = pxe_parse_include(ctx, inc, buf, base); - unmap_sysmem(buf); + r = pxe_parse_include(ctx, inc, base); if (r < 0) return r; @@ -1064,10 +1061,17 @@ int pxe_process_includes(struct pxe_context *ctx, struct pxe_menu *cfg, return 0; } -int pxe_parse_include(struct pxe_context *ctx, struct pxe_include *inc, - char *buf, ulong base) +int pxe_parse_include(struct pxe_context *ctx, const struct pxe_include *inc, + ulong addr) { - return parse_pxefile_top(ctx, buf, base, inc->cfg, inc->nest_level); + char *buf; + int ret; + + buf = map_sysmem(addr, 0); + ret = parse_pxefile_top(ctx, buf, addr, inc->cfg, inc->nest_level); + unmap_sysmem(buf); + + return ret; } /* diff --git a/include/pxe_utils.h b/include/pxe_utils.h index a03e00e2a4a..f6ee0417a9b 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -299,22 +299,6 @@ struct pxe_menu *parse_pxefile(struct pxe_context *ctx, ulong menucfg); int pxe_process_includes(struct pxe_context *ctx, struct pxe_menu *cfg, ulong base); -/** - * pxe_parse_include() - Parse an included file into its target menu - * - * After loading an include file referenced in cfg->includes, call this - * to parse it and merge any labels into the target menu. This may add - * more entries to cfg->includes if the included file has its own includes. - * - * @ctx: PXE context - * @inc: Include info with path and target menu - * @buf: Buffer containing the included file content - * @base: Memory address where buf is located - * Return: 1 on success, -ve on error - */ -int pxe_parse_include(struct pxe_context *ctx, struct pxe_include *inc, - char *buf, ulong base); - /** * format_mac_pxe() - Convert a MAC address to PXE format * @@ -512,4 +496,19 @@ int parse_pxefile_top(struct pxe_context *ctx, char *p, ulong base, */ void label_destroy(struct pxe_label *label); +/** + * pxe_parse_include() - Parse an included file into its target menu + * + * After loading an include file referenced in cfg->includes, call this + * to parse it and merge any labels into the target menu. This may add + * more entries to cfg->includes if the included file has its own includes. + * + * @ctx: PXE context + * @inc: Include info with path and target menu + * @addr: Memory address where file is located + * Return: 1 on success, -ve on error + */ +int pxe_parse_include(struct pxe_context *ctx, const struct pxe_include *inc, + ulong addr); + #endif /* __PXE_UTILS_H */ -- 2.43.0