fwvolp.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  1. /*++
  2. Copyright (c) 2014 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. fwvolp.h
  9. Abstract:
  10. This header contains internal definitions for the firmware volume support
  11. library.
  12. Author:
  13. Evan Green 11-Mar-2014
  14. --*/
  15. //
  16. // ------------------------------------------------------------------- Includes
  17. //
  18. #include "fwvol.h"
  19. #include "fvblock.h"
  20. #include "efiffs.h"
  21. #include "fv2.h"
  22. //
  23. // --------------------------------------------------------------------- Macros
  24. //
  25. //
  26. // This macro returns a pointer to the firmware volume device given a pointer
  27. // to the protocol instance.
  28. //
  29. #define EFI_FIRMWARE_VOLUME_FROM_THIS(_FirmwareVolumeProtocol) \
  30. LIST_VALUE(_FirmwareVolumeProtocol, EFI_FIRMWARE_VOLUME, VolumeProtocol)
  31. //
  32. // ---------------------------------------------------------------- Definitions
  33. //
  34. #define EFI_FIRMWARE_VOLUME_MAGIC 0x6F567746 // 'oVwF'
  35. //
  36. // ------------------------------------------------------ Data Type Definitions
  37. //
  38. /*++
  39. Structure Description:
  40. This structure describes information about a file in a firmware volume.
  41. Members:
  42. ListEntry - Stores pointers to the next and previous FFS file list entries.
  43. FileHeader - Stores a pointer to the FFS file header.
  44. StreamHandle - Stores the stream handle.
  45. --*/
  46. typedef struct _EFI_FFS_FILE_LIST_ENTRY {
  47. LIST_ENTRY ListEntry;
  48. EFI_FFS_FILE_HEADER *FileHeader;
  49. UINTN StreamHandle;
  50. } EFI_FFS_FILE_LIST_ENTRY, *PEFI_FFS_FILE_LIST_ENTRY;
  51. /*++
  52. Structure Description:
  53. This structure describes the internal data structure of a firmware volume.
  54. Members:
  55. Magic - Stores the magic constant EFI_FIRMWARE_VOLUME_MAGIC.
  56. BlockIo - Stores a pointer to the firmware volume block I/O protocol.
  57. Handle - Stores the volume handle.
  58. VolumeProtocol - Stores the firmware volume protocol.
  59. VolumeHeader - Stores a cached copy of the firmware volume header.
  60. CachedVolume - Stores cached volume data.
  61. EndOfCachedVolume - Stores the end of the cached volume data.
  62. LastKey - Stores a pointer to the last search key used.
  63. FfsFileList - Stores the head of the list of FFS files.
  64. ErasePolarity - Stores the erase polarity of the device.
  65. IsFfs3 - Stores a boolean indicating if this is FFS version 3 (TRUE) or
  66. version 2 (FALSE).
  67. AuthenticationStatus - Stores the authentication status.
  68. --*/
  69. typedef struct _EFI_FIRMWARE_VOLUME {
  70. UINTN Magic;
  71. EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *BlockIo;
  72. EFI_HANDLE Handle;
  73. EFI_FIRMWARE_VOLUME2_PROTOCOL VolumeProtocol;
  74. EFI_FIRMWARE_VOLUME_HEADER *VolumeHeader;
  75. UINT8 *CachedVolume;
  76. UINT8 *EndOfCachedVolume;
  77. EFI_FFS_FILE_LIST_ENTRY *LastKey;
  78. LIST_ENTRY FfsFileList;
  79. UINT8 ErasePolarity;
  80. BOOLEAN IsFfs3;
  81. UINT32 AuthenticationStatus;
  82. } EFI_FIRMWARE_VOLUME, *PEFI_FIRMWARE_VOLUME;
  83. //
  84. // -------------------------------------------------------------------- Globals
  85. //
  86. extern EFI_GUID EfiFirmwareVolumeBlockProtocolGuid;
  87. //
  88. // -------------------------------------------------------- Function Prototypes
  89. //
  90. EFI_STATUS
  91. EfiFvGetVolumeHeader (
  92. EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *BlockProtocol,
  93. EFI_FIRMWARE_VOLUME_HEADER **Header
  94. );
  95. /*++
  96. Routine Description:
  97. This routine returns the firmware volume header of the volume represented
  98. by the given block I/O interface.
  99. Arguments:
  100. BlockProtocol - Supplies an instance of the block I/O protocol.
  101. Header - Supplies a pointer where a pointer to the volume header allocated
  102. from pool will be returned on success.
  103. Return Value:
  104. EFI status code.
  105. --*/
  106. EFI_STATUS
  107. EfiFvReadData (
  108. EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *BlockProtocol,
  109. EFI_LBA *StartLba,
  110. UINTN *Offset,
  111. UINTN DataSize,
  112. UINT8 *Data
  113. );
  114. /*++
  115. Routine Description:
  116. This routine reads data from the firmware volume represented by the given
  117. block I/O interface. This data may span multiple block ranges.
  118. Arguments:
  119. BlockProtocol - Supplies an instance of the block I/O protocol.
  120. StartLba - Supplies a pointer that on input contains the logical block
  121. address to read from. On output, this will contain the logical block
  122. address after reading.
  123. Offset - Supplies a pointer that on input contains the offset within the
  124. block to start reading. On output, the offset into the block after
  125. reading will be returned.
  126. DataSize - Supplies the size of the data to read in bytes.
  127. Data - Supplies a pointer where the read data will be returned.
  128. Return Value:
  129. EFI status code.
  130. --*/
  131. BOOLEAN
  132. EfiFvVerifyHeaderChecksum (
  133. EFI_FIRMWARE_VOLUME_HEADER *VolumeHeader
  134. );
  135. /*++
  136. Routine Description:
  137. This routine verifies the checksum of a firmware volume header.
  138. Arguments:
  139. VolumeHeader - Supplies a pointer to the volume header to verify.
  140. Return Value:
  141. TRUE if the checksum verification passed.
  142. FALSE if the checksum verification failed.
  143. --*/
  144. EFIAPI
  145. EFI_STATUS
  146. EfiFvOpenSectionStream (
  147. UINTN SectionStreamLength,
  148. VOID *SectionStream,
  149. UINTN *SectionStreamHandle
  150. );
  151. /*++
  152. Routine Description:
  153. This routine creates and returns a new section stream handle to represent
  154. a new section stream.
  155. Arguments:
  156. SectionStreamLength - Supplies the size in bytes of the section stream.
  157. SectionStream - Supplies the section stream.
  158. SectionStreamHandle - Supplies a pointer where a handle to the stream will
  159. be returned.
  160. Return Value:
  161. EFI_SUCCESS on success.
  162. EFI_OUT_OF_RESOURCES if memory allocation failed.
  163. EFI_INVALID_PARAMETER if the section stream does not end noincidentally to
  164. the end of the previous section.
  165. --*/
  166. EFIAPI
  167. EFI_STATUS
  168. EfiFvCloseSectionStream (
  169. UINTN StreamHandle
  170. );
  171. /*++
  172. Routine Description:
  173. This routine closes an open section stream handle.
  174. Arguments:
  175. StreamHandle - Supplies the stream handle previously returned.
  176. Return Value:
  177. EFI status code.
  178. --*/
  179. EFIAPI
  180. EFI_STATUS
  181. EfiFvGetSection (
  182. UINTN SectionStreamHandle,
  183. EFI_SECTION_TYPE *SectionType,
  184. EFI_GUID *SectionDefinitionGuid,
  185. UINTN SectionInstance,
  186. VOID **Buffer,
  187. UINTN *BufferSize,
  188. UINT32 *AuthenticationStatus,
  189. BOOLEAN IsFfs3Fv
  190. );
  191. /*++
  192. Routine Description:
  193. This routine reads a section from a given section stream.
  194. Arguments:
  195. SectionStreamHandle - Supplies the stream handle of the stream to get the
  196. section from.
  197. SectionType - Supplies a pointer that on input contains the type of section
  198. to search for. On output, this will return the type of the section
  199. found.
  200. SectionDefinitionGuid - Supplies a pointer to the GUID of the section to
  201. search for if the section type indicates EFI_SECTION_GUID_DEFINED.
  202. SectionInstance - Supplies the instance of the requested section to
  203. return.
  204. Buffer - Supplies a pointer to a buffer value. If the value of the buffer
  205. is NULL, then the buffer is callee-allocated. If it is not NULL, then
  206. the supplied buffer is used.
  207. BufferSize - Supplies a pointer that on input contains the size of the
  208. buffer, if supplied. On output, the size of the section will be
  209. returned.
  210. AuthenticationStatus - Supplies a pointer where the authentication status
  211. will be returned.
  212. IsFfs3Fv - Supplies a boolean indicating if the firmware file system is
  213. version 3 (TRUE) or version 2 (FALSE).
  214. Return Value:
  215. EFI_SUCCESS on success.
  216. EFI_PROTOCOL_ERROR if a GUIDed section was encountered but no extraction
  217. protocol was found.
  218. EFI_NOT_FOUND if an error occurred while parsing the section stream, or the
  219. requested section does not exist.
  220. EFI_OUT_OF_RESOURCES on allocation failure.
  221. EFI_INVALID_PARAMETER if the given section stream handle does not exist.
  222. EFI_WARN_TOO_SMALL if a buffer value was supplied but it was not big enough
  223. to hold the requested section.
  224. --*/
  225. EFIAPI
  226. EFI_STATUS
  227. EfiFvGetVolumeAttributes (
  228. CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
  229. EFI_FV_ATTRIBUTES *Attributes
  230. );
  231. /*++
  232. Routine Description:
  233. This routine returns the attributes and current settings of the firmware
  234. volume. Because of constraints imposed by the underlying firmware storage,
  235. an instance of the Firmware Volume Protocol may not be to able to support
  236. all possible variations of this architecture. These constraints and the
  237. current state of the firmware volume are exposed to the caller using the
  238. get volume attributes function. The get volume attributes function is
  239. callable only from TPL_NOTIFY and below. Behavior of this routine at any
  240. EFI_TPL above TPL_NOTIFY is undefined.
  241. Arguments:
  242. This - Supplies the protocol instance.
  243. Attributes - Supplies a pointer where the volume attributes and current
  244. settings are returned.
  245. Return Value:
  246. EFI_SUCCESS on success.
  247. --*/
  248. EFIAPI
  249. EFI_STATUS
  250. EfiFvSetVolumeAttributes (
  251. CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
  252. EFI_FV_ATTRIBUTES *Attributes
  253. );
  254. /*++
  255. Routine Description:
  256. This routine modifies current settings of the firmware volume according to
  257. the input parameter. This function is used to set configurable firmware
  258. volume attributes. Only EFI_FV_READ_STATUS, EFI_FV_WRITE_STATUS, and
  259. EFI_FV_LOCK_STATUS may be modified, and then only in accordance with the
  260. declared capabilities. All other bits of FvAttributes are ignored on input.
  261. On successful return, all bits of *FvAttributes are valid and it contains
  262. the completed EFI_FV_ATTRIBUTES for the volume. To modify an attribute, the
  263. corresponding status bit in the EFI_FV_ATTRIBUTES is set to the desired
  264. value on input. The EFI_FV_LOCK_STATUS bit does not affect the ability to
  265. read or write the firmware volume. Rather, once the EFI_FV_LOCK_STATUS bit
  266. is set, it prevents further modification to all the attribute bits. This
  267. routine is callable only from TPL_NOTIFY and below. Behavior of this
  268. routine at any EFI_TPL above TPL_NOTIFY is undefined.
  269. Arguments:
  270. This - Supplies the protocol instance.
  271. Attributes - Supplies a that on input contains the attributes to set. On
  272. output, the new current settings of the firmware volume are returned.
  273. Return Value:
  274. EFI_SUCCESS on success.
  275. EFI_INVALID_PARAMETER if the device does not support the status bit
  276. settings.
  277. EFI_ACCESS_DENIED if the device is locked and does not allow modification.
  278. --*/
  279. EFIAPI
  280. EFI_STATUS
  281. EfiFvGetVolumeInfo (
  282. CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
  283. CONST EFI_GUID *InformationType,
  284. UINTN *BufferSize,
  285. VOID *Buffer
  286. );
  287. /*++
  288. Routine Description:
  289. This routine returns information about a firmware volume. this routine
  290. returns information of the requested type for the requested firmware
  291. volume. If the volume does not support the requested information type, then
  292. EFI_UNSUPPORTED is returned. If the buffer is not large enough to hold the
  293. requested structure, EFI_BUFFER_TOO_SMALL is returned and the buffer size
  294. is set to the size of buffer that is required to make the request. The
  295. information types defined by this specification are required information
  296. types that all file systems must support.
  297. Arguments:
  298. This - Supplies the protocol instance.
  299. InformationType - Supplies a pointer to the GUID defining the type of
  300. information being requested.
  301. BufferSize - Supplies a pointer that on input contains the size of the
  302. buffer. On output, contains the size of the data, even if the buffer
  303. was too small.
  304. Buffer - Supplies the buffer where the information value will be returned.
  305. Return Value:
  306. EFI_SUCCESS on success.
  307. EFI_UNSUPPORTED if the information type is not known.
  308. EFI_NO_MEDIA if the device has no media inserted.
  309. EFI_DEVICE_ERROR if a hardware error occurred accessing the device.
  310. EFI_VOLUME_CORRUPTED if the file system structures are gonezo.
  311. EFI_BUFFER_TOO_SMALL if the supplied buffer was not large enough to hold
  312. the requested value. In this case the buffer size will have been updated
  313. to contain the needed value.
  314. --*/
  315. EFIAPI
  316. EFI_STATUS
  317. EfiFvSetVolumeInfo (
  318. CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
  319. CONST EFI_GUID *InformationType,
  320. UINTN BufferSize,
  321. CONST VOID *Buffer
  322. );
  323. /*++
  324. Routine Description:
  325. This routine sets information about a firmware volume.
  326. Arguments:
  327. This - Supplies the protocol instance.
  328. InformationType - Supplies a pointer to the GUID defining the type of
  329. information being set.
  330. BufferSize - Supplies the size of the information value in bytes.
  331. Buffer - Supplies the information value.
  332. Return Value:
  333. EFI_SUCCESS on success.
  334. EFI_UNSUPPORTED if the information type is not known.
  335. EFI_NO_MEDIA if the device has no media inserted.
  336. EFI_DEVICE_ERROR if a hardware error occurred accessing the device.
  337. EFI_VOLUME_CORRUPTED if the file system structures are gonezo.
  338. EFI_WRITE_PROTECTED if the volume is read-only.
  339. EFI_BAD_BUFFER_SIZE if the buffer size was smaller than the size of the
  340. type indicated in the information type GUID.
  341. --*/
  342. EFIAPI
  343. EFI_STATUS
  344. EfiFvReadFileSection (
  345. CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
  346. CONST EFI_GUID *NameGuid,
  347. EFI_SECTION_TYPE SectionType,
  348. UINTN SectionInstance,
  349. VOID **Buffer,
  350. UINTN *BufferSize,
  351. UINT32 *AuthenticationStatus
  352. );
  353. /*++
  354. Routine Description:
  355. This routine locates the requested section within a file and returns it in
  356. a buffer. This routine is used to retrieve a specific section from a file
  357. within a firmware volume. The section returned is determined using a
  358. depth-first, left-to-right search algorithm through all sections found in
  359. the specified file. The output buffer is specified by a double indirection
  360. of the buffer parameter. The input value of Buffer is used to determine if
  361. the output buffer is caller allocated or is dynamically allocated by this
  362. routine. If the input value of the buffer is not NULL, it indicates that
  363. the output buffer is caller allocated. In this case, the input value of
  364. *BufferSize indicates the size of the caller-allocated output buffer. If
  365. the output buffer is not large enough to contain the entire requested
  366. output, it is filled up to the point that the output buffer is exhausted
  367. and EFI_WARN_BUFFER_TOO_SMALL is returned, and then BufferSize is returned
  368. with the size that is required to successfully complete the read. All other
  369. output parameters are returned with valid values. If the input value of the
  370. buffer is NULL, it indicates the output buffer is to be allocated by this
  371. routine. In this case, this routine will allocate an appropriately sized
  372. buffer from boot services pool memory, which will be returned in the buffer
  373. value. The size of the new buffer is returned in *BufferSize and all other
  374. output parameters are returned with valid values. This routine is callable
  375. only from TPL_NOTIFY and below. Behavior of this routine at any EFI_TPL
  376. above TPL_NOTIFY is undefined.
  377. Arguments:
  378. This - Supplies the protocol instance.
  379. NameGuid - Supplies a pointer to a GUID containing the name of the file.
  380. All firmware file names are EFI_GUIDs. Each firmware volume file name
  381. must be unique.
  382. SectionType - Supplies the type of section to return.
  383. SectionInstance - Supplies the occurrence of the given section type to
  384. return.
  385. Buffer - Supplies a pointer to a buffer in which the file contents are
  386. returned, not including the file header.
  387. BufferSize - Supplies a pointer that on input indicates the size of the
  388. supplied buffer in bytes.
  389. AuthenticationStatus - Supplies a pointer where the file authentication
  390. status will be returned.
  391. Return Value:
  392. EFI_SUCCESS on success.
  393. EFI_WARN_TOO_SMALL if the buffer is too small to contain the requested
  394. output. The buffer is filled and truncated.
  395. EFI_OUT_OF_RESOURCES if an allocation failed.
  396. EFI_NOT_FOUND if the requested file or section was not found in the
  397. firmware volume or file.
  398. EFI_DEVICE_ERROR if a hardware error occurred accessing the device.
  399. EFI_ACCESS_DENIED if the firmware volume is configured to disallow reads.
  400. EFI_PROTOCOL_ERROR if the requested section was not found, but the file
  401. could not be fully parsed because a required
  402. GUIDED_SECTION_EXTRACTION_PROTOCOL was not found. The requested section
  403. might have been found if only it could be extracted.
  404. --*/
  405. EFIAPI
  406. EFI_STATUS
  407. EfiFvReadFile (
  408. CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
  409. CONST EFI_GUID *NameGuid,
  410. VOID **Buffer,
  411. UINTN *BufferSize,
  412. EFI_FV_FILETYPE *FoundType,
  413. EFI_FV_FILE_ATTRIBUTES *FileAttributes,
  414. UINT32 *AuthenticationStatus
  415. );
  416. /*++
  417. Routine Description:
  418. This routine retrieves a file and/or file information from the firmware
  419. volume. This routine is used to retrieve any file from a firmware volume
  420. during the DXE phase. The actual binary encoding of the file in the
  421. firmware volume media may be in any arbitrary format as long as it does the
  422. following: It is accessed using the Firmware Volume Protocol. The image
  423. that is returned follows the image format defined in Code Definitions:
  424. PI Firmware File Format. If the input buffer is NULL, it indicates the
  425. caller is requesting only that the type, attributes, and size of the file
  426. be returned and that there is no output buffer. In this case, the following
  427. occurs:
  428. - BufferSize is returned with the size that is required to
  429. successfully complete the read.
  430. - The output parameters FoundType and *FileAttributes are
  431. returned with valid values.
  432. - The returned value of *AuthenticationStatus is undefined.
  433. If the input buffer is not NULL, the output buffer is specified by a double
  434. indirection of the Buffer parameter. The input value of *Buffer is used to
  435. determine if the output buffer is caller allocated or is dynamically
  436. allocated by this routine. If the input value of *Buffer is not NULL, it
  437. indicates the output buffer is caller allocated. In this case, the input
  438. value of *BufferSize indicates the size of the caller-allocated output
  439. buffer. If the output buffer is not large enough to contain the entire
  440. requested output, it is filled up to the point that the output buffer is
  441. exhausted and EFI_WARN_BUFFER_TOO_SMALL is returned, and then BufferSize is
  442. returned with the size required to successfully complete the read. All
  443. other output parameters are returned with valid values. If the input buffer
  444. is NULL, it indicates the output buffer is to be allocated by this routine.
  445. In this case, this routine will allocate an appropriately sized buffer from
  446. boot services pool memory, which will be returned in Buffer. The size of
  447. the new buffer is returned in the buffer size parameter and all other
  448. output parameters are returned with valid values. This routine is callable
  449. only from TPL_NOTIFY and below. Behavior of this routine at any EFI_TPL
  450. above TPL_NOTIFY is undefined.
  451. Arguments:
  452. This - Supplies the protocol instance.
  453. NameGuid - Supplies a pointer to a GUID containing the name of the file.
  454. All firmware file names are EFI_GUIDs. Each firmware volume file name
  455. must be unique.
  456. Buffer - Supplies a pointer to a buffer in which the file contents are
  457. returned, not including the file header.
  458. BufferSize - Supplies a pointer that on input indicates the size of the
  459. supplied buffer in bytes.
  460. FoundType - Supplies a pointer where the file type will be returned.
  461. FileAttributes - Supplies a pointer where the file attributes will be
  462. returned.
  463. AuthenticationStatus - Supplies a pointer where the file authentication
  464. status will be returned.
  465. Return Value:
  466. EFI_SUCCESS on success.
  467. EFI_WARN_TOO_SMALL if the buffer is too small to contain the requested
  468. output. The buffer is filled and truncated.
  469. EFI_OUT_OF_RESOURCES if an allocation failed.
  470. EFI_NOT_FOUND if the given name was not in the firmware volume.
  471. EFI_DEVICE_ERROR if a hardware error occurred accessing the device.
  472. EFI_ACCESS_DENIED if the firmware volume is configured to disallow reads.
  473. --*/
  474. EFIAPI
  475. EFI_STATUS
  476. EfiFvGetNextFile (
  477. CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
  478. VOID *Key,
  479. EFI_FV_FILETYPE *FileType,
  480. EFI_GUID *NameGuid,
  481. EFI_FV_FILE_ATTRIBUTES *Attributes,
  482. UINTN *Size
  483. );
  484. /*++
  485. Routine Description:
  486. This routine retrieves information about the next file in the firmware
  487. volume store that matches the search criteria. This routine is the
  488. interface that is used to search a firmware volume for a particular file.
  489. It is called successively until the desired file is located or the function
  490. returns EFI_NOT_FOUND. To filter uninteresting files from the output, the
  491. type of file to search for may be specified in FileType. For example, if the
  492. file type is EFI_FV_FILETYPE_DRIVER, only files of this type will be
  493. returned in the output. If the file type is EFI_FV_FILETYPE_ALL, no
  494. filtering of file types is done. The key parameter is used to indicate a
  495. starting point of the search. If the value of the key parameter is
  496. completely initialized to zero, the search re-initialized and starts at the
  497. beginning. Subsequent calls to this routine must maintain the value of *Key
  498. returned by the immediately previous call. The actual contents of *Key are
  499. implementation specific and no semantic content is implied. This routine is
  500. callable only from TPL_NOTIFY and below. Behavior of this routine at any
  501. EFI_TPL above TPL_NOTIFY is undefined.
  502. Arguments:
  503. This - Supplies the protocol instance.
  504. Key - Supplies a pointer to a caller-allocated buffer containing the
  505. implementation-specific data used to track the current position of the
  506. search. The size of the buffer must be at least This->KeySize bytes
  507. long. To re-initialize the search and begin from the beginning of the
  508. firmware volume, the entire buffer must be cleared to zero. Other than
  509. clearing the buffer to initiate a new search, the caller must not
  510. modify the data in the buffer between calls to this routine.
  511. FileType - Supplies a pointer that on input contains the filter of file
  512. types to search for. If a file is found, its type will be returned
  513. here.
  514. NameGuid - Supplies a pointer where the name GUID of the file will be
  515. returned on success.
  516. Attributes - Supplies a pointer where the file attributes will be returned
  517. on success.
  518. Size - Supplies a pointer where the size of the file is returned on success.
  519. Return Value:
  520. EFI_SUCCESS on success.
  521. EFI_NOT_FOUND if no files of the given file type were found.
  522. EFI_DEVICE_ERROR if a hardware error occurred accessing the device.
  523. EFI_ACCESS_DENIED if the firmware volume does not allow reads.
  524. --*/
  525. EFIAPI
  526. EFI_STATUS
  527. EfiFvWriteFile (
  528. CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
  529. UINT32 NumberOfFiles,
  530. EFI_FV_WRITE_POLICY WritePolicy,
  531. EFI_FV_WRITE_FILE_DATA *FileData
  532. );
  533. /*++
  534. Routine Description:
  535. This routine is used to write one or more files to a firmware volume. Each
  536. file to be written is described by an EFI_FV_WRITE_FILE_DATA structure.
  537. The caller must ensure that any required alignment for all files listed in
  538. the file data array is compatible with the firmware volume. Firmware volume
  539. capabilities can be determined using the get volume attributes function.
  540. Similarly, if the write policy is set to EFI_FV_RELIABLE_WRITE, the caller
  541. must check the firmware volume capabilities to ensure EFI_FV_RELIABLE_WRITE
  542. is supported by the firmware volume. EFI_FV_UNRELIABLE_WRITE must always be
  543. supported. Writing a file with a size of zero (FileData[n].BufferSize == 0)
  544. deletes the file from the firmware volume if it exists. Deleting a file
  545. must be done one at a time. Deleting a file as part of a multiple file
  546. write is not allowed. This routine is callable only from TPL_NOTIFY and
  547. below. Behavior of this routine at any EFI_TPL above TPL_NOTIFY is
  548. undefined.
  549. Arguments:
  550. This - Supplies the protocol instance.
  551. NumberOfFiles - Supplies the number of elements in the write file data
  552. array.
  553. WritePolicy - Supplies the level of reliability for the write in the event
  554. of a power failure or other system failure during the write operation.
  555. FileData - Supplies a pointer to an array of file data structures, where
  556. each element represents a file to be written.
  557. Return Value:
  558. EFI_SUCCESS on success.
  559. EFI_OUT_OF_RESOURCES if an allocation failed.
  560. EFI_NOT_FOUND if a delete was requested but the specified file was not
  561. found.
  562. EFI_DEVICE_ERROR if a hardware error occurred accessing the device.
  563. EFI_WRITE_PROTECTED if the firmware volume is configured to disallow writes.
  564. EFI_INVALID_PARAMETER if a delete was requested with multiple file writes,
  565. the write policy was unsupported, an unknown file type was specified, or a
  566. file system specific error occurred.
  567. --*/