diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/Kconfig | 14 | ||||
| -rw-r--r-- | cmd/config.c | 26 | ||||
| -rw-r--r-- | cmd/cyclic.c | 5 | ||||
| -rw-r--r-- | cmd/date.c | 2 | ||||
| -rw-r--r-- | cmd/efi.c | 221 | ||||
| -rw-r--r-- | cmd/efi_common.c | 137 | ||||
| -rw-r--r-- | cmd/eficonfig.c | 4 | ||||
| -rw-r--r-- | cmd/efidebug.c | 96 | ||||
| -rw-r--r-- | cmd/i3c.c | 11 | ||||
| -rw-r--r-- | cmd/lwip/Makefile | 1 | ||||
| -rw-r--r-- | cmd/lwip/sntp.c | 1 | ||||
| -rw-r--r-- | cmd/lwip/tftpsrv.c | 11 | ||||
| -rw-r--r-- | cmd/lwip/wget.c | 3 | ||||
| -rw-r--r-- | cmd/mbr.c | 2 | ||||
| -rw-r--r-- | cmd/mtd.c | 4 | ||||
| -rw-r--r-- | cmd/net.c | 4 | ||||
| -rw-r--r-- | cmd/nvedit_efi.c | 22 | ||||
| -rw-r--r-- | cmd/pstore.c | 10 | ||||
| -rw-r--r-- | cmd/read.c | 2 | ||||
| -rw-r--r-- | cmd/scmi.c | 3 | ||||
| -rw-r--r-- | cmd/scsi.c | 2 | ||||
| -rw-r--r-- | cmd/strings.c | 2 | ||||
| -rw-r--r-- | cmd/ufetch.c | 4 |
23 files changed, 232 insertions, 355 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig index 35ce42f8397..ff90a87024c 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2135,12 +2135,6 @@ config CMD_TFTPPUT help TFTP put command, for uploading files to a server -config CMD_TFTPSRV - bool "tftpsrv" - depends on CMD_TFTPBOOT - help - Act as a TFTP server and boot the first received file - config NET_TFTP_VARS bool "Control TFTP timeout and count through environment" depends on CMD_TFTPBOOT @@ -2287,6 +2281,14 @@ config CMD_TFTPBOOT help tftpboot - load file via network using TFTP protocol +config CMD_TFTPSRV + bool "tftpsrv" + depends on CMD_TFTPBOOT + help + Act as a TFTP server and receive the first incoming file into + memory. The command returns successfully after the transfer so + boot scripts can boot the received image from the load address. + config CMD_WGET bool "wget" default y if SANDBOX || ARCH_QEMU diff --git a/cmd/config.c b/cmd/config.c index f0d2033c61f..22115e9b1da 100644 --- a/cmd/config.c +++ b/cmd/config.c @@ -6,6 +6,7 @@ #include <command.h> #include <gzip.h> #include <malloc.h> +#include <linux/string.h> #include "config_data_gz.h" #include "config_data_size.h" @@ -29,7 +30,23 @@ static int do_config(struct cmd_tbl *cmdtp, int flag, int argc, } dst[data_size] = 0; - puts(dst); + if (argc > 1) { + const char *s = argv[1]; + char *b = dst, *e = dst + data_size, *n; + + while (b < e) { + n = strchrnul(b, '\n'); + *n = '\0'; + + if (strcasestr(b, s)) { + puts(b); + puts("\n"); + } + b = n + 1; + } + } else { + puts(dst); + } free: free(dst); @@ -38,7 +55,10 @@ free: } U_BOOT_CMD( - config, 1, 1, do_config, + config, 2, 1, do_config, "print .config", - "" + "[str]\n" + "\n" + "When the optional argument is given, only lines containing\n" + "that string are printed. Matching is case-insensitive." ); diff --git a/cmd/cyclic.c b/cmd/cyclic.c index 339dd4a7bce..880cd648aae 100644 --- a/cmd/cyclic.c +++ b/cmd/cyclic.c @@ -16,6 +16,9 @@ #include <vsprintf.h> #include <linux/delay.h> #include <linux/kernel.h> +#include <asm/global_data.h> + +DECLARE_GLOBAL_DATA_PTR; struct cyclic_demo_info { struct cyclic_info cyclic; @@ -64,7 +67,7 @@ static int do_cyclic_list(struct cmd_tbl *cmdtp, int flag, int argc, struct hlist_node *tmp; u64 cnt, freq; - hlist_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) { + hlist_for_each_entry_safe(cyclic, tmp, &gd->cyclic_list, list) { cnt = cyclic->run_cnt * 1000000ULL * 100ULL; freq = lldiv(cnt, timer_get_us() - cyclic->start_time_us); printf("function: %s, cpu-time: %lld us, frequency: %lld.%02d times/s\n", diff --git a/cmd/date.c b/cmd/date.c index 67cfaed0d48..8d15018253b 100644 --- a/cmd/date.c +++ b/cmd/date.c @@ -44,7 +44,7 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc, if (strcmp(argv[1],"reset") == 0) { puts ("Reset RTC...\n"); rcode = dm_rtc_reset(dev); - if (!rcode) + if (!rcode || rcode == -ENOSYS) rcode = dm_rtc_set(dev, &default_tm); if (rcode) puts("## Failed to set date after RTC reset\n"); diff --git a/cmd/efi.c b/cmd/efi.c index 687ccb52042..c49a873f3da 100644 --- a/cmd/efi.c +++ b/cmd/efi.c @@ -10,223 +10,19 @@ #include <errno.h> #include <log.h> #include <malloc.h> -#include <sort.h> #include <u-boot/uuid.h> #include <asm/global_data.h> DECLARE_GLOBAL_DATA_PTR; -static const char *const type_name[] = { - "reserved", - "loader_code", - "loader_data", - "bs_code", - "bs_data", - "rt_code", - "rt_data", - "conv", - "unusable", - "acpi_reclaim", - "acpi_nvs", - "io", - "io_port", - "pal_code", -}; - -static struct attr_info { - u64 val; - const char *name; -} mem_attr[] = { - { EFI_MEMORY_UC, "uncached" }, - { EFI_MEMORY_WC, "write-coalescing" }, - { EFI_MEMORY_WT, "write-through" }, - { EFI_MEMORY_WB, "write-back" }, - { EFI_MEMORY_UCE, "uncached & exported" }, - { EFI_MEMORY_WP, "write-protect" }, - { EFI_MEMORY_RP, "read-protect" }, - { EFI_MEMORY_XP, "execute-protect" }, - { EFI_MEMORY_NV, "non-volatile" }, - { EFI_MEMORY_MORE_RELIABLE, "higher reliability" }, - { EFI_MEMORY_RO, "read-only" }, - { EFI_MEMORY_SP, "specific purpose" }, - { EFI_MEMORY_RUNTIME, "needs runtime mapping" } -}; - -/* Maximum different attribute values we can track */ -#define ATTR_SEEN_MAX 30 - -static inline bool is_boot_services(int type) -{ - return type == EFI_LOADER_CODE || type == EFI_LOADER_DATA || - type == EFI_BOOT_SERVICES_CODE || - type == EFI_BOOT_SERVICES_DATA; -} - -static int h_cmp_entry(const void *v1, const void *v2) -{ - const struct efi_mem_desc *desc1 = v1; - const struct efi_mem_desc *desc2 = v2; - int64_t diff = desc1->physical_start - desc2->physical_start; - - /* - * Manually calculate the difference to avoid sign loss in the 64-bit - * to 32-bit conversion - */ - return diff < 0 ? -1 : diff > 0 ? 1 : 0; -} - -/** - * efi_build_mem_table() - make a sorted copy of the memory table - * - * @desc_base: Pointer to EFI memory map table - * @size: Size of table in bytes - * @desc_size: Size of each @desc_base record - * @skip_bs: True to skip boot-time memory and merge it with conventional - * memory. This will significantly reduce the number of table - * entries. - * Return: pointer to the new table. It should be freed with free() by the - * caller. - */ -static void *efi_build_mem_table(struct efi_mem_desc *desc_base, int size, - int desc_size, bool skip_bs) -{ - struct efi_mem_desc *desc, *end, *base, *dest, *prev; - int count; - u64 addr; - - base = malloc(size + sizeof(*desc)); - if (!base) { - debug("%s: Cannot allocate %#x bytes\n", __func__, size); - return NULL; - } - end = (void *)desc_base + size; - count = ((ulong)end - (ulong)desc_base) / desc_size; - memcpy(base, desc_base, (ulong)end - (ulong)desc_base); - qsort(base, count, desc_size, h_cmp_entry); - prev = NULL; - addr = 0; - dest = base; - end = (struct efi_mem_desc *)((ulong)base + count * desc_size); - for (desc = base; desc < end; - desc = efi_get_next_mem_desc(desc, desc_size)) { - bool merge = true; - u32 type = desc->type; - - if (type >= EFI_MAX_MEMORY_TYPE) { - printf("Memory map contains invalid entry type %u\n", - type); - continue; - } - - if (skip_bs && is_boot_services(desc->type)) - type = EFI_CONVENTIONAL_MEMORY; - - memcpy(dest, desc, desc_size); - dest->type = type; - if (!skip_bs || !prev) - merge = false; - else if (desc->physical_start != addr) - merge = false; - else if (type != EFI_CONVENTIONAL_MEMORY) - merge = false; - else if (prev->type != EFI_CONVENTIONAL_MEMORY) - merge = false; - - if (merge) { - prev->num_pages += desc->num_pages; - } else { - prev = dest; - dest = efi_get_next_mem_desc(dest, desc_size); - } - addr = desc->physical_start + (desc->num_pages << - EFI_PAGE_SHIFT); - } - - /* Mark the end */ - dest->type = EFI_MAX_MEMORY_TYPE; - - return base; -} - -static void efi_print_mem_table(struct efi_mem_desc *desc, int desc_size, - bool skip_bs) -{ - u64 attr_seen[ATTR_SEEN_MAX]; - int attr_seen_count; - int upto, i; - u64 addr; - - printf(" # %-14s %10s %10s %10s %s\n", "Type", "Physical", - "Virtual", "Size", "Attributes"); - - /* Keep track of all the different attributes we have seen */ - attr_seen_count = 0; - addr = 0; - for (upto = 0; desc->type != EFI_MAX_MEMORY_TYPE; - upto++, desc = efi_get_next_mem_desc(desc, desc_size)) { - const char *name; - u64 size; - - if (skip_bs && is_boot_services(desc->type)) - continue; - if (desc->physical_start != addr) { - printf(" %-14s %010llx %10s %010llx\n", "<gap>", - addr, "", desc->physical_start - addr); - } - size = desc->num_pages << EFI_PAGE_SHIFT; - - name = desc->type < ARRAY_SIZE(type_name) ? - type_name[desc->type] : "<invalid>"; - printf("%2d %x:%-12s %010llx %010llx %010llx ", upto, - desc->type, name, desc->physical_start, - desc->virtual_start, size); - if (desc->attribute & EFI_MEMORY_RUNTIME) - putc('r'); - printf("%llx", desc->attribute & ~EFI_MEMORY_RUNTIME); - putc('\n'); - - for (i = 0; i < attr_seen_count; i++) { - if (attr_seen[i] == desc->attribute) - break; - } - if (i == attr_seen_count && i < ATTR_SEEN_MAX) - attr_seen[attr_seen_count++] = desc->attribute; - addr = desc->physical_start + size; - } - - printf("\nAttributes key:\n"); - for (i = 0; i < attr_seen_count; i++) { - u64 attr = attr_seen[i]; - bool first; - int j; - - printf("%c%llx: ", (attr & EFI_MEMORY_RUNTIME) ? 'r' : ' ', - attr & ~EFI_MEMORY_RUNTIME); - for (j = 0, first = true; j < ARRAY_SIZE(mem_attr); j++) { - if (attr & mem_attr[j].val) { - if (first) - first = false; - else - printf(", "); - printf("%s", mem_attr[j].name); - } - } - putc('\n'); - } - if (skip_bs) - printf("*Some areas are merged (use 'all' to see)\n"); -} - static int do_efi_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct efi_mem_desc *orig, *desc; - uint version, key; + struct efi_mem_desc *orig; + uint version, key = 0; int desc_size; int size, ret; - bool skip_bs; - skip_bs = !argc || *argv[0] != 'a'; if (IS_ENABLED(CONFIG_EFI_APP)) { ret = efi_get_mmap(&orig, &size, &key, &desc_size, &version); if (ret) { @@ -257,14 +53,7 @@ static int do_efi_mem(struct cmd_tbl *cmdtp, int flag, int argc, goto done; } - desc = efi_build_mem_table(orig, size, desc_size, skip_bs); - if (!desc) { - ret = -ENOMEM; - goto done; - } - - efi_print_mem_table(desc, desc_size, skip_bs); - free(desc); + efi_show_memmap(orig, size, desc_size); if (IS_ENABLED(CONFIG_EFI_APP)) free(orig); done: @@ -300,7 +89,7 @@ static int do_efi_tables(struct cmd_tbl *cmdtp, int flag, int argc, } static struct cmd_tbl efi_commands[] = { - U_BOOT_CMD_MKENT(mem, 1, 1, do_efi_mem, "", ""), + U_BOOT_CMD_MKENT(mem, 0, 1, do_efi_mem, "", ""), U_BOOT_CMD_MKENT(tables, 1, 1, do_efi_tables, "", ""), }; @@ -325,6 +114,6 @@ static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) U_BOOT_CMD( efi, 3, 1, do_efi, "EFI access", - "mem [all] Dump memory information [include boot services]\n" + "mem Dump memory map\n" "tables Dump tables" ); diff --git a/cmd/efi_common.c b/cmd/efi_common.c index d2f2b59e9e3..e57835d3bae 100644 --- a/cmd/efi_common.c +++ b/cmd/efi_common.c @@ -8,8 +8,60 @@ #include <efi.h> #include <efi_api.h> +#include <mapmem.h> #include <u-boot/uuid.h> +/* Width of an EFI physical address in hexadecimal digits */ +#define EFI_PHYS_ADDR_WIDTH (int)(sizeof(efi_physical_addr_t) * 2) + +/* Width of the memory type column, sized for the longest type name */ +#define EFI_MEM_TYPE_WIDTH 23 + +/* + * The type names of the UEFI specification without the leading 'Efi' and + * the trailing 'Type' + */ +static const char *const efi_mem_type_string[] = { + [EFI_RESERVED_MEMORY_TYPE] = "ReservedMemory", + [EFI_LOADER_CODE] = "LoaderCode", + [EFI_LOADER_DATA] = "LoaderData", + [EFI_BOOT_SERVICES_CODE] = "BootServicesCode", + [EFI_BOOT_SERVICES_DATA] = "BootServicesData", + [EFI_RUNTIME_SERVICES_CODE] = "RuntimeServicesCode", + [EFI_RUNTIME_SERVICES_DATA] = "RuntimeServicesData", + [EFI_CONVENTIONAL_MEMORY] = "ConventionalMemory", + [EFI_UNUSABLE_MEMORY] = "UnusableMemory", + [EFI_ACPI_RECLAIM_MEMORY] = "ACPIReclaimMemory", + [EFI_ACPI_MEMORY_NVS] = "ACPIMemoryNVS", + [EFI_MMAP_IO] = "MemoryMappedIO", + [EFI_MMAP_IO_PORT] = "MemoryMappedIOPortSpace", + [EFI_PAL_CODE] = "PalCode", + [EFI_PERSISTENT_MEMORY_TYPE] = "PersistentMemory", + [EFI_UNACCEPTED_MEMORY_TYPE] = "UnacceptedMemory", +}; + +static const struct efi_mem_attrs { + const u64 bit; + const char *text; +} efi_mem_attrs[] = { + {EFI_MEMORY_UC, "UC"}, + {EFI_MEMORY_WC, "WC"}, + {EFI_MEMORY_WT, "WT"}, + {EFI_MEMORY_WB, "WB"}, + {EFI_MEMORY_UCE, "UCE"}, + {EFI_MEMORY_WP, "WP"}, + {EFI_MEMORY_RP, "RP"}, + {EFI_MEMORY_XP, "XP"}, + {EFI_MEMORY_NV, "NV"}, + {EFI_MEMORY_MORE_RELIABLE, "REL"}, + {EFI_MEMORY_RO, "RO"}, + {EFI_MEMORY_SP, "SP"}, + {EFI_MEMORY_CPU_CRYPTO, "CRYPT"}, + {EFI_MEMORY_HOT_PLUGGABLE, "HOTPL"}, + {EFI_MEMORY_ISA_VALID, "ISA_VALID"}, + {EFI_MEMORY_RUNTIME, "RT"}, +}; + void efi_show_tables(struct efi_system_table *systab) { int i; @@ -21,3 +73,88 @@ void efi_show_tables(struct efi_system_table *systab) uuid_guid_get_str(tab->guid.b) ?: "(unknown)"); } } + +/** + * efi_mem_type_name() - get the name of an EFI memory type + * + * @type: memory type (enum efi_memory_type) + * Return: name of the memory type, or NULL if @type is unknown + */ +static const char *efi_mem_type_name(u32 type) +{ + if (type >= ARRAY_SIZE(efi_mem_type_string)) + return NULL; + + return efi_mem_type_string[type]; +} + +/** + * efi_print_mem_attrs() - print the names of set EFI memory attributes + * + * Prints the set attribute bits as a '|'-separated list of mnemonics, + * e.g. ' UC|WB|RT', preceded by a space. When EFI_MEMORY_ISA_VALID is + * set, the EFI_MEMORY_ISA_MASK field is printed as ISA=<value>. Bits + * that have no mnemonic are printed as a hexadecimal value so that + * invalid or not yet known attributes are never dropped silently. + * + * @attributes: memory attributes (EFI_MEMORY_...) + */ +static void efi_print_mem_attrs(u64 attributes) +{ + u64 unknown = attributes; + int sep, i; + + for (sep = 0, i = 0; i < ARRAY_SIZE(efi_mem_attrs); i++) + if (attributes & efi_mem_attrs[i].bit) { + if (sep) { + putc('|'); + } else { + putc(' '); + sep = 1; + } + puts(efi_mem_attrs[i].text); + unknown &= ~efi_mem_attrs[i].bit; + } + + if (attributes & EFI_MEMORY_ISA_VALID) { + printf("%sISA=0x%llx", sep ? "|" : " ", + (attributes & EFI_MEMORY_ISA_MASK) >> + EFI_MEMORY_ISA_SHIFT); + sep = 1; + unknown &= ~EFI_MEMORY_ISA_MASK; + } + + if (unknown) + printf("%s0x%llx", sep ? "|" : " ", unknown); +} + +void efi_show_memmap(struct efi_mem_desc *map, efi_uintn_t map_size, + efi_uintn_t desc_size) +{ + struct efi_mem_desc *end = (void *)map + map_size; + static const char sep[] = "========================"; + const char *type; + + printf("%-*s %-*s %-*s Attributes\n", + EFI_MEM_TYPE_WIDTH, "Type", + EFI_PHYS_ADDR_WIDTH, "Start", EFI_PHYS_ADDR_WIDTH, "End"); + printf("%.*s %.*s %.*s ==========\n", + EFI_MEM_TYPE_WIDTH, sep, + EFI_PHYS_ADDR_WIDTH, sep, EFI_PHYS_ADDR_WIDTH, sep); + + for (; map < end; map = efi_get_next_mem_desc(map, desc_size)) { + type = efi_mem_type_name(map->type) ?: "(unknown)"; + + printf("%-*s %.*llx-%.*llx", EFI_MEM_TYPE_WIDTH, type, + EFI_PHYS_ADDR_WIDTH, + (u64)map_to_sysmem((void *)(uintptr_t) + map->physical_start), + EFI_PHYS_ADDR_WIDTH, + (u64)map_to_sysmem((void *)(uintptr_t) + (map->physical_start + + map->num_pages * EFI_PAGE_SIZE))); + + efi_print_mem_attrs(map->attribute); + putc('\n'); + } +} diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 4d060e3007c..d8e7ed6666a 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -1844,6 +1844,7 @@ static efi_status_t eficonfig_show_boot_selection(unsigned int *selected) struct efimenu *efi_menu; struct list_head *pos, *n; struct eficonfig_entry *entry; + efi_guid_t guid; efi_menu = calloc(1, sizeof(struct efimenu)); if (!efi_menu) @@ -1872,7 +1873,6 @@ static efi_status_t eficonfig_show_boot_selection(unsigned int *selected) var_name16[0] = 0; for (;;) { int index; - efi_guid_t guid; ret = efi_next_variable_name(&buf_size, &var_name16, &guid); if (ret == EFI_NOT_FOUND) @@ -2245,6 +2245,7 @@ static efi_status_t eficonfig_create_change_boot_order_entry(struct efimenu *efi u16 *var_name16 = NULL; efi_uintn_t size, buf_size; struct eficonfig_save_boot_order_data *save_data; + efi_guid_t guid; /* list the load option in the order of BootOrder variable */ for (i = 0; i < num; i++) { @@ -2265,7 +2266,6 @@ static efi_status_t eficonfig_create_change_boot_order_entry(struct efimenu *efi var_name16[0] = 0; for (;;) { int index; - efi_guid_t guid; if (efi_menu->count >= EFICONFIG_ENTRY_NUM_MAX - 2) break; diff --git a/cmd/efidebug.c b/cmd/efidebug.c index a6faa36b500..e55de04c699 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -574,70 +574,6 @@ static int do_efi_show_ecpt(struct cmd_tbl *cmdtp, int flag, int argc, } #endif /* CONFIG_IS_ENABLED(EFI_ECPT) */ -static const char * const efi_mem_type_string[] = { - [EFI_RESERVED_MEMORY_TYPE] = "RESERVED", - [EFI_LOADER_CODE] = "LOADER CODE", - [EFI_LOADER_DATA] = "LOADER DATA", - [EFI_BOOT_SERVICES_CODE] = "BOOT CODE", - [EFI_BOOT_SERVICES_DATA] = "BOOT DATA", - [EFI_RUNTIME_SERVICES_CODE] = "RUNTIME CODE", - [EFI_RUNTIME_SERVICES_DATA] = "RUNTIME DATA", - [EFI_CONVENTIONAL_MEMORY] = "CONVENTIONAL", - [EFI_UNUSABLE_MEMORY] = "UNUSABLE MEM", - [EFI_ACPI_RECLAIM_MEMORY] = "ACPI RECLAIM MEM", - [EFI_ACPI_MEMORY_NVS] = "ACPI NVS", - [EFI_MMAP_IO] = "IO", - [EFI_MMAP_IO_PORT] = "IO PORT", - [EFI_PAL_CODE] = "PAL", - [EFI_PERSISTENT_MEMORY_TYPE] = "PERSISTENT", -}; - -static const struct efi_mem_attrs { - const u64 bit; - const char *text; -} efi_mem_attrs[] = { - {EFI_MEMORY_UC, "UC"}, - {EFI_MEMORY_WC, "WC"}, - {EFI_MEMORY_WT, "WT"}, - {EFI_MEMORY_WB, "WB"}, - {EFI_MEMORY_UCE, "UCE"}, - {EFI_MEMORY_WP, "WP"}, - {EFI_MEMORY_RP, "RP"}, - {EFI_MEMORY_XP, "XP"}, - {EFI_MEMORY_NV, "NV"}, - {EFI_MEMORY_MORE_RELIABLE, "REL"}, - {EFI_MEMORY_RO, "RO"}, - {EFI_MEMORY_SP, "SP"}, - {EFI_MEMORY_CPU_CRYPTO, "CRYPT"}, - {EFI_MEMORY_HOT_PLUGGABLE, "HOTPL"}, - {EFI_MEMORY_RUNTIME, "RT"}, -}; - -/** - * print_memory_attributes() - print memory map attributes - * - * @attributes: Attribute value - * - * Print memory map attributes - */ -static void print_memory_attributes(u64 attributes) -{ - int sep, i; - - for (sep = 0, i = 0; i < ARRAY_SIZE(efi_mem_attrs); i++) - if (attributes & efi_mem_attrs[i].bit) { - if (sep) { - putc('|'); - } else { - putc(' '); - sep = 1; - } - puts(efi_mem_attrs[i].text); - } -} - -#define EFI_PHYS_ADDR_WIDTH (int)(sizeof(efi_physical_addr_t) * 2) - /** * do_efi_show_memmap() - show UEFI memory map * @@ -653,43 +589,15 @@ static void print_memory_attributes(u64 attributes) static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct efi_mem_desc *memmap, *map; + struct efi_mem_desc *memmap; efi_uintn_t map_size; - const char *type; - int i; efi_status_t ret; ret = efi_get_memory_map_alloc(&map_size, &memmap); if (ret != EFI_SUCCESS) return CMD_RET_FAILURE; - printf("Type Start%.*s End%.*s Attributes\n", - EFI_PHYS_ADDR_WIDTH - 5, spc, EFI_PHYS_ADDR_WIDTH - 3, spc); - printf("================ %.*s %.*s ==========\n", - EFI_PHYS_ADDR_WIDTH, sep, EFI_PHYS_ADDR_WIDTH, sep); - /* - * Coverity check: dereferencing null pointer "map." - * This is a false positive as memmap will always be - * populated by allocate_pool() above. - */ - for (i = 0, map = memmap; i < map_size / sizeof(*map); map++, i++) { - if (map->type < ARRAY_SIZE(efi_mem_type_string)) - type = efi_mem_type_string[map->type]; - else - type = "(unknown)"; - - printf("%-16s %.*llx-%.*llx", type, - EFI_PHYS_ADDR_WIDTH, - (u64)map_to_sysmem((void *)(uintptr_t) - map->physical_start), - EFI_PHYS_ADDR_WIDTH, - (u64)map_to_sysmem((void *)(uintptr_t) - (map->physical_start + - map->num_pages * EFI_PAGE_SIZE))); - - print_memory_attributes(map->attribute); - putc('\n'); - } + efi_show_memmap(memmap, map_size, sizeof(*memmap)); efi_free_pool(memmap); diff --git a/cmd/i3c.c b/cmd/i3c.c index 08957f4d447..ba99a937990 100644 --- a/cmd/i3c.c +++ b/cmd/i3c.c @@ -240,16 +240,17 @@ static int do_i3c(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (!is_i3c_subcommand(subcmd)) return handle_i3c_select(subcmd); + if (!strcmp(subcmd, "list")) + return handle_i3c_list(); + else if (!strcmp(subcmd, "current")) + return handle_i3c_current(); + if (!currdev) { printf("i3c: No I3C controller selected\n"); return CMD_RET_FAILURE; } - if (!strcmp(subcmd, "list")) - return handle_i3c_list(); - else if (!strcmp(subcmd, "current")) - return handle_i3c_current(); - else if (!strcmp(subcmd, "device_list")) + if (!strcmp(subcmd, "device_list")) return handle_i3c_device_list(); else if (!strcmp(subcmd, "write")) return handle_i3c_write(argc, argv); diff --git a/cmd/lwip/Makefile b/cmd/lwip/Makefile index 90df1f5511c..245683a9672 100644 --- a/cmd/lwip/Makefile +++ b/cmd/lwip/Makefile @@ -4,4 +4,5 @@ obj-$(CONFIG_CMD_NFS) += nfs.o obj-$(CONFIG_CMD_PING) += ping.o obj-$(CONFIG_CMD_SNTP) += sntp.o obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o +obj-$(CONFIG_CMD_TFTPSRV) += tftpsrv.o obj-$(CONFIG_CMD_WGET) += wget.o diff --git a/cmd/lwip/sntp.c b/cmd/lwip/sntp.c index 5fa400b104a..584151ba7d1 100644 --- a/cmd/lwip/sntp.c +++ b/cmd/lwip/sntp.c @@ -71,6 +71,7 @@ static int sntp_loop(struct udevice *udev, ip_addr_t *srvip) } else { if (!ntp_server_known()) { log_err("error: ntpserverip not set\n"); + net_lwip_remove_netif(netif); return -1; } } diff --git a/cmd/lwip/tftpsrv.c b/cmd/lwip/tftpsrv.c new file mode 100644 index 00000000000..6370c900489 --- /dev/null +++ b/cmd/lwip/tftpsrv.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <command.h> +#include <net.h> + +U_BOOT_CMD(tftpsrv, 2, 1, do_tftpsrv, + "act as a TFTP server and receive the first file", + "[loadAddress]\n" + "Listen for an incoming TFTP transfer and receive a file into memory.\n" + "The transfer is aborted if a transfer has not been started after\n" + "about 50 seconds or if Ctrl-C is pressed."); diff --git a/cmd/lwip/wget.c b/cmd/lwip/wget.c index 4883ad61bce..531e886e986 100644 --- a/cmd/lwip/wget.c +++ b/cmd/lwip/wget.c @@ -67,12 +67,15 @@ static int _set_cacert(const void *addr, size_t sz) if (ret) { if (!wget_info->silent) printf("Could not parse certificates (%d)\n", ret); + mbedtls_x509_crt_free(&crt); free(cacert); cacert = NULL; cacert_size = 0; return CMD_RET_FAILURE; } + mbedtls_x509_crt_free(&crt); + #if CONFIG_IS_ENABLED(WGET_BUILTIN_CACERT) cacert_initialized = true; #endif diff --git a/cmd/mbr.c b/cmd/mbr.c index 7fe6c9e103a..b282b68d50e 100644 --- a/cmd/mbr.c +++ b/cmd/mbr.c @@ -73,7 +73,7 @@ static bool found_key(const char *str, const char *key) strcopy = strdup(str); if (!strcopy) - return NULL; + return false; s = strcopy; while (s) { diff --git a/cmd/mtd.c b/cmd/mtd.c index 7f25144098b..ed827accfb5 100644 --- a/cmd/mtd.c +++ b/cmd/mtd.c @@ -470,10 +470,10 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { bool dump, read, raw, woob, benchmark, write_empty_pages, has_pages = false; - u64 start_off, off, len, remaining, default_len, speed; + u64 start_off, off, len, remaining, default_len, speed, user_addr = 0; unsigned long bench_start, bench_end; struct mtd_oob_ops io_op = {}; - uint user_addr = 0, npages; + uint npages; const char *cmd = argv[0]; struct mtd_info *mtd; u32 oob_len; diff --git a/cmd/net.c b/cmd/net.c index f6f556f36ae..0f0b2386d87 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -89,9 +89,9 @@ static int do_tftpsrv(struct cmd_tbl *cmdtp, int flag, int argc, U_BOOT_CMD( tftpsrv, 2, 1, do_tftpsrv, - "act as a TFTP server and boot the first received file", + "act as a TFTP server and receive the first file", "[loadAddress]\n" - "Listen for an incoming TFTP transfer, receive a file and boot it.\n" + "Listen for an incoming TFTP transfer and receive a file into memory.\n" "The transfer is aborted if a transfer has not been started after\n" "about 50 seconds or if Ctrl-C is pressed." ); diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 3a36f94775b..f38802e4f4d 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -448,13 +448,14 @@ int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; var_name = argv[0]; - if (default_guid) { - if (!strcmp(var_name, "db") || !strcmp(var_name, "dbx") || - !strcmp(var_name, "dbt")) - guid = efi_guid_image_security_database; - else - guid = efi_global_variable_guid; + var_name16 = efi_convert_string(var_name); + if (!var_name16) { + printf("## Out of memory\n"); + ret = CMD_RET_FAILURE; + goto out; } + if (default_guid) + guid = *efi_auth_var_get_guid(var_name16); if (verbose) { printf("GUID: %pUl (%pUs)\n", &guid, &guid); @@ -479,16 +480,8 @@ int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc, 16, 1, value, size, true); } - var_name16 = efi_convert_string(var_name); - if (!var_name16) { - printf("## Out of memory\n"); - ret = CMD_RET_FAILURE; - goto out; - } ret = efi_set_variable_int(var_name16, &guid, attributes, size, value, true); - free(var_name16); - unmap_sysmem(value); if (ret == EFI_SUCCESS) { ret = CMD_RET_SUCCESS; } else { @@ -518,6 +511,7 @@ int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc, ret = CMD_RET_FAILURE; } out: + free(var_name16); if (value_on_memory) unmap_sysmem(value); else diff --git a/cmd/pstore.c b/cmd/pstore.c index 9795eea2dbc..f2c0034abbe 100644 --- a/cmd/pstore.c +++ b/cmd/pstore.c @@ -413,8 +413,8 @@ static int pstore_save(struct cmd_tbl *cmdtp, int flag, int argc, sprintf(addr, "0x%08lx", (ulong)map_to_sysmem(buffer + header_len)); sprintf(length, "0x%X", size - header_len); - sprintf(path, "%s/dmesg-ramoops-%u%s", argv[3], index, - compressed ? ".enc.z" : ""); + snprintf(path, sizeof(path), "%s/dmesg-ramoops-%u%s", argv[3], + index, compressed ? ".enc.z" : ""); do_save(cmdtp, flag, 6, save_argv, FS_TYPE_ANY); index++; } @@ -426,7 +426,7 @@ static int pstore_save(struct cmd_tbl *cmdtp, int flag, int argc, buffer); if (size != 0) { sprintf(length, "0x%X", size); - sprintf(path, "%s/console-ramoops-0", argv[3]); + snprintf(path, sizeof(path), "%s/console-ramoops-0", argv[3]); do_save(cmdtp, flag, 6, save_argv, FS_TYPE_ANY); } ptr += pstore_console_size; @@ -438,7 +438,7 @@ static int pstore_save(struct cmd_tbl *cmdtp, int flag, int argc, size = pstore_get_buffer(0, ptr, pstore_ftrace_size, buffer); if (size != 0) { sprintf(length, "0x%X", size); - sprintf(path, "%s/ftrace-ramoops-0", argv[3]); + snprintf(path, sizeof(path), "%s/ftrace-ramoops-0", argv[3]); do_save(cmdtp, flag, 6, save_argv, FS_TYPE_ANY); } ptr += pstore_ftrace_size; @@ -448,7 +448,7 @@ static int pstore_save(struct cmd_tbl *cmdtp, int flag, int argc, buffer); if (size != 0) { sprintf(length, "0x%X", size); - sprintf(path, "%s/pmsg-ramoops-0", argv[3]); + snprintf(path, sizeof(path), "%s/pmsg-ramoops-0", argv[3]); do_save(cmdtp, flag, 6, save_argv, FS_TYPE_ANY); } diff --git a/cmd/read.c b/cmd/read.c index 8e21f004423..efc255ce85d 100644 --- a/cmd/read.c +++ b/cmd/read.c @@ -46,7 +46,7 @@ do_rw(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) limit = ~0; } - if (cnt + blk > limit) { + if (blk > limit || cnt > limit - blk) { printf("%s out of range\n", cmdtp->name); unmap_sysmem(ptr); return 1; diff --git a/cmd/scmi.c b/cmd/scmi.c index d0498b816aa..1aa20c7bd96 100644 --- a/cmd/scmi.c +++ b/cmd/scmi.c @@ -30,6 +30,9 @@ struct { {SCMI_PROTOCOL_ID_RESET_DOMAIN, "Reset domain management"}, {SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN, "Voltage domain management"}, {SCMI_PROTOCOL_ID_PINCTRL, "Pin control management"}, + {SCMI_PROTOCOL_ID_VENDOR_80, "Vendor specific (0x80)"}, + {SCMI_PROTOCOL_ID_VENDOR_81, "Vendor specific (0x81)"}, + {SCMI_PROTOCOL_ID_VENDOR_82, "Vendor specific (0x82)"}, }; /** diff --git a/cmd/scsi.c b/cmd/scsi.c index ad7d8a4b664..5e732c1e50a 100644 --- a/cmd/scsi.c +++ b/cmd/scsi.c @@ -45,7 +45,7 @@ static int do_scsi(struct cmd_tbl *cmdtp, int flag, int argc, U_BOOT_CMD( scsi, 5, 1, do_scsi, "SCSI sub-system", - "scsi info - show available SCSI devices\n" + "info - show available SCSI devices\n" "scsi scan - (re-)scan SCSI bus\n" "scsi device [dev] - show or set current device\n" "scsi part [dev] - print partition table of one or all SCSI devices\n" diff --git a/cmd/strings.c b/cmd/strings.c index beac2a6e6b3..3727c00341a 100644 --- a/cmd/strings.c +++ b/cmd/strings.c @@ -21,7 +21,7 @@ int do_strings(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if ((flag & CMD_FLAG_REPEAT) == 0) { start_addr = (char *)hextoul(argv[1], NULL); if (argc > 2) - last_addr = (char *)hextoul(argv[2], NULL); + last_addr = start_addr + hextoul(argv[2], NULL); else last_addr = (char *)-1; } diff --git a/cmd/ufetch.c b/cmd/ufetch.c index 763ab42c48a..d4b54f77b7b 100644 --- a/cmd/ufetch.c +++ b/cmd/ufetch.c @@ -60,7 +60,9 @@ enum output_lines { FIRST, SECOND, KERNEL, +#ifdef CONFIG_SYS_CONFIG_NAME SYSINFO, +#endif HOST, UPTIME, IP, @@ -125,9 +127,11 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc, case KERNEL: printf("Kernel:" RESET " %s\n", U_BOOT_VERSION); break; +#ifdef CONFIG_SYS_CONFIG_NAME case SYSINFO: printf("Config:" RESET " %s_defconfig\n", CONFIG_SYS_CONFIG_NAME); break; +#endif case HOST: model = ofnode_read_string(ofnode_root(), "model"); if (model) |
