mirror of https://github.com/acidanthera/audk.git
Searching for files starts on an 8 byte aligned boundary after the end of the Extended Header if it exists.
Signed-off-by: lzeng14 Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13143 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
6dbd32caf6
commit
f95f107c8e
|
@ -4,7 +4,7 @@
|
||||||
Layers on top of Firmware Block protocol to produce a file abstraction
|
Layers on top of Firmware Block protocol to produce a file abstraction
|
||||||
of FV based files.
|
of FV based files.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2012, 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
|
are licensed and made available under the terms and conditions
|
||||||
|
@ -194,6 +194,7 @@ FvCheck (
|
||||||
EFI_FVB_ATTRIBUTES_2 FvbAttributes;
|
EFI_FVB_ATTRIBUTES_2 FvbAttributes;
|
||||||
EFI_FV_BLOCK_MAP_ENTRY *BlockMap;
|
EFI_FV_BLOCK_MAP_ENTRY *BlockMap;
|
||||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||||
|
EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExtHeader;
|
||||||
UINT8 *FwCache;
|
UINT8 *FwCache;
|
||||||
LBA_ENTRY *LbaEntry;
|
LBA_ENTRY *LbaEntry;
|
||||||
FREE_SPACE_ENTRY *FreeSpaceEntry;
|
FREE_SPACE_ENTRY *FreeSpaceEntry;
|
||||||
|
@ -349,14 +350,23 @@ FvCheck (
|
||||||
//
|
//
|
||||||
// go through the whole FV cache, check the consistence of the FV
|
// go through the whole FV cache, check the consistence of the FV
|
||||||
//
|
//
|
||||||
Ptr = (UINT8 *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->HeaderLength);
|
if (FvDevice->FwVolHeader->ExtHeaderOffset != 0) {
|
||||||
TopFvAddress = (UINT8 *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->FvLength - 1);
|
//
|
||||||
|
// Searching for files starts on an 8 byte aligned boundary after the end of the Extended Header if it exists.
|
||||||
|
//
|
||||||
|
FwVolExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->ExtHeaderOffset);
|
||||||
|
Ptr = (UINT8 *) FwVolExtHeader + FwVolExtHeader->ExtHeaderSize;
|
||||||
|
Ptr = (UINT8 *) ALIGN_POINTER (Ptr, 8);
|
||||||
|
} else {
|
||||||
|
Ptr = (UINT8 *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->HeaderLength);
|
||||||
|
}
|
||||||
|
TopFvAddress = (UINT8 *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->FvLength);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Build FFS list & Free Space List here
|
// Build FFS list & Free Space List here
|
||||||
//
|
//
|
||||||
while (Ptr <= TopFvAddress) {
|
while (Ptr < TopFvAddress) {
|
||||||
TestLength = TopFvAddress - Ptr + 1;
|
TestLength = TopFvAddress - Ptr;
|
||||||
|
|
||||||
if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {
|
if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {
|
||||||
TestLength = sizeof (EFI_FFS_FILE_HEADER);
|
TestLength = sizeof (EFI_FFS_FILE_HEADER);
|
||||||
|
@ -370,7 +380,7 @@ FvCheck (
|
||||||
FreeSize = 0;
|
FreeSize = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
TestLength = TopFvAddress - Ptr + 1;
|
TestLength = TopFvAddress - Ptr;
|
||||||
|
|
||||||
if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {
|
if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {
|
||||||
TestLength = sizeof (EFI_FFS_FILE_HEADER);
|
TestLength = sizeof (EFI_FFS_FILE_HEADER);
|
||||||
|
@ -382,7 +392,7 @@ FvCheck (
|
||||||
|
|
||||||
FreeSize += TestLength;
|
FreeSize += TestLength;
|
||||||
Ptr += TestLength;
|
Ptr += TestLength;
|
||||||
} while (Ptr <= TopFvAddress);
|
} while (Ptr < TopFvAddress);
|
||||||
|
|
||||||
FreeSpaceEntry = AllocateZeroPool (sizeof (FREE_SPACE_ENTRY));
|
FreeSpaceEntry = AllocateZeroPool (sizeof (FREE_SPACE_ENTRY));
|
||||||
if (FreeSpaceEntry == NULL) {
|
if (FreeSpaceEntry == NULL) {
|
||||||
|
|
|
@ -294,6 +294,7 @@ FvCheck (
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
|
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
|
||||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||||
|
EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExtHeader;
|
||||||
EFI_FVB_ATTRIBUTES_2 FvbAttributes;
|
EFI_FVB_ATTRIBUTES_2 FvbAttributes;
|
||||||
EFI_FV_BLOCK_MAP_ENTRY *BlockMap;
|
EFI_FV_BLOCK_MAP_ENTRY *BlockMap;
|
||||||
FFS_FILE_LIST_ENTRY *FfsFileEntry;
|
FFS_FILE_LIST_ENTRY *FfsFileEntry;
|
||||||
|
@ -410,7 +411,7 @@ FvCheck (
|
||||||
|
|
||||||
//
|
//
|
||||||
// go through the whole FV cache, check the consistence of the FV.
|
// go through the whole FV cache, check the consistence of the FV.
|
||||||
// Make a linked list off all the Ffs file headers
|
// Make a linked list of all the Ffs file headers
|
||||||
//
|
//
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
InitializeListHead (&FvDevice->FfsFileListHeader);
|
InitializeListHead (&FvDevice->FfsFileListHeader);
|
||||||
|
@ -418,7 +419,16 @@ FvCheck (
|
||||||
//
|
//
|
||||||
// Build FFS list
|
// Build FFS list
|
||||||
//
|
//
|
||||||
FfsHeader = (EFI_FFS_FILE_HEADER *) FvDevice->CachedFv;
|
if (FwVolHeader->ExtHeaderOffset != 0) {
|
||||||
|
//
|
||||||
|
// Searching for files starts on an 8 byte aligned boundary after the end of the Extended Header if it exists.
|
||||||
|
//
|
||||||
|
FwVolExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) (FvDevice->CachedFv + (FwVolHeader->ExtHeaderOffset - FwVolHeader->HeaderLength));
|
||||||
|
FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolExtHeader + FwVolExtHeader->ExtHeaderSize);
|
||||||
|
FfsHeader = (EFI_FFS_FILE_HEADER *) ALIGN_POINTER (FfsHeader, 8);
|
||||||
|
} else {
|
||||||
|
FfsHeader = (EFI_FFS_FILE_HEADER *) (FvDevice->CachedFv);
|
||||||
|
}
|
||||||
TopFvAddress = FvDevice->EndOfCachedFv;
|
TopFvAddress = FvDevice->EndOfCachedFv;
|
||||||
while ((UINT8 *) FfsHeader < TopFvAddress) {
|
while ((UINT8 *) FfsHeader < TopFvAddress) {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Pei Core Firmware File System service routines.
|
Pei Core Firmware File System service routines.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2012, 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
|
||||||
|
@ -229,7 +229,8 @@ FindFileEx (
|
||||||
IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL
|
IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||||
|
EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExtHeader;
|
||||||
EFI_FFS_FILE_HEADER **FileHeader;
|
EFI_FFS_FILE_HEADER **FileHeader;
|
||||||
EFI_FFS_FILE_HEADER *FfsFileHeader;
|
EFI_FFS_FILE_HEADER *FfsFileHeader;
|
||||||
UINT32 FileLength;
|
UINT32 FileLength;
|
||||||
|
@ -262,7 +263,16 @@ FindFileEx (
|
||||||
// start from the FileHeader.
|
// start from the FileHeader.
|
||||||
//
|
//
|
||||||
if ((*FileHeader == NULL) || (FileName != NULL)) {
|
if ((*FileHeader == NULL) || (FileName != NULL)) {
|
||||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);
|
if (FwVolHeader->ExtHeaderOffset != 0) {
|
||||||
|
//
|
||||||
|
// Searching for files starts on an 8 byte aligned boundary after the end of the Extended Header if it exists.
|
||||||
|
//
|
||||||
|
FwVolExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->ExtHeaderOffset);
|
||||||
|
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolExtHeader + FwVolExtHeader->ExtHeaderSize);
|
||||||
|
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ALIGN_POINTER (FfsFileHeader, 8);
|
||||||
|
} else {
|
||||||
|
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (IS_FFS_FILE2 (*FileHeader)) {
|
if (IS_FFS_FILE2 (*FileHeader)) {
|
||||||
if (!IsFfs3Fv) {
|
if (!IsFfs3Fv) {
|
||||||
|
|
Loading…
Reference in New Issue