public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 10/14] cmd: bootefi: carve out fdt parameter handling
Date: Tue, 25 Dec 2018 21:05:52 +0900	[thread overview]
Message-ID: <20181225120551.GN14405@linaro.org> (raw)
In-Reply-To: <8866b549-918e-c670-39ea-81b3b405ca64@suse.de>

On Sun, Dec 23, 2018 at 04:11:59AM +0100, Alexander Graf wrote:
> 
> 
> On 03.12.18 08:33, AKASHI Takahiro wrote:
> > On Mon, Dec 03, 2018 at 12:50:04AM +0100, Alexander Graf wrote:
> >>
> >>
> >> On 05.11.18 10:06, AKASHI Takahiro wrote:
> >>> The current way how command parameters, particularly "fdt addr," are
> >>> handled makes it a bit complicated to add a subcommand-specific parameter.
> >>> So just refactor the code and extract efi_handle_fdt().
> >>>
> >>> This commit is a preparatory change for enhancing bootmgr sub-command.
> >>>
> >>> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> >>> ---
> >>>  cmd/bootefi.c  | 51 +++++++++++++++++++++++++++++++++-----------------
> >>>  cmd/efishell.h |  1 +
> >>>  2 files changed, 35 insertions(+), 17 deletions(-)
> >>>
> >>> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> >>> index 5d61819f1f5c..3aedf5a09f93 100644
> >>> --- a/cmd/bootefi.c
> >>> +++ b/cmd/bootefi.c
> >>> @@ -356,6 +356,31 @@ static efi_status_t efi_install_fdt(ulong fdt_addr)
> >>>  	return ret;
> >>>  }
> >>>  
> >>> +int efi_handle_fdt(char *fdt_opt)
> >>> +{
> >>> +	unsigned long fdt_addr;
> >>> +	efi_status_t r;
> >>> +
> >>> +	if (fdt_opt) {
> >>> +		fdt_addr = simple_strtoul(fdt_opt, NULL, 16);
> >>> +		if (!fdt_addr && *fdt_opt != '0')
> >>> +			return CMD_RET_USAGE;
> >>> +
> >>> +		/* Install device tree */
> >>> +		r = efi_install_fdt(fdt_addr);
> >>> +		if (r != EFI_SUCCESS) {
> >>> +			printf("ERROR: failed to install device tree\n");
> >>> +			return CMD_RET_FAILURE;
> >>> +		}
> >>> +	} else {
> >>> +		/* Remove device tree. EFI_NOT_FOUND can be ignored here */
> >>> +		efi_install_configuration_table(&efi_guid_fdt, NULL);
> >>> +		printf("WARNING: booting without device tree\n");
> >>> +	}
> >>> +
> >>> +	return CMD_RET_SUCCESS;
> >>> +}
> >>> +
> >>>  /**
> >>>   * do_bootefi_exec() - execute EFI binary
> >>>   *
> >>> @@ -511,7 +536,6 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> >>>  	unsigned long addr;
> >>>  	char *saddr;
> >>>  	efi_status_t r;
> >>> -	unsigned long fdt_addr;
> >>>  
> >>>  	/* Allow unaligned memory access */
> >>>  	allow_unaligned();
> >>> @@ -527,21 +551,6 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> >>>  	if (argc < 2)
> >>>  		return CMD_RET_USAGE;
> >>>  
> >>> -	if (argc > 2) {
> >>> -		fdt_addr = simple_strtoul(argv[2], NULL, 16);
> >>> -		if (!fdt_addr && *argv[2] != '0')
> >>> -			return CMD_RET_USAGE;
> >>> -		/* Install device tree */
> >>> -		r = efi_install_fdt(fdt_addr);
> >>> -		if (r != EFI_SUCCESS) {
> >>> -			printf("ERROR: failed to install device tree\n");
> >>> -			return CMD_RET_FAILURE;
> >>> -		}
> >>> -	} else {
> >>> -		/* Remove device tree. EFI_NOT_FOUND can be ignored here */
> >>> -		efi_install_configuration_table(&efi_guid_fdt, NULL);
> >>> -		printf("WARNING: booting without device tree\n");
> >>> -	}
> >>>  #ifdef CONFIG_CMD_BOOTEFI_HELLO
> >>>  	if (!strcmp(argv[1], "hello")) {
> >>>  		ulong size = __efi_helloworld_end - __efi_helloworld_begin;
> >>> @@ -559,6 +568,9 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> >>>  		struct efi_loaded_image_obj *image_obj;
> >>>  		struct efi_loaded_image *loaded_image_info;
> >>>  
> >>> +		if (efi_handle_fdt(argc > 2 ? argv[2] : NULL))
> >>> +			return CMD_RET_FAILURE;
> >>> +
> >>>  		/* Construct a dummy device path. */
> >>>  		bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
> >>>  						      (uintptr_t)&efi_selftest,
> >>> @@ -583,7 +595,10 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> >>>  	} else
> >>>  #endif
> >>>  	if (!strcmp(argv[1], "bootmgr")) {
> >>> -		return do_bootefi_bootmgr_exec();
> >>> +		if (efi_handle_fdt(argc > 2 ? argv[2] : NULL))
> >>> +			return CMD_RET_FAILURE;
> >>> +
> >>> +		return do_bootefi_bootmgr_exec(boot_id);
> >>>  	} else {
> >>>  		saddr = argv[1];
> >>>  
> >>> @@ -592,6 +607,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> >>>  		if (!addr && *saddr != '0')
> >>>  			return CMD_RET_USAGE;
> >>>  
> >>> +		if (efi_handle_fdt(argc > 2 ? argv[2] : NULL))
> >>> +			return CMD_RET_FAILURE;
> >>>  	}
> >>>  
> >>>  	printf("## Starting EFI application at %08lx ...\n", addr);
> >>> diff --git a/cmd/efishell.h b/cmd/efishell.h
> >>> index 6f70b402b26b..1e5764a8a38d 100644
> >>> --- a/cmd/efishell.h
> >>> +++ b/cmd/efishell.h
> >>> @@ -3,3 +3,4 @@
> >>>  #include <efi.h>
> >>>  
> >>>  efi_status_t efi_init_obj_list(void);
> >>> +int efi_handle_fdt(char *fdt_opt);
> >>
> >> This should also go into efi_loader.h, as that's the subsystem that
> >> exports the function.
> > 
> > I hesitate to agree with you here as this function is provided as part
> > of bootefi in the first place. Run command is just a variant of
> > bootefi for efi binary. So it won't be seen as part of efi_loader function.
> > 
> > # In this sense, efishell.h should be renamed to bootefi.h?
> 
> Feel free to introduce a bootefi.h that contains all exports from
> bootefi.c, yes :).

