From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 5/5] cmd: run: add "-e" option to run an EFI application
Date: Tue, 25 Dec 2018 20:29:46 +0900 [thread overview]
Message-ID: <20181225112945.GI14405@linaro.org> (raw)
In-Reply-To: <f80afbbf-f029-3382-acce-eaa5b78a1a4b@suse.de>
On Sun, Dec 23, 2018 at 03:19:17AM +0100, Alexander Graf wrote:
>
>
> On 18.12.18 06:02, AKASHI Takahiro wrote:
> > "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 | 2 +-
> > cmd/nvedit.c | 5 +++++
> > common/cli.c | 31 +++++++++++++++++++++++++++++++
> > include/command.h | 3 +++
> > 4 files changed, 40 insertions(+), 1 deletion(-)
> >
> > diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> > index 2fc52e3056d2..8122793d11c5 100644
> > --- a/cmd/bootefi.c
> > +++ b/cmd/bootefi.c
> > @@ -471,7 +471,7 @@ static efi_status_t bootefi_test_prepare
> >
> > #endif /* CONFIG_CMD_BOOTEFI_SELFTEST */
> >
> > -static int do_bootefi_bootmgr_exec(int boot_id)
> > +int do_bootefi_bootmgr_exec(int boot_id)
> > {
> > struct efi_device_path *device_path, *file_path;
> > void *addr;
> > diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> > index de16c72c23f2..c0facabfc4fe 100644
> > --- a/cmd/nvedit.c
> > +++ b/cmd/nvedit.c
> > @@ -1343,8 +1343,13 @@ U_BOOT_CMD(
> > U_BOOT_CMD_COMPLETE(
> > run, CONFIG_SYS_MAXARGS, 1, do_run,
> > "run commands in an environment variable",
> > +#if defined(CONFIG_CMD_BOOTEFI)
> > + "var -e [BootXXXX]\n"
> > + " - load and run UEFI app based on 'BootXXXX' UEFI variable",
> > +#else
> > "var [...]\n"
> > " - run the commands in the environment variable(s) 'var'",
> > +#endif
> > var_complete
> > );
> > #endif
> > diff --git a/common/cli.c b/common/cli.c
> > index 51b8d5f85cbb..013dd2e51936 100644
> > --- a/common/cli.c
> > +++ b/common/cli.c
> > @@ -12,8 +12,10 @@
> > #include <cli.h>
> > #include <cli_hush.h>
> > #include <console.h>
> > +#include <efi_loader.h>
> > #include <fdtdec.h>
> > #include <malloc.h>
> > +#include "../cmd/bootefi.h"
> >
> > DECLARE_GLOBAL_DATA_PTR;
> >
> > @@ -125,6 +127,35 @@ 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")) {
> > + int boot_id = -1;
> > + char *endp;
> > +
> > + if (argc == 3) {
> > + if (!strcmp(argv[2], "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;
>
> This duplicates the same logic you added to bootefi.c. Better reuse it.
> I guess you can just call a function inside bootefi.c from here if you
> detect -e:
>
> if (!strcmp(argv[1], "-e"))
> return do_bootefi_run(cmdtp, flag, argc, argv);
>
> and just handle it all inside bootefi.c at that point.
Hmm, OK.
In this case, the command syntax of bootmgr will be changed so as to
accept "BootXXXX" instead of just an integer (as boot id).
Thanks,
-Takahiro Akashi
> > + } 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);
> > + }
> > +#endif
> > +
> > for (i = 1; i < argc; ++i) {
> > char *arg;
> >
> > diff --git a/include/command.h b/include/command.h
> > index 200c7a5e9f4e..9b7b876585d9 100644
> > --- a/include/command.h
> > +++ b/include/command.h
> > @@ -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)
> > +int do_bootefi_bootmgr_exec(int boot_id);
> > +#endif
>
> I would prefer if nvedit.c includes efi_loader.h and we define it there?
>
>
> Alex
next prev parent reply other threads:[~2018-12-25 11:29 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-18 5:02 [U-Boot] [PATCH 0/5] efi_loader: run a specific efi application more easily AKASHI Takahiro
2018-12-18 5:02 ` [U-Boot] [PATCH 1/5] efi_loader: bootmgr: support BootNext and BootCurrent variable behavior AKASHI Takahiro
2018-12-23 2:03 ` Alexander Graf
2018-12-25 9:36 ` AKASHI Takahiro
2018-12-26 21:23 ` Alexander Graf
2018-12-26 21:33 ` Heinrich Schuchardt
2018-12-26 21:41 ` Alexander Graf
2018-12-27 4:58 ` Heinrich Schuchardt
2019-01-07 6:58 ` AKASHI Takahiro
2018-12-18 5:02 ` [U-Boot] [PATCH 2/5] efi_loader: bootmgr: allow for running a given load option AKASHI Takahiro
2018-12-23 2:05 ` Alexander Graf
2018-12-25 9:44 ` AKASHI Takahiro
2018-12-18 5:02 ` [U-Boot] [PATCH 3/5] cmd: bootefi: carve out fdt parameter handling AKASHI Takahiro
2018-12-23 2:08 ` Alexander Graf
2018-12-25 9:48 ` AKASHI Takahiro
2018-12-18 5:02 ` [U-Boot] [PATCH 4/5] cmd: bootefi: run an EFI application of a specific load option AKASHI Takahiro
2018-12-23 2:15 ` Alexander Graf
2018-12-25 9:56 ` AKASHI Takahiro
2018-12-18 5:02 ` [U-Boot] [PATCH 5/5] cmd: run: add "-e" option to run an EFI application AKASHI Takahiro
2018-12-23 2:19 ` Alexander Graf
2018-12-25 11:29 ` AKASHI Takahiro [this message]
2018-12-26 21:24 ` Alexander Graf
2019-01-07 7:40 ` AKASHI Takahiro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181225112945.GI14405@linaro.org \
--to=takahiro.akashi@linaro.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox