Blame view
cmd/sysboot.c
2.73 KB
993c912d3 cmd: sysboot: Cre... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
// SPDX-License-Identifier: GPL-2.0+ #include <common.h> #include <command.h> #include <env.h> #include <fs.h> #include "pxe_utils.h" static char *fs_argv[5]; static int do_get_ext2(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr) { #ifdef CONFIG_CMD_EXT2 fs_argv[0] = "ext2load"; fs_argv[3] = file_addr; fs_argv[4] = (void *)file_path; if (!do_ext2load(cmdtp, 0, 5, fs_argv)) return 1; #endif return -ENOENT; } static int do_get_fat(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr) { #ifdef CONFIG_CMD_FAT fs_argv[0] = "fatload"; fs_argv[3] = file_addr; fs_argv[4] = (void *)file_path; if (!do_fat_fsload(cmdtp, 0, 5, fs_argv)) return 1; #endif return -ENOENT; } static int do_get_any(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr) { #ifdef CONFIG_CMD_FS_GENERIC fs_argv[0] = "load"; fs_argv[3] = file_addr; fs_argv[4] = (void *)file_path; if (!do_load(cmdtp, 0, 5, fs_argv, FS_TYPE_ANY)) return 1; #endif return -ENOENT; } /* * Boots a system using a local disk syslinux/extlinux file * * Returns 0 on success, 1 on error. */ static int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { unsigned long pxefile_addr_r; struct pxe_menu *cfg; char *pxefile_addr_str; char *filename; int prompt = 0; is_pxe = false; if (argc > 1 && strstr(argv[1], "-p")) { prompt = 1; argc--; argv++; } if (argc < 4) return cmd_usage(cmdtp); if (argc < 5) { pxefile_addr_str = from_env("pxefile_addr_r"); if (!pxefile_addr_str) return 1; } else { pxefile_addr_str = argv[4]; } |
51843eaba cmd: sysboot: Fix... |
81 |
if (argc < 6) { |
993c912d3 cmd: sysboot: Cre... |
82 |
filename = env_get("bootfile"); |
51843eaba cmd: sysboot: Fix... |
83 |
} else { |
993c912d3 cmd: sysboot: Cre... |
84 85 86 |
filename = argv[5]; env_set("bootfile", filename); } |
51843eaba cmd: sysboot: Fix... |
87 |
if (strstr(argv[3], "ext2")) { |
993c912d3 cmd: sysboot: Cre... |
88 |
do_getfile = do_get_ext2; |
51843eaba cmd: sysboot: Fix... |
89 |
} else if (strstr(argv[3], "fat")) { |
993c912d3 cmd: sysboot: Cre... |
90 |
do_getfile = do_get_fat; |
51843eaba cmd: sysboot: Fix... |
91 |
} else if (strstr(argv[3], "any")) { |
993c912d3 cmd: sysboot: Cre... |
92 |
do_getfile = do_get_any; |
51843eaba cmd: sysboot: Fix... |
93 |
} else { |
993c912d3 cmd: sysboot: Cre... |
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
printf("Invalid filesystem: %s ", argv[3]); return 1; } fs_argv[1] = argv[1]; fs_argv[2] = argv[2]; if (strict_strtoul(pxefile_addr_str, 16, &pxefile_addr_r) < 0) { printf("Invalid pxefile address: %s ", pxefile_addr_str); return 1; } if (get_pxe_file(cmdtp, filename, pxefile_addr_r) < 0) { printf("Error reading config file "); return 1; } cfg = parse_pxefile(cmdtp, pxefile_addr_r); |
51843eaba cmd: sysboot: Fix... |
114 |
if (!cfg) { |
993c912d3 cmd: sysboot: Cre... |
115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
printf("Error parsing config file "); return 1; } if (prompt) cfg->prompt = 1; handle_pxe_menu(cmdtp, cfg); destroy_pxe_menu(cfg); return 0; } |
51843eaba cmd: sysboot: Fix... |
129 130 131 132 133 134 135 |
U_BOOT_CMD(sysboot, 7, 1, do_sysboot, "command to get and boot from syslinux files", "[-p] <interface> <dev[:part]> <ext2|fat|any> [addr] [filename] " " - load and parse syslinux menu file 'filename' from ext2, fat " " or any filesystem on 'dev' on 'interface' to address 'addr'" |
993c912d3 cmd: sysboot: Cre... |
136 |
); |