efi_init.c File Reference

#include <string.h>
#include <gpxe/efi/efi.h>
#include <gpxe/uuid.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static void * efi_find_table (EFI_GUID *guid)
 Look up EFI configuration table.
EFI_STATUS efi_init (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
 Initialise EFI environment.

Variables

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


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static void* efi_find_table ( EFI_GUID guid  )  [static]

Look up EFI configuration table.

Parameters:
guid Configuration table GUID
Return values:
table Configuration table, or NULL

Definition at line 37 of file efi_init.c.

References _EFI_SYSTEM_TABLE::ConfigurationTable, memcmp(), NULL, _EFI_SYSTEM_TABLE::NumberOfTableEntries, EFI_CONFIGURATION_TABLE::VendorGuid, and EFI_CONFIGURATION_TABLE::VendorTable.

Referenced by efi_init().

00037                                                 {
00038         unsigned int i;
00039 
00040         for ( i = 0 ; i < efi_systab->NumberOfTableEntries ; i++ ) {
00041                 if ( memcmp ( &efi_systab->ConfigurationTable[i].VendorGuid,
00042                               guid, sizeof ( *guid ) ) == 0 )
00043                         return efi_systab->ConfigurationTable[i].VendorTable;
00044         }
00045 
00046         return NULL;
00047 }

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 }


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:53 2010 for gPXE by  doxygen 1.5.7.1