]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDriver.h
Add core FFS3 support, FwVolDxe and SectionExtraction.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / FirmwareVolume / FwVolDxe / FwVolDriver.h
1 /** @file
2 Common defines and definitions for a FwVolDxe driver.
3
4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
5
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions
8 of the BSD License which accompanies this distribution. The
9 full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #ifndef _FWVOL_DRIVER_H_
18 #define _FWVOL_DRIVER_H_
19
20 #include <PiDxe.h>
21
22 #include <Guid/FirmwareFileSystem2.h>
23 #include <Guid/FirmwareFileSystem3.h>
24 #include <Protocol/SectionExtraction.h>
25 #include <Protocol/FaultTolerantWrite.h>
26 #include <Protocol/FirmwareVolume2.h>
27 #include <Protocol/FirmwareVolumeBlock.h>
28
29 #include <Library/DebugLib.h>
30 #include <Library/UefiDriverEntryPoint.h>
31 #include <Library/UefiLib.h>
32 #include <Library/BaseLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/MemoryAllocationLib.h>
35 #include <Library/UefiBootServicesTableLib.h>
36
37 #define FV_DEVICE_SIGNATURE SIGNATURE_32 ('_', 'F', 'V', '_')
38
39 //
40 // Define two helper macro to extract the Capability field or Status field in FVB
41 // bit fields
42 //
43 #define EFI_FVB2_CAPABILITIES (EFI_FVB2_READ_DISABLED_CAP | \
44 EFI_FVB2_READ_ENABLED_CAP | \
45 EFI_FVB2_WRITE_DISABLED_CAP | \
46 EFI_FVB2_WRITE_ENABLED_CAP | \
47 EFI_FVB2_LOCK_CAP \
48 )
49
50 #define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)
51
52 #define MAX_FILES 32
53
54 //
55 // Used to caculate from address -> Lba
56 //
57 typedef struct {
58 LIST_ENTRY Link;
59 EFI_LBA LbaIndex;
60 UINT8 *StartingAddress;
61 UINTN BlockLength;
62 } LBA_ENTRY;
63
64 //
65 // Used to track free space in the Fv
66 //
67 typedef struct {
68 LIST_ENTRY Link;
69 UINT8 *StartingAddress;
70 UINTN Length;
71 } FREE_SPACE_ENTRY;
72
73 //
74 // Used to track all non-deleted files
75 //
76 typedef struct {
77 LIST_ENTRY Link;
78 UINT8 *FfsHeader;
79 } FFS_FILE_LIST_ENTRY;
80
81 typedef struct {
82 UINTN Signature;
83 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
84 EFI_FIRMWARE_VOLUME2_PROTOCOL Fv;
85 EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
86 UINT8 *Key;
87 EFI_HANDLE Handle;
88
89 UINT8 ErasePolarity;
90 EFI_PHYSICAL_ADDRESS CachedFv;
91 LIST_ENTRY LbaHeader;
92 LIST_ENTRY FreeSpaceHeader;
93 LIST_ENTRY FfsFileListHeader;
94
95 FFS_FILE_LIST_ENTRY *CurrentFfsFile;
96 BOOLEAN IsFfs3Fv;
97 } FV_DEVICE;
98
99 #define FV_DEVICE_FROM_THIS(a) CR (a, FV_DEVICE, Fv, FV_DEVICE_SIGNATURE)
100
101 /**
102 Retrieves attributes, insures positive polarity of attribute bits, returns
103 resulting attributes in output parameter.
104
105 @param This Calling context
106 @param Attributes output buffer which contains attributes
107
108 @retval EFI_SUCCESS Successfully got volume attributes
109
110 **/
111 EFI_STATUS
112 EFIAPI
113 FvGetVolumeAttributes (
114 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
115 OUT EFI_FV_ATTRIBUTES *Attributes
116 );
117
118 /**
119 Sets current attributes for volume.
120
121 @param This Calling context
122 @param Attributes On input, FvAttributes is a pointer to
123 an EFI_FV_ATTRIBUTES containing the
124 desired firmware volume settings. On
125 successful return, it contains the new
126 settings of the firmware volume. On
127 unsuccessful return, FvAttributes is not
128 modified and the firmware volume
129 settings are not changed.
130
131 @retval EFI_SUCCESS The requested firmware volume attributes
132 were set and the resulting
133 EFI_FV_ATTRIBUTES is returned in
134 FvAttributes.
135 @retval EFI_ACCESS_DENIED Atrribute is locked down.
136 @retval EFI_INVALID_PARAMETER Atrribute is not valid.
137
138 **/
139 EFI_STATUS
140 EFIAPI
141 FvSetVolumeAttributes (
142 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
143 IN OUT EFI_FV_ATTRIBUTES *Attributes
144 );
145
146 /**
147 Given the input key, search for the next matching file in the volume.
148
149 @param This Indicates the calling context.
150 @param Key Key is a pointer to a caller allocated
151 buffer that contains implementation specific
152 data that is used to track where to begin
153 the search for the next file. The size of
154 the buffer must be at least This->KeySize
155 bytes long. To reinitialize the search and
156 begin from the beginning of the firmware
157 volume, the entire buffer must be cleared to
158 zero. Other than clearing the buffer to
159 initiate a new search, the caller must not
160 modify the data in the buffer between calls
161 to GetNextFile().
162 @param FileType FileType is a pointer to a caller allocated
163 EFI_FV_FILETYPE. The GetNextFile() API can
164 filter it's search for files based on the
165 value of *FileType input. A *FileType input
166 of 0 causes GetNextFile() to search for
167 files of all types. If a file is found, the
168 file's type is returned in *FileType.
169 *FileType is not modified if no file is
170 found.
171 @param NameGuid NameGuid is a pointer to a caller allocated
172 EFI_GUID. If a file is found, the file's
173 name is returned in *NameGuid. *NameGuid is
174 not modified if no file is found.
175 @param Attributes Attributes is a pointer to a caller
176 allocated EFI_FV_FILE_ATTRIBUTES. If a file
177 is found, the file's attributes are returned
178 in *Attributes. *Attributes is not modified
179 if no file is found.
180 @param Size Size is a pointer to a caller allocated
181 UINTN. If a file is found, the file's size
182 is returned in *Size. *Size is not modified
183 if no file is found.
184
185 @retval EFI_SUCCESS Successfully find the file.
186 @retval EFI_DEVICE_ERROR Device error.
187 @retval EFI_ACCESS_DENIED Fv could not read.
188 @retval EFI_NOT_FOUND No matching file found.
189 @retval EFI_INVALID_PARAMETER Invalid parameter
190
191 **/
192 EFI_STATUS
193 EFIAPI
194 FvGetNextFile (
195 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
196 IN OUT VOID *Key,
197 IN OUT EFI_FV_FILETYPE *FileType,
198 OUT EFI_GUID *NameGuid,
199 OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
200 OUT UINTN *Size
201 );
202
203 /**
204 Locates a file in the firmware volume and
205 copies it to the supplied buffer.
206
207 @param This Indicates the calling context.
208 @param NameGuid Pointer to an EFI_GUID, which is the
209 filename.
210 @param Buffer Buffer is a pointer to pointer to a buffer
211 in which the file or section contents or are
212 returned.
213 @param BufferSize BufferSize is a pointer to caller allocated
214 UINTN. On input *BufferSize indicates the
215 size in bytes of the memory region pointed
216 to by Buffer. On output, *BufferSize
217 contains the number of bytes required to
218 read the file.
219 @param FoundType FoundType is a pointer to a caller allocated
220 EFI_FV_FILETYPE that on successful return
221 from Read() contains the type of file read.
222 This output reflects the file type
223 irrespective of the value of the SectionType
224 input.
225 @param FileAttributes FileAttributes is a pointer to a caller
226 allocated EFI_FV_FILE_ATTRIBUTES. On
227 successful return from Read(),
228 *FileAttributes contains the attributes of
229 the file read.
230 @param AuthenticationStatus AuthenticationStatus is a pointer to a
231 caller allocated UINTN in which the
232 authentication status is returned.
233
234 @retval EFI_SUCCESS Successfully read to memory buffer.
235 @retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.
236 @retval EFI_NOT_FOUND Not found.
237 @retval EFI_DEVICE_ERROR Device error.
238 @retval EFI_ACCESS_DENIED Could not read.
239 @retval EFI_INVALID_PARAMETER Invalid parameter.
240 @retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.
241
242 **/
243 EFI_STATUS
244 EFIAPI
245 FvReadFile (
246 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
247 IN CONST EFI_GUID *NameGuid,
248 IN OUT VOID **Buffer,
249 IN OUT UINTN *BufferSize,
250 OUT EFI_FV_FILETYPE *FoundType,
251 OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
252 OUT UINT32 *AuthenticationStatus
253 );
254
255 /**
256 Locates a section in a given FFS File and
257 copies it to the supplied buffer (not including section header).
258
259 @param This Indicates the calling context.
260 @param NameGuid Pointer to an EFI_GUID, which is the
261 filename.
262 @param SectionType Indicates the section type to return.
263 @param SectionInstance Indicates which instance of sections with a
264 type of SectionType to return.
265 @param Buffer Buffer is a pointer to pointer to a buffer
266 in which the file or section contents or are
267 returned.
268 @param BufferSize BufferSize is a pointer to caller allocated
269 UINTN.
270 @param AuthenticationStatus AuthenticationStatus is a pointer to a
271 caller allocated UINT32 in which the
272 authentication status is returned.
273
274 @retval EFI_SUCCESS Successfully read the file section into
275 buffer.
276 @retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small.
277 @retval EFI_NOT_FOUND Section not found.
278 @retval EFI_DEVICE_ERROR Device error.
279 @retval EFI_ACCESS_DENIED Could not read.
280 @retval EFI_INVALID_PARAMETER Invalid parameter.
281
282 **/
283 EFI_STATUS
284 EFIAPI
285 FvReadFileSection (
286 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
287 IN CONST EFI_GUID *NameGuid,
288 IN EFI_SECTION_TYPE SectionType,
289 IN UINTN SectionInstance,
290 IN OUT VOID **Buffer,
291 IN OUT UINTN *BufferSize,
292 OUT UINT32 *AuthenticationStatus
293 );
294
295 /**
296 Writes one or more files to the firmware volume.
297
298 @param This Indicates the calling context.
299 @param NumberOfFiles Number of files.
300 @param WritePolicy WritePolicy indicates the level of reliability
301 for the write in the event of a power failure or
302 other system failure during the write operation.
303 @param FileData FileData is an pointer to an array of
304 EFI_FV_WRITE_DATA. Each element of array
305 FileData represents a file to be written.
306
307 @retval EFI_SUCCESS Files successfully written to firmware volume
308 @retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated.
309 @retval EFI_DEVICE_ERROR Device error.
310 @retval EFI_WRITE_PROTECTED Write protected.
311 @retval EFI_NOT_FOUND Not found.
312 @retval EFI_INVALID_PARAMETER Invalid parameter.
313 @retval EFI_UNSUPPORTED This function not supported.
314
315 **/
316 EFI_STATUS
317 EFIAPI
318 FvWriteFile (
319 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
320 IN UINT32 NumberOfFiles,
321 IN EFI_FV_WRITE_POLICY WritePolicy,
322 IN EFI_FV_WRITE_FILE_DATA *FileData
323 );
324
325 /**
326 Return information of type InformationType for the requested firmware
327 volume.
328
329 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
330 @param InformationType InformationType for requested.
331 @param BufferSize On input, size of Buffer.On output, the amount of
332 data returned in Buffer.
333 @param Buffer A poniter to the data buffer to return.
334
335 @return EFI_UNSUPPORTED Could not get.
336
337 **/
338 EFI_STATUS
339 EFIAPI
340 FvGetVolumeInfo (
341 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
342 IN CONST EFI_GUID *InformationType,
343 IN OUT UINTN *BufferSize,
344 OUT VOID *Buffer
345 );
346
347
348 /**
349 Set information with InformationType into the requested firmware volume.
350
351 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
352 @param InformationType InformationType for requested.
353 @param BufferSize Size of Buffer data.
354 @param Buffer A poniter to the data buffer to be set.
355
356 @retval EFI_UNSUPPORTED Could not set.
357
358 **/
359 EFI_STATUS
360 EFIAPI
361 FvSetVolumeInfo (
362 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
363 IN CONST EFI_GUID *InformationType,
364 IN UINTN BufferSize,
365 IN CONST VOID *Buffer
366 );
367
368 /**
369 Writes data beginning at Lba:Offset from FV. The write terminates either
370 when *NumBytes of data have been written, or when the firmware end is
371 reached. *NumBytes is updated to reflect the actual number of bytes
372 written.
373
374 @param FvDevice Cached Firmware Volume
375 @param Offset Offset in the block at which to begin write
376 @param NumBytes At input, indicates the requested write size.
377 At output, indicates the actual number of bytes written.
378 @param Buffer Buffer containing source data for the write.
379
380 @retval EFI_SUCCESS Data is successfully written into FV.
381 @return error Data is failed written.
382
383 **/
384 EFI_STATUS
385 FvcWrite (
386 IN FV_DEVICE *FvDevice,
387 IN UINTN Offset,
388 IN OUT UINTN *NumBytes,
389 IN UINT8 *Buffer
390 );
391
392
393 /**
394 Check if a block of buffer is erased.
395
396 @param ErasePolarity Erase polarity attribute of the firmware volume
397 @param Buffer The buffer to be checked
398 @param BufferSize Size of the buffer in bytes
399
400 @retval TRUE The block of buffer is erased
401 @retval FALSE The block of buffer is not erased
402
403 **/
404 BOOLEAN
405 IsBufferErased (
406 IN UINT8 ErasePolarity,
407 IN UINT8 *Buffer,
408 IN UINTN BufferSize
409 );
410
411 /**
412 Get the FFS file state by checking the highest bit set in the header's state field.
413
414 @param ErasePolarity Erase polarity attribute of the firmware volume
415 @param FfsHeader Points to the FFS file header
416
417 @return FFS File state
418
419 **/
420 EFI_FFS_FILE_STATE
421 GetFileState (
422 IN UINT8 ErasePolarity,
423 IN EFI_FFS_FILE_HEADER *FfsHeader
424 );
425
426 /**
427 Verify checksum of the firmware volume header.
428
429 @param FvHeader Points to the firmware volume header to be checked
430
431 @retval TRUE Checksum verification passed
432 @retval FALSE Checksum verification failed
433
434 **/
435 BOOLEAN
436 VerifyFvHeaderChecksum (
437 IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader
438 );
439
440 /**
441 Check if it's a valid FFS file header.
442
443 @param ErasePolarity Erase polarity attribute of the firmware volume
444 @param FfsHeader Points to the FFS file header to be checked
445
446 @retval TRUE Valid FFS file header
447 @retval FALSE Invalid FFS file header
448
449 **/
450 BOOLEAN
451 IsValidFFSHeader (
452 IN UINT8 ErasePolarity,
453 IN EFI_FFS_FILE_HEADER *FfsHeader
454 );
455
456 /**
457 Check if it's a valid FFS file.
458 Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.
459
460 @param FvDevice Cached FV image.
461 @param FfsHeader Points to the FFS file to be checked
462
463 @retval TRUE Valid FFS file
464 @retval FALSE Invalid FFS file
465
466 **/
467 BOOLEAN
468 IsValidFFSFile (
469 IN FV_DEVICE *FvDevice,
470 IN EFI_FFS_FILE_HEADER *FfsHeader
471 );
472
473 /**
474 Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
475 copy the real length volume header into it.
476
477 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to
478 read the volume header
479 @param FwVolHeader Pointer to pointer to allocated buffer in which
480 the volume header is returned.
481
482 @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
483 @retval EFI_SUCCESS Successfully read volume header to the allocated
484 buffer.
485 @retval EFI_ACCESS_DENIED Read status of FV is not enabled.
486 **/
487 EFI_STATUS
488 GetFwVolHeader (
489 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,
490 OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
491 );
492
493 /**
494 Convert the Buffer Address to LBA Entry Address.
495
496 @param FvDevice Cached FvDevice
497 @param BufferAddress Address of Buffer
498 @param LbaListEntry Pointer to the got LBA entry that contains the address.
499
500 @retval EFI_NOT_FOUND Buffer address is out of FvDevice.
501 @retval EFI_SUCCESS LBA entry is found for Buffer address.
502
503 **/
504 EFI_STATUS
505 Buffer2LbaEntry (
506 IN FV_DEVICE *FvDevice,
507 IN EFI_PHYSICAL_ADDRESS BufferAddress,
508 OUT LBA_ENTRY **LbaListEntry
509 );
510
511 /**
512 Convert the Buffer Address to LBA Address & Offset.
513
514 @param FvDevice Cached FvDevice
515 @param BufferAddress Address of Buffer
516 @param Lba Pointer to the gob Lba value
517 @param Offset Pointer to the got Offset
518
519 @retval EFI_NOT_FOUND Buffer address is out of FvDevice.
520 @retval EFI_SUCCESS LBA and Offset is found for Buffer address.
521
522 **/
523 EFI_STATUS
524 Buffer2Lba (
525 IN FV_DEVICE *FvDevice,
526 IN EFI_PHYSICAL_ADDRESS BufferAddress,
527 OUT EFI_LBA *Lba,
528 OUT UINTN *Offset
529 );
530
531 /**
532 Set File State in the FfsHeader.
533
534 @param State File state to be set into FFS header.
535 @param FfsHeader Points to the FFS file header
536
537 **/
538 VOID
539 SetFileState (
540 IN UINT8 State,
541 IN EFI_FFS_FILE_HEADER *FfsHeader
542 );
543
544 /**
545 Create a PAD File in the Free Space.
546
547 @param FvDevice Firmware Volume Device.
548 @param FreeSpaceEntry Indicating in which Free Space(Cache) the Pad file will be inserted.
549 @param Size Pad file Size, not include the header.
550 @param PadFileEntry The Ffs File Entry that points to this Pad File.
551
552 @retval EFI_SUCCESS Successfully create a PAD file.
553 @retval EFI_OUT_OF_RESOURCES No enough free space to create a PAD file.
554 @retval EFI_INVALID_PARAMETER Size is not 8 byte alignment.
555 @retval EFI_DEVICE_ERROR Free space is not erased.
556 **/
557 EFI_STATUS
558 FvCreatePadFileInFreeSpace (
559 IN FV_DEVICE *FvDevice,
560 IN FREE_SPACE_ENTRY *FreeSpaceEntry,
561 IN UINTN Size,
562 OUT FFS_FILE_LIST_ENTRY **PadFileEntry
563 );
564
565 /**
566 Create a new file within a PAD file area.
567
568 @param FvDevice Firmware Volume Device.
569 @param FfsFileBuffer A buffer that holds an FFS file,(it contains a File Header which is in init state).
570 @param BufferSize The size of FfsFileBuffer.
571 @param ActualFileSize The actual file length, it may not be multiples of 8.
572 @param FileName The FFS File Name.
573 @param FileType The FFS File Type.
574 @param FileAttributes The Attributes of the FFS File to be created.
575
576 @retval EFI_SUCCESS Successfully create a new file within the found PAD file area.
577 @retval EFI_OUT_OF_RESOURCES No suitable PAD file is found.
578 @retval other errors New file is created failed.
579
580 **/
581 EFI_STATUS
582 FvCreateNewFileInsidePadFile (
583 IN FV_DEVICE *FvDevice,
584 IN UINT8 *FfsFileBuffer,
585 IN UINTN BufferSize,
586 IN UINTN ActualFileSize,
587 IN EFI_GUID *FileName,
588 IN EFI_FV_FILETYPE FileType,
589 IN EFI_FV_FILE_ATTRIBUTES FileAttributes
590 );
591
592 /**
593 Write multiple files into FV in reliable method.
594
595 @param FvDevice Firmware Volume Device.
596 @param NumOfFiles Total File number to be written.
597 @param FileData The array of EFI_FV_WRITE_FILE_DATA structure,
598 used to get name, attributes, type, etc
599 @param FileOperation The array of operation for each file.
600
601 @retval EFI_SUCCESS Files are added into FV.
602 @retval EFI_OUT_OF_RESOURCES No enough free PAD files to add the input files.
603 @retval EFI_INVALID_PARAMETER File number is less than or equal to 1.
604 @retval EFI_UNSUPPORTED File number exceeds the supported max numbers of files.
605
606 **/
607 EFI_STATUS
608 FvCreateMultipleFiles (
609 IN FV_DEVICE *FvDevice,
610 IN UINTN NumOfFiles,
611 IN EFI_FV_WRITE_FILE_DATA *FileData,
612 IN BOOLEAN *FileOperation
613 );
614
615 /**
616 Caculate the checksum for the FFS header.
617
618 @param FfsHeader FFS File Header which needs to caculate the checksum
619
620 **/
621 VOID
622 SetHeaderChecksum (
623 IN EFI_FFS_FILE_HEADER *FfsHeader
624 );
625
626 /**
627 Caculate the checksum for the FFS File.
628
629 @param FfsHeader FFS File Header which needs to caculate the checksum
630 @param ActualFileSize The whole Ffs File Length.
631
632 **/
633 VOID
634 SetFileChecksum (
635 IN EFI_FFS_FILE_HEADER *FfsHeader,
636 IN UINTN ActualFileSize
637 );
638
639 /**
640 Get the alignment value from File Attributes.
641
642 @param FfsAttributes FFS attribute
643
644 @return Alignment value.
645
646 **/
647 UINTN
648 GetRequiredAlignment (
649 IN EFI_FV_FILE_ATTRIBUTES FfsAttributes
650 );
651
652 /**
653 Locate Pad File for writing, this is got from FV Cache.
654
655 @param FvDevice Cached Firmware Volume.
656 @param Size The required FFS file size.
657 @param RequiredAlignment FFS File Data alignment requirement.
658 @param PadSize Pointer to the size of leading Pad File.
659 @param PadFileEntry Pointer to the Pad File Entry that meets the requirement.
660
661 @retval EFI_SUCCESS The required pad file is found.
662 @retval EFI_NOT_FOUND The required pad file can't be found.
663
664 **/
665 EFI_STATUS
666 FvLocatePadFile (
667 IN FV_DEVICE *FvDevice,
668 IN UINTN Size,
669 IN UINTN RequiredAlignment,
670 OUT UINTN *PadSize,
671 OUT FFS_FILE_LIST_ENTRY **PadFileEntry
672 );
673
674 /**
675 Locate a suitable pad file for multiple file writing.
676
677 @param FvDevice Cached Firmware Volume.
678 @param NumOfFiles The number of Files that needed updating
679 @param BufferSize The array of each file size.
680 @param RequiredAlignment The array of of FFS File Data alignment requirement.
681 @param PadSize The array of size of each leading Pad File.
682 @param TotalSizeNeeded The totalsize that can hold these files.
683 @param PadFileEntry Pointer to the Pad File Entry that meets the requirement.
684
685 @retval EFI_SUCCESS The required pad file is found.
686 @retval EFI_NOT_FOUND The required pad file can't be found.
687
688 **/
689 EFI_STATUS
690 FvSearchSuitablePadFile (
691 IN FV_DEVICE *FvDevice,
692 IN UINTN NumOfFiles,
693 IN UINTN *BufferSize,
694 IN UINTN *RequiredAlignment,
695 OUT UINTN *PadSize,
696 OUT UINTN *TotalSizeNeeded,
697 OUT FFS_FILE_LIST_ENTRY **PadFileEntry
698 );
699
700 /**
701 Locate a Free Space entry which can hold these files, including
702 meeting the alignment requirements.
703
704 @param FvDevice Cached Firmware Volume.
705 @param NumOfFiles The number of Files that needed updating
706 @param BufferSize The array of each file size.
707 @param RequiredAlignment The array of of FFS File Data alignment requirement.
708 @param PadSize The array of size of each leading Pad File.
709 @param TotalSizeNeeded The got total size that can hold these files.
710 @param FreeSpaceEntry The Free Space Entry that can hold these files.
711
712 @retval EFI_SUCCESS The free space entry is found.
713 @retval EFI_NOT_FOUND The free space entry can't be found.
714
715 **/
716 EFI_STATUS
717 FvSearchSuitableFreeSpace (
718 IN FV_DEVICE *FvDevice,
719 IN UINTN NumOfFiles,
720 IN UINTN *BufferSize,
721 IN UINTN *RequiredAlignment,
722 OUT UINTN *PadSize,
723 OUT UINTN *TotalSizeNeeded,
724 OUT FREE_SPACE_ENTRY **FreeSpaceEntry
725 );
726
727 /**
728 Change FFS file header state and write to FV.
729
730 @param FvDevice Cached FV image.
731 @param FfsHeader Points to the FFS file header to be updated.
732 @param State FFS file state to be set.
733
734 @retval EFI_SUCCESS File state is writen into FV.
735 @retval others File state can't be writen into FV.
736
737 **/
738 EFI_STATUS
739 UpdateHeaderBit (
740 IN FV_DEVICE *FvDevice,
741 IN EFI_FFS_FILE_HEADER *FfsHeader,
742 IN EFI_FFS_FILE_STATE State
743 );
744
745 /**
746 Convert EFI_FV_FILE_ATTRIBUTES to FFS_FILE_ATTRIBUTES.
747
748 @param FvFileAttrib The value of EFI_FV_FILE_ATTRIBUTES
749 @param FfsFileAttrib Pointer to the got FFS_FILE_ATTRIBUTES value.
750
751 **/
752 VOID
753 FvFileAttrib2FfsFileAttrib (
754 IN EFI_FV_FILE_ATTRIBUTES FvFileAttrib,
755 OUT UINT8 *FfsFileAttrib
756 );
757
758 #endif