Path: blob/main/sys/contrib/edk2/Include/Pi/PiFirmwareFile.h
96339 views
/** @file1The firmware file related definitions in PI.23Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>4SPDX-License-Identifier: BSD-2-Clause-Patent56@par Revision Reference:7PI Version 1.6.89**/1011#ifndef __PI_FIRMWARE_FILE_H__12#define __PI_FIRMWARE_FILE_H__1314#pragma pack(1)15///16/// Used to verify the integrity of the file.17///18typedef union {19struct {20///21/// The IntegrityCheck.Checksum.Header field is an 8-bit checksum of the file22/// header. The State and IntegrityCheck.Checksum.File fields are assumed23/// to be zero and the checksum is calculated such that the entire header sums to zero.24///25UINT8 Header;26///27/// If the FFS_ATTRIB_CHECKSUM (see definition below) bit of the Attributes28/// field is set to one, the IntegrityCheck.Checksum.File field is an 8-bit29/// checksum of the file data.30/// If the FFS_ATTRIB_CHECKSUM bit of the Attributes field is cleared to zero,31/// the IntegrityCheck.Checksum.File field must be initialized with a value of32/// 0xAA. The IntegrityCheck.Checksum.File field is valid any time the33/// EFI_FILE_DATA_VALID bit is set in the State field.34///35UINT8 File;36} Checksum;37///38/// This is the full 16 bits of the IntegrityCheck field.39///40UINT16 Checksum16;41} EFI_FFS_INTEGRITY_CHECK;4243///44/// FFS_FIXED_CHECKSUM is the checksum value used when the45/// FFS_ATTRIB_CHECKSUM attribute bit is clear.46///47#define FFS_FIXED_CHECKSUM 0xAA4849typedef UINT8 EFI_FV_FILETYPE;50typedef UINT8 EFI_FFS_FILE_ATTRIBUTES;51typedef UINT8 EFI_FFS_FILE_STATE;5253///54/// File Types Definitions55///56#define EFI_FV_FILETYPE_ALL 0x0057#define EFI_FV_FILETYPE_RAW 0x0158#define EFI_FV_FILETYPE_FREEFORM 0x0259#define EFI_FV_FILETYPE_SECURITY_CORE 0x0360#define EFI_FV_FILETYPE_PEI_CORE 0x0461#define EFI_FV_FILETYPE_DXE_CORE 0x0562#define EFI_FV_FILETYPE_PEIM 0x0663#define EFI_FV_FILETYPE_DRIVER 0x0764#define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x0865#define EFI_FV_FILETYPE_APPLICATION 0x0966#define EFI_FV_FILETYPE_MM 0x0A67#define EFI_FV_FILETYPE_SMM EFI_FV_FILETYPE_MM68#define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B69#define EFI_FV_FILETYPE_COMBINED_MM_DXE 0x0C70#define EFI_FV_FILETYPE_COMBINED_SMM_DXE EFI_FV_FILETYPE_COMBINED_MM_DXE71#define EFI_FV_FILETYPE_MM_CORE 0x0D72#define EFI_FV_FILETYPE_SMM_CORE EFI_FV_FILETYPE_MM_CORE73#define EFI_FV_FILETYPE_MM_STANDALONE 0x0E74#define EFI_FV_FILETYPE_MM_CORE_STANDALONE 0x0F75#define EFI_FV_FILETYPE_OEM_MIN 0xc076#define EFI_FV_FILETYPE_OEM_MAX 0xdf77#define EFI_FV_FILETYPE_DEBUG_MIN 0xe078#define EFI_FV_FILETYPE_DEBUG_MAX 0xef79#define EFI_FV_FILETYPE_FFS_MIN 0xf080#define EFI_FV_FILETYPE_FFS_MAX 0xff81#define EFI_FV_FILETYPE_FFS_PAD 0xf082///83/// FFS File Attributes.84///85#define FFS_ATTRIB_LARGE_FILE 0x0186#define FFS_ATTRIB_DATA_ALIGNMENT_2 0x0287#define FFS_ATTRIB_FIXED 0x0488#define FFS_ATTRIB_DATA_ALIGNMENT 0x3889#define FFS_ATTRIB_CHECKSUM 0x409091///92/// FFS File State Bits.93///94#define EFI_FILE_HEADER_CONSTRUCTION 0x0195#define EFI_FILE_HEADER_VALID 0x0296#define EFI_FILE_DATA_VALID 0x0497#define EFI_FILE_MARKED_FOR_UPDATE 0x0898#define EFI_FILE_DELETED 0x1099#define EFI_FILE_HEADER_INVALID 0x20100101///102/// Each file begins with the header that describe the103/// contents and state of the files.104///105typedef struct {106///107/// This GUID is the file name. It is used to uniquely identify the file.108///109EFI_GUID Name;110///111/// Used to verify the integrity of the file.112///113EFI_FFS_INTEGRITY_CHECK IntegrityCheck;114///115/// Identifies the type of file.116///117EFI_FV_FILETYPE Type;118///119/// Declares various file attribute bits.120///121EFI_FFS_FILE_ATTRIBUTES Attributes;122///123/// The length of the file in bytes, including the FFS header.124///125UINT8 Size[3];126///127/// Used to track the state of the file throughout the life of the file from creation to deletion.128///129EFI_FFS_FILE_STATE State;130} EFI_FFS_FILE_HEADER;131132typedef struct {133///134/// This GUID is the file name. It is used to uniquely identify the file. There may be only135/// one instance of a file with the file name GUID of Name in any given firmware136/// volume, except if the file type is EFI_FV_FILETYPE_FFS_PAD.137///138EFI_GUID Name;139140///141/// Used to verify the integrity of the file.142///143EFI_FFS_INTEGRITY_CHECK IntegrityCheck;144145///146/// Identifies the type of file.147///148EFI_FV_FILETYPE Type;149150///151/// Declares various file attribute bits.152///153EFI_FFS_FILE_ATTRIBUTES Attributes;154155///156/// The length of the file in bytes, including the FFS header.157/// The length of the file data is either (Size - sizeof(EFI_FFS_FILE_HEADER)). This calculation means a158/// zero-length file has a Size of 24 bytes, which is sizeof(EFI_FFS_FILE_HEADER).159/// Size is not required to be a multiple of 8 bytes. Given a file F, the next file header is160/// located at the next 8-byte aligned firmware volume offset following the last byte of the file F.161///162UINT8 Size[3];163164///165/// Used to track the state of the file throughout the life of the file from creation to deletion.166///167EFI_FFS_FILE_STATE State;168169///170/// If FFS_ATTRIB_LARGE_FILE is set in Attributes, then ExtendedSize exists and Size must be set to zero.171/// If FFS_ATTRIB_LARGE_FILE is not set then EFI_FFS_FILE_HEADER is used.172///173UINT64 ExtendedSize;174} EFI_FFS_FILE_HEADER2;175176#define IS_FFS_FILE2(FfsFileHeaderPtr) \177(((((EFI_FFS_FILE_HEADER *) (UINTN) FfsFileHeaderPtr)->Attributes) & FFS_ATTRIB_LARGE_FILE) == FFS_ATTRIB_LARGE_FILE)178179///180/// The argument passed as the FfsFileHeaderPtr parameter to the181/// FFS_FILE_SIZE() function-like macro below must not have side effects:182/// FfsFileHeaderPtr is evaluated multiple times.183///184#define FFS_FILE_SIZE(FfsFileHeaderPtr) ((UINT32) (\185(((EFI_FFS_FILE_HEADER *) (UINTN) (FfsFileHeaderPtr))->Size[0] ) | \186(((EFI_FFS_FILE_HEADER *) (UINTN) (FfsFileHeaderPtr))->Size[1] << 8) | \187(((EFI_FFS_FILE_HEADER *) (UINTN) (FfsFileHeaderPtr))->Size[2] << 16)))188189#define FFS_FILE2_SIZE(FfsFileHeaderPtr) \190((UINT32) (((EFI_FFS_FILE_HEADER2 *) (UINTN) FfsFileHeaderPtr)->ExtendedSize))191192typedef UINT8 EFI_SECTION_TYPE;193194///195/// Pseudo type. It is used as a wild card when retrieving sections.196/// The section type EFI_SECTION_ALL matches all section types.197///198#define EFI_SECTION_ALL 0x00199200///201/// Encapsulation section Type values.202///203#define EFI_SECTION_COMPRESSION 0x01204205#define EFI_SECTION_GUID_DEFINED 0x02206207#define EFI_SECTION_DISPOSABLE 0x03208209///210/// Leaf section Type values.211///212#define EFI_SECTION_PE32 0x10213#define EFI_SECTION_PIC 0x11214#define EFI_SECTION_TE 0x12215#define EFI_SECTION_DXE_DEPEX 0x13216#define EFI_SECTION_VERSION 0x14217#define EFI_SECTION_USER_INTERFACE 0x15218#define EFI_SECTION_COMPATIBILITY16 0x16219#define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17220#define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18221#define EFI_SECTION_RAW 0x19222#define EFI_SECTION_PEI_DEPEX 0x1B223#define EFI_SECTION_MM_DEPEX 0x1C224#define EFI_SECTION_SMM_DEPEX EFI_SECTION_MM_DEPEX225226///227/// Common section header.228///229typedef struct {230///231/// A 24-bit unsigned integer that contains the total size of the section in bytes,232/// including the EFI_COMMON_SECTION_HEADER.233///234UINT8 Size[3];235EFI_SECTION_TYPE Type;236///237/// Declares the section type.238///239} EFI_COMMON_SECTION_HEADER;240241typedef struct {242///243/// A 24-bit unsigned integer that contains the total size of the section in bytes,244/// including the EFI_COMMON_SECTION_HEADER.245///246UINT8 Size[3];247248EFI_SECTION_TYPE Type;249250///251/// If Size is 0xFFFFFF, then ExtendedSize contains the size of the section. If252/// Size is not equal to 0xFFFFFF, then this field does not exist.253///254UINT32 ExtendedSize;255} EFI_COMMON_SECTION_HEADER2;256257///258/// Leaf section type that contains an259/// IA-32 16-bit executable image.260///261typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION;262typedef EFI_COMMON_SECTION_HEADER2 EFI_COMPATIBILITY16_SECTION2;263264///265/// CompressionType of EFI_COMPRESSION_SECTION.266///267#define EFI_NOT_COMPRESSED 0x00268#define EFI_STANDARD_COMPRESSION 0x01269///270/// An encapsulation section type in which the271/// section data is compressed.272///273typedef struct {274///275/// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.276///277EFI_COMMON_SECTION_HEADER CommonHeader;278///279/// The UINT32 that indicates the size of the section data after decompression.280///281UINT32 UncompressedLength;282///283/// Indicates which compression algorithm is used.284///285UINT8 CompressionType;286} EFI_COMPRESSION_SECTION;287288typedef struct {289///290/// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.291///292EFI_COMMON_SECTION_HEADER2 CommonHeader;293///294/// UINT32 that indicates the size of the section data after decompression.295///296UINT32 UncompressedLength;297///298/// Indicates which compression algorithm is used.299///300UINT8 CompressionType;301} EFI_COMPRESSION_SECTION2;302303///304/// An encapsulation section type in which the section data is disposable.305/// A disposable section is an encapsulation section in which the section data may be disposed of during306/// the process of creating or updating a firmware image without significant impact on the usefulness of307/// the file. The Type field in the section header is set to EFI_SECTION_DISPOSABLE. This308/// allows optional or descriptive data to be included with the firmware file which can be removed in309/// order to conserve space. The contents of this section are implementation specific, but might contain310/// debug data or detailed integration instructions.311///312typedef EFI_COMMON_SECTION_HEADER EFI_DISPOSABLE_SECTION;313typedef EFI_COMMON_SECTION_HEADER2 EFI_DISPOSABLE_SECTION2;314315///316/// The leaf section which could be used to determine the dispatch order of DXEs.317///318typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION;319typedef EFI_COMMON_SECTION_HEADER2 EFI_DXE_DEPEX_SECTION2;320321///322/// The leaf section which contains a PI FV.323///324typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;325typedef EFI_COMMON_SECTION_HEADER2 EFI_FIRMWARE_VOLUME_IMAGE_SECTION2;326327///328/// The leaf section which contains a single GUID.329///330typedef struct {331///332/// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.333///334EFI_COMMON_SECTION_HEADER CommonHeader;335///336/// This GUID is defined by the creator of the file. It is a vendor-defined file type.337///338EFI_GUID SubTypeGuid;339} EFI_FREEFORM_SUBTYPE_GUID_SECTION;340341typedef struct {342///343/// The common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.344///345EFI_COMMON_SECTION_HEADER2 CommonHeader;346///347/// This GUID is defined by the creator of the file. It is a vendor-defined file type.348///349EFI_GUID SubTypeGuid;350} EFI_FREEFORM_SUBTYPE_GUID_SECTION2;351352///353/// Attributes of EFI_GUID_DEFINED_SECTION.354///355#define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01356#define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02357///358/// The leaf section which is encapsulation defined by specific GUID.359///360typedef struct {361///362/// The common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.363///364EFI_COMMON_SECTION_HEADER CommonHeader;365///366/// The GUID that defines the format of the data that follows. It is a vendor-defined section type.367///368EFI_GUID SectionDefinitionGuid;369///370/// Contains the offset in bytes from the beginning of the common header to the first byte of the data.371///372UINT16 DataOffset;373///374/// The bit field that declares some specific characteristics of the section contents.375///376UINT16 Attributes;377} EFI_GUID_DEFINED_SECTION;378379typedef struct {380///381/// The common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.382///383EFI_COMMON_SECTION_HEADER2 CommonHeader;384///385/// The GUID that defines the format of the data that follows. It is a vendor-defined section type.386///387EFI_GUID SectionDefinitionGuid;388///389/// Contains the offset in bytes from the beginning of the common header to the first byte of the data.390///391UINT16 DataOffset;392///393/// The bit field that declares some specific characteristics of the section contents.394///395UINT16 Attributes;396} EFI_GUID_DEFINED_SECTION2;397398///399/// The leaf section which contains PE32+ image.400///401typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION;402typedef EFI_COMMON_SECTION_HEADER2 EFI_PE32_SECTION2;403404///405/// The leaf section used to determine the dispatch order of PEIMs.406///407typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION;408typedef EFI_COMMON_SECTION_HEADER2 EFI_PEI_DEPEX_SECTION2;409410///411/// A leaf section type that contains a position-independent-code (PIC) image.412/// A PIC image section is a leaf section that contains a position-independent-code (PIC) image.413/// In addition to normal PE32+ images that contain relocation information, PEIM executables may be414/// PIC and are referred to as PIC images. A PIC image is the same as a PE32+ image except that all415/// relocation information has been stripped from the image and the image can be moved and will416/// execute correctly without performing any relocation or other fix-ups. EFI_PIC_SECTION2 must417/// be used if the section is 16MB or larger.418///419typedef EFI_COMMON_SECTION_HEADER EFI_PIC_SECTION;420typedef EFI_COMMON_SECTION_HEADER2 EFI_PIC_SECTION2;421422///423/// The leaf section which constains the position-independent-code image.424///425typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION;426typedef EFI_COMMON_SECTION_HEADER2 EFI_TE_SECTION2;427428///429/// The leaf section which contains an array of zero or more bytes.430///431typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION;432typedef EFI_COMMON_SECTION_HEADER2 EFI_RAW_SECTION2;433434///435/// The SMM dependency expression section is a leaf section that contains a dependency expression that436/// is used to determine the dispatch order for SMM drivers. Before the SMRAM invocation of the437/// SMM driver's entry point, this dependency expression must evaluate to TRUE. See the Platform438/// Initialization Specification, Volume 2, for details regarding the format of the dependency expression.439/// The dependency expression may refer to protocols installed in either the UEFI or the SMM protocol440/// database. EFI_SMM_DEPEX_SECTION2 must be used if the section is 16MB or larger.441///442typedef EFI_COMMON_SECTION_HEADER EFI_SMM_DEPEX_SECTION;443typedef EFI_COMMON_SECTION_HEADER2 EFI_SMM_DEPEX_SECTION2;444445///446/// The leaf section which contains a unicode string that447/// is human readable file name.448///449typedef struct {450EFI_COMMON_SECTION_HEADER CommonHeader;451452///453/// Array of unicode string.454///455CHAR16 FileNameString[1];456} EFI_USER_INTERFACE_SECTION;457458typedef struct {459EFI_COMMON_SECTION_HEADER2 CommonHeader;460CHAR16 FileNameString[1];461} EFI_USER_INTERFACE_SECTION2;462463///464/// The leaf section which contains a numeric build number and465/// an optional unicode string that represents the file revision.466///467typedef struct {468EFI_COMMON_SECTION_HEADER CommonHeader;469UINT16 BuildNumber;470471///472/// Array of unicode string.473///474CHAR16 VersionString[1];475} EFI_VERSION_SECTION;476477typedef struct {478EFI_COMMON_SECTION_HEADER2 CommonHeader;479///480/// A UINT16 that represents a particular build. Subsequent builds have monotonically481/// increasing build numbers relative to earlier builds.482///483UINT16 BuildNumber;484CHAR16 VersionString[1];485} EFI_VERSION_SECTION2;486487///488/// The argument passed as the SectionHeaderPtr parameter to the SECTION_SIZE()489/// and IS_SECTION2() function-like macros below must not have side effects:490/// SectionHeaderPtr is evaluated multiple times.491///492#define SECTION_SIZE(SectionHeaderPtr) ((UINT32) (\493(((EFI_COMMON_SECTION_HEADER *) (UINTN) (SectionHeaderPtr))->Size[0] ) | \494(((EFI_COMMON_SECTION_HEADER *) (UINTN) (SectionHeaderPtr))->Size[1] << 8) | \495(((EFI_COMMON_SECTION_HEADER *) (UINTN) (SectionHeaderPtr))->Size[2] << 16)))496497#define IS_SECTION2(SectionHeaderPtr) \498(SECTION_SIZE (SectionHeaderPtr) == 0x00ffffff)499500#define SECTION2_SIZE(SectionHeaderPtr) \501(((EFI_COMMON_SECTION_HEADER2 *) (UINTN) SectionHeaderPtr)->ExtendedSize)502503#pragma pack()504505#endif506507508