@@ -492,6 +492,37 @@ static int do_bootefi_bootmgr_exec(int boot_id)
return CMD_RET_SUCCESS;
}
+/* Called by "run" command */
+int do_bootefi_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ int boot_id = -1;
+ char *endp;
+
+ if (argc > 2)
+ return CMD_RET_USAGE;
+
+ if (argc == 2) {
+ if (!strcmp(argv[1], "BootOrder")) {
+ boot_id = -1;
+ } else if (!strncmp(argv[2], "Boot", 4)) {
+ boot_id = (int)simple_strtoul(&argv[2][4], &endp, 0);
+ if ((argv[2] + strlen(argv[2]) != endp) ||
+ boot_id > 0xffff)
+ return CMD_RET_USAGE;
+ } else {
+ return CMD_RET_USAGE;
+ }
+ }
+
+ if (efi_init_obj_list())
+ return CMD_RET_FAILURE;
+
+ if (efi_handle_fdt(NULL))
+ return CMD_RET_FAILURE;
+
+ return do_bootefi_bootmgr_exec(boot_id);
+}
+
/* 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[])
{
@@ -1344,7 +1344,14 @@ U_BOOT_CMD_COMPLETE(
run, CONFIG_SYS_MAXARGS, 1, do_run,
"run commands in an environment variable",
"var [...]\n"
- " - run the commands in the environment variable(s) 'var'",
+ " - run the commands in the environment variable(s) 'var'"
+#if defined(CONFIG_CMD_BOOTEFI)
+ "\n"
+ "run -e [BootXXXX]\n"
+ " - load and run UEFI app based on 'BootXXXX' UEFI variable",
+#else
+ ,
+#endif
var_complete
);
#endif
@@ -12,6 +12,7 @@
#include <cli.h>
#include <cli_hush.h>
#include <console.h>
+#include <efi_loader.h>
#include <fdtdec.h>
#include <malloc.h>
@@ -125,6 +126,15 @@ int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (argc < 2)
return CMD_RET_USAGE;
+#ifdef CONFIG_CMD_BOOTEFI
+ if (!strcmp(argv[1], "-e")) {
+ argc--;
+ argv++;
+
+ return do_bootefi_run(cmdtp, flag, argc, argv);
+ }
+#endif
+
for (i = 1; i < argc; ++i) {
char *arg;
@@ -48,6 +48,9 @@ typedef struct cmd_tbl_s cmd_tbl_t;
#if defined(CONFIG_CMD_RUN)
extern int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
#endif
+#if defined(CONFIG_CMD_BOOTEFI)
+extern int do_bootefi_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+#endif
/* common/command.c */
int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
"run -e" allows for executing EFI application with a specific "BootXXXX" variable. If no "BootXXXX" is specified or "BootOrder" is specified, it tries to run an EFI application specified in the order of "bootOrder." Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> --- cmd/bootefi.c | 31 +++++++++++++++++++++++++++++++ cmd/nvedit.c | 9 ++++++++- common/cli.c | 10 ++++++++++ include/command.h | 3 +++ 4 files changed, 52 insertions(+), 1 deletion(-)