summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2017-09-15 10:06:11 +0200
committerAlexander Graf <agraf@suse.de>2017-09-18 23:53:57 +0200
commit623b3a579765f8e05723bd1eff6f8c7e56d33922 (patch)
tree6c51f2a6aa341c2e6c424201f48630d7c9c61f1c /cmd
parentea630ce9eae4858a2108bd019a6ef22e2bc1b3f6 (diff)
efi_selftest: provide an EFI selftest application
A testing framework for the EFI API is provided. It can be executed with the 'bootefi selftest' command. It is coded in a way that at a later stage we may turn it into a standalone EFI application. The current build system does not allow this yet. All tests use a driver model and are run in three phases: setup, execute, teardown. A test may be setup and executed at boottime, it may be setup at boottime and executed at runtime, or it may be setup and executed at runtime. After executing all tests the system is reset. 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/Kconfig2
-rw-r--r--cmd/bootefi.c25
2 files changed, 24 insertions, 3 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index d6d130edfa..3ef9b16b08 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -222,6 +222,8 @@ config CMD_BOOTEFI_HELLO
for testing that EFI is working at a basic level, and for bringing
up EFI support on a new architecture.
+source lib/efi_selftest/Kconfig
+
config CMD_BOOTMENU
bool "bootmenu"
select MENU
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index ffd50ba159..788f869479 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -285,7 +285,6 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt)
return efi_do_enter(&loaded_image_info, &systab, entry);
}
-
/* 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[])
{
@@ -307,6 +306,22 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
memcpy((char *)addr, __efi_helloworld_begin, size);
} else
#endif
+#ifdef CONFIG_CMD_BOOTEFI_SELFTEST
+ if (!strcmp(argv[1], "selftest")) {
+ /*
+ * 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
+ */
+ efi_save_gd();
+ /* Initialize and populate EFI object list */
+ if (!efi_obj_list_initalized)
+ efi_init_obj_list();
+ loaded_image_info.device_handle = bootefi_device_path;
+ loaded_image_info.file_path = bootefi_image_path;
+ return efi_selftest(&loaded_image_info, &systab);
+ } else
+#endif
{
saddr = argv[1];
@@ -336,8 +351,12 @@ static char bootefi_help_text[] =
" If specified, the device tree located at <fdt address> gets\n"
" exposed as EFI configuration table.\n"
#ifdef CONFIG_CMD_BOOTEFI_HELLO
- "hello\n"
- " - boot a sample Hello World application stored within U-Boot"
+ "bootefi hello\n"
+ " - boot a sample Hello World application stored within U-Boot\n"
+#endif
+#ifdef CONFIG_CMD_BOOTEFI_SELFTEST
+ "bootefi selftest\n"
+ " - boot an EFI selftest application stored within U-Boot\n"
#endif
;
#endif