From: Alexander Graf <agraf@suse.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/5] cmd: bootefi: carve out fdt parameter handling
Date: Sun, 23 Dec 2018 03:08:52 +0100 [thread overview]
Message-ID: <5e7828a2-bbda-4a09-604f-a89fefeb92e1@suse.de> (raw)
In-Reply-To: <20181218050257.20142-4-takahiro.akashi@linaro.org>
On 18.12.18 06:02, 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>
>
> Revert "fixup! fixup! cmd: bootefi: carve out fdt parameter handling"
>
> This reverts commit abc315426e37bdfb96a48d23c1fc96399b68baa5.
You sure you wanted this to be part of the commit message? ;)
> ---
> cmd/bootefi.c | 49 +++++++++++++++++++++++++++++++++----------------
> cmd/bootefi.h | 3 +++
> 2 files changed, 36 insertions(+), 16 deletions(-)
> create mode 100644 cmd/bootefi.h
>
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 3ebae1cdad08..796ca6ee69ec 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -279,6 +279,31 @@ static void bootefi_run_finish(struct efi_loaded_image_obj *image_obj,
> efi_delete_handle(&image_obj->header);
> }
>
> +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
> *
> @@ -473,7 +498,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();
> @@ -489,21 +513,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;
> @@ -521,6 +530,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;
> +
> if (bootefi_test_prepare(&image_obj, &loaded_image_info,
> "\\selftest", (uintptr_t)&efi_selftest,
> "efi_selftest"))
> @@ -533,6 +545,9 @@ 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;
> +
> return do_bootefi_bootmgr_exec();
> } else {
> saddr = argv[1];
> @@ -542,6 +557,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/bootefi.h b/cmd/bootefi.h
> new file mode 100644
> index 000000000000..4e11ab1211cb
> --- /dev/null
> +++ b/cmd/bootefi.h
> @@ -0,0 +1,3 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
This should be a separate patch.
> +
> +int efi_handle_fdt(char *fdt_opt);
>
next prev parent reply other threads:[~2018-12-23 2:08 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 [this message]
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
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=5e7828a2-bbda-4a09-604f-a89fefeb92e1@suse.de \
--to=agraf@suse.de \
--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