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 /* Include the top-level EFI header files */
35 #include <gpxe/efi/Uefi.h>
36 #include <gpxe/efi/PiDxe.h>
38 /* Reset any trailing #pragma pack directives */
41 #include <gpxe/tables.h>
42 #include <gpxe/uuid.h>
44 /** An EFI protocol used by gPXE */
48 /** EFI protocol GUID */
50 /** UUID structure understood by gPXE */
53 /** Variable containing pointer to protocol structure */
57 /** EFI protocol table */
58 #define EFI_PROTOCOLS __table ( struct efi_protocol, "efi_protocols" )
60 /** Declare an EFI protocol used by gPXE */
61 #define __efi_protocol __table_entry ( EFI_PROTOCOLS, 01 )
63 /** Declare an EFI protocol to be required by gPXE
65 * @v _protocol EFI protocol name
66 * @v _ptr Pointer to protocol instance
68 #define EFI_REQUIRE_PROTOCOL( _protocol, _ptr ) \
69 struct efi_protocol __ ## _protocol __efi_protocol = { \
70 .u.guid = _protocol ## _GUID, \
71 .protocol = ( ( void ** ) ( void * ) \
72 ( ( (_ptr) == ( ( _protocol ** ) NULL ) ) ? \
73 (_ptr) : (_ptr) ) ), \
76 /** An EFI configuration table used by gPXE */
77 struct efi_config_table {
80 /** EFI configuration table GUID */
82 /** UUID structure understood by gPXE */
85 /** Variable containing pointer to configuration table */
87 /** Table is required for operation */
91 /** EFI configuration table table */
92 #define EFI_CONFIG_TABLES \
93 __table ( struct efi_config_table, "efi_config_tables" )
95 /** Declare an EFI configuration table used by gPXE */
96 #define __efi_config_table __table_entry ( EFI_CONFIG_TABLES, 01 )
98 /** Declare an EFI configuration table to be used by gPXE
100 * @v _table EFI configuration table name
101 * @v _ptr Pointer to configuration table
102 * @v _required Table is required for operation
104 #define EFI_USE_TABLE( _table, _ptr, _required ) \
105 struct efi_config_table __ ## _table __efi_config_table = { \
106 .u.guid = _table ## _GUID, \
107 .table = ( ( void ** ) ( void * ) (_ptr) ), \
108 .required = (_required), \
111 /** Convert a gPXE status code to an EFI status code
113 * FIXME: actually perform some kind of conversion. gPXE error codes
114 * will be detected as EFI error codes; both have the top bit set, and
115 * the success return code is zero for both. Anything that just
116 * reports a numerical error will be OK, anything attempting to
117 * interpret the value or to display a text equivalent will be
120 #define RC_TO_EFIRC( rc ) (rc)
122 /** Convert an EFI status code to a gPXE status code
126 #define EFIRC_TO_RC( efirc ) (efirc)
128 extern EFI_HANDLE efi_image_handle;
129 extern EFI_SYSTEM_TABLE *efi_systab;
131 extern const char * efi_strerror ( EFI_STATUS efirc );
132 extern EFI_STATUS efi_init ( EFI_HANDLE image_handle,
133 EFI_SYSTEM_TABLE *systab );
134 extern int efi_snp_install ( void );