fwvolp.h 25 KB

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