Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

efi.h 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. /* Include the top-level EFI header files */
  32. #include <gpxe/efi/Uefi.h>
  33. #include <gpxe/efi/PiDxe.h>
  34. /* Reset any trailing #pragma pack directives */
  35. #pragma pack()
  36. #include <gpxe/tables.h>
  37. #include <gpxe/uuid.h>
  38. /** An EFI protocol used by gPXE */
  39. struct efi_protocol {
  40. /** GUID */
  41. union {
  42. /** EFI protocol GUID */
  43. EFI_GUID guid;
  44. /** UUID structure understood by gPXE */
  45. union uuid uuid;
  46. } u;
  47. /** Variable containing pointer to protocol structure */
  48. void **protocol;
  49. };
  50. /** Declare an EFI protocol used by gPXE */
  51. #define __efi_protocol \
  52. __table ( struct efi_protocol, efi_protocols, 01 )
  53. /** Declare an EFI protocol to be required by gPXE
  54. *
  55. * @v _protocol EFI protocol name
  56. * @v _ptr Pointer to protocol instance
  57. */
  58. #define EFI_REQUIRE_PROTOCOL( _protocol, _ptr ) \
  59. struct efi_protocol __ ## _protocol __efi_protocol = { \
  60. .u.guid = _protocol ## _GUID, \
  61. .protocol = ( ( void ** ) ( void * ) \
  62. ( ( (_ptr) == ( ( _protocol ** ) NULL ) ) ? \
  63. (_ptr) : (_ptr) ) ), \
  64. }
  65. /** An EFI configuration table used by gPXE */
  66. struct efi_config_table {
  67. /** GUID */
  68. union {
  69. /** EFI configuration table GUID */
  70. EFI_GUID guid;
  71. /** UUID structure understood by gPXE */
  72. union uuid uuid;
  73. } u;
  74. /** Variable containing pointer to configuration table */
  75. void **table;
  76. /** Table is required for operation */
  77. int required;
  78. };
  79. /** Declare an EFI configuration table used by gPXE */
  80. #define __efi_config_table \
  81. __table ( struct efi_config_table, efi_config_tables, 01 )
  82. /** Declare an EFI configuration table to be used by gPXE
  83. *
  84. * @v _table EFI configuration table name
  85. * @v _ptr Pointer to configuration table
  86. * @v _required Table is required for operation
  87. */
  88. #define EFI_USE_TABLE( _table, _ptr, _required ) \
  89. struct efi_config_table __ ## _table __efi_config_table = { \
  90. .u.guid = _table ## _GUID, \
  91. .table = ( ( void ** ) ( void * ) (_ptr) ), \
  92. .required = (_required), \
  93. }
  94. /** Convert a gPXE status code to an EFI status code
  95. *
  96. * FIXME: actually perform some kind of conversion. gPXE error codes
  97. * will be detected as EFI error codes; both have the top bit set, and
  98. * the success return code is zero for both. Anything that just
  99. * reports a numerical error will be OK, anything attempting to
  100. * interpret the value or to display a text equivalent will be
  101. * screwed.
  102. */
  103. #define RC_TO_EFIRC( rc ) (rc)
  104. /** Convert an EFI status code to a gPXE status code
  105. *
  106. * FIXME: as above
  107. */
  108. #define EFIRC_TO_RC( efirc ) (efirc)
  109. extern EFI_HANDLE efi_image_handle;
  110. extern EFI_SYSTEM_TABLE *efi_systab;
  111. extern const char * efi_strerror ( EFI_STATUS efirc );
  112. extern EFI_STATUS efi_init ( EFI_HANDLE image_handle,
  113. EFI_SYSTEM_TABLE *systab );
  114. extern int efi_snp_install ( void );
  115. #endif /* _EFI_H */