summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2025-03-18 13:12:51 -0600
committerTom Rini <[email protected]>2025-03-18 13:12:51 -0600
commit8bc3542384e3a1219e5ffb62b79d16dddc1b1fb9 (patch)
tree8473478696b9a12d2db424afcec705dcce58c580 /cmd
parent698edd63eca090a2e299cd3facf90a0b97bed677 (diff)
parent0f094b8b146679c3980cd2febde4e902bbc4405d (diff)
Merge patch series "pxe: Precursor series for supporting read_all() in extlinux / PXE"
Simon Glass <[email protected]> says: This series includes some patches related to allowing read_all() to be used with the extlinux / PXE bootmeths. These patches were split out from the stb4 series, since it will need to have additional patches for LWIP, to avoid breaking PXE booting when LWIP is used. Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'cmd')
-rw-r--r--cmd/bootflow.c8
-rw-r--r--cmd/net.c92
-rw-r--r--cmd/x86/zboot.c33
3 files changed, 75 insertions, 58 deletions
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index f88995a478f..6d0be320bdb 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -380,7 +380,13 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,
bflow = std->cur_bootflow;
if (IS_ENABLED(CONFIG_X86) && x86_setup) {
- zimage_dump(bflow->x86_setup, false);
+ struct bootm_info bmi;
+
+ bootm_init(&bmi);
+ /* we don't know this at present */
+ bootm_x86_set(&bmi, bzimage_addr, 0);
+ bootm_x86_set(&bmi, base_ptr, bflow->x86_setup);
+ zimage_dump(&bmi, false);
return 0;
}
diff --git a/cmd/net.c b/cmd/net.c
index 79525f73a51..8f33c9f55d5 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -297,13 +297,15 @@ static void netboot_update_env(void)
/**
* parse_addr_size() - parse address and size arguments for tftpput
*
- * @argv: command line arguments
+ * @argv: command line arguments (argv[1] and argv[2] must be valid)
+ * @addrp: returns the address, on success
+ * @sizep: returns the size, on success
* Return: 0 on success
*/
-static int parse_addr_size(char * const argv[])
+static int parse_addr_size(char * const argv[], ulong *addrp, ulong *sizep)
{
- if (strict_strtoul(argv[1], 16, &image_save_addr) < 0 ||
- strict_strtoul(argv[2], 16, &image_save_size) < 0) {
+ if (strict_strtoul(argv[1], 16, addrp) < 0 ||
+ strict_strtoul(argv[2], 16, sizep) < 0) {
printf("Invalid address/size\n");
return CMD_RET_USAGE;
}
@@ -313,24 +315,31 @@ static int parse_addr_size(char * const argv[])
/**
* parse_args() - parse command line arguments
*
+ * Sets:
+ * - image_save_addr and image_save_size, if proto == TFTPPUT
+ *
* @proto: command prototype
- * @argc: number of arguments
- * @argv: command line arguments
+ * @argc: number of arguments, include the command, which has already been
+ * parsed
+ * @argv: command line arguments, with argv[0] being the command
+ * @fnamep: set to the filename, if provided, else NULL
+ * @addrp: returns the load/save address, if any is provided, else it is
+ * left unchanged
+ * @sizep: returns the save size, if any is provided, else it is left
+ * unchanged
* Return: 0 on success
*/
-static int parse_args(enum proto_t proto, int argc, char *const argv[])
+static int parse_args(enum proto_t proto, int argc, char *const argv[],
+ const char **fnamep, ulong *addrp, ulong *sizep)
{
ulong addr;
char *end;
+ *fnamep = NULL;
switch (argc) {
case 1:
if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT)
return 1;
-
- /* refresh bootfile name from env */
- copy_filename(net_boot_file_name, env_get("bootfile"),
- sizeof(net_boot_file_name));
break;
case 2:
@@ -343,48 +352,42 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[])
* mis-interpreted as a valid number.
*/
addr = hextoul(argv[1], &end);
- if (end == (argv[1] + strlen(argv[1]))) {
- image_load_addr = addr;
- /* refresh bootfile name from env */
- copy_filename(net_boot_file_name, env_get("bootfile"),
- sizeof(net_boot_file_name));
- } else {
- net_boot_file_name_explicit = true;
- copy_filename(net_boot_file_name, argv[1],
- sizeof(net_boot_file_name));
- }
+ if (end == (argv[1] + strlen(argv[1])))
+ *addrp = addr;
+ else
+ *fnamep = argv[1];
break;
case 3:
if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) {
- if (parse_addr_size(argv))
+ if (parse_addr_size(argv, addrp, sizep))
return 1;
} else {
- image_load_addr = hextoul(argv[1], NULL);
- net_boot_file_name_explicit = true;
- copy_filename(net_boot_file_name, argv[2],
- sizeof(net_boot_file_name));
+ *addrp = hextoul(argv[1], NULL);
+ *fnamep = argv[2];
}
break;
-#ifdef CONFIG_CMD_TFTPPUT
case 4:
- if (parse_addr_size(argv))
- return 1;
- net_boot_file_name_explicit = true;
- copy_filename(net_boot_file_name, argv[3],
- sizeof(net_boot_file_name));
- break;
-#endif
+ if (IS_ENABLED(CONFIG_CMD_TFTPPUT)) {
+ if (parse_addr_size(argv, addrp, sizep))
+ return 1;
+ *fnamep = argv[3];
+ break;
+ }
default:
return 1;
}
+
return 0;
}
static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc,
char *const argv[])
{
+ ulong addr, save_size;
+ bool fname_explicit;
+ const char *fname;
char *s;
int rcode = 0;
int size;
@@ -392,10 +395,10 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc,
net_boot_file_name_explicit = false;
*net_boot_file_name = '\0';
- /* pre-set image_load_addr */
+ /* pre-set addr */
s = env_get("loadaddr");
if (s != NULL)
- image_load_addr = hextoul(s, NULL);
+ addr = hextoul(s, NULL);
if (IS_ENABLED(CONFIG_IPV6)) {
use_ip6 = false;
@@ -408,12 +411,17 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc,
}
}
- if (parse_args(proto, argc, argv)) {
+ if (parse_args(proto, argc, argv, &fname, &addr, &save_size)) {
bootstage_error(BOOTSTAGE_ID_NET_START);
return CMD_RET_USAGE;
}
- bootstage_mark(BOOTSTAGE_ID_NET_START);
+ if (fname) {
+ fname_explicit = true;
+ } else {
+ fname_explicit = false;
+ fname = env_get("bootfile");
+ }
if (IS_ENABLED(CONFIG_IPV6) && !use_ip6) {
char *s, *e;
@@ -428,12 +436,10 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc,
}
}
- size = net_loop(proto);
- if (size < 0) {
- bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK);
+ size = netboot_run_(proto, addr, fname, save_size, fname_explicit,
+ IS_ENABLED(CONFIG_IPV6) && use_ip6);
+ if (size < 0)
return CMD_RET_FAILURE;
- }
- bootstage_mark(BOOTSTAGE_ID_NET_NETLOOP_OK);
/* net_loop ok, update environment */
netboot_update_env();
diff --git a/cmd/x86/zboot.c b/cmd/x86/zboot.c
index 94e602b8a5b..ee099ca041b 100644
--- a/cmd/x86/zboot.c
+++ b/cmd/x86/zboot.c
@@ -7,11 +7,15 @@
#define LOG_CATEGORY LOGC_BOOT
+#include <bootm.h>
#include <command.h>
#include <mapmem.h>
#include <vsprintf.h>
#include <asm/zimage.h>
+/* Current state of the boot */
+static struct bootm_info bmi;
+
static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -20,6 +24,8 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc,
ulong base_addr;
int i;
+ bootm_init(&bmi);
+
log_debug("argc %d:", argc);
for (i = 0; i < argc; i++)
log_debug(" %s", argv[i]);
@@ -35,7 +41,7 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc,
base_addr = argc > 5 ? hextoul(argv[5], NULL) : 0;
cmdline = argc > 6 ? env_get(argv[6]) : NULL;
- zboot_start(bzimage_addr, bzimage_size, initrd_addr, initrd_size,
+ zboot_start(&bmi, bzimage_addr, bzimage_size, initrd_addr, initrd_size,
base_addr, cmdline);
return 0;
@@ -46,7 +52,7 @@ static int do_zboot_load(struct cmd_tbl *cmdtp, int flag, int argc,
{
int ret;
- ret = zboot_load();
+ ret = zboot_load(&bmi);
if (ret)
return ret;
@@ -56,16 +62,17 @@ static int do_zboot_load(struct cmd_tbl *cmdtp, int flag, int argc,
static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
- if (!state.base_ptr) {
+ if (!bmi.base_ptr) {
printf("base is not set: use 'zboot load' first\n");
return CMD_RET_FAILURE;
}
- if (zboot_setup()) {
+
+ if (zboot_setup(&bmi)) {
puts("Setting up boot parameters failed ...\n");
return CMD_RET_FAILURE;
}
- if (zboot_setup())
+ if (zboot_setup(&bmi))
return CMD_RET_FAILURE;
return 0;
@@ -74,7 +81,7 @@ static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc,
static int do_zboot_info(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
- zboot_info();
+ zboot_info(&bmi);
return 0;
}
@@ -84,7 +91,7 @@ static int do_zboot_go(struct cmd_tbl *cmdtp, int flag, int argc,
{
int ret;
- ret = zboot_go();
+ ret = zboot_go(&bmi);
if (ret) {
printf("Kernel returned! (err=%d)\n", ret);
return CMD_RET_FAILURE;
@@ -96,15 +103,13 @@ static int do_zboot_go(struct cmd_tbl *cmdtp, int flag, int argc,
static int do_zboot_dump(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
- struct boot_params *base_ptr = state.base_ptr;
-
if (argc > 1)
- base_ptr = (void *)hextoul(argv[1], NULL);
- if (!base_ptr) {
+ bmi.base_ptr = (void *)hextoul(argv[1], NULL);
+ if (!bmi.base_ptr) {
printf("No zboot setup_base\n");
return CMD_RET_FAILURE;
}
- zimage_dump(base_ptr, true);
+ zimage_dump(&bmi, true);
return 0;
}
@@ -119,8 +124,8 @@ U_BOOT_SUBCMDS(zboot,
U_BOOT_CMD_MKENT(dump, 2, 1, do_zboot_dump, "", ""),
)
-int do_zboot_states(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[], int state_mask)
+static int do_zboot_states(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[], int state_mask)
{
int ret = 0;