1 // SPDX-License-Identifier: GPL-2.0+
9 static char *fs_argv[5];
11 static int do_get_ext2(struct cmd_tbl *cmdtp, 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(cmdtp, 0, 5, fs_argv))
25 static int do_get_fat(struct cmd_tbl *cmdtp, 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(cmdtp, 0, 5, fs_argv))
39 static int do_get_any(struct cmd_tbl *cmdtp, 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(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;
63 char *pxefile_addr_str;
69 if (argc > 1 && strstr(argv[1], "-p")) {
76 return cmd_usage(cmdtp);
79 pxefile_addr_str = from_env("pxefile_addr_r");
80 if (!pxefile_addr_str)
83 pxefile_addr_str = argv[4];
87 filename = env_get("bootfile");
90 env_set("bootfile", filename);
93 if (strstr(argv[3], "ext2")) {
94 do_getfile = do_get_ext2;
95 } else if (strstr(argv[3], "fat")) {
96 do_getfile = do_get_fat;
97 } else if (strstr(argv[3], "any")) {
98 do_getfile = do_get_any;
100 printf("Invalid filesystem: %s\n", argv[3]);
103 fs_argv[1] = argv[1];
104 fs_argv[2] = argv[2];
106 if (strict_strtoul(pxefile_addr_str, 16, &pxefile_addr_r) < 0) {
107 printf("Invalid pxefile address: %s\n", pxefile_addr_str);
111 if (get_pxe_file(cmdtp, filename, pxefile_addr_r) < 0) {
112 printf("Error reading config file\n");
116 cfg = parse_pxefile(cmdtp, pxefile_addr_r);
119 printf("Error parsing config file\n");
126 handle_pxe_menu(cmdtp, cfg);
128 destroy_pxe_menu(cfg);
133 U_BOOT_CMD(sysboot, 7, 1, do_sysboot,
134 "command to get and boot from syslinux files",
135 "[-p] <interface> <dev[:part]> <ext2|fat|any> [addr] [filename]\n"
136 " - load and parse syslinux menu file 'filename' from ext2, fat\n"
137 " or any filesystem on 'dev' on 'interface' to address 'addr'"