You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef _EFI_H
  2. #define _EFI_H
  3. /** @file
  4. *
  5. * EFI API
  6. *
  7. * The intention is to include near-verbatim copies of the EFI headers
  8. * required by gPXE. This is achieved using the import.pl script in
  9. * this directory. Run the import script to update the local copies
  10. * of the headers:
  11. *
  12. * ./import.pl /path/to/edk2/edk2
  13. *
  14. * where /path/to/edk2/edk2 is the path to your local checkout of the
  15. * EFI Development Kit.
  16. *
  17. * Note that import.pl will modify any #include lines in each imported
  18. * header to reflect its new location within the gPXE tree. It will
  19. * also tidy up the file by removing carriage return characters and
  20. * trailing whitespace.
  21. *
  22. *
  23. * At the time of writing, there are a few other modifications to
  24. * these headers that are present in my personal edk2 tree, that are
  25. * not yet committed back to the main edk2 repository. These
  26. * modifications are fixes for compilation on case-dependent
  27. * filesystems, compilation under -mrtd and -mregparm=3, etc.
  28. */
  29. /* EFI headers rudely redefine NULL */
  30. #undef NULL
  31. /* EFI headers expect ICC to define __GNUC__ */
  32. #if defined ( __ICC ) && ! defined ( __GNUC__ )
  33. #define __GNUC__ 1
  34. #endif
  35. /* Include the top-level EFI header files */
  36. #include <gpxe/efi/Uefi.h>
  37. #include <gpxe/efi/PiDxe.h>
  38. /* Reset any trailing #pragma pack directives */
  39. #pragma pack(1)
  40. #pragma pack()
  41. #include <gpxe/tables.h>
  42. #include <gpxe/uuid.h>
  43. /** An EFI protocol used by gPXE */
  44. struct efi_protocol {
  45. /** GUID */
  46. union {
  47. /** EFI protocol GUID */
  48. EFI_GUID guid;
  49. /** UUID structure understood by gPXE */
  50. union uuid uuid;
  51. } u;
  52. /** Variable containing pointer to protocol structure */
  53. void **protocol;
  54. };
  55. /** EFI protocol table */
  56. #define EFI_PROTOCOLS __table ( struct efi_protocol, "efi_protocols" )
  57. /** Declare an EFI protocol used by gPXE */
  58. #define __efi_protocol __table_entry ( EFI_PROTOCOLS, 01 )
  59. /** Declare an EFI protocol to be required by gPXE
  60. *
  61. * @v _protocol EFI protocol name
  62. * @v _ptr Pointer to protocol instance
  63. */
  64. #define EFI_REQUIRE_PROTOCOL( _protocol, _ptr ) \
  65. struct efi_protocol __ ## _protocol __efi_protocol = { \
  66. .u.guid = _protocol ## _GUID, \
  67. .protocol = ( ( void ** ) ( void * ) \
  68. ( ( (_ptr) == ( ( _protocol ** ) (_ptr) ) ) ? \
  69. (_ptr) : (_ptr) ) ), \
  70. }
  71. /** An EFI configuration table used by gPXE */
  72. struct efi_config_table {
  73. /** GUID */
  74. union {
  75. /** EFI configuration table GUID */
  76. EFI_GUID guid;
  77. /** UUID structure understood by gPXE */
  78. union uuid uuid;
  79. } u;
  80. /** Variable containing pointer to configuration table */
  81. void **table;
  82. /** Table is required for operation */
  83. int required;
  84. };
  85. /** EFI configuration table table */
  86. #define EFI_CONFIG_TABLES \
  87. __table ( struct efi_config_table, "efi_config_tables" )
  88. /** Declare an EFI configuration table used by gPXE */
  89. #define __efi_config_table __table_entry ( EFI_CONFIG_TABLES, 01 )
  90. /** Declare an EFI configuration table to be used by gPXE
  91. *
  92. * @v _table EFI configuration table name
  93. * @v _ptr Pointer to configuration table
  94. * @v _required Table is required for operation
  95. */
  96. #define EFI_USE_TABLE( _table, _ptr, _required ) \
  97. struct efi_config_table __ ## _table __efi_config_table = { \
  98. .u.guid = _table ## _GUID, \
  99. .table = ( ( void ** ) ( void * ) (_ptr) ), \
  100. .required = (_required), \
  101. }
  102. /** Convert a gPXE status code to an EFI status code
  103. *
  104. * FIXME: actually perform some kind of conversion. gPXE error codes
  105. * will be detected as EFI error codes; both have the top bit set, and
  106. * the success return code is zero for both. Anything that just
  107. * reports a numerical error will be OK, anything attempting to
  108. * interpret the value or to display a text equivalent will be
  109. * screwed.
  110. */
  111. #define RC_TO_EFIRC( rc ) (rc)
  112. /** Convert an EFI status code to a gPXE status code
  113. *
  114. * FIXME: as above
  115. */
  116. #define EFIRC_TO_RC( efirc ) (efirc)
  117. extern EFI_HANDLE efi_image_handle;
  118. extern EFI_SYSTEM_TABLE *efi_systab;
  119. extern const char * efi_strerror ( EFI_STATUS efirc );
  120. extern EFI_STATUS efi_init ( EFI_HANDLE image_handle,
  121. EFI_SYSTEM_TABLE *systab );
  122. extern int efi_snp_install ( void );
  123. #endif /* _EFI_H */