
From: Simon Glass <sjg@chromium.org> There should be no need to parse the LMB tables manually. Use the allocation-function provided instead. Adjust the argument checks while we are here. Also enable this command for sandbox and the EFI app, so it is built in CI. Signed-off-by: Simon Glass <sjg@chromium.org> --- cmd/Kconfig | 4 ++-- cmd/addr_find.c | 17 +++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 44e1b60c592..05c130b511e 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -129,8 +129,8 @@ config CMD_ACPI want to make hardware changes without the OS needing to be adjusted. config CMD_ADDR_FIND - bool "addr_find" - default y if EFI_APP + bool "addr_find" + default y if SANDBOX || EFI_APP help This command searches for an unused region of address space sufficiently large to hold a file. If successful, it sets the diff --git a/cmd/addr_find.c b/cmd/addr_find.c index 876c58feabd..64ecc816be3 100644 --- a/cmd/addr_find.c +++ b/cmd/addr_find.c @@ -17,8 +17,8 @@ DECLARE_GLOBAL_DATA_PTR; int do_addr_find(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { const char *filename; + phys_addr_t start; loff_t size; - ulong addr; int ret; if (!gd->fdt_blob) { @@ -47,24 +47,21 @@ int do_addr_find(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_FAILURE; } - addr = lmb_alloc(size, SZ_1M); - if (!addr) { + start = lmb_alloc(size, SZ_2M); + if ((long)start < 0) { log_err("Failed to find enough RAM for 0x%llx bytes\n", size); - return CMD_RET_FAILURE; - } - if (env_set_hex("loadaddr", addr)) { - log_err("Could not set loadaddr\n"); return CMD_RET_FAILURE; } - log_debug("Set loadaddr to %lx\n", addr); + env_set_hex("loadaddr", start); + debug("Set loadaddr to %llx\n", (u64)start); - return CMD_RET_SUCCESS; + return 0; } U_BOOT_CMD( - addr_find, 7, 1, do_addr_find, + addr_find, 4, 1, do_addr_find, "find a load address suitable for a file", "<interface> [<dev[:part]>] <filename>\n" "- find a consecutive region of memory sufficiently large to hold\n" -- 2.43.0