diff options
Diffstat (limited to 'MdeModulePkg/Core/Dxe/FwVol')
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/Ffs.c | 14 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/FwVol.c | 40 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h | 3 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c | 25 |
4 files changed, 56 insertions, 26 deletions
diff --git a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c index 2bd4405..20dade1 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c +++ b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c @@ -133,7 +133,11 @@ VerifyHeaderChecksum ( {
UINT8 HeaderChecksum;
- HeaderChecksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER));
+ if (IS_FFS_FILE2 (FfsHeader)) {
+ HeaderChecksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER2));
+ } else {
+ HeaderChecksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER));
+ }
HeaderChecksum = (UINT8) (HeaderChecksum - FfsHeader->State - FfsHeader->IntegrityCheck.Checksum.File);
if (HeaderChecksum == 0) {
@@ -202,7 +206,6 @@ IsValidFfsFile ( {
EFI_FFS_FILE_STATE FileState;
UINT8 DataCheckSum;
- UINT32 FileLength;
FileState = GetFileState (ErasePolarity, FfsHeader);
switch (FileState) {
@@ -211,9 +214,12 @@ IsValidFfsFile ( case EFI_FILE_DATA_VALID:
case EFI_FILE_MARKED_FOR_UPDATE:
DataCheckSum = FFS_FIXED_CHECKSUM;
- FileLength = *(UINT32 *)(FfsHeader->Size) & 0x00FFFFFF;
if ((FfsHeader->Attributes & FFS_ATTRIB_CHECKSUM) == FFS_ATTRIB_CHECKSUM) {
- DataCheckSum = CalculateCheckSum8 ((CONST UINT8 *)FfsHeader + sizeof(EFI_FFS_FILE_HEADER), FileLength - sizeof(EFI_FFS_FILE_HEADER));
+ if (IS_FFS_FILE2 (FfsHeader)) {
+ DataCheckSum = CalculateCheckSum8 ((CONST UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER2), FFS_FILE2_SIZE (FfsHeader) - sizeof(EFI_FFS_FILE_HEADER2));
+ } else {
+ DataCheckSum = CalculateCheckSum8 ((CONST UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER), FFS_FILE_SIZE (FfsHeader) - sizeof(EFI_FFS_FILE_HEADER));
+ }
}
if (FfsHeader->IntegrityCheck.Checksum.File == DataCheckSum) {
return TRUE;
diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c index e7a5b44..1e1cbae 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c @@ -3,7 +3,7 @@ Layers on top of Firmware Block protocol to produce a file abstraction
of FV based files.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
@@ -304,7 +304,6 @@ FvCheck ( UINTN Index;
EFI_LBA LbaIndex;
UINTN Size;
- UINTN FileLength;
EFI_FFS_FILE_STATE FileState;
UINT8 *TopFvAddress;
UINTN TestLength;
@@ -438,7 +437,14 @@ FvCheck ( if (!IsValidFfsHeader (FvDevice->ErasePolarity, FfsHeader, &FileState)) {
if ((FileState == EFI_FILE_HEADER_INVALID) ||
(FileState == EFI_FILE_HEADER_CONSTRUCTION)) {
- FfsHeader++;
+ if (IS_FFS_FILE2 (FfsHeader)) {
+ if (!FvDevice->IsFfs3Fv) {
+ DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsHeader->Name));
+ }
+ FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER2));
+ } else {
+ FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER));
+ }
continue;
} else {
//
@@ -457,10 +463,18 @@ FvCheck ( goto Done;
}
- //
- // Size[3] is a three byte array, read 4 bytes and throw one away
- //
- FileLength = *(UINT32 *)&FfsHeader->Size[0] & 0x00FFFFFF;
+ if (IS_FFS_FILE2 (FfsHeader)) {
+ ASSERT (FFS_FILE2_SIZE (FfsHeader) > 0x00FFFFFF);
+ if (!FvDevice->IsFfs3Fv) {
+ DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsHeader->Name));
+ FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + FFS_FILE2_SIZE (FfsHeader));
+ //
+ // Adjust pointer to the next 8-byte aligned boundry.
+ //
+ FfsHeader = (EFI_FFS_FILE_HEADER *) (((UINTN) FfsHeader + 7) & ~0x07);
+ continue;
+ }
+ }
FileState = GetFileState (FvDevice->ErasePolarity, FfsHeader);
@@ -481,7 +495,11 @@ FvCheck ( InsertTailList (&FvDevice->FfsFileListHeader, &FfsFileEntry->Link);
}
- FfsHeader = (EFI_FFS_FILE_HEADER *)(((UINT8 *)FfsHeader) + FileLength);
+ if (IS_FFS_FILE2 (FfsHeader)) {
+ FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + FFS_FILE2_SIZE (FfsHeader));
+ } else {
+ FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + FFS_FILE_SIZE (FfsHeader));
+ }
//
// Adjust pointer to the next 8-byte aligned boundry.
@@ -502,7 +520,7 @@ Done: /**
This notification function is invoked when an instance of the
- EFI_FW_VOLUME_BLOCK_PROTOCOL is produced. It layers an instance of the
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL is produced. It layers an instance of the
EFI_FIRMWARE_VOLUME2_PROTOCOL on the same handle. This is the function where
the actual initialization of the EFI_FIRMWARE_VOLUME2_PROTOCOL is done.
@@ -577,7 +595,8 @@ NotifyFwVolBlock ( // Check to see that the file system is indeed formatted in a way we can
// understand it...
//
- if (!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem2Guid)) {
+ if ((!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem2Guid)) &&
+ (!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem3Guid))) {
continue;
}
@@ -610,6 +629,7 @@ NotifyFwVolBlock ( FvDevice->Handle = Handle;
FvDevice->FwVolHeader = FwVolHeader;
FvDevice->Fv.ParentHandle = Fvb->ParentHandle;
+ FvDevice->IsFfs3Fv = CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem3Guid);
//
// Install an New FV protocol on the existing handle
diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h b/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h index 12ace7a..7cc775f 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h @@ -2,7 +2,7 @@ Firmware File System protocol. Layers on top of Firmware
Block protocol to produce a file abstraction of FV based files.
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
@@ -43,6 +43,7 @@ typedef struct { LIST_ENTRY FfsFileListHeader;
UINT8 ErasePolarity;
+ BOOLEAN IsFfs3Fv;
} FV_DEVICE;
#define FV_DEVICE_FROM_THIS(a) CR(a, FV_DEVICE, Fv, FV2_DEVICE_SIGNATURE)
diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c index 0b53af2..52f8491 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c @@ -1,7 +1,7 @@ /** @file
Implements functions to read firmware file
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
@@ -119,7 +119,6 @@ FvGetNextFile ( UINTN *KeyValue;
LIST_ENTRY *Link;
FFS_FILE_LIST_ENTRY *FfsFileEntry;
- UINTN FileLength;
FvDevice = FV_DEVICE_FROM_THIS (This);
@@ -202,14 +201,13 @@ FvGetNextFile ( *Attributes = FfsAttributes2FvFileAttributes (FfsFileHeader->Attributes);
//
- // Read four bytes out of the 3 byte array and throw out extra data
- //
- FileLength = *(UINT32 *)&FfsFileHeader->Size[0] & 0x00FFFFFF;
-
- //
// we need to substract the header size
//
- *Size = FileLength - sizeof(EFI_FFS_FILE_HEADER);
+ if (IS_FFS_FILE2 (FfsFileHeader)) {
+ *Size = FFS_FILE2_SIZE (FfsFileHeader) - sizeof (EFI_FFS_FILE_HEADER2);
+ } else {
+ *Size = FFS_FILE_SIZE (FfsFileHeader) - sizeof (EFI_FFS_FILE_HEADER);
+ }
return EFI_SUCCESS;
}
@@ -333,7 +331,11 @@ FvReadFile ( //
// Skip over file header
//
- SrcPtr = ((UINT8 *)FfsHeader) + sizeof (EFI_FFS_FILE_HEADER);
+ if (IS_FFS_FILE2 (FfsHeader)) {
+ SrcPtr = ((UINT8 *) FfsHeader) + sizeof (EFI_FFS_FILE_HEADER2);
+ } else {
+ SrcPtr = ((UINT8 *) FfsHeader) + sizeof (EFI_FFS_FILE_HEADER);
+ }
Status = EFI_SUCCESS;
if (*Buffer == NULL) {
@@ -447,7 +449,7 @@ FvReadFileSection ( }
//
- // Use FfsEntry to cache Section Extraction Protocol Inforomation
+ // Use FfsEntry to cache Section Extraction Protocol Information
//
if (FfsEntry->StreamHandle == 0) {
Status = OpenSectionStream (
@@ -470,7 +472,8 @@ FvReadFileSection ( (SectionType == 0) ? 0 : SectionInstance,
Buffer,
BufferSize,
- AuthenticationStatus
+ AuthenticationStatus,
+ FvDevice->IsFfs3Fv
);
//
|