ctx->userdata = userdata;
ctx->allow_abs_path = allow_abs_path;
}
+
+int pxe_process(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt)
+{
+ struct pxe_menu *cfg;
+
+ cfg = parse_pxefile(ctx, pxefile_addr_r);
+ if (!cfg) {
+ printf("Error parsing config file\n");
+ return 1;
+ }
+
+ if (prompt)
+ cfg->prompt = 1;
+
+ handle_pxe_menu(ctx, cfg);
+
+ destroy_pxe_menu(cfg);
+
+ return 0;
+}
do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
unsigned long pxefile_addr_r;
- struct pxe_menu *cfg;
char *pxefile_addr_str;
struct pxe_context ctx;
+ int ret;
pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL, false);
return 1;
}
- cfg = parse_pxefile(&ctx, pxefile_addr_r);
-
- if (!cfg) {
- printf("Error parsing config file\n");
- return 1;
- }
-
- handle_pxe_menu(&ctx, cfg);
-
- destroy_pxe_menu(cfg);
+ ret = pxe_process(&ctx, pxefile_addr_r, false);
+ if (ret)
+ return CMD_RET_FAILURE;
copy_filename(net_boot_file_name, "", sizeof(net_boot_file_name));
{
unsigned long pxefile_addr_r;
struct pxe_context ctx;
- struct pxe_menu *cfg;
char *pxefile_addr_str;
char *filename;
int prompt = 0;
+ int ret;
if (argc > 1 && strstr(argv[1], "-p")) {
prompt = 1;
return 1;
}
- cfg = parse_pxefile(&ctx, pxefile_addr_r);
-
- if (!cfg) {
- printf("Error parsing config file\n");
- return 1;
- }
-
- if (prompt)
- cfg->prompt = 1;
-
- handle_pxe_menu(&ctx, cfg);
-
- destroy_pxe_menu(cfg);
+ ret = pxe_process(&ctx, pxefile_addr_r, prompt);
+ if (ret)
+ return CMD_RET_FAILURE;
return 0;
}
pxe_getfile_func getfile, void *userdata,
bool allow_abs_path);
+/**
+ * pxe_process() - Process a PXE file through to boot
+ *
+ * @ctx: PXE context created with pxe_setup_ctx()
+ * @pxefile_addr_r: Address to load file
+ * @prompt: Force a prompt for the user
+ */
+int pxe_process(struct pxe_context *ctx, ulong pxefile_addr_r, bool prompt);
+
#endif /* __PXE_UTILS_H */