diff options
| author | Tom Rini <[email protected]> | 2026-04-06 12:16:57 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-04-06 12:16:57 -0600 |
| commit | 93f84ee022a8401421cdaab84fe7d106d83fdb4a (patch) | |
| tree | fb15a4af876e8faf9893fd86c1c0e127265dbe9a /cmd | |
| parent | 88dc2788777babfd6322fa655df549a019aa1e69 (diff) | |
| parent | e2138cf1e6088f12ffa874e87cc8f4b198378635 (diff) | |
Merge branch 'next'
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/Kconfig | 21 | ||||
| -rw-r--r-- | cmd/Makefile | 1 | ||||
| -rw-r--r-- | cmd/bloblist.c | 3 | ||||
| -rw-r--r-- | cmd/bootefi.c | 3 | ||||
| -rw-r--r-- | cmd/bootm.c | 3 | ||||
| -rw-r--r-- | cmd/date.c | 3 | ||||
| -rw-r--r-- | cmd/efidebug.c | 49 | ||||
| -rw-r--r-- | cmd/ide.c | 4 | ||||
| -rw-r--r-- | cmd/legacy_led.c | 161 | ||||
| -rw-r--r-- | cmd/mem.c | 4 | ||||
| -rw-r--r-- | cmd/mmc.c | 4 | ||||
| -rw-r--r-- | cmd/part.c | 215 | ||||
| -rw-r--r-- | cmd/smbios.c | 365 | ||||
| -rw-r--r-- | cmd/sound.c | 3 | ||||
| -rw-r--r-- | cmd/spl.c | 3 | ||||
| -rw-r--r-- | cmd/test.c | 43 |
16 files changed, 680 insertions, 205 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig index 322ebe600c5..f47ce7f45ce 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -223,6 +223,7 @@ config CMD_LICENSE config CMD_PMC bool "pmc" + depends on ACPI_PMC help Provides access to the Intel Power-Management Controller (PMC) so that its state can be examined. This does not currently support @@ -298,6 +299,7 @@ config CMD_BOOTD config CMD_BOOTM bool "bootm" + depends on LMB default y select LIB_BOOTM help @@ -376,6 +378,7 @@ config BOOTM_ELF config CMD_BOOTZ bool "bootz" + depends on LMB select LIB_BOOTZ select LIB_BOOTM help @@ -384,6 +387,7 @@ config CMD_BOOTZ config CMD_BOOTI bool "booti" depends on ARM64 || RISCV || SANDBOX + depends on LMB default y select LIB_BOOTI select LIB_BOOTM @@ -1408,6 +1412,7 @@ config CMD_LOADM config CMD_LOADS bool "loads - Load a file over serial in S-Record format" + depends on LMB default y help Load an S-Record file over serial line @@ -1663,6 +1668,15 @@ config CMD_PART Read and display information about the partition table on various media. +config CMD_PART_DUPCHECK + bool "part dupcheck" + depends on CMD_PART && BLK + help + Adds the 'part dupcheck' subcommand, which scans all block devices + and reports any duplicate partition UUIDs (PARTUUIDs) or partition + labels (PARTLABELs). Returns failure if any duplicates are found, + making it suitable for use in boot scripts. + config CMD_PCI bool "pci - Access PCI devices" help @@ -1715,7 +1729,8 @@ config CMD_REMOTEPROC config CMD_SATA bool "sata - Access SATA subsystem" - select SATA + depends on SATA && AHCI + default y help SATA (Serial Advanced Technology Attachment) is a serial bus standard for connecting to hard drives and other storage devices. @@ -2186,6 +2201,7 @@ endif # if NET config CMD_DHCP bool "dhcp" select PROT_DHCP_LWIP if NET_LWIP + select CMD_BOOTP if NET help Boot image via network using DHCP/TFTP protocol @@ -2220,6 +2236,7 @@ config CMD_MDIO config CMD_NFS bool "nfs" + select PROT_UDP_LWIP if NET_LWIP help Boot image via network using NFS protocol. @@ -2304,7 +2321,7 @@ config WGET_BUILTIN_CACERT_PATH config CMD_PXE bool "pxe" select PXE_UTILS - imply CMD_TFTPBOOT + select CMD_TFTPBOOT help Boot image via network using PXE protocol diff --git a/cmd/Makefile b/cmd/Makefile index 4cd13d4fa6e..6b69da1f2b0 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -105,7 +105,6 @@ obj-$(CONFIG_CMD_IRQ) += irq.o obj-$(CONFIG_CMD_ITEST) += itest.o obj-$(CONFIG_CMD_JFFS2) += jffs2.o obj-$(CONFIG_CMD_CRAMFS) += cramfs.o -obj-$(CONFIG_LED_STATUS_CMD) += legacy_led.o obj-$(CONFIG_CMD_LED) += led.o obj-$(CONFIG_CMD_LICENSE) += license.o obj-y += load.o diff --git a/cmd/bloblist.c b/cmd/bloblist.c index 333ae558142..318a1af0220 100644 --- a/cmd/bloblist.c +++ b/cmd/bloblist.c @@ -8,9 +8,6 @@ #include <bloblist.h> #include <command.h> -#include <asm/global_data.h> - -DECLARE_GLOBAL_DATA_PTR; static int do_bloblist_info(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index b8f5bb35950..85f41c3b0a0 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -17,11 +17,8 @@ #include <mapmem.h> #include <vsprintf.h> #include <asm-generic/sections.h> -#include <asm/global_data.h> #include <linux/string.h> -DECLARE_GLOBAL_DATA_PTR; - static struct efi_device_path *test_image_path; static struct efi_device_path *test_device_path; diff --git a/cmd/bootm.c b/cmd/bootm.c index 2c5aea26d98..ca7cec91fad 100644 --- a/cmd/bootm.c +++ b/cmd/bootm.c @@ -15,14 +15,11 @@ #include <malloc.h> #include <nand.h> #include <asm/byteorder.h> -#include <asm/global_data.h> #include <linux/ctype.h> #include <linux/err.h> #include <u-boot/zlib.h> #include <mapmem.h> -DECLARE_GLOBAL_DATA_PTR; - #if defined(CONFIG_CMD_IMI) static int image_info(unsigned long addr); #endif diff --git a/cmd/date.c b/cmd/date.c index 8614f022761..d047872289c 100644 --- a/cmd/date.c +++ b/cmd/date.c @@ -11,9 +11,6 @@ #include <dm.h> #include <rtc.h> #include <i2c.h> -#include <asm/global_data.h> - -DECLARE_GLOBAL_DATA_PTR; static const char * const weekdays[] = { "Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 109496d9e95..7b733119c82 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -533,6 +533,47 @@ static int do_efi_show_defaults(struct cmd_tbl *cmdtp, int flag, return CMD_RET_SUCCESS; } +#if CONFIG_IS_ENABLED(EFI_ECPT) +/** + * do_efi_show_ecpt() - show UEFI conformance profiles in ECPT + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * Return: CMD_RET_SUCCESS on success, + * CMD_RET_USAGE or CMD_RET_FAILURE on failure + * + * Implement efidebug "ecpt" sub-command. + * Show all the UEFI Conformance Profiles listed in the EFI Conformance Profiles + * Table (ECPT). + */ +static int do_efi_show_ecpt(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + const struct efi_conformance_profiles_table *ecpt; + u16 n; + + if (argc != 1) + return CMD_RET_USAGE; + + ecpt = efi_get_configuration_table(&efi_ecpt_guid); + if (!ecpt) { + log_err("ECPT table missing\n"); + return CMD_RET_FAILURE; + } + + for (n = 0; n < ecpt->number_of_profiles; n++) { + const efi_guid_t *guid = &ecpt->conformance_profiles[n]; + + printf("%pUl %s\n", guid->b, + uuid_guid_get_str(guid->b) ?: "(unknown)"); + } + + return CMD_RET_SUCCESS; +} +#endif /* CONFIG_IS_ENABLED(EFI_ECPT) */ + static const char * const efi_mem_type_string[] = { [EFI_RESERVED_MEMORY_TYPE] = "RESERVED", [EFI_LOADER_CODE] = "LOADER CODE", @@ -1586,6 +1627,10 @@ static struct cmd_tbl cmd_efidebug_sub[] = { "", ""), U_BOOT_CMD_MKENT(defaults, CONFIG_SYS_MAXARGS, 1, do_efi_show_defaults, "", ""), +#if CONFIG_IS_ENABLED(EFI_ECPT) + U_BOOT_CMD_MKENT(ecpt, CONFIG_SYS_MAXARGS, 1, do_efi_show_ecpt, + "", ""), +#endif U_BOOT_CMD_MKENT(images, CONFIG_SYS_MAXARGS, 1, do_efi_show_images, "", ""), U_BOOT_CMD_MKENT(memmap, CONFIG_SYS_MAXARGS, 1, do_efi_show_memmap, @@ -1680,6 +1725,10 @@ U_BOOT_LONGHELP(efidebug, " - show UEFI handles\n" "efidebug defaults\n" " - show default EFI filename and PXE architecture\n" +#if CONFIG_IS_ENABLED(EFI_ECPT) + "efidebug ecpt\n" + " - show conformance profiles in the ECPT\n" +#endif "efidebug images\n" " - show loaded images\n" "efidebug memmap\n" diff --git a/cmd/ide.c b/cmd/ide.c index ed30f946866..f99fb6f5824 100644 --- a/cmd/ide.c +++ b/cmd/ide.c @@ -21,10 +21,6 @@ #include <ata.h> -#ifdef CONFIG_LED_STATUS -# include <status_led.h> -#endif - /* Current I/O Device */ static int curr_device; diff --git a/cmd/legacy_led.c b/cmd/legacy_led.c deleted file mode 100644 index 4e0d09522ad..00000000000 --- a/cmd/legacy_led.c +++ /dev/null @@ -1,161 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * (C) Copyright 2010 - * Jason Kridner <[email protected]> - * - * Based on cmd_led.c patch from: - * http://www.mail-archive.com/[email protected]/msg06873.html - * (C) Copyright 2008 - * Ulf Samuelsson <[email protected]> - */ - -#include <command.h> -#include <status_led.h> -#include <vsprintf.h> -#include <linux/string.h> - -struct led_tbl_s { - char *string; /* String for use in the command */ - led_id_t mask; /* Mask used for calling __led_set() */ - void (*off)(void); /* Optional function for turning LED off */ - void (*on)(void); /* Optional function for turning LED on */ - void (*toggle)(void);/* Optional function for toggling LED */ -}; - -typedef struct led_tbl_s led_tbl_t; - -static const led_tbl_t led_commands[] = { -#ifdef CONFIG_LED_STATUS_BOARD_SPECIFIC -#ifdef CONFIG_LED_STATUS0 - { "0", CONFIG_LED_STATUS_BIT, NULL, NULL, NULL }, -#endif -#ifdef CONFIG_LED_STATUS1 - { "1", CONFIG_LED_STATUS_BIT1, NULL, NULL, NULL }, -#endif -#ifdef CONFIG_LED_STATUS2 - { "2", CONFIG_LED_STATUS_BIT2, NULL, NULL, NULL }, -#endif -#ifdef CONFIG_LED_STATUS3 - { "3", CONFIG_LED_STATUS_BIT3, NULL, NULL, NULL }, -#endif -#ifdef CONFIG_LED_STATUS4 - { "4", CONFIG_LED_STATUS_BIT4, NULL, NULL, NULL }, -#endif -#ifdef CONFIG_LED_STATUS5 - { "5", CONFIG_LED_STATUS_BIT5, NULL, NULL, NULL }, -#endif -#endif - { NULL, 0, NULL, NULL, NULL } -}; - -enum led_cmd { LED_ON, LED_OFF, LED_TOGGLE, LED_BLINK }; - -enum led_cmd get_led_cmd(char *var) -{ - if (strcmp(var, "off") == 0) - return LED_OFF; - if (strcmp(var, "on") == 0) - return LED_ON; - if (strcmp(var, "toggle") == 0) - return LED_TOGGLE; - if (strcmp(var, "blink") == 0) - return LED_BLINK; - - return -1; -} - -/* - * LED drivers providing a blinking LED functionality, like the - * PCA9551, can override this empty weak function - */ -void __weak __led_blink(led_id_t mask, int freq) -{ -} - -int do_legacy_led(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - int i, match = 0; - enum led_cmd cmd; - int freq; - - /* Validate arguments */ - if ((argc < 3) || (argc > 4)) - return CMD_RET_USAGE; - - cmd = get_led_cmd(argv[2]); - if (cmd < 0) { - return CMD_RET_USAGE; - } - - for (i = 0; led_commands[i].string; i++) { - if ((strcmp("all", argv[1]) == 0) || - (strcmp(led_commands[i].string, argv[1]) == 0)) { - match = 1; - switch (cmd) { - case LED_ON: - if (led_commands[i].on) - led_commands[i].on(); - else - __led_set(led_commands[i].mask, - CONFIG_LED_STATUS_ON); - break; - case LED_OFF: - if (led_commands[i].off) - led_commands[i].off(); - else - __led_set(led_commands[i].mask, - CONFIG_LED_STATUS_OFF); - break; - case LED_TOGGLE: - if (led_commands[i].toggle) - led_commands[i].toggle(); - else - __led_toggle(led_commands[i].mask); - break; - case LED_BLINK: - if (argc != 4) - return CMD_RET_USAGE; - - freq = dectoul(argv[3], NULL); - __led_blink(led_commands[i].mask, freq); - } - /* Need to set only 1 led if led_name wasn't 'all' */ - if (strcmp("all", argv[1]) != 0) - break; - } - } - - /* If we ran out of matches, print Usage */ - if (!match) { - return CMD_RET_USAGE; - } - - return 0; -} - -U_BOOT_CMD( - led, 4, 1, do_legacy_led, - "[" -#ifdef CONFIG_LED_STATUS_BOARD_SPECIFIC -#ifdef CONFIG_LED_STATUS0 - "0|" -#endif -#ifdef CONFIG_LED_STATUS1 - "1|" -#endif -#ifdef CONFIG_LED_STATUS2 - "2|" -#endif -#ifdef CONFIG_LED_STATUS3 - "3|" -#endif -#ifdef CONFIG_LED_STATUS4 - "4|" -#endif -#ifdef CONFIG_LED_STATUS5 - "5|" -#endif -#endif - "all] [on|off|toggle|blink] [blink-freq in ms]", - "[led_name] [on|off|toggle|blink] sets or clears led(s)" -); diff --git a/cmd/mem.c b/cmd/mem.c index d5d7ca2790b..68eb6989b94 100644 --- a/cmd/mem.c +++ b/cmd/mem.c @@ -26,16 +26,14 @@ #include <mapmem.h> #include <rand.h> #include <time.h> +#include <vsprintf.h> #include <watchdog.h> -#include <asm/global_data.h> #include <asm/io.h> #include <linux/bitops.h> #include <linux/compiler.h> #include <linux/ctype.h> #include <linux/delay.h> -DECLARE_GLOBAL_DATA_PTR; - /* Create a compile-time value */ #if MEM_SUPPORT_64BIT_DATA #define HELP_Q ", .q" diff --git a/cmd/mmc.c b/cmd/mmc.c index 6cb1ef5dc23..81b1ca4ad84 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -29,12 +29,12 @@ static void print_mmcinfo(struct mmc *mmc) printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24); if (IS_SD(mmc)) { printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff); - printf("Name: %c%c%c%c%c \n", mmc->cid[0] & 0xff, + printf("Name: %c%c%c%c%c\n", mmc->cid[0] & 0xff, (mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff, (mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff); } else { printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xff); - printf("Name: %c%c%c%c%c%c \n", mmc->cid[0] & 0xff, + printf("Name: %c%c%c%c%c%c\n", mmc->cid[0] & 0xff, (mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff, (mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff, (mmc->cid[2] >> 24)); diff --git a/cmd/part.c b/cmd/part.c index 975a0a08a99..5e520d707f3 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -15,10 +15,15 @@ * Pavel Bartusek <[email protected]> */ -#include <config.h> +#include <alist.h> +#include <blk.h> #include <command.h> +#include <config.h> +#include <dm.h> #include <env.h> +#include <stddef.h> #include <part.h> +#include <sort.h> #include <stdio.h> #include <vsprintf.h> @@ -246,6 +251,205 @@ static int do_part_type(int argc, char *const argv[]) } #endif +#if CONFIG_IS_ENABLED(CMD_PART_DUPCHECK) +struct part_seen { + char uuid[UUID_STR_LEN + 1]; + char name[PART_NAME_LEN + 1]; + struct udevice *dev; + int part; +}; + +static int compare_uuid(const void *a, const void *b) +{ + const struct part_seen *pa = a; + const struct part_seen *pb = b; + + /* Sort empty UUIDs to the end */ + if (!pa->uuid[0] && !pb->uuid[0]) + return 0; + if (!pa->uuid[0]) + return 1; + if (!pb->uuid[0]) + return -1; + + return strcmp(pa->uuid, pb->uuid); +} + +static int compare_name(const void *a, const void *b) +{ + const struct part_seen *pa = a; + const struct part_seen *pb = b; + + /* Sort empty names to the end */ + if (!pa->name[0] && !pb->name[0]) + return 0; + if (!pa->name[0]) + return 1; + if (!pb->name[0]) + return -1; + + return strcmp(pa->name, pb->name); +} + +/** + * detect_duplicates() - Sort and detect duplicate fields in the partition list + * + * Sorts the seen list using the given comparator, then performs a single + * linear pass to find and report consecutive duplicate entries. + * + * @seen: The list of collected partition entries + * @cmp: Comparator function for qsort (must sort empties to the end) + * @field_label: Human-readable label for reporting (e.g. "PARTUUID", "PARTLABEL") + * @field_off: Offset of the string field within struct part_seen + * @dup_groups: Output: number of distinct duplicate values found + * @total: Total number of partitions that have this field set + */ +static void detect_duplicates(struct alist *seen, + int (*cmp)(const void *, const void *), + const char *field_label, size_t field_off, + int *dup_groups, int total) +{ + const struct part_seen *pi; + const struct part_seen *pj; + const char *field_i; + const char *field_j; + int occurrences; + int count = seen->count; + int dup_parts = 0; + + *dup_groups = 0; + + qsort(seen->data, count, sizeof(struct part_seen), cmp); + + for (int i = 0; i < count; i++) { + pi = alist_get(seen, i, struct part_seen); + field_i = (const char *)pi + field_off; + occurrences = 1; + + if (!field_i[0]) + break; /* Reached empty fields at the end */ + + /* Count consecutive duplicates */ + while (i + occurrences < count) { + pj = alist_get(seen, i + occurrences, struct part_seen); + field_j = (const char *)pj + field_off; + + if (strcmp(field_i, field_j) != 0) + break; + occurrences++; + } + + if (occurrences > 1) { + printf("Warning: duplicate %s %s (%d copies)\n", + field_label, field_i, occurrences); + for (int j = 0; j < occurrences; j++) { + pj = alist_get(seen, i + j, struct part_seen); + printf(" found on %s:%d\n", + pj->dev->name, + pj->part); + } + + (*dup_groups)++; + dup_parts += occurrences; + i += occurrences - 1; + } + } + + if (*dup_groups) + printf("Found %d duplicate %s(s) (%d total copies) among %d partitions\n", + *dup_groups, field_label, dup_parts, total); +} + +static int do_part_dupcheck(int argc, char *const argv[]) +{ + struct alist seen; + int uuid_count = 0; + int label_count = 0; + int duplicate_uuids = 0; + int duplicate_labels = 0; + struct udevice *dev; + + if (argc) + return CMD_RET_USAGE; + + if (!blk_count_devices(BLKF_BOTH)) { + printf("No block devices found\n"); + return CMD_RET_SUCCESS; + } + + alist_init_struct(&seen, struct part_seen); + + /* First pass: collect all partitions with UUIDs or labels */ + blk_foreach_probe(BLKF_BOTH, dev) { + struct blk_desc *desc = dev_get_uclass_plat(dev); + + for (int part = 1; part <= MAX_SEARCH_PARTITIONS; part++) { + struct disk_partition info; + struct part_seen entry; + bool has_uuid; + bool has_label; + + if (part_get_info(desc, part, &info)) + continue; + has_uuid = disk_partition_uuid(&info)[0] != '\0'; + has_label = info.name[0] != '\0'; + if (!has_uuid && !has_label) + continue; + + memset(&entry, 0, sizeof(entry)); + if (has_uuid) + strlcpy(entry.uuid, disk_partition_uuid(&info), + sizeof(entry.uuid)); + if (has_label) + strlcpy(entry.name, (const char *)info.name, + sizeof(entry.name)); + entry.dev = dev; + entry.part = part; + + if (has_uuid) + uuid_count++; + if (has_label) + label_count++; + + if (!alist_add(&seen, entry)) { + printf("Unable to grow dupcheck list\n"); + alist_uninit(&seen); + return CMD_RET_FAILURE; + } + } + } + + if (!seen.count) { + printf("No partitions with UUID or label found\n"); + alist_uninit(&seen); + return CMD_RET_SUCCESS; + } + + /* Detect duplicate UUIDs */ + detect_duplicates(&seen, compare_uuid, "PARTUUID", + offsetof(struct part_seen, uuid), + &duplicate_uuids, uuid_count); + + /* Detect duplicate partition labels */ + detect_duplicates(&seen, compare_name, "PARTLABEL", + offsetof(struct part_seen, name), + &duplicate_labels, label_count); + + if (!duplicate_uuids && !duplicate_labels) + printf("No duplicate PARTUUIDs or PARTLABELs found (%d UUIDs, %d labels)\n", + uuid_count, label_count); + else if (!duplicate_uuids) + printf("No duplicate PARTUUIDs found (%d UUIDs)\n", uuid_count); + else if (!duplicate_labels) + printf("No duplicate PARTLABELs found (%d labels)\n", label_count); + + alist_uninit(&seen); + + return (duplicate_uuids || duplicate_labels) ? + CMD_RET_FAILURE : CMD_RET_SUCCESS; +} +#endif + static int do_part_types(int argc, char * const argv[]) { struct part_driver *drv = ll_entry_start(struct part_driver, @@ -292,6 +496,10 @@ static int do_part(struct cmd_tbl *cmdtp, int flag, int argc, else if (!strcmp(argv[1], "type")) return do_part_type(argc - 2, argv + 2); #endif +#if CONFIG_IS_ENABLED(CMD_PART_DUPCHECK) + else if (!strcmp(argv[1], "dupcheck")) + return do_part_dupcheck(argc - 2, argv + 2); +#endif return CMD_RET_USAGE; } @@ -329,4 +537,9 @@ U_BOOT_CMD( " - set partition type for a device\n" "part types\n" " - list supported partition table types" +#if CONFIG_IS_ENABLED(CMD_PART_DUPCHECK) + "\n" + "part dupcheck\n" + " - scan all block devices for duplicate partition UUIDs and labels" +#endif ); diff --git a/cmd/smbios.c b/cmd/smbios.c index ed419f19028..3fafa46d0a5 100644 --- a/cmd/smbios.c +++ b/cmd/smbios.c @@ -119,6 +119,149 @@ static const struct str_lookup_table associativity_strings[] = { }; +static const struct str_lookup_table slot_type_strings[] = { + { SMBIOS_SYSSLOT_TYPE_OTHER, "Other" }, + { SMBIOS_SYSSLOT_TYPE_UNKNOWN, "Unknown" }, + { SMBIOS_SYSSLOT_TYPE_ISA, "ISA" }, + { SMBIOS_SYSSLOT_TYPE_PCI, "PCI" }, + { SMBIOS_SYSSLOT_TYPE_PCMCIA, "PC Card (PCMCIA)" }, + { SMBIOS_SYSSLOT_TYPE_PCIE, "PCI Express" }, + { SMBIOS_SYSSLOT_TYPE_PCIEGEN2, "PCI Express Gen 2" }, + { SMBIOS_SYSSLOT_TYPE_PCIEGEN3, "PCI Express Gen 3" }, + { SMBIOS_SYSSLOT_TYPE_PCIEGEN3X16, "PCI Express Gen 3 x16" }, + { SMBIOS_SYSSLOT_TYPE_PCIEGEN4, "PCI Express Gen 4" }, + { SMBIOS_SYSSLOT_TYPE_PCIEGEN4X8, "PCI Express Gen 4 x8" }, + { SMBIOS_SYSSLOT_TYPE_PCIEGEN4X16, "PCI Express Gen 4 x16" }, +}; + +static const struct str_lookup_table slot_bus_width_strings[] = { + { SMBIOS_SYSSLOT_WIDTH_OTHER, "Other" }, + { SMBIOS_SYSSLOT_WIDTH_UNKNOWN, "Unknown" }, + { SMBIOS_SYSSLOT_WIDTH_8BIT, "8 bit" }, + { SMBIOS_SYSSLOT_WIDTH_16BIT, "16 bit" }, + { SMBIOS_SYSSLOT_WIDTH_32BIT, "32 bit" }, + { SMBIOS_SYSSLOT_WIDTH_64BIT, "64 bit" }, + { SMBIOS_SYSSLOT_WIDTH_128BIT, "128 bit " }, + { SMBIOS_SYSSLOT_WIDTH_1X, "1x or x1" }, + { SMBIOS_SYSSLOT_WIDTH_2X, "2x or x2" }, + { SMBIOS_SYSSLOT_WIDTH_4X, "4x or x4" }, + { SMBIOS_SYSSLOT_WIDTH_8X, "8x or x8" }, + { SMBIOS_SYSSLOT_WIDTH_12X, "12x or x12" }, + { SMBIOS_SYSSLOT_WIDTH_16X, "16x or x16" }, + { SMBIOS_SYSSLOT_WIDTH_32X, "32x or x32" }, +}; + +static const struct str_lookup_table slot_usage_strings[] = { + { SMBIOS_SYSSLOT_USAGE_OTHER, "Other" }, + { SMBIOS_SYSSLOT_USAGE_UNKNOWN, "Unknown" }, + { SMBIOS_SYSSLOT_USAGE_AVAILABLE, "Available" }, + { SMBIOS_SYSSLOT_USAGE_INUSE, "In use" }, + { SMBIOS_SYSSLOT_USAGE_NA, "Unavailable" }, +}; + +static const struct str_lookup_table slot_length_strings[] = { + { SMBIOS_SYSSLOT_LENG_OTHER, "Other" }, + { SMBIOS_SYSSLOT_LENG_UNKNOWN, "Unknown" }, + { SMBIOS_SYSSLOT_LENG_SHORT, "Short Length" }, + { SMBIOS_SYSSLOT_LENG_LONG, "Long Length" }, + { SMBIOS_SYSSLOT_LENG_2_5INDRV, "2.5 inch drive form factor" }, + { SMBIOS_SYSSLOT_LENG_3_5INDRV, "3.5 inch drive form factor" }, +}; + +static const struct str_lookup_table ma_location_strings[] = { + { SMBIOS_MA_LOCATION_OTHER, "Other" }, + { SMBIOS_MA_LOCATION_UNKNOWN, "Unknown" }, + { SMBIOS_MA_LOCATION_MOTHERBOARD, "System board or motherboard" }, +}; + +static const struct str_lookup_table ma_use_strings[] = { + { SMBIOS_MA_USE_OTHER, "Other" }, + { SMBIOS_MA_USE_UNKNOWN, "Unknown" }, + { SMBIOS_MA_USE_SYSTEM, "System memory" }, + { SMBIOS_MA_USE_VIDEO, "Video memory" }, + { SMBIOS_MA_USE_FLASH, "Flash memory" }, + { SMBIOS_MA_USE_NVRAM, "Non-volatile RAM" }, + { SMBIOS_MA_USE_CACHE, "Cache memory" }, +}; + +static const struct str_lookup_table ma_err_corr_strings[] = { + { SMBIOS_MA_ERRCORR_OTHER, "Other" }, + { SMBIOS_MA_ERRCORR_UNKNOWN, "Unknown" }, + { SMBIOS_MA_ERRCORR_NONE, "None" }, + { SMBIOS_MA_ERRCORR_PARITY, "Parity" }, + { SMBIOS_MA_ERRCORR_SBITECC, "Single-bit ECC" }, + { SMBIOS_MA_ERRCORR_MBITECC, "Multi-bit ECC" }, + { SMBIOS_MA_ERRCORR_CRC, "CRC" }, +}; + +static const struct str_lookup_table md_form_factor_strings[] = { + { SMBIOS_MD_FF_OTHER, "Other" }, + { SMBIOS_MD_FF_UNKNOWN, "Unknown" }, + { SMBIOS_MD_FF_SIMM, "SIMM" }, + { SMBIOS_MD_FF_SIP, "SIP" }, + { SMBIOS_MD_FF_CHIP, "Chip" }, + { SMBIOS_MD_FF_DIP, "DIP" }, + { SMBIOS_MD_FF_ZIP, "ZIP" }, + { SMBIOS_MD_FF_PROPCARD, "Proprietary Card" }, + { SMBIOS_MD_FF_DIMM, "DIMM" }, + { SMBIOS_MD_FF_TSOP, "TSOP" }, + { SMBIOS_MD_FF_ROC, "Row of chips" }, + { SMBIOS_MD_FF_RIMM, "RIMM" }, + { SMBIOS_MD_FF_SODIMM, "SODIMM" }, + { SMBIOS_MD_FF_SRIMM, "SRIMM" }, + { SMBIOS_MD_FF_FBDIMM, "FB-DIMM" }, + { SMBIOS_MD_FF_DIE, "Die" }, +}; + +static const struct str_lookup_table md_type_strings[] = { + { SMBIOS_MD_TYPE_OTHER, "Other" }, + { SMBIOS_MD_TYPE_UNKNOWN, "Unknown" }, + { SMBIOS_MD_TYPE_DRAM, "DRAM" }, + { SMBIOS_MD_TYPE_EDRAM, "EDRAM" }, + { SMBIOS_MD_TYPE_VRAM, "VRAM" }, + { SMBIOS_MD_TYPE_SRAM, "SRAM" }, + { SMBIOS_MD_TYPE_RAM, "RAM" }, + { SMBIOS_MD_TYPE_ROM, "ROM" }, + { SMBIOS_MD_TYPE_FLASH, "FLASH" }, + { SMBIOS_MD_TYPE_EEPROM, "EEPROM" }, + { SMBIOS_MD_TYPE_FEPROM, "FEPROM" }, + { SMBIOS_MD_TYPE_EPROM, "EPROM" }, + { SMBIOS_MD_TYPE_CDRAM, "CDRAM" }, + { SMBIOS_MD_TYPE_3DRAM, "3DRAM" }, + { SMBIOS_MD_TYPE_SDRAM, "SDRAM" }, + { SMBIOS_MD_TYPE_SGRAM, "SGRAM" }, + { SMBIOS_MD_TYPE_RDRAM, "RDRAM" }, + { SMBIOS_MD_TYPE_DDR, "DDR" }, + { SMBIOS_MD_TYPE_DDR2, "DDR2" }, + { SMBIOS_MD_TYPE_DDR2FBD, "DDR2 FB-DIMM" }, + { SMBIOS_MD_TYPE_RSVD1, "Reserved" }, + { SMBIOS_MD_TYPE_RSVD2, "Reserved" }, + { SMBIOS_MD_TYPE_DSVD3, "Reserved" }, + { SMBIOS_MD_TYPE_DDR3, "DDR3" }, + { SMBIOS_MD_TYPE_FBD2, "FBD2" }, + { SMBIOS_MD_TYPE_DDR4, "DDR4" }, + { SMBIOS_MD_TYPE_LPDDR, "LPDDR" }, + { SMBIOS_MD_TYPE_LPDDR2, "LPDDR2" }, + { SMBIOS_MD_TYPE_LPDDR3, "LPDDR3" }, + { SMBIOS_MD_TYPE_LPDDR4, "LPDDR4" }, + { SMBIOS_MD_TYPE_LNVD, "Logical non-volatile device" }, + { SMBIOS_MD_TYPE_HBM, "HBM" }, + { SMBIOS_MD_TYPE_HBM2, "HBM2" }, + { SMBIOS_MD_TYPE_DDR5, "DDR5" }, + { SMBIOS_MD_TYPE_LPDDR5, "LPDDR5" }, + { SMBIOS_MD_TYPE_HBM3, "HBM3" }, +}; + +static const struct str_lookup_table md_tech_strings[] = { + { SMBIOS_MD_TECH_OTHER, "Other" }, + { SMBIOS_MD_TECH_UNKNOWN, "Unknown" }, + { SMBIOS_MD_TECH_DRAM, "DRAM" }, + { SMBIOS_MD_TECH_NVDIMMN, "NVDIMM-N" }, + { SMBIOS_MD_TECH_NVDIMMF, "NVDIMM-F" }, + { SMBIOS_MD_TECH_NVDIMMP, "NVDIMM-P" }, + { SMBIOS_MD_TECH_OPTANE, "Intel Optane persistent memory" }, +}; + /** * smbios_get_string() - get SMBIOS string from table * @@ -205,6 +348,8 @@ static void smbios_print_type0(struct smbios_type0 *table) printf("\tBIOS ROM Size: 0x%02x\n", table->bios_rom_size); printf("\tBIOS Characteristics: 0x%016llx\n", table->bios_characteristics); + if (table->hdr.length < SMBIOS_TYPE0_LENGTH_V24) + return; printf("\tBIOS Characteristics Extension Byte 1: 0x%02x\n", table->bios_characteristics_ext1); printf("\tBIOS Characteristics Extension Byte 2: 0x%02x\n", @@ -217,6 +362,8 @@ static void smbios_print_type0(struct smbios_type0 *table) table->ec_major_release); printf("\tEmbedded Controller Firmware Minor Release: 0x%02x\n", table->ec_minor_release); + if (table->hdr.length < SMBIOS_TYPE0_LENGTH_V31) + return; printf("\tExtended BIOS ROM Size: 0x%04x\n", table->extended_bios_rom_size); } @@ -228,17 +375,16 @@ static void smbios_print_type1(struct smbios_type1 *table) smbios_print_str("Product Name", table, table->product_name); smbios_print_str("Version", table, table->version); smbios_print_str("Serial Number", table, table->serial_number); - if (table->hdr.length >= SMBIOS_TYPE1_LENGTH_V21) { - printf("\tUUID: %pUl\n", table->uuid); - smbios_print_lookup_str(wakeup_type_strings, - table->wakeup_type, - ARRAY_SIZE(wakeup_type_strings), - "Wake-up Type"); - } - if (table->hdr.length >= SMBIOS_TYPE1_LENGTH_V24) { - smbios_print_str("SKU Number", table, table->sku_number); - smbios_print_str("Family", table, table->family); - } + if (table->hdr.length < SMBIOS_TYPE1_LENGTH_V21) + return; + printf("\tUUID: %pUl\n", table->uuid); + smbios_print_lookup_str(wakeup_type_strings, table->wakeup_type, + ARRAY_SIZE(wakeup_type_strings), + "Wake-up Type"); + if (table->hdr.length < SMBIOS_TYPE1_LENGTH_V24) + return; + smbios_print_str("SKU Number", table, table->sku_number); + smbios_print_str("Family", table, table->family); } static void smbios_print_type2(struct smbios_type2 *table) @@ -358,21 +504,31 @@ static void smbios_print_type4(struct smbios_type4 *table) printf("\tL1 Cache Handle: 0x%04x\n", table->l1_cache_handle); printf("\tL2 Cache Handle: 0x%04x\n", table->l2_cache_handle); printf("\tL3 Cache Handle: 0x%04x\n", table->l3_cache_handle); + if (table->hdr.length < SMBIOS_TYPE4_LENGTH_V23) + return; smbios_print_str("Serial Number", table, table->serial_number); smbios_print_str("Asset Tag", table, table->asset_tag); smbios_print_str("Part Number", table, table->part_number); + if (table->hdr.length < SMBIOS_TYPE4_LENGTH_V25) + return; printf("\tCore Count: 0x%02x\n", table->core_count); printf("\tCore Enabled: 0x%02x\n", table->core_enabled); printf("\tThread Count: 0x%02x\n", table->thread_count); printf("\tProcessor Characteristics: 0x%04x\n", table->processor_characteristics); + if (table->hdr.length < SMBIOS_TYPE4_LENGTH_V26) + return; smbios_print_lookup_str(processor_family_strings, table->processor_family2, ARRAY_SIZE(processor_family_strings), "Processor Family 2"); + if (table->hdr.length < SMBIOS_TYPE4_LENGTH_V30) + return; printf("\tCore Count 2: 0x%04x\n", table->core_count2); printf("\tCore Enabled 2: 0x%04x\n", table->core_enabled2); printf("\tThread Count 2: 0x%04x\n", table->thread_count2); + if (table->hdr.length < SMBIOS_TYPE4_LENGTH_V36) + return; printf("\tThread Enabled: 0x%04x\n", table->thread_enabled); } @@ -386,6 +542,8 @@ static void smbios_print_type7(struct smbios_type7 *table) printf("\tInstalled Size: 0x%04x\n", table->inst_size.data); printf("\tSupported SRAM Type: 0x%04x\n", table->supp_sram_type.data); printf("\tCurrent SRAM Type: 0x%04x\n", table->curr_sram_type.data); + if (table->hdr.length < SMBIOS_TYPE7_LENGTH_V21) + return; printf("\tCache Speed: 0x%02x\n", table->speed); smbios_print_lookup_str(err_corr_type_strings, table->err_corr_type, @@ -399,10 +557,183 @@ static void smbios_print_type7(struct smbios_type7 *table) table->associativity, ARRAY_SIZE(associativity_strings), "Associativity"); + if (table->hdr.length < SMBIOS_TYPE7_LENGTH_V31) + return; printf("\tMaximum Cache Size 2: 0x%08x\n", table->max_size2.data); printf("\tInstalled Cache Size 2: 0x%08x\n", table->inst_size2.data); } +static void smbios_print_type9(struct smbios_type9 *table) +{ + int i; + u8 *addr = (u8 *)table + + offsetof(struct smbios_type9, slot_information); + + printf("System Slots:\n"); + smbios_print_str("Socket Designation", table, + table->socket_design); + smbios_print_lookup_str(slot_type_strings, + table->slot_type, + ARRAY_SIZE(slot_type_strings), + "Slot Type"); + smbios_print_lookup_str(slot_bus_width_strings, + table->slot_data_bus_width, + ARRAY_SIZE(slot_bus_width_strings), + "Slot Data Bus Width"); + smbios_print_lookup_str(slot_usage_strings, + table->current_usage, + ARRAY_SIZE(slot_usage_strings), + "Current Usage"); + smbios_print_lookup_str(slot_length_strings, + table->slot_length, + ARRAY_SIZE(slot_length_strings), + "Slot Length"); + printf("\tSlot ID: 0x%04x\n", table->slot_id); + printf("\tSlot Characteristics 1: 0x%04x\n", + table->slot_characteristics_1); + if (table->hdr.length < SMBIOS_TYPE9_LENGTH_V21) + return; + printf("\tSlot Characteristics 2: 0x%04x\n", + table->slot_characteristics_2); + if (table->hdr.length < SMBIOS_TYPE9_LENGTH_V26) + return; + printf("\tSegment Group Number (Base): 0x%04x\n", + table->segment_group_number); + printf("\tBus Number (Base): 0x%04x\n", table->bus_number); + printf("\tDevice/Function Number (Base): 0x%04x\n", + table->device_function_number.data); + printf("\tData Bus Width (Base): 0x%04x\n", + table->electrical_bus_width); + printf("\tPeer (S/B/D/F/Width) grouping count: 0x%04x\n", + table->peer_grouping_count); + printf("\tPeer (S/B/D/F/Width) groups:\n"); + for (i = 0; i < table->peer_grouping_count; i++) { + printf("\t\tPeer group[%03d]:\n", i); + if (CONFIG_IS_ENABLED(HEXDUMP)) + print_hex_dump("\t\t", DUMP_PREFIX_OFFSET, 16, 1, addr, + SMBIOS_TYPE9_PGROUP_SIZE, false); + addr += SMBIOS_TYPE9_PGROUP_SIZE; + } + printf("\n"); + + /* table->slot_information */ + printf("\tSlot Information: 0x%04x\n", *addr); + /* table->slot_physical_width */ + addr += sizeof(table->slot_information); + printf("\tSlot Physical Width: 0x%04x\n", *addr); + /* table->slot_pitch */ + addr += sizeof(table->slot_physical_width); + printf("\tSlot Pitch: 0x%04x\n", *(u16 *)addr); + /* table->slot_height */ + addr += sizeof(table->slot_pitch); + printf("\tSlot Height: 0x%04x\n", *addr); +} + +static void smbios_print_type16(struct smbios_type16 *table) +{ + printf("Physical Memory Array:\n"); + if (table->hdr.length < SMBIOS_TYPE16_LENGTH_V21) + return; + smbios_print_lookup_str(ma_location_strings, table->location, + ARRAY_SIZE(ma_location_strings), "Location"); + smbios_print_lookup_str(ma_use_strings, table->use, + ARRAY_SIZE(ma_use_strings), "Use"); + smbios_print_lookup_str(ma_err_corr_strings, table->mem_err_corr, + ARRAY_SIZE(ma_err_corr_strings), + "Memory Error Correction"); + printf("\tMaximum Capacity: 0x%08x\n", table->max_cap); + printf("\tMemory Error Information Handle: 0x%04x\n", + table->mem_err_info_hdl); + printf("\tNumber of Memory Devices: 0x%04x\n", table->num_of_mem_dev); + if (table->hdr.length < SMBIOS_TYPE16_LENGTH_V27) + return; + printf("\tExtended Maximum Capacity: 0x%016llx\n", table->ext_max_cap); +} + +static void smbios_print_type17(struct smbios_type17 *table) +{ + printf("Memory Device:\n"); + if (table->hdr.length < SMBIOS_TYPE17_LENGTH_V21) + return; + printf("\tPhysical Memory Array Handle: 0x%04x\n", + table->phy_mem_array_hdl); + printf("\tMemory Error Information Handle: 0x%04x\n", + table->mem_err_info_hdl); + printf("\tTotal Width: 0x%04x\n", table->total_width); + printf("\tData Width: 0x%04x\n", table->data_width); + printf("\tSize: 0x%04x\n", table->size); + smbios_print_lookup_str(md_form_factor_strings, table->form_factor, + ARRAY_SIZE(md_form_factor_strings), + "Form Factor"); + printf("\tDevice Set: 0x%04x\n", table->dev_set); + smbios_print_str("Device Locator", table, table->dev_locator); + smbios_print_str("Bank Locator", table, table->bank_locator); + smbios_print_lookup_str(md_type_strings, table->mem_type, + ARRAY_SIZE(md_type_strings), "Memory Type"); + printf("\tType Detail: 0x%04x\n", table->type_detail); + if (table->hdr.length < SMBIOS_TYPE17_LENGTH_V23) + return; + printf("\tSpeed: 0x%04x\n", table->speed); + smbios_print_str("Manufacturer", table, table->manufacturer); + smbios_print_str("Serial Number", table, table->serial_number); + smbios_print_str("Asset Tag", table, table->asset_tag); + smbios_print_str("Part Number", table, table->part_number); + if (table->hdr.length < SMBIOS_TYPE17_LENGTH_V26) + return; + printf("\tAttributes: 0x%04x\n", table->attributes); + if (table->hdr.length < SMBIOS_TYPE17_LENGTH_V27) + return; + printf("\tExtended Size: 0x%08x\n", table->ext_size); + printf("\tConfigured Memory Speed: 0x%04x\n", table->config_mem_speed); + if (table->hdr.length < SMBIOS_TYPE17_LENGTH_V28) + return; + printf("\tMinimum voltage: 0x%04x\n", table->min_voltage); + printf("\tMaximum voltage: 0x%04x\n", table->max_voltage); + printf("\tConfigured voltage: 0x%04x\n", table->config_voltage); + if (table->hdr.length < SMBIOS_TYPE17_LENGTH_V32) + return; + smbios_print_lookup_str(md_tech_strings, table->mem_tech, + ARRAY_SIZE(md_tech_strings), + "Memory Technology"); + printf("\tMemory Operating Mode Capability: 0x%04x\n", + table->mem_op_mode_cap); + smbios_print_str("Firmware Version", table, table->fw_ver); + printf("\tModule Manufacturer ID: 0x%04x\n", table->module_man_id); + printf("\tModule Product ID: 0x%04x\n", table->module_prod_id); + printf("\tMemory Subsystem Controller Manufacturer ID: 0x%04x\n", + table->mem_subsys_con_man_id); + printf("\tMemory Subsystem Controller Product ID: 0x%04x\n", + table->mem_subsys_con_prod_id); + printf("\tNon-volatile Size: 0x%016llx\n", table->nonvolatile_size); + printf("\tVolatile Size: 0x%016llx\n", table->volatile_size); + printf("\tCache Size: 0x%016llx\n", table->cache_size); + printf("\tLogical Size: 0x%016llx\n", table->logical_size); + if (table->hdr.length < SMBIOS_TYPE17_LENGTH_V33) + return; + printf("\tExtended Speed: 0x%04x\n", table->ext_speed); + printf("\tExtended Configured Memory Speed: 0x%04x\n", + table->ext_config_mem_speed); + printf("\tPMIC0 Manufacturer ID: 0x%04x\n", table->pmic0_man_id); + printf("\tPMIC0 Revision Number: 0x%04x\n", table->pmic0_rev_num); + printf("\tRCD Manufacturer ID: 0x%04x\n", table->rcd_man_id); + printf("\tRCD Revision Number: 0x%04x\n", table->rcd_rev_num); +} + +static void smbios_print_type19(struct smbios_type19 *table) +{ + printf("Memory Array Mapped Address:\n"); + if (table->hdr.length < SMBIOS_TYPE19_LENGTH_V21) + return; + printf("\tStarting Address: 0x%08x\n", table->start_addr); + printf("\tEnding Address: 0x%08x\n", table->end_addr); + printf("\tMemory Array Handle: 0x%04x\n", table->mem_array_hdl); + printf("\tPartition Width: 0x%04x\n", table->partition_wid); + if (table->hdr.length < SMBIOS_TYPE19_LENGTH_V27) + return; + printf("\tExtended Starting Address: 0x%016llx\n", table->ext_start_addr); + printf("\tExtended Ending Address: 0x%016llx\n", table->ext_end_addr); +} + static void smbios_print_type127(struct smbios_type127 *table) { printf("End Of Table\n"); @@ -482,6 +813,18 @@ static int do_smbios(struct cmd_tbl *cmdtp, int flag, int argc, case SMBIOS_CACHE_INFORMATION: smbios_print_type7((struct smbios_type7 *)pos); break; + case SMBIOS_SYSTEM_SLOTS: + smbios_print_type9((struct smbios_type9 *)pos); + break; + case SMBIOS_PHYS_MEMORY_ARRAY: + smbios_print_type16((struct smbios_type16 *)pos); + break; + case SMBIOS_MEMORY_DEVICE: + smbios_print_type17((struct smbios_type17 *)pos); + break; + case SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS: + smbios_print_type19((struct smbios_type19 *)pos); + break; case SMBIOS_END_OF_TABLE: smbios_print_type127((struct smbios_type127 *)pos); break; diff --git a/cmd/sound.c b/cmd/sound.c index 8f67cbd96e1..7546059022f 100644 --- a/cmd/sound.c +++ b/cmd/sound.c @@ -8,9 +8,6 @@ #include <dm.h> #include <fdtdec.h> #include <sound.h> -#include <asm/global_data.h> - -DECLARE_GLOBAL_DATA_PTR; /* Initilaise sound subsystem */ static int do_init(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/cmd/spl.c b/cmd/spl.c index f591dc07fb6..ddbbd4a8172 100644 --- a/cmd/spl.c +++ b/cmd/spl.c @@ -9,11 +9,8 @@ #include <env.h> #include <image.h> #include <log.h> -#include <asm/global_data.h> #include <linux/libfdt.h> -DECLARE_GLOBAL_DATA_PTR; - static const char **subcmd_list[] = { [SPL_EXPORT_FDT] = (const char * []) { diff --git a/cmd/test.c b/cmd/test.c index a9ac07e6143..c76ebf800ee 100644 --- a/cmd/test.c +++ b/cmd/test.c @@ -63,10 +63,38 @@ static int do_test(struct cmd_tbl *cmdtp, int flag, int argc, char * const *ap; int i, op, left, adv, expr, last_expr, last_unop, last_binop; - /* args? */ - if (argc < 3) + if (!strcmp(argv[0], "[")) { + if (strcmp(argv[argc - 1], "]")) { + printf("[: missing terminating ]\n"); + return 1; + } + argc--; + } + + /* + * Per POSIX, 'test' with 0 arguments should return 1, while + * 'test <arg>' should be equivalent to 'test -n <arg>', + * i.e. true if and only if <arg> is not empty. + * + * However, due to previous versions of U-Boot unconditionally + * returning false when 'test' was given less than two + * arguments, there are existing scripts that do + * + * test -n $somevar + * + * (i.e. without properly quoting $somevar) and expecting that + * to return false when $somevar expands to nothing. It is + * quite unlikely that anyone would use the single-argument + * form to test a string for being empty and a possible + * non-empty value for that string to be exactly "-n". So we + * interpret 'test -n' as if it was 'test -n ""'. + */ + if (argc < 2) return 1; + if (argc == 2) + return !strcmp(argv[1], "") || !strcmp(argv[1], "-n"); + #ifdef DEBUG { debug("test(%d):", argc); @@ -212,6 +240,17 @@ U_BOOT_CMD( "[args..]" ); +/* + * This does not use the U_BOOT_CMD macro as [ can't be used in symbol names + */ +ll_entry_declare(struct cmd_tbl, lbracket, cmd) = { + "[", CONFIG_SYS_MAXARGS, cmd_always_repeatable, do_test, + "alias for 'test'", +#ifdef CONFIG_SYS_LONGHELP + " <test expression> ]" +#endif /* CONFIG_SYS_LONGHELP */ +}; + static int do_false(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { |
