From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 5/9] cmd: efitool: add dh command
Date: Thu, 17 Jan 2019 15:01:11 +0900 [thread overview]
Message-ID: <20190117060109.GT20286@linaro.org> (raw)
In-Reply-To: <add7a705-d331-6abe-54da-b70c1420105a@gmx.de>
On Tue, Jan 15, 2019 at 05:55:26AM +0100, Heinrich Schuchardt wrote:
> On 1/15/19 3:55 AM, AKASHI Takahiro wrote:
> > "dh" command prints all the uefi handles used in the system.
> >
> > => efi dh
> > 7ef3bfa0: Device Path, Device Path To Text, Device Path Utilities,
> > Unicode Collation 2
> > 7ef31d30: Driver Binding
> > 7ef31da0: Simple Text Output
> > 7ef31e10: Simple Text Input, Simple Text Input Ex
> > 7ef3cca0: Block IO, Device Path
> > 7ef3d070: Block IO, Device Path
> > 7ef3d1b0: Block IO, Device Path, Simple File System
> > 7ef3d3e0: Block IO, Device Path, Simple File System
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> > cmd/efitool.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 102 insertions(+), 1 deletion(-)
> >
> > diff --git a/cmd/efitool.c b/cmd/efitool.c
> > index 4d46721fbf91..4bd6367b4bd9 100644
> > --- a/cmd/efitool.c
> > +++ b/cmd/efitool.c
> > @@ -436,6 +436,103 @@ static int do_efi_show_drivers(int argc, char * const argv[])
> > return CMD_RET_SUCCESS;
> > }
> >
> > +static struct {
> > + u16 *name;
>
> Please, reduce the memory size by using char *.
OK
> > + efi_guid_t guid;
> > +} guid_list[] = {
> > + {
> > + L"Device Path",
> > + DEVICE_PATH_GUID,
> > + },
> > + {
> > + L"Device Path To Text",
> > + EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID,
> > + },
> > + {
> > + L"Device Path Utilities",
> > + EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID,
> > + },
> > + {
> > + L"Unicode Collation 2",
> > + EFI_UNICODE_COLLATION_PROTOCOL2_GUID,
> > + },
> > + {
> > + L"Driver Binding",
> > + EFI_DRIVER_BINDING_PROTOCOL_GUID,
> > + },
> > + {
> > + L"Simple Text Input",
> > + EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID,
> > + },
> > + {
> > + L"Simple Text Input Ex",
> > + EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID,
> > + },
> > + {
> > + L"Simple Text Output",
> > + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID,
> > + },
> > + {
> > + L"Block IO",
> > + BLOCK_IO_GUID,
> > + },
> > + {
> > + L"Simple File System",
> > + EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID,
> > + },
>
> We implement a few more protocols, e.g.
>
> include/efi_api.h:467:#define BLOCK_IO_GUID \
> include/efi_api.h:977:#define EFI_DRIVER_BINDING_PROTOCOL_GUID \
> include/efi_api.h:999:#define EFI_UNICODE_COLLATION_PROTOCOL2_GUID \
They are already in there.
> include/efi_api.h:283:#define LOADED_IMAGE_PROTOCOL_GUID \
> include/efi_api.h:700:#define EFI_GOP_GUID \
Added.
> > + {
> > + NULL,
> > + {{0,},},
> > + }
> You could use the ARRAY_SIZE() macro instead of the NULL entry.
OK
> > +};
> > +
> > +static int do_efi_show_handles(int argc, char * const argv[])
> > +{
> > + efi_handle_t *handles;
> > + efi_guid_t **guid;
> > + efi_uintn_t count;
> > + int num, i, j, k;
> > + efi_status_t ret;
> > +
> > + handles = NULL;
> > + num = 0;
> > + if (efi_get_handles_by_proto(NULL, &handles, &num))
> > + return CMD_RET_FAILURE;
> > +
> > + if (!num)
> > + return CMD_RET_SUCCESS;
> > +
> > + for (i = 0; i < num; i++) {
> > + printf("%16p:", handles[i]);
> > + ret = BS->protocols_per_handle(handles[i], &guid, &count);
> > + if (ret || !count) {
> > + putc('\n');
> > + continue;
> > + }
> > +
> > + for (j = 0; j < count; j++) {
> > + for (k = 0; guid_list[k].name; k++)
> > + if (!guidcmp(&guid_list[k].guid, guid[j]))
> > + break;
>
> Please, put this logic into a separate function returning const char *.
> Return NULL if not found.
OK
> > +
> > + if (j)
> > + printf(", ");
> > + else
> > + putc(' ');
> > +
> > + if (guid[j])
> > + printf("%ls", guid_list[k].name);
> > + else
> > + printf("%pUl", guid[j]);
> > + }
> > + putc('\n');
> > + }
> > +
> > + free(handles);
> > +
> > + return CMD_RET_SUCCESS;
> > +}
> > +
> > static int do_efi_boot_add(int argc, char * const argv[])
> > {
>
> Please, use the standard way of adding sub-commands. See
> doc/README.commands.
OK
Thanks,
-Takahiro Akashi
> Best regards
>
> Heinrich
>
> > int id;
> > @@ -847,6 +944,8 @@ static int do_efitool(cmd_tbl_t *cmdtp, int flag,
> > return do_efi_show_devices(argc, argv);
> > else if (!strcmp(command, "drivers"))
> > return do_efi_show_drivers(argc, argv);
> > + else if (!strcmp(command, "dh"))
> > + return do_efi_show_handles(argc, argv);
> > else
> > return CMD_RET_USAGE;
> > }
> > @@ -875,7 +974,9 @@ static char efitool_help_text[] =
> > "efitool devices\n"
> > " - show uefi devices\n"
> > "efitool drivers\n"
> > - " - show uefi drivers\n";
> > + " - show uefi drivers\n"
> > + "efitool dh\n"
> > + " - show uefi handles\n";
> > #endif
> >
> > U_BOOT_CMD(
> >
>
next prev parent reply other threads:[~2019-01-17 6:01 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-15 2:55 [U-Boot] [PATCH v4 0/9] cmd: add efitool for efi environment AKASHI Takahiro
2019-01-15 2:55 ` [U-Boot] [PATCH v4 1/9] cmd: add efitool command AKASHI Takahiro
2019-01-15 3:31 ` Heinrich Schuchardt
2019-01-17 4:27 ` AKASHI Takahiro
2019-01-15 2:55 ` [U-Boot] [PATCH v4 2/9] cmd: efitool: add devices command AKASHI Takahiro
2019-01-15 5:09 ` Heinrich Schuchardt
2019-01-17 4:48 ` AKASHI Takahiro
2019-01-15 2:55 ` [U-Boot] [PATCH v4 3/9] efi_driver: add name to driver binding protocol AKASHI Takahiro
2019-01-15 3:41 ` Heinrich Schuchardt
2019-01-17 5:33 ` AKASHI Takahiro
2019-01-17 6:58 ` Heinrich Schuchardt
2019-01-21 7:47 ` AKASHI Takahiro
2019-01-15 2:55 ` [U-Boot] [PATCH v4 4/9] cmd: efitool: add drivers command AKASHI Takahiro
2019-01-15 3:39 ` Heinrich Schuchardt
2019-01-15 2:55 ` [U-Boot] [PATCH v4 5/9] cmd: efitool: add dh command AKASHI Takahiro
2019-01-15 4:55 ` Heinrich Schuchardt
2019-01-17 6:01 ` AKASHI Takahiro [this message]
2019-01-15 2:55 ` [U-Boot] [PATCH v4 6/9] cmd: efitool: add images command AKASHI Takahiro
2019-01-15 4:58 ` Heinrich Schuchardt
2019-01-17 6:02 ` AKASHI Takahiro
2019-01-15 2:55 ` [U-Boot] [PATCH v4 7/9] cmd: efitool: add memmap command AKASHI Takahiro
2019-01-15 4:26 ` Heinrich Schuchardt
2019-01-17 7:03 ` AKASHI Takahiro
2019-01-15 2:55 ` [U-Boot] [PATCH v4 8/9] cmd: efitool: export uefi variable helper functions AKASHI Takahiro
2019-01-15 5:28 ` Heinrich Schuchardt
2019-01-17 7:30 ` AKASHI Takahiro
2019-01-15 2:55 ` [U-Boot] [PATCH v4 9/9] cmd: env: add "-e" option for handling UEFI variables AKASHI Takahiro
2019-01-15 3:47 ` Heinrich Schuchardt
2019-01-15 13:23 ` Alexander Graf
2019-01-15 13:26 ` Alexander Graf
2019-01-15 9:16 ` [U-Boot] [PATCH v4 0/9] cmd: add efitool for efi environment Alexander Graf
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=20190117060109.GT20286@linaro.org \
--to=takahiro.akashi@linaro.org \
--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.