Message ID | 20190419032236.8242-10-takahiro.akashi@linaro.org |
---|---|
State | Rejected, archived |
Delegated to: | Heinrich Schuchardt |
Headers | show |
Series | efi_loader: rework bootefi/bootmgr | expand |
On 4/19/19 5:22 AM, AKASHI Takahiro wrote: > Add CONFIG_CMD_STANDALONE_EFIBOOTMGR. > With this patch, EFI boot manager can be kicked in by a standalone > command, efibootmgr. > > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> I still do not see that we really need a command efibootmgr duplicationg `bootefi bootmgr`. What I think is worthwhile in your patch is falling back to $fdt_control_addr. The Embedded Base Boot Requirements Specification (EBBR) requires that we always have either an ACPI table or a device tree but not both. So if no ACPI table is provided we should fallback to $fdtcontroladdr. If an ACPI table is present (i.e. on x86) we should not allow an FDT to be passed to bootefi. Best regards Heinrich > --- > cmd/Kconfig | 8 ++++++++ > cmd/bootefi.c | 35 +++++++++++++++++++++++++++++++++++ > 2 files changed, 43 insertions(+) > > diff --git a/cmd/Kconfig b/cmd/Kconfig > index 2bdbfcb3d091..46222be4a3c6 100644 > --- a/cmd/Kconfig > +++ b/cmd/Kconfig > @@ -224,6 +224,14 @@ config CMD_BOOTEFI > help > Boot an EFI image from memory. > > +config CMD_STANDALONE_EFIBOOTMGR > + bool "Enable EFI Boot Manager as a standalone command" > + depends on CMD_BOOTEFI > + default n > + help > + With this option enabled, EFI Boot Manager can be invoked > + as a standalone command. > + > config CMD_BOOTEFI_HELLO_COMPILE > bool "Compile a standard EFI hello world binary for testing" > depends on CMD_BOOTEFI && !CPU_V7M && !SANDBOX > diff --git a/cmd/bootefi.c b/cmd/bootefi.c > index 8c84fff590a7..348c6fdbe28d 100644 > --- a/cmd/bootefi.c > +++ b/cmd/bootefi.c > @@ -644,3 +644,38 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path) > bootefi_image_path = NULL; > } > } > + > +#ifdef CONFIG_CMD_STANDALONE_EFIBOOTMGR > +static int do_efibootmgr_cmd(cmd_tbl_t *cmdtp, int flag, int argc, > + char * const argv[]) > +{ > + char *fdt_opt; > + int ret; > + > + if (argc != 1) > + return CMD_RET_USAGE; > + > + fdt_opt = env_get("fdtaddr"); > + if (!fdt_opt) > + fdt_opt = env_get("fdtcontroladdr"); > + > + ret = do_efibootmgr(fdt_opt); > + > + free(fdt_opt); > + > + return ret; > +} > + > +#ifdef CONFIG_SYS_LONGHELP > +static char efibootmgr_help_text[] = > + "(no arguments)\n" > + " - Launch EFI boot manager and execute EFI application\n" > + " based on BootNext and BootOrder variables\n"; > +#endif > + > +U_BOOT_CMD( > + efibootmgr, 1, 0, do_efibootmgr_cmd, > + "Launch EFI boot manager", > + efibootmgr_help_text > +); > +#endif /* CONFIG_CMD_STANDALONE_EFIBOOTMGR */ >
diff --git a/cmd/Kconfig b/cmd/Kconfig index 2bdbfcb3d091..46222be4a3c6 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -224,6 +224,14 @@ config CMD_BOOTEFI help Boot an EFI image from memory. +config CMD_STANDALONE_EFIBOOTMGR + bool "Enable EFI Boot Manager as a standalone command" + depends on CMD_BOOTEFI + default n + help + With this option enabled, EFI Boot Manager can be invoked + as a standalone command. + config CMD_BOOTEFI_HELLO_COMPILE bool "Compile a standard EFI hello world binary for testing" depends on CMD_BOOTEFI && !CPU_V7M && !SANDBOX diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 8c84fff590a7..348c6fdbe28d 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -644,3 +644,38 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path) bootefi_image_path = NULL; } } + +#ifdef CONFIG_CMD_STANDALONE_EFIBOOTMGR +static int do_efibootmgr_cmd(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + char *fdt_opt; + int ret; + + if (argc != 1) + return CMD_RET_USAGE; + + fdt_opt = env_get("fdtaddr"); + if (!fdt_opt) + fdt_opt = env_get("fdtcontroladdr"); + + ret = do_efibootmgr(fdt_opt); + + free(fdt_opt); + + return ret; +} + +#ifdef CONFIG_SYS_LONGHELP +static char efibootmgr_help_text[] = + "(no arguments)\n" + " - Launch EFI boot manager and execute EFI application\n" + " based on BootNext and BootOrder variables\n"; +#endif + +U_BOOT_CMD( + efibootmgr, 1, 0, do_efibootmgr_cmd, + "Launch EFI boot manager", + efibootmgr_help_text +); +#endif /* CONFIG_CMD_STANDALONE_EFIBOOTMGR */
Add CONFIG_CMD_STANDALONE_EFIBOOTMGR. With this patch, EFI boot manager can be kicked in by a standalone command, efibootmgr. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> --- cmd/Kconfig | 8 ++++++++ cmd/bootefi.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)