mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-06-28 01:22:20 +00:00
pxe: Move common parsing coding into pxe_util
Both the syslinux and pxe commands use essentially the same code to parse and run extlinux.conf files. Move this into a common function. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Artem Lapkin <email2tema@gmail.com> Tested-by: Artem Lapkin <email2tema@gmail.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
This commit is contained in:
parent
929860bfbb
commit
9e62e7ca54
4 changed files with 37 additions and 25 deletions
|
@ -1505,3 +1505,23 @@ void pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp,
|
||||||
ctx->userdata = userdata;
|
ctx->userdata = userdata;
|
||||||
ctx->allow_abs_path = allow_abs_path;
|
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;
|
||||||
|
}
|
||||||
|
|
15
cmd/pxe.c
15
cmd/pxe.c
|
@ -171,9 +171,9 @@ static int
|
||||||
do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
{
|
{
|
||||||
unsigned long pxefile_addr_r;
|
unsigned long pxefile_addr_r;
|
||||||
struct pxe_menu *cfg;
|
|
||||||
char *pxefile_addr_str;
|
char *pxefile_addr_str;
|
||||||
struct pxe_context ctx;
|
struct pxe_context ctx;
|
||||||
|
int ret;
|
||||||
|
|
||||||
pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL, false);
|
pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL, false);
|
||||||
|
|
||||||
|
@ -193,16 +193,9 @@ do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg = parse_pxefile(&ctx, pxefile_addr_r);
|
ret = pxe_process(&ctx, pxefile_addr_r, false);
|
||||||
|
if (ret)
|
||||||
if (!cfg) {
|
return CMD_RET_FAILURE;
|
||||||
printf("Error parsing config file\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_pxe_menu(&ctx, cfg);
|
|
||||||
|
|
||||||
destroy_pxe_menu(cfg);
|
|
||||||
|
|
||||||
copy_filename(net_boot_file_name, "", sizeof(net_boot_file_name));
|
copy_filename(net_boot_file_name, "", sizeof(net_boot_file_name));
|
||||||
|
|
||||||
|
|
|
@ -60,10 +60,10 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
{
|
{
|
||||||
unsigned long pxefile_addr_r;
|
unsigned long pxefile_addr_r;
|
||||||
struct pxe_context ctx;
|
struct pxe_context ctx;
|
||||||
struct pxe_menu *cfg;
|
|
||||||
char *pxefile_addr_str;
|
char *pxefile_addr_str;
|
||||||
char *filename;
|
char *filename;
|
||||||
int prompt = 0;
|
int prompt = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (argc > 1 && strstr(argv[1], "-p")) {
|
if (argc > 1 && strstr(argv[1], "-p")) {
|
||||||
prompt = 1;
|
prompt = 1;
|
||||||
|
@ -113,19 +113,9 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg = parse_pxefile(&ctx, pxefile_addr_r);
|
ret = pxe_process(&ctx, pxefile_addr_r, prompt);
|
||||||
|
if (ret)
|
||||||
if (!cfg) {
|
return CMD_RET_FAILURE;
|
||||||
printf("Error parsing config file\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prompt)
|
|
||||||
cfg->prompt = 1;
|
|
||||||
|
|
||||||
handle_pxe_menu(&ctx, cfg);
|
|
||||||
|
|
||||||
destroy_pxe_menu(cfg);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,4 +202,13 @@ void pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp,
|
||||||
pxe_getfile_func getfile, void *userdata,
|
pxe_getfile_func getfile, void *userdata,
|
||||||
bool allow_abs_path);
|
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 */
|
#endif /* __PXE_UTILS_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue