From mboxrd@z Thu Jan 1 00:00:00 1970 From: AKASHI Takahiro Date: Thu, 14 Jan 2021 14:11:33 +0900 Subject: [RFC PATCH 3/3] efidebug: add multiple device path instances on Boot#### In-Reply-To: <20210113111149.64567-4-ilias.apalodimas@linaro.org> References: <20210113111149.64567-1-ilias.apalodimas@linaro.org> <20210113111149.64567-4-ilias.apalodimas@linaro.org> Message-ID: <20210114051133.GC25252@laputa> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Ilias, On Wed, Jan 13, 2021 at 01:11:49PM +0200, Ilias Apalodimas wrote: > The UEFI spec allow a packed array of UEFI device paths in the > FilePathList[] of an EFI_LOAD_OPTION. The first file path must > describe the laoded image but the rest are OS specific. > Previous patches parse the device path and try to use the second > member of the array as an initrd. So let's modify efidebug slightly > and install the second file described in the command line as the > initrd device path. I have a concern about your proposed command line syntax. It takes a lot of parameters as a whole which makes it hard to understand it at a glance, easily overflowing the width of terminal window. It will even get worse if we want to take dtb as a third device path, and what if we want to specify dtb, but not initrd? Moreover, if we want to add support for non-linux executabes which utilize extra device paths (neither initrd nor dtb) in a boot load option, the syntax will be problematic. > Signed-off-by: Ilias Apalodimas > --- > cmd/efidebug.c | 89 +++++++++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 81 insertions(+), 8 deletions(-) > > diff --git a/cmd/efidebug.c b/cmd/efidebug.c > index 5fb7b1e3c6a9..8d62981aca92 100644 > --- a/cmd/efidebug.c > +++ b/cmd/efidebug.c > @@ -8,6 +8,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -17,6 +18,7 @@ > #include > #include > #include > +#include > > #define BS systab.boottime > #define RT systab.runtime > @@ -782,6 +784,42 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag, > return CMD_RET_SUCCESS; > } > > +/** > + * add_initrd_instance() - Append a device path to load_options pointing to an > + * inirtd > + * > + * @argc: Number of arguments > + * @argv: Argument array > + * @file_path Existing device path, the new instance will be appended > + * Return: Pointer to the device path or ERR_PTR > + * > + */ > +static struct efi_device_path *add_initrd_instance(int argc, char *const argv[], > + struct efi_device_path *file_path) > +{ > + struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL; > + struct efi_device_path *final_fp = NULL; > + efi_status_t ret; > + > + if (argc < 8) > + return ERR_PTR(-EINVAL); > + > + ret = efi_dp_from_name(argv[6], argv[7], argv[8], &tmp_dp, > + &tmp_fp); > + if (ret != EFI_SUCCESS) { > + printf("Cannot create device path for \"%s %s\"\n", > + argv[6], argv[7]); > + goto out; > + } > + > + final_fp = efi_dp_append_instance(file_path, tmp_fp); > + > +out: > + efi_free_pool(tmp_dp); > + efi_free_pool(tmp_fp); > + return final_fp ? final_fp : ERR_PTR(-EINVAL); > +} > + > /** > * do_efi_boot_add() - set UEFI load option > * > @@ -794,7 +832,11 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag, > * > * Implement efidebug "boot add" sub-command. Create or change UEFI load option. > * > - * efidebug boot add