mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 15:44:04 +02:00
MdeModulePkg: Add support for weakly aligned FVs.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14671 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
82ea59a012
commit
3837e91c58
@ -1035,6 +1035,12 @@ CoreProcessFvImageFile (
|
|||||||
// FvImage should be at its required alignment.
|
// FvImage should be at its required alignment.
|
||||||
//
|
//
|
||||||
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;
|
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;
|
||||||
|
//
|
||||||
|
// If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
|
||||||
|
// can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
|
||||||
|
// its initial linked location and maintain its alignment.
|
||||||
|
//
|
||||||
|
if ((FvHeader->Attributes & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
|
||||||
//
|
//
|
||||||
// Get FvHeader alignment
|
// Get FvHeader alignment
|
||||||
//
|
//
|
||||||
@ -1050,26 +1056,29 @@ CoreProcessFvImageFile (
|
|||||||
//
|
//
|
||||||
AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);
|
AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);
|
||||||
if (AlignedBuffer == NULL) {
|
if (AlignedBuffer == NULL) {
|
||||||
Status = EFI_OUT_OF_RESOURCES;
|
FreePool (Buffer);
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// Move FvImage into the aligned buffer and release the original buffer.
|
// Move FvImage into the aligned buffer and release the original buffer.
|
||||||
//
|
//
|
||||||
CopyMem (AlignedBuffer, Buffer, BufferSize);
|
CopyMem (AlignedBuffer, Buffer, BufferSize);
|
||||||
|
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;
|
||||||
CoreFreePool (Buffer);
|
CoreFreePool (Buffer);
|
||||||
Buffer = NULL;
|
Buffer = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Produce a FVB protocol for the file
|
// Produce a FVB protocol for the file
|
||||||
//
|
//
|
||||||
Status = ProduceFVBProtocolOnBuffer (
|
Status = ProduceFVBProtocolOnBuffer (
|
||||||
(EFI_PHYSICAL_ADDRESS) (UINTN) AlignedBuffer,
|
(EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
|
||||||
(UINT64)BufferSize,
|
(UINT64)BufferSize,
|
||||||
FvHandle,
|
FvHandle,
|
||||||
AuthenticationStatus,
|
AuthenticationStatus,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
|
@ -474,6 +474,13 @@ ProduceFVBProtocolOnBuffer (
|
|||||||
if (FwVolHeader->Signature != EFI_FVH_SIGNATURE) {
|
if (FwVolHeader->Signature != EFI_FVH_SIGNATURE) {
|
||||||
return EFI_VOLUME_CORRUPTED;
|
return EFI_VOLUME_CORRUPTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
|
||||||
|
// can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
|
||||||
|
// its initial linked location and maintain its alignment.
|
||||||
|
//
|
||||||
|
if ((FwVolHeader->Attributes & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
|
||||||
//
|
//
|
||||||
// Get FvHeader alignment
|
// Get FvHeader alignment
|
||||||
//
|
//
|
||||||
@ -490,6 +497,8 @@ ProduceFVBProtocolOnBuffer (
|
|||||||
//
|
//
|
||||||
return EFI_VOLUME_CORRUPTED;
|
return EFI_VOLUME_CORRUPTED;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Allocate EFI_FW_VOL_BLOCK_DEVICE
|
// Allocate EFI_FW_VOL_BLOCK_DEVICE
|
||||||
//
|
//
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Pei Core Firmware File System service routines.
|
Pei Core Firmware File System service routines.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -226,7 +226,7 @@ FindFileEx (
|
|||||||
IN CONST EFI_GUID *FileName, OPTIONAL
|
IN CONST EFI_GUID *FileName, OPTIONAL
|
||||||
IN EFI_FV_FILETYPE SearchType,
|
IN EFI_FV_FILETYPE SearchType,
|
||||||
IN OUT EFI_PEI_FILE_HANDLE *FileHandle,
|
IN OUT EFI_PEI_FILE_HANDLE *FileHandle,
|
||||||
IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL
|
IN OUT EFI_PEI_FILE_HANDLE *AprioriFile OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||||
@ -1112,7 +1112,13 @@ ProcessFvFile (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// FvAlignment must be more than 8 bytes required by FvHeader structure.
|
// If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
|
||||||
|
// can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
|
||||||
|
// its initial linked location and maintain its alignment.
|
||||||
|
//
|
||||||
|
if ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
|
||||||
|
//
|
||||||
|
// FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.
|
||||||
//
|
//
|
||||||
FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ALIGNMENT) >> 16);
|
FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ALIGNMENT) >> 16);
|
||||||
if (FvAlignment < 8) {
|
if (FvAlignment < 8) {
|
||||||
@ -1131,6 +1137,7 @@ ProcessFvFile (
|
|||||||
CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);
|
CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);
|
||||||
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;
|
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Status = ParentFvPpi->GetVolumeInfo (ParentFvPpi, ParentFvHandle, &ParentFvImageInfo);
|
Status = ParentFvPpi->GetVolumeInfo (ParentFvPpi, ParentFvHandle, &ParentFvImageInfo);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
The firmware volume related definitions in PI.
|
The firmware volume related definitions in PI.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -11,7 +11,7 @@
|
|||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
@par Revision Reference:
|
@par Revision Reference:
|
||||||
PI Version 1.2C
|
PI Version 1.3
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ typedef UINT32 EFI_FVB_ATTRIBUTES_2;
|
|||||||
#define EFI_FVB2_ALIGNMENT_512M 0x001D0000
|
#define EFI_FVB2_ALIGNMENT_512M 0x001D0000
|
||||||
#define EFI_FVB2_ALIGNMENT_1G 0x001E0000
|
#define EFI_FVB2_ALIGNMENT_1G 0x001E0000
|
||||||
#define EFI_FVB2_ALIGNMENT_2G 0x001F0000
|
#define EFI_FVB2_ALIGNMENT_2G 0x001F0000
|
||||||
|
#define EFI_FVB2_WEAK_ALIGNMENT 0x80000000
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user