Layers on top of Firmware Block protocol to produce a file abstraction\r
of FV based files.\r
\r
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions\r
EFI_FVB_ATTRIBUTES_2 FvbAttributes;\r
EFI_FV_BLOCK_MAP_ENTRY *BlockMap;\r
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
+ EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExtHeader;\r
UINT8 *FwCache;\r
LBA_ENTRY *LbaEntry;\r
FREE_SPACE_ENTRY *FreeSpaceEntry;\r
//\r
// go through the whole FV cache, check the consistence of the FV\r
//\r
- Ptr = (UINT8 *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->HeaderLength);\r
- TopFvAddress = (UINT8 *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->FvLength - 1);\r
+ if (FvDevice->FwVolHeader->ExtHeaderOffset != 0) {\r
+ //\r
+ // Searching for files starts on an 8 byte aligned boundary after the end of the Extended Header if it exists.\r
+ //\r
+ FwVolExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->ExtHeaderOffset);\r
+ Ptr = (UINT8 *) FwVolExtHeader + FwVolExtHeader->ExtHeaderSize;\r
+ Ptr = (UINT8 *) ALIGN_POINTER (Ptr, 8);\r
+ } else {\r
+ Ptr = (UINT8 *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->HeaderLength);\r
+ }\r
+ TopFvAddress = (UINT8 *) (UINTN) (FvDevice->CachedFv + FvDevice->FwVolHeader->FvLength);\r
\r
//\r
// Build FFS list & Free Space List here\r
//\r
- while (Ptr <= TopFvAddress) {\r
- TestLength = TopFvAddress - Ptr + 1;\r
+ while (Ptr < TopFvAddress) {\r
+ TestLength = TopFvAddress - Ptr;\r
\r
if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {\r
TestLength = sizeof (EFI_FFS_FILE_HEADER);\r
FreeSize = 0;\r
\r
do {\r
- TestLength = TopFvAddress - Ptr + 1;\r
+ TestLength = TopFvAddress - Ptr;\r
\r
if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {\r
TestLength = sizeof (EFI_FFS_FILE_HEADER);\r
\r
FreeSize += TestLength;\r
Ptr += TestLength;\r
- } while (Ptr <= TopFvAddress);\r
+ } while (Ptr < TopFvAddress);\r
\r
FreeSpaceEntry = AllocateZeroPool (sizeof (FREE_SPACE_ENTRY));\r
if (FreeSpaceEntry == NULL) {\r
EFI_STATUS Status;\r
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;\r
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
+ EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExtHeader;\r
EFI_FVB_ATTRIBUTES_2 FvbAttributes;\r
EFI_FV_BLOCK_MAP_ENTRY *BlockMap;\r
FFS_FILE_LIST_ENTRY *FfsFileEntry;\r
\r
//\r
// go through the whole FV cache, check the consistence of the FV.\r
- // Make a linked list off all the Ffs file headers\r
+ // Make a linked list of all the Ffs file headers\r
//\r
Status = EFI_SUCCESS;\r
InitializeListHead (&FvDevice->FfsFileListHeader);\r
//\r
// Build FFS list\r
//\r
- FfsHeader = (EFI_FFS_FILE_HEADER *) FvDevice->CachedFv;\r
+ if (FwVolHeader->ExtHeaderOffset != 0) {\r
+ //\r
+ // Searching for files starts on an 8 byte aligned boundary after the end of the Extended Header if it exists.\r
+ //\r
+ FwVolExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) (FvDevice->CachedFv + (FwVolHeader->ExtHeaderOffset - FwVolHeader->HeaderLength));\r
+ FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolExtHeader + FwVolExtHeader->ExtHeaderSize);\r
+ FfsHeader = (EFI_FFS_FILE_HEADER *) ALIGN_POINTER (FfsHeader, 8);\r
+ } else {\r
+ FfsHeader = (EFI_FFS_FILE_HEADER *) (FvDevice->CachedFv);\r
+ }\r
TopFvAddress = FvDevice->EndOfCachedFv;\r
while ((UINT8 *) FfsHeader < TopFvAddress) {\r
\r
/** @file\r
Pei Core Firmware File System service routines.\r
\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials \r
are licensed and made available under the terms and conditions of the BSD License \r
which accompanies this distribution. The full text of the license may be found at \r
IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL\r
)\r
{\r
- EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
+ EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExtHeader;\r
EFI_FFS_FILE_HEADER **FileHeader;\r
EFI_FFS_FILE_HEADER *FfsFileHeader;\r
UINT32 FileLength;\r
// start from the FileHeader.\r
//\r
if ((*FileHeader == NULL) || (FileName != NULL)) {\r
- FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);\r
+ if (FwVolHeader->ExtHeaderOffset != 0) {\r
+ //\r
+ // Searching for files starts on an 8 byte aligned boundary after the end of the Extended Header if it exists.\r
+ //\r
+ FwVolExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->ExtHeaderOffset);\r
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolExtHeader + FwVolExtHeader->ExtHeaderSize);\r
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *) ALIGN_POINTER (FfsFileHeader, 8);\r
+ } else {\r
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength);\r
+ }\r
} else {\r
if (IS_FFS_FILE2 (*FileHeader)) {\r
if (!IsFfs3Fv) {\r