summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig21
-rw-r--r--cmd/bootefi.c90
-rw-r--r--cmd/net.c6
-rw-r--r--cmd/tpm-common.c24
-rw-r--r--cmd/tpm-v1.c2
-rw-r--r--cmd/tpm-v2.c4
6 files changed, 113 insertions, 34 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 0cf530d923..ef43ed8dda 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -152,8 +152,8 @@ config CMD_BDI
config CMD_CONFIG
bool "config"
- select BUILD_BIN2C
default SANDBOX
+ select BUILD_BIN2C
help
Print ".config" contents.
@@ -429,8 +429,8 @@ config CMD_BINOP
config CMD_CRC32
bool "crc32"
- select HASH
default y
+ select HASH
help
Compute CRC32.
@@ -640,7 +640,6 @@ config CMD_DFU
config CMD_DM
bool "dm - Access to driver model information"
depends on DM
- default y
help
Provides access to driver model data structures and information,
such as a list of devices, list of uclasses and the state of each
@@ -737,9 +736,9 @@ config CMD_GPIO
config CMD_GPT
bool "GPT (GUID Partition Table) command"
- select PARTITION_UUIDS
select EFI_PARTITION
select HAVE_BLOCK_DEVICE
+ select PARTITION_UUIDS
imply RANDOM_UUID
help
Enable the 'gpt' command to ready and write GPT style partition
@@ -899,8 +898,8 @@ config CMD_ONENAND
config CMD_PART
bool "part"
- select PARTITION_UUIDS
select HAVE_BLOCK_DEVICE
+ select PARTITION_UUIDS
help
Read and display information about the partition table on
various media.
@@ -1012,11 +1011,12 @@ config CMD_USB_SDP
help
Enables the command "sdp" which is used to have U-Boot emulating the
Serial Download Protocol (SDP) via USB.
+
config CMD_ROCKUSB
bool "rockusb"
depends on USB_FUNCTION_ROCKUSB
help
- Rockusb protocol is widely used by Rockchip SoC based devices. It can
+ Rockusb protocol is widely used by Rockchip SoC based devices. It can
read/write info, image to/from devices. This enable rockusb command
support to communication with rockusb device. for more detail about
this command, please read doc/README.rockusb.
@@ -1489,7 +1489,7 @@ config CMD_BLOB
the original data.
Sub-commands:
- blob enc - encapsulating data as a cryptgraphic blob
+ blob enc - encapsulating data as a cryptgraphic blob
blob dec - decapsulating cryptgraphic blob to get the data
Syntax:
@@ -1544,6 +1544,7 @@ config CMD_TPM_V1
config CMD_TPM_V2
bool
+ select CMD_LOG
config CMD_TPM
bool "Enable the 'tpm' command"
@@ -1797,10 +1798,10 @@ endmenu
config CMD_UBI
tristate "Enable UBI - Unsorted block images commands"
+ default y if NAND_SUNXI
+ select CMD_MTDPARTS
select CRC32
select MTD_UBI
- select CMD_MTDPARTS
- default y if NAND_SUNXI
help
UBI is a software layer above MTD layer which admits use of LVM-like
logical volumes on top of MTD devices, hides some complexities of
@@ -1812,9 +1813,9 @@ config CMD_UBI
config CMD_UBIFS
tristate "Enable UBIFS - Unsorted block images filesystem commands"
depends on CMD_UBI
+ default y if CMD_UBI
select CRC32
select LZO
- default y if CMD_UBI
help
UBIFS is a file system for flash devices which works on top of UBI.
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index cd755b6bf4..b60c151fb4 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -14,12 +14,18 @@
#include <errno.h>
#include <linux/libfdt.h>
#include <linux/libfdt_env.h>
+#include <mapmem.h>
#include <memalign.h>
#include <asm/global_data.h>
#include <asm-generic/sections.h>
#include <asm-generic/unaligned.h>
#include <linux/linkage.h>
+#ifdef CONFIG_ARMV7_NONSEC
+#include <asm/armv7.h>
+#include <asm/secure.h>
+#endif
+
DECLARE_GLOBAL_DATA_PTR;
#define OBJ_LIST_NOT_INITIALIZED 1
@@ -38,6 +44,11 @@ efi_status_t efi_init_obj_list(void)
if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
return efi_obj_list_initialized;
+ /* Initialize system table */
+ ret = efi_initialize_system_table();
+ if (ret != EFI_SUCCESS)
+ goto out;
+
/* Initialize EFI driver uclass */
ret = efi_driver_init();
if (ret != EFI_SUCCESS)
@@ -79,9 +90,6 @@ efi_status_t efi_init_obj_list(void)
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;
@@ -142,8 +150,12 @@ static void *copy_fdt(void *fdt)
fdt_ram_start = ram_start;
}
- /* Give us at least 4kb breathing room */
- fdt_size = ALIGN(fdt_size + 4096, EFI_PAGE_SIZE);
+ /*
+ * Give us at least 4KB of breathing room in case the device tree needs
+ * to be expanded later. Round up to the nearest EFI page boundary.
+ */
+ fdt_size += 4096;
+ fdt_size = ALIGN(fdt_size + EFI_PAGE_SIZE - 1, EFI_PAGE_SIZE);
fdt_pages = fdt_size >> EFI_PAGE_SHIFT;
/* Safe fdt location is at 128MB */
@@ -194,8 +206,32 @@ 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)
+#ifdef CONFIG_ARMV7_NONSEC
+static bool is_nonsec;
+
+static efi_status_t efi_run_in_hyp(EFIAPI efi_status_t (*entry)(
+ efi_handle_t image_handle, struct efi_system_table *st),
+ efi_handle_t image_handle, struct efi_system_table *st)
+{
+ /* Enable caches again */
+ dcache_enable();
+
+ is_nonsec = true;
+
+ return efi_do_enter(image_handle, st, entry);
+}
+#endif
+
+/*
+ * efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges
+ *
+ * The mem_rsv entries of the FDT are added to the memory map. Any failures are
+ * ignored because this is not critical and we would rather continue to try to
+ * boot.
+ *
+ * @fdt: Pointer to device tree
+ */
+static void efi_carve_out_dt_rsv(void *fdt)
{
int nr_rsv, i;
uint64_t addr, size, pages;
@@ -208,11 +244,10 @@ static efi_status_t efi_carve_out_dt_rsv(void *fdt)
continue;
pages = ALIGN(size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT;
- efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
- false);
+ if (!efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
+ false))
+ printf("FDT memrsv map %d: Failed to add to map\n", i);
}
-
- return EFI_SUCCESS;
}
static efi_status_t efi_install_fdt(void *fdt)
@@ -236,10 +271,7 @@ static efi_status_t efi_install_fdt(void *fdt)
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;
- }
+ efi_carve_out_dt_rsv(fdt);
/* Link to it in the efi tables */
ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
@@ -350,6 +382,22 @@ static efi_status_t do_bootefi_exec(void *efi,
}
#endif
+#ifdef CONFIG_ARMV7_NONSEC
+ if (armv7_boot_nonsec() && !is_nonsec) {
+ dcache_disable(); /* flush cache before switch to HYP */
+
+ armv7_init_nonsec();
+ secure_ram_addr(_do_nonsec_entry)(
+ efi_run_in_hyp,
+ (uintptr_t)entry,
+ (uintptr_t)loaded_image_info_obj.handle,
+ (uintptr_t)&systab);
+
+ /* Should never reach here, efi exits with longjmp */
+ while (1) { }
+ }
+#endif
+
ret = efi_do_enter(loaded_image_info_obj.handle, &systab, entry);
exit:
@@ -394,7 +442,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
unsigned long addr;
char *saddr;
efi_status_t r;
- void *fdt_addr;
+ unsigned long fdt_addr;
+ void *fdt;
/* Allow unaligned memory access */
allow_unaligned();
@@ -411,11 +460,12 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return CMD_RET_USAGE;
if (argc > 2) {
- fdt_addr = (void *)simple_strtoul(argv[2], NULL, 16);
+ fdt_addr = 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);
+ fdt = map_sysmem(fdt_addr, 0);
+ r = efi_install_fdt(fdt);
if (r != EFI_SUCCESS) {
printf("ERROR: failed to install device tree\n");
return CMD_RET_FAILURE;
@@ -434,7 +484,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
addr = simple_strtoul(saddr, NULL, 16);
else
addr = CONFIG_SYS_LOAD_ADDR;
- memcpy((char *)addr, __efi_helloworld_begin, size);
+ memcpy(map_sysmem(addr, size), __efi_helloworld_begin, size);
} else
#endif
#ifdef CONFIG_CMD_BOOTEFI_SELFTEST
@@ -480,7 +530,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
printf("## Starting EFI application at %08lx ...\n", addr);
- r = do_bootefi_exec((void *)addr, bootefi_device_path,
+ r = do_bootefi_exec(map_sysmem(addr, 0), bootefi_device_path,
bootefi_image_path);
printf("## Application terminated, r = %lu\n",
r & ~EFI_ERROR_MASK);
diff --git a/cmd/net.c b/cmd/net.c
index eca6dd8918..89721b8f8b 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -192,6 +192,9 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
switch (argc) {
case 1:
+ /* refresh bootfile name from env */
+ copy_filename(net_boot_file_name, env_get("bootfile"),
+ sizeof(net_boot_file_name));
break;
case 2: /*
@@ -203,6 +206,9 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
addr = simple_strtoul(argv[1], &end, 16);
if (end == (argv[1] + strlen(argv[1]))) {
load_addr = addr;
+ /* refresh bootfile name from env */
+ copy_filename(net_boot_file_name, env_get("bootfile"),
+ sizeof(net_boot_file_name));
} else {
net_boot_file_name_explicit = true;
copy_filename(net_boot_file_name, argv[1],
diff --git a/cmd/tpm-common.c b/cmd/tpm-common.c
index 6cf9fcc9ac..56443862c2 100644
--- a/cmd/tpm-common.c
+++ b/cmd/tpm-common.c
@@ -273,12 +273,34 @@ int do_tpm_init(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int do_tpm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
cmd_tbl_t *tpm_commands, *cmd;
+ struct tpm_chip_priv *priv;
+ struct udevice *dev;
unsigned int size;
+ int ret;
if (argc < 2)
return CMD_RET_USAGE;
- tpm_commands = get_tpm_commands(&size);
+ ret = get_tpm(&dev);
+ if (ret)
+ return ret;
+
+ priv = dev_get_uclass_priv(dev);
+
+ /* Below getters return NULL if the desired stack is not built */
+ switch (priv->version) {
+ case TPM_V1:
+ tpm_commands = get_tpm1_commands(&size);
+ break;
+ case TPM_V2:
+ tpm_commands = get_tpm2_commands(&size);
+ break;
+ default:
+ tpm_commands = NULL;
+ }
+
+ if (!tpm_commands)
+ return CMD_RET_USAGE;
cmd = find_cmd_tbl(argv[1], tpm_commands, size);
if (!cmd)
diff --git a/cmd/tpm-v1.c b/cmd/tpm-v1.c
index 0874c4d7ba..69870002d4 100644
--- a/cmd/tpm-v1.c
+++ b/cmd/tpm-v1.c
@@ -608,7 +608,7 @@ static cmd_tbl_t tpm1_commands[] = {
#endif /* CONFIG_TPM_LIST_RESOURCES */
};
-cmd_tbl_t *get_tpm_commands(unsigned int *size)
+cmd_tbl_t *get_tpm1_commands(unsigned int *size)
{
*size = ARRAY_SIZE(tpm1_commands);
diff --git a/cmd/tpm-v2.c b/cmd/tpm-v2.c
index 38add4f462..ffbf35a75c 100644
--- a/cmd/tpm-v2.c
+++ b/cmd/tpm-v2.c
@@ -319,14 +319,14 @@ static cmd_tbl_t tpm2_commands[] = {
do_tpm_pcr_setauthvalue, "", ""),
};
-cmd_tbl_t *get_tpm_commands(unsigned int *size)
+cmd_tbl_t *get_tpm2_commands(unsigned int *size)
{
*size = ARRAY_SIZE(tpm2_commands);
return tpm2_commands;
}
-U_BOOT_CMD(tpm, CONFIG_SYS_MAXARGS, 1, do_tpm, "Issue a TPMv2.x command",
+U_BOOT_CMD(tpm2, CONFIG_SYS_MAXARGS, 1, do_tpm, "Issue a TPMv2.x command",
"<command> [<arguments>]\n"
"\n"
"info\n"