[PATCH v3 42/46] pxe: Collect the FDT in the bootflow

Simon Glass sjg at chromium.org
Fri Dec 6 03:36:21 CET 2024


Move processing of the FDT so that it happens before booting. Add a test
to check that the FDT is now visible.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 boot/pxe_utils.c     | 22 +++++++++++++---------
 test/boot/bootflow.c |  6 +++++-
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 3531ab1c71a..053fdcbb6e7 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -578,26 +578,23 @@ static int label_process_fdt(struct pxe_context *ctx, struct pxe_label *label,
  * @initrd_filesize: String containing initrd size (only used if
  *	@initrd_addr_str)
  * @initrd_str: initrd string to process (only used if @initrd_addr_str)
+ * @conf_fdt: string containing the FDT address
  * Return: does not return on success, or returns 0 if the boot command
  * returned, or -ve error value on error
  */
 static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label,
 			  char *kernel_addr, char *initrd_addr_str,
-			  char *initrd_filesize, char *initrd_str)
+			  char *initrd_filesize, char *initrd_str,
+			  const char *conf_fdt)
 {
 	struct bootm_info bmi;
 	ulong kernel_addr_r;
+	int ret = 0;
 	void *buf;
-	int ret;
 
 	bootm_init(&bmi);
 
-	bmi.conf_fdt = env_get("fdt_addr_r");
-
-	ret = label_process_fdt(ctx, label, kernel_addr, &bmi.conf_fdt);
-	if (ret)
-		return ret;
-
+	bmi.conf_fdt = conf_fdt;
 	bmi.addr_img = kernel_addr;
 	bootm_x86_set(&bmi, bzimage_addr, hextoul(kernel_addr, NULL));
 
@@ -678,6 +675,8 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
 	char mac_str[29] = "";
 	char ip_str[68] = "";
 	char *fit_addr = NULL;
+	const char *conf_fdt;
+	int ret;
 
 	label_print(label);
 
@@ -782,11 +781,16 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
 		printf("append: %s\n", finalbootargs);
 	}
 
+	conf_fdt = env_get("fdt_addr_r");
+	ret = label_process_fdt(ctx, label, kernel_addr, &conf_fdt);
+	if (ret)
+		return ret;
+
 	if (ctx->no_boot)
 		return 0;
 
 	label_run_boot(ctx, label, kernel_addr, initrd_addr_str,
-		       initrd_filesize, initrd_str);
+		       initrd_filesize, initrd_str, conf_fdt);
 	/* ignore the error value since we are going to fail anyway */
 
 cleanup:
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index ef8c0c1bbaa..640a7cdb7c9 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -1459,7 +1459,7 @@ static int bootflow_scan_extlinux(struct unit_test_state *uts)
 		"ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB",
 		bflow->cmdline);
 
-	ut_asserteq(3, bflow->images.count);
+	ut_asserteq(4, bflow->images.count);
 
 	/* check each image */
 	img = alist_get(&bflow->images, 0, struct bootflow_img);
@@ -1473,6 +1473,10 @@ static int bootflow_scan_extlinux(struct unit_test_state *uts)
 	ut_asserteq(IH_TYPE_RAMDISK, img->type);
 	ut_asserteq(0x2000000, img->addr);	/* ramdisk_addr_r */
 
+	img = alist_get(&bflow->images, 3, struct bootflow_img);
+	ut_asserteq(IH_TYPE_FLATDT, img->type);
+	ut_asserteq(0xc00000, img->addr);	/* fdt_addr_r */
+
 	return 0;
 }
 BOOTSTD_TEST(bootflow_scan_extlinux, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE);
-- 
2.34.1



More information about the U-Boot mailing list