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