iPXE
Data Structures | Defines | Functions | Variables
efi.h File Reference

EFI API. More...

#include <ipxe/efi/Uefi/UefiBaseType.h>
#include <ipxe/efi/Uefi.h>
#include <ipxe/efi/PiDxe.h>
#include <ipxe/efi/Protocol/LoadedImage.h>
#include <ipxe/tables.h>
#include <ipxe/uuid.h>

Go to the source code of this file.

Data Structures

struct  EFI_HANDLE
struct  efi_protocol
 An EFI protocol used by iPXE. More...
struct  efi_config_table
 An EFI configuration table used by iPXE. More...

Defines

#define EFI_HANDLE   STUPID_EFI_HANDLE
#define EFI_PROTOCOLS   __table ( struct efi_protocol, "efi_protocols" )
 EFI protocol table.
#define __efi_protocol   __table_entry ( EFI_PROTOCOLS, 01 )
 Declare an EFI protocol used by iPXE.
#define EFI_REQUIRE_PROTOCOL(_protocol, _ptr)
 Declare an EFI protocol to be required by iPXE.
#define EFI_REQUEST_PROTOCOL(_protocol, _ptr)
 Declare an EFI protocol to be requested by iPXE.
#define EFI_CONFIG_TABLES   __table ( struct efi_config_table, "efi_config_tables" )
 EFI configuration table table.
#define __efi_config_table   __table_entry ( EFI_CONFIG_TABLES, 01 )
 Declare an EFI configuration table used by iPXE.
#define EFI_USE_TABLE(_table, _ptr, _required)
 Declare an EFI configuration table to be used by iPXE.
#define EFIRC(rc)   ERRNO_TO_PLATFORM ( -(rc) )
 Convert an iPXE status code to an EFI status code.
#define EEFI(efirc)   EPLATFORM ( EINFO_EPLATFORM, efirc )
 Convert an EFI status code to an iPXE status code.
#define DBG_EFI_OPENERS_IF(level, handle, protocol)
#define DBG_EFI_PROTOCOLS_IF(level, handle)
#define DBGC_EFI_OPENERS_IF(level, id,...)
#define DBGC_EFI_PROTOCOLS_IF(level, id,...)
#define DBGC_EFI_OPENERS(...)   DBGC_EFI_OPENERS_IF ( LOG, ##__VA_ARGS__ )
#define DBGC_EFI_PROTOCOLS(...)   DBGC_EFI_PROTOCOLS_IF ( LOG, ##__VA_ARGS__ )
#define DBGC2_EFI_OPENERS(...)   DBGC_EFI_OPENERS_IF ( EXTRA, ##__VA_ARGS__ )
#define DBGC2_EFI_PROTOCOLS(...)   DBGC_EFI_PROTOCOLS_IF ( EXTRA, ##__VA_ARGS__ )
#define DBGCP_EFI_OPENERS(...)   DBGC_EFI_OPENERS_IF ( PROFILE, ##__VA_ARGS__ )
#define DBGCP_EFI_PROTOCOLS(...)   DBGC_EFI_PROTOCOLS_IF ( PROFILE, ##__VA_ARGS__ )

Functions

 FILE_LICENCE (GPL2_OR_LATER)
const char * efi_guid_ntoa (EFI_GUID *guid)
 Convert GUID to a printable string.
const char * efi_locate_search_type_name (EFI_LOCATE_SEARCH_TYPE search_type)
 Name locate search type.
const char * efi_open_attributes_name (unsigned int attributes)
 Name protocol open attributes.
const char * efi_devpath_text (EFI_DEVICE_PATH_PROTOCOL *path)
 Get textual representation of device path.
const char * efi_handle_name (EFI_HANDLE handle)
 Get name of an EFI handle.
void dbg_efi_openers (EFI_HANDLE handle, EFI_GUID *protocol)
 Print list of openers of a given protocol on a given handle.
void dbg_efi_protocols (EFI_HANDLE handle)
 Print list of protocol handlers attached to a handle.
