Add core FFS3 support, DxeCore.
Signed-off-by: lzeng14 Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12584 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
||||
@@ -201,15 +200,14 @@ FvGetNextFile (
|
||||
CopyGuid (NameGuid, &FfsFileHeader->Name);
|
||||
*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
|
||||
);
|
||||
|
||||
//
|
||||
|
Reference in New Issue
Block a user