diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/Kconfig | 213 | ||||
-rw-r--r-- | cmd/Makefile | 15 | ||||
-rw-r--r-- | cmd/ab_select.c | 66 | ||||
-rw-r--r-- | cmd/bcb.c | 221 | ||||
-rw-r--r-- | cmd/bdinfo.c | 5 | ||||
-rw-r--r-- | cmd/booti.c | 2 | ||||
-rw-r--r-- | cmd/bootmeth.c | 25 | ||||
-rw-r--r-- | cmd/clk.c | 14 | ||||
-rw-r--r-- | cmd/efidebug.c | 4 | ||||
-rw-r--r-- | cmd/elf.c | 8 | ||||
-rw-r--r-- | cmd/fat.c | 2 | ||||
-rw-r--r-- | cmd/font.c | 17 | ||||
-rw-r--r-- | cmd/irq.c | 3 | ||||
-rw-r--r-- | cmd/mem.c | 19 | ||||
-rw-r--r-- | cmd/meminfo.c | 99 | ||||
-rw-r--r-- | cmd/mtd.c | 9 | ||||
-rw-r--r-- | cmd/net-common.c | 109 | ||||
-rw-r--r-- | cmd/net-lwip.c | 45 | ||||
-rw-r--r-- | cmd/net.c | 115 | ||||
-rw-r--r-- | cmd/nvedit.c | 20 | ||||
-rw-r--r-- | cmd/pxe.c | 4 | ||||
-rw-r--r-- | cmd/riscv/sbi.c | 4 | ||||
-rw-r--r-- | cmd/sf.c | 8 | ||||
-rw-r--r-- | cmd/sysboot.c | 2 | ||||
-rw-r--r-- | cmd/tcpm.c | 136 | ||||
-rw-r--r-- | cmd/ubi.c | 13 | ||||
-rw-r--r-- | cmd/upl.c | 2 | ||||
-rw-r--r-- | cmd/x86/Makefile | 2 | ||||
-rw-r--r-- | cmd/x86/cpuid.c | 37 | ||||
-rw-r--r-- | cmd/x86/msr.c | 52 |
30 files changed, 820 insertions, 451 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig index 4ccb0cef390..4fba9fe6703 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -221,6 +221,13 @@ config CMD_REGINFO help Register dump +config CMD_TCPM + bool "tcpm" + depends on TYPEC_TCPM + help + Show voltage and current negotiated via USB PD as well as the + current state of the Type C Port Manager (TCPM) state machine. + config CMD_TLV_EEPROM bool "tlv_eeprom" depends on I2C_EEPROM @@ -438,21 +445,9 @@ config CMD_BOOTEFI_BOOTMGR This subcommand will allow you to select the UEFI binary to be booted via UEFI variables Boot####, BootOrder, and BootNext. -config CMD_BOOTEFI_HELLO_COMPILE - bool "Compile a standard EFI hello world binary for testing" - default y - help - This compiles a standard EFI hello world application with U-Boot so - that it can be used with the test/py testing framework. This is useful - for testing that EFI is working at a basic level, and for bringing - up EFI support on a new architecture. - - No additional space will be required in the resulting U-Boot binary - when this option is enabled. - config CMD_BOOTEFI_HELLO bool "Allow booting a standard EFI hello world for testing" - depends on CMD_BOOTEFI_BINARY && CMD_BOOTEFI_HELLO_COMPILE + depends on CMD_BOOTEFI_BINARY && BOOTEFI_HELLO_COMPILE default y if CMD_BOOTEFI_SELFTEST help This adds a standard EFI hello world application to U-Boot so that @@ -498,11 +493,18 @@ config CMD_CEDIT loading and saving of configuration as well as showing an editor. config CMD_ELF - bool "bootelf, bootvx" + bool "bootelf" default y select LIB_ELF help - Boot an ELF/vxWorks image from the memory. + Boot an ELF image from memory. + +config CMD_ELF_BOOTVX + bool "bootvx" + default y + depends on CMD_ELF + help + Boot a vxWorks image from memory config CMD_ELF_FDT_SETUP bool "Flattened Device Tree setup in bootelf cmd" @@ -883,9 +885,21 @@ config MD5SUM_VERIFY config CMD_MEMINFO bool "meminfo" + default y if SANDBOX help Display memory information. +config CMD_MEMINFO_MAP + bool "- with memory map" + depends on CMD_MEMINFO + default y if SANDBOX + help + Shows a memory map, in addition to just the DRAM size. This allows + seeing where U-Boot's memory area is, at the top of DRAM, as well as + detail about each piece of it. + + See doc/usage/cmd/meminfo.rst for more information. + config CMD_MEMORY bool "md, mm, nm, mw, cp, cmp, base, loop" default y @@ -1084,13 +1098,10 @@ config CMD_BIND gadget driver from the command line. config CMD_CLK - bool "clk - Show clock frequencies" + bool "clk - Show and set clock frequencies" + depends on CLK help - (deprecated) - Shows clock frequences by calling a sock_clk_dump() hook function. - This is depreated in favour of using the CLK uclass and accessing - clock values from associated drivers. However currently no command - exists for this. + Show and set clock frequencies managed by CLK uclass drivers. config CMD_DEMO bool "demo - Demonstration commands for driver model" @@ -1661,6 +1672,7 @@ config CMD_USB config CMD_USB_SDP bool "sdp" + depends on USB_GADGET_DOWNLOAD select USB_FUNCTION_SDP help Enables the command "sdp" which is used to have U-Boot emulating the @@ -1685,9 +1697,8 @@ config CMD_ROCKUSB config CMD_USB_MASS_STORAGE bool "UMS usb mass storage" - depends on USB_GADGET_DOWNLOAD + depends on BLK && USB_GADGET_DOWNLOAD select USB_FUNCTION_MASS_STORAGE - depends on BLK && USB_GADGET help Enables the command "ums" and the USB mass storage support to the export a block device: U-Boot, the USB device, acts as a simple @@ -1783,26 +1794,16 @@ config CMD_XXD endmenu -menu "Android support commands" - -config CMD_AB_SELECT - bool "ab_select" - depends on ANDROID_AB - help - On Android devices with more than one boot slot (multiple copies of - the kernel and system images) this provides a command to select which - slot should be used to boot from and register the boot attempt. This - is used by the new A/B update model where one slot is updated in the - background while running from the other slot. - -endmenu - -if NET +if NET || NET_LWIP menuconfig CMD_NET bool "Network commands" default y +endif + +if NET + if CMD_NET config CMD_BOOTP @@ -1811,12 +1812,6 @@ config CMD_BOOTP help bootp - boot image via network using BOOTP/TFTP protocol -config CMD_DHCP - bool "dhcp" - depends on CMD_BOOTP - help - Boot image via network using DHCP/TFTP protocol - config CMD_DHCP6 bool "dhcp6" depends on IPV6 @@ -1960,12 +1955,6 @@ config BOOTP_VCI_STRING default "U-Boot.arm" if ARM default "U-Boot" -config CMD_TFTPBOOT - bool "tftpboot" - default y - help - tftpboot - load file via network using TFTP protocol - config CMD_TFTPPUT bool "tftp put" depends on CMD_TFTPBOOT @@ -2017,42 +2006,6 @@ config SYS_DISABLE_AUTOLOAD is complete. Enable this option to disable this behavior and instead require files to be loaded over the network by subsequent commands. -config CMD_WGET - bool "wget" - select PROT_TCP - default y if SANDBOX - help - wget is a simple command to download kernel, or other files, - from a http server over TCP. - -config CMD_MII - bool "mii" - imply CMD_MDIO - help - If set, allows 802.3(clause 22) MII Management functions interface access - The management interface specified in Clause 22 provides - a simple, two signal, serial interface to connect a - Station Management entity and a managed PHY for providing access - to management parameters and services. - The interface is referred to as the MII management interface. - -config MII_INIT - bool "Call mii_init() in the mii command" - depends on CMD_MII && (MPC8XX_FEC || FSLDMAFE || MCFFEC) - -config CMD_MDIO - bool "mdio" - depends on PHYLIB - help - If set, allows Enable 802.3(clause 45) MDIO interface registers access - The MDIO interface is orthogonal to the MII interface and extends - it by adding access to more registers through indirect addressing. - -config CMD_PING - bool "ping" - help - Send ICMP ECHO_REQUEST to network host - config CMD_PING6 bool "ping6" depends on IPV6 @@ -2071,11 +2024,6 @@ config CMD_SNTP help Synchronize RTC via network -config CMD_DNS - bool "dns" - help - Lookup the IP of a hostname - config CMD_LINK_LOCAL bool "linklocal" select LIB_RAND @@ -2096,7 +2044,7 @@ config IPV6_ROUTER_DISCOVERY help Will automatically perform router solicitation on first IPv6 network operation -endif +endif # if CMD_NET config CMD_ETHSW bool "ethsw" @@ -2106,18 +2054,86 @@ config CMD_ETHSW operations such as enabling / disabling a port and viewing/maintaining the filtering database (FDB) +config CMD_WOL + bool "wol" + help + Wait for wake-on-lan Magic Packet + +endif # if NET + +if NET || NET_LWIP + +if CMD_NET + +config CMD_DHCP + bool "dhcp" + select PROT_DHCP_LWIP if NET_LWIP + help + Boot image via network using DHCP/TFTP protocol + +config CMD_DNS + bool "dns" + select PROT_DNS_LWIP if NET_LWIP + help + Lookup the IP of a hostname + +config CMD_MII + bool "mii" + imply CMD_MDIO + help + If set, allows 802.3(clause 22) MII Management functions interface access + The management interface specified in Clause 22 provides + a simple, two signal, serial interface to connect a + Station Management entity and a managed PHY for providing access + to management parameters and services. + The interface is referred to as the MII management interface. + +config MII_INIT + bool "Call mii_init() in the mii command" + depends on CMD_MII && (MPC8XX_FEC || FSLDMAFE || MCFFEC) + +config CMD_MDIO + bool "mdio" + depends on PHYLIB + help + If set, allows Enable 802.3(clause 45) MDIO interface registers access + The MDIO interface is orthogonal to the MII interface and extends + it by adding access to more registers through indirect addressing. + +config CMD_PING + bool "ping" + select PROT_RAW_LWIP if NET_LWIP + help + Send ICMP ECHO_REQUEST to network host + +config CMD_TFTPBOOT + bool "tftp" + select PROT_UDP_LWIP if NET_LWIP + default y + help + tftpboot - load file via network using TFTP protocol + +config CMD_WGET + bool "wget" + depends on CMD_NET + default y if SANDBOX + select PROT_TCP if NET + select PROT_TCP_LWIP if NET_LWIP + select PROT_DNS_LWIP if NET_LWIP + help + wget is a simple command to download kernel, or other files, + from a http server over TCP. + +endif # if CMD_NET + config CMD_PXE bool "pxe" select PXE_UTILS + imply CMD_TFTPBOOT help Boot image via network using PXE protocol -config CMD_WOL - bool "wol" - help - Wait for wake-on-lan Magic Packet - -endif +endif # if NET || NET_LWIP menu "Misc commands" @@ -2274,6 +2290,7 @@ config CMD_DATE config CMD_RTC bool "rtc" depends on DM_RTC + default y if X86 help Enable the 'rtc' command for low-level access to RTC devices. diff --git a/cmd/Makefile b/cmd/Makefile index 91227f1249c..d1f369deec0 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -3,7 +3,7 @@ # (C) Copyright 2004-2006 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. -ifndef CONFIG_SPL_BUILD +ifndef CONFIG_XPL_BUILD # core command obj-y += boot.o obj-$(CONFIG_CMD_BOOTM) += bootm.o @@ -17,7 +17,6 @@ obj-$(CONFIG_CMD_2048) += 2048.o obj-$(CONFIG_CMD_ACPI) += acpi.o obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o obj-$(CONFIG_CMD_AES) += aes.o -obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o obj-$(CONFIG_CMD_ADC) += adc.o obj-$(CONFIG_CMD_ARMFLASH) += armflash.o obj-$(CONFIG_BLK) += blk_common.o @@ -110,6 +109,7 @@ obj-$(CONFIG_CMD_LOG) += log.o obj-$(CONFIG_CMD_LSBLK) += lsblk.o obj-$(CONFIG_CMD_MD5SUM) += md5sum.o obj-$(CONFIG_CMD_MEMORY) += mem.o +obj-$(CONFIG_CMD_MEMINFO) += meminfo.o obj-$(CONFIG_CMD_IO) += io.o obj-$(CONFIG_CMD_MII) += mii.o obj-$(CONFIG_CMD_MISC) += misc.o @@ -127,7 +127,11 @@ obj-y += legacy-mtd-utils.o endif obj-$(CONFIG_CMD_MUX) += mux.o obj-$(CONFIG_CMD_NAND) += nand.o -obj-$(CONFIG_CMD_NET) += net.o +ifdef CONFIG_NET +obj-$(CONFIG_CMD_NET) += net.o net-common.o +else ifdef CONFIG_NET_LWIP +obj-$(CONFIG_CMD_NET) += net-lwip.o net-common.o +endif obj-$(CONFIG_ENV_SUPPORT) += nvedit.o obj-$(CONFIG_CMD_NVEDIT_EFI) += nvedit_efi.o obj-$(CONFIG_CMD_ONENAND) += onenand.o @@ -172,6 +176,7 @@ obj-$(CONFIG_CMD_SMBIOS) += smbios.o obj-$(CONFIG_CMD_SMC) += smccc.o obj-$(CONFIG_CMD_SYSBOOT) += sysboot.o obj-$(CONFIG_CMD_STACKPROTECTOR_TEST) += stackprot_test.o +obj-$(CONFIG_CMD_TCPM) += tcpm.o obj-$(CONFIG_CMD_TEMPERATURE) += temperature.o obj-$(CONFIG_CMD_TERMINAL) += terminal.o obj-$(CONFIG_CMD_TIME) += time.o @@ -247,9 +252,9 @@ obj-$(CONFIG_ARCH_MVEBU) += mvebu/ obj-$(CONFIG_ARCH_KEYSTONE) += ti/ obj-$(CONFIG_ARCH_K3) += ti/ obj-$(CONFIG_ARCH_OMAP2PLUS) += ti/ -endif # !CONFIG_SPL_BUILD +endif # !CONFIG_XPL_BUILD -obj-$(CONFIG_$(SPL_)CMD_TLV_EEPROM) += tlv_eeprom.o +obj-$(CONFIG_$(XPL_)CMD_TLV_EEPROM) += tlv_eeprom.o obj-$(CONFIG_CMD_BCM_EXT_UTILS) += broadcom/ diff --git a/cmd/ab_select.c b/cmd/ab_select.c deleted file mode 100644 index 7c178c728ca..00000000000 --- a/cmd/ab_select.c +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -/* - * Copyright (C) 2017 The Android Open Source Project - */ - -#include <android_ab.h> -#include <command.h> -#include <env.h> -#include <part.h> - -static int do_ab_select(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) -{ - int ret; - struct blk_desc *dev_desc; - struct disk_partition part_info; - char slot[2]; - bool dec_tries = true; - - if (argc < 4) - return CMD_RET_USAGE; - - for (int i = 4; i < argc; i++) { - if (strcmp(argv[i], "--no-dec") == 0) { - dec_tries = false; - } else { - return CMD_RET_USAGE; - } - } - - /* Lookup the "misc" partition from argv[2] and argv[3] */ - if (part_get_info_by_dev_and_name_or_num(argv[2], argv[3], - &dev_desc, &part_info, - false) < 0) { - return CMD_RET_FAILURE; - } - - ret = ab_select_slot(dev_desc, &part_info, dec_tries); - if (ret < 0) { - printf("Android boot failed, error %d.\n", ret); - return CMD_RET_FAILURE; - } - - /* Android standard slot names are 'a', 'b', ... */ - slot[0] = BOOT_SLOT_NAME(ret); - slot[1] = '\0'; - env_set(argv[1], slot); - printf("ANDROID: Booting slot: %s\n", slot); - return CMD_RET_SUCCESS; -} - -U_BOOT_CMD(ab_select, 5, 0, do_ab_select, - "Select the slot used to boot from and register the boot attempt.", - "<slot_var_name> <interface> <dev[:part|#part_name]> [--no-dec]\n" - " - Load the slot metadata from the partition 'part' on\n" - " device type 'interface' instance 'dev' and store the active\n" - " slot in the 'slot_var_name' variable. This also updates the\n" - " Android slot metadata with a boot attempt, which can cause\n" - " successive calls to this function to return a different result\n" - " if the returned slot runs out of boot attempts.\n" - " - If 'part_name' is passed, preceded with a # instead of :, the\n" - " partition name whose label is 'part_name' will be looked up in\n" - " the partition table. This is commonly the \"misc\" partition.\n" - " - If '--no-dec' is set, the number of tries remaining will not\n" - " decremented for the selected boot slot\n" -); diff --git a/cmd/bcb.c b/cmd/bcb.c index 97a96c00964..16eabfe00f5 100644 --- a/cmd/bcb.c +++ b/cmd/bcb.c @@ -8,6 +8,7 @@ #include <android_bootloader_message.h> #include <bcb.h> #include <command.h> +#include <android_ab.h> #include <display_options.h> #include <log.h> #include <part.h> @@ -16,15 +17,6 @@ #include <vsprintf.h> #include <linux/err.h> -enum bcb_cmd { - BCB_CMD_LOAD, - BCB_CMD_FIELD_SET, - BCB_CMD_FIELD_CLEAR, - BCB_CMD_FIELD_TEST, - BCB_CMD_FIELD_DUMP, - BCB_CMD_STORE, -}; - static const char * const fields[] = { "command", "status", @@ -38,67 +30,9 @@ static struct disk_partition partition_data; static struct blk_desc *block; static struct disk_partition *partition = &partition_data; -static int bcb_cmd_get(char *cmd) -{ - if (!strcmp(cmd, "load")) - return BCB_CMD_LOAD; - if (!strcmp(cmd, "set")) - return BCB_CMD_FIELD_SET; - if (!strcmp(cmd, "clear")) - return BCB_CMD_FIELD_CLEAR; - if (!strcmp(cmd, "test")) - return BCB_CMD_FIELD_TEST; - if (!strcmp(cmd, "store")) - return BCB_CMD_STORE; - if (!strcmp(cmd, "dump")) - return BCB_CMD_FIELD_DUMP; - else - return -1; -} - -static int bcb_is_misused(int argc, char *const argv[]) +static int bcb_not_loaded(void) { - int cmd = bcb_cmd_get(argv[0]); - - switch (cmd) { - case BCB_CMD_LOAD: - if (argc != 3 && argc != 4) - goto err; - break; - case BCB_CMD_FIELD_SET: - if (argc != 3) - goto err; - break; - case BCB_CMD_FIELD_TEST: - if (argc != 4) - goto err; - break; - case BCB_CMD_FIELD_CLEAR: - if (argc != 1 && argc != 2) - goto err; - break; - case BCB_CMD_STORE: - if (argc != 1) - goto err; - break; - case BCB_CMD_FIELD_DUMP: - if (argc != 2) - goto err; - break; - default: - printf("Error: 'bcb %s' not supported\n", argv[0]); - return -1; - } - - if (cmd != BCB_CMD_LOAD && !block) { - printf("Error: Please, load BCB first!\n"); - return -1; - } - - return 0; -err: - printf("Error: Bad usage of 'bcb %s'\n", argv[0]); - + printf("Error: Please, load BCB first!\n"); return -1; } @@ -216,6 +150,9 @@ static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc, char *endp; char *iface = "mmc"; + if (argc < 3) + return CMD_RET_USAGE; + if (argc == 4) { iface = argv[1]; argc--; @@ -270,6 +207,12 @@ static int __bcb_set(const char *fieldp, const char *valp) static int do_bcb_set(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { + if (argc < 3) + return CMD_RET_USAGE; + + if (!block) + return bcb_not_loaded(); + return __bcb_set(argv[1], argv[2]); } @@ -279,6 +222,9 @@ static int do_bcb_clear(struct cmd_tbl *cmdtp, int flag, int argc, int size; char *field; + if (!block) + return bcb_not_loaded(); + if (argc == 1) { memset(&bcb, 0, sizeof(bcb)); return CMD_RET_SUCCESS; @@ -297,7 +243,15 @@ static int do_bcb_test(struct cmd_tbl *cmdtp, int flag, int argc, { int size; char *field; - char *op = argv[2]; + char *op; + + if (argc < 4) + return CMD_RET_USAGE; + + if (!block) + return bcb_not_loaded(); + + op = argv[2]; if (bcb_field_get(argv[1], &field, &size)) return CMD_RET_FAILURE; @@ -325,6 +279,12 @@ static int do_bcb_dump(struct cmd_tbl *cmdtp, int flag, int argc, int size; char *field; + if (argc < 2) + return CMD_RET_USAGE; + + if (!block) + return bcb_not_loaded(); + if (bcb_field_get(argv[1], &field, &size)) return CMD_RET_FAILURE; @@ -356,6 +316,9 @@ err: static int do_bcb_store(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { + if (!block) + return bcb_not_loaded(); + return __bcb_store(); } @@ -414,44 +377,75 @@ void bcb_reset(void) __bcb_reset(); } -static struct cmd_tbl cmd_bcb_sub[] = { - U_BOOT_CMD_MKENT(load, CONFIG_SYS_MAXARGS, 1, do_bcb_load, "", ""), - U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 1, do_bcb_set, "", ""), - U_BOOT_CMD_MKENT(clear, CONFIG_SYS_MAXARGS, 1, do_bcb_clear, "", ""), - U_BOOT_CMD_MKENT(test, CONFIG_SYS_MAXARGS, 1, do_bcb_test, "", ""), - U_BOOT_CMD_MKENT(dump, CONFIG_SYS_MAXARGS, 1, do_bcb_dump, "", ""), - U_BOOT_CMD_MKENT(store, CONFIG_SYS_MAXARGS, 1, do_bcb_store, "", ""), -}; - -static int do_bcb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +__maybe_unused static int do_bcb_ab_select(struct cmd_tbl *cmdtp, + int flag, int argc, + char * const argv[]) { - struct cmd_tbl *c; + int ret; + struct blk_desc *dev_desc; + struct disk_partition part_info; + char slot[2]; + bool dec_tries = true; - if (argc < 2) + if (argc < 4) return CMD_RET_USAGE; - argc--; - argv++; + for (int i = 4; i < argc; i++) { + if (!strcmp(argv[i], "--no-dec")) + dec_tries = false; + else + return CMD_RET_USAGE; + } + + /* Lookup the "misc" partition from argv[2] and argv[3] */ + if (part_get_info_by_dev_and_name_or_num(argv[2], argv[3], + &dev_desc, &part_info, + false) < 0) { + return CMD_RET_FAILURE; + } + + ret = ab_select_slot(dev_desc, &part_info, dec_tries); + if (ret < 0) { + printf("Android boot failed, error %d.\n", ret); + return CMD_RET_FAILURE; + } + + /* Android standard slot names are 'a', 'b', ... */ + slot[0] = BOOT_SLOT_NAME(ret); + slot[1] = '\0'; + env_set(argv[1], slot); + printf("ANDROID: Booting slot: %s\n", slot); - c = find_cmd_tbl(argv[0], cmd_bcb_sub, ARRAY_SIZE(cmd_bcb_sub)); - if (!c) + return CMD_RET_SUCCESS; +} + +__maybe_unused static int do_bcb_ab_dump(struct cmd_tbl *cmdtp, + int flag, int argc, + char *const argv[]) +{ + int ret; + struct blk_desc *dev_desc; + struct disk_partition part_info; + + if (argc < 3) return CMD_RET_USAGE; - if (bcb_is_misused(argc, argv)) { - /* - * We try to improve the user experience by reporting the - * root-cause of misusage, so don't return CMD_RET_USAGE, - * since the latter prints out the full-blown help text - */ + if (part_get_info_by_dev_and_name_or_num(argv[1], argv[2], + &dev_desc, &part_info, + false) < 0) { + return CMD_RET_FAILURE; + } + + ret = ab_dump_abc(dev_desc, &part_info); + if (ret < 0) { + printf("Cannot dump ABC data, error %d.\n", ret); return CMD_RET_FAILURE; } - return c->cmd(cmdtp, flag, argc, argv); + return CMD_RET_SUCCESS; } -U_BOOT_CMD( - bcb, CONFIG_SYS_MAXARGS, 1, do_bcb, - "Load/set/clear/test/dump/store Android BCB fields", +U_BOOT_LONGHELP(bcb, "load <interface> <dev> <part> - load BCB from <interface> <dev>:<part>\n" "load <dev> <part> - load BCB from mmc <dev>:<part>\n" "bcb set <field> <val> - set BCB <field> to <val>\n" @@ -460,6 +454,27 @@ U_BOOT_CMD( "bcb dump <field> - dump BCB <field>\n" "bcb store - store BCB back to <interface>\n" "\n" +#if IS_ENABLED(CONFIG_ANDROID_AB) + "bcb ab_select -\n" + " Select the slot used to boot from and register the boot attempt.\n" + " <slot_var_name> <interface> <dev[:part|#part_name]> [--no-dec]\n" + " - Load the slot metadata from the partition 'part' on\n" + " device type 'interface' instance 'dev' and store the active\n" + " slot in the 'slot_var_name' variable. This also updates the\n" + " Android slot metadata with a boot attempt, which can cause\n" + " successive calls to this function to return a different result\n" + " if the returned slot runs out of boot attempts.\n" + " - If 'part_name' is passed, preceded with a # instead of :, the\n" + " partition name whose label is 'part_name' will be looked up in\n" + " the partition table. This is commonly the \"misc\" partition.\n" + " - If '--no-dec' is set, the number of tries remaining will not\n" + " decremented for the selected boot slot\n" + "\n" + "bcb ab_dump -\n" + " Dump boot_control information from specific partition.\n" + " <interface> <dev[:part|#part_name]>\n" + "\n" +#endif "Legend:\n" "<interface> - storage device interface (virtio, mmc, etc)\n" "<dev> - storage device index containing the BCB partition\n" @@ -472,3 +487,17 @@ U_BOOT_CMD( " NOTE: any ':' character in <val> will be replaced by line feed\n" " during 'bcb set' and used as separator by upper layers\n" ); + +U_BOOT_CMD_WITH_SUBCMDS(bcb, + "Load/set/clear/test/dump/store Android BCB fields", bcb_help_text, + U_BOOT_SUBCMD_MKENT(load, 4, 1, do_bcb_load), + U_BOOT_SUBCMD_MKENT(set, 3, 1, do_bcb_set), + U_BOOT_SUBCMD_MKENT(clear, 2, 1, do_bcb_clear), + U_BOOT_SUBCMD_MKENT(test, 4, 1, do_bcb_test), + U_BOOT_SUBCMD_MKENT(dump, 2, 1, do_bcb_dump), + U_BOOT_SUBCMD_MKENT(store, 1, 1, do_bcb_store), +#if IS_ENABLED(CONFIG_ANDROID_AB) + U_BOOT_SUBCMD_MKENT(ab_select, 5, 1, do_bcb_ab_select), + U_BOOT_SUBCMD_MKENT(ab_dump, 3, 1, do_bcb_ab_dump), +#endif +); diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index f6e534dd5bb..4c0e2adabc3 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -151,7 +151,7 @@ static int bdinfo_print_all(struct bd_info *bd) bdinfo_print_num_l("relocaddr", gd->relocaddr); bdinfo_print_num_l("reloc off", gd->reloc_off); printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8); - if (IS_ENABLED(CONFIG_CMD_NET)) + if (IS_ENABLED(CONFIG_CMD_NET) || IS_ENABLED(CONFIG_CMD_NET_LWIP)) print_eth(); bdinfo_print_num_l("fdt_blob", (ulong)map_to_sysmem(gd->fdt_blob)); if (IS_ENABLED(CONFIG_VIDEO)) @@ -192,7 +192,8 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) case 'a': return bdinfo_print_all(bd); case 'e': - if (!IS_ENABLED(CONFIG_CMD_NET)) + if (!IS_ENABLED(CONFIG_CMD_NET) && + !IS_ENABLED(CONFIG_CMD_NET_LWIP)) return CMD_RET_USAGE; print_eth(); return CMD_RET_SUCCESS; diff --git a/cmd/booti.c b/cmd/booti.c index 6018cbacf0a..43e79e87201 100644 --- a/cmd/booti.c +++ b/cmd/booti.c @@ -78,7 +78,7 @@ static int booti_start(struct bootm_info *bmi) /* Handle BOOTM_STATE_LOADOS */ if (relocated_addr != ld) { - printf("Moving Image from 0x%lx to 0x%lx, end=%lx\n", ld, + printf("Moving Image from 0x%lx to 0x%lx, end=0x%lx\n", ld, relocated_addr, relocated_addr + image_size); memmove((void *)relocated_addr, (void *)ld, image_size); } diff --git a/cmd/bootmeth.c b/cmd/bootmeth.c index ebf8b7e2530..2f41fa1bec6 100644 --- a/cmd/bootmeth.c +++ b/cmd/bootmeth.c @@ -103,10 +103,31 @@ static int do_bootmeth_order(struct cmd_tbl *cmdtp, int flag, int argc, return 0; } +static int do_bootmeth_set(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + int ret; + + if (argc < 4) { + printf("Required parameters not provided\n"); + return CMD_RET_FAILURE; + } + + ret = bootmeth_set_property(argv[1], argv[2], argv[3]); + if (ret) { + printf("Failed (err=%d)\n", ret); + return CMD_RET_FAILURE; + } + + return 0; +} + U_BOOT_LONGHELP(bootmeth, "list [-a] - list available bootmeths (-a all)\n" - "bootmeth order [<bd> ...] - select bootmeth order / subset to use"); + "bootmeth order [<bd> ...] - select bootmeth order / subset to use\n" + "bootmeth set <bootmeth> <property> <value> - set optional property"); U_BOOT_CMD_WITH_SUBCMDS(bootmeth, "Boot methods", bootmeth_help_text, U_BOOT_SUBCMD_MKENT(list, 2, 1, do_bootmeth_list), - U_BOOT_SUBCMD_MKENT(order, CONFIG_SYS_MAXARGS, 1, do_bootmeth_order)); + U_BOOT_SUBCMD_MKENT(order, CONFIG_SYS_MAXARGS, 1, do_bootmeth_order), + U_BOOT_SUBCMD_MKENT(set, CONFIG_SYS_MAXARGS, 1, do_bootmeth_set)); diff --git a/cmd/clk.c b/cmd/clk.c index 6fda6efb1ce..2fc834e5549 100644 --- a/cmd/clk.c +++ b/cmd/clk.c @@ -4,15 +4,12 @@ */ #include <command.h> #include <clk.h> -#if defined(CONFIG_DM) && defined(CONFIG_CLK) #include <dm.h> #include <dm/device.h> #include <dm/root.h> #include <dm/device-internal.h> #include <linux/clk-provider.h> -#endif -#if defined(CONFIG_DM) && defined(CONFIG_CLK) static void show_clks(struct udevice *dev, int depth, int last_flag) { int i, is_last; @@ -79,13 +76,6 @@ static int soc_clk_dump(void) return 0; } -#else -static int soc_clk_dump(void) -{ - puts("Not implemented\n"); - return 1; -} -#endif static int do_clk_dump(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) @@ -101,7 +91,6 @@ static int do_clk_dump(struct cmd_tbl *cmdtp, int flag, int argc, return ret; } -#if CONFIG_IS_ENABLED(DM) && CONFIG_IS_ENABLED(CLK) static int do_clk_setfreq(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -131,13 +120,10 @@ static int do_clk_setfreq(struct cmd_tbl *cmdtp, int flag, int argc, printf("set_rate returns %u\n", freq); return 0; } -#endif static struct cmd_tbl cmd_clk_sub[] = { U_BOOT_CMD_MKENT(dump, 1, 1, do_clk_dump, "", ""), -#if CONFIG_IS_ENABLED(DM) && CONFIG_IS_ENABLED(CLK) U_BOOT_CMD_MKENT(setfreq, 3, 1, do_clk_setfreq, "", ""), -#endif }; static int do_clk(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 1a191eb9994..e040fe75fa1 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -665,7 +665,7 @@ enum efi_lo_dp_part { }; /** - * create_lo_dp() - create a special device path for our Boot### option + * create_lo_dp_part() - create a special device path for our Boot### option * * @dev: device * @part: disk partition @@ -1127,7 +1127,7 @@ static void show_efi_boot_opt(u16 *varname16) } /** - * show_efi_boot_dump() - dump all UEFI load options + * do_efi_boot_dump() - dump all UEFI load options * * @cmdtp: Command table * @flag: Command flag diff --git a/cmd/elf.c b/cmd/elf.c index f07e344a596..6b49c613703 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -10,8 +10,10 @@ #include <env.h> #include <image.h> #include <log.h> +#ifdef CONFIG_CMD_ELF_BOOTVX #include <net.h> #include <vxworks.h> +#endif #ifdef CONFIG_X86 #include <vesa.h> #include <asm/cache.h> @@ -100,6 +102,7 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return rcode; } +#ifdef CONFIG_CMD_ELF_BOOTVX /* * Interpreter command to boot VxWorks from a memory image. The image can * be either an ELF image or a raw binary. Will attempt to setup the @@ -130,7 +133,7 @@ int do_bootvx(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) else addr = hextoul(argv[1], NULL); -#if defined(CONFIG_CMD_NET) +#if defined(CONFIG_CMD_NET) && !defined(CONFIG_NET_LWIP) /* * Check to see if we need to tftp the image ourselves * before starting @@ -307,6 +310,7 @@ int do_bootvx(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return 1; } +#endif U_BOOT_CMD( bootelf, CONFIG_SYS_MAXARGS, 0, do_bootelf, @@ -323,8 +327,10 @@ U_BOOT_CMD( #endif ); +#ifdef CONFIG_CMD_ELF_BOOTVX U_BOOT_CMD( bootvx, 2, 0, do_bootvx, "Boot vxWorks from an ELF image", " [address] - load address of vxWorks ELF image." ); +#endif diff --git a/cmd/fat.c b/cmd/fat.c index 1655e80e945..5b7484dc1af 100644 --- a/cmd/fat.c +++ b/cmd/fat.c @@ -14,7 +14,7 @@ #include <part.h> #include <asm/cache.h> -int do_fat_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +static int do_fat_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { return do_size(cmdtp, flag, argc, argv, FS_TYPE_FAT); } diff --git a/cmd/font.c b/cmd/font.c index eb13fb12f79..36e41203654 100644 --- a/cmd/font.c +++ b/cmd/font.c @@ -55,9 +55,6 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc, uint size; int ret; - if (argc != 2) - return CMD_RET_USAGE; - if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) return CMD_RET_FAILURE; ret = vidconsole_get_font_size(dev, &font_name, &size); @@ -66,12 +63,16 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } - size = dectoul(argv[1], NULL); + if (argc < 2) { + printf("%d\n", size); + } else { + size = dectoul(argv[1], NULL); - ret = vidconsole_select_font(dev, font_name, size); - if (ret) { - printf("Failed (error %d)\n", ret); - return CMD_RET_FAILURE; + ret = vidconsole_select_font(dev, font_name, size); + if (ret) { + printf("Failed (error %d)\n", ret); + return CMD_RET_FAILURE; + } } return 0; diff --git a/cmd/irq.c b/cmd/irq.c index 655aba576a8..da223b4b2cc 100644 --- a/cmd/irq.c +++ b/cmd/irq.c @@ -29,9 +29,6 @@ U_BOOT_CMD( "[on, off]" ); -/* Implemented in $(CPU)/interrupts.c */ -int do_irqinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); - U_BOOT_CMD( irqinfo, 1, 1, do_irqinfo, "print information about IRQs", diff --git a/cmd/mem.c b/cmd/mem.c index 4d6fde28531..9e716776393 100644 --- a/cmd/mem.c +++ b/cmd/mem.c @@ -1379,17 +1379,6 @@ U_BOOT_CMD( #endif -#ifdef CONFIG_CMD_MEMINFO -static int do_mem_info(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) -{ - puts("DRAM: "); - print_size(gd->ram_size, "\n"); - - return 0; -} -#endif - U_BOOT_CMD( base, 2, 1, do_mem_base, "print or set address offset", @@ -1433,14 +1422,6 @@ U_BOOT_CMD( ); #endif /* CONFIG_CMD_MX_CYCLIC */ -#ifdef CONFIG_CMD_MEMINFO -U_BOOT_CMD( - meminfo, 3, 1, do_mem_info, - "display memory information", - "" -); -#endif - #ifdef CONFIG_CMD_RANDOM U_BOOT_CMD( random, 4, 0, do_random, diff --git a/cmd/meminfo.c b/cmd/meminfo.c new file mode 100644 index 00000000000..5e83d61c2dd --- /dev/null +++ b/cmd/meminfo.c @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 Google LLC + * Written by Simon Glass <sjg@chromium.org> + */ + +#include <bloblist.h> +#include <bootstage.h> +#include <command.h> +#include <display_options.h> +#include <lmb.h> +#include <malloc.h> +#include <mapmem.h> +#include <asm/global_data.h> + +DECLARE_GLOBAL_DATA_PTR; + +static void print_region(const char *name, ulong base, ulong size, ulong *uptop) +{ + ulong end = base + size; + + printf("%-12s %8lx %8lx %8lx", name, base, size, end); + if (*uptop) + printf(" %8lx", *uptop - end); + putc('\n'); + *uptop = base; +} + +static void show_lmb(const struct lmb *lmb, ulong *uptop) +{ + int i; + + for (i = lmb->used_mem.count - 1; i >= 0; i--) { + const struct lmb_region *rgn = alist_get(&lmb->used_mem, i, + struct lmb_region); + + /* + * Assume that the top lmb region is the U-Boot region, so just + * take account of the memory not already reported + */ + if (lmb->used_mem.count - 1) + print_region("lmb", rgn->base, *uptop - rgn->base, + uptop); + else + print_region("lmb", rgn->base, rgn->size, uptop); + *uptop = rgn->base; + } +} + +static int do_meminfo(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + ulong upto, stk_bot; + + puts("DRAM: "); + print_size(gd->ram_size, "\n"); + + if (!IS_ENABLED(CONFIG_CMD_MEMINFO_MAP)) + return 0; + + printf("\n%-12s %8s %8s %8s %8s\n", "Region", "Base", "Size", "End", + "Gap"); + printf("------------------------------------------------\n"); + upto = 0; + if (IS_ENABLED(CONFIG_VIDEO)) + print_region("video", gd_video_bottom(), + gd_video_size(), &upto); + if (IS_ENABLED(CONFIG_TRACE)) + print_region("trace", map_to_sysmem(gd_trace_buff()), + gd_trace_size(), &upto); + print_region("code", gd->relocaddr, gd->mon_len, &upto); + print_region("malloc", map_to_sysmem((void *)mem_malloc_start), + mem_malloc_end - mem_malloc_start, &upto); + print_region("board_info", map_to_sysmem(gd->bd), + sizeof(struct bd_info), &upto); + print_region("global_data", map_to_sysmem((void *)gd), + sizeof(struct global_data), &upto); + print_region("devicetree", map_to_sysmem(gd->fdt_blob), + fdt_totalsize(gd->fdt_blob), &upto); + if (IS_ENABLED(CONFIG_BOOTSTAGE)) + print_region("bootstage", map_to_sysmem(gd_bootstage()), + bootstage_get_size(false), &upto); + if (IS_ENABLED(CONFIG_BLOBLIST)) + print_region("bloblist", map_to_sysmem(gd_bloblist()), + bloblist_get_total_size(), &upto); + stk_bot = gd->start_addr_sp - CONFIG_STACK_SIZE; + print_region("stack", stk_bot, CONFIG_STACK_SIZE, &upto); + if (IS_ENABLED(CONFIG_LMB)) + show_lmb(lmb_get(), &upto); + print_region("free", gd->ram_base, upto, &upto); + + return 0; +} + +U_BOOT_CMD( + meminfo, 1, 1, do_meminfo, + "display memory information", + "" +); diff --git a/cmd/mtd.c b/cmd/mtd.c index 795aaa2b37d..f178d7bea61 100644 --- a/cmd/mtd.c +++ b/cmd/mtd.c @@ -10,6 +10,7 @@ #include <command.h> #include <console.h> +#include <led.h> #if CONFIG_IS_ENABLED(CMD_MTD_OTP) #include <hexdump.h> #endif @@ -558,6 +559,8 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc, while (mtd_block_isbad(mtd, off)) off += mtd->erasesize; + led_activity_blink(); + /* Loop over the pages to do the actual read/write */ while (remaining) { /* Skip the block if it is bad */ @@ -585,6 +588,8 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc, io_op.oobbuf += io_op.oobretlen; } + led_activity_off(); + if (!ret && dump) mtd_dump_device_buf(mtd, start_off, buf, len, woob); @@ -652,6 +657,8 @@ static int do_mtd_erase(struct cmd_tbl *cmdtp, int flag, int argc, erase_op.addr = off; erase_op.len = mtd->erasesize; + led_activity_blink(); + while (len) { if (!scrub) { ret = mtd_block_isbad(mtd, erase_op.addr); @@ -680,6 +687,8 @@ static int do_mtd_erase(struct cmd_tbl *cmdtp, int flag, int argc, erase_op.addr += mtd->erasesize; } + led_activity_off(); + if (ret && ret != -EIO) ret = CMD_RET_FAILURE; else diff --git a/cmd/net-common.c b/cmd/net-common.c new file mode 100644 index 00000000000..1c9fb83b896 --- /dev/null +++ b/cmd/net-common.c @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2000 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + */ + +#include <command.h> +#include <dm/device.h> +#include <dm/uclass.h> +#include <net.h> +#include <linux/compat.h> +#include <linux/ethtool.h> + +static int do_net_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + const struct udevice *current = eth_get_dev(); + unsigned char env_enetaddr[ARP_HLEN]; + const struct udevice *dev; + struct uclass *uc; + + uclass_id_foreach_dev(UCLASS_ETH, dev, uc) { + eth_env_get_enetaddr_by_index("eth", dev_seq(dev), env_enetaddr); + printf("eth%d : %s %pM %s\n", dev_seq(dev), dev->name, env_enetaddr, + current == dev ? "active" : ""); + } + return CMD_RET_SUCCESS; +} + +static int do_net_stats(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + int nstats, err, i, off; + struct udevice *dev; + u64 *values; + u8 *strings; + + if (argc < 2) + return CMD_RET_USAGE; + + err = uclass_get_device_by_name(UCLASS_ETH, argv[1], &dev); + if (err) { + printf("Could not find device %s\n", argv[1]); + return CMD_RET_FAILURE; + } + + if (!eth_get_ops(dev)->get_sset_count || + !eth_get_ops(dev)->get_strings || + !eth_get_ops(dev)->get_stats) { + printf("Driver does not implement stats dump!\n"); + return CMD_RET_FAILURE; + } + + nstats = eth_get_ops(dev)->get_sset_count(dev); + strings = kcalloc(nstats, ETH_GSTRING_LEN, GFP_KERNEL); + if (!strings) + return CMD_RET_FAILURE; + + values = kcalloc(nstats, sizeof(u64), GFP_KERNEL); + if (!values) + goto err_free_strings; + + eth_get_ops(dev)->get_strings(dev, strings); + eth_get_ops(dev)->get_stats(dev, values); + + off = 0; + for (i = 0; i < nstats; i++) { + printf(" %s: %llu\n", &strings[off], values[i]); + off += ETH_GSTRING_LEN; + }; + + kfree(strings); + kfree(values); + + return CMD_RET_SUCCESS; + +err_free_strings: + kfree(strings); + + return CMD_RET_FAILURE; +} + +static struct cmd_tbl cmd_net[] = { + U_BOOT_CMD_MKENT(list, 1, 0, do_net_list, "", ""), + U_BOOT_CMD_MKENT(stats, 2, 0, do_net_stats, "", ""), +}; + +static int do_net(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + struct cmd_tbl *cp; + + cp = find_cmd_tbl(argv[1], cmd_net, ARRAY_SIZE(cmd_net)); + + /* Drop the net command */ + argc--; + argv++; + + if (!cp || argc > cp->maxargs) + return CMD_RET_USAGE; + if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) + return CMD_RET_SUCCESS; + + return cp->cmd(cmdtp, flag, argc, argv); +} + +U_BOOT_CMD( + net, 3, 1, do_net, + "NET sub-system", + "list - list available devices\n" + "stats <device> - dump statistics for specified device\n" +); diff --git a/cmd/net-lwip.c b/cmd/net-lwip.c new file mode 100644 index 00000000000..42f8bd6b259 --- /dev/null +++ b/cmd/net-lwip.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* Copyright (C) 2024 Linaro Ltd. */ + +#include <command.h> +#include <net.h> + +#if defined(CONFIG_CMD_DHCP) +U_BOOT_CMD( + dhcp, 3, 1, do_dhcp, + "boot image via network using DHCP/TFTP protocol", + "[loadAddress] [[hostIPaddr:]bootfilename]" +); +#endif + +#if defined(CONFIG_CMD_PING) +U_BOOT_CMD( + ping, 2, 1, do_ping, + "send ICMP ECHO_REQUEST to network host", + "pingAddress" +); +#endif + +#if defined(CONFIG_CMD_TFTPBOOT) +U_BOOT_CMD( + tftpboot, 3, 0, do_tftpb, + "boot image via network using TFTP protocol\n", + "[loadAddress] [[hostIPaddr:]bootfilename]" +); +#endif + +#if defined(CONFIG_CMD_DNS) +U_BOOT_CMD( + dns, 3, 1, do_dns, + "lookup the IP of a hostname", + "hostname [envvar]" +); +#endif + +#if defined(CONFIG_CMD_WGET) +U_BOOT_CMD( + wget, 3, 1, do_wget, + "boot image via network using HTTP protocol", + "[loadAddress] URL" +); +#endif diff --git a/cmd/net.c b/cmd/net.c index 53ce2bc5d0c..c90578e1b9f 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -674,118 +674,3 @@ U_BOOT_CMD( ); #endif /* CONFIG_CMD_LINK_LOCAL */ - -static int do_net_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - const struct udevice *current = eth_get_dev(); - unsigned char env_enetaddr[ARP_HLEN]; - const struct udevice *dev; - struct uclass *uc; - - uclass_id_foreach_dev(UCLASS_ETH, dev, uc) { - eth_env_get_enetaddr_by_index("eth", dev_seq(dev), env_enetaddr); - printf("eth%d : %s %pM %s\n", dev_seq(dev), dev->name, env_enetaddr, - current == dev ? "active" : ""); - } - return CMD_RET_SUCCESS; -} - -static int do_net_stats(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - int nstats, err, i, off; - struct udevice *dev; - u64 *values; - u8 *strings; - - if (argc < 2) - return CMD_RET_USAGE; - - err = uclass_get_device_by_name(UCLASS_ETH, argv[1], &dev); - if (err) { - printf("Could not find device %s\n", argv[1]); - return CMD_RET_FAILURE; - } - - if (!eth_get_ops(dev)->get_sset_count || - !eth_get_ops(dev)->get_strings || - !eth_get_ops(dev)->get_stats) { - printf("Driver does not implement stats dump!\n"); - return CMD_RET_FAILURE; - } - - nstats = eth_get_ops(dev)->get_sset_count(dev); - strings = kcalloc(nstats, ETH_GSTRING_LEN, GFP_KERNEL); - if (!strings) - return CMD_RET_FAILURE; - - values = kcalloc(nstats, sizeof(u64), GFP_KERNEL); - if (!values) - goto err_free_strings; - - eth_get_ops(dev)->get_strings(dev, strings); - eth_get_ops(dev)->get_stats(dev, values); - - off = 0; - for (i = 0; i < nstats; i++) { - printf(" %s: %llu\n", &strings[off], values[i]); - off += ETH_GSTRING_LEN; - }; - - return CMD_RET_SUCCESS; - -err_free_strings: - kfree(strings); - - return CMD_RET_FAILURE; -} - -static struct cmd_tbl cmd_net[] = { - U_BOOT_CMD_MKENT(list, 1, 0, do_net_list, "", ""), - U_BOOT_CMD_MKENT(stats, 2, 0, do_net_stats, "", ""), -}; - -static int do_net(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - struct cmd_tbl *cp; - - cp = find_cmd_tbl(argv[1], cmd_net, ARRAY_SIZE(cmd_net)); - - /* Drop the net command */ - argc--; - argv++; - - if (!cp || argc > cp->maxargs) - return CMD_RET_USAGE; - if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) - return CMD_RET_SUCCESS; - - return cp->cmd(cmdtp, flag, argc, argv); -} - -U_BOOT_CMD( - net, 3, 1, do_net, - "NET sub-system", - "list - list available devices\n" - "stats <device> - dump statistics for specified device\n" -); - -#if defined(CONFIG_CMD_NCSI) -static int do_ncsi(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) -{ - if (!phy_interface_is_ncsi() || !ncsi_active()) { - printf("Device not configured for NC-SI\n"); - return CMD_RET_FAILURE; - } - - if (net_loop(NCSI) < 0) - return CMD_RET_FAILURE; - - return CMD_RET_SUCCESS; -} - -U_BOOT_CMD( - ncsi, 1, 1, do_ncsi, - "Configure attached NIC via NC-SI", - "" -); -#endif /* CONFIG_CMD_NCSI */ diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 98a687bcabb..392f90f8698 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -49,7 +49,7 @@ DECLARE_GLOBAL_DATA_PTR; */ #define MAX_ENV_SIZE (1 << 20) /* 1 MiB */ -#ifndef CONFIG_SPL_BUILD +#ifndef CONFIG_XPL_BUILD /* * Command interface: print one or all environment variables * @@ -182,9 +182,9 @@ DONE: return 0; } #endif -#endif /* CONFIG_SPL_BUILD */ +#endif /* CONFIG_XPL_BUILD */ -#ifndef CONFIG_SPL_BUILD +#ifndef CONFIG_XPL_BUILD static int do_env_set(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -198,7 +198,7 @@ static int do_env_set(struct cmd_tbl *cmdtp, int flag, int argc, * Prompt for environment variable */ #if defined(CONFIG_CMD_ASKENV) -int do_env_ask(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +static int do_env_ask(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { char message[CONFIG_SYS_CBSIZE]; int i, len, pos, size; @@ -312,8 +312,8 @@ static int print_active_callback(struct env_entry *entry) /* * Print the callbacks available and what they are bound to */ -int do_env_callback(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) +static int do_env_callback(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) { struct env_clbk_tbl *clbkp; int i; @@ -381,7 +381,7 @@ static int print_active_flags(struct env_entry *entry) /* * Print the flags available and what variables have flags */ -int do_env_flags(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +static int do_env_flags(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { /* Print the available variable types */ printf("Available variable type flags (position %d):\n", @@ -503,9 +503,9 @@ static int do_env_select(struct cmd_tbl *cmdtp, int flag, int argc, } #endif -#endif /* CONFIG_SPL_BUILD */ +#endif /* CONFIG_XPL_BUILD */ -#ifndef CONFIG_SPL_BUILD +#ifndef CONFIG_XPL_BUILD static int do_env_default(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -1289,4 +1289,4 @@ U_BOOT_CMD_COMPLETE( var_complete ); #endif -#endif /* CONFIG_SPL_BUILD */ +#endif /* CONFIG_XPL_BUILD */ diff --git a/cmd/pxe.c b/cmd/pxe.c index ae02c28c075..982e2b1e7ea 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -138,7 +138,7 @@ int pxe_get(ulong pxefile_addr_r, char **bootdirp, ulong *sizep, bool use_ipv6) int i; if (pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL, false, - env_get("bootfile"), use_ipv6)) + env_get("bootfile"), use_ipv6, false)) return -ENOMEM; if (IS_ENABLED(CONFIG_BOOTP_PXE_DHCP_OPTION) && @@ -288,7 +288,7 @@ do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } if (pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL, false, - env_get("bootfile"), use_ipv6)) { + env_get("bootfile"), use_ipv6, false)) { printf("Out of memory\n"); return CMD_RET_FAILURE; } diff --git a/cmd/riscv/sbi.c b/cmd/riscv/sbi.c index a231604e492..5ecf56781c1 100644 --- a/cmd/riscv/sbi.c +++ b/cmd/riscv/sbi.c @@ -54,8 +54,10 @@ static struct sbi_ext extensions[] = { { SBI_EXT_CPPC, "Collaborative Processor Performance Control Extension" }, { SBI_EXT_NACL, "Nested Acceleration Extension" }, { SBI_EXT_STA, "Steal-time Accounting Extension" }, - { SBI_EXT_DBTR, "Debug Trigger Extension" }, { SBI_EXT_SSE, "Supervisor Software Events" }, + { SBI_EXT_FWFT, "Firmware Features Extension" }, + { SBI_EXT_DBTR, "Debug Triggers Extension" }, + { SBI_EXT_MPXY, "Message Proxy Extension" }, }; static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc, @@ -10,6 +10,7 @@ #include <div64.h> #include <dm.h> #include <log.h> +#include <lmb.h> #include <malloc.h> #include <mapmem.h> #include <spi.h> @@ -317,6 +318,13 @@ static int do_spi_flash_read_write(int argc, char *const argv[]) strncmp(argv[0], "write", 5) == 0) { int read; + if (CONFIG_IS_ENABLED(LMB)) { + if (lmb_read_check(addr, len)) { + printf("ERROR: trying to overwrite reserved memory...\n"); + return CMD_RET_FAILURE; + } + } + read = strncmp(argv[0], "read", 4) == 0; if (read) ret = spi_flash_read(flash, offset, len, buf); diff --git a/cmd/sysboot.c b/cmd/sysboot.c index 0ea08fd7b53..8a060780cab 100644 --- a/cmd/sysboot.c +++ b/cmd/sysboot.c @@ -105,7 +105,7 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int argc, } if (pxe_setup_ctx(&ctx, cmdtp, sysboot_read_file, &info, true, - filename, false)) { + filename, false, false)) { printf("Out of memory\n"); return CMD_RET_FAILURE; } diff --git a/cmd/tcpm.c b/cmd/tcpm.c new file mode 100644 index 00000000000..39578f6ccc0 --- /dev/null +++ b/cmd/tcpm.c @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2024 Collabora + */ + +#include <command.h> +#include <errno.h> +#include <dm.h> +#include <dm/uclass-internal.h> +#include <usb/tcpm.h> + +#define LIMIT_DEV 32 +#define LIMIT_PARENT 20 + +static struct udevice *currdev; + +static int do_dev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + int devnum, ret; + + switch (argc) { + case 2: + devnum = (int)dectoul(argv[1], NULL); + ret = tcpm_get(devnum, &currdev); + if (ret) { + log_err("Can't get TCPM %d: %d (%s)!\n", devnum, ret, errno_str(ret)); + return CMD_RET_FAILURE; + } + case 1: + if (!currdev) { + log_err("TCPM device is not set!\n\n"); + return CMD_RET_USAGE; + } + + printf("dev: %d @ %s\n", dev_seq(currdev), currdev->name); + } + + return CMD_RET_SUCCESS; +} + +static int do_list(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct udevice *dev; + int ret, err = 0; + + printf("| ID | %-*.*s| %-*.*s| %s @ %s\n", + LIMIT_DEV, LIMIT_DEV, "Name", + LIMIT_PARENT, LIMIT_PARENT, "Parent name", + "Parent uclass", "seq"); + + for (ret = uclass_first_device_check(UCLASS_TCPM, &dev); dev; + ret = uclass_next_device_check(&dev)) { + if (ret) + err = ret; + + printf("| %2d | %-*.*s| %-*.*s| %s @ %d | status: %i\n", + dev_seq(dev), + LIMIT_DEV, LIMIT_DEV, dev->name, + LIMIT_PARENT, LIMIT_PARENT, dev->parent->name, + dev_get_uclass_name(dev->parent), dev_seq(dev->parent), + ret); + } + + if (err) + return CMD_RET_FAILURE; + + return CMD_RET_SUCCESS; +} + +int do_print_info(struct udevice *dev) +{ + enum typec_orientation orientation = tcpm_get_orientation(dev); + const char *state = tcpm_get_state(dev); + int pd_rev = tcpm_get_pd_rev(dev); + int mv = tcpm_get_voltage(dev); + int ma = tcpm_get_current(dev); + enum typec_role pwr_role = tcpm_get_pwr_role(dev); + enum typec_data_role data_role = tcpm_get_data_role(dev); + bool connected = tcpm_is_connected(dev); + + if (!connected) { + printf("TCPM State: %s\n", state); + return 0; + } + + printf("Orientation: %s\n", typec_orientation_name[orientation]); + printf("PD Revision: %s\n", typec_pd_rev_name[pd_rev]); + printf("Power Role: %s\n", typec_role_name[pwr_role]); + printf("Data Role: %s\n", typec_data_role_name[data_role]); + printf("Voltage: %2d.%03d V\n", mv / 1000, mv % 1000); + printf("Current: %2d.%03d A\n", ma / 1000, ma % 1000); + + return 0; +} + +static int do_info(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + if (!currdev) { + printf("First, set the TCPM device!\n"); + return CMD_RET_USAGE; + } + + return do_print_info(currdev); +} + +static struct cmd_tbl subcmd[] = { + U_BOOT_CMD_MKENT(dev, 2, 1, do_dev, "", ""), + U_BOOT_CMD_MKENT(list, 1, 1, do_list, "", ""), + U_BOOT_CMD_MKENT(info, 1, 1, do_info, "", ""), +}; + +static int do_tcpm(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct cmd_tbl *cmd; + + argc--; + argv++; + + cmd = find_cmd_tbl(argv[0], subcmd, ARRAY_SIZE(subcmd)); + if (!cmd || argc > cmd->maxargs) + return CMD_RET_USAGE; + + return cmd->cmd(cmdtp, flag, argc, argv); +} + + /**************************************************/ + +U_BOOT_CMD(tcpm, CONFIG_SYS_MAXARGS, 1, do_tcpm, + "TCPM sub-system", + "list - list TCPM devices\n" + "tcpm dev [ID] - show or [set] operating TCPM device\n" + "tcpm info - dump information\n" +); diff --git a/cmd/ubi.c b/cmd/ubi.c index 0e62e449327..56d7da82629 100644 --- a/cmd/ubi.c +++ b/cmd/ubi.c @@ -14,6 +14,7 @@ #include <command.h> #include <env.h> #include <exports.h> +#include <led.h> #include <malloc.h> #include <memalign.h> #include <mtd.h> @@ -488,10 +489,18 @@ exit: int ubi_volume_write(char *volume, void *buf, loff_t offset, size_t size) { + int ret; + + led_activity_blink(); + if (!offset) - return ubi_volume_begin_write(volume, buf, size, size); + ret = ubi_volume_begin_write(volume, buf, size, size); + else + ret = ubi_volume_offset_write(volume, buf, offset, size); - return ubi_volume_offset_write(volume, buf, offset, size); + led_activity_off(); + + return ret; } int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size) diff --git a/cmd/upl.c b/cmd/upl.c index c9745886507..4996f36c787 100644 --- a/cmd/upl.c +++ b/cmd/upl.c @@ -72,7 +72,7 @@ static int do_upl_write(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } addr = map_to_sysmem(abuf_data(&buf)); - printf("UPL handoff written to %lx size %lx\n", addr, abuf_size(&buf)); + printf("UPL handoff written to %lx size %zx\n", addr, abuf_size(&buf)); if (env_set_hex("upladdr", addr) || env_set_hex("uplsize", abuf_size(&buf))) { printf("Cannot set env var\n"); diff --git a/cmd/x86/Makefile b/cmd/x86/Makefile index b1f39d3bfde..925215235d3 100644 --- a/cmd/x86/Makefile +++ b/cmd/x86/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ obj-$(CONFIG_CMD_CBSYSINFO) += cbsysinfo.o -obj-y += mtrr.o +obj-y += cpuid.o msr.o mtrr.o obj-$(CONFIG_CMD_EXCEPTION) += exception.o obj-$(CONFIG_USE_HOB) += hob.o obj-$(CONFIG_HAVE_FSP) += fsp.o diff --git a/cmd/x86/cpuid.c b/cmd/x86/cpuid.c new file mode 100644 index 00000000000..222754b5d15 --- /dev/null +++ b/cmd/x86/cpuid.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * The 'cpuid' command provides access to the CPU's cpuid information + * + * Copyright 2024 Google, LLC + * Written by Simon Glass <sjg@chromium.org> + */ + +#include <command.h> +#include <vsprintf.h> +#include <asm/cpu.h> + +static int do_cpuid(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct cpuid_result res; + ulong op; + + if (argc < 2) + return CMD_RET_USAGE; + + op = hextoul(argv[1], NULL); + res = cpuid(op); + printf("eax %08x\n", res.eax); + printf("ebx %08x\n", res.ebx); + printf("ecx %08x\n", res.ecx); + printf("edx %08x\n", res.edx); + + return 0; +} + +U_BOOT_LONGHELP(cpuid, "Show CPU Identification information"); + +U_BOOT_CMD( + cpuid, 2, 1, do_cpuid, + "cpuid <op>", cpuid_help_text +); diff --git a/cmd/x86/msr.c b/cmd/x86/msr.c new file mode 100644 index 00000000000..3cb70d1f89a --- /dev/null +++ b/cmd/x86/msr.c @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * The 'cpuid' command provides access to the CPU's cpuid information + * + * Copyright 2024 Google, LLC + * Written by Simon Glass <sjg@chromium.org> + */ + +#include <command.h> +#include <vsprintf.h> +#include <asm/msr.h> + +static int do_read(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct msr_t msr; + ulong op; + + if (argc < 2) + return CMD_RET_USAGE; + + op = hextoul(argv[1], NULL); + msr = msr_read(op); + printf("%08x %08x\n", msr.hi, msr.lo); + + return 0; +} + +static int do_write(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct msr_t msr; + ulong op; + + if (argc < 4) + return CMD_RET_USAGE; + + op = hextoul(argv[1], NULL); + msr.hi = hextoul(argv[2], NULL); + msr.lo = hextoul(argv[3], NULL); + msr_write(op, msr); + + return 0; +} + +U_BOOT_LONGHELP(msr, + "read <op> - read a machine-status register (MSR) as <hi 32-bits> <lo 32-bits>\n" + "write <op< <hi> <lo> - write an MSR"); + +U_BOOT_CMD_WITH_SUBCMDS(msr, "Machine Status Registers", msr_help_text, + U_BOOT_CMD_MKENT(read, CONFIG_SYS_MAXARGS, 1, do_read, "", ""), + U_BOOT_CMD_MKENT(write, CONFIG_SYS_MAXARGS, 1, do_write, "", "")); |