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 "efi_protocols"
60 /** Declare an EFI protocol used by gPXE */
61 #define __efi_protocol \
62 __table ( struct efi_protocol, EFI_PROTOCOLS, 01 )
64 /** Declare an EFI protocol to be required by gPXE
66 * @v _protocol EFI protocol name
67 * @v _ptr Pointer to protocol instance
69 #define EFI_REQUIRE_PROTOCOL( _protocol, _ptr ) \
70 struct efi_protocol __ ## _protocol __efi_protocol = { \
71 .u.guid = _protocol ## _GUID, \
72 .protocol = ( ( void ** ) ( void * ) \
73 ( ( (_ptr) == ( ( _protocol ** ) NULL ) ) ? \
74 (_ptr) : (_ptr) ) ), \
77 /** An EFI configuration table used by gPXE */
78 struct efi_config_table {
81 /** EFI configuration table GUID */
83 /** UUID structure understood by gPXE */
86 /** Variable containing pointer to configuration table */
88 /** Table is required for operation */
92 /** EFI configuration table table */
93 #define EFI_CONFIG_TABLES "efi_config_tables"
95 /** Declare an EFI configuration table used by gPXE */
96 #define __efi_config_table \
97 __table ( struct efi_config_table, EFI_CONFIG_TABLES, 01 )
99 /** Declare an EFI configuration table to be used by gPXE
101 * @v _table EFI configuration table name
102 * @v _ptr Pointer to configuration table
103 * @v _required Table is required for operation
105 #define EFI_USE_TABLE( _table, _ptr, _required ) \
106 struct efi_config_table __ ## _table __efi_config_table = { \
107 .u.guid = _table ## _GUID, \
108 .table = ( ( void ** ) ( void * ) (_ptr) ), \
109 .required = (_required), \
112 /** Convert a gPXE status code to an EFI status code
114 * FIXME: actually perform some kind of conversion. gPXE error codes
115 * will be detected as EFI error codes; both have the top bit set, and
116 * the success return code is zero for both. Anything that just
117 * reports a numerical error will be OK, anything attempting to
118 * interpret the value or to display a text equivalent will be
121 #define RC_TO_EFIRC( rc ) (rc)
123 /** Convert an EFI status code to a gPXE status code
127 #define EFIRC_TO_RC( efirc ) (efirc)
129 extern EFI_HANDLE efi_image_handle;
130 extern EFI_SYSTEM_TABLE *efi_systab;
132 extern const char * efi_strerror ( EFI_STATUS efirc );
133 extern EFI_STATUS efi_init ( EFI_HANDLE image_handle,
134 EFI_SYSTEM_TABLE *systab );
135 extern int efi_snp_install ( void );