1*83d290c5STom Rini /* SPDX-License-Identifier: Intel */ 21021af4dSSimon Glass /* 31021af4dSSimon Glass * Copyright (C) 2013, Intel Corporation 41021af4dSSimon Glass * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com> 51021af4dSSimon Glass */ 61021af4dSSimon Glass 71021af4dSSimon Glass #ifndef __FSP_FFS_H__ 81021af4dSSimon Glass #define __FSP_FFS_H__ 91021af4dSSimon Glass 101021af4dSSimon Glass /* Used to verify the integrity of the file */ 111021af4dSSimon Glass union __packed ffs_integrity { 121021af4dSSimon Glass struct { 131021af4dSSimon Glass /* 141021af4dSSimon Glass * The IntegrityCheck.checksum.header field is an 8-bit 151021af4dSSimon Glass * checksum of the file header. The State and 161021af4dSSimon Glass * IntegrityCheck.checksum.file fields are assumed to be zero 171021af4dSSimon Glass * and the checksum is calculated such that the entire header 181021af4dSSimon Glass * sums to zero. 191021af4dSSimon Glass */ 201021af4dSSimon Glass u8 header; 211021af4dSSimon Glass /* 221021af4dSSimon Glass * If the FFS_ATTRIB_CHECKSUM (see definition below) bit of 231021af4dSSimon Glass * the Attributes field is set to one, the 241021af4dSSimon Glass * IntegrityCheck.checksum.file field is an 8-bit checksum of 251021af4dSSimon Glass * the file data. If the FFS_ATTRIB_CHECKSUM bit of the 261021af4dSSimon Glass * Attributes field is cleared to zero, the 271021af4dSSimon Glass * IntegrityCheck.checksum.file field must be initialized with 281021af4dSSimon Glass * a value of 0xAA. The IntegrityCheck.checksum.file field is 291021af4dSSimon Glass * valid any time the EFI_FILE_DATA_VALID bit is set in the 301021af4dSSimon Glass * State field. 311021af4dSSimon Glass */ 321021af4dSSimon Glass u8 file; 331021af4dSSimon Glass } checksum; 341021af4dSSimon Glass 351021af4dSSimon Glass /* This is the full 16 bits of the IntegrityCheck field */ 361021af4dSSimon Glass u16 checksum16; 371021af4dSSimon Glass }; 381021af4dSSimon Glass 391021af4dSSimon Glass /* 401021af4dSSimon Glass * Each file begins with the header that describe the 411021af4dSSimon Glass * contents and state of the files. 421021af4dSSimon Glass */ 431021af4dSSimon Glass struct __packed ffs_file_header { 441021af4dSSimon Glass /* 451021af4dSSimon Glass * This GUID is the file name. 461021af4dSSimon Glass * It is used to uniquely identify the file. 471021af4dSSimon Glass */ 481021af4dSSimon Glass struct efi_guid name; 491021af4dSSimon Glass /* Used to verify the integrity of the file */ 501021af4dSSimon Glass union ffs_integrity integrity; 511021af4dSSimon Glass /* Identifies the type of file */ 521021af4dSSimon Glass u8 type; 531021af4dSSimon Glass /* Declares various file attribute bits */ 541021af4dSSimon Glass u8 attr; 551021af4dSSimon Glass /* The length of the file in bytes, including the FFS header */ 561021af4dSSimon Glass u8 size[3]; 571021af4dSSimon Glass /* 581021af4dSSimon Glass * Used to track the state of the file throughout the life of 591021af4dSSimon Glass * the file from creation to deletion. 601021af4dSSimon Glass */ 611021af4dSSimon Glass u8 state; 621021af4dSSimon Glass }; 631021af4dSSimon Glass 641021af4dSSimon Glass struct __packed ffs_file_header2 { 651021af4dSSimon Glass /* 661021af4dSSimon Glass * This GUID is the file name. It is used to uniquely identify the file. 671021af4dSSimon Glass * There may be only one instance of a file with the file name GUID of 681021af4dSSimon Glass * Name in any given firmware volume, except if the file type is 691021af4dSSimon Glass * EFI_FV_FILE_TYPE_FFS_PAD. 701021af4dSSimon Glass */ 711021af4dSSimon Glass struct efi_guid name; 721021af4dSSimon Glass /* Used to verify the integrity of the file */ 731021af4dSSimon Glass union ffs_integrity integrity; 741021af4dSSimon Glass /* Identifies the type of file */ 751021af4dSSimon Glass u8 type; 761021af4dSSimon Glass /* Declares various file attribute bits */ 771021af4dSSimon Glass u8 attr; 781021af4dSSimon Glass /* 791021af4dSSimon Glass * The length of the file in bytes, including the FFS header. 801021af4dSSimon Glass * The length of the file data is either 811021af4dSSimon Glass * (size - sizeof(struct ffs_file_header)). This calculation means a 821021af4dSSimon Glass * zero-length file has a size of 24 bytes, which is 831021af4dSSimon Glass * sizeof(struct ffs_file_header). Size is not required to be a 841021af4dSSimon Glass * multiple of 8 bytes. Given a file F, the next file header is located 851021af4dSSimon Glass * at the next 8-byte aligned firmware volume offset following the last 861021af4dSSimon Glass * byte of the file F. 871021af4dSSimon Glass */ 881021af4dSSimon Glass u8 size[3]; 891021af4dSSimon Glass /* 901021af4dSSimon Glass * Used to track the state of the file throughout the life of 911021af4dSSimon Glass * the file from creation to deletion. 921021af4dSSimon Glass */ 931021af4dSSimon Glass u8 state; 941021af4dSSimon Glass /* 951021af4dSSimon Glass * If FFS_ATTRIB_LARGE_FILE is set in attr, then ext_size exists 961021af4dSSimon Glass * and size must be set to zero. 971021af4dSSimon Glass * If FFS_ATTRIB_LARGE_FILE is not set then 981021af4dSSimon Glass * struct ffs_file_header is used. 991021af4dSSimon Glass */ 1001021af4dSSimon Glass u32 ext_size; 1011021af4dSSimon Glass }; 1021021af4dSSimon Glass 1031021af4dSSimon Glass /* 1041021af4dSSimon Glass * Pseudo type. It is used as a wild card when retrieving sections. 1051021af4dSSimon Glass * The section type EFI_SECTION_ALL matches all section types. 1061021af4dSSimon Glass */ 1071021af4dSSimon Glass #define EFI_SECTION_ALL 0x00 1081021af4dSSimon Glass 1091021af4dSSimon Glass /* Encapsulation section Type values */ 1101021af4dSSimon Glass #define EFI_SECTION_COMPRESSION 0x01 1111021af4dSSimon Glass #define EFI_SECTION_GUID_DEFINED 0x02 1121021af4dSSimon Glass #define EFI_SECTION_DISPOSABLE 0x03 1131021af4dSSimon Glass 1141021af4dSSimon Glass /* Leaf section Type values */ 1151021af4dSSimon Glass #define EFI_SECTION_PE32 0x10 1161021af4dSSimon Glass #define EFI_SECTION_PIC 0x11 1171021af4dSSimon Glass #define EFI_SECTION_TE 0x12 1181021af4dSSimon Glass #define EFI_SECTION_DXE_DEPEX 0x13 1191021af4dSSimon Glass #define EFI_SECTION_VERSION 0x14 1201021af4dSSimon Glass #define EFI_SECTION_USER_INTERFACE 0x15 1211021af4dSSimon Glass #define EFI_SECTION_COMPATIBILITY16 0x16 1221021af4dSSimon Glass #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17 1231021af4dSSimon Glass #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18 1241021af4dSSimon Glass #define EFI_SECTION_RAW 0x19 1251021af4dSSimon Glass #define EFI_SECTION_PEI_DEPEX 0x1B 1261021af4dSSimon Glass #define EFI_SECTION_SMM_DEPEX 0x1C 1271021af4dSSimon Glass 1281021af4dSSimon Glass /* Common section header */ 1291021af4dSSimon Glass struct __packed raw_section { 1301021af4dSSimon Glass /* 1311021af4dSSimon Glass * A 24-bit unsigned integer that contains the total size of 1321021af4dSSimon Glass * the section in bytes, including the EFI_COMMON_SECTION_HEADER. 1331021af4dSSimon Glass */ 1341021af4dSSimon Glass u8 size[3]; 1351021af4dSSimon Glass u8 type; 1361021af4dSSimon Glass }; 1371021af4dSSimon Glass 1381021af4dSSimon Glass struct __packed raw_section2 { 1391021af4dSSimon Glass /* 1401021af4dSSimon Glass * A 24-bit unsigned integer that contains the total size of 1411021af4dSSimon Glass * the section in bytes, including the EFI_COMMON_SECTION_HEADER. 1421021af4dSSimon Glass */ 1431021af4dSSimon Glass u8 size[3]; 1441021af4dSSimon Glass u8 type; 1451021af4dSSimon Glass /* 1461021af4dSSimon Glass * If size is 0xFFFFFF, then ext_size contains the size of 1471021af4dSSimon Glass * the section. If size is not equal to 0xFFFFFF, then this 1481021af4dSSimon Glass * field does not exist. 1491021af4dSSimon Glass */ 1501021af4dSSimon Glass u32 ext_size; 1511021af4dSSimon Glass }; 1521021af4dSSimon Glass 1531021af4dSSimon Glass #endif 154