THe driver image handle


Feng Libo <lbfeng@...>
 

Hello, Madam/Sir,


I have a problem:


Given a device handle, How to find the driver image handles that are managing the controller? The drivers are compliant to the UEFI driver model.


Thanks


--

Best Regards


Feng Libo
ZD Technology (Beijing) Co., Ltd


Tomas Pilar (tpilar)
 

Hi Libo,

The convention says that when a driver manages a device, it should find the
relevant IO protocol installed on the device handle (for example a PCI
device will have EFI_PCI_IO_PROTOCOL) and open it using
the EFI_OPEN_PROTOCOL_BY_DRIVER attribute. The driver will keep the
protocol open for the entire duration while it manages the device. You can
use boot services (UefiBootServicesTableLib.h), in particular the
gBS->OpenProtocolInformation() function, to inspect who has a specific
protocol on a specific handle open and with what attributes.

Now, if you are a user and you boot into UEFI shell, all you have to do is
inspect the (shell) handle using the 'dh -d -v <handle>' command.

Cheers,
Tom

On Fri, Sep 4, 2020 at 2:43 AM Feng Libo <lbfeng@zd-tech.com.cn> wrote:

Hello, Madam/Sir,


I have a problem:


Given a device handle, How to find the driver image handles that are
managing the controller? The drivers are compliant to the UEFI driver model.


Thanks


--

Best Regards


Feng Libo
ZD Technology (Beijing) Co., Ltd



Laszlo Ersek
 

On 09/04/20 13:04, Tomas Pilar (tpilar) wrote:
Hi Libo,

The convention says that when a driver manages a device, it should find the
relevant IO protocol installed on the device handle (for example a PCI
device will have EFI_PCI_IO_PROTOCOL) and open it using
the EFI_OPEN_PROTOCOL_BY_DRIVER attribute. The driver will keep the
protocol open for the entire duration while it manages the device. You can
use boot services (UefiBootServicesTableLib.h), in particular the
gBS->OpenProtocolInformation() function, to inspect who has a specific
protocol on a specific handle open and with what attributes.

Now, if you are a user and you boot into UEFI shell, all you have to do is
inspect the (shell) handle using the 'dh -d -v <handle>' command.
See also the EfiTestManagedDevice() and EfiTestChildHandle() utility
functions in UefiLib.

Thanks
Laszlo