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