fsp_ffs.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* SPDX-License-Identifier: Intel */
  2. /*
  3. * Copyright (C) 2013, Intel Corporation
  4. * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
  5. */
  6. #ifndef __FSP_FFS_H__
  7. #define __FSP_FFS_H__
  8. /* Used to verify the integrity of the file */
  9. union __packed ffs_integrity {
  10. struct {
  11. /*
  12. * The IntegrityCheck.checksum.header field is an 8-bit
  13. * checksum of the file header. The State and
  14. * IntegrityCheck.checksum.file fields are assumed to be zero
  15. * and the checksum is calculated such that the entire header
  16. * sums to zero.
  17. */
  18. u8 header;
  19. /*
  20. * If the FFS_ATTRIB_CHECKSUM (see definition below) bit of
  21. * the Attributes field is set to one, the
  22. * IntegrityCheck.checksum.file field is an 8-bit checksum of
  23. * the file data. If the FFS_ATTRIB_CHECKSUM bit of the
  24. * Attributes field is cleared to zero, the
  25. * IntegrityCheck.checksum.file field must be initialized with
  26. * a value of 0xAA. The IntegrityCheck.checksum.file field is
  27. * valid any time the EFI_FILE_DATA_VALID bit is set in the
  28. * State field.
  29. */
  30. u8 file;
  31. } checksum;
  32. /* This is the full 16 bits of the IntegrityCheck field */
  33. u16 checksum16;
  34. };
  35. /*
  36. * Each file begins with the header that describe the
  37. * contents and state of the files.
  38. */
  39. struct __packed ffs_file_header {
  40. /*
  41. * This GUID is the file name.
  42. * It is used to uniquely identify the file.
  43. */
  44. struct efi_guid name;
  45. /* Used to verify the integrity of the file */
  46. union ffs_integrity integrity;
  47. /* Identifies the type of file */
  48. u8 type;
  49. /* Declares various file attribute bits */
  50. u8 attr;
  51. /* The length of the file in bytes, including the FFS header */
  52. u8 size[3];
  53. /*
  54. * Used to track the state of the file throughout the life of
  55. * the file from creation to deletion.
  56. */
  57. u8 state;
  58. };
  59. struct __packed ffs_file_header2 {
  60. /*
  61. * This GUID is the file name. It is used to uniquely identify the file.
  62. * There may be only one instance of a file with the file name GUID of
  63. * Name in any given firmware volume, except if the file type is
  64. * EFI_FV_FILE_TYPE_FFS_PAD.
  65. */
  66. struct efi_guid name;
  67. /* Used to verify the integrity of the file */
  68. union ffs_integrity integrity;
  69. /* Identifies the type of file */
  70. u8 type;
  71. /* Declares various file attribute bits */
  72. u8 attr;
  73. /*
  74. * The length of the file in bytes, including the FFS header.
  75. * The length of the file data is either
  76. * (size - sizeof(struct ffs_file_header)). This calculation means a
  77. * zero-length file has a size of 24 bytes, which is
  78. * sizeof(struct ffs_file_header). Size is not required to be a
  79. * multiple of 8 bytes. Given a file F, the next file header is located
  80. * at the next 8-byte aligned firmware volume offset following the last
  81. * byte of the file F.
  82. */
  83. u8 size[3];
  84. /*
  85. * Used to track the state of the file throughout the life of
  86. * the file from creation to deletion.
  87. */
  88. u8 state;
  89. /*
  90. * If FFS_ATTRIB_LARGE_FILE is set in attr, then ext_size exists
  91. * and size must be set to zero.
  92. * If FFS_ATTRIB_LARGE_FILE is not set then
  93. * struct ffs_file_header is used.
  94. */
  95. u32 ext_size;
  96. };
  97. /*
  98. * Pseudo type. It is used as a wild card when retrieving sections.
  99. * The section type EFI_SECTION_ALL matches all section types.
  100. */
  101. #define EFI_SECTION_ALL 0x00
  102. /* Encapsulation section Type values */
  103. #define EFI_SECTION_COMPRESSION 0x01
  104. #define EFI_SECTION_GUID_DEFINED 0x02
  105. #define EFI_SECTION_DISPOSABLE 0x03
  106. /* Leaf section Type values */
  107. #define EFI_SECTION_PE32 0x10
  108. #define EFI_SECTION_PIC 0x11
  109. #define EFI_SECTION_TE 0x12
  110. #define EFI_SECTION_DXE_DEPEX 0x13
  111. #define EFI_SECTION_VERSION 0x14
  112. #define EFI_SECTION_USER_INTERFACE 0x15
  113. #define EFI_SECTION_COMPATIBILITY16 0x16
  114. #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
  115. #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
  116. #define EFI_SECTION_RAW 0x19
  117. #define EFI_SECTION_PEI_DEPEX 0x1B
  118. #define EFI_SECTION_SMM_DEPEX 0x1C
  119. /* Common section header */
  120. struct __packed raw_section {
  121. /*
  122. * A 24-bit unsigned integer that contains the total size of
  123. * the section in bytes, including the EFI_COMMON_SECTION_HEADER.
  124. */
  125. u8 size[3];
  126. u8 type;
  127. };
  128. struct __packed raw_section2 {
  129. /*
  130. * A 24-bit unsigned integer that contains the total size of
  131. * the section in bytes, including the EFI_COMMON_SECTION_HEADER.
  132. */
  133. u8 size[3];
  134. u8 type;
  135. /*
  136. * If size is 0xFFFFFF, then ext_size contains the size of
  137. * the section. If size is not equal to 0xFFFFFF, then this
  138. * field does not exist.
  139. */
  140. u32 ext_size;
  141. };
  142. #endif