From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 3/8] cmd: efishell: add drivers command
Date: Tue, 25 Dec 2018 16:22:57 +0900 [thread overview]
Message-ID: <20181225072256.GB14405@linaro.org> (raw)
In-Reply-To: <55a9b14a-7583-890f-b5c4-a0cc67f19d1b@gmx.de>
On Thu, Dec 20, 2018 at 08:51:34AM +0100, Heinrich Schuchardt wrote:
> On 12/18/18 6:05 AM, AKASHI Takahiro wrote:
> > "drivers" command prints all the uefi drivers on the system.
> > => efi drivers
> > Driver Name Image Path
> > ============================================
> > (unknown) <NULL>+(not found)
> > guid: 18a031ab-b443-4d1a-a5c0-0c09261e9f71
> >
> > Currently, no useful information can be printed.
>
> Why? We have lib/efi_driver/efi_block_device.c. So you should be able to
> test the output.
There are a couple of reasons that I think there are no useful
information:
1. EFI driver doesn't have any printable name.
A corresponding u-boot driver, efi_block in efi_block_device.c,
has a name, but there is not direct link between efi driver
and this u-boot driver. So it's not easy to find a name for efi driver.
2. I will fix this by adding a "name" field to
efi_driver_binding_extended_protocol, but if even so, we can only
say "EFI block driver." We have no chance to know about controller
-specific, say USB, SCSI or anything, information.
3. More importantly, efi block devices can be defined in two ways,
via efi_uclass/efi_block_device and efi_disk. The latter supports
BLOCK_IO_PROTOCOL binding having any associated driver/controller.
It seems to me that it's quite confusion.
Thanks,
-Takahiro Akashi
> Best regards
>
> Heirnich
>
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> > cmd/efishell.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 94 insertions(+), 1 deletion(-)
> >
> > diff --git a/cmd/efishell.c b/cmd/efishell.c
> > index 929b6343b1b2..ed8de9e0355d 100644
> > --- a/cmd/efishell.c
> > +++ b/cmd/efishell.c
> > @@ -343,6 +343,95 @@ static int do_efi_show_devices(int argc, char * const argv[])
> > return CMD_RET_SUCCESS;
> > }
> >
> > +static int efi_get_driver_handle_info(efi_handle_t handle, u16 **name,
> > + u16 **devname, u16 **filename)
> > +{
> > + struct efi_driver_binding_protocol *binding;
> > + struct efi_loaded_image *image;
> > + efi_status_t ret;
> > +
> > + ret = bs->open_protocol(handle, &efi_guid_driver_binding_protocol,
> > + (void **)&binding, NULL, NULL,
> > + EFI_OPEN_PROTOCOL_GET_PROTOCOL);
> > + if (ret != EFI_SUCCESS)
> > + return -1;
> > +
> > + ret = bs->open_protocol(binding->image_handle, &efi_guid_loaded_image,
> > + (void **)&image, NULL /* FIXME */, NULL,
> > + EFI_OPEN_PROTOCOL_GET_PROTOCOL);
> > + if (ret != EFI_SUCCESS)
> > + goto e_out;
> > +
> > + /*
> > + * TODO:
> > + * handle image->device_handle,
> > + * use append_device_path()
> > + */
> > + *devname = NULL;
> > + *filename = efi_dp_str(image->file_path);
> > +
> > + return 0;
> > +
> > +e_out:
> > + *devname = NULL;
> > + *filename = NULL;
> > +
> > + return 0;
> > +}
> > +
> > +static int do_efi_show_drivers(int argc, char * const argv[])
> > +{
> > + efi_handle_t *handles = NULL, *handle;
> > + efi_uintn_t size = 0;
> > + u16 *drvname, *devname, *filename;
> > + efi_status_t ret;
> > + int i;
> > +
> > + ret = bs->locate_handle(BY_PROTOCOL, &efi_guid_driver_binding_protocol,
> > + NULL, &size, NULL);
> > + if (ret == EFI_BUFFER_TOO_SMALL) {
> > + handles = calloc(1, size);
> > + if (!handles)
> > + return CMD_RET_FAILURE;
> > +
> > + ret = bs->locate_handle(BY_PROTOCOL,
> > + &efi_guid_driver_binding_protocol,
> > + NULL, &size, handles);
> > + }
> > + if (ret != EFI_SUCCESS) {
> > + free(handles);
> > + return CMD_RET_FAILURE;
> > + }
> > +
> > + printf("Driver Name Image Path\n");
> > + printf("============================================\n");
> > + handle = handles;
> > + for (i = 0; i < size / sizeof(*handle); i++) {
> > + if (!efi_get_driver_handle_info(*handle, &drvname, &devname,
> > + &filename)) {
> > + printf("%-16s%ls+%ls\n",
> > + "(unknown)", devname, filename);
> > + efi_free_pool(devname);
> > + efi_free_pool(filename);
> > +
> > + /* TODO: no other info */
> > + struct efi_object *efiobj;
> > + struct list_head *lhandle;
> > + struct efi_handler *protocol;
> > +
> > + efiobj = efi_search_obj(*handle);
> > + list_for_each(lhandle, &efiobj->protocols) {
> > + protocol = list_entry(lhandle,
> > + struct efi_handler, link);
> > + printf(" guid: %pUl\n", protocol->guid);
> > + }
> > + }
> > + handle++;
> > + }
> > +
> > + return CMD_RET_SUCCESS;
> > +}
> > +
> > static int do_efi_boot_add(int argc, char * const argv[])
> > {
> > int id;
> > @@ -726,6 +815,8 @@ static int do_efishell(cmd_tbl_t *cmdtp, int flag,
> > return do_efi_set_var(argc, argv);
> > else if (!strcmp(command, "devices"))
> > return do_efi_show_devices(argc, argv);
> > + else if (!strcmp(command, "drivers"))
> > + return do_efi_show_drivers(argc, argv);
> > else
> > return CMD_RET_USAGE;
> > }
> > @@ -749,7 +840,9 @@ static char efishell_help_text[] =
> > " - set/delete uefi variable's value\n"
> > " <value> may be \"=\"...\"\", \"=0x...\" (set) or \"=\" (delete)\n"
> > "efishell devices\n"
> > - " - show uefi devices\n";
> > + " - show uefi devices\n"
> > + "efishell drivers\n"
> > + " - show uefi drivers\n";
> > #endif
> >
> > U_BOOT_CMD(
> >
>
next prev parent reply other threads:[~2018-12-25 7:22 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-18 5:05 [U-Boot] [PATCH v3 0/8] cmd: add efishell for efi environment AKASHI Takahiro
2018-12-18 5:05 ` [U-Boot] [PATCH v3 1/8] cmd: add efishell command AKASHI Takahiro
2018-12-30 15:44 ` Heinrich Schuchardt
2018-12-30 17:10 ` Heinrich Schuchardt
2019-01-07 5:08 ` AKASHI Takahiro
2019-01-08 9:57 ` Alexander Graf
2019-01-07 5:06 ` AKASHI Takahiro
2018-12-30 23:47 ` Heinrich Schuchardt
2019-01-07 5:13 ` AKASHI Takahiro
2018-12-18 5:05 ` [U-Boot] [PATCH v3 2/8] cmd: efishell: add devices command AKASHI Takahiro
2018-12-18 5:05 ` [U-Boot] [PATCH v3 3/8] cmd: efishell: add drivers command AKASHI Takahiro
2018-12-20 7:51 ` Heinrich Schuchardt
2018-12-25 7:22 ` AKASHI Takahiro [this message]
2018-12-25 12:07 ` Heinrich Schuchardt
2018-12-18 5:05 ` [U-Boot] [PATCH v3 4/8] cmd: efishell: add images command AKASHI Takahiro
2018-12-18 5:05 ` [U-Boot] [PATCH v3 5/8] cmd: efishell: add memmap command AKASHI Takahiro
2018-12-18 5:05 ` [U-Boot] [PATCH v3 6/8] cmd: efishell: add dh command AKASHI Takahiro
2018-12-20 7:49 ` Heinrich Schuchardt
2018-12-25 5:32 ` AKASHI Takahiro
2018-12-18 5:05 ` [U-Boot] [PATCH v3 7/8] cmd: efishell: export uefi variable helper functions AKASHI Takahiro
2018-12-18 5:05 ` [U-Boot] [PATCH v3 8/8] cmd: env: add "-e" option for handling UEFI variables AKASHI Takahiro
2018-12-18 6:07 ` Heinrich Schuchardt
2018-12-19 1:49 ` AKASHI Takahiro
2018-12-19 12:23 ` Heinrich Schuchardt
2018-12-23 1:56 ` Alexander Graf
2018-12-25 8:44 ` AKASHI Takahiro
2018-12-26 21:20 ` Alexander Graf
2019-01-07 7:47 ` AKASHI Takahiro
2019-01-08 7:29 ` AKASHI Takahiro
2019-01-08 8:58 ` 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=20181225072256.GB14405@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox