[U-Boot] [PATCH v2 10/14] cmd: bootefi: carve out fdt parameter handling
AKASHI Takahiro
takahiro.akashi at linaro.org
Mon Dec 3 07:33:42 UTC 2018
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 at 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?
Thanks,
-Takahiro Akashi
>
> Alex
More information about the U-Boot
mailing list