cmd: Update addr_find to use a simple lmb allocation
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>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
env_set_hex("loadaddr", start);
|
||||
debug("Set loadaddr to %llx\n", (u64)start);
|
||||
|
||||
log_debug("Set loadaddr to %lx\n", addr);
|
||||
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user