EFI_STATUS efi_init (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
 Initialise EFI environment.

Variables

EFI_GUID efi_absolute_pointer_protocol_guid
 Absolute pointer protocol GUID.
EFI_GUID efi_acpi_table_protocol_guid
 ACPI table protocol GUID.
EFI_GUID efi_apple_net_boot_protocol_guid
 Apple NetBoot protocol GUID.
EFI_GUID efi_arp_protocol_guid
 ARP protocol GUID.
EFI_GUID efi_arp_service_binding_protocol_guid
 ARP service binding protocol GUID.
EFI_GUID efi_block_io_protocol_guid
 Block I/O protocol GUID.
EFI_GUID efi_block_io2_protocol_guid
 Block I/O version 2 protocol GUID.
EFI_GUID efi_bus_specific_driver_override_protocol_guid
 Bus specific driver override protocol GUID.
EFI_GUID efi_component_name_protocol_guid
 Component name protocol GUID.
EFI_GUID efi_component_name2_protocol_guid
 Component name 2 protocol GUID.
EFI_GUID efi_console_control_protocol_guid
 Console control protocol GUID.
EFI_GUID efi_device_path_protocol_guid
 Device path protocol GUID.
EFI_GUID efi_dhcp4_protocol_guid
 DHCPv4 protocol GUID.
EFI_GUID efi_dhcp4_service_binding_protocol_guid
 DHCPv4 service binding protocol GUID.
EFI_GUID efi_disk_io_protocol_guid
 Disk I/O protocol GUID.
EFI_GUID efi_driver_binding_protocol_guid
 Driver binding protocol GUID.
EFI_GUID efi_graphics_output_protocol_guid
 Graphics output protocol GUID.
EFI_GUID efi_hii_config_access_protocol_guid
 HII configuration access protocol GUID.
EFI_GUID efi_hii_font_protocol_guid
 HII font protocol GUID.
EFI_GUID efi_ip4_protocol_guid
 IPv4 protocol GUID.
EFI_GUID efi_ip4_config_protocol_guid
 IPv4 configuration protocol GUID.
EFI_GUID efi_ip4_service_binding_protocol_guid
 IPv4 service binding protocol GUID.
EFI_GUID efi_load_file_protocol_guid
 Load file protocol GUID.
EFI_GUID efi_load_file2_protocol_guid
 Load file 2 protocol GUID.
EFI_GUID efi_loaded_image_protocol_guid
 Loaded image protocol GUID.
EFI_GUID efi_loaded_image_device_path_protocol_guid
 Loaded image device path protocol GUID.
EFI_GUID efi_managed_network_protocol_guid
 Managed network protocol GUID.
EFI_GUID efi_managed_network_service_binding_protocol_guid
 Managed network service binding protocol GUID.
EFI_GUID efi_mtftp4_protocol_guid
 MTFTPv4 protocol GUID.
EFI_GUID efi_mtftp4_service_binding_protocol_guid
 MTFTPv4 service binding protocol GUID.
EFI_GUID efi_nii_protocol_guid
 Network interface identifier protocol GUID (old version)
EFI_GUID efi_nii31_protocol_guid
 Network interface identifier protocol GUID (new version)
EFI_GUID efi_pci_io_protocol_guid
 PCI I/O protocol GUID.
EFI_GUID efi_pci_root_bridge_io_protocol_guid
 PCI root bridge I/O protocol GUID.
EFI_GUID efi_pxe_base_code_protocol_guid
 PXE base code protocol GUID.
EFI_GUID efi_serial_io_protocol_guid
 Serial I/O protocol GUID.
EFI_GUID efi_simple_file_system_protocol_guid
 Simple file system protocol GUID.
EFI_GUID efi_simple_network_protocol_guid
 Simple network protocol GUID.
EFI_GUID efi_simple_pointer_protocol_guid
 Simple pointer protocol GUID.
EFI_GUID efi_simple_text_input_protocol_guid
 Simple text input protocol GUID.
EFI_GUID efi_simple_text_input_ex_protocol_guid
 Simple text input extension protocol GUID.
EFI_GUID efi_simple_text_output_protocol_guid
 Simple text output protocol GUID.
EFI_GUID efi_tcg_protocol_guid
 TCG protocol GUID.
EFI_GUID efi_tcp4_protocol_guid
 TCPv4 protocol GUID.
EFI_GUID efi_tcp4_service_binding_protocol_guid
 TCPv4 service binding protocol GUID.
EFI_GUID efi_tree_protocol_guid
 TrEE protocol GUID.
EFI_GUID efi_udp4_protocol_guid
 UDPv4 protocol GUID.
EFI_GUID efi_udp4_service_binding_protocol_guid
 UDPv4 service binding protocol GUID.
EFI_GUID efi_uga_draw_protocol_guid
 UGA draw protocol GUID.
EFI_GUID efi_unicode_collation_protocol_guid
 Unicode collation protocol GUID.
EFI_GUID efi_usb_hc_protocol_guid
 USB host controller protocol GUID.
EFI_GUID efi_usb2_hc_protocol_guid
 USB2 host controller protocol GUID.
EFI_GUID efi_usb_io_protocol_guid
 USB I/O protocol GUID.
EFI_GUID efi_vlan_config_protocol_guid
 VLAN configuration protocol GUID.
EFI_GUID efi_file_info_id
 File information GUID.
EFI_GUID efi_file_system_info_id
 File system information GUID.
EFI_HANDLE efi_image_handle
 Image handle passed to entry point.
EFI_LOADED_IMAGE_PROTOCOLefi_loaded_image
 Loaded image protocol for this image.
EFI_DEVICE_PATH_PROTOCOLefi_loaded_image_path
EFI_SYSTEM_TABLEefi_systab
int efi_shutdown_in_progress
 EFI shutdown is in progress.

Detailed Description

EFI API.

The intention is to include near-verbatim copies of the EFI headers required by iPXE. This is achieved using the import.pl script in this directory. Run the import script to update the local copies of the headers:

./import.pl /path/to/edk2/edk2

where /path/to/edk2/edk2 is the path to your local checkout of the EFI Development Kit.

Note that import.pl will modify any #include lines in each imported header to reflect its new location within the iPXE tree. It will also tidy up the file by removing carriage return characters and trailing whitespace.

Definition in file efi.h.


Define Documentation

#define EFI_HANDLE   STUPID_EFI_HANDLE

Definition at line 52 of file efi.h.

#define EFI_PROTOCOLS   __table ( struct efi_protocol, "efi_protocols" )

EFI protocol table.

Definition at line 80 of file efi.h.

Referenced by efi_init().

Declare an EFI protocol used by iPXE.

Definition at line 83 of file efi.h.

#define EFI_REQUIRE_PROTOCOL (   _protocol,
  _ptr 
)
Value:
struct efi_protocol __ ## _protocol __efi_protocol = {               \
                .guid = _protocol ## _GUID,                                  \
                .protocol = ( ( void ** ) ( void * )                         \
                              ( ( (_ptr) == ( ( _protocol ** ) (_ptr) ) ) ?  \
                                (_ptr) : (_ptr) ) ),                         \
                .required = 1,                                               \
        }

Declare an EFI protocol to be required by iPXE.

Parameters:
_protocolEFI protocol name
_ptrPointer to protocol instance

Definition at line 90 of file efi.h.

#define EFI_REQUEST_PROTOCOL (   _protocol,
  _ptr 
)
Value:
struct efi_protocol __ ## _protocol __efi_protocol = {               \
                .guid = _protocol ## _GUID,                                  \
                .protocol = ( ( void ** ) ( void * )                         \
                              ( ( (_ptr) == ( ( _protocol ** ) (_ptr) ) ) ?  \
                                (_ptr) : (_ptr) ) ),                         \
                .required = 0,                                               \
        }

Declare an EFI protocol to be requested by iPXE.

