简体   繁体   中英

uefi specifications example mentions EfiCoreImageHandle. How to get it?

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?

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 , ie

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM