1 /** @file 2 The firmware file related definitions in PI. 3 4 @par Revision Reference: 5 Version 1.4. 6 7 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR> 8 9 This program and the accompanying materials are licensed and made available 10 under the terms and conditions of the BSD License which accompanies this 11 distribution. The full text of the license may be found at 12 http://opensource.org/licenses/bsd-license.php 13 14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 16 17 **/ 18 19 #ifndef __PI_FIRMWARE_FILE_H__ 20 #define __PI_FIRMWARE_FILE_H__ 21 22 #pragma pack(1) 23 // 24 // Used to verify the integrity of the file. 25 // 26 typedef union { 27 struct { 28 UINT8 Header; 29 UINT8 File; 30 } Checksum; 31 UINT16 Checksum16; 32 } EFI_FFS_INTEGRITY_CHECK; 33 34 typedef UINT8 EFI_FV_FILETYPE; 35 typedef UINT8 EFI_FFS_FILE_ATTRIBUTES; 36 typedef UINT8 EFI_FFS_FILE_STATE; 37 38 // 39 // File Types Definitions 40 // 41 #define EFI_FV_FILETYPE_ALL 0x00 42 #define EFI_FV_FILETYPE_RAW 0x01 43 #define EFI_FV_FILETYPE_FREEFORM 0x02 44 #define EFI_FV_FILETYPE_SECURITY_CORE 0x03 45 #define EFI_FV_FILETYPE_PEI_CORE 0x04 46 #define EFI_FV_FILETYPE_DXE_CORE 0x05 47 #define EFI_FV_FILETYPE_PEIM 0x06 48 #define EFI_FV_FILETYPE_DRIVER 0x07 49 #define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08 50 #define EFI_FV_FILETYPE_APPLICATION 0x09 51 #define EFI_FV_FILETYPE_SMM 0x0A 52 #define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B 53 #define EFI_FV_FILETYPE_COMBINED_SMM_DXE 0x0C 54 #define EFI_FV_FILETYPE_SMM_CORE 0x0D 55 #define EFI_FV_FILETYPE_OEM_MIN 0xc0 56 #define EFI_FV_FILETYPE_OEM_MAX 0xdf 57 #define EFI_FV_FILETYPE_DEBUG_MIN 0xe0 58 #define EFI_FV_FILETYPE_DEBUG_MAX 0xef 59 #define EFI_FV_FILETYPE_FFS_MIN 0xf0 60 #define EFI_FV_FILETYPE_FFS_MAX 0xff 61 #define EFI_FV_FILETYPE_FFS_PAD 0xf0 62 // 63 // FFS File Attributes. 64 // 65 #define FFS_ATTRIB_LARGE_FILE 0x01 66 #define FFS_ATTRIB_FIXED 0x04 67 #define FFS_ATTRIB_DATA_ALIGNMENT 0x38 68 #define FFS_ATTRIB_CHECKSUM 0x40 69 // 70 // FFS_FIXED_CHECKSUM is the checksum value used when the 71 // FFS_ATTRIB_CHECKSUM attribute bit is clear 72 // 73 #define FFS_FIXED_CHECKSUM 0xAA 74 75 // 76 // FFS File State Bits. 77 // 78 #define EFI_FILE_HEADER_CONSTRUCTION 0x01 79 #define EFI_FILE_HEADER_VALID 0x02 80 #define EFI_FILE_DATA_VALID 0x04 81 #define EFI_FILE_MARKED_FOR_UPDATE 0x08 82 #define EFI_FILE_DELETED 0x10 83 #define EFI_FILE_HEADER_INVALID 0x20 84 85 #define EFI_FILE_ALL_STATE_BITS (EFI_FILE_HEADER_CONSTRUCTION | \ 86 EFI_FILE_HEADER_VALID | \ 87 EFI_FILE_DATA_VALID | \ 88 EFI_FILE_MARKED_FOR_UPDATE | \ 89 EFI_FILE_DELETED | \ 90 EFI_FILE_HEADER_INVALID \ 91 ) 92 93 // 94 // Each file begins with the header that describe the 95 // contents and state of the files. 96 // 97 typedef struct { 98 EFI_GUID Name; 99 EFI_FFS_INTEGRITY_CHECK IntegrityCheck; 100 EFI_FV_FILETYPE Type; 101 EFI_FFS_FILE_ATTRIBUTES Attributes; 102 UINT8 Size[3]; 103 EFI_FFS_FILE_STATE State; 104 } EFI_FFS_FILE_HEADER; 105 106 typedef struct { 107 EFI_GUID Name; 108 EFI_FFS_INTEGRITY_CHECK IntegrityCheck; 109 EFI_FV_FILETYPE Type; 110 EFI_FFS_FILE_ATTRIBUTES Attributes; 111 UINT8 Size[3]; 112 EFI_FFS_FILE_STATE State; 113 UINT64 ExtendedSize; 114 } EFI_FFS_FILE_HEADER2; 115 116 #define MAX_FFS_SIZE 0x1000000 117 118 typedef UINT8 EFI_SECTION_TYPE; 119 120 // 121 // Pseudo type. It is 122 // used as a wild card when retrieving sections. The section 123 // type EFI_SECTION_ALL matches all section types. 124 // 125 #define EFI_SECTION_ALL 0x00 126 127 // 128 // Encapsulation section Type values 129 // 130 #define EFI_SECTION_COMPRESSION 0x01 131 132 #define EFI_SECTION_GUID_DEFINED 0x02 133 134 // 135 // Leaf section Type values 136 // 137 #define EFI_SECTION_PE32 0x10 138 #define EFI_SECTION_PIC 0x11 139 #define EFI_SECTION_TE 0x12 140 #define EFI_SECTION_DXE_DEPEX 0x13 141 #define EFI_SECTION_VERSION 0x14 142 #define EFI_SECTION_USER_INTERFACE 0x15 143 #define EFI_SECTION_COMPATIBILITY16 0x16 144 #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17 145 #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18 146 #define EFI_SECTION_RAW 0x19 147 #define EFI_SECTION_PEI_DEPEX 0x1B 148 #define EFI_SECTION_SMM_DEPEX 0x1C 149 150 typedef struct { 151 UINT8 Size[3]; 152 EFI_SECTION_TYPE Type; 153 } EFI_COMMON_SECTION_HEADER; 154 155 typedef struct { 156 UINT8 Size[3]; 157 EFI_SECTION_TYPE Type; 158 UINT32 ExtendedSize; 159 } EFI_COMMON_SECTION_HEADER2; 160 161 #define MAX_SECTION_SIZE 0x1000000 162 163 // 164 // Leaf section type that contains an 165 // IA-32 16-bit executable image. 166 // 167 typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION; 168 typedef EFI_COMMON_SECTION_HEADER2 EFI_COMPATIBILITY16_SECTION2; 169 170 // 171 // CompressionType of EFI_COMPRESSION_SECTION. 172 // 173 #define EFI_NOT_COMPRESSED 0x00 174 #define EFI_STANDARD_COMPRESSION 0x01 175 // 176 // An encapsulation section type in which the 177 // section data is compressed. 178 // 179 typedef struct { 180 EFI_COMMON_SECTION_HEADER CommonHeader; 181 UINT32 UncompressedLength; 182 UINT8 CompressionType; 183 } EFI_COMPRESSION_SECTION; 184 185 typedef struct { 186 EFI_COMMON_SECTION_HEADER2 CommonHeader; 187 UINT32 UncompressedLength; 188 UINT8 CompressionType; 189 } EFI_COMPRESSION_SECTION2; 190 191 // 192 // Leaf section which could be used to determine the dispatch order of DXEs. 193 // 194 typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION; 195 typedef EFI_COMMON_SECTION_HEADER2 EFI_DXE_DEPEX_SECTION2; 196 197 // 198 // Leaf section witch contains a PI FV. 199 // 200 typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION; 201 typedef EFI_COMMON_SECTION_HEADER2 EFI_FIRMWARE_VOLUME_IMAGE_SECTION2; 202 203 // 204 // Leaf section which contains a single GUID. 205 // 206 typedef struct { 207 EFI_COMMON_SECTION_HEADER CommonHeader; 208 EFI_GUID SubTypeGuid; 209 } EFI_FREEFORM_SUBTYPE_GUID_SECTION; 210 211 typedef struct { 212 EFI_COMMON_SECTION_HEADER2 CommonHeader; 213 EFI_GUID SubTypeGuid; 214 } EFI_FREEFORM_SUBTYPE_GUID_SECTION2; 215 216 // 217 // Attributes of EFI_GUID_DEFINED_SECTION 218 // 219 #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01 220 #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02 221 // 222 // Leaf section which is encapsulation defined by specific GUID 223 // 224 typedef struct { 225 EFI_COMMON_SECTION_HEADER CommonHeader; 226 EFI_GUID SectionDefinitionGuid; 227 UINT16 DataOffset; 228 UINT16 Attributes; 229 } EFI_GUID_DEFINED_SECTION; 230 231 typedef struct { 232 EFI_COMMON_SECTION_HEADER2 CommonHeader; 233 EFI_GUID SectionDefinitionGuid; 234 UINT16 DataOffset; 235 UINT16 Attributes; 236 } EFI_GUID_DEFINED_SECTION2; 237 238 // 239 // Leaf section which contains PE32+ image. 240 // 241 typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION; 242 typedef EFI_COMMON_SECTION_HEADER2 EFI_PE32_SECTION2; 243 244 // 245 // Leaf section which contains PIC image. 246 // 247 typedef EFI_COMMON_SECTION_HEADER EFI_PIC_SECTION; 248 typedef EFI_COMMON_SECTION_HEADER2 EFI_PIC_SECTION2; 249 250 // 251 // Leaf section which used to determine the dispatch order of PEIMs. 252 // 253 typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION; 254 typedef EFI_COMMON_SECTION_HEADER2 EFI_PEI_DEPEX_SECTION2; 255 256 // 257 // Leaf section which constains the position-independent-code image. 258 // 259 typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION; 260 typedef EFI_COMMON_SECTION_HEADER2 EFI_TE_SECTION2; 261 262 // 263 // Leaf section which contains an array of zero or more bytes. 264 // 265 typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION; 266 typedef EFI_COMMON_SECTION_HEADER2 EFI_RAW_SECTION2; 267 268 // 269 // Leaf section which contains a unicode string that 270 // is human readable file name. 271 // 272 typedef struct { 273 EFI_COMMON_SECTION_HEADER CommonHeader; 274 275 // 276 // Array of unicode string. 277 // 278 CHAR16 FileNameString[1]; 279 } EFI_USER_INTERFACE_SECTION; 280 281 typedef struct { 282 EFI_COMMON_SECTION_HEADER2 CommonHeader; 283 284 // 285 // Array of unicode string. 286 // 287 CHAR16 FileNameString[1]; 288 } EFI_USER_INTERFACE_SECTION2; 289 290 // 291 // Leaf section which contains a numeric build number and 292 // an optional unicode string that represent the file revision. 293 // 294 typedef struct { 295 EFI_COMMON_SECTION_HEADER CommonHeader; 296 UINT16 BuildNumber; 297 CHAR16 VersionString[1]; 298 } EFI_VERSION_SECTION; 299 300 typedef struct { 301 EFI_COMMON_SECTION_HEADER2 CommonHeader; 302 UINT16 BuildNumber; 303 CHAR16 VersionString[1]; 304 } EFI_VERSION_SECTION2; 305 306 #define SECTION_SIZE(SectionHeaderPtr) \ 307 ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff)) 308 309 #pragma pack() 310 311 typedef union { 312 EFI_COMMON_SECTION_HEADER *CommonHeader; 313 EFI_COMPRESSION_SECTION *CompressionSection; 314 EFI_GUID_DEFINED_SECTION *GuidDefinedSection; 315 EFI_PE32_SECTION *Pe32Section; 316 EFI_PIC_SECTION *PicSection; 317 EFI_TE_SECTION *TeSection; 318 EFI_PEI_DEPEX_SECTION *PeimHeaderSection; 319 EFI_DXE_DEPEX_SECTION *DependencySection; 320 EFI_VERSION_SECTION *VersionSection; 321 EFI_USER_INTERFACE_SECTION *UISection; 322 EFI_COMPATIBILITY16_SECTION *Code16Section; 323 EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FVImageSection; 324 EFI_FREEFORM_SUBTYPE_GUID_SECTION *FreeformSubtypeSection; 325 EFI_RAW_SECTION *RawSection; 326 // 327 // For section whose size is equal or greater than 0x1000000 328 // 329 EFI_COMMON_SECTION_HEADER2 *CommonHeader2; 330 EFI_COMPRESSION_SECTION2 *CompressionSection2; 331 EFI_GUID_DEFINED_SECTION2 *GuidDefinedSection2; 332 EFI_PE32_SECTION2 *Pe32Section2; 333 EFI_PIC_SECTION2 *PicSection2; 334 EFI_TE_SECTION2 *TeSection2; 335 EFI_PEI_DEPEX_SECTION2 *PeimHeaderSection2; 336 EFI_DXE_DEPEX_SECTION2 *DependencySection2; 337 EFI_VERSION_SECTION2 *VersionSection2; 338 EFI_USER_INTERFACE_SECTION2 *UISection2; 339 EFI_COMPATIBILITY16_SECTION2 *Code16Section2; 340 EFI_FIRMWARE_VOLUME_IMAGE_SECTION2 *FVImageSection2; 341 EFI_FREEFORM_SUBTYPE_GUID_SECTION2 *FreeformSubtypeSection2; 342 EFI_RAW_SECTION2 *RawSection2; 343 } EFI_FILE_SECTION_POINTER; 344 345 #endif 346 347