Parameters:
_protocolEFI protocol name
_ptrPointer to protocol instance

Definition at line 104 of file efi.h.

#define EFI_CONFIG_TABLES   __table ( struct efi_config_table, "efi_config_tables" )

EFI configuration table table.

Definition at line 124 of file efi.h.

Referenced by efi_init().

Declare an EFI configuration table used by iPXE.

Definition at line 128 of file efi.h.

#define EFI_USE_TABLE (   _table,
  _ptr,
  _required 
)
Value:
struct efi_config_table __ ## _table __efi_config_table = {          \
                .guid = _table ## _GUID,                                     \
                .table = ( ( void ** ) ( void * ) (_ptr) ),                  \
                .required = (_required),                                     \
        }

Declare an EFI configuration table to be used by iPXE.

Parameters:
_tableEFI configuration table name
_ptrPointer to configuration table
_requiredTable is required for operation

Definition at line 136 of file efi.h.

#define EFIRC (   rc)    ERRNO_TO_PLATFORM ( -(rc) )
#define EEFI (   efirc)    EPLATFORM ( EINFO_EPLATFORM, efirc )

Convert an EFI status code to an iPXE status code.

Parameters:
efircEFI status code
Return values:
rciPXE status code (before negation)

Definition at line 157 of file efi.h.

Referenced by chained_locate(), chained_supported(), dbg_efi_openers(), dbg_efi_protocols(), efi_block_boot(), efi_block_boot_image(), efi_block_connect(), efi_block_describe(), efi_block_hook(), efi_block_install(), efi_bofm_start(), efi_bofm_supported(), efi_child_add(), efi_download_abort(), efi_download_deliver_iob(), efi_download_install(), efi_driver_connect(), efi_driver_handles(), efi_driver_install(), efi_driver_start(), efi_entropy_enable(), efi_entropy_tick(), efi_file_install(), efi_file_uninstall(), efi_get_noise_rng(), efi_get_time(), efi_getchar(), efi_image_exec(), efi_init(), efi_local_check_volume_name(), efi_local_len(), efi_local_open_resolved(), efi_local_open_root(), efi_local_open_volume(), efi_local_step(), efi_locate_device(), efi_pxe_install(), efi_snp_hii_install(), efi_snp_probe(), efi_tick_shutdown(), efi_tick_startup(), efi_udelay(), efi_urealloc(), efi_usb_async_start(), efi_usb_get_string_descriptor(), efi_usb_install(), efi_usb_open(), efi_watchdog_expired(), efi_wrap(), efifb_glyphs(), efifb_init(), efifb_restore(), efifb_select_mode(), efipci_open(), efipci_read(), efipci_root(), efipci_write(), nii_io(), nii_map(), nii_pci_open(), nii_start(), nii_supported(), snp_supported(), snpnet_close(), snpnet_open(), snpnet_poll_rx(), snpnet_poll_tx(), snpnet_rx_filters(), snpnet_start(), snpnet_stop(), snpnet_transmit(), txnic_bgx_mac(), usbio_bulk_in_poll(), usbio_bulk_out_poll(), usbio_config(), usbio_control_poll(), usbio_interfaces(), usbio_interrupt_open(), usbio_open(), usbio_path(), usbio_start(), and usbio_supported().

#define DBG_EFI_OPENERS_IF (   level,
  handle,
  protocol 
)
Value:
do {    \
                if ( DBG_ ## level ) {                          \
                        dbg_efi_openers ( handle, protocol );   \
                }                                               \
        } while ( 0 )

Definition at line 236 of file efi.h.

#define DBG_EFI_PROTOCOLS_IF (   level,
  handle 
)
Value:
do {            \
                if ( DBG_ ## level ) {                          \
                        dbg_efi_protocols ( handle );           \
                }                                               \
        } while ( 0 )

Definition at line 242 of file efi.h.

#define DBGC_EFI_OPENERS_IF (   level,
  id,
  ... 
)
Value:
do {            \
                DBG_AC_IF ( level, id );                        \
                DBG_EFI_OPENERS_IF ( level, __VA_ARGS__ );      \
                DBG_DC_IF ( level );                            \
        } while ( 0 )

Definition at line 248 of file efi.h.

#define DBGC_EFI_PROTOCOLS_IF (   level,
  id,
  ... 
)
Value:
do {            \
                DBG_AC_IF ( level, id );                        \
                DBG_EFI_PROTOCOLS_IF ( level, __VA_ARGS__ );    \
                DBG_DC_IF ( level );                            \
        } while ( 0 )

Definition at line 254 of file efi.h.

#define DBGC_EFI_OPENERS (   ...)    DBGC_EFI_OPENERS_IF ( LOG, ##__VA_ARGS__ )
#define DBGC_EFI_PROTOCOLS (   ...)    DBGC_EFI_PROTOCOLS_IF ( LOG, ##__VA_ARGS__ )

Definition at line 262 of file efi.h.

Referenced by efi_wrap().

#define DBGC2_EFI_OPENERS (   ...)    DBGC_EFI_OPENERS_IF ( EXTRA, ##__VA_ARGS__ )

Definition at line 265 of file efi.h.

#define DBGC2_EFI_PROTOCOLS (   ...)    DBGC_EFI_PROTOCOLS_IF ( EXTRA, ##__VA_ARGS__ )

Definition at line 267 of file efi.h.

Referenced by efi_block_connect(), and efi_driver_connect().

#define DBGCP_EFI_OPENERS (   ...)    DBGC_EFI_OPENERS_IF ( PROFILE, ##__VA_ARGS__ )

Definition at line 270 of file efi.h.

#define DBGCP_EFI_PROTOCOLS (   ...)    DBGC_EFI_PROTOCOLS_IF ( PROFILE, ##__VA_ARGS__ )

Definition at line 272 of file efi.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER  )
const char* efi_guid_ntoa ( EFI_GUID guid)

Convert GUID to a printable string.

