1 // SPDX-License-Identifier: GPL-2.0+
9 static char *fs_argv[5];
11 static int do_get_ext2(struct pxe_context *ctx, const char *file_path,
14 #ifdef CONFIG_CMD_EXT2
15 fs_argv[0] = "ext2load";
16 fs_argv[3] = file_addr;
17 fs_argv[4] = (void *)file_path;
19 if (!do_ext2load(ctx->cmdtp, 0, 5, fs_argv))
25 static int do_get_fat(struct pxe_context *ctx, const char *file_path,
29 fs_argv[0] = "fatload";
30 fs_argv[3] = file_addr;
31 fs_argv[4] = (void *)file_path;
33 if (!do_fat_fsload(ctx->cmdtp, 0, 5, fs_argv))
39 static int do_get_any(struct pxe_context *ctx, const char *file_path,
42 #ifdef CONFIG_CMD_FS_GENERIC
44 fs_argv[3] = file_addr;
45 fs_argv[4] = (void *)file_path;
47 if (!do_load(ctx->cmdtp, 0, 5, fs_argv, FS_TYPE_ANY))
54 * Boots a system using a local disk syslinux/extlinux file
56 * Returns 0 on success, 1 on error.
58 static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int argc,
61 unsigned long pxefile_addr_r;
62 struct pxe_context ctx;
64 char *pxefile_addr_str;
70 if (argc > 1 && strstr(argv[1], "-p")) {
77 return cmd_usage(cmdtp);
80 pxefile_addr_str = from_env("pxefile_addr_r");
81 if (!pxefile_addr_str)
84 pxefile_addr_str = argv[4];
88 filename = env_get("bootfile");
91 env_set("bootfile", filename);
94 pxe_setup_ctx(&ctx, cmdtp, NULL);
95 if (strstr(argv[3], "ext2")) {
96 ctx.getfile = do_get_ext2;
97 } else if (strstr(argv[3], "fat")) {
98 ctx.getfile = do_get_fat;
99 } else if (strstr(argv[3], "any")) {
100 ctx.getfile = do_get_any;
102 printf("Invalid filesystem: %s\n", argv[3]);
105 fs_argv[1] = argv[1];
106 fs_argv[2] = argv[2];
108 if (strict_strtoul(pxefile_addr_str, 16, &pxefile_addr_r) < 0) {
109 printf("Invalid pxefile address: %s\n", pxefile_addr_str);
113 if (get_pxe_file(&ctx, filename, pxefile_addr_r) < 0) {
114 printf("Error reading config file\n");
118 cfg = parse_pxefile(&ctx, pxefile_addr_r);
121 printf("Error parsing config file\n");
128 handle_pxe_menu(&ctx, cfg);
130 destroy_pxe_menu(cfg);
135 U_BOOT_CMD(sysboot, 7, 1, do_sysboot,
136 "command to get and boot from syslinux files",
137 "[-p] <interface> <dev[:part]> <ext2|fat|any> [addr] [filename]\n"
138 " - load and parse syslinux menu file 'filename' from ext2, fat\n"
139 " or any filesystem on 'dev' on 'interface' to address 'addr'"