@@ -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;
@@ -3,6 +3,7 @@
#ifndef __PXE_UTILS_H
#define __PXE_UTILS_H
+#include <abuf.h>
#include <alist.h>
#include <bootflow.h>
#include <linux/list.h>
@@ -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
@@ -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 */