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