From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: jbx6244@gmail.com, u-boot@lists.denx.de, trini@konsulko.com,
sjg@chromium.org, ilias.apalodimas@linaro.org
Subject: Re: [RFC 01/13] cmd: bootefi: unfold do_bootefi_image()
Date: Fri, 27 Oct 2023 09:25:44 +0900 [thread overview]
Message-ID: <ZTsDiJUA9esxg9nb@octopus> (raw)
In-Reply-To: <b6110e38-5a44-4fcf-8ae1-ad77f1b66390@gmx.de>
On Thu, Oct 26, 2023 at 01:01:52PM +0200, Heinrich Schuchardt wrote:
> On 10/26/23 07:30, AKASHI Takahiro wrote:
> > Unfold do_bootefi_image() into do_bootefi() for the sake of the succeeding
> > refactor work.
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> > cmd/bootefi.c | 101 ++++++++++++++++++--------------------------------
> > 1 file changed, 37 insertions(+), 64 deletions(-)
> >
> > diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> > index 20e5c94a33a4..1b28bf5a318d 100644
> > --- a/cmd/bootefi.c
> > +++ b/cmd/bootefi.c
> > @@ -425,58 +425,6 @@ static int do_efibootmgr(void)
> > return CMD_RET_SUCCESS;
> > }
> >
> > -/**
> > - * do_bootefi_image() - execute EFI binary
> > - *
> > - * Set up memory image for the binary to be loaded, prepare device path, and
> > - * then call do_bootefi_exec() to execute it.
> > - *
> > - * @image_opt: string with image start address
> > - * @size_opt: string with image size or NULL
> > - * Return: status code
> > - */
> > -static int do_bootefi_image(const char *image_opt, const char *size_opt)
> > -{
> > - void *image_buf;
> > - unsigned long addr, size;
> > - efi_status_t ret;
> > -
> > -#ifdef CONFIG_CMD_BOOTEFI_HELLO
> > - if (!strcmp(image_opt, "hello")) {
> > - image_buf = __efi_helloworld_begin;
> > - size = __efi_helloworld_end - __efi_helloworld_begin;
> > - efi_clear_bootdev();
> > - } else
> > -#endif
> > - {
> > - addr = strtoul(image_opt, NULL, 16);
> > - /* Check that a numeric value was passed */
> > - if (!addr)
> > - return CMD_RET_USAGE;
> > - image_buf = map_sysmem(addr, 0);
> > -
> > - if (size_opt) {
> > - size = strtoul(size_opt, NULL, 16);
> > - if (!size)
> > - return CMD_RET_USAGE;
> > - efi_clear_bootdev();
> > - } else {
> > - if (image_buf != image_addr) {
> > - log_err("No UEFI binary known at %s\n",
> > - image_opt);
> > - return CMD_RET_FAILURE;
> > - }
> > - size = image_size;
> > - }
> > - }
> > - ret = efi_run_image(image_buf, size);
> > -
> > - if (ret != EFI_SUCCESS)
> > - return CMD_RET_FAILURE;
> > -
> > - return CMD_RET_SUCCESS;
> > -}
> > -
> > /**
> > * efi_run_image() - run loaded UEFI image
> > *
> > @@ -648,8 +596,9 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
> > char *const argv[])
> > {
> > efi_status_t ret;
> > - char *img_addr, *img_size, *str_copy, *pos;
> > - void *fdt;
> > + char *p;
> > + void *fdt, *image_buf;
> > + unsigned long addr, size;
> >
> > if (argc < 2)
> > return CMD_RET_USAGE;
> > @@ -684,18 +633,42 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
> > if (!strcmp(argv[1], "selftest"))
> > return do_efi_selftest();
> > #endif
> > - str_copy = strdup(argv[1]);
> > - if (!str_copy) {
> > - log_err("Out of memory\n");
> > - return CMD_RET_FAILURE;
> > +
> > +#ifdef CONFIG_CMD_BOOTEFI_HELLO
>
> I would prefer a normal if and let the linker sort it out.
Here I focused on simply unfolding("moving") the function, keeping the code
as same as possible. Any how the code is in a tentative form
at this point and will be reshaped in later patches, using IS_ENABLED().
Please look at the final code after applying the whole series.
-Takahiro Akashi
> Otherwise looks good to me.
>
> Best regards
>
> Heinrich
>
> > + if (!strcmp(argv[1], "hello")) {
> > + image_buf = __efi_helloworld_begin;
> > + size = __efi_helloworld_end - __efi_helloworld_begin;
> > + efi_clear_bootdev();
> > + } else
> > +#endif
> > + {
> > + addr = strtoul(argv[1], NULL, 16);
> > + /* Check that a numeric value was passed */
> > + if (!addr)
> > + return CMD_RET_USAGE;
> > + image_buf = map_sysmem(addr, 0);
> > +
> > + p = strchr(argv[1], ':');
> > + if (p) {
> > + size = strtoul(++p, NULL, 16);
> > + if (!size)
> > + return CMD_RET_USAGE;
> > + efi_clear_bootdev();
> > + } else {
> > + if (image_buf != image_addr) {
> > + log_err("No UEFI binary known at %s\n",
> > + argv[1]);
> > + return CMD_RET_FAILURE;
> > + }
> > + size = image_size;
> > + }
> > }
> > - pos = str_copy;
> > - img_addr = strsep(&pos, ":");
> > - img_size = strsep(&pos, ":");
> > - ret = do_bootefi_image(img_addr, img_size);
> > - free(str_copy);
> > + ret = efi_run_image(image_buf, size);
> >
> > - return ret;
> > + if (ret != EFI_SUCCESS)
> > + return CMD_RET_FAILURE;
> > +
> > + return CMD_RET_SUCCESS;
> > }
> >
> > U_BOOT_LONGHELP(bootefi,
>
next prev parent reply other threads:[~2023-10-27 0:25 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 5:30 [RFC 00/13] cmd: bootefi: refactor the code for bootmgr AKASHI Takahiro
2023-10-26 5:30 ` [RFC 01/13] cmd: bootefi: unfold do_bootefi_image() AKASHI Takahiro
2023-10-26 11:01 ` Heinrich Schuchardt
2023-10-27 0:25 ` AKASHI Takahiro [this message]
2023-10-27 1:00 ` Tom Rini
2023-10-27 12:23 ` Ilias Apalodimas
2023-10-30 0:34 ` AKASHI Takahiro
2023-10-26 5:30 ` [RFC 02/13] cmd: bootefi: re-organize do_bootefi_image() AKASHI Takahiro
2023-10-26 10:44 ` Heinrich Schuchardt
2023-10-26 12:47 ` Tom Rini
2023-10-27 0:35 ` AKASHI Takahiro
2023-10-26 5:30 ` [RFC 03/13] cmd: bootefi: carve out EFI boot manager interface AKASHI Takahiro
2023-10-26 5:30 ` [RFC 04/13] cmd: bootefi: carve out binary execution interface AKASHI Takahiro
2023-10-26 5:30 ` [RFC 05/13] cmd: bootefi: move library interfaces under lib/efi_loader AKASHI Takahiro
2023-10-26 5:30 ` [RFC 06/13] cmd: efidebug: ease efi configuration dependency AKASHI Takahiro
2023-10-26 5:30 ` [RFC 07/13] bootmeth: use efi_loader interfaces instead of bootefi command AKASHI Takahiro
2023-10-26 5:30 ` [RFC 08/13] efi_loader: split unrelated code from efi_bootmgr.c AKASHI Takahiro
2023-10-26 5:30 ` [RFC 09/13] efi_loader: rename BOOTEFI_BOOTMGR to EFI_BOOTMGR AKASHI Takahiro
2023-10-26 5:30 ` [RFC 10/13] net: tftp: remove explicit efi configuration dependency AKASHI Takahiro
2023-10-26 5:30 ` [RFC 11/13] fs: " AKASHI Takahiro
2023-10-26 7:58 ` Heinrich Schuchardt
2023-10-26 8:48 ` AKASHI Takahiro
2023-10-26 12:47 ` Tom Rini
2023-10-27 0:59 ` AKASHI Takahiro
2023-10-27 1:04 ` Tom Rini
2023-10-26 5:30 ` [RFC 12/13] lib: uuid: move CONFIG_RANDOM_UUID AKASHI Takahiro
2023-10-26 12:47 ` Tom Rini
2023-10-27 12:24 ` Ilias Apalodimas
2023-10-26 5:30 ` [RFC 13/13] block: rkmtd: select CONFIG_RANDOM_UUID explicitly AKASHI Takahiro
2023-10-26 12:47 ` Tom Rini
2023-10-26 12:47 ` [RFC 00/13] cmd: bootefi: refactor the code for bootmgr Tom Rini
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=ZTsDiJUA9esxg9nb@octopus \
--to=takahiro.akashi@linaro.org \
--cc=ilias.apalodimas@linaro.org \
--cc=jbx6244@gmail.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.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