diff options
author | Simon Glass | 2023-11-18 14:05:09 -0700 |
---|---|---|
committer | Tom Rini | 2023-12-13 11:51:24 -0500 |
commit | ba5e3f7f7825169d95a17cc4929143f522e82868 (patch) | |
tree | c57552b53a29e0b31a727d14bff46c3f28bedb16 /boot | |
parent | 972d524893e4635ff1ac4286a870cda2dd3fc301 (diff) |
bootm: Pass image buffer to boot_get_fdt()
Rather than having boot_get_fdt() calculate this, move the calculation
into the caller. This removes the access to argv[0] in this function,
so we can later refactor it to just accept argv[2] instead of the whole
argv[].
Move the function comment to the header file and fix the u8 argument,
while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'boot')
-rw-r--r-- | boot/bootm.c | 11 | ||||
-rw-r--r-- | boot/image-fdt.c | 32 |
2 files changed, 10 insertions, 33 deletions
diff --git a/boot/bootm.c b/boot/bootm.c index d9c62d730f7..cd11994e21c 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -490,11 +490,11 @@ int bootm_find_images(int flag, int argc, char *const argv[], ulong start, ulong size) { const char *select = NULL; + ulong img_addr; + void *buf; int ret; if (IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE)) { - char *buf; - /* Look for an Android boot image */ buf = map_sysmem(images.os.start, 0); if (buf && genimg_get_format(buf) == IMAGE_FORMAT_ANDROID) @@ -525,9 +525,12 @@ int bootm_find_images(int flag, int argc, char *const argv[], ulong start, } if (CONFIG_IS_ENABLED(OF_LIBFDT)) { + img_addr = argc ? hextoul(argv[0], NULL) : image_load_addr; + buf = map_sysmem(img_addr, 0); + /* find flattened device tree */ - ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, &images, - &images.ft_addr, &images.ft_len); + ret = boot_get_fdt(buf, flag, argc, argv, IH_ARCH_DEFAULT, + &images, &images.ft_addr, &images.ft_len); if (ret) { puts("Could not find a valid device tree\n"); return 1; diff --git a/boot/image-fdt.c b/boot/image-fdt.c index f10200f6474..6ff2d52d6c7 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -447,43 +447,17 @@ static int select_fdt(struct bootm_headers *images, const char *select, u8 arch, return 0; } -/** - * boot_get_fdt - main fdt handling routine - * @argc: command argument count - * @argv: command argument list - * @arch: architecture (IH_ARCH_...) - * @images: pointer to the bootm images structure - * @of_flat_tree: pointer to a char* variable, will hold fdt start address - * @of_size: pointer to a ulong variable, will hold fdt length - * - * boot_get_fdt() is responsible for finding a valid flat device tree image. - * Currently supported are the following ramdisk sources: - * - multicomponent kernel/ramdisk image, - * - commandline provided address of decicated ramdisk image. - * - * returns: - * 0, if fdt image was found and valid, or skipped - * of_flat_tree and of_size are set to fdt start address and length if - * fdt image is found and valid - * - * 1, if fdt image is found but corrupted - * of_flat_tree and of_size are set to 0 if no fdt exists - */ -int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch, - struct bootm_headers *images, char **of_flat_tree, ulong *of_size) +int boot_get_fdt(void *buf, int flag, int argc, char *const argv[], uint arch, + struct bootm_headers *images, char **of_flat_tree, + ulong *of_size) { - ulong img_addr; ulong fdt_addr; char *fdt_blob = NULL; - void *buf; const char *select = NULL; *of_flat_tree = NULL; *of_size = 0; - img_addr = (argc == 0) ? image_load_addr : hextoul(argv[0], NULL); - buf = map_sysmem(img_addr, 0); - if (argc > 2) select = argv[2]; if (select || genimg_has_config(images)) { |