From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Cc: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>,
Shantur Rathore <i@shantur.com>, Bin Meng <bmeng@tinylab.org>,
AKASHI Takahiro <akashi.tkhro@gmail.com>,
Masahisa Kojima <kojima.masahisa@socionext.com>,
Raymond Mao <raymond.mao@linaro.org>,
Mark Kettenis <kettenis@openbsd.org>,
Joao Marcos Costa <jmcosta944@gmail.com>,
u-boot@lists.denx.de
Subject: Re: [RFC 10/14] efi_loader: load device-tree specified in boot option
Date: Wed, 22 May 2024 09:28:57 +0300 [thread overview]
Message-ID: <Zk2QqSXxS6NgonVv@hera> (raw)
In-Reply-To: <20240426141321.232236-11-heinrich.schuchardt@canonical.com>
On Fri, Apr 26, 2024 at 04:13:17PM +0200, Heinrich Schuchardt wrote:
> We allow to specify the triple of binary, initrd, and device-tree in boot
> options.
>
> Add the code to actually load the specified device-tree.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> lib/efi_loader/efi_bootmgr.c | 57 +++++++++++++++++++++++++++++++++++-
> 1 file changed, 56 insertions(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
> index d924810a94b..3d58a928b10 100644
> --- a/lib/efi_loader/efi_bootmgr.c
> +++ b/lib/efi_loader/efi_bootmgr.c
> @@ -1185,6 +1185,55 @@ out:
> return ret;
> }
>
> +/**
> + * load_fdt_from_load_option - load device-tree from load option
> + *
> + * Return: pointer to loaded device-tree or NULL
> + */
> +static void *load_fdt_from_load_option(void)
> +{
> + struct efi_device_path *dp = NULL;
> + struct efi_file_handle *f = NULL;
> + efi_uintn_t filesize;
> + void *buffer;
> + efi_status_t ret;
> +
> + dp = efi_get_dp_from_boot(&efi_guid_fdt);
> + if (!dp)
> + return NULL;
> +
> + /* Open file */
> + f = efi_file_from_path(dp);
> + if (!f) {
> + log_err("Can't find fdt specified in Boot####\n");
> + goto out;
> + }
> +
> + /* Get file size */
> + ret = efi_file_size(f, &filesize);
> + if (ret != EFI_SUCCESS)
> + goto out;
> +
> + buffer = malloc(filesize);
> + if (!buffer) {
> + log_err("Out of memory\n");
> + goto out;
> + }
> + ret = EFI_CALL(f->read(f, &filesize, (void *)buffer));
> + if (ret != EFI_SUCCESS) {
> + log_err("Can't read fdt\n");
> + free(buffer);
> + buffer = NULL;
> + }
> +
> +out:
> + efi_free_pool(dp);
> + if (f)
> + EFI_CALL(f->close(f));
> +
> + return buffer;
> +}
> +
> /**
> * efi_bootmgr_run() - execute EFI boot manager
> * @fdt: Flat device tree
> @@ -1200,6 +1249,7 @@ efi_status_t efi_bootmgr_run(void *fdt)
> efi_handle_t handle;
> void *load_options;
> efi_status_t ret;
> + void *fdt_lo;
>
> /* Initialize EFI drivers */
> ret = efi_init_obj_list();
> @@ -1215,9 +1265,14 @@ efi_status_t efi_bootmgr_run(void *fdt)
> return ret;
> }
>
> + fdt_lo = load_fdt_from_load_option();
> + if (fdt_lo)
> + fdt = fdt_lo;
> +
> ret = efi_install_fdt(fdt);
> + free(fdt_lo);
> if (ret != EFI_SUCCESS) {
> - if (EFI_CALL(efi_unload_image(*handle)) == EFI_SUCCESS)
> + if (EFI_CALL(efi_unload_image(handle)) == EFI_SUCCESS)
You don't need this change. The *handle was a typo in patch #9
Thanks
/Ilias
> free(load_options);
> else
> log_err("Unloading image failed\n");
> --
> 2.43.0
>
next prev parent reply other threads:[~2024-05-22 6:29 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-26 14:13 [RFC 00/14] efi_loader: improve device-tree loading Heinrich Schuchardt
2024-04-26 14:13 ` [RFC 01/14] efi_loader: pass GUID by address to efi_dp_from_lo Heinrich Schuchardt
2024-04-26 23:50 ` Ilias Apalodimas
2024-04-26 14:13 ` [RFC 02/14] efi_loader: library function efi_dp_merge Heinrich Schuchardt
2024-04-26 14:30 ` Ilias Apalodimas
2024-04-26 14:52 ` Heinrich Schuchardt
2024-04-26 15:47 ` Ilias Apalodimas
2024-05-14 12:49 ` Heinrich Schuchardt
2024-05-14 12:58 ` Mark Kettenis
2024-05-14 13:08 ` Heinrich Schuchardt
2024-05-22 5:57 ` Ilias Apalodimas
2024-04-26 14:13 ` [RFC 03/14] efi_loader: simplify efi_dp_concat() Heinrich Schuchardt
2024-04-28 13:29 ` Ilias Apalodimas
2024-04-26 14:13 ` [RFC 04/14] cmd: eficonfig: add support for setting fdt Heinrich Schuchardt
2024-04-27 17:21 ` E Shattow
2024-04-27 21:25 ` Heinrich Schuchardt
2024-04-28 4:13 ` E Shattow
2024-04-26 14:13 ` [RFC 05/14] cmd: efidebug: " Heinrich Schuchardt
2024-05-22 6:16 ` Ilias Apalodimas
2024-04-26 14:13 ` [RFC 06/14] efi_loader: superfluous efi_restore_gd after EFI_CALL Heinrich Schuchardt
2024-04-26 14:13 ` [RFC 07/14] cmd: terminate efidebug test bootmgr early on error Heinrich Schuchardt
2024-04-26 14:13 ` [RFC 08/14] efi_loader: improve error handling in try_load_entry() Heinrich Schuchardt
2024-04-26 14:13 ` [RFC 09/14] efi_loader: do not install dtb if bootmgr fails Heinrich Schuchardt
2024-05-22 6:17 ` Ilias Apalodimas
2024-05-22 6:27 ` Ilias Apalodimas
2024-04-26 14:13 ` [RFC 10/14] efi_loader: load device-tree specified in boot option Heinrich Schuchardt
2024-05-22 6:28 ` Ilias Apalodimas [this message]
2024-04-26 14:13 ` [RFC 11/14] efi_loader: move distro_efi_get_fdt_name() Heinrich Schuchardt
2024-04-26 14:52 ` Caleb Connolly
2024-04-26 15:18 ` Heinrich Schuchardt
2024-04-26 14:13 ` [RFC 12/14] efi_loader: return binary from efi_dp_from_lo() Heinrich Schuchardt
2024-04-28 13:28 ` Ilias Apalodimas
2024-05-14 12:57 ` Heinrich Schuchardt
2024-04-26 14:13 ` [RFC 13/14] efi_loader: export efi_load_image_from_path Heinrich Schuchardt
2024-04-28 13:32 ` Ilias Apalodimas
2024-04-26 14:13 ` [RFC 14/14] efi_loader: load distro dtb in bootmgr Heinrich Schuchardt
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=Zk2QqSXxS6NgonVv@hera \
--to=ilias.apalodimas@linaro.org \
--cc=akashi.tkhro@gmail.com \
--cc=bmeng@tinylab.org \
--cc=heinrich.schuchardt@canonical.com \
--cc=i@shantur.com \
--cc=jmcosta944@gmail.com \
--cc=kettenis@openbsd.org \
--cc=kojima.masahisa@socionext.com \
--cc=raymond.mao@linaro.org \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.