aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2017-10-18 18:13:13 +0200
committerAlexander Graf <agraf@suse.de>2017-12-01 13:22:55 +0100
commitd78e40d651972ef061c960e4b7da7843383c2ec9 (patch)
tree141b41d60b1966f3f77ca6c7c6aaa4b8157e9cf2 /cmd
parent1f66a12e237f7ce9dc9b997e7ce0b2a33893ce12 (diff)
downloadu-boot-d78e40d651972ef061c960e4b7da7843383c2ec9.zip
u-boot-d78e40d651972ef061c960e4b7da7843383c2ec9.tar.gz
u-boot-d78e40d651972ef061c960e4b7da7843383c2ec9.tar.bz2
efi_selftest: allow to select a single test for execution
Environment variable efi_selftest is passed as load options to the selftest application. It is used to select a single test to be executed. The load options are an UTF8 string. Yet I decided to keep the name propertiy of the tests as char[] to reduce code size. Special value 'list' displays a list of all available tests. Tests get an on_request property. If this property is set the tests are only executed if explicitly requested. The invocation of efi_selftest is changed to reflect that bootefi selftest with efi_selftest = 'list' will call the Exit bootservice. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/bootefi.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 4935173..b894403 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -6,10 +6,12 @@
* SPDX-License-Identifier: GPL-2.0+
*/
+#include <charset.h>
#include <common.h>
#include <command.h>
#include <dm.h>
#include <efi_loader.h>
+#include <efi_selftest.h>
#include <errno.h>
#include <libfdt.h>
#include <libfdt_env.h>
@@ -50,6 +52,32 @@ static void efi_init_obj_list(void)
efi_get_time_init();
}
+/*
+ * Set the load options of an image from an environment variable.
+ *
+ * @loaded_image_info: the image
+ * @env_var: name of the environment variable
+ */
+static void set_load_options(struct efi_loaded_image *loaded_image_info,
+ const char *env_var)
+{
+ size_t size;
+ const char *env = env_get(env_var);
+
+ loaded_image_info->load_options = NULL;
+ loaded_image_info->load_options_size = 0;
+ if (!env)
+ return;
+ size = strlen(env) + 1;
+ loaded_image_info->load_options = calloc(size, sizeof(u16));
+ if (!loaded_image_info->load_options) {
+ printf("ERROR: Out of memory\n");
+ return;
+ }
+ utf8_to_utf16(loaded_image_info->load_options, (u8 *)env, size);
+ loaded_image_info->load_options_size = size * 2;
+}
+
static void *copy_fdt(void *fdt)
{
u64 fdt_size = fdt_totalsize(fdt);
@@ -317,7 +345,12 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/* Initialize and populate EFI object list */
if (!efi_obj_list_initalized)
efi_init_obj_list();
- return efi_selftest(&loaded_image_info, &systab);
+ /* Transfer environment variable efi_selftest as load options */
+ set_load_options(&loaded_image_info, "efi_selftest");
+ /* Execute the test */
+ r = efi_selftest(&loaded_image_info, &systab);
+ free(loaded_image_info.load_options);
+ return r;
} else
#endif
if (!strcmp(argv[1], "bootmgr")) {
@@ -363,6 +396,8 @@ static char bootefi_help_text[] =
#ifdef CONFIG_CMD_BOOTEFI_SELFTEST
"bootefi selftest\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"
#endif
"bootmgr [fdt addr]\n"
" - load and boot EFI payload based on BootOrder/BootXXXX variables.\n"