From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/5] cmd: bootefi: run an EFI application of a specific load option
Date: Tue, 25 Dec 2018 18:56:44 +0900 [thread overview]
Message-ID: <20181225095643.GH14405@linaro.org> (raw)
In-Reply-To: <97e52b4f-87f3-bd74-378e-d65a051bbb82@suse.de>
On Sun, Dec 23, 2018 at 03:15:16AM +0100, Alexander Graf wrote:
>
>
> On 18.12.18 06:02, AKASHI Takahiro wrote:
> > With this patch applied, we will be able to selectively execute
> > an EFI application by specifying a load option, say "1" for Boot0001,
> > "2" for Boot0002 and so on.
> >
> > => bootefi bootmgr <fdt addr> 1, or
> > bootefi bootmgr - 1
> >
> > Please note that BootXXXX need not be included in "BootOrder".
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> > cmd/bootefi.c | 26 +++++++++++++++++++-------
> > 1 file changed, 19 insertions(+), 7 deletions(-)
> >
> > diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> > index 796ca6ee69ec..2fc52e3056d2 100644
> > --- a/cmd/bootefi.c
> > +++ b/cmd/bootefi.c
> > @@ -471,13 +471,13 @@ static efi_status_t bootefi_test_prepare
> >
> > #endif /* CONFIG_CMD_BOOTEFI_SELFTEST */
> >
> > -static int do_bootefi_bootmgr_exec(void)
> > +static int do_bootefi_bootmgr_exec(int boot_id)
> > {
> > struct efi_device_path *device_path, *file_path;
> > void *addr;
> > efi_status_t r;
> >
> > - addr = efi_bootmgr_load(-1, &device_path, &file_path);
> > + addr = efi_bootmgr_load(boot_id, &device_path, &file_path);
> > if (!addr)
> > return 1;
> >
> > @@ -545,10 +545,22 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> > } else
> > #endif
> > if (!strcmp(argv[1], "bootmgr")) {
> > - if (efi_handle_fdt(argc > 2 ? argv[2] : NULL))
> > - return CMD_RET_FAILURE;
> > + char *endp;
> > + int boot_id = -1;
> > +
> > + if (argc > 2)
> > + if (efi_handle_fdt((argv[2][0] == '-') ?
> > + NULL : argv[2]))
> > + return CMD_RET_FAILURE;
>
> This is slowly getting quite unreadable. How about you make the code
> less dense, but easier to grasp?
>
>
> if (argc > 2) {
> const char *fdtstr = argv[2];
>
> /* Special address "-" means no device tree */
> if (fdtstr[0] == '-')
> fdtstr = NULL;
>
> r = efi_handle_fdt(fdtstr);
>
> if (r)
> return r;
> }
OK
-Takahiro Akashi
> Alex
>
> > +
> > + if (argc > 3) {
> > + boot_id = (int)simple_strtoul(argv[3], &endp, 0);
> > + if ((argv[3] + strlen(argv[3]) != endp) ||
> > + boot_id > 0xffff)
> > + return CMD_RET_USAGE;
> > + }
> >
> > - return do_bootefi_bootmgr_exec();
> > + return do_bootefi_bootmgr_exec(boot_id);
> > } else {
> > saddr = argv[1];
> >
> > @@ -589,7 +601,7 @@ static char bootefi_help_text[] =
> > " Use environment variable efi_selftest to select a single test.\n"
> > " Use 'setenv efi_selftest list' to enumerate all tests.\n"
> > #endif
> > - "bootefi bootmgr [fdt addr]\n"
> > + "bootefi bootmgr [<fdt addr>|'-' [<boot id>]]\n"
> > " - load and boot EFI payload based on BootOrder/BootXXXX variables.\n"
> > "\n"
> > " If specified, the device tree located at <fdt address> gets\n"
> > @@ -597,7 +609,7 @@ static char bootefi_help_text[] =
> > #endif
> >
> > U_BOOT_CMD(
> > - bootefi, 3, 0, do_bootefi,
> > + bootefi, 5, 0, do_bootefi,
> > "Boots an EFI payload from memory",
> > bootefi_help_text
> > );
> >
next prev parent reply other threads:[~2018-12-25 9:56 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 [this message]
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
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=20181225095643.GH14405@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