Changeset 77662 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/PeiHobLib/HobLib.c
- Timestamp:
- Mar 12, 2019 12:40:12 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 129295
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776 /vendor/edk2/current 103735-103757,103769-103776,129194-129237
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/PeiHobLib/HobLib.c
r58466 r77662 2 2 Provide Hob Library functions for Pei phase. 3 3 4 Copyright (c) 2007 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 475 475 476 476 /** 477 Check FV alignment. 478 479 @param BaseAddress The base address of the Firmware Volume. 480 @param Length The size of the Firmware Volume in bytes. 481 482 @retval TRUE FvImage buffer is at its required alignment. 483 @retval FALSE FvImage buffer is not at its required alignment. 484 485 **/ 486 BOOLEAN 487 InternalCheckFvAlignment ( 488 IN EFI_PHYSICAL_ADDRESS BaseAddress, 489 IN UINT64 Length 490 ) 491 { 492 EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; 493 UINT32 FvAlignment; 494 495 FvAlignment = 0; 496 FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress; 497 498 // 499 // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume 500 // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from 501 // its initial linked location and maintain its alignment. 502 // 503 if ((FwVolHeader->Attributes & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) { 504 // 505 // Get FvHeader alignment 506 // 507 FvAlignment = 1 << ((FwVolHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16); 508 // 509 // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value. 510 // 511 if (FvAlignment < 8) { 512 FvAlignment = 8; 513 } 514 if ((UINTN)BaseAddress % FvAlignment != 0) { 515 // 516 // FvImage buffer is not at its required alignment. 517 // 518 DEBUG (( 519 DEBUG_ERROR, 520 "Unaligned FvImage found at 0x%lx:0x%lx, the required alignment is 0x%x\n", 521 BaseAddress, 522 Length, 523 FvAlignment 524 )); 525 return FALSE; 526 } 527 } 528 529 return TRUE; 530 } 531 532 /** 477 533 Builds a Firmware Volume HOB. 478 534 … … 482 538 483 539 If there is no additional space for HOB creation, then ASSERT(). 540 If the FvImage buffer is not at its required alignment, then ASSERT(). 484 541 485 542 @param BaseAddress The base address of the Firmware Volume. … … 496 553 EFI_HOB_FIRMWARE_VOLUME *Hob; 497 554 555 if (!InternalCheckFvAlignment (BaseAddress, Length)) { 556 ASSERT (FALSE); 557 return; 558 } 559 498 560 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME)); 499 561 if (Hob == NULL) { … … 513 575 514 576 If there is no additional space for HOB creation, then ASSERT(). 577 If the FvImage buffer is not at its required alignment, then ASSERT(). 515 578 516 579 @param BaseAddress The base address of the Firmware Volume. … … 531 594 EFI_HOB_FIRMWARE_VOLUME2 *Hob; 532 595 596 if (!InternalCheckFvAlignment (BaseAddress, Length)) { 597 ASSERT (FALSE); 598 return; 599 } 600 533 601 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV2, (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME2)); 534 602 if (Hob == NULL) { … … 543 611 544 612 /** 613 Builds a EFI_HOB_TYPE_FV3 HOB. 614 615 This function builds a EFI_HOB_TYPE_FV3 HOB. 616 It can only be invoked during PEI phase; 617 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. 618 619 If there is no additional space for HOB creation, then ASSERT(). 620 If the FvImage buffer is not at its required alignment, then ASSERT(). 621 622 @param BaseAddress The base address of the Firmware Volume. 623 @param Length The size of the Firmware Volume in bytes. 624 @param AuthenticationStatus The authentication status. 625 @param ExtractedFv TRUE if the FV was extracted as a file within 626 another firmware volume. FALSE otherwise. 627 @param FvName The name of the Firmware Volume. 628 Valid only if IsExtractedFv is TRUE. 629 @param FileName The name of the file. 630 Valid only if IsExtractedFv is TRUE. 631 632 **/ 633 VOID 634 EFIAPI 635 BuildFv3Hob ( 636 IN EFI_PHYSICAL_ADDRESS BaseAddress, 637 IN UINT64 Length, 638 IN UINT32 AuthenticationStatus, 639 IN BOOLEAN ExtractedFv, 640 IN CONST EFI_GUID *FvName, OPTIONAL 641 IN CONST EFI_GUID *FileName OPTIONAL 642 ) 643 { 644 EFI_HOB_FIRMWARE_VOLUME3 *Hob; 645 646 if (!InternalCheckFvAlignment (BaseAddress, Length)) { 647 ASSERT (FALSE); 648 return; 649 } 650 651 Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV3, (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME3)); 652 if (Hob == NULL) { 653 return; 654 } 655 656 Hob->BaseAddress = BaseAddress; 657 Hob->Length = Length; 658 Hob->AuthenticationStatus = AuthenticationStatus; 659 Hob->ExtractedFv = ExtractedFv; 660 if (ExtractedFv) { 661 CopyGuid (&Hob->FvName, FvName); 662 CopyGuid (&Hob->FileName, FileName); 663 } 664 } 665 666 /** 545 667 Builds a Capsule Volume HOB. 546 668
Note:
See TracChangeset
for help on using the changeset viewer.