efi.h File Reference

EFI API. More...

#include <gpxe/efi/Uefi.h>
#include <gpxe/efi/PiDxe.h>
#include <gpxe/tables.h>
#include <gpxe/uuid.h>

Go to the source code of this file.

Data Structures

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

Defines

#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 gPXE.
#define EFI_REQUIRE_PROTOCOL(_protocol, _ptr)
 Declare an EFI protocol to be required by gPXE.
#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 gPXE.
#define EFI_USE_TABLE(_table, _ptr, _required)
 Declare an EFI configuration table to be used by gPXE.
#define RC_TO_EFIRC(rc)   (rc)
 Convert a gPXE status code to an EFI status code.
#define EFIRC_TO_RC(efirc)   (efirc)
 Convert an EFI status code to a gPXE status code.

Functions

const char * efi_strerror (EFI_STATUS efirc)
 Format EFI status code.
EFI_STATUS efi_init (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
 Initialise EFI environment.
int efi_snp_install (void)
 Install EFI SNP driver.

Variables

EFI_HANDLE efi_image_handle
 Image handle passed to entry point.
EFI_SYSTEM_TABLEefi_systab
 System table passed to entry point.


Detailed Description

EFI API.

The intention is to include near-verbatim copies of the EFI headers required by gPXE. 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 gPXE tree. It will also tidy up the file by removing carriage return characters and trailing whitespace.

At the time of writing, there are a few other modifications to these headers that are present in my personal edk2 tree, that are not yet committed back to the main edk2 repository. These modifications are fixes for compilation on case-dependent filesystems, compilation under -mrtd and -mregparm=3, etc.

Definition in file efi.h.


Define Documentation

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

EFI protocol table.

Definition at line 64 of file efi.h.

Referenced by efi_init().

#define __efi_protocol   __table_entry ( EFI_PROTOCOLS, 01 )

Declare an EFI protocol used by gPXE.

Definition at line 67 of file efi.h.

#define EFI_REQUIRE_PROTOCOL ( _protocol,
_ptr   ) 

Value:

struct efi_protocol __ ## _protocol __efi_protocol = {               \
                .u.guid = _protocol ## _GUID,                                \
                .protocol = ( ( void ** ) ( void * )                         \
                              ( ( (_ptr) == ( ( _protocol ** ) (_ptr) ) ) ?  \
                                (_ptr) : (_ptr) ) ),                         \
        }
Declare an EFI protocol to be required by gPXE.

Parameters:
_protocol EFI protocol name
_ptr Pointer to protocol instance

Definition at line 74 of file efi.h.

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

EFI configuration table table.

Definition at line 98 of file efi.h.

Referenced by efi_init().

#define __efi_config_table   __table_entry ( EFI_CONFIG_TABLES, 01 )

Declare an EFI configuration table used by gPXE.

Definition at line 102 of file efi.h.

#define EFI_USE_TABLE ( _table,
_ptr,
_required   ) 

Value:

struct efi_config_table __ ## _table __efi_config_table = {          \
                .u.guid = _table ## _GUID,                                   \
                .table = ( ( void ** ) ( void * ) (_ptr) ),                  \
                .required = (_required),                                     \
        }
Declare an EFI configuration table to be used by gPXE.

Parameters:
_table EFI configuration table name
_ptr Pointer to configuration table
_required Table is required for operation

Definition at line 110 of file efi.h.

#define RC_TO_EFIRC ( rc   )     (rc)

Convert a gPXE status code to an EFI status code.

FIXME: actually perform some kind of conversion. gPXE error codes will be detected as EFI error codes; both have the top bit set, and the success return code is zero for both. Anything that just reports a numerical error will be OK, anything attempting to interpret the value or to display a text equivalent will be screwed.

Definition at line 126 of file efi.h.

Referenced by _start(), efi_snp_initialize(), efi_snp_mcast_ip_to_mac(), efi_snp_receive(), efi_snp_reset(), and efi_snp_transmit().

#define EFIRC_TO_RC ( efirc   )     (efirc)

Convert an EFI status code to a gPXE status code.

FIXME: as above

Definition at line 132 of file efi.h.

Referenced by efi_image_exec(), and efi_snp_install().


Function Documentation

const char* efi_strerror ( EFI_STATUS  efirc  ) 

Format EFI status code.

Parameters:
efirc EFI status code
efi_strerror EFI status code string

Definition at line 36 of file efi_strerror.c.

References MAX_BIT, and snprintf().

Referenced by efi_currticks(), efi_getchar(), efi_image_exec(), efi_image_load(), efi_ioread(), efi_ioreads(), efi_iowrite(), efi_iowrites(), efi_snp_driver_start(), efi_snp_install(), efi_snp_netdev(), efi_snp_snpdev(), efi_udelay(), efi_urealloc(), efipci_read(), and efipci_write().

00036                                                {
00037         static char errbuf[32];
00038 
00039         if ( ! efirc )
00040                 return "No error";
00041 
00042         snprintf ( errbuf, sizeof ( errbuf ), "Error %lld",
00043                    ( unsigned long long ) ( efirc ^ MAX_BIT ) );
00044         return errbuf;
00045 }

EFI_STATUS efi_init ( EFI_HANDLE  image_handle,
EFI_SYSTEM_TABLE systab 
)

Initialise EFI environment.

