Reputation: 31
Quoting the UEFI specifications section about EFI_BOOT_SERVICES.HandleProtocol():
The HandleProtocol() function is still available for use by old EFI applications and drivers. However, all new applications and drivers should use EFI_BOOT_SERVICES.OpenProtocol() in place of HandleProtocol(). The following code fragment shows a possible implementation of HandleProtocol() using OpenProtocol(). The variable EfiCoreImageHandle is the image handle of the EFI core.
EFI_STATUS
HandleProtocol (
IN EFI_HANDLE Handle,
IN EFI_GUID *Protocol,
OUT VOID **Interface
)
{
return OpenProtocol (
Handle,
Protocol,
Interface,
EfiCoreImageHandle,
NULL,
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
);
}
End of quote.
My question is: how to get the value for EfiCoreImageHandle when an EFI application was run by a boot manager, or from a UEFI shell?
Upvotes: 0
Views: 690
Reputation: 2537
Simply put, EfiCoreImageHandle
is just a placeholder in the specification. Have a look at how I invoke OpenProtocol
in the ShowEDID
utility in https://github.com/fpmurphy/UEFI-Utilities-2019.
Also look at the ShowUSB
utility where I currently use HandleProtocol
, i.e.
Status = gBS->HandleProtocol( HandleBuffer[Index],
&gEfiUsbIoProtocolGuid,
(VOID**)&UsbIo );
I could replace the above code with:
Status = gBS->OpenProtocol( HandleBuffer[Index],
&gEfiUsbIoProtocolGuid,
(VOID **)&UsbIo,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL );
Tested with UDK2018 and Lenovo T480
Upvotes: 1