Parameters:
guidGUID
Return values:
stringPrintable string

Definition at line 192 of file efi_debug.c.

References efi_well_known_guids, efi_well_known_guid::guid, memcmp(), memcpy(), efi_well_known_guid::name, NULL, u, uuid_mangle(), and uuid_ntoa().

Referenced by chained_locate(), chained_supported(), dbg_efi_openers(), dbg_efi_protocols(), efi_close_protocol_wrapper(), efi_file_get_info(), efi_file_set_info(), efi_handle_name(), efi_handle_protocol_wrapper(), efi_init(), efi_install_protocol_interface_wrapper(), efi_locate_device(), efi_locate_device_path_wrapper(), efi_locate_handle_buffer_wrapper(), efi_locate_handle_wrapper(), efi_locate_protocol_wrapper(), efi_open_protocol_wrapper(), efi_protocols_per_handle_wrapper(), efi_reinstall_protocol_interface_wrapper(), and efi_uninstall_protocol_interface_wrapper().

                                                                       {
        union {
                union uuid uuid;
                EFI_GUID guid;
        } u;
        unsigned int i;

        /* Sanity check */
        if ( ! guid )
                return NULL;

        /* Check for a match against well-known GUIDs */
        for ( i = 0 ; i < ( sizeof ( efi_well_known_guids ) /
                            sizeof ( efi_well_known_guids[0] ) ) ; i++ ) {
                if ( memcmp ( guid, efi_well_known_guids[i].guid,
                              sizeof ( *guid ) ) == 0 ) {
                        return efi_well_known_guids[i].name;
                }
        }

        /* Convert GUID to standard endianness */
        memcpy ( &u.guid, guid, sizeof ( u.guid ) );
        uuid_mangle ( &u.uuid );
        return uuid_ntoa ( &u.uuid );
}

Name locate search type.

Parameters:
search_typeLocate search type
Return values:
nameLocate search type name

Definition at line 225 of file efi_debug.c.

References AllHandles, ByProtocol, ByRegisterNotify, and snprintf().

Referenced by efi_locate_handle_buffer_wrapper(), and efi_locate_handle_wrapper().

                                                                   {
        static char buf[16];

        switch ( search_type ) {
        case AllHandles :       return "AllHandles";
        case ByRegisterNotify:  return "ByRegisterNotify";
        case ByProtocol:        return "ByProtocol";
        default:
                snprintf ( buf, sizeof ( buf ), "UNKNOWN<%d>", search_type );
                return buf;
        }
}
const char* efi_open_attributes_name ( unsigned int  attributes)

Name protocol open attributes.

Parameters:
attributesProtocol open attributes
Return values:
nameProtocol open attributes name

Returns a (static) string with characters for each set bit corresponding to BY_(H)ANDLE_PROTOCOL, (G)ET_PROTOCOL, (T)EST_PROTOCOL, BY_(C)HILD_CONTROLLER, BY_(D)RIVER, and E(X)CLUSIVE.

Definition at line 250 of file efi_debug.c.

References name.

Referenced by dbg_efi_openers(), and efi_open_protocol_wrapper().

                                                     {
        static char attribute_chars[] = "HGTCDX";
        static char name[ sizeof ( attribute_chars ) ];
        char *tmp = name;
        unsigned int i;

        for ( i = 0 ; i < ( sizeof ( attribute_chars ) - 1 ) ; i++ ) {
                if ( attributes & ( 1 << i ) )
                        *(tmp++) = attribute_chars[i];
        }
        *tmp = '\0';

        return name;
}
const char* efi_devpath_text ( EFI_DEVICE_PATH_PROTOCOL path)

Get textual representation of device path.

Parameters:
pathDevice path
Return values:
textTextual representation of device path, or NULL

Definition at line 367 of file efi_debug.c.

References EFI_SYSTEM_TABLE::BootServices, EFI_DEVICE_PATH_TO_TEXT_PROTOCOL::ConvertDevicePathToText, DBG, efi_devpath_len(), efi_systab, FALSE, EFI_BOOT_SERVICES::FreePool, len, NULL, snprintf(), and TRUE.

Referenced by efi_block_boot_image(), efi_block_hook(), efi_connect_controller_wrapper(), efi_driver_start(), efi_driver_supported(), efi_load_image_wrapper(), efi_loaded_image_filepath_name(), efi_locate_device_path_wrapper(), efi_wrap(), usbio_open(), and usbio_path().

                                                    {
        EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
        static char text[256];
        size_t len;
        CHAR16 *wtext;

        /* Sanity checks */
        if ( ! path ) {
                DBG ( "[NULL DevicePath]" );
                return NULL;
        }

        /* If we have no DevicePathToText protocol then use a raw hex string */
        if ( ! efidpt ) {
                DBG ( "[No DevicePathToText]" );
                len = efi_devpath_len ( path );
                base16_encode ( path, len, text, sizeof ( text ) );
                return text;
        }

        /* Convert path to a textual representation */
        wtext = efidpt->ConvertDevicePathToText ( path, TRUE, FALSE );
        if ( ! wtext )
                return NULL;

        /* Store path in buffer */
        snprintf ( text, sizeof ( text ), "%ls", wtext );

        /* Free path */
        bs->FreePool ( wtext );

        return text;
}
const char* efi_handle_name ( EFI_HANDLE  handle)

Get name of an EFI handle.

Parameters:
handleEFI handle
Return values:
textName of handle, or NULL

Definition at line 714 of file efi_debug.c.

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, count, DBG2, efi_guid_ntoa(), efi_handle_name_types, efi_image_handle, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_systab, EFI_BOOT_SERVICES::FreePool, efi_handle_name_type::name, name, NULL, EFI_BOOT_SERVICES::OpenProtocol, efi_handle_name_type::protocol, EFI_BOOT_SERVICES::ProtocolsPerHandle, ssnprintf(), and type.

