efiimg.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*++
  2. Copyright (c) 2014 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. efiimg.h
  9. Abstract:
  10. This header contains definitions for the EFI image format.
  11. Author:
  12. Evan Green 6-Mar-2014
  13. --*/
  14. //
  15. // ------------------------------------------------------------------- Includes
  16. //
  17. //
  18. // --------------------------------------------------------------------- Macros
  19. //
  20. //
  21. // ---------------------------------------------------------------- Definitions
  22. //
  23. //
  24. // Define EFI file types.
  25. //
  26. #define EFI_FV_FILETYPE_ALL 0x00
  27. #define EFI_FV_FILETYPE_RAW 0x01
  28. #define EFI_FV_FILETYPE_FREEFORM 0x02
  29. #define EFI_FV_FILETYPE_SECURITY_CORE 0x03
  30. #define EFI_FV_FILETYPE_PEI_CORE 0x04
  31. #define EFI_FV_FILETYPE_DXE_CORE 0x05
  32. #define EFI_FV_FILETYPE_PEIM 0x06
  33. #define EFI_FV_FILETYPE_DRIVER 0x07
  34. #define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08
  35. #define EFI_FV_FILETYPE_APPLICATION 0x09
  36. #define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
  37. #define EFI_SECTION_ALL 0x00
  38. //
  39. // Define EFI encapsulation section types.
  40. //
  41. #define EFI_SECTION_COMPRESSION 0x01
  42. #define EFI_SECTION_GUID_DEFINED 0x02
  43. //
  44. // Define EFI leaf section types.
  45. //
  46. #define EFI_SECTION_FIRST_LEAF_SECTION_TYPE 0x10
  47. #define EFI_SECTION_PE32 0x10
  48. #define EFI_SECTION_PIC 0x11
  49. #define EFI_SECTION_TE 0x12
  50. #define EFI_SECTION_DXE_DEPEX 0x13
  51. #define EFI_SECTION_VERSION 0x14
  52. #define EFI_SECTION_USER_INTERFACE 0x15
  53. #define EFI_SECTION_COMPATIBILITY16 0x16
  54. #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
  55. #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
  56. #define EFI_SECTION_RAW 0x19
  57. #define EFI_SECTION_PEI_DEPEX 0x1B
  58. #define EFI_SECTION_LAST_LEAF_SECTION_TYPE 0x1B
  59. #define EFI_SECTION_LAST_SECTION_TYPE 0x1B
  60. //
  61. // Define compression type values.
  62. //
  63. #define EFI_NOT_COMPRESSED 0x00
  64. #define EFI_STANDARD_COMPRESSION 0x01
  65. #define EFI_CUSTOMIZED_COMPRESSION 0x02
  66. //
  67. // Define GUIDed section attributes.
  68. //
  69. #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
  70. #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
  71. //
  72. // Define authentication status bits.
  73. //
  74. #define EFI_AGGREGATE_AUTH_STATUS_PLATFORM_OVERRIDE 0x000001
  75. #define EFI_AGGREGATE_AUTH_STATUS_IMAGE_SIGNED 0x000002
  76. #define EFI_AGGREGATE_AUTH_STATUS_NOT_TESTED 0x000004
  77. #define EFI_AGGREGATE_AUTH_STATUS_TEST_FAILED 0x000008
  78. #define EFI_AGGREGATE_AUTH_STATUS_ALL 0x00000f
  79. #define EFI_LOCAL_AUTH_STATUS_PLATFORM_OVERRIDE 0x010000
  80. #define EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED 0x020000
  81. #define EFI_LOCAL_AUTH_STATUS_NOT_TESTED 0x040000
  82. #define EFI_LOCAL_AUTH_STATUS_TEST_FAILED 0x080000
  83. #define EFI_LOCAL_AUTH_STATUS_ALL 0x0f0000
  84. //
  85. // ------------------------------------------------------ Data Type Definitions
  86. //
  87. typedef UINT8 EFI_FV_FILETYPE, *PEFI_FV_FILETYPE;
  88. typedef UINT8 EFI_SECTION_TYPE, *PEFI_SECTION_TYPE;
  89. #pragma pack(push, 1)
  90. typedef union _EFI_COMMON_SECTION_HEADER {
  91. struct {
  92. UINT8 Size[3];
  93. UINT8 Type;
  94. } Elements;
  95. UINT32 AsUint32;
  96. } PACKED EFI_COMMON_SECTION_HEADER, *PEFI_COMMON_SECTION_HEADER;
  97. typedef union _EFI_COMMON_SECTION_HEADER2 {
  98. struct {
  99. UINT8 Size[3];
  100. EFI_SECTION_TYPE Type;
  101. UINT32 ExtendedSize;
  102. } Elements;
  103. UINT32 AsUint32;
  104. } PACKED EFI_COMMON_SECTION_HEADER2, *PEFI_COMMON_SECTION_HEADER2;
  105. typedef struct _EFI_COMPRESSION_SECTION {
  106. EFI_COMMON_SECTION_HEADER CommonHeader;
  107. UINT32 UncompressedLength;
  108. UINT8 CompressionType;
  109. } PACKED EFI_COMPRESSION_SECTION, *PEFI_COMPRESSION_SECTION;
  110. typedef struct _EFI_GUID_DEFINED_SECTION {
  111. EFI_COMMON_SECTION_HEADER CommonHeader;
  112. EFI_GUID SectionDefinitionGuid;
  113. UINT16 DataOffset;
  114. UINT16 Attributes;
  115. } PACKED EFI_GUID_DEFINED_SECTION, *PEFI_GUID_DEFINED_SECTION;
  116. typedef struct _EFI_GUID_DEFINED_SECTION2 {
  117. EFI_COMMON_SECTION_HEADER2 CommonHeader;
  118. EFI_GUID SectionDefinitionGuid;
  119. UINT16 DataOffset;
  120. UINT16 Attributes;
  121. } PACKED EFI_GUID_DEFINED_SECTION2, *PEFI_GUID_DEFINED_SECTION2;
  122. typedef struct _EFI_PE32_SECTION {
  123. EFI_COMMON_SECTION_HEADER CommonHeader;
  124. } PACKED EFI_PE32_SECTION, *PEFI_PE32_SECTION;
  125. typedef struct _EFI_PIC_SECTION {
  126. EFI_COMMON_SECTION_HEADER CommonHeader;
  127. } PACKED EFI_PIC_SECTION, *PEFI_PIC_SECTION;
  128. typedef struct _EFI_PEIM_HEADER_SECTION {
  129. EFI_COMMON_SECTION_HEADER CommonHeader;
  130. } PACKED EFI_PEIM_HEADER_SECTION, *PEFI_PEIM_HEADER_SECTION;
  131. typedef struct _EFI_DEPEX_SECTION {
  132. EFI_COMMON_SECTION_HEADER CommonHeader;
  133. } PACKED EFI_DEPEX_SECTION, *PEFI_DEPEX_SECTION;
  134. typedef struct _EFI_VERSION_SECTION {
  135. EFI_COMMON_SECTION_HEADER CommonHeader;
  136. UINT16 BuildNumber;
  137. INT16 VersionString[1];
  138. } PACKED EFI_VERSION_SECTION, *PEFI_VERSION_SECTION;
  139. typedef struct _EFI_USER_INTERFACE_SECTION {
  140. EFI_COMMON_SECTION_HEADER CommonHeader;
  141. INT16 FileNameString[1];
  142. } PACKED EFI_USER_INTERFACE_SECTION, *PEFI_USER_INTERFACE_SECTION;
  143. typedef struct _EFI_CODE16_SECTION {
  144. EFI_COMMON_SECTION_HEADER CommonHeader;
  145. } PACKED EFI_CODE16_SECTION, *PEFI_CODE16_SECTION;
  146. typedef struct _EFI_FIRMWARE_VOLUME_IMAGE_SECTION {
  147. EFI_COMMON_SECTION_HEADER CommonHeader;
  148. } PACKED EFI_FIRMWARE_VOLUME_IMAGE_SECTION, *PEFI_FIRMWARE_VOLUME_IMAGE_SECTION;
  149. typedef struct _EFI_FREEFORM_SUBTYPE_GUID_SECTION {
  150. EFI_COMMON_SECTION_HEADER CommonHeader;
  151. EFI_GUID SubTypeGuid;
  152. } PACKED EFI_FREEFORM_SUBTYPE_GUID_SECTION, *PEFI_FREEFORM_SUBTYPE_GUID_SECTION;
  153. typedef struct _EFI_RAW_SECTION {
  154. EFI_COMMON_SECTION_HEADER CommonHeader;
  155. } PACKED EFI_RAW_SECTION, *PEFI_RAW_SECTION;
  156. #pragma pack(pop)
  157. typedef union _EFI_FILE_SECTION_POINTER {
  158. EFI_COMMON_SECTION_HEADER *CommonHeader;
  159. EFI_COMPRESSION_SECTION *CompressionSection;
  160. EFI_GUID_DEFINED_SECTION *GuidDefinedSection;
  161. EFI_PE32_SECTION *Pe32Section;
  162. EFI_PIC_SECTION *PicSection;
  163. EFI_PEIM_HEADER_SECTION *PeimHeaderSection;
  164. EFI_DEPEX_SECTION *DependencySection;
  165. EFI_VERSION_SECTION *VersionSection;
  166. EFI_USER_INTERFACE_SECTION *UISection;
  167. EFI_CODE16_SECTION *Code16Section;
  168. EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FVImageSection;
  169. EFI_FREEFORM_SUBTYPE_GUID_SECTION *FreeformSubtypeSection;
  170. EFI_RAW_SECTION *RawSection;
  171. } EFI_FILE_SECTION_POINTER, *PEFI_FILE_SECTION_POINTER;
  172. //
  173. // -------------------------------------------------------------------- Globals
  174. //
  175. //
  176. // -------------------------------------------------------- Function Prototypes
  177. //