[PATCH 36/39] pxe: Collect the FDT in the bootflow
Simon Glass
sjg at chromium.org
Tue Nov 19 14:18:41 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>
---
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 7106e532e03..ca91bff7e51 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));
@@ -684,6 +681,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);
@@ -788,11 +787,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 4671bd7ab1f..cbd65cb3eb5 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -1436,7 +1436,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);
@@ -1450,6 +1450,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