OK, but due to your comment on a new do_bootefi_run() function,
we may no longer need to export efi_handle_fdt() (at least for now).
That's good.

-Takahiro Akashi

> 
> Alex

  reply	other threads:[~2018-12-25 12:05 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-05  9:06 [U-Boot] [PATCH v2 00/14] efi: make efi and bootmgr more usable AKASHI Takahiro
2018-11-05  9:06 ` [U-Boot] [PATCH v2 01/14] efi_loader: allow device == NULL in efi_dp_from_name() AKASHI Takahiro
2018-11-05  9:06 ` [U-Boot] [PATCH v2 02/14] efi_loader: bootmgr: add load option helper functions AKASHI Takahiro
2018-11-05  9:06 ` [U-Boot] [PATCH v2 03/14] efi_loader: bootmgr: allow for running a given load option AKASHI Takahiro
2018-12-02 23:22   ` Alexander Graf
2018-12-03  3:20     ` AKASHI Takahiro
2018-12-03 13:54       ` Alexander Graf
2018-11-05  9:06 ` [U-Boot] [PATCH v2 04/14] cmd: add efishell command AKASHI Takahiro
2018-12-02 23:42   ` Alexander Graf
2018-12-03  6:42     ` AKASHI Takahiro
2018-12-03 14:01       ` Alexander Graf
2018-11-05  9:06 ` [U-Boot] [PATCH v2 05/14] cmd: efishell: add devices command AKASHI Takahiro
2018-12-02 23:46   ` Alexander Graf
2018-12-03  7:02     ` AKASHI Takahiro
2018-12-23  3:11       ` Alexander Graf
2018-12-25 12:00         ` AKASHI Takahiro
2018-12-26  8:00           ` Alexander Graf
2019-01-07  8:22             ` AKASHI Takahiro
2018-11-05  9:06 ` [U-Boot] [PATCH v2 06/14] cmd: efishell: add drivers command AKASHI Takahiro
2018-11-05  9:06 ` [U-Boot] [PATCH v2 07/14] cmd: efishell: add images command AKASHI Takahiro
2018-11-05  9:06 ` [U-Boot] [PATCH v2 08/14] cmd: efishell: add memmap command AKASHI Takahiro
2018-12-02 23:48   ` Alexander Graf
2018-12-03  7:10     ` AKASHI Takahiro
2018-11-05  9:06 ` [U-Boot] [PATCH v2 09/14] cmd: efishell: add dh command AKASHI Takahiro
2018-11-05  9:06 ` [U-Boot] [PATCH v2 10/14] cmd: bootefi: carve out fdt parameter handling AKASHI Takahiro
2018-12-02 23:50   ` Alexander Graf
2018-12-03  7:33     ` AKASHI Takahiro
2018-12-23  3:11       ` Alexander Graf
2018-12-25 12:05         ` AKASHI Takahiro [this message]
2018-11-05  9:06 ` [U-Boot] [PATCH v2 11/14] cmd: bootefi: run an EFI application of a specific load option AKASHI Takahiro
2018-11-05  9:06 ` [U-Boot] [PATCH v2 12/14] cmd: run: add "-e" option to run an EFI application AKASHI Takahiro
2018-12-02 23:53   ` Alexander Graf
2018-12-03  7:57     ` AKASHI Takahiro
2018-11-05  9:06 ` [U-Boot] [PATCH v2 13/14] cmd: efishell: export uefi variable helper functions AKASHI Takahiro
2018-12-02 23:54   ` Alexander Graf
2018-12-03  8:08     ` AKASHI Takahiro
2018-12-23  3:13       ` Alexander Graf
2018-12-25 12:14         ` AKASHI Takahiro
2018-11-05  9:06 ` [U-Boot] [PATCH v2 14/14] cmd: env: add "-e" option for handling UEFI variables 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=20181225120551.GN14405@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