/** @file
The firmware file related definitions in PI.
Copyright (c) 2006 - 2011, 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
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@par Revision Reference:
PI Version 1.2.
**/
#ifndef __PI_FIRMWARE_FILE_H__
#define __PI_FIRMWARE_FILE_H__
#pragma pack(1)
///
/// Used to verify the integrity of the file.
///
typedef union {
struct {
///
/// The IntegrityCheck.Checksum.Header field is an 8-bit checksum of the file
/// 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.
///
///
/// 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
/// checksum of the file data.
/// If the FFS_ATTRIB_CHECKSUM bit of the Attributes field is cleared to zero,
/// the IntegrityCheck.Checksum.File field must be initialized with a value of
/// 0xAA. The IntegrityCheck.Checksum.File field is valid any time the
/// EFI_FILE_DATA_VALID bit is set in the State field.
///
} Checksum;
///
/// This is the full 16 bits of the IntegrityCheck field.
///
///
/// FFS_FIXED_CHECKSUM is the checksum value used when the
/// FFS_ATTRIB_CHECKSUM attribute bit is clear.
///
///
/// File Types Definitions
///
///
/// FFS File Attributes.
///
///
/// FFS File State Bits.
///
///
/// Each file begins with the header that describe the
/// contents and state of the files.
///
typedef struct {
///
/// This GUID is the file name. It is used to uniquely identify the file.
///
///
/// Used to verify the integrity of the file.
///
///
/// Identifies the type of file.
///
///
/// Declares various file attribute bits.
///
///
/// The length of the file in bytes, including the FFS header.
///
///
/// Used to track the state of the file throughout the life of the file from creation to deletion.
///
typedef struct {
///
/// This GUID is the file name. It is used to uniquely identify the file. There may be only
/// 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.
///
///
/// Used to verify the integrity of the file.
///
///
/// Identifies the type of file.
///
///
/// Declares various file attribute bits.
///
///
/// The length of the file in bytes, including the FFS header.
/// The length of the file data is either (Size - sizeof(EFI_FFS_FILE_HEADER)). This calculation means a
/// zero-length file has a Size of 24 bytes, which is sizeof(EFI_FFS_FILE_HEADER).
/// 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.
///
///
/// Used to track the state of the file throughout the life of the file from creation to deletion.
///
///
/// 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.
///
(((((EFI_FFS_FILE_HEADER *) (UINTN) FfsFileHeaderPtr)->Attributes) & FFS_ATTRIB_LARGE_FILE) == FFS_ATTRIB_LARGE_FILE)
///
/// Pseudo type. It is used as a wild card when retrieving sections.
/// The section type EFI_SECTION_ALL matches all section types.
///
///
/// Encapsulation section Type values.
///
///
/// Leaf section Type values.
///
///
/// Common section header.
///
typedef struct {
///
/// A 24-bit unsigned integer that contains the total size of the section in bytes,
/// including the EFI_COMMON_SECTION_HEADER.
///
///
/// Declares the section type.
///
typedef struct {
///
/// A 24-bit unsigned integer that contains the total size of the section in bytes,
/// including the EFI_COMMON_SECTION_HEADER.
///
///
/// 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.
///
///
/// Leaf section type that contains an
/// IA-32 16-bit executable image.
///
///
/// CompressionType of EFI_COMPRESSION_SECTION.
///
///
/// An encapsulation section type in which the
/// section data is compressed.
///
typedef struct {
///
/// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
///
///
/// The UINT32 that indicates the size of the section data after decompression.
///
///
/// Indicates which compression algorithm is used.
///
typedef struct {
///
/// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
///
///
/// UINT32 that indicates the size of the section data after decompression.
///
///
/// Indicates which compression algorithm is used.
///
///
/// An encapsulation section type in which the section data is disposable.
/// A disposable section is an encapsulation section in which the section data may be disposed of during
/// the process of creating or updating a firmware image without significant impact on the usefulness of
/// the file. The Type field in the section header is set to EFI_SECTION_DISPOSABLE. This
/// allows optional or descriptive data to be included with the firmware file which can be removed in
/// order to conserve space. The contents of this section are implementation specific, but might contain
/// debug data or detailed integration instructions.
///
///
/// The leaf section which could be used to determine the dispatch order of DXEs.
///
///
/// The leaf section which contains a PI FV.
///
///
/// The leaf section which contains a single GUID.
///
typedef struct {
///
/// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
///
///
/// This GUID is defined by the creator of the file. It is a vendor-defined file type.
///
typedef struct {
///
/// The common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
///
///
/// This GUID is defined by the creator of the file. It is a vendor-defined file type.
///
///
/// Attributes of EFI_GUID_DEFINED_SECTION.
///
///
/// The leaf section which is encapsulation defined by specific GUID.
///
typedef struct {
///
/// The common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
///
///
/// The GUID that defines the format of the data that follows. It is a vendor-defined section type.
///
///
/// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
///
///
/// The bit field that declares some specific characteristics of the section contents.
///
typedef struct {
///
/// The common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
///
///
/// The GUID that defines the format of the data that follows. It is a vendor-defined section type.
///
///
/// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
///
///
/// The bit field that declares some specific characteristics of the section contents.
///
///
/// The leaf section which contains PE32+ image.
///
///
/// The leaf section used to determine the dispatch order of PEIMs.
///
///
/// A leaf section type that contains a position-independent-code (PIC) image.
/// A PIC image section is a leaf section that contains a position-independent-code (PIC) image.
/// In addition to normal PE32+ images that contain relocation information, PEIM executables may be
/// PIC and are referred to as PIC images. A PIC image is the same as a PE32+ image except that all
/// relocation information has been stripped from the image and the image can be moved and will
/// execute correctly without performing any relocation or other fix-ups. EFI_PIC_SECTION2 must
/// be used if the section is 16MB or larger.
///
///
/// The leaf section which constains the position-independent-code image.
///
///
/// The leaf section which contains an array of zero or more bytes.
///
///
/// The SMM dependency expression section is a leaf section that contains a dependency expression that
/// is used to determine the dispatch order for SMM drivers. Before the SMRAM invocation of the
/// SMM driver's entry point, this dependency expression must evaluate to TRUE. See the Platform
/// Initialization Specification, Volume 2, for details regarding the format of the dependency expression.
/// 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.
///
///
/// The leaf section which contains a unicode string that
/// is human readable file name.
///
typedef struct {
///
/// Array of unicode string.
///
typedef struct {
///
/// The leaf section which contains a numeric build number and
/// an optional unicode string that represents the file revision.
///
typedef struct {
///
/// Array of unicode string.
///
typedef struct {
///
/// A UINT16 that represents a particular build. Subsequent builds have monotonically
/// increasing build numbers relative to earlier builds.
///
((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) (UINTN) SectionHeaderPtr)->Size) & 0x00ffffff) == 0x00ffffff)
((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) (UINTN) SectionHeaderPtr)->Size) & 0x00ffffff))
#pragma pack()
#endif