00001 #ifndef _EFI_H 00002 #define _EFI_H 00003 00004 /** @file 00005 * 00006 * EFI API 00007 * 00008 * The intention is to include near-verbatim copies of the EFI headers 00009 * required by gPXE. This is achieved using the import.pl script in 00010 * this directory. Run the import script to update the local copies 00011 * of the headers: 00012 * 00013 * ./import.pl /path/to/edk2/edk2 00014 * 00015 * where /path/to/edk2/edk2 is the path to your local checkout of the 00016 * EFI Development Kit. 00017 * 00018 * Note that import.pl will modify any #include lines in each imported 00019 * header to reflect its new location within the gPXE tree. It will 00020 * also tidy up the file by removing carriage return characters and 00021 * trailing whitespace. 00022 * 00023 * 00024 * At the time of writing, there are a few other modifications to 00025 * these headers that are present in my personal edk2 tree, that are 00026 * not yet committed back to the main edk2 repository. These 00027 * modifications are fixes for compilation on case-dependent 00028 * filesystems, compilation under -mrtd and -mregparm=3, etc. 00029 */ 00030 00031 /* EFI headers rudely redefine NULL */ 00032 #undef NULL 00033 00034 /* EFI headers expect ICC to define __GNUC__ */ 00035 #if defined ( __ICC ) && ! defined ( __GNUC__ ) 00036 #define __GNUC__ 1 00037 #endif 00038 00039 /* Include the top-level EFI header files */ 00040 #include <gpxe/efi/Uefi.h> 00041 #include <gpxe/efi/PiDxe.h> 00042 00043 /* Reset any trailing #pragma pack directives */ 00044 #pragma pack(1) 00045 #pragma pack() 00046 00047 #include <gpxe/tables.h> 00048 #include <gpxe/uuid.h> 00049 00050 /** An EFI protocol used by gPXE */ 00051 struct efi_protocol { 00052 /** GUID */ 00053 union { 00054 /** EFI protocol GUID */ 00055 EFI_GUID guid; 00056 /** UUID structure understood by gPXE */ 00057 union uuid uuid; 00058 } u; 00059 /** Variable containing pointer to protocol structure */ 00060 void **protocol; 00061 }; 00062 00063 /** EFI protocol table */ 00064 #define EFI_PROTOCOLS __table ( struct efi_protocol, "efi_protocols" ) 00065 00066 /** Declare an EFI protocol used by gPXE */ 00067 #define __efi_protocol __table_entry ( EFI_PROTOCOLS, 01 ) 00068 00069 /** Declare an EFI protocol to be required by gPXE 00070 * 00071 * @v _protocol EFI protocol name 00072 * @v _ptr Pointer to protocol instance 00073 */ 00074 #define EFI_REQUIRE_PROTOCOL( _protocol, _ptr ) \ 00075 struct efi_protocol __ ## _protocol __efi_protocol = { \ 00076 .u.guid = _protocol ## _GUID, \ 00077 .protocol = ( ( void ** ) ( void * ) \ 00078 ( ( (_ptr) == ( ( _protocol ** ) (_ptr) ) ) ? \ 00079 (_ptr) : (_ptr) ) ), \ 00080 } 00081 00082 /** An EFI configuration table used by gPXE */ 00083 struct efi_config_table { 00084 /** GUID */ 00085 union { 00086 /** EFI configuration table GUID */ 00087 EFI_GUID guid; 00088 /** UUID structure understood by gPXE */ 00089 union uuid uuid; 00090 } u; 00091 /** Variable containing pointer to configuration table */ 00092 void **table; 00093 /** Table is required for operation */ 00094 int required; 00095 }; 00096 00097 /** EFI configuration table table */ 00098 #define EFI_CONFIG_TABLES \ 00099 __table ( struct efi_config_table, "efi_config_tables" ) 00100 00101 /** Declare an EFI configuration table used by gPXE */ 00102 #define __efi_config_table __table_entry ( EFI_CONFIG_TABLES, 01 ) 00103 00104 /** Declare an EFI configuration table to be used by gPXE 00105 * 00106 * @v _table EFI configuration table name 00107 * @v _ptr Pointer to configuration table 00108 * @v _required Table is required for operation 00109 */ 00110 #define EFI_USE_TABLE( _table, _ptr, _required ) \ 00111 struct efi_config_table __ ## _table __efi_config_table = { \ 00112 .u.guid = _table ## _GUID, \ 00113 .table = ( ( void ** ) ( void * ) (_ptr) ), \ 00114 .required = (_required), \ 00115 } 00116 00117 /** Convert a gPXE status code to an EFI status code 00118 * 00119 * FIXME: actually perform some kind of conversion. gPXE error codes 00120 * will be detected as EFI error codes; both have the top bit set, and 00121 * the success return code is zero for both. Anything that just 00122 * reports a numerical error will be OK, anything attempting to 00123 * interpret the value or to display a text equivalent will be 00124 * screwed. 00125 */ 00126 #define RC_TO_EFIRC( rc ) (rc) 00127 00128 /** Convert an EFI status code to a gPXE status code 00129 * 00130 * FIXME: as above 00131 */ 00132 #define EFIRC_TO_RC( efirc ) (efirc) 00133 00134 extern EFI_HANDLE efi_image_handle; 00135 extern EFI_SYSTEM_TABLE *efi_systab; 00136 00137 extern const char * efi_strerror ( EFI_STATUS efirc ); 00138 extern EFI_STATUS efi_init ( EFI_HANDLE image_handle, 00139 EFI_SYSTEM_TABLE *systab ); 00140 extern int efi_snp_install ( void ); 00141 00142 #endif /* _EFI_H */
1.5.7.1