Referenced by chained_locate(), chained_supported(), dbg_efi_openers(), dbg_efi_protocols(), efi_bofm_start(), efi_bofm_supported(), efi_child_add(), efi_child_del(), efi_close_protocol_wrapper(), efi_connect_controller_wrapper(), efi_device_info(), efi_disconnect_controller_wrapper(), efi_driver_connect(), efi_driver_start(), efi_driver_stop(), efi_driver_supported(), efi_exit_boot_services_wrapper(), efi_exit_wrapper(), efi_handle_protocol_wrapper(), efi_install_protocol_interface_wrapper(), efi_load_image_wrapper(), efi_local_check_volume_name(), efi_local_open_root(), efi_local_open_volume(), efi_locate_device(), efi_locate_device_path_wrapper(), efi_locate_handle_buffer_wrapper(), efi_locate_handle_wrapper(), efi_open_protocol_wrapper(), efi_pci_info(), efi_protocols_per_handle_wrapper(), efi_pxe_install(), efi_pxe_uninstall(), efi_reinstall_protocol_interface_wrapper(), efi_snp_probe(), efi_start_image_wrapper(), efi_uninstall_protocol_interface_wrapper(), efi_unload_image_wrapper(), efi_usb_install(), efi_wrap(), efipci_open(), efipci_root(), efipci_start(), nii_start(), nii_supported(), snp_supported(), snpnet_start(), snpnet_stop(), usbio_bulk_in_poll(), usbio_bulk_out_poll(), usbio_config(), usbio_control_poll(), usbio_endpoint_open(), usbio_interface(), usbio_interfaces(), usbio_interrupt_callback(), usbio_interrupt_open(), usbio_open(), usbio_path(), usbio_start(), and usbio_supported().

                                                                            {
        EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
        struct efi_handle_name_type *type;
        static char buf[256];
        size_t used = 0;
        EFI_GUID **protocols;
        UINTN count;
        unsigned int i;
        void *interface;
        const char *name;
        EFI_STATUS efirc;

        /* Fail immediately for NULL handles */
        if ( ! handle )
                return NULL;

        /* Try each name type in turn */
        for ( i = 0 ; i < ( sizeof ( efi_handle_name_types ) /
                            sizeof ( efi_handle_name_types[0] ) ) ; i++ ) {
                type = &efi_handle_name_types[i];
                DBG2 ( "<%d", i );

                /* Try to open the applicable protocol */
                efirc = bs->OpenProtocol ( handle, type->protocol, &interface,
                                           efi_image_handle, handle,
                                           EFI_OPEN_PROTOCOL_GET_PROTOCOL );
                if ( efirc != 0 ) {
                        DBG2 ( ">" );
                        continue;
                }

                /* Try to get name from this protocol */
                DBG2 ( "-" );
                name = type->name ( interface );
                DBG2 ( "%c", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) );

                /* Close protocol */
                bs->CloseProtocol ( handle, type->protocol,
                                    efi_image_handle, handle );
                DBG2 ( ">" );

                /* Use this name, if possible */
                if ( name && name[0] )
                        return name;
        }

        /* If no name is found, then use the raw handle value and a
         * list of installed protocols.
         */
        used = ssnprintf ( buf, sizeof ( buf ), "UNKNOWN<%p", handle );
        if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
                                                &count ) ) == 0 ) {
                for ( i = 0 ; i < count ; i++ ) {
                        used += ssnprintf ( ( buf + used ),
                                            ( sizeof ( buf ) - used ), ",%s",
                                            efi_guid_ntoa ( protocols[i] ) );
                }
                bs->FreePool ( protocols );
        }
        used += ssnprintf ( ( buf + used ), ( sizeof ( buf ) - used ), ">" );
        return buf;
}
void dbg_efi_openers ( EFI_HANDLE  handle,
EFI_GUID protocol 
)

Print list of openers of a given protocol on a given handle.

Parameters:
handleEFI handle
protocolProtocol GUID

Definition at line 271 of file efi_debug.c.

References EFI_OPEN_PROTOCOL_INFORMATION_ENTRY::AgentHandle, EFI_OPEN_PROTOCOL_INFORMATION_ENTRY::Attributes, EFI_SYSTEM_TABLE::BootServices, EFI_OPEN_PROTOCOL_INFORMATION_ENTRY::ControllerHandle, count, EEFI, efi_guid_ntoa(), efi_handle_name(), efi_open_attributes_name(), efi_systab, EFI_BOOT_SERVICES::FreePool, EFI_OPEN_PROTOCOL_INFORMATION_ENTRY::OpenCount, EFI_BOOT_SERVICES::OpenProtocolInformation, printf(), rc, and strerror().

Referenced by dbg_efi_protocols().

                                                               {
        EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
        EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *openers;
        EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener;
        UINTN count;
        unsigned int i;
        EFI_STATUS efirc;
        int rc;

        /* Sanity check */
        if ( ( ! handle ) || ( ! protocol ) ) {
                printf ( "HANDLE %s could not retrieve openers for %s\n",
                         efi_handle_name ( handle ),
                         efi_guid_ntoa ( protocol ) );
                return;
        }

        /* Retrieve list of openers */
        if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
                                                     &count ) ) != 0 ) {
                rc = -EEFI ( efirc );
                printf ( "HANDLE %s could not retrieve openers for %s: %s\n",
                         efi_handle_name ( handle ),
                         efi_guid_ntoa ( protocol ), strerror ( rc ) );
                return;
        }

        /* Dump list of openers */
        for ( i = 0 ; i < count ; i++ ) {
                opener = &openers[i];
                printf ( "HANDLE %s %s opened %dx (%s)",
                         efi_handle_name ( handle ),
                         efi_guid_ntoa ( protocol ), opener->OpenCount,
                         efi_open_attributes_name ( opener->Attributes ) );
                printf ( " by %s", efi_handle_name ( opener->AgentHandle ) );
                if ( opener->ControllerHandle == handle ) {
                        printf ( "\n" );
                } else {
                        printf ( " for %s\n",
                                 efi_handle_name ( opener->ControllerHandle ) );
                }
        }

        /* Free list */
        bs->FreePool ( openers );
}
void dbg_efi_protocols ( EFI_HANDLE  handle)

