iPXE
Functions
efi_wrap.h File Reference

EFI driver interface. More...

#include <ipxe/efi/efi.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
void efi_wrap (EFI_HANDLE handle)
 Wrap the calls made by a loaded image.

Detailed Description

EFI driver interface.

Definition in file efi_wrap.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
void efi_wrap ( EFI_HANDLE  handle)

Wrap the calls made by a loaded image.

Parameters:
handleImage handle

Definition at line 550 of file efi_wrap.c.

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, colour, EFI_BOOT_SERVICES::ConnectController, DBG_LOG, DBGC, DBGC_EFI_PROTOCOLS, EFI_BOOT_SERVICES::DisconnectController, EEFI, efi_bs_wrapper, efi_close_protocol_wrapper(), efi_connect_controller_wrapper(), efi_devpath_text(), efi_disconnect_controller_wrapper(), efi_exit_boot_services_wrapper(), efi_exit_wrapper(), efi_handle_name(), efi_handle_protocol_wrapper(), efi_image_handle, efi_install_protocol_interface_wrapper(), efi_load_image_wrapper(), efi_loaded_image_protocol_guid, efi_locate_device_path_wrapper(), efi_locate_handle_buffer_wrapper(), efi_locate_handle_wrapper(), efi_locate_protocol_wrapper(), EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_open_protocol_wrapper(), efi_protocols_per_handle_wrapper(), efi_reinstall_protocol_interface_wrapper(), efi_start_image_wrapper(), efi_systab, efi_systab_wrapper, efi_uninstall_protocol_interface_wrapper(), efi_unload_image_wrapper(), EFI_BOOT_SERVICES::Exit, EFI_BOOT_SERVICES::ExitBootServices, EFI_BOOT_SERVICES::HandleProtocol, EFI_BOOT_SERVICES::InstallProtocolInterface, EFI_BOOT_SERVICES::LoadImage, EFI_BOOT_SERVICES::LocateDevicePath, EFI_BOOT_SERVICES::LocateHandle, EFI_BOOT_SERVICES::LocateHandleBuffer, EFI_BOOT_SERVICES::LocateProtocol, memcpy(), NULL, EFI_BOOT_SERVICES::OpenProtocol, EFI_BOOT_SERVICES::ProtocolsPerHandle, rc, EFI_BOOT_SERVICES::ReinstallProtocolInterface, EFI_BOOT_SERVICES::StartImage, strerror(), EFI_BOOT_SERVICES::UninstallProtocolInterface, and EFI_BOOT_SERVICES::UnloadImage.

Referenced by efi_image_exec(), and efi_load_image_wrapper().

                                     {
        EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
        union {
                EFI_LOADED_IMAGE_PROTOCOL *image;
                void *intf;
        } loaded;
        EFI_STATUS efirc;
        int rc;

        /* Do nothing unless debugging is enabled */
        if ( ! DBG_LOG )
                return;

        /* Populate table wrappers */
        memcpy ( &efi_systab_wrapper, efi_systab,
                 sizeof ( efi_systab_wrapper ) );
        memcpy ( &efi_bs_wrapper, bs, sizeof ( efi_bs_wrapper ) );
        efi_systab_wrapper.BootServices = &efi_bs_wrapper;
        efi_bs_wrapper.InstallProtocolInterface
                = efi_install_protocol_interface_wrapper;
        efi_bs_wrapper.ReinstallProtocolInterface
                = efi_reinstall_protocol_interface_wrapper;
        efi_bs_wrapper.UninstallProtocolInterface
                = efi_uninstall_protocol_interface_wrapper;
        efi_bs_wrapper.HandleProtocol   = efi_handle_protocol_wrapper;
        efi_bs_wrapper.LocateHandle     = efi_locate_handle_wrapper;
        efi_bs_wrapper.LocateDevicePath = efi_locate_device_path_wrapper;
        efi_bs_wrapper.LoadImage        = efi_load_image_wrapper;
        efi_bs_wrapper.StartImage       = efi_start_image_wrapper;
        efi_bs_wrapper.Exit             = efi_exit_wrapper;
        efi_bs_wrapper.UnloadImage      = efi_unload_image_wrapper;
        efi_bs_wrapper.ExitBootServices = efi_exit_boot_services_wrapper;
        efi_bs_wrapper.ConnectController
                = efi_connect_controller_wrapper;
        efi_bs_wrapper.DisconnectController
                = efi_disconnect_controller_wrapper;
        efi_bs_wrapper.OpenProtocol     = efi_open_protocol_wrapper;
        efi_bs_wrapper.CloseProtocol    = efi_close_protocol_wrapper;
        efi_bs_wrapper.ProtocolsPerHandle
                = efi_protocols_per_handle_wrapper;
        efi_bs_wrapper.LocateHandleBuffer
                = efi_locate_handle_buffer_wrapper;
        efi_bs_wrapper.LocateProtocol   = efi_locate_protocol_wrapper;

        /* Open loaded image protocol */
        if ( ( efirc = bs->OpenProtocol ( handle,
                                          &efi_loaded_image_protocol_guid,
                                          &loaded.intf, efi_image_handle, NULL,
                                          EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
                rc = -EEFI ( efirc );
                DBGC ( colour, "WRAP %s could not get loaded image protocol: "
                       "%s\n", efi_handle_name ( handle ), strerror ( rc ) );
                return;
        }

        /* Provide system table wrapper to image */
        loaded.image->SystemTable = &efi_systab_wrapper;
        DBGC ( colour, "WRAP %s at base %p has protocols:\n",
               efi_handle_name ( handle ), loaded.image->ImageBase );
        DBGC_EFI_PROTOCOLS ( colour, handle );
        DBGC ( colour, "WRAP %s parent", efi_handle_name ( handle ) );
        DBGC ( colour, " %s\n", efi_handle_name ( loaded.image->ParentHandle ));
        DBGC ( colour, "WRAP %s device", efi_handle_name ( handle ) );
        DBGC ( colour, " %s\n", efi_handle_name ( loaded.image->DeviceHandle ));
        DBGC ( colour, "WRAP %s file", efi_handle_name ( handle ) );
        DBGC ( colour, " %s\n", efi_devpath_text ( loaded.image->FilePath ) );

        /* Close loaded image protocol */
        bs->CloseProtocol ( handle, &efi_loaded_image_protocol_guid,
                            efi_image_handle, NULL );
}