8 * The intention is to include near-verbatim copies of the EFI headers
9 * required by gPXE. This is achieved using the import.pl script in
10 * this directory. Run the import script to update the local copies
13 * ./import.pl /path/to/edk2/edk2
15 * where /path/to/edk2/edk2 is the path to your local checkout of the
16 * EFI Development Kit.
18 * Note that import.pl will modify any #include lines in each imported
19 * header to reflect its new location within the gPXE tree. It will
20 * also tidy up the file by removing carriage return characters and
21 * trailing whitespace.
24 * At the time of writing, there are a few other modifications to
25 * these headers that are present in my personal edk2 tree, that are
26 * not yet committed back to the main edk2 repository. These
27 * modifications are fixes for compilation on case-dependent
28 * filesystems, compilation under -mrtd and -mregparm=3, etc.
31 /* EFI headers rudely redefine NULL */
34 /* EFI headers expect ICC to define __GNUC__ */
35 #if defined ( __ICC ) && ! defined ( __GNUC__ )
39 /* Include the top-level EFI header files */
40 #include <gpxe/efi/Uefi.h>
41 #include <gpxe/efi/PiDxe.h>
43 /* Reset any trailing #pragma pack directives */
46 #include <gpxe/tables.h>
47 #include <gpxe/uuid.h>
49 /** An EFI protocol used by gPXE */
53 /** EFI protocol GUID */
55 /** UUID structure understood by gPXE */
58 /** Variable containing pointer to protocol structure */
62 /** EFI protocol table */
63 #define EFI_PROTOCOLS __table ( struct efi_protocol, "efi_protocols" )
65 /** Declare an EFI protocol used by gPXE */
66 #define __efi_protocol __table_entry ( EFI_PROTOCOLS, 01 )
68 /** Declare an EFI protocol to be required by gPXE
70 * @v _protocol EFI protocol name
71 * @v _ptr Pointer to protocol instance
73 #define EFI_REQUIRE_PROTOCOL( _protocol, _ptr ) \
74 struct efi_protocol __ ## _protocol __efi_protocol = { \
75 .u.guid = _protocol ## _GUID, \
76 .protocol = ( ( void ** ) ( void * ) \
77 ( ( (_ptr) == ( ( _protocol ** ) (_ptr) ) ) ? \
78 (_ptr) : (_ptr) ) ), \
81 /** An EFI configuration table used by gPXE */
82 struct efi_config_table {
85 /** EFI configuration table GUID */
87 /** UUID structure understood by gPXE */
90 /** Variable containing pointer to configuration table */
92 /** Table is required for operation */
96 /** EFI configuration table table */
97 #define EFI_CONFIG_TABLES \
98 __table ( struct efi_config_table, "efi_config_tables" )
100 /** Declare an EFI configuration table used by gPXE */
101 #define __efi_config_table __table_entry ( EFI_CONFIG_TABLES, 01 )
103 /** Declare an EFI configuration table to be used by gPXE
105 * @v _table EFI configuration table name
106 * @v _ptr Pointer to configuration table
107 * @v _required Table is required for operation
109 #define EFI_USE_TABLE( _table, _ptr, _required ) \
110 struct efi_config_table __ ## _table __efi_config_table = { \
111 .u.guid = _table ## _GUID, \
112 .table = ( ( void ** ) ( void * ) (_ptr) ), \
113 .required = (_required), \
116 /** Convert a gPXE status code to an EFI status code
118 * FIXME: actually perform some kind of conversion. gPXE error codes
119 * will be detected as EFI error codes; both have the top bit set, and
120 * the success return code is zero for both. Anything that just
121 * reports a numerical error will be OK, anything attempting to
122 * interpret the value or to display a text equivalent will be
125 #define RC_TO_EFIRC( rc ) (rc)
127 /** Convert an EFI status code to a gPXE status code
131 #define EFIRC_TO_RC( efirc ) (efirc)
133 extern EFI_HANDLE efi_image_handle;
134 extern EFI_SYSTEM_TABLE *efi_systab;
136 extern const char * efi_strerror ( EFI_STATUS efirc );
137 extern EFI_STATUS efi_init ( EFI_HANDLE image_handle,
138 EFI_SYSTEM_TABLE *systab );
139 extern int efi_snp_install ( void );