Parameters:
image_handle Image handle
systab System table
Return values:
efirc EFI return status code

Definition at line 56 of file efi_init.c.

References _EFI_SYSTEM_TABLE::BootServices, _EFI_SYSTEM_TABLE::ConOut, DBGC, EFI_CONFIG_TABLES, efi_find_table(), efi_image_handle, EFI_NOT_AVAILABLE_YET, EFI_PROTOCOLS, for_each_table_entry, efi_config_table::guid, efi_protocol::guid, EFI_BOOT_SERVICES::LocateProtocol, NULL, efi_protocol::protocol, efi_config_table::required, _EFI_SYSTEM_TABLE::RuntimeServices, efi_config_table::table, efi_config_table::u, efi_protocol::u, efi_config_table::uuid, efi_protocol::uuid, and uuid_ntoa().

Referenced by _start().

00057                                                  {
00058         EFI_BOOT_SERVICES *bs;
00059         struct efi_protocol *prot;
00060         struct efi_config_table *tab;
00061         EFI_STATUS efirc;
00062 
00063         /* Store image handle and system table pointer for future use */
00064         efi_image_handle = image_handle;
00065         efi_systab = systab;
00066 
00067         /* Sanity checks */
00068         if ( ! systab )
00069                 return EFI_NOT_AVAILABLE_YET;
00070         if ( ! systab->ConOut )
00071                 return EFI_NOT_AVAILABLE_YET;
00072         if ( ! systab->BootServices ) {
00073                 DBGC ( systab, "EFI provided no BootServices entry point\n" );
00074                 return EFI_NOT_AVAILABLE_YET;
00075         }
00076         if ( ! systab->RuntimeServices ) {
00077                 DBGC ( systab, "EFI provided no RuntimeServices entry "
00078                        "point\n" );
00079                 return EFI_NOT_AVAILABLE_YET;
00080         }
00081         DBGC ( systab, "EFI handle %p systab %p\n", image_handle, systab );
00082 
00083         /* Look up used protocols */
00084         bs = systab->BootServices;
00085         for_each_table_entry ( prot, EFI_PROTOCOLS ) {
00086                 if ( ( efirc = bs->LocateProtocol ( &prot->u.guid, NULL,
00087                                                     prot->protocol ) ) == 0 ) {
00088                         DBGC ( systab, "EFI protocol %s is at %p\n",
00089                                uuid_ntoa ( &prot->u.uuid ), *(prot->protocol));
00090                 } else {
00091                         DBGC ( systab, "EFI does not provide protocol %s\n",
00092                                uuid_ntoa ( &prot->u.uuid ) );
00093                         /* All protocols are required */
00094                         return efirc;
00095                 }
00096         }
00097 
00098         /* Look up used configuration tables */
00099         for_each_table_entry ( tab, EFI_CONFIG_TABLES ) {
00100                 if ( ( *(tab->table) = efi_find_table ( &tab->u.guid ) ) ) {
00101                         DBGC ( systab, "EFI configuration table %s is at %p\n",
00102                                uuid_ntoa ( &tab->u.uuid ), *(tab->table) );
00103                 } else {
00104                         DBGC ( systab, "EFI does not provide configuration "
00105                                "table %s\n", uuid_ntoa ( &tab->u.uuid ) );
00106                         if ( tab->required )
00107                                 return EFI_NOT_AVAILABLE_YET;
00108                 }
00109         }
00110 
00111         return 0;
00112 }

int efi_snp_install ( void   ) 

Install EFI SNP driver.

Return values:
rc Return status code

Definition at line 1129 of file efi_snp.c.

References _EFI_SYSTEM_TABLE::BootServices, DBGC, _EFI_DRIVER_BINDING_PROTOCOL::DriverBindingHandle, efi_component_name2_protocol_guid, efi_driver_binding_protocol_guid, efi_image_handle, efi_strerror(), efi_systab, EFIRC_TO_RC, _EFI_DRIVER_BINDING_PROTOCOL::ImageHandle, EFI_BOOT_SERVICES::InstallMultipleProtocolInterfaces, and NULL.

Referenced by _start().

01129                              {
01130         EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
01131         EFI_DRIVER_BINDING_PROTOCOL *driver = &efi_snp_binding;
01132         EFI_STATUS efirc;
01133 
01134         driver->ImageHandle = efi_image_handle;
01135         if ( ( efirc = bs->InstallMultipleProtocolInterfaces (
01136                         &driver->DriverBindingHandle,
01137                         &efi_driver_binding_protocol_guid, driver,
01138                         &efi_component_name2_protocol_guid, &efi_snp_name,
01139                         NULL ) ) != 0 ) {
01140                 DBGC ( driver, "SNPDRV %p could not install protocols: "
01141                        "%s\n", driver, efi_strerror ( efirc ) );
01142                 return EFIRC_TO_RC ( efirc );
01143         }
01144 
01145         DBGC ( driver, "SNPDRV %p driver binding installed as %p\n",
01146                driver, driver->DriverBindingHandle );
01147         return 0;
01148 }


Variable Documentation

Image handle passed to entry point.

Definition at line 26 of file efi_init.c.

Referenced by efi_image_exec(), efi_image_load(), efi_init(), and efi_snp_install().


Generated on Tue Apr 6 20:01:14 2010 for gPXE by  doxygen 1.5.7.1