fsp_ffs.h 4.4 KB

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