summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig147
-rw-r--r--cmd/Makefile1
-rw-r--r--cmd/bdinfo.c2
-rw-r--r--cmd/binop.c176
-rw-r--r--cmd/bootefi.c233
-rw-r--r--cmd/cbfs.c2
-rw-r--r--cmd/elf.c8
-rw-r--r--cmd/ethsw.c1
-rw-r--r--cmd/net.c4
-rw-r--r--cmd/nvedit.c30
-rw-r--r--cmd/part.c75
-rw-r--r--cmd/sf.c2
-rw-r--r--cmd/ximg.c2
13 files changed, 529 insertions, 154 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 136836d146..bc1d2f31c0 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -423,10 +423,15 @@ endmenu
menu "Memory commands"
+config CMD_BINOP
+ bool "binop"
+ help
+ Compute binary operations (xor, or, and) of byte arrays of arbitrary
+ size from memory and store the result in memory or the environment.
+
config CMD_CRC32
bool "crc32"
select HASH
- default n if ARCH_SUNXI
default y
help
Compute CRC32.
@@ -528,6 +533,15 @@ config CMD_MEMTEST
help
Simple RAM read/write test.
+if CMD_MEMTEST
+
+config SYS_ALT_MEMTEST
+ bool "Alternative test"
+ help
+ Use a more complete alternative memory test.
+
+endif
+
config CMD_MX_CYCLIC
bool "mdc, mwc"
help
@@ -568,7 +582,6 @@ config CMD_LZMADEC
config CMD_UNZIP
bool "unzip"
- default n if ARCH_SUNXI
default y if CMD_BOOTI
help
Uncompress a zip-compressed memory region.
@@ -780,14 +793,12 @@ config CMD_I2C
config CMD_LOADB
bool "loadb"
- default n if ARCH_SUNXI
default y
help
Load a binary file over serial line.
config CMD_LOADS
bool "loads"
- default n if ARCH_SUNXI
default y
help
Load an S-Record file over serial line
@@ -1010,46 +1021,127 @@ config CMD_SETEXPR
endmenu
-menu "Network commands"
-
if NET
-config CMD_NET
- bool "bootp, tftpboot"
+menuconfig CMD_NET
+ bool "Network commands"
+ default y
+
+if CMD_NET
+
+config CMD_BOOTP
+ bool "bootp"
default y
help
- Network commands.
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 BOOTP_BOOTPATH
+ bool "Request & store 'rootpath' from BOOTP/DHCP server"
+ default y
+ depends on CMD_BOOTP
+ help
+ Even though the config is called BOOTP_BOOTPATH, it stores the
+ path in the variable 'rootpath'.
+
+config BOOTP_DNS
+ bool "Request & store 'dnsip' from BOOTP/DHCP server"
+ default y
+ depends on CMD_BOOTP
+ help
+ The primary DNS server is stored as 'dnsip'. If two servers are
+ returned, you must set BOOTP_DNS2 to store that second server IP
+ also.
+
+config BOOTP_DNS2
+ bool "Store 'dnsip2' from BOOTP/DHCP server"
+ depends on BOOTP_DNS
+ help
+ If a DHCP client requests the DNS server IP from a DHCP server,
+ it is possible that more than one DNS serverip is offered to the
+ client. If CONFIG_BOOTP_DNS2 is enabled, the secondary DNS
+ server IP will be stored in the additional environment
+ variable "dnsip2". The first DNS serverip is always
+ stored in the variable "dnsip", when BOOTP_DNS is defined.
+
+config BOOTP_GATEWAY
+ bool "Request & store 'gatewayip' from BOOTP/DHCP server"
+ default y
+ depends on CMD_BOOTP
+
+config BOOTP_HOSTNAME
+ bool "Request & store 'hostname' from BOOTP/DHCP server"
+ default y
+ depends on CMD_BOOTP
+ help
+ The name may or may not be qualified with the local domain name.
+
+config BOOTP_SUBNETMASK
+ bool "Request & store 'netmask' from BOOTP/DHCP server"
+ default y
+ depends on CMD_BOOTP
+
+config BOOTP_PXE
+ bool "Send PXE client arch to BOOTP/DHCP server"
+ default y
+ depends on CMD_BOOTP && CMD_PXE
+ help
+ Supported for ARM, ARM64, and x86 for now.
+
+config BOOTP_PXE_CLIENTARCH
+ hex
+ depends on BOOTP_PXE
+ default 0x16 if ARM64
+ default 0x15 if ARM
+ default 0 if X86
+
+config BOOTP_VCI_STRING
+ string
+ depends on CMD_BOOTP
+ default "U-Boot.armv7" if CPU_V7 || CPU_V7M
+ default "U-Boot.armv8" if ARM64
+ default "U-Boot.arm" if ARM
+ default "U-Boot"
+
+config CMD_TFTPBOOT
+ bool "tftpboot"
+ default y
+ help
tftpboot - boot image via network using TFTP protocol
config CMD_TFTPPUT
bool "tftp put"
+ depends on CMD_TFTPBOOT
help
TFTP put command, for uploading files to a server
config CMD_TFTPSRV
bool "tftpsrv"
+ depends on CMD_TFTPBOOT
help
Act as a TFTP server and boot the first received file
+config NET_TFTP_VARS
+ bool "Control TFTP timeout and count through environment"
+ depends on CMD_TFTPBOOT
+ default y
+ help
+ If set, allows controlling the TFTP timeout through the
+ environment variable tftptimeout, and the TFTP maximum
+ timeout count through the variable tftptimeoutcountmax.
+ If unset, timeout and maximum are hard-defined as 1 second
+ and 10 timouts per TFTP transfer.
+
config CMD_RARP
bool "rarpboot"
help
Boot image via network using RARP/TFTP protocol
-config CMD_DHCP
- bool "dhcp"
- depends on CMD_NET
- help
- Boot image via network using DHCP/TFTP protocol
-
-config CMD_PXE
- bool "pxe"
- depends on CMD_NET
- select MENU
- help
- Boot image via network using PXE protocol
-
config CMD_NFS
bool "nfs"
default y
@@ -1086,6 +1178,8 @@ config CMD_LINK_LOCAL
help
Acquire a network IP address using the link-local protocol
+endif
+
config CMD_ETHSW
bool "ethsw"
help
@@ -1094,9 +1188,13 @@ config CMD_ETHSW
operations such as enabling / disabling a port and
viewing/maintaining the filtering database (FDB)
-endif
+config CMD_PXE
+ bool "pxe"
+ select MENU
+ help
+ Boot image via network using PXE protocol
-endmenu
+endif
menu "Misc commands"
@@ -1187,7 +1285,6 @@ config CMD_GETTIME
# TODO: rename to CMD_SLEEP
config CMD_MISC
bool "sleep"
- default n if ARCH_SUNXI
default y
help
Delay execution for some time
diff --git a/cmd/Makefile b/cmd/Makefile
index 9a358e4801..c4269ac8ac 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_SOURCE) += source.o
obj-$(CONFIG_CMD_SOURCE) += source.o
obj-$(CONFIG_CMD_BDI) += bdinfo.o
obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
+obj-$(CONFIG_CMD_BINOP) += binop.o
obj-$(CONFIG_CMD_BLOCK_CACHE) += blkcache.o
obj-$(CONFIG_CMD_BMP) += bmp.o
obj-$(CONFIG_CMD_BOOTEFI) += bootefi.o
diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index de6fc48987..7bea9b7a2d 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -180,7 +180,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
print_bi_flash(bd);
print_num("sramstart", bd->bi_sramstart);
print_num("sramsize", bd->bi_sramsize);
-#if defined(CONFIG_8xx) || defined(CONFIG_E500)
+#if defined(CONFIG_MPC8xx) || defined(CONFIG_E500)
print_num("immr_base", bd->bi_immr_base);
#endif
print_num("bootflags", bd->bi_bootflags);
diff --git a/cmd/binop.c b/cmd/binop.c
new file mode 100644
index 0000000000..0002c66609
--- /dev/null
+++ b/cmd/binop.c
@@ -0,0 +1,176 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+#include <malloc.h>
+#include <mapmem.h>
+#include <linux/ctype.h>
+
+enum {
+ OP_ID_XOR,
+ OP_ID_AND,
+ OP_ID_OR,
+};
+
+void write_to_env_var(char *varname, u8 *result, ulong len)
+{
+ char *str_output;
+ char *str_ptr;
+ int i;
+
+ str_output = malloc(len * 2 + 1);
+ str_ptr = str_output;
+
+ for (i = 0; i < len; i++) {
+ sprintf(str_ptr, "%02x", result[i]);
+ str_ptr += 2;
+ }
+ *str_ptr = '\0';
+ setenv(varname, str_output);
+
+ free(str_output);
+}
+
+void decode_hexstring(char *hexstr, u8 *result)
+{
+ int i;
+ int acc = 0;
+
+ for (i = 0; i < strlen(hexstr); ++i) {
+ char d = hexstr[i];
+ int value;
+
+ if (isdigit(d))
+ value = (d - '0');
+ else
+ value = (islower(d) ? toupper(d) : d) - 'A' + 10;
+
+ if (i % 2 == 0) {
+ acc = value * 16;
+ } else {
+ result[i / 2] = acc + value;
+ acc = 0;
+ }
+ }
+}
+
+void read_from_env_var(char *varname, u8 *result)
+{
+ char *str_value;
+
+ str_value = getenv(varname);
+ if (str_value)
+ decode_hexstring(str_value, result);
+ else
+ decode_hexstring(varname, result);
+}
+
+void read_from_mem(ulong addr, u8 *result, ulong len)
+{
+ u8 *src;
+
+ src = map_sysmem(addr, len);
+ memcpy(result, src, len);
+ unmap_sysmem(src);
+}
+
+void write_to_mem(char *varname, u8 *result, ulong len)
+{
+ ulong addr;
+ u8 *buf;
+
+ addr = simple_strtoul(varname, NULL, 16);
+ buf = map_sysmem(addr, len);
+ memcpy(buf, result, len);
+ unmap_sysmem(buf);
+}
+
+static int do_binop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ ulong len;
+ u8 *result, *src1, *src2;
+ char *oparg, *lenarg, *src1arg, *src2arg, *destarg;
+ int i, op;
+
+ if (argc < 5)
+ return CMD_RET_USAGE;
+
+ oparg = argv[1];
+ lenarg = argv[2];
+ src1arg = argv[3];
+ src2arg = argv[4];
+
+ if (!strcmp(oparg, "xor"))
+ op = OP_ID_XOR;
+ else if (!strcmp(oparg, "or"))
+ op = OP_ID_OR;
+ else if (!strcmp(oparg, "and"))
+ op = OP_ID_AND;
+ else
+ return CMD_RET_USAGE;
+
+ len = simple_strtoul(lenarg, NULL, 10);
+
+ src1 = malloc(len);
+ src2 = malloc(len);
+
+ if (*src1arg == '*')
+ read_from_mem(simple_strtoul(src1arg + 1, NULL, 16), src1, len);
+ else
+ read_from_env_var(src1arg, src1);
+
+ if (*src2arg == '*')
+ read_from_mem(simple_strtoul(src2arg + 1, NULL, 16), src2, len);
+ else
+ read_from_env_var(src2arg, src2);
+
+ result = malloc(len);
+
+ switch (op) {
+ case OP_ID_XOR:
+ for (i = 0; i < len; i++)
+ result[i] = src1[i] ^ src2[i];
+ break;
+ case OP_ID_OR:
+ for (i = 0; i < len; i++)
+ result[i] = src1[i] | src2[i];
+ break;
+ case OP_ID_AND:
+ for (i = 0; i < len; i++)
+ result[i] = src1[i] & src2[i];
+ break;
+ }
+
+ if (argc == 5) {
+ for (i = 0; i < len; i++) {
+ printf("%02x ", result[i]);
+ if (i % 16 == 15)
+ puts("\n");
+ }
+ puts("\n");
+
+ goto exit;
+ }
+
+ destarg = argv[5];
+
+ if (*destarg == '*')
+ write_to_mem(destarg + 1, result, len); /* Skip asterisk */
+ else
+ write_to_env_var(destarg, result, len);
+exit:
+ free(result);
+ free(src2);
+ free(src1);
+
+ return 0;
+}
+
+U_BOOT_CMD(
+ binop, 6, 1, do_binop,
+ "compute binary operation",
+ "op count [*]src1 [*]src2 [[*]dest]\n"
+ " - compute binary operation of data at/in src1 and\n src2 (either *memaddr, env var name or hex string)\n and store result in/at dest, where op is one of\n xor, or, and."
+);
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 6546272348..5498a5fccf 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -22,37 +22,65 @@
DECLARE_GLOBAL_DATA_PTR;
-static uint8_t efi_obj_list_initalized;
+#define OBJ_LIST_NOT_INITIALIZED 1
+
+static efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED;
static struct efi_device_path *bootefi_image_path;
static struct efi_device_path *bootefi_device_path;
/* Initialize and populate EFI object list */
-static void efi_init_obj_list(void)
+efi_status_t efi_init_obj_list(void)
{
- efi_obj_list_initalized = 1;
+ efi_status_t ret = EFI_SUCCESS;
+
+ /* Initialize once only */
+ if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
+ return efi_obj_list_initialized;
/* Initialize EFI driver uclass */
- efi_driver_init();
+ ret = efi_driver_init();
+ if (ret != EFI_SUCCESS)
+ goto out;
- efi_console_register();
+ ret = efi_console_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
#ifdef CONFIG_PARTITIONS
- efi_disk_register();
+ ret = efi_disk_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
#endif
#if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO)
- efi_gop_register();
+ ret = efi_gop_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
#endif
-#ifdef CONFIG_CMD_NET
- efi_net_register();
+#ifdef CONFIG_NET
+ ret = efi_net_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
#endif
#ifdef CONFIG_GENERATE_SMBIOS_TABLE
- efi_smbios_register();
+ ret = efi_smbios_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
#endif
- efi_watchdog_register();
+ ret = efi_watchdog_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
/* Initialize EFI runtime services */
- efi_reset_system_init();
- efi_get_time_init();
+ ret = efi_reset_system_init();
+ if (ret != EFI_SUCCESS)
+ goto out;
+ ret = efi_get_time_init();
+ if (ret != EFI_SUCCESS)
+ goto out;
+
+out:
+ efi_obj_list_initialized = ret;
+ return ret;
}
/*
@@ -150,24 +178,85 @@ static efi_status_t efi_run_in_el2(EFIAPI efi_status_t (*entry)(
}
#endif
+/* Carve out DT reserved memory ranges */
+static efi_status_t efi_carve_out_dt_rsv(void *fdt)
+{
+ int nr_rsv, i;
+ uint64_t addr, size, pages;
+
+ nr_rsv = fdt_num_mem_rsv(fdt);
+
+ /* Look for an existing entry and add it to the efi mem map. */
+ for (i = 0; i < nr_rsv; i++) {
+ if (fdt_get_mem_rsv(fdt, i, &addr, &size) != 0)
+ continue;
+
+ pages = ALIGN(size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT;
+ efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
+ false);
+ }
+
+ return EFI_SUCCESS;
+}
+
+static efi_status_t efi_install_fdt(void *fdt)
+{
+ bootm_headers_t img = { 0 };
+ ulong fdt_pages, fdt_size, fdt_start, fdt_end;
+ efi_status_t ret;
+
+ if (fdt_check_header(fdt)) {
+ printf("ERROR: invalid device tree\n");
+ return EFI_INVALID_PARAMETER;
+ }
+
+ /* Prepare fdt for payload */
+ fdt = copy_fdt(fdt);
+ if (!fdt)
+ return EFI_OUT_OF_RESOURCES;
+
+ if (image_setup_libfdt(&img, fdt, 0, NULL)) {
+ printf("ERROR: failed to process device tree\n");
+ return EFI_LOAD_ERROR;
+ }
+
+ if (efi_carve_out_dt_rsv(fdt) != EFI_SUCCESS) {
+ printf("ERROR: failed to carve out memory\n");
+ return EFI_LOAD_ERROR;
+ }
+
+ /* Link to it in the efi tables */
+ ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
+ if (ret != EFI_SUCCESS)
+ return EFI_OUT_OF_RESOURCES;
+
+ /* And reserve the space in the memory map */
+ fdt_start = ((ulong)fdt) & ~EFI_PAGE_MASK;
+ fdt_end = ((ulong)fdt) + fdt_totalsize(fdt);
+ fdt_size = (fdt_end - fdt_start) + EFI_PAGE_MASK;
+ fdt_pages = fdt_size >> EFI_PAGE_SHIFT;
+ /* Give a bootloader the chance to modify the device tree */
+ fdt_pages += 2;
+ ret = efi_add_memory_map(fdt_start, fdt_pages,
+ EFI_BOOT_SERVICES_DATA, true);
+ return ret;
+}
+
/*
* Load an EFI payload into a newly allocated piece of memory, register all
* EFI objects it would want to access and jump to it.
*/
-static efi_status_t do_bootefi_exec(void *efi, void *fdt,
+static efi_status_t do_bootefi_exec(void *efi,
struct efi_device_path *device_path,
struct efi_device_path *image_path)
{
struct efi_loaded_image loaded_image_info = {};
struct efi_object loaded_image_info_obj = {};
struct efi_device_path *memdp = NULL;
- ulong ret;
+ efi_status_t ret;
EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
struct efi_system_table *st);
- ulong fdt_pages, fdt_size, fdt_start, fdt_end;
- const efi_guid_t fdt_guid = EFI_FDT_GUID;
- bootm_headers_t img = { 0 };
/*
* Special case for efi payload not loaded from disk, such as
@@ -183,10 +272,6 @@ static efi_status_t do_bootefi_exec(void *efi, void *fdt,
assert(device_path && image_path);
}
- /* Initialize and populate EFI object list */
- if (!efi_obj_list_initalized)
- efi_init_obj_list();
-
efi_setup_loaded_image(&loaded_image_info, &loaded_image_info_obj,
device_path, image_path);
@@ -196,38 +281,12 @@ static efi_status_t do_bootefi_exec(void *efi, void *fdt,
*/
efi_save_gd();
- if (fdt && !fdt_check_header(fdt)) {
- /* Prepare fdt for payload */
- fdt = copy_fdt(fdt);
-
- if (image_setup_libfdt(&img, fdt, 0, NULL)) {
- printf("ERROR: Failed to process device tree\n");
- return -EINVAL;
- }
-
- /* Link to it in the efi tables */
- efi_install_configuration_table(&fdt_guid, fdt);
-
- /* And reserve the space in the memory map */
- fdt_start = ((ulong)fdt) & ~EFI_PAGE_MASK;
- fdt_end = ((ulong)fdt) + fdt_totalsize(fdt);
- fdt_size = (fdt_end - fdt_start) + EFI_PAGE_MASK;
- fdt_pages = fdt_size >> EFI_PAGE_SHIFT;
- /* Give a bootloader the chance to modify the device tree */
- fdt_pages += 2;
- efi_add_memory_map(fdt_start, fdt_pages,
- EFI_BOOT_SERVICES_DATA, true);
- } else {
- printf("WARNING: Invalid device tree, expect boot to fail\n");
- efi_install_configuration_table(&fdt_guid, NULL);
- }
-
/* Transfer environment variable bootargs as load options */
set_load_options(&loaded_image_info, "bootargs");
/* Load the EFI payload */
entry = efi_load_pe(efi, &loaded_image_info);
if (!entry) {
- ret = -ENOENT;
+ ret = EFI_LOAD_ERROR;
goto exit;
}
@@ -277,16 +336,12 @@ exit:
return ret;
}
-static int do_bootefi_bootmgr_exec(unsigned long fdt_addr)
+static int do_bootefi_bootmgr_exec(void)
{
struct efi_device_path *device_path, *file_path;
void *addr;
efi_status_t r;
- /* Initialize and populate EFI object list */
- if (!efi_obj_list_initalized)
- efi_init_obj_list();
-
/*
* gd lives in a fixed register which may get clobbered while we execute
* the payload. So save it here and restore it on every callback entry
@@ -298,7 +353,7 @@ static int do_bootefi_bootmgr_exec(unsigned long fdt_addr)
return 1;
printf("## Starting EFI application at %p ...\n", addr);
- r = do_bootefi_exec(addr, (void *)fdt_addr, device_path, file_path);
+ r = do_bootefi_exec(addr, device_path, file_path);
printf("## Application terminated, r = %lu\n",
r & ~EFI_ERROR_MASK);
@@ -311,12 +366,37 @@ static int do_bootefi_bootmgr_exec(unsigned long fdt_addr)
/* Interpreter command to boot an arbitrary EFI image from memory */
static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
- char *saddr, *sfdt;
- unsigned long addr, fdt_addr = 0;
+ unsigned long addr;
+ char *saddr;
efi_status_t r;
+ void *fdt_addr;
+
+ /* Initialize EFI drivers */
+ r = efi_init_obj_list();
+ if (r != EFI_SUCCESS) {
+ printf("Error: Cannot set up EFI drivers, r = %lu\n",
+ r & ~EFI_ERROR_MASK);
+ return CMD_RET_FAILURE;
+ }
if (argc < 2)
return CMD_RET_USAGE;
+
+ if (argc > 2) {
+ fdt_addr = (void *)simple_strtoul(argv[2], NULL, 16);
+ if (!fdt_addr && *argv[2] != '0')
+ return CMD_RET_USAGE;
+ /* Install device tree */
+ r = efi_install_fdt(fdt_addr);
+ if (r != EFI_SUCCESS) {
+ printf("ERROR: failed to install device tree\n");
+ return CMD_RET_FAILURE;
+ }
+ } else {
+ /* Remove device tree. EFI_NOT_FOUND can be ignored here */
+ efi_install_configuration_table(&efi_guid_fdt, NULL);
+ printf("WARNING: booting without device tree\n");
+ }
#ifdef CONFIG_CMD_BOOTEFI_HELLO
if (!strcmp(argv[1], "hello")) {
ulong size = __efi_helloworld_end - __efi_helloworld_begin;
@@ -350,8 +430,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
*/
efi_save_gd();
/* Initialize and populate EFI object list */
- if (!efi_obj_list_initalized)
- efi_init_obj_list();
+ efi_init_obj_list();
/* Transfer environment variable efi_selftest as load options */
set_load_options(&loaded_image_info, "efi_selftest");
/* Execute the test */
@@ -363,12 +442,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
} else
#endif
if (!strcmp(argv[1], "bootmgr")) {
- unsigned long fdt_addr = 0;
-
- if (argc > 2)
- fdt_addr = simple_strtoul(argv[2], NULL, 16);
-
- return do_bootefi_bootmgr_exec(fdt_addr);
+ return do_bootefi_bootmgr_exec();
} else {
saddr = argv[1];
@@ -377,15 +451,11 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (!addr && *saddr != '0')
return CMD_RET_USAGE;
- if (argc > 2) {
- sfdt = argv[2];
- fdt_addr = simple_strtoul(sfdt, NULL, 16);
- }
}
printf("## Starting EFI application at %08lx ...\n", addr);
- r = do_bootefi_exec((void *)addr, (void *)fdt_addr,
- bootefi_device_path, bootefi_image_path);
+ r = do_bootefi_exec((void *)addr, bootefi_device_path,
+ bootefi_image_path);
printf("## Application terminated, r = %lu\n",
r & ~EFI_ERROR_MASK);
@@ -406,7 +476,7 @@ static char bootefi_help_text[] =
" - boot a sample Hello World application stored within U-Boot\n"
#endif
#ifdef CONFIG_CMD_BOOTEFI_SELFTEST
- "bootefi selftest\n"
+ "bootefi selftest [fdt address]\n"
" - boot an EFI selftest application stored within U-Boot\n"
" Use environment variable efi_selftest to select a single test.\n"
" Use 'setenv efi_selftest list' to enumerate all tests.\n"
@@ -424,16 +494,6 @@ U_BOOT_CMD(
bootefi_help_text
);
-static int parse_partnum(const char *devnr)
-{
- const char *str = strchr(devnr, ':');
- if (str) {
- str++;
- return simple_strtoul(str, NULL, 16);
- }
- return 0;
-}
-
void efi_set_bootdev(const char *dev, const char *devnr, const char *path)
{
char filename[32] = { 0 }; /* dp->str is u16[32] long */
@@ -441,16 +501,17 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path)
if (strcmp(dev, "Net")) {
struct blk_desc *desc;
+ disk_partition_t fs_partition;
int part;
- desc = blk_get_dev(dev, simple_strtol(devnr, NULL, 10));
- if (!desc)
+ part = blk_get_device_part_str(dev, devnr, &desc, &fs_partition,
+ 1);
+ if (part < 0)
return;
- part = parse_partnum(devnr);
bootefi_device_path = efi_dp_from_part(desc, part);
} else {
-#ifdef CONFIG_CMD_NET
+#ifdef CONFIG_NET
bootefi_device_path = efi_dp_from_eth();
#endif
}
diff --git a/cmd/cbfs.c b/cmd/cbfs.c
index 799ba01fcc..736f8c4527 100644
--- a/cmd/cbfs.c
+++ b/cmd/cbfs.c
@@ -22,7 +22,7 @@ static int do_cbfs_init(cmd_tbl_t *cmdtp, int flag, int argc,
return 0;
}
if (argc == 2) {
- end_of_rom = (int)simple_strtoul(argv[1], &ep, 16);
+ end_of_rom = simple_strtoul(argv[1], &ep, 16);
if (*ep) {
puts("\n** Invalid end of ROM **\n");
return 1;
diff --git a/cmd/elf.c b/cmd/elf.c
index 5b59fc6329..19479bb706 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -16,6 +16,7 @@
#include <common.h>
#include <command.h>
#include <elf.h>
+#include <environment.h>
#include <net.h>
#include <vxworks.h>
#ifdef CONFIG_X86
@@ -361,13 +362,18 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
* binary image.
*/
if (valid_elf_image(addr))
- addr = load_elf_image_shdr(addr);
+ addr = load_elf_image_phdr(addr);
else
puts("## Not an ELF image, assuming binary\n");
printf("## Starting vxWorks at 0x%08lx ...\n", addr);
dcache_disable();
+#if defined(CONFIG_ARM64) && defined(CONFIG_ARMV8_PSCI)
+ armv8_setup_psci();
+ smp_kick_all_cpus();
+#endif
+
#ifdef CONFIG_X86
/* VxWorks on x86 uses stack to pass parameters */
((asmlinkage void (*)(int))addr)(0);
diff --git a/cmd/ethsw.c b/cmd/ethsw.c
index b600965e8a..92a60b4515 100644
--- a/cmd/ethsw.c
+++ b/cmd/ethsw.c
@@ -8,6 +8,7 @@
#include <common.h>
#include <command.h>
+#include <environment.h>
#include <errno.h>
#include <env_flags.h>
#include <ethsw.h>
diff --git a/cmd/net.c b/cmd/net.c
index d7c776aacf..67888d4e18 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -14,6 +14,7 @@
static int netboot_common(enum proto_t, cmd_tbl_t *, int, char * const []);
+#ifdef CONFIG_CMD_BOOTP
static int do_bootp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
return netboot_common(BOOTP, cmdtp, argc, argv);
@@ -24,7 +25,9 @@ U_BOOT_CMD(
"boot image via network using BOOTP/TFTP protocol",
"[loadAddress] [[hostIPaddr:]bootfilename]"
);
+#endif
+#ifdef CONFIG_CMD_TFTPBOOT
int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
int ret;
@@ -40,6 +43,7 @@ U_BOOT_CMD(
"boot image via network using TFTP protocol",
"[loadAddress] [[hostIPaddr:]bootfilename]"
);
+#endif
#ifdef CONFIG_CMD_TFTPPUT
static int do_tftpput(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 4cb25b8248..9838678262 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -341,6 +341,36 @@ ulong env_get_hex(const char *varname, ulong default_val)
return value;
}
+void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr)
+{
+ char *end;
+ int i;
+
+ for (i = 0; i < 6; ++i) {
+ enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0;
+ if (addr)
+ addr = (*end) ? end + 1 : end;
+ }
+}
+
+int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr)
+{
+ eth_parse_enetaddr(env_get(name), enetaddr);
+ return is_valid_ethaddr(enetaddr);
+}
+
+int eth_env_set_enetaddr(const char *name, const uint8_t *enetaddr)
+{
+ char buf[ARP_HLEN_ASCII + 1];
+
+ if (eth_env_get_enetaddr(name, (uint8_t *)buf))
+ return -EEXIST;
+
+ sprintf(buf, "%pM", enetaddr);
+
+ return env_set(name, buf);
+}
+
#ifndef CONFIG_SPL_BUILD
static int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
diff --git a/cmd/part.c b/cmd/part.c
index 746bf40b2d..ec791fdc5d 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -22,6 +22,11 @@
#include <part.h>
#include <vsprintf.h>
+enum cmd_part_info {
+ CMD_PART_INFO_START = 0,
+ CMD_PART_INFO_SIZE,
+};
+
static int do_part_uuid(int argc, char * const argv[])
{
int part;
@@ -108,11 +113,12 @@ static int do_part_list(int argc, char * const argv[])
return 0;
}
-static int do_part_start(int argc, char * const argv[])
+static int do_part_info(int argc, char * const argv[], enum cmd_part_info param)
{
struct blk_desc *desc;
disk_partition_t info;
char buf[512] = { 0 };
+ char *endp;
int part;
int err;
int ret;
@@ -122,17 +128,32 @@ static int do_part_start(int argc, char * const argv[])
if (argc > 4)
return CMD_RET_USAGE;
- part = simple_strtoul(argv[2], NULL, 0);
-
ret = blk_get_device_by_str(argv[0], argv[1], &desc);
if (ret < 0)
return 1;
- err = part_get_info(desc, part, &info);
- if (err)
- return 1;
+ part = simple_strtoul(argv[2], &endp, 0);
+ if (*endp == '\0') {
+ err = part_get_info(desc, part, &info);
+ if (err)
+ return 1;
+ } else {
+ part = part_get_info_by_name(desc, argv[2], &info);
+ if (part == -1)
+ return 1;
+ }
- snprintf(buf, sizeof(buf), LBAF, info.start);
+ switch (param) {
+ case CMD_PART_INFO_START:
+ snprintf(buf, sizeof(buf), LBAF, info.start);
+ break;
+ case CMD_PART_INFO_SIZE:
+ snprintf(buf, sizeof(buf), LBAF, info.size);
+ break;
+ default:
+ printf("** Unknown cmd_part_info value: %d\n", param);
+ return 1;
+ }
if (argc > 3)
env_set(argv[3], buf);
@@ -142,38 +163,14 @@ static int do_part_start(int argc, char * const argv[])
return 0;
}
-static int do_part_size(int argc, char * const argv[])
+static int do_part_start(int argc, char * const argv[])
{
- struct blk_desc *desc;
- disk_partition_t info;
- char buf[512] = { 0 };
- int part;
- int err;
- int ret;
-
- if (argc < 3)
- return CMD_RET_USAGE;
- if (argc > 4)
- return CMD_RET_USAGE;
-
- part = simple_strtoul(argv[2], NULL, 0);
-
- ret = blk_get_device_by_str(argv[0], argv[1], &desc);
- if (ret < 0)
- return 1;
-
- err = part_get_info(desc, part, &info);
- if (err)
- return 1;
-
- snprintf(buf, sizeof(buf), LBAF, info.size);
-
- if (argc > 3)
- env_set(argv[3], buf);
- else
- printf("%s\n", buf);
+ return do_part_info(argc, argv, CMD_PART_INFO_START);
+}
- return 0;
+static int do_part_size(int argc, char * const argv[])
+{
+ return do_part_info(argc, argv, CMD_PART_INFO_SIZE);
}
static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
@@ -207,6 +204,8 @@ U_BOOT_CMD(
" flags can be -bootable (list only bootable partitions)\n"
"part start <interface> <dev> <part> <varname>\n"
" - set environment variable to the start of the partition (in blocks)\n"
+ " part can be either partition number or partition name\n"
"part size <interface> <dev> <part> <varname>\n"
- " - set environment variable to the size of the partition (in blocks)"
+ " - set environment variable to the size of the partition (in blocks)\n"
+ " part can be either partition number or partition name"
);
diff --git a/cmd/sf.c b/cmd/sf.c
index f971eec781..e7ff9a6462 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -287,7 +287,7 @@ static int do_spi_flash_read_write(int argc, char * const argv[])
}
buf = map_physmem(addr, len, MAP_WRBACK);
- if (!buf) {
+ if (!buf && addr) {
puts("Failed to map physical memory\n");
return 1;
}
diff --git a/cmd/ximg.c b/cmd/ximg.c
index 21b5c37721..069c6ad39a 100644
--- a/cmd/ximg.c
+++ b/cmd/ximg.c
@@ -249,7 +249,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
puts("OK\n");
}
- flush_cache(dest, len);
+ flush_cache(dest, ALIGN(len, ARCH_DMA_MINALIGN));
env_set_hex("fileaddr", data);
env_set_hex("filesize", len);