Print list of protocol handlers attached to a handle.

Parameters:
handleEFI handle

Definition at line 323 of file efi_debug.c.

References EFI_SYSTEM_TABLE::BootServices, count, dbg_efi_openers(), EEFI, efi_guid_ntoa(), efi_handle_name(), efi_systab, EFI_BOOT_SERVICES::FreePool, printf(), protocol, EFI_BOOT_SERVICES::ProtocolsPerHandle, rc, and strerror().

                                             {
        EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
        EFI_GUID **protocols;
        EFI_GUID *protocol;
        UINTN count;
        unsigned int i;
        EFI_STATUS efirc;
        int rc;

        /* Sanity check */
        if ( ! handle ) {
                printf ( "HANDLE %s could not retrieve protocols\n",
                         efi_handle_name ( handle ) );
                return;
        }

        /* Retrieve list of protocols */
        if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
                                                &count ) ) != 0 ) {
                rc = -EEFI ( efirc );
                printf ( "HANDLE %s could not retrieve protocols: %s\n",
                         efi_handle_name ( handle ), strerror ( rc ) );
                return;
        }

        /* Dump list of protocols */
        for ( i = 0 ; i < count ; i++ ) {
                protocol = protocols[i];
                printf ( "HANDLE %s %s supported\n", efi_handle_name ( handle ),
                         efi_guid_ntoa ( protocol ) );
                dbg_efi_openers ( handle, protocol );
        }

        /* Free list */
        bs->FreePool ( protocols );
}
EFI_STATUS efi_init ( EFI_HANDLE  image_handle,
EFI_SYSTEM_TABLE systab 
)

Initialise EFI environment.

Parameters:
image_handleImage handle
systabSystem table
Return values:
efircEFI return status code

Definition at line 97 of file efi_init.c.

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseEvent, EFI_SYSTEM_TABLE::ConOut, EFI_BOOT_SERVICES::CreateEvent, DBGC, EEFI, EFI_CONFIG_TABLES, efi_driver_install(), efi_driver_uninstall(), efi_find_table(), efi_guid_ntoa(), efi_loaded_image_protocol_guid, EFI_NOT_AVAILABLE_YET, EFI_OPEN_PROTOCOL_GET_PROTOCOL, EFI_PROTOCOLS, efi_shutdown_event, efi_shutdown_hook(), efi_systab, efi_unload(), EFIRC, EVT_SIGNAL_EXIT_BOOT_SERVICES, for_each_table_entry, efi_protocol::guid, efi_config_table::guid, EFI_LOADED_IMAGE_PROTOCOL::ImageBase, EFI_BOOT_SERVICES::LocateProtocol, NULL, EFI_BOOT_SERVICES::OpenProtocol, efi_protocol::protocol, rc, efi_protocol::required, efi_config_table::required, EFI_SYSTEM_TABLE::RuntimeServices, strerror(), efi_config_table::table, TPL_CALLBACK, and EFI_LOADED_IMAGE_PROTOCOL::Unload.

Referenced by _efi_start(), and _efidrv_start().

                                                 {
        EFI_BOOT_SERVICES *bs;
        struct efi_protocol *prot;
        struct efi_config_table *tab;
        void *loaded_image;
        EFI_STATUS efirc;
        int rc;

        /* Store image handle and system table pointer for future use */
        efi_image_handle = image_handle;
        efi_systab = systab;

        /* Sanity checks */
        if ( ! systab ) {
                efirc = EFI_NOT_AVAILABLE_YET;
                goto err_sanity;
        }
        if ( ! systab->ConOut ) {
                efirc = EFI_NOT_AVAILABLE_YET;
                goto err_sanity;
        }
        if ( ! systab->BootServices ) {
                DBGC ( systab, "EFI provided no BootServices entry point\n" );
                efirc = EFI_NOT_AVAILABLE_YET;
                goto err_sanity;
        }
        if ( ! systab->RuntimeServices ) {
                DBGC ( systab, "EFI provided no RuntimeServices entry "
                       "point\n" );
                efirc = EFI_NOT_AVAILABLE_YET;
                goto err_sanity;
        }
        DBGC ( systab, "EFI handle %p systab %p\n", image_handle, systab );
        bs = systab->BootServices;

        /* Look up used protocols */
        for_each_table_entry ( prot, EFI_PROTOCOLS ) {
                if ( ( efirc = bs->LocateProtocol ( &prot->guid, NULL,
                                                    prot->protocol ) ) == 0 ) {
                        DBGC ( systab, "EFI protocol %s is at %p\n",
                               efi_guid_ntoa ( &prot->guid ),
                               *(prot->protocol) );
                } else {
                        DBGC ( systab, "EFI does not provide protocol %s\n",
                               efi_guid_ntoa ( &prot->guid ) );
                        /* Fail if protocol is required */
                        if ( prot->required )
                                goto err_missing_protocol;
                }
        }

        /* Look up used configuration tables */
        for_each_table_entry ( tab, EFI_CONFIG_TABLES ) {
                if ( ( *(tab->table) = efi_find_table ( &tab->guid ) ) ) {
                        DBGC ( systab, "EFI configuration table %s is at %p\n",
                               efi_guid_ntoa ( &tab->guid ), *(tab->table) );
                } else {
                        DBGC ( systab, "EFI does not provide configuration "
                               "table %s\n", efi_guid_ntoa ( &tab->guid ) );
                        if ( tab->required ) {
                                efirc = EFI_NOT_AVAILABLE_YET;
                                goto err_missing_table;
                        }
                }
        }

        /* Get loaded image protocol */
        if ( ( efirc = bs->OpenProtocol ( image_handle,
                                &efi_loaded_image_protocol_guid,
                                &loaded_image, image_handle, NULL,
                                EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
                rc = -EEFI ( efirc );
                DBGC ( systab, "EFI could not get loaded image protocol: %s",
                       strerror ( rc ) );
                goto err_no_loaded_image;
        }
        efi_loaded_image = loaded_image;
        DBGC ( systab, "EFI image base address %p\n",
               efi_loaded_image->ImageBase );

        /* EFI is perfectly capable of gracefully shutting down any
         * loaded devices if it decides to fall back to a legacy boot.
         * For no particularly comprehensible reason, it doesn't
         * bother doing so when ExitBootServices() is called.
         */
        if ( ( efirc = bs->CreateEvent ( EVT_SIGNAL_EXIT_BOOT_SERVICES,
                                         TPL_CALLBACK, efi_shutdown_hook,
                                         NULL, &efi_shutdown_event ) ) != 0 ) {
                rc = -EEFI ( efirc );
                DBGC ( systab, "EFI could not create ExitBootServices event: "
                       "%s\n", strerror ( rc ) );
                goto err_create_event;
        }

        /* Install driver binding protocol */
        if ( ( rc = efi_driver_install() ) != 0 ) {
                DBGC ( systab, "EFI could not install driver: %s\n",
                       strerror ( rc ) );
                efirc = EFIRC ( rc );
                goto err_driver_install;
        }

        /* Install image unload method */
        efi_loaded_image->Unload = efi_unload;

        return 0;

        efi_driver_uninstall();
 err_driver_install:
        bs->CloseEvent ( efi_shutdown_event );
 err_create_event:
 err_no_loaded_image:
 err_missing_table:
 err_missing_protocol:
 err_sanity:
        return efirc;
}

Variable Documentation

Absolute pointer protocol GUID.

Definition at line 88 of file efi_guid.c.

ACPI table protocol GUID.

Definition at line 92 of file efi_guid.c.

Apple NetBoot protocol GUID.

Definition at line 96 of file efi_guid.c.

Referenced by efi_pxe_install(), and efi_pxe_uninstall().

ARP protocol GUID.

Definition at line 100 of file efi_guid.c.

ARP service binding protocol GUID.

Definition at line 104 of file efi_guid.c.

Block I/O protocol GUID.

Definition at line 108 of file efi_guid.c.

Referenced by efi_block_hook(), efi_block_unhook(), efi_file_install(), and efi_file_uninstall().

Block I/O version 2 protocol GUID.

Definition at line 112 of file efi_guid.c.

Bus specific driver override protocol GUID.

Definition at line 116 of file efi_guid.c.

Component name protocol GUID.

Definition at line 120 of file efi_guid.c.

Component name 2 protocol GUID.

Definition at line 124 of file efi_guid.c.

Referenced by efi_driver_controller_name(), efi_driver_install(), efi_driver_uninstall(), efi_snp_probe(), and efi_snp_remove().

Console control protocol GUID.

Definition at line 128 of file efi_guid.c.

DHCPv4 protocol GUID.

Definition at line 136 of file efi_guid.c.

DHCPv4 service binding protocol GUID.

Definition at line 140 of file efi_guid.c.

Disk I/O protocol GUID.

Definition at line 144 of file efi_guid.c.

Referenced by efi_file_install(), and efi_file_uninstall().

Driver binding protocol GUID.

Definition at line 148 of file efi_guid.c.

Referenced by efi_driver_install(), and efi_driver_uninstall().

Graphics output protocol GUID.

Definition at line 152 of file efi_guid.c.

Referenced by efifb_init().

HII configuration access protocol GUID.

Definition at line 156 of file efi_guid.c.

Referenced by efi_snp_hii_install(), and efi_snp_hii_uninstall().

HII font protocol GUID.

Definition at line 160 of file efi_guid.c.

Referenced by efifb_init().

IPv4 protocol GUID.

Definition at line 164 of file efi_guid.c.

IPv4 configuration protocol GUID.

Definition at line 168 of file efi_guid.c.

IPv4 service binding protocol GUID.

Definition at line 172 of file efi_guid.c.

Load file protocol GUID.

Definition at line 176 of file efi_guid.c.

Referenced by efi_snp_probe(), and efi_snp_remove().

Load file 2 protocol GUID.

Definition at line 180 of file efi_guid.c.

Loaded image protocol GUID.

Definition at line 184 of file efi_guid.c.

Referenced by efi_image_exec(), efi_init(), and efi_wrap().

Loaded image device path protocol GUID.

Definition at line 188 of file efi_guid.c.

Managed network protocol GUID.

Definition at line 192 of file efi_guid.c.

Managed network service binding protocol GUID.

Definition at line 196 of file efi_guid.c.

MTFTPv4 protocol GUID.

Definition at line 200 of file efi_guid.c.

MTFTPv4 service binding protocol GUID.

Definition at line 204 of file efi_guid.c.

Network interface identifier protocol GUID (old version)

Definition at line 208 of file efi_guid.c.

Referenced by efi_snp_probe(), and efi_snp_remove().

Network interface identifier protocol GUID (new version)

Definition at line 212 of file efi_guid.c.

Referenced by efi_snp_probe(), efi_snp_remove(), nii_start(), nii_stop(), and nii_supported().

PCI I/O protocol GUID.

Definition at line 216 of file efi_guid.c.

Referenced by efi_pci_info(), efipci_close(), efipci_open(), efipci_start(), nii_pci_close(), and nii_pci_open().

PCI root bridge I/O protocol GUID.

Definition at line 220 of file efi_guid.c.

Referenced by efipci_read(), efipci_root(), and efipci_write().

PXE base code protocol GUID.

Definition at line 224 of file efi_guid.c.

Referenced by efi_pxe_install(), and efi_pxe_uninstall().

Serial I/O protocol GUID.

Definition at line 228 of file efi_guid.c.

Simple file system protocol GUID.

Definition at line 232 of file efi_guid.c.

Referenced by efi_block_boot(), efi_file_install(), efi_file_uninstall(), efi_local_open_root(), and efi_local_open_volume().

Simple network protocol GUID.

Definition at line 236 of file efi_guid.c.

Referenced by efi_set_autoboot(), efi_snp_probe(), efi_snp_remove(), snp_supported(), snpnet_start(), and snpnet_stop().

Simple pointer protocol GUID.

Definition at line 240 of file efi_guid.c.

Simple text input protocol GUID.

Definition at line 244 of file efi_guid.c.

Simple text input extension protocol GUID.

Definition at line 248 of file efi_guid.c.

Simple text output protocol GUID.

Definition at line 252 of file efi_guid.c.

TCG protocol GUID.

Definition at line 256 of file efi_guid.c.

TCPv4 protocol GUID.

Definition at line 260 of file efi_guid.c.

TCPv4 service binding protocol GUID.

Definition at line 264 of file efi_guid.c.

TrEE protocol GUID.

Definition at line 268 of file efi_guid.c.

UDPv4 protocol GUID.

Definition at line 272 of file efi_guid.c.

UDPv4 service binding protocol GUID.

Definition at line 276 of file efi_guid.c.

UGA draw protocol GUID.

Definition at line 280 of file efi_guid.c.

Unicode collation protocol GUID.

Definition at line 284 of file efi_guid.c.

USB host controller protocol GUID.

Definition at line 288 of file efi_guid.c.

USB2 host controller protocol GUID.

Definition at line 292 of file efi_guid.c.

USB I/O protocol GUID.

Definition at line 296 of file efi_guid.c.

Referenced by efi_usb_install(), efi_usb_uninstall(), usbio_close(), usbio_open(), usbio_start(), usbio_stop(), and usbio_supported().

VLAN configuration protocol GUID.

Definition at line 300 of file efi_guid.c.

File information GUID.

Definition at line 303 of file efi_guid.c.

Referenced by efi_file_get_info(), and efi_local_len().

File system information GUID.

Definition at line 306 of file efi_guid.c.

Referenced by efi_file_get_info(), and efi_local_check_volume_name().

Loaded image protocol for this image.

Definition at line 33 of file efi_init.c.

Referenced by _efi_start(), chained_locate(), efi_local_open_path(), efi_local_open_volume(), and efi_set_autoboot().

Referenced by chained_locate(), chained_supported(), dbg_efi_openers(), dbg_efi_protocols(), efi_block_boot(), efi_block_boot_image(), efi_block_connect(), efi_block_hook(), efi_block_unhook(), efi_bofm_start(), efi_bofm_supported(), efi_child_add(), efi_child_del(), efi_close_protocol_wrapper(), efi_conin_name(), efi_connect_controller_wrapper(), efi_conout_name(), efi_currticks(), efi_devpath_text(), efi_disconnect_controller_wrapper(), efi_download_install(), efi_download_uninstall(), efi_driver_connect(), efi_driver_controller_name(), efi_driver_disconnect(), efi_driver_handles(), efi_driver_install(), efi_driver_reconnect(), efi_driver_start(), efi_driver_stop(), efi_driver_uninstall(), efi_entropy_disable(), efi_entropy_enable(), efi_entropy_tick(), efi_exit_boot_services_wrapper(), efi_exit_wrapper(), efi_file_install(), efi_file_uninstall(), efi_find_table(), efi_get_time(), efi_getchar(), efi_handle_cup(), efi_handle_dectcem_reset(), efi_handle_dectcem_set(), efi_handle_ed(), efi_handle_name(), efi_handle_protocol_wrapper(), efi_handle_sgr(), efi_image_exec(), efi_image_probe(), efi_init(), efi_install_protocol_interface_wrapper(), efi_iskey(), efi_load_image_wrapper(), efi_local_open_root(), efi_local_open_volume(), efi_locate_device(), efi_locate_device_path_wrapper(), efi_locate_handle_buffer_wrapper(), efi_locate_handle_wrapper(), efi_locate_protocol_wrapper(), efi_open_protocol_wrapper(), efi_poweroff(), efi_protocols_per_handle_wrapper(), efi_putchar(), efi_pxe_install(), efi_pxe_uninstall(), efi_reboot(), efi_reinstall_protocol_interface_wrapper(), efi_set_autoboot(), efi_snp_add_claim(), efi_snp_get_status(), efi_snp_hii_append(), efi_snp_hii_install(), efi_snp_hii_uninstall(), efi_snp_initialize(), efi_snp_poll(), efi_snp_probe(), efi_snp_receive(), efi_snp_remove(), efi_snp_reset(), efi_snp_shutdown(), efi_snp_transmit(), efi_snp_wait_for_packet(), efi_start_image_wrapper(), efi_tick_shutdown(), efi_tick_startup(), efi_udelay(), efi_uninstall_protocol_interface_wrapper(), efi_unload(), efi_unload_image_wrapper(), efi_urealloc(), efi_usb_async_interrupt_transfer(), efi_usb_async_start(), efi_usb_async_stop(), efi_usb_bulk_transfer(), efi_usb_close(), efi_usb_control_transfer(), efi_usb_get_string_descriptor(), efi_usb_install(), efi_usb_open(), efi_usb_probe(), efi_usb_sync_interrupt_transfer(), efi_usb_uninstall(), efi_watchdog_expired(), efi_wrap(), efifb_glyphs(), efifb_init(), efifb_select_mode(), efipci_close(), efipci_open(), efipci_read(), efipci_root(), efipci_write(), nii_block(), nii_issue_cpb_db(), nii_pci_close(), nii_pci_open(), nii_start(), nii_stop(), nii_supported(), snp_supported(), snpnet_start(), snpnet_stop(), usbio_close(), usbio_open(), usbio_path(), usbio_start(), usbio_stop(), and usbio_supported().

EFI shutdown is in progress.

Definition at line 45 of file efi_init.c.

Referenced by efi_currticks(), and efi_shutdown_hook().