Revert "Merge patch series "pxe: Precursor series for supporting read_all() in extlinux / PXE""

This reverts commit 8bc3542384e3a1219e5ffb62b79d16dddc1b1fb9, reversing
changes made to 698edd63eca090a2e299cd3facf90a0b97bed677.

There are still problems with this series to work out.

Link: https://lore.kernel.org/u-boot/CAFLszTjw_MJbK9tpzVYi3XKGazcv55auBAdgVzcAVUta7dRqcg@mail.gmail.com/
Signed-off-by: Tom Rini <trini@konsulko.com>
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 5349abe..a1fd59a 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -380,13 +380,7 @@
 	bflow = std->cur_bootflow;
 
 	if (IS_ENABLED(CONFIG_X86) && x86_setup) {
-		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);
+		zimage_dump(bflow->x86_setup, false);
 
 		return 0;
 	}
diff --git a/cmd/net.c b/cmd/net.c
index 8f33c9f..79525f7 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -297,15 +297,13 @@
 /**
  * parse_addr_size() - parse address and size arguments for tftpput
  *
- * @argv:	command line arguments (argv[1] and argv[2] must be valid)
- * @addrp:	returns the address, on success
- * @sizep:	returns the size, on success
+ * @argv:	command line arguments
  * Return:	0 on success
  */
-static int parse_addr_size(char * const argv[], ulong *addrp, ulong *sizep)
+static int parse_addr_size(char * const argv[])
 {
-	if (strict_strtoul(argv[1], 16, addrp) < 0 ||
-	    strict_strtoul(argv[2], 16, sizep) < 0) {
+	if (strict_strtoul(argv[1], 16, &image_save_addr) < 0 ||
+	    strict_strtoul(argv[2], 16, &image_save_size) < 0) {
 		printf("Invalid address/size\n");
 		return CMD_RET_USAGE;
 	}
@@ -315,31 +313,24 @@
 /**
  * parse_args() - parse command line arguments
  *
- * Sets:
- * - image_save_addr and image_save_size, if proto == TFTPPUT
- *
  * @proto:	command prototype
- * @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
+ * @argc:	number of arguments
+ * @argv:	command line arguments
  * Return:	0 on success
  */
-static int parse_args(enum proto_t proto, int argc, char *const argv[],
-		      const char **fnamep, ulong *addrp, ulong *sizep)
+static int parse_args(enum proto_t proto, int argc, char *const argv[])
 {
 	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:
@@ -352,42 +343,48 @@
 		 * mis-interpreted as a valid number.
 		 */
 		addr = hextoul(argv[1], &end);
-		if (end == (argv[1] + strlen(argv[1])))
-			*addrp = addr;
-		else
-			*fnamep = argv[1];
+		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));
+		}
 		break;
 
 	case 3:
 		if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) {
-			if (parse_addr_size(argv, addrp, sizep))
+			if (parse_addr_size(argv))
 				return 1;
 		} else {
-			*addrp = hextoul(argv[1], NULL);
-			*fnamep = argv[2];
+			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));
 		}
 		break;
 
+#ifdef CONFIG_CMD_TFTPPUT
 	case 4:
-		if (IS_ENABLED(CONFIG_CMD_TFTPPUT)) {
-			if (parse_addr_size(argv, addrp, sizep))
-				return 1;
-			*fnamep = argv[3];
-			break;
-		}
+		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
 	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;
@@ -395,10 +392,10 @@
 	net_boot_file_name_explicit = false;
 	*net_boot_file_name = '\0';
 
-	/* pre-set addr */
+	/* pre-set image_load_addr */
 	s = env_get("loadaddr");
 	if (s != NULL)
-		addr = hextoul(s, NULL);
+		image_load_addr = hextoul(s, NULL);
 
 	if (IS_ENABLED(CONFIG_IPV6)) {
 		use_ip6 = false;
@@ -411,17 +408,12 @@
 		}
 	}
 
-	if (parse_args(proto, argc, argv, &fname, &addr, &save_size)) {
+	if (parse_args(proto, argc, argv)) {
 		bootstage_error(BOOTSTAGE_ID_NET_START);
 		return CMD_RET_USAGE;
 	}
 
-	if (fname) {
-		fname_explicit = true;
-	} else {
-		fname_explicit = false;
-		fname = env_get("bootfile");
-	}
+	bootstage_mark(BOOTSTAGE_ID_NET_START);
 
 	if (IS_ENABLED(CONFIG_IPV6) && !use_ip6) {
 		char *s, *e;
@@ -436,10 +428,12 @@
 		}
 	}
 
-	size = netboot_run_(proto, addr, fname, save_size, fname_explicit,
-			    IS_ENABLED(CONFIG_IPV6) && use_ip6);
-	if (size < 0)
+	size = net_loop(proto);
+	if (size < 0) {
+		bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK);
 		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 ee099ca..94e602b8 100644
--- a/cmd/x86/zboot.c
+++ b/cmd/x86/zboot.c
@@ -7,15 +7,11 @@
 
 #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[])
 {
@@ -24,8 +20,6 @@
 	ulong base_addr;
 	int i;
 
-	bootm_init(&bmi);
-
 	log_debug("argc %d:", argc);
 	for (i = 0; i < argc; i++)
 		log_debug(" %s", argv[i]);
@@ -41,7 +35,7 @@
 	base_addr = argc > 5 ? hextoul(argv[5], NULL) : 0;
 	cmdline = argc > 6 ? env_get(argv[6]) : NULL;
 
-	zboot_start(&bmi, bzimage_addr, bzimage_size, initrd_addr, initrd_size,
+	zboot_start(bzimage_addr, bzimage_size, initrd_addr, initrd_size,
 		    base_addr, cmdline);
 
 	return 0;
@@ -52,7 +46,7 @@
 {
 	int ret;
 
-	ret = zboot_load(&bmi);
+	ret = zboot_load();
 	if (ret)
 		return ret;
 
@@ -62,17 +56,16 @@
 static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc,
 			  char *const argv[])
 {
-	if (!bmi.base_ptr) {
+	if (!state.base_ptr) {
 		printf("base is not set: use 'zboot load' first\n");
 		return CMD_RET_FAILURE;
 	}
-
-	if (zboot_setup(&bmi)) {
+	if (zboot_setup()) {
 		puts("Setting up boot parameters failed ...\n");
 		return CMD_RET_FAILURE;
 	}
 
-	if (zboot_setup(&bmi))
+	if (zboot_setup())
 		return CMD_RET_FAILURE;
 
 	return 0;
@@ -81,7 +74,7 @@
 static int do_zboot_info(struct cmd_tbl *cmdtp, int flag, int argc,
 			 char *const argv[])
 {
-	zboot_info(&bmi);
+	zboot_info();
 
 	return 0;
 }
@@ -91,7 +84,7 @@
 {
 	int ret;
 
-	ret = zboot_go(&bmi);
+	ret = zboot_go();
 	if (ret) {
 		printf("Kernel returned! (err=%d)\n", ret);
 		return CMD_RET_FAILURE;
@@ -103,13 +96,15 @@
 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)
-		bmi.base_ptr = (void *)hextoul(argv[1], NULL);
-	if (!bmi.base_ptr) {
+		base_ptr = (void *)hextoul(argv[1], NULL);
+	if (!base_ptr) {
 		printf("No zboot setup_base\n");
 		return CMD_RET_FAILURE;
 	}
-	zimage_dump(&bmi, true);
+	zimage_dump(base_ptr, true);
 
 	return 0;
 }
@@ -124,8 +119,8 @@
 	U_BOOT_CMD_MKENT(dump, 2, 1, do_zboot_dump, "", ""),
 )
 
-static int do_zboot_states(struct cmd_tbl *cmdtp, int flag, int argc,
-			   char *const argv[], int state_mask)
+int do_zboot_states(struct cmd_tbl *cmdtp, int flag, int argc,
+		    char *const argv[], int state_mask)
 {
 	int ret = 0;