summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-05-18 08:17:29 -0400
committerTom Rini <trini@konsulko.com>2020-05-18 08:17:29 -0400
commited9a3aa6452f57af65eb74f73bd2a54c3a2f4b03 (patch)
tree360fcb8e12955e02f8454e5f901d7891cf4168b6 /cmd
parent515f613253cf0a892c3a321770ab927fa3d925cf (diff)
parent7f44c7e281ef228d60625f5acdcbe68a847256bd (diff)
Merge tag 'efi-2020-07-rc3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Pull request for UEFI sub-system for efi-2020-07-rc3 A series of patches introduces the possibility to manage UEFI variables via an OP-TEE module. CONFIG_EFI_MM_COMM_TEE enables this. If this option is not specified the U-Boot behavior remains unchanged. A defconfig is provided for compile testing (lx2160ardb_tfa_stmm_defconfig). An incorrect UEFI memory allocation for fsl-layerscape is fixed
Diffstat (limited to 'cmd')
-rw-r--r--cmd/bootefi.c8
-rw-r--r--cmd/efidebug.c58
2 files changed, 59 insertions, 7 deletions
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 06573b14e9..9849eb4f99 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -151,14 +151,10 @@ done:
static void efi_reserve_memory(u64 addr, u64 size)
{
- u64 pages;
-
/* Convert from sandbox address space. */
addr = (uintptr_t)map_sysmem(addr, 0);
- pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK));
- addr &= ~EFI_PAGE_MASK;
- if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
- false) != EFI_SUCCESS)
+ if (efi_add_memory_map(addr, size,
+ EFI_RESERVED_MEMORY_TYPE) != EFI_SUCCESS)
printf("Reserved memory mapping failed addr %llx size %llx\n",
addr, size);
}
diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 5cc0a41af3..f020d95dbb 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -1165,6 +1165,58 @@ static int do_efi_test(cmd_tbl_t *cmdtp, int flag,
return cp->cmd(cmdtp, flag, argc, argv);
}
+/**
+ * do_efi_query_info() - QueryVariableInfo EFI service
+ *
+ * @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 "test" sub-command.
+ */
+
+static int do_efi_query_info(cmd_tbl_t *cmdtp, int flag,
+ int argc, char * const argv[])
+{
+ efi_status_t ret;
+ u32 attr = 0;
+ u64 max_variable_storage_size;
+ u64 remain_variable_storage_size;
+ u64 max_variable_size;
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "-bs"))
+ attr |= EFI_VARIABLE_BOOTSERVICE_ACCESS;
+ else if (!strcmp(argv[i], "-rt"))
+ attr |= EFI_VARIABLE_RUNTIME_ACCESS;
+ else if (!strcmp(argv[i], "-nv"))
+ attr |= EFI_VARIABLE_NON_VOLATILE;
+ else if (!strcmp(argv[i], "-at"))
+ attr |=
+ EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
+ }
+
+ ret = EFI_CALL(efi_query_variable_info(attr,
+ &max_variable_storage_size,
+ &remain_variable_storage_size,
+ &max_variable_size));
+ if (ret != EFI_SUCCESS) {
+ printf("Error: Cannot query UEFI variables, r = %lu\n",
+ ret & ~EFI_ERROR_MASK);
+ return CMD_RET_FAILURE;
+ }
+
+ printf("Max storage size %llu\n", max_variable_storage_size);
+ printf("Remaining storage size %llu\n", remain_variable_storage_size);
+ printf("Max variable size %llu\n", max_variable_size);
+
+ return CMD_RET_SUCCESS;
+}
+
static cmd_tbl_t cmd_efidebug_sub[] = {
U_BOOT_CMD_MKENT(boot, CONFIG_SYS_MAXARGS, 1, do_efi_boot_opt, "", ""),
U_BOOT_CMD_MKENT(devices, CONFIG_SYS_MAXARGS, 1, do_efi_show_devices,
@@ -1181,6 +1233,8 @@ static cmd_tbl_t cmd_efidebug_sub[] = {
"", ""),
U_BOOT_CMD_MKENT(test, CONFIG_SYS_MAXARGS, 1, do_efi_test,
"", ""),
+ U_BOOT_CMD_MKENT(query, CONFIG_SYS_MAXARGS, 1, do_efi_query_info,
+ "", ""),
};
/**
@@ -1252,7 +1306,9 @@ static char efidebug_help_text[] =
"efidebug tables\n"
" - show UEFI configuration tables\n"
"efidebug test bootmgr\n"
- " - run simple bootmgr for test\n";
+ " - run simple bootmgr for test\n"
+ "efidebug query [-nv][-bs][-rt][-at]\n"
+ " - show size of UEFI variables store\n";
#endif
U_BOOT_CMD(