diff options
author | Tom Rini <trini@konsulko.com> | 2020-03-31 17:24:19 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-03-31 17:24:19 -0400 |
commit | 2b18b89156335bf1f0d84f81d3597762bc48c61d (patch) | |
tree | 544e93c39bfaeff20b2ac47980de27edf1a585e4 /cmd | |
parent | 779e6dc6a429ac28dfd4f07ab0c3648a31399d4a (diff) | |
parent | ac28e59a574dd231a4787752d923f618587e3d10 (diff) | |
download | u-boot-2b18b89156335bf1f0d84f81d3597762bc48c61d.tar.gz |
Merge branch 'next' of git://git.denx.de/u-boot-usb into nextWIP/31Mar2020-next
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/bootefi.c | 49 | ||||
-rw-r--r-- | cmd/efidebug.c | 13 | ||||
-rw-r--r-- | cmd/gpio.c | 7 |
3 files changed, 51 insertions, 18 deletions
diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 24fc42ae89..3bbe2d6a1a 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -149,6 +149,20 @@ done: return ret; } +static void efi_reserve_memory(u64 addr, u64 size) +{ + u64 pages; + + /* Convert from sandbox address space. */ + addr = (uintptr_t)map_sysmem(addr, 0); + pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK)); + addr &= ~EFI_PAGE_MASK; + if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE, + false) != EFI_SUCCESS) + printf("Reserved memory mapping failed addr %llx size %llx\n", + addr, size); +} + /** * efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges * @@ -161,7 +175,8 @@ done: static void efi_carve_out_dt_rsv(void *fdt) { int nr_rsv, i; - uint64_t addr, size, pages; + u64 addr, size; + int nodeoffset, subnode; nr_rsv = fdt_num_mem_rsv(fdt); @@ -169,15 +184,25 @@ static void efi_carve_out_dt_rsv(void *fdt) for (i = 0; i < nr_rsv; i++) { if (fdt_get_mem_rsv(fdt, i, &addr, &size) != 0) continue; + efi_reserve_memory(addr, size); + } - /* Convert from sandbox address space. */ - addr = (uintptr_t)map_sysmem(addr, 0); - - pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK)); - addr &= ~EFI_PAGE_MASK; - if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE, - false) != EFI_SUCCESS) - printf("FDT memrsv map %d: Failed to add to map\n", i); + /* process reserved-memory */ + nodeoffset = fdt_subnode_offset(fdt, 0, "reserved-memory"); + if (nodeoffset >= 0) { + subnode = fdt_first_subnode(fdt, nodeoffset); + while (subnode >= 0) { + /* check if this subnode has a reg property */ + addr = fdtdec_get_addr_size(fdt, subnode, "reg", + (fdt_size_t *)&size); + /* + * The /reserved-memory node may have children with + * a size instead of a reg property. + */ + if (addr != FDT_ADDR_T_NONE) + efi_reserve_memory(addr, size); + subnode = fdt_next_subnode(fdt, subnode); + } } } @@ -263,9 +288,6 @@ efi_status_t efi_install_fdt(void *fdt) return EFI_LOAD_ERROR; } - /* Create memory reservations as indicated by the device tree */ - efi_carve_out_dt_rsv(fdt); - /* Prepare device tree for payload */ ret = copy_fdt(&fdt); if (ret) { @@ -278,6 +300,9 @@ efi_status_t efi_install_fdt(void *fdt) return EFI_LOAD_ERROR; } + /* Create memory reservations as indicated by the device tree */ + efi_carve_out_dt_rsv(fdt); + /* Install device tree as UEFI table */ ret = efi_install_configuration_table(&efi_guid_fdt, fdt); if (ret != EFI_SUCCESS) { diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 21dfd44fcc..bb7c13d6a1 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -12,6 +12,7 @@ #include <exports.h> #include <hexdump.h> #include <malloc.h> +#include <mapmem.h> #include <search.h> #include <linux/ctype.h> @@ -488,9 +489,10 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag, printf("%-16s %.*llx-%.*llx", type, EFI_PHYS_ADDR_WIDTH, - map->physical_start, + (u64)map_to_sysmem((void *)map->physical_start), EFI_PHYS_ADDR_WIDTH, - map->physical_start + map->num_pages * EFI_PAGE_SIZE); + (u64)map_to_sysmem((void *)map->physical_start + + map->num_pages * EFI_PAGE_SIZE)); print_memory_attributes(map->attribute); putc('\n'); @@ -649,7 +651,7 @@ static int do_efi_boot_rm(cmd_tbl_t *cmdtp, int flag, int id, i; char *endp; char var_name[9]; - u16 var_name16[9]; + u16 var_name16[9], *p; efi_status_t ret; if (argc == 1) @@ -662,11 +664,12 @@ static int do_efi_boot_rm(cmd_tbl_t *cmdtp, int flag, return CMD_RET_FAILURE; sprintf(var_name, "Boot%04X", id); - utf8_utf16_strncpy((u16 **)&var_name16, var_name, 9); + p = var_name16; + utf8_utf16_strncpy(&p, var_name, 9); ret = EFI_CALL(RT->set_variable(var_name16, &guid, 0, 0, NULL)); if (ret) { - printf("Cannot remove Boot%04X", id); + printf("Cannot remove %ls\n", var_name16); return CMD_RET_FAILURE; } } diff --git a/cmd/gpio.c b/cmd/gpio.c index 16c2cebb3d..408a942455 100644 --- a/cmd/gpio.c +++ b/cmd/gpio.c @@ -248,7 +248,12 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (ret != -EBUSY) gpio_free(gpio); - return CMD_RET_SUCCESS; + /* + * Whilst wrong, the legacy gpio input command returns the pin + * value, or CMD_RET_FAILURE (which is indistinguishable from a + * valid pin value). + */ + return (sub_cmd == GPIOC_INPUT) ? value : CMD_RET_SUCCESS; err: if (ret != -EBUSY) |