diff options
Diffstat (limited to 'src/include/ipxe/efi/Pi/PiFirmwareFile.h')
-rw-r--r-- | src/include/ipxe/efi/Pi/PiFirmwareFile.h | 240 |
1 files changed, 126 insertions, 114 deletions
diff --git a/src/include/ipxe/efi/Pi/PiFirmwareFile.h b/src/include/ipxe/efi/Pi/PiFirmwareFile.h index 9bd22a5..daf66f8 100644 --- a/src/include/ipxe/efi/Pi/PiFirmwareFile.h +++ b/src/include/ipxe/efi/Pi/PiFirmwareFile.h @@ -1,25 +1,18 @@ /** @file The firmware file related definitions in PI. -Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR> -This program and the accompanying materials are licensed and made available under -the terms and conditions of the BSD License that accompanies this distribution. -The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php. - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> +SPDX-License-Identifier: BSD-2-Clause-Patent @par Revision Reference: - PI Version 1.4. + PI Version 1.6. **/ - #ifndef __PI_FIRMWARE_FILE_H__ #define __PI_FIRMWARE_FILE_H__ -FILE_LICENCE ( BSD3 ); +FILE_LICENCE ( BSD2_PATENT ); #pragma pack(1) /// @@ -32,7 +25,7 @@ typedef union { /// header. The State and IntegrityCheck.Checksum.File fields are assumed /// to be zero and the checksum is calculated such that the entire header sums to zero. /// - UINT8 Header; + UINT8 Header; /// /// If the FFS_ATTRIB_CHECKSUM (see definition below) bit of the Attributes /// field is set to one, the IntegrityCheck.Checksum.File field is an 8-bit @@ -42,7 +35,7 @@ typedef union { /// 0xAA. The IntegrityCheck.Checksum.File field is valid any time the /// EFI_FILE_DATA_VALID bit is set in the State field. /// - UINT8 File; + UINT8 File; } Checksum; /// /// This is the full 16 bits of the IntegrityCheck field. @@ -56,41 +49,47 @@ typedef union { /// #define FFS_FIXED_CHECKSUM 0xAA -typedef UINT8 EFI_FV_FILETYPE; -typedef UINT8 EFI_FFS_FILE_ATTRIBUTES; -typedef UINT8 EFI_FFS_FILE_STATE; +typedef UINT8 EFI_FV_FILETYPE; +typedef UINT8 EFI_FFS_FILE_ATTRIBUTES; +typedef UINT8 EFI_FFS_FILE_STATE; /// /// File Types Definitions /// -#define EFI_FV_FILETYPE_ALL 0x00 -#define EFI_FV_FILETYPE_RAW 0x01 -#define EFI_FV_FILETYPE_FREEFORM 0x02 -#define EFI_FV_FILETYPE_SECURITY_CORE 0x03 -#define EFI_FV_FILETYPE_PEI_CORE 0x04 -#define EFI_FV_FILETYPE_DXE_CORE 0x05 -#define EFI_FV_FILETYPE_PEIM 0x06 -#define EFI_FV_FILETYPE_DRIVER 0x07 -#define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08 -#define EFI_FV_FILETYPE_APPLICATION 0x09 -#define EFI_FV_FILETYPE_SMM 0x0A -#define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B -#define EFI_FV_FILETYPE_COMBINED_SMM_DXE 0x0C -#define EFI_FV_FILETYPE_SMM_CORE 0x0D -#define EFI_FV_FILETYPE_OEM_MIN 0xc0 -#define EFI_FV_FILETYPE_OEM_MAX 0xdf -#define EFI_FV_FILETYPE_DEBUG_MIN 0xe0 -#define EFI_FV_FILETYPE_DEBUG_MAX 0xef -#define EFI_FV_FILETYPE_FFS_MIN 0xf0 -#define EFI_FV_FILETYPE_FFS_MAX 0xff -#define EFI_FV_FILETYPE_FFS_PAD 0xf0 +#define EFI_FV_FILETYPE_ALL 0x00 +#define EFI_FV_FILETYPE_RAW 0x01 +#define EFI_FV_FILETYPE_FREEFORM 0x02 +#define EFI_FV_FILETYPE_SECURITY_CORE 0x03 +#define EFI_FV_FILETYPE_PEI_CORE 0x04 +#define EFI_FV_FILETYPE_DXE_CORE 0x05 +#define EFI_FV_FILETYPE_PEIM 0x06 +#define EFI_FV_FILETYPE_DRIVER 0x07 +#define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08 +#define EFI_FV_FILETYPE_APPLICATION 0x09 +#define EFI_FV_FILETYPE_MM 0x0A +#define EFI_FV_FILETYPE_SMM EFI_FV_FILETYPE_MM +#define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B +#define EFI_FV_FILETYPE_COMBINED_MM_DXE 0x0C +#define EFI_FV_FILETYPE_COMBINED_SMM_DXE EFI_FV_FILETYPE_COMBINED_MM_DXE +#define EFI_FV_FILETYPE_MM_CORE 0x0D +#define EFI_FV_FILETYPE_SMM_CORE EFI_FV_FILETYPE_MM_CORE +#define EFI_FV_FILETYPE_MM_STANDALONE 0x0E +#define EFI_FV_FILETYPE_MM_CORE_STANDALONE 0x0F +#define EFI_FV_FILETYPE_OEM_MIN 0xc0 +#define EFI_FV_FILETYPE_OEM_MAX 0xdf +#define EFI_FV_FILETYPE_DEBUG_MIN 0xe0 +#define EFI_FV_FILETYPE_DEBUG_MAX 0xef +#define EFI_FV_FILETYPE_FFS_MIN 0xf0 +#define EFI_FV_FILETYPE_FFS_MAX 0xff +#define EFI_FV_FILETYPE_FFS_PAD 0xf0 /// /// FFS File Attributes. /// -#define FFS_ATTRIB_LARGE_FILE 0x01 -#define FFS_ATTRIB_FIXED 0x04 -#define FFS_ATTRIB_DATA_ALIGNMENT 0x38 -#define FFS_ATTRIB_CHECKSUM 0x40 +#define FFS_ATTRIB_LARGE_FILE 0x01 +#define FFS_ATTRIB_DATA_ALIGNMENT_2 0x02 +#define FFS_ATTRIB_FIXED 0x04 +#define FFS_ATTRIB_DATA_ALIGNMENT 0x38 +#define FFS_ATTRIB_CHECKSUM 0x40 /// /// FFS File State Bits. @@ -102,7 +101,6 @@ typedef UINT8 EFI_FFS_FILE_STATE; #define EFI_FILE_DELETED 0x10 #define EFI_FILE_HEADER_INVALID 0x20 - /// /// Each file begins with the header that describe the /// contents and state of the files. @@ -111,27 +109,27 @@ typedef struct { /// /// This GUID is the file name. It is used to uniquely identify the file. /// - EFI_GUID Name; + EFI_GUID Name; /// /// Used to verify the integrity of the file. /// - EFI_FFS_INTEGRITY_CHECK IntegrityCheck; + EFI_FFS_INTEGRITY_CHECK IntegrityCheck; /// /// Identifies the type of file. /// - EFI_FV_FILETYPE Type; + EFI_FV_FILETYPE Type; /// /// Declares various file attribute bits. /// - EFI_FFS_FILE_ATTRIBUTES Attributes; + EFI_FFS_FILE_ATTRIBUTES Attributes; /// /// The length of the file in bytes, including the FFS header. /// - UINT8 Size[3]; + UINT8 Size[3]; /// /// Used to track the state of the file throughout the life of the file from creation to deletion. /// - EFI_FFS_FILE_STATE State; + EFI_FFS_FILE_STATE State; } EFI_FFS_FILE_HEADER; typedef struct { @@ -140,22 +138,22 @@ typedef struct { /// one instance of a file with the file name GUID of Name in any given firmware /// volume, except if the file type is EFI_FV_FILETYPE_FFS_PAD. /// - EFI_GUID Name; + EFI_GUID Name; /// /// Used to verify the integrity of the file. /// - EFI_FFS_INTEGRITY_CHECK IntegrityCheck; + EFI_FFS_INTEGRITY_CHECK IntegrityCheck; /// /// Identifies the type of file. /// - EFI_FV_FILETYPE Type; + EFI_FV_FILETYPE Type; /// /// Declares various file attribute bits. /// - EFI_FFS_FILE_ATTRIBUTES Attributes; + EFI_FFS_FILE_ATTRIBUTES Attributes; /// /// The length of the file in bytes, including the FFS header. @@ -164,25 +162,32 @@ typedef struct { /// Size is not required to be a multiple of 8 bytes. Given a file F, the next file header is /// located at the next 8-byte aligned firmware volume offset following the last byte of the file F. /// - UINT8 Size[3]; + UINT8 Size[3]; /// /// Used to track the state of the file throughout the life of the file from creation to deletion. /// - EFI_FFS_FILE_STATE State; + EFI_FFS_FILE_STATE State; /// /// If FFS_ATTRIB_LARGE_FILE is set in Attributes, then ExtendedSize exists and Size must be set to zero. /// If FFS_ATTRIB_LARGE_FILE is not set then EFI_FFS_FILE_HEADER is used. /// - UINT64 ExtendedSize; + UINT64 ExtendedSize; } EFI_FFS_FILE_HEADER2; #define IS_FFS_FILE2(FfsFileHeaderPtr) \ (((((EFI_FFS_FILE_HEADER *) (UINTN) FfsFileHeaderPtr)->Attributes) & FFS_ATTRIB_LARGE_FILE) == FFS_ATTRIB_LARGE_FILE) -#define FFS_FILE_SIZE(FfsFileHeaderPtr) \ - ((UINT32) (*((UINT32 *) ((EFI_FFS_FILE_HEADER *) (UINTN) FfsFileHeaderPtr)->Size) & 0x00ffffff)) +/// +/// The argument passed as the FfsFileHeaderPtr parameter to the +/// FFS_FILE_SIZE() function-like macro below must not have side effects: +/// FfsFileHeaderPtr is evaluated multiple times. +/// +#define FFS_FILE_SIZE(FfsFileHeaderPtr) ((UINT32) (\ + (((EFI_FFS_FILE_HEADER *) (UINTN) (FfsFileHeaderPtr))->Size[0] ) | \ + (((EFI_FFS_FILE_HEADER *) (UINTN) (FfsFileHeaderPtr))->Size[1] << 8) | \ + (((EFI_FFS_FILE_HEADER *) (UINTN) (FfsFileHeaderPtr))->Size[2] << 16))) #define FFS_FILE2_SIZE(FfsFileHeaderPtr) \ ((UINT32) (((EFI_FFS_FILE_HEADER2 *) (UINTN) FfsFileHeaderPtr)->ExtendedSize)) @@ -193,32 +198,33 @@ typedef UINT8 EFI_SECTION_TYPE; /// Pseudo type. It is used as a wild card when retrieving sections. /// The section type EFI_SECTION_ALL matches all section types. /// -#define EFI_SECTION_ALL 0x00 +#define EFI_SECTION_ALL 0x00 /// /// Encapsulation section Type values. /// -#define EFI_SECTION_COMPRESSION 0x01 +#define EFI_SECTION_COMPRESSION 0x01 -#define EFI_SECTION_GUID_DEFINED 0x02 +#define EFI_SECTION_GUID_DEFINED 0x02 -#define EFI_SECTION_DISPOSABLE 0x03 +#define EFI_SECTION_DISPOSABLE 0x03 /// /// Leaf section Type values. /// -#define EFI_SECTION_PE32 0x10 -#define EFI_SECTION_PIC 0x11 -#define EFI_SECTION_TE 0x12 -#define EFI_SECTION_DXE_DEPEX 0x13 -#define EFI_SECTION_VERSION 0x14 -#define EFI_SECTION_USER_INTERFACE 0x15 -#define EFI_SECTION_COMPATIBILITY16 0x16 -#define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17 -#define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18 -#define EFI_SECTION_RAW 0x19 -#define EFI_SECTION_PEI_DEPEX 0x1B -#define EFI_SECTION_SMM_DEPEX 0x1C +#define EFI_SECTION_PE32 0x10 +#define EFI_SECTION_PIC 0x11 +#define EFI_SECTION_TE 0x12 +#define EFI_SECTION_DXE_DEPEX 0x13 +#define EFI_SECTION_VERSION 0x14 +#define EFI_SECTION_USER_INTERFACE 0x15 +#define EFI_SECTION_COMPATIBILITY16 0x16 +#define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17 +#define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18 +#define EFI_SECTION_RAW 0x19 +#define EFI_SECTION_PEI_DEPEX 0x1B +#define EFI_SECTION_MM_DEPEX 0x1C +#define EFI_SECTION_SMM_DEPEX EFI_SECTION_MM_DEPEX /// /// Common section header. @@ -228,8 +234,8 @@ typedef struct { /// A 24-bit unsigned integer that contains the total size of the section in bytes, /// including the EFI_COMMON_SECTION_HEADER. /// - UINT8 Size[3]; - EFI_SECTION_TYPE Type; + UINT8 Size[3]; + EFI_SECTION_TYPE Type; /// /// Declares the section type. /// @@ -240,15 +246,15 @@ typedef struct { /// A 24-bit unsigned integer that contains the total size of the section in bytes, /// including the EFI_COMMON_SECTION_HEADER. /// - UINT8 Size[3]; + UINT8 Size[3]; - EFI_SECTION_TYPE Type; + EFI_SECTION_TYPE Type; /// /// If Size is 0xFFFFFF, then ExtendedSize contains the size of the section. If /// Size is not equal to 0xFFFFFF, then this field does not exist. /// - UINT32 ExtendedSize; + UINT32 ExtendedSize; } EFI_COMMON_SECTION_HEADER2; /// @@ -271,15 +277,15 @@ typedef struct { /// /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION. /// - EFI_COMMON_SECTION_HEADER CommonHeader; + EFI_COMMON_SECTION_HEADER CommonHeader; /// /// The UINT32 that indicates the size of the section data after decompression. /// - UINT32 UncompressedLength; + UINT32 UncompressedLength; /// /// Indicates which compression algorithm is used. /// - UINT8 CompressionType; + UINT8 CompressionType; } EFI_COMPRESSION_SECTION; typedef struct { @@ -306,20 +312,20 @@ typedef struct { /// order to conserve space. The contents of this section are implementation specific, but might contain /// debug data or detailed integration instructions. /// -typedef EFI_COMMON_SECTION_HEADER EFI_DISPOSABLE_SECTION; -typedef EFI_COMMON_SECTION_HEADER2 EFI_DISPOSABLE_SECTION2; +typedef EFI_COMMON_SECTION_HEADER EFI_DISPOSABLE_SECTION; +typedef EFI_COMMON_SECTION_HEADER2 EFI_DISPOSABLE_SECTION2; /// /// The leaf section which could be used to determine the dispatch order of DXEs. /// -typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION; -typedef EFI_COMMON_SECTION_HEADER2 EFI_DXE_DEPEX_SECTION2; +typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION; +typedef EFI_COMMON_SECTION_HEADER2 EFI_DXE_DEPEX_SECTION2; /// /// The leaf section which contains a PI FV. /// -typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION; -typedef EFI_COMMON_SECTION_HEADER2 EFI_FIRMWARE_VOLUME_IMAGE_SECTION2; +typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION; +typedef EFI_COMMON_SECTION_HEADER2 EFI_FIRMWARE_VOLUME_IMAGE_SECTION2; /// /// The leaf section which contains a single GUID. @@ -328,11 +334,11 @@ typedef struct { /// /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID. /// - EFI_COMMON_SECTION_HEADER CommonHeader; + EFI_COMMON_SECTION_HEADER CommonHeader; /// /// This GUID is defined by the creator of the file. It is a vendor-defined file type. /// - EFI_GUID SubTypeGuid; + EFI_GUID SubTypeGuid; } EFI_FREEFORM_SUBTYPE_GUID_SECTION; typedef struct { @@ -358,19 +364,19 @@ typedef struct { /// /// The common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED. /// - EFI_COMMON_SECTION_HEADER CommonHeader; + EFI_COMMON_SECTION_HEADER CommonHeader; /// /// The GUID that defines the format of the data that follows. It is a vendor-defined section type. /// - EFI_GUID SectionDefinitionGuid; + EFI_GUID SectionDefinitionGuid; /// /// Contains the offset in bytes from the beginning of the common header to the first byte of the data. /// - UINT16 DataOffset; + UINT16 DataOffset; /// /// The bit field that declares some specific characteristics of the section contents. /// - UINT16 Attributes; + UINT16 Attributes; } EFI_GUID_DEFINED_SECTION; typedef struct { @@ -395,14 +401,14 @@ typedef struct { /// /// The leaf section which contains PE32+ image. /// -typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION; -typedef EFI_COMMON_SECTION_HEADER2 EFI_PE32_SECTION2; +typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION; +typedef EFI_COMMON_SECTION_HEADER2 EFI_PE32_SECTION2; /// /// The leaf section used to determine the dispatch order of PEIMs. /// -typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION; -typedef EFI_COMMON_SECTION_HEADER2 EFI_PEI_DEPEX_SECTION2; +typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION; +typedef EFI_COMMON_SECTION_HEADER2 EFI_PEI_DEPEX_SECTION2; /// /// A leaf section type that contains a position-independent-code (PIC) image. @@ -413,20 +419,20 @@ typedef EFI_COMMON_SECTION_HEADER2 EFI_PEI_DEPEX_SECTION2; /// execute correctly without performing any relocation or other fix-ups. EFI_PIC_SECTION2 must /// be used if the section is 16MB or larger. /// -typedef EFI_COMMON_SECTION_HEADER EFI_PIC_SECTION; -typedef EFI_COMMON_SECTION_HEADER2 EFI_PIC_SECTION2; +typedef EFI_COMMON_SECTION_HEADER EFI_PIC_SECTION; +typedef EFI_COMMON_SECTION_HEADER2 EFI_PIC_SECTION2; /// /// The leaf section which constains the position-independent-code image. /// -typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION; -typedef EFI_COMMON_SECTION_HEADER2 EFI_TE_SECTION2; +typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION; +typedef EFI_COMMON_SECTION_HEADER2 EFI_TE_SECTION2; /// /// The leaf section which contains an array of zero or more bytes. /// -typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION; -typedef EFI_COMMON_SECTION_HEADER2 EFI_RAW_SECTION2; +typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION; +typedef EFI_COMMON_SECTION_HEADER2 EFI_RAW_SECTION2; /// /// The SMM dependency expression section is a leaf section that contains a dependency expression that @@ -436,7 +442,7 @@ typedef EFI_COMMON_SECTION_HEADER2 EFI_RAW_SECTION2; /// The dependency expression may refer to protocols installed in either the UEFI or the SMM protocol /// database. EFI_SMM_DEPEX_SECTION2 must be used if the section is 16MB or larger. /// -typedef EFI_COMMON_SECTION_HEADER EFI_SMM_DEPEX_SECTION; +typedef EFI_COMMON_SECTION_HEADER EFI_SMM_DEPEX_SECTION; typedef EFI_COMMON_SECTION_HEADER2 EFI_SMM_DEPEX_SECTION2; /// @@ -444,12 +450,12 @@ typedef EFI_COMMON_SECTION_HEADER2 EFI_SMM_DEPEX_SECTION2; /// is human readable file name. /// typedef struct { - EFI_COMMON_SECTION_HEADER CommonHeader; + EFI_COMMON_SECTION_HEADER CommonHeader; /// /// Array of unicode string. /// - CHAR16 FileNameString[1]; + CHAR16 FileNameString[1]; } EFI_USER_INTERFACE_SECTION; typedef struct { @@ -462,13 +468,13 @@ typedef struct { /// an optional unicode string that represents the file revision. /// typedef struct { - EFI_COMMON_SECTION_HEADER CommonHeader; - UINT16 BuildNumber; + EFI_COMMON_SECTION_HEADER CommonHeader; + UINT16 BuildNumber; /// /// Array of unicode string. /// - CHAR16 VersionString[1]; + CHAR16 VersionString[1]; } EFI_VERSION_SECTION; typedef struct { @@ -481,11 +487,18 @@ typedef struct { CHAR16 VersionString[1]; } EFI_VERSION_SECTION2; -#define IS_SECTION2(SectionHeaderPtr) \ - ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) (UINTN) SectionHeaderPtr)->Size) & 0x00ffffff) == 0x00ffffff) +/// +/// The argument passed as the SectionHeaderPtr parameter to the SECTION_SIZE() +/// and IS_SECTION2() function-like macros below must not have side effects: +/// SectionHeaderPtr is evaluated multiple times. +/// +#define SECTION_SIZE(SectionHeaderPtr) ((UINT32) (\ + (((EFI_COMMON_SECTION_HEADER *) (UINTN) (SectionHeaderPtr))->Size[0] ) | \ + (((EFI_COMMON_SECTION_HEADER *) (UINTN) (SectionHeaderPtr))->Size[1] << 8) | \ + (((EFI_COMMON_SECTION_HEADER *) (UINTN) (SectionHeaderPtr))->Size[2] << 16))) -#define SECTION_SIZE(SectionHeaderPtr) \ - ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) (UINTN) SectionHeaderPtr)->Size) & 0x00ffffff)) +#define IS_SECTION2(SectionHeaderPtr) \ + (SECTION_SIZE (SectionHeaderPtr) == 0x00ffffff) #define SECTION2_SIZE(SectionHeaderPtr) \ (((EFI_COMMON_SECTION_HEADER2 *) (UINTN) SectionHeaderPtr)->ExtendedSize) @@ -493,4 +506,3 @@ typedef struct { #pragma pack() #endif - |