fwvol.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. fwvol.h
  5. Abstract:
  6. This header contains definitions for UEFI Firmware Volumes.
  7. Author:
  8. Evan Green 6-Mar-2014
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // --------------------------------------------------------------------- Macros
  15. //
  16. //
  17. // This macro determines if the given alleged section header is a section
  18. // header version 2.
  19. //
  20. #define EFI_IS_SECTION2(_SectionHeader) \
  21. (EFI_SECTION_SIZE(_SectionHeader) == 0x00FFFFFF)
  22. #define EFI_SECTION_SIZE(_SectionHeader) \
  23. (((EFI_COMMON_SECTION_HEADER *)(UINTN)_SectionHeader)->AsUint32 & \
  24. 0x00FFFFFF)
  25. #define EFI_SECTION2_SIZE(_SectionHeader) \
  26. (((EFI_COMMON_SECTION_HEADER2 *) \
  27. (UINTN)_SectionHeader)->Elements.ExtendedSize)
  28. //
  29. // ---------------------------------------------------------------- Definitions
  30. //
  31. //
  32. // Firmware Volume Block Attributes bit definitions.
  33. // They are the shared between Framework and PI1.0.
  34. //
  35. #define EFI_FVB_READ_DISABLED_CAP 0x00000001
  36. #define EFI_FVB_READ_ENABLED_CAP 0x00000002
  37. #define EFI_FVB_READ_STATUS 0x00000004
  38. #define EFI_FVB_WRITE_DISABLED_CAP 0x00000008
  39. #define EFI_FVB_WRITE_ENABLED_CAP 0x00000010
  40. #define EFI_FVB_WRITE_STATUS 0x00000020
  41. #define EFI_FVB_LOCK_CAP 0x00000040
  42. #define EFI_FVB_LOCK_STATUS 0x00000080
  43. #define EFI_FVB_STICKY_WRITE 0x00000200
  44. #define EFI_FVB_MEMORY_MAPPED 0x00000400
  45. #define EFI_FVB_ERASE_POLARITY 0x00000800
  46. #define EFI_FVB2_READ_LOCK_CAP 0x00001000
  47. #define EFI_FVB2_READ_LOCK_STATUS 0x00002000
  48. #define EFI_FVB2_WRITE_LOCK_CAP 0x00004000
  49. #define EFI_FVB2_WRITE_LOCK_STATUS 0x00008000
  50. #define EFI_FVB2_WEAK_ALIGNMENT 0x80000000
  51. #define EFI_FVB2_ALIGNMENT 0x001F0000
  52. #define EFI_FVB2_ALIGNMENT_1 0x00000000
  53. #define EFI_FVB2_ALIGNMENT_2 0x00010000
  54. #define EFI_FVB2_ALIGNMENT_4 0x00020000
  55. #define EFI_FVB2_ALIGNMENT_8 0x00030000
  56. #define EFI_FVB2_ALIGNMENT_16 0x00040000
  57. #define EFI_FVB2_ALIGNMENT_32 0x00050000
  58. #define EFI_FVB2_ALIGNMENT_64 0x00060000
  59. #define EFI_FVB2_ALIGNMENT_128 0x00070000
  60. #define EFI_FVB2_ALIGNMENT_256 0x00080000
  61. #define EFI_FVB2_ALIGNMENT_512 0x00090000
  62. #define EFI_FVB2_ALIGNMENT_1K 0x000A0000
  63. #define EFI_FVB2_ALIGNMENT_2K 0x000B0000
  64. #define EFI_FVB2_ALIGNMENT_4K 0x000C0000
  65. #define EFI_FVB2_ALIGNMENT_8K 0x000D0000
  66. #define EFI_FVB2_ALIGNMENT_16K 0x000E0000
  67. #define EFI_FVB2_ALIGNMENT_32K 0x000F0000
  68. #define EFI_FVB2_ALIGNMENT_64K 0x00100000
  69. #define EFI_FVB2_ALIGNMENT_128K 0x00110000
  70. #define EFI_FVB2_ALIGNMENT_256K 0x00120000
  71. #define EFI_FVB2_ALIGNMENT_512K 0x00130000
  72. #define EFI_FVB2_ALIGNMENT_1M 0x00140000
  73. #define EFI_FVB2_ALIGNMENT_2M 0x00150000
  74. #define EFI_FVB2_ALIGNMENT_4M 0x00160000
  75. #define EFI_FVB2_ALIGNMENT_8M 0x00170000
  76. #define EFI_FVB2_ALIGNMENT_16M 0x00180000
  77. #define EFI_FVB2_ALIGNMENT_32M 0x00190000
  78. #define EFI_FVB2_ALIGNMENT_64M 0x001A0000
  79. #define EFI_FVB2_ALIGNMENT_128M 0x001B0000
  80. #define EFI_FVB2_ALIGNMENT_256M 0x001C0000
  81. #define EFI_FVB2_ALIGNMENT_512M 0x001D0000
  82. #define EFI_FVB2_ALIGNMENT_1G 0x001E0000
  83. #define EFI_FVB2_ALIGNMENT_2G 0x001F0000
  84. #define EFI_FVB_CAPABILITIES (EFI_FVB_READ_DISABLED_CAP | \
  85. EFI_FVB_READ_ENABLED_CAP | \
  86. EFI_FVB_WRITE_DISABLED_CAP | \
  87. EFI_FVB_WRITE_ENABLED_CAP | \
  88. EFI_FVB_LOCK_CAP | \
  89. EFI_FVB2_READ_LOCK_CAP | \
  90. EFI_FVB2_WRITE_LOCK_CAP)
  91. #define EFI_FVB_STATUS (EFI_FVB_READ_STATUS | EFI_FVB_WRITE_STATUS | \
  92. EFI_FVB_LOCK_STATUS | EFI_FVB2_READ_LOCK_STATUS | \
  93. EFI_FVB2_WRITE_LOCK_STATUS)
  94. #define EFI_FV_EXT_TYPE_END 0x00
  95. #define EFI_FV_EXT_TYPE_OEM_TYPE 0x01
  96. //
  97. // Firmware Volume Header Revision definition
  98. //
  99. #define EFI_FVH_REVISION 0x01
  100. //
  101. // PI1.0 define Firmware Volume Header Revision to 2
  102. //
  103. #define EFI_FVH_PI_REVISION 0x02
  104. //
  105. // Firmware Volume Header Signature definition
  106. //
  107. #define EFI_FVH_SIGNATURE 0x4856465F // 'HVF_'
  108. //
  109. // ------------------------------------------------------ Data Type Definitions
  110. //
  111. typedef UINT32 EFI_FVB_ATTRIBUTES, *PEFI_FVB_ATTRIBUTES;
  112. typedef struct _EFI_FIRMWARE_VOLUME_EXT_ENTRY {
  113. UINT16 ExtEntrySize;
  114. UINT16 ExtEntryType;
  115. } PACKED EFI_FIRMWARE_VOLUME_EXT_ENTRY, *PEFI_FIRMWARE_VOLUME_EXT_ENTRY;
  116. typedef struct _EFI_FIRMWARE_VOLUME_EXT_HEADER_OEM_TYPE {
  117. EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr;
  118. UINT32 TypeMask;
  119. EFI_GUID Types[1];
  120. } PACKED EFI_FIRMWARE_VOLUME_EXT_HEADER_OEM_TYPE,
  121. *PEFI_FIRMWARE_VOLUME_EXT_HEADER_OEM_TYPE;
  122. typedef struct _EFI_FIRMWARE_VOLUME_EXT_HEADER {
  123. EFI_GUID FvName;
  124. UINT32 ExtHeaderSize;
  125. } PACKED EFI_FIRMWARE_VOLUME_EXT_HEADER, *PEFI_FIRMWARE_VOLUME_EXT_HEADER;
  126. //
  127. // Firmware Volume Header Block Map Entry definition
  128. //
  129. typedef struct {
  130. UINT32 BlockCount;
  131. UINT32 BlockLength;
  132. } PACKED EFI_FV_BLOCK_MAP_ENTRY;
  133. //
  134. // Firmware Volume Header definition
  135. //
  136. typedef struct {
  137. UINT8 ZeroVector[16];
  138. EFI_GUID FileSystemGuid;
  139. UINT64 Length;
  140. UINT32 Signature;
  141. EFI_FVB_ATTRIBUTES Attributes;
  142. UINT16 HeaderLength;
  143. UINT16 Checksum;
  144. UINT16 ExtHeaderOffset;
  145. UINT8 Reserved[1];
  146. UINT8 Revision;
  147. EFI_FV_BLOCK_MAP_ENTRY BlockMap[1];
  148. } PACKED EFI_FIRMWARE_VOLUME_HEADER;
  149. //
  150. // -------------------------------------------------------------------- Globals
  151. //
  152. //
  153. // -------------------------------------------------------- Function Prototypes
  154. //