FirmwareVolume.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /** @file
  2. This file declares the Firmware Volume Protocol.
  3. The Firmware Volume Protocol provides file-level access to the firmware volume.
  4. Each firmware volume driver must produce an instance of the Firmware Volume
  5. Protocol if the firmware volume is to be visible to the system. The Firmware
  6. Volume Protocol also provides mechanisms for determining and modifying some
  7. attributes of the firmware volume.
  8. Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
  9. SPDX-License-Identifier: BSD-2-Clause-Patent
  10. @par Revision Reference:
  11. This protocol is defined in Firmware Volume specification.
  12. Version 0.9.
  13. **/
  14. #ifndef _FIRMWARE_VOLUME_H_
  15. #define _FIRMWARE_VOLUME_H_
  16. //
  17. // Firmware Volume Protocol GUID definition
  18. //
  19. #define EFI_FIRMWARE_VOLUME_PROTOCOL_GUID \
  20. { \
  21. 0x389F751F, 0x1838, 0x4388, {0x83, 0x90, 0xCD, 0x81, 0x54, 0xBD, 0x27, 0xF8 } \
  22. }
  23. #define FV_DEVICE_SIGNATURE SIGNATURE_32 ('_', 'F', 'V', '_')
  24. typedef struct _EFI_FIRMWARE_VOLUME_PROTOCOL EFI_FIRMWARE_VOLUME_PROTOCOL;
  25. //
  26. // FRAMEWORK_EFI_FV_ATTRIBUTES bit definitions
  27. //
  28. typedef UINT64 FRAMEWORK_EFI_FV_ATTRIBUTES;
  29. //
  30. // ************************************************************
  31. // FRAMEWORK_EFI_FV_ATTRIBUTES bit definitions
  32. // ************************************************************
  33. //
  34. #define EFI_FV_READ_DISABLE_CAP 0x0000000000000001ULL
  35. #define EFI_FV_READ_ENABLE_CAP 0x0000000000000002ULL
  36. #define EFI_FV_READ_STATUS 0x0000000000000004ULL
  37. #define EFI_FV_WRITE_DISABLE_CAP 0x0000000000000008ULL
  38. #define EFI_FV_WRITE_ENABLE_CAP 0x0000000000000010ULL
  39. #define EFI_FV_WRITE_STATUS 0x0000000000000020ULL
  40. #define EFI_FV_LOCK_CAP 0x0000000000000040ULL
  41. #define EFI_FV_LOCK_STATUS 0x0000000000000080ULL
  42. #define EFI_FV_WRITE_POLICY_RELIABLE 0x0000000000000100ULL
  43. #define EFI_FV_ALIGNMENT_CAP 0x0000000000008000ULL
  44. #define EFI_FV_ALIGNMENT_2 0x0000000000010000ULL
  45. #define EFI_FV_ALIGNMENT_4 0x0000000000020000ULL
  46. #define EFI_FV_ALIGNMENT_8 0x0000000000040000ULL
  47. #define EFI_FV_ALIGNMENT_16 0x0000000000080000ULL
  48. #define EFI_FV_ALIGNMENT_32 0x0000000000100000ULL
  49. #define EFI_FV_ALIGNMENT_64 0x0000000000200000ULL
  50. #define EFI_FV_ALIGNMENT_128 0x0000000000400000ULL
  51. #define EFI_FV_ALIGNMENT_256 0x0000000000800000ULL
  52. #define EFI_FV_ALIGNMENT_512 0x0000000001000000ULL
  53. #define EFI_FV_ALIGNMENT_1K 0x0000000002000000ULL
  54. #define EFI_FV_ALIGNMENT_2K 0x0000000004000000ULL
  55. #define EFI_FV_ALIGNMENT_4K 0x0000000008000000ULL
  56. #define EFI_FV_ALIGNMENT_8K 0x0000000010000000ULL
  57. #define EFI_FV_ALIGNMENT_16K 0x0000000020000000ULL
  58. #define EFI_FV_ALIGNMENT_32K 0x0000000040000000ULL
  59. #define EFI_FV_ALIGNMENT_64K 0x0000000080000000ULL
  60. //
  61. // Protocol API definitions
  62. //
  63. /**
  64. Retrieves attributes, insures positive polarity of attribute bits, and returns
  65. resulting attributes in an output parameter.
  66. @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
  67. @param Attributes Output buffer containing attributes.
  68. @retval EFI_SUCCESS The firmware volume attributes were returned.
  69. **/
  70. typedef
  71. EFI_STATUS
  72. (EFIAPI *FRAMEWORK_EFI_FV_GET_ATTRIBUTES)(
  73. IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
  74. OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes
  75. );
  76. /**
  77. Sets volume attributes
  78. @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
  79. @param Attributes On input, Attributes is a pointer to an
  80. EFI_FV_ATTRIBUTES containing the desired firmware
  81. volume settings. On successful return, it contains
  82. the new settings of the firmware volume. On
  83. unsuccessful return, Attributes is not modified
  84. and the firmware volume settings are not changed.
  85. @retval EFI_INVALID_PARAMETER A bit in Attributes was invalid.
  86. @retval EFI_SUCCESS The requested firmware volume attributes were set
  87. and the resulting EFI_FV_ATTRIBUTES is returned in
  88. Attributes.
  89. @retval EFI_ACCESS_DENIED The Device is locked and does not permit modification.
  90. **/
  91. typedef
  92. EFI_STATUS
  93. (EFIAPI *FRAMEWORK_EFI_FV_SET_ATTRIBUTES)(
  94. IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
  95. IN OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes
  96. );
  97. /**
  98. Read the requested file (NameGuid) or file information from the firmware volume
  99. and returns data in Buffer.
  100. @param This The EFI_FIRMWARE_VOLUME_PROTOCOL instance.
  101. @param NameGuid The pointer to EFI_GUID, which is the filename of
  102. the file to read.
  103. @param Buffer The pointer to pointer to buffer in which contents of file are returned.
  104. <br>
  105. If Buffer is NULL, only type, attributes, and size
  106. are returned as there is no output buffer.
  107. <br>
  108. If Buffer != NULL and *Buffer == NULL, the output
  109. buffer is allocated from BS pool by ReadFile.
  110. <br>
  111. If Buffer != NULL and *Buffer != NULL, the output
  112. buffer has been allocated by the caller and is being
  113. passed in.
  114. @param BufferSize On input: The buffer size. On output: The size
  115. required to complete the read.
  116. @param FoundType The pointer to the type of the file whose data
  117. is returned.
  118. @param FileAttributes The pointer to attributes of the file whose data
  119. is returned.
  120. @param AuthenticationStatus The pointer to the authentication status of the data.
  121. @retval EFI_SUCCESS The call completed successfully.
  122. @retval EFI_WARN_BUFFER_TOO_SMALL The buffer is too small to contain the requested output.
  123. The buffer filled, and the output is truncated.
  124. @retval EFI_NOT_FOUND NameGuid was not found in the firmware volume.
  125. @retval EFI_DEVICE_ERROR A hardware error occurred when attempting to
  126. access the firmware volume.
  127. @retval EFI_ACCESS_DENIED The firmware volume is configured to disallow reads.
  128. @retval EFI_OUT_OF_RESOURCES An allocation failure occurred.
  129. **/
  130. typedef
  131. EFI_STATUS
  132. (EFIAPI *FRAMEWORK_EFI_FV_READ_FILE)(
  133. IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
  134. IN EFI_GUID *NameGuid,
  135. IN OUT VOID **Buffer,
  136. IN OUT UINTN *BufferSize,
  137. OUT EFI_FV_FILETYPE *FoundType,
  138. OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
  139. OUT UINT32 *AuthenticationStatus
  140. );
  141. /**
  142. Read the requested section from the specified file and returns data in Buffer.
  143. @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
  144. @param NameGuid Filename identifying the file from which to read.
  145. @param SectionType The section type to retrieve.
  146. @param SectionInstance The instance of SectionType to retrieve.
  147. @param Buffer Pointer to pointer to buffer in which contents of
  148. a file are returned.
  149. <br>
  150. If Buffer is NULL, only type, attributes, and size
  151. are returned as there is no output buffer.
  152. <br>
  153. If Buffer != NULL and *Buffer == NULL, the output
  154. buffer is allocated from BS pool by ReadFile.
  155. <br>
  156. If Buffer != NULL and *Buffer != NULL, the output
  157. buffer has been allocated by the caller and is being
  158. passed in.
  159. @param BufferSize The pointer to the buffer size passed in, and on
  160. output the size required to complete the read.
  161. @param AuthenticationStatus The pointer to the authentication status of the data.
  162. @retval EFI_SUCCESS The call completed successfully.
  163. @retval EFI_WARN_BUFFER_TOO_SMALL The buffer is too small to contain the requested output.
  164. The buffer is filled and the output is truncated.
  165. @retval EFI_OUT_OF_RESOURCES An allocation failure occurred.
  166. @retval EFI_NOT_FOUND The name was not found in the firmware volume.
  167. @retval EFI_DEVICE_ERROR A hardware error occurred when attempting to
  168. access the firmware volume.
  169. @retval EFI_ACCESS_DENIED The firmware volume is configured to disallow reads.
  170. **/
  171. typedef
  172. EFI_STATUS
  173. (EFIAPI *FRAMEWORK_EFI_FV_READ_SECTION)(
  174. IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
  175. IN EFI_GUID *NameGuid,
  176. IN EFI_SECTION_TYPE SectionType,
  177. IN UINTN SectionInstance,
  178. IN OUT VOID **Buffer,
  179. IN OUT UINTN *BufferSize,
  180. OUT UINT32 *AuthenticationStatus
  181. );
  182. typedef UINT32 FRAMEWORK_EFI_FV_WRITE_POLICY;
  183. #define FRAMEWORK_EFI_FV_UNRELIABLE_WRITE 0x00000000
  184. #define FRAMEWORK_EFI_FV_RELIABLE_WRITE 0x00000001
  185. typedef struct {
  186. EFI_GUID *NameGuid;
  187. EFI_FV_FILETYPE Type;
  188. EFI_FV_FILE_ATTRIBUTES FileAttributes;
  189. VOID *Buffer;
  190. UINT32 BufferSize;
  191. } FRAMEWORK_EFI_FV_WRITE_FILE_DATA;
  192. /**
  193. Write the supplied file (NameGuid) to the FV.
  194. @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
  195. @param NumberOfFiles Indicates the number of file records pointed to
  196. by FileData.
  197. @param WritePolicy Indicates the level of reliability of the write
  198. with respect to things like power failure events.
  199. @param FileData A pointer to an array of EFI_FV_WRITE_FILE_DATA
  200. structures. Each element in the array indicates
  201. a file to write, and there are NumberOfFiles
  202. elements in the input array.
  203. @retval EFI_SUCCESS The write completed successfully.
  204. @retval EFI_OUT_OF_RESOURCES The firmware volume does not have enough free
  205. space to store file(s).
  206. @retval EFI_DEVICE_ERROR A hardware error occurred when attempting to
  207. access the firmware volume.
  208. @retval EFI_WRITE_PROTECTED The firmware volume is configured to disallow writes.
  209. @retval EFI_NOT_FOUND A delete was requested, but the requested file was
  210. not found in the firmware volume.
  211. @retval EFI_INVALID_PARAMETER A delete was requested with a multiple file write.
  212. An unsupported WritePolicy was requested.
  213. An unknown file type was specified.
  214. A file system specific error has occurred.
  215. **/
  216. typedef
  217. EFI_STATUS
  218. (EFIAPI *FRAMEWORK_EFI_FV_WRITE_FILE)(
  219. IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
  220. IN UINT32 NumberOfFiles,
  221. IN FRAMEWORK_EFI_FV_WRITE_POLICY WritePolicy,
  222. IN FRAMEWORK_EFI_FV_WRITE_FILE_DATA *FileData
  223. );
  224. /**
  225. Given the input key, search for the next matching file in the volume.
  226. @param This Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
  227. @param Key Pointer to a caller allocated buffer that contains
  228. an implementation-specific key that is used to track
  229. where to begin searching on successive calls.
  230. @param FileType The pointer to the file type to filter for.
  231. @param NameGuid The pointer to Guid filename of the file found.
  232. @param Attributes The pointer to Attributes of the file found.
  233. @param Size The pointer to Size in bytes of the file found.
  234. @retval EFI_SUCCESS The output parameters are filled with data obtained from
  235. the first matching file that was found.
  236. @retval EFI_NOT_FOUND No files of type FileType were found.
  237. @retval EFI_DEVICE_ERROR A hardware error occurred when attempting to access
  238. the firmware volume.
  239. @retval EFI_ACCESS_DENIED The firmware volume is configured to disallow reads.
  240. **/
  241. typedef
  242. EFI_STATUS
  243. (EFIAPI *FRAMEWORK_EFI_FV_GET_NEXT_FILE)(
  244. IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
  245. IN OUT VOID *Key,
  246. IN OUT EFI_FV_FILETYPE *FileType,
  247. OUT EFI_GUID *NameGuid,
  248. OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
  249. OUT UINTN *Size
  250. );
  251. //
  252. // Protocol interface structure
  253. //
  254. struct _EFI_FIRMWARE_VOLUME_PROTOCOL {
  255. ///
  256. /// Retrieves volume capabilities and current settings.
  257. ///
  258. FRAMEWORK_EFI_FV_GET_ATTRIBUTES GetVolumeAttributes;
  259. ///
  260. /// Modifies the current settings of the firmware volume.
  261. ///
  262. FRAMEWORK_EFI_FV_SET_ATTRIBUTES SetVolumeAttributes;
  263. ///
  264. /// Reads an entire file from the firmware volume.
  265. ///
  266. FRAMEWORK_EFI_FV_READ_FILE ReadFile;
  267. ///
  268. /// Reads a single section from a file into a buffer.
  269. ///
  270. FRAMEWORK_EFI_FV_READ_SECTION ReadSection;
  271. ///
  272. /// Writes an entire file into the firmware volume.
  273. ///
  274. FRAMEWORK_EFI_FV_WRITE_FILE WriteFile;
  275. ///
  276. /// Provides service to allow searching the firmware volume.
  277. ///
  278. FRAMEWORK_EFI_FV_GET_NEXT_FILE GetNextFile;
  279. ///
  280. /// Data field that indicates the size in bytes of the Key input buffer for
  281. /// the GetNextFile() API.
  282. ///
  283. UINT32 KeySize;
  284. ///
  285. /// Handle of the parent firmware volume.
  286. ///
  287. EFI_HANDLE ParentHandle;
  288. };
  289. extern EFI_GUID gEfiFirmwareVolumeProtocolGuid;
  290. #endif