| 1397 | } |
| 1398 | |
| 1399 | EFI_STATUS |
| 1400 | PadFvImage ( |
| 1401 | IN MEMORY_FILE *FvImage, |
| 1402 | IN EFI_FFS_FILE_HEADER *VtfFileImage |
| 1403 | ) |
| 1404 | /*++ |
| 1405 | |
| 1406 | Routine Description: |
| 1407 | |
| 1408 | This function places a pad file between the last file in the FV and the VTF |
| 1409 | file if the VTF file exists. |
| 1410 | |
| 1411 | Arguments: |
| 1412 | |
| 1413 | FvImage Memory file for the FV memory image |
| 1414 | VtfFileImage The address of the VTF file. If this is the end of the FV |
| 1415 | image, no VTF exists and no pad file is needed. |
| 1416 | |
| 1417 | Returns: |
| 1418 | |
| 1419 | EFI_SUCCESS Completed successfully. |
| 1420 | EFI_INVALID_PARAMETER One of the input parameters was NULL. |
| 1421 | |
| 1422 | --*/ |
| 1423 | { |
| 1424 | EFI_FFS_FILE_HEADER *PadFile; |
| 1425 | UINTN FileSize; |
| 1426 | UINT32 FfsHeaderSize; |
| 1427 | |
| 1428 | // |
| 1429 | // If there is no VTF or the VTF naturally follows the previous file without a |
| 1430 | // pad file, then there's nothing to do |
| 1431 | // |
| 1432 | if ((UINTN) VtfFileImage == (UINTN) FvImage->Eof || \ |
| 1433 | ((UINTN) VtfFileImage == (UINTN) FvImage->CurrentFilePointer)) { |
| 1434 | return EFI_SUCCESS; |
| 1435 | } |
| 1436 | |
| 1437 | if ((UINTN) VtfFileImage < (UINTN) FvImage->CurrentFilePointer) { |
| 1438 | return EFI_INVALID_PARAMETER; |
| 1439 | } |
| 1440 | |
| 1441 | // |
| 1442 | // Pad file starts at beginning of free space |
| 1443 | // |
| 1444 | PadFile = (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer; |
| 1445 | |
| 1446 | // |
| 1447 | // write PadFile FFS header with PadType, don't need to set PAD file guid in its header. |
| 1448 | // |
| 1449 | PadFile->Type = EFI_FV_FILETYPE_FFS_PAD; |
| 1450 | PadFile->Attributes = 0; |
| 1451 | |
| 1452 | // |
| 1453 | // FileSize includes the EFI_FFS_FILE_HEADER |
| 1454 | // |
| 1455 | FileSize = (UINTN) VtfFileImage - (UINTN) FvImage->CurrentFilePointer; |
| 1456 | if (FileSize >= MAX_FFS_SIZE) { |
no test coverage detected