Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2010-2011 Calxeda, Inc. |
Bryan Wu | a1d715b | 2014-07-31 17:39:59 -0700 | [diff] [blame] | 4 | * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved. |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 5 | */ |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 7 | #include <common.h> |
| 8 | #include <command.h> |
Simon Glass | 1b3f75f | 2019-12-28 10:44:44 -0700 | [diff] [blame] | 9 | #include <fs.h> |
Simon Glass | 6e51ee1 | 2019-12-28 10:44:43 -0700 | [diff] [blame] | 10 | #include <net.h> |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 11 | #include <net6.h> |
| 12 | #include <malloc.h> |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 13 | |
Patrice Chotard | 17e8804 | 2019-11-25 09:07:37 +0100 | [diff] [blame] | 14 | #include "pxe_utils.h" |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 15 | |
Patrice Chotard | 17e8804 | 2019-11-25 09:07:37 +0100 | [diff] [blame] | 16 | #ifdef CONFIG_CMD_NET |
Rob Herring | e26e8d6 | 2012-12-02 21:00:28 -0600 | [diff] [blame] | 17 | const char *pxe_default_paths[] = { |
Joe Hershberger | 921a71d | 2013-06-24 17:21:04 -0500 | [diff] [blame] | 18 | #ifdef CONFIG_SYS_SOC |
Marek BehĂșn | 016ed13 | 2019-05-02 15:29:12 +0200 | [diff] [blame] | 19 | #ifdef CONFIG_SYS_BOARD |
| 20 | "default-" CONFIG_SYS_ARCH "-" CONFIG_SYS_SOC "-" CONFIG_SYS_BOARD, |
| 21 | #endif |
Rob Herring | e26e8d6 | 2012-12-02 21:00:28 -0600 | [diff] [blame] | 22 | "default-" CONFIG_SYS_ARCH "-" CONFIG_SYS_SOC, |
Joe Hershberger | 921a71d | 2013-06-24 17:21:04 -0500 | [diff] [blame] | 23 | #endif |
Rob Herring | e26e8d6 | 2012-12-02 21:00:28 -0600 | [diff] [blame] | 24 | "default-" CONFIG_SYS_ARCH, |
| 25 | "default", |
| 26 | NULL |
| 27 | }; |
| 28 | |
Simon Glass | 44a20ef | 2021-10-14 12:47:57 -0600 | [diff] [blame] | 29 | static int do_get_tftp(struct pxe_context *ctx, const char *file_path, |
Simon Glass | a9401b9 | 2021-10-14 12:48:08 -0600 | [diff] [blame] | 30 | char *file_addr, ulong *sizep) |
Rob Herring | eee675f | 2012-05-25 10:47:39 +0000 | [diff] [blame] | 31 | { |
| 32 | char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; |
Simon Glass | a9401b9 | 2021-10-14 12:48:08 -0600 | [diff] [blame] | 33 | int ret; |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 34 | int num_args; |
Rob Herring | eee675f | 2012-05-25 10:47:39 +0000 | [diff] [blame] | 35 | |
| 36 | tftp_argv[1] = file_addr; |
Rob Herring | 824901c | 2012-12-02 21:00:21 -0600 | [diff] [blame] | 37 | tftp_argv[2] = (void *)file_path; |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 38 | if (ctx->use_ipv6) { |
| 39 | tftp_argv[3] = USE_IP6_CMD_PARAM; |
| 40 | num_args = 4; |
| 41 | } else { |
| 42 | num_args = 3; |
| 43 | } |
Rob Herring | eee675f | 2012-05-25 10:47:39 +0000 | [diff] [blame] | 44 | |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 45 | if (do_tftpb(ctx->cmdtp, 0, num_args, tftp_argv)) |
Rob Herring | eee675f | 2012-05-25 10:47:39 +0000 | [diff] [blame] | 46 | return -ENOENT; |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 47 | |
Simon Glass | a9401b9 | 2021-10-14 12:48:08 -0600 | [diff] [blame] | 48 | ret = pxe_get_file_size(sizep); |
| 49 | if (ret) |
| 50 | return log_msg_ret("tftp", ret); |
| 51 | ctx->pxe_file_size = *sizep; |
Rob Herring | eee675f | 2012-05-25 10:47:39 +0000 | [diff] [blame] | 52 | |
| 53 | return 1; |
| 54 | } |
Stephen Warren | 857291b | 2014-02-05 20:49:20 -0700 | [diff] [blame] | 55 | |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 56 | /* |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 57 | * Looks for a pxe file with specified config file name, |
| 58 | * which is received from DHCPv4 option 209 or |
| 59 | * DHCPv6 option 60. |
| 60 | * |
| 61 | * Returns 1 on success or < 0 on error. |
| 62 | */ |
| 63 | static int pxe_dhcp_option_path(struct pxe_context *ctx, unsigned long pxefile_addr_r) |
| 64 | { |
| 65 | int ret = get_pxe_file(ctx, pxelinux_configfile, pxefile_addr_r); |
| 66 | |
| 67 | free(pxelinux_configfile); |
| 68 | |
| 69 | return ret; |
| 70 | } |
| 71 | |
| 72 | /* |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 73 | * Looks for a pxe file with a name based on the pxeuuid environment variable. |
| 74 | * |
| 75 | * Returns 1 on success or < 0 on error. |
| 76 | */ |
Simon Glass | b0d08db | 2021-10-14 12:47:56 -0600 | [diff] [blame] | 77 | static int pxe_uuid_path(struct pxe_context *ctx, unsigned long pxefile_addr_r) |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 78 | { |
| 79 | char *uuid_str; |
| 80 | |
| 81 | uuid_str = from_env("pxeuuid"); |
| 82 | |
| 83 | if (!uuid_str) |
| 84 | return -ENOENT; |
| 85 | |
Simon Glass | b0d08db | 2021-10-14 12:47:56 -0600 | [diff] [blame] | 86 | return get_pxelinux_path(ctx, uuid_str, pxefile_addr_r); |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | /* |
| 90 | * Looks for a pxe file with a name based on the 'ethaddr' environment |
| 91 | * variable. |
| 92 | * |
| 93 | * Returns 1 on success or < 0 on error. |
| 94 | */ |
Simon Glass | b0d08db | 2021-10-14 12:47:56 -0600 | [diff] [blame] | 95 | static int pxe_mac_path(struct pxe_context *ctx, unsigned long pxefile_addr_r) |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 96 | { |
| 97 | char mac_str[21]; |
| 98 | int err; |
| 99 | |
| 100 | err = format_mac_pxe(mac_str, sizeof(mac_str)); |
| 101 | |
| 102 | if (err < 0) |
| 103 | return err; |
| 104 | |
Simon Glass | b0d08db | 2021-10-14 12:47:56 -0600 | [diff] [blame] | 105 | return get_pxelinux_path(ctx, mac_str, pxefile_addr_r); |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | /* |
| 109 | * Looks for pxe files with names based on our IP address. See pxelinux |
| 110 | * documentation for details on what these file names look like. We match |
| 111 | * that exactly. |
| 112 | * |
| 113 | * Returns 1 on success or < 0 on error. |
| 114 | */ |
Simon Glass | b0d08db | 2021-10-14 12:47:56 -0600 | [diff] [blame] | 115 | static int pxe_ipaddr_paths(struct pxe_context *ctx, unsigned long pxefile_addr_r) |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 116 | { |
| 117 | char ip_addr[9]; |
| 118 | int mask_pos, err; |
| 119 | |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 120 | sprintf(ip_addr, "%08X", ntohl(net_ip.s_addr)); |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 121 | |
| 122 | for (mask_pos = 7; mask_pos >= 0; mask_pos--) { |
Simon Glass | b0d08db | 2021-10-14 12:47:56 -0600 | [diff] [blame] | 123 | err = get_pxelinux_path(ctx, ip_addr, pxefile_addr_r); |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 124 | |
| 125 | if (err > 0) |
| 126 | return err; |
| 127 | |
| 128 | ip_addr[mask_pos] = '\0'; |
| 129 | } |
| 130 | |
| 131 | return -ENOENT; |
| 132 | } |
Simon Glass | 1dacc6f | 2021-10-14 12:48:11 -0600 | [diff] [blame] | 133 | |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 134 | int pxe_get(ulong pxefile_addr_r, char **bootdirp, ulong *sizep, bool use_ipv6) |
Simon Glass | 1dacc6f | 2021-10-14 12:48:11 -0600 | [diff] [blame] | 135 | { |
| 136 | struct cmd_tbl cmdtp[] = {}; /* dummy */ |
| 137 | struct pxe_context ctx; |
| 138 | int i; |
| 139 | |
| 140 | if (pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL, false, |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 141 | env_get("bootfile"), use_ipv6)) |
Simon Glass | 1dacc6f | 2021-10-14 12:48:11 -0600 | [diff] [blame] | 142 | return -ENOMEM; |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 143 | |
| 144 | if (IS_ENABLED(CONFIG_DHCP6_PXE_DHCP_OPTION) && |
| 145 | pxelinux_configfile && use_ipv6) { |
| 146 | if (pxe_dhcp_option_path(&ctx, pxefile_addr_r) > 0) |
| 147 | goto done; |
| 148 | |
| 149 | goto error_exit; |
| 150 | } |
| 151 | |
Simon Glass | 1dacc6f | 2021-10-14 12:48:11 -0600 | [diff] [blame] | 152 | /* |
| 153 | * Keep trying paths until we successfully get a file we're looking |
| 154 | * for. |
| 155 | */ |
| 156 | if (pxe_uuid_path(&ctx, pxefile_addr_r) > 0 || |
| 157 | pxe_mac_path(&ctx, pxefile_addr_r) > 0 || |
| 158 | pxe_ipaddr_paths(&ctx, pxefile_addr_r) > 0) |
| 159 | goto done; |
| 160 | |
| 161 | i = 0; |
| 162 | while (pxe_default_paths[i]) { |
| 163 | if (get_pxelinux_path(&ctx, pxe_default_paths[i], |
| 164 | pxefile_addr_r) > 0) |
| 165 | goto done; |
| 166 | i++; |
| 167 | } |
| 168 | |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 169 | error_exit: |
Simon Glass | 1dacc6f | 2021-10-14 12:48:11 -0600 | [diff] [blame] | 170 | pxe_destroy_ctx(&ctx); |
| 171 | |
| 172 | return -ENOENT; |
| 173 | done: |
| 174 | *bootdirp = env_get("bootfile"); |
| 175 | |
| 176 | /* |
| 177 | * The PXE file size is returned but not the name. It is probably not |
| 178 | * that useful. |
| 179 | */ |
| 180 | *sizep = ctx.pxe_file_size; |
| 181 | pxe_destroy_ctx(&ctx); |
| 182 | |
| 183 | return 0; |
| 184 | } |
| 185 | |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 186 | /* |
| 187 | * Entry point for the 'pxe get' command. |
| 188 | * This Follows pxelinux's rules to download a config file from a tftp server. |
| 189 | * The file is stored at the location given by the pxefile_addr_r environment |
| 190 | * variable, which must be set. |
| 191 | * |
| 192 | * UUID comes from pxeuuid env variable, if defined |
| 193 | * MAC addr comes from ethaddr env variable, if defined |
| 194 | * IP |
| 195 | * |
| 196 | * see http://syslinux.zytor.com/wiki/index.php/PXELINUX |
| 197 | * |
| 198 | * Returns 0 on success or 1 on error. |
| 199 | */ |
| 200 | static int |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 201 | do_pxe_get(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 202 | { |
| 203 | char *pxefile_addr_str; |
Simon Glass | 1dacc6f | 2021-10-14 12:48:11 -0600 | [diff] [blame] | 204 | ulong pxefile_addr_r; |
| 205 | char *fname; |
| 206 | ulong size; |
| 207 | int ret; |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 208 | bool use_ipv6 = false; |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 209 | |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 210 | if (IS_ENABLED(CONFIG_IPV6)) { |
| 211 | if (!strcmp(argv[argc - 1], USE_IP6_CMD_PARAM)) |
| 212 | use_ipv6 = true; |
| 213 | |
| 214 | if (!(argc == 1 || (argc == 2 && use_ipv6))) |
| 215 | return CMD_RET_USAGE; |
| 216 | } else { |
| 217 | if (argc != 1) |
| 218 | return CMD_RET_USAGE; |
| 219 | } |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 220 | |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 221 | pxefile_addr_str = from_env("pxefile_addr_r"); |
| 222 | |
| 223 | if (!pxefile_addr_str) |
| 224 | return 1; |
| 225 | |
Simon Glass | 1dacc6f | 2021-10-14 12:48:11 -0600 | [diff] [blame] | 226 | ret = strict_strtoul(pxefile_addr_str, 16, |
Patrice Chotard | 7f87165 | 2019-11-25 09:07:41 +0100 | [diff] [blame] | 227 | (unsigned long *)&pxefile_addr_r); |
Simon Glass | 1dacc6f | 2021-10-14 12:48:11 -0600 | [diff] [blame] | 228 | if (ret < 0) |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 229 | return 1; |
| 230 | |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 231 | ret = pxe_get(pxefile_addr_r, &fname, &size, use_ipv6); |
Simon Glass | 1dacc6f | 2021-10-14 12:48:11 -0600 | [diff] [blame] | 232 | switch (ret) { |
| 233 | case 0: |
| 234 | printf("Config file '%s' found\n", fname); |
| 235 | break; |
| 236 | case -ENOMEM: |
Simon Glass | e719fe0 | 2021-10-14 12:48:04 -0600 | [diff] [blame] | 237 | printf("Out of memory\n"); |
| 238 | return CMD_RET_FAILURE; |
Simon Glass | 1dacc6f | 2021-10-14 12:48:11 -0600 | [diff] [blame] | 239 | default: |
| 240 | printf("Config file not found\n"); |
| 241 | return CMD_RET_FAILURE; |
Rob Herring | e26e8d6 | 2012-12-02 21:00:28 -0600 | [diff] [blame] | 242 | } |
| 243 | |
Simon Glass | 1dacc6f | 2021-10-14 12:48:11 -0600 | [diff] [blame] | 244 | return 0; |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | /* |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 248 | * Boots a system using a pxe file |
| 249 | * |
| 250 | * Returns 0 on success, 1 on error. |
| 251 | */ |
| 252 | static int |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 253 | do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 254 | { |
| 255 | unsigned long pxefile_addr_r; |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 256 | char *pxefile_addr_str; |
Simon Glass | b0d08db | 2021-10-14 12:47:56 -0600 | [diff] [blame] | 257 | struct pxe_context ctx; |
Simon Glass | 791bbfe | 2021-10-14 12:48:03 -0600 | [diff] [blame] | 258 | int ret; |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 259 | bool use_ipv6 = false; |
| 260 | |
| 261 | if (IS_ENABLED(CONFIG_IPV6)) { |
| 262 | if (!strcmp(argv[argc - 1], USE_IP6_CMD_PARAM)) |
| 263 | use_ipv6 = true; |
| 264 | } |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 265 | |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 266 | if (argc == 1 || (argc == 2 && use_ipv6)) { |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 267 | pxefile_addr_str = from_env("pxefile_addr_r"); |
| 268 | if (!pxefile_addr_str) |
| 269 | return 1; |
| 270 | |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 271 | } else if (argc == 2 || (argc == 3 && use_ipv6)) { |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 272 | pxefile_addr_str = argv[1]; |
| 273 | } else { |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 274 | return CMD_RET_USAGE; |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | if (strict_strtoul(pxefile_addr_str, 16, &pxefile_addr_r) < 0) { |
| 278 | printf("Invalid pxefile address: %s\n", pxefile_addr_str); |
| 279 | return 1; |
| 280 | } |
| 281 | |
Simon Glass | e719fe0 | 2021-10-14 12:48:04 -0600 | [diff] [blame] | 282 | if (pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL, false, |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 283 | env_get("bootfile"), use_ipv6)) { |
Simon Glass | e719fe0 | 2021-10-14 12:48:04 -0600 | [diff] [blame] | 284 | printf("Out of memory\n"); |
| 285 | return CMD_RET_FAILURE; |
| 286 | } |
Simon Glass | 791bbfe | 2021-10-14 12:48:03 -0600 | [diff] [blame] | 287 | ret = pxe_process(&ctx, pxefile_addr_r, false); |
Simon Glass | e719fe0 | 2021-10-14 12:48:04 -0600 | [diff] [blame] | 288 | pxe_destroy_ctx(&ctx); |
Simon Glass | 791bbfe | 2021-10-14 12:48:03 -0600 | [diff] [blame] | 289 | if (ret) |
| 290 | return CMD_RET_FAILURE; |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 291 | |
Joe Hershberger | 290c899 | 2015-04-08 01:41:02 -0500 | [diff] [blame] | 292 | copy_filename(net_boot_file_name, "", sizeof(net_boot_file_name)); |
Stephen Warren | c24cbc2 | 2014-07-22 18:06:46 -0600 | [diff] [blame] | 293 | |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 294 | return 0; |
| 295 | } |
| 296 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 297 | static struct cmd_tbl cmd_pxe_sub[] = { |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 298 | U_BOOT_CMD_MKENT(get, 2, 1, do_pxe_get, "", ""), |
| 299 | U_BOOT_CMD_MKENT(boot, 3, 1, do_pxe_boot, "", "") |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 300 | }; |
| 301 | |
T Karthik Reddy | 37923d9 | 2020-09-16 01:13:56 -0600 | [diff] [blame] | 302 | static void __maybe_unused pxe_reloc(void) |
| 303 | { |
| 304 | static int relocated_pxe; |
| 305 | |
| 306 | if (!relocated_pxe) { |
| 307 | fixup_cmdtable(cmd_pxe_sub, ARRAY_SIZE(cmd_pxe_sub)); |
| 308 | relocated_pxe = 1; |
| 309 | } |
| 310 | } |
| 311 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 312 | static int do_pxe(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 313 | { |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 314 | struct cmd_tbl *cp; |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 315 | |
T Karthik Reddy | 37923d9 | 2020-09-16 01:13:56 -0600 | [diff] [blame] | 316 | #if defined(CONFIG_NEEDS_MANUAL_RELOC) |
| 317 | pxe_reloc(); |
| 318 | #endif |
| 319 | |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 320 | if (argc < 2) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 321 | return CMD_RET_USAGE; |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 322 | |
| 323 | /* drop initial "pxe" arg */ |
| 324 | argc--; |
| 325 | argv++; |
| 326 | |
| 327 | cp = find_cmd_tbl(argv[0], cmd_pxe_sub, ARRAY_SIZE(cmd_pxe_sub)); |
| 328 | |
| 329 | if (cp) |
| 330 | return cp->cmd(cmdtp, flag, argc, argv); |
| 331 | |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 332 | return CMD_RET_USAGE; |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 333 | } |
| 334 | |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 335 | U_BOOT_CMD(pxe, 4, 1, do_pxe, |
Bin Meng | c44cfba | 2023-07-31 16:33:23 +0800 | [diff] [blame] | 336 | "get and boot from pxe files", |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 337 | "get [" USE_IP6_CMD_PARAM "] - try to retrieve a pxe file using tftp\n" |
| 338 | "pxe boot [pxefile_addr_r] [-ipv6] - boot from the pxe file at pxefile_addr_r\n" |
Jason Hobbs | 0e3a593 | 2011-08-31 10:37:30 -0500 | [diff] [blame] | 339 | ); |
Sean Edmond | ba80286 | 2023-04-11 10:48:47 -0700 | [diff] [blame] | 340 | |
| 341 | #endif /* CONFIG_CMD_NET */ |