From 795bb9b6c4ee03833496a263fbe60c1fe7b215ad Mon Sep 17 00:00:00 2001 From: lzeng14 Date: Fri, 25 Nov 2011 01:57:23 +0000 Subject: [PATCH] 1. According to PI errata 0000840 and PI 1.2c Vol 3 3.2.3, remove description rows that start with a Required Alignment (bytes) of 2, 4, and 8. 2. In PeiFfsFvPpiGetFileInfo(), FileHeader->Attributes needs to be converted to EFI_FV_FILE_ATTRIBUTES from EFI_FFS_FILE_ATTRIBUTES before it is assigned to FileInfo->FileAttributes. 3. Set EFI_FV_FILE_ATTRIB_FIXED and EFI_FV_FILE_ATTRIB_MEMORY_MAPPED bits for EFI_FV_FILE_ATTRIBUTES based on the FFS file and FV image. Signed-off-by: lzeng14 Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12777 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c | 26 ++++++++----- MdeModulePkg/Core/Pei/FwVol/FwVol.c | 49 ++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 11 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c index 52f84919d1..fc1a2e5fae 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c @@ -19,9 +19,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Required Alignment Alignment Value in FFS Alignment Value in (bytes) Attributes Field Firmware Volume Interfaces 1 0 0 -2 0 1 -4 0 2 -8 0 3 16 1 4 128 2 7 512 3 9 @@ -32,8 +29,6 @@ Required Alignment Alignment Value in FFS Alignment Value in **/ UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16}; - - /** Convert the FFS File Attributes to FV File Attributes @@ -47,13 +42,20 @@ FfsAttributes2FvFileAttributes ( IN EFI_FFS_FILE_ATTRIBUTES FfsAttributes ) { - FfsAttributes = (EFI_FFS_FILE_ATTRIBUTES)((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3); - ASSERT (FfsAttributes < 8); + UINT8 DataAlignment; + EFI_FV_FILE_ATTRIBUTES FileAttribute; - return (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[FfsAttributes]; -} + DataAlignment = (UINT8) ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3); + ASSERT (DataAlignment < 8); + FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[DataAlignment]; + if ((FfsAttributes & FFS_ATTRIB_FIXED) == FFS_ATTRIB_FIXED) { + FileAttribute |= EFI_FV_FILE_ATTRIB_FIXED; + } + + return FileAttribute; +} /** Given the input key, search for the next matching file in the volume. @@ -199,6 +201,9 @@ FvGetNextFile ( *FileType = FfsFileHeader->Type; CopyGuid (NameGuid, &FfsFileHeader->Name); *Attributes = FfsAttributes2FvFileAttributes (FfsFileHeader->Attributes); + if ((FvDevice->FwVolHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == EFI_FVB2_MEMORY_MAPPED) { + *Attributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED; + } // // we need to substract the header size @@ -318,6 +323,9 @@ FvReadFile ( // *FoundType = FfsHeader->Type; *FileAttributes = FfsAttributes2FvFileAttributes (FfsHeader->Attributes); + if ((FvDevice->FwVolHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == EFI_FVB2_MEMORY_MAPPED) { + *FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED; + } *AuthenticationStatus = 0; *BufferSize = FileSize; diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c index b2575c9798..bcf8335a27 100644 --- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c @@ -57,7 +57,49 @@ EFI_PEI_PPI_DESCRIPTOR mPeiFfs3FvPpiList = { &gEfiFirmwareFileSystem3Guid, &mPeiFfs3FwVol.Fv }; - + +/** +Required Alignment Alignment Value in FFS Alignment Value in +(bytes) Attributes Field Firmware Volume Interfaces +1 0 0 +16 1 4 +128 2 7 +512 3 9 +1 KB 4 10 +4 KB 5 12 +32 KB 6 15 +64 KB 7 16 +**/ +UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16}; + +/** + Convert the FFS File Attributes to FV File Attributes + + @param FfsAttributes The attributes of UINT8 type. + + @return The attributes of EFI_FV_FILE_ATTRIBUTES + +**/ +EFI_FV_FILE_ATTRIBUTES +FfsAttributes2FvFileAttributes ( + IN EFI_FFS_FILE_ATTRIBUTES FfsAttributes + ) +{ + UINT8 DataAlignment; + EFI_FV_FILE_ATTRIBUTES FileAttribute; + + DataAlignment = (UINT8) ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3); + ASSERT (DataAlignment < 8); + + FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[DataAlignment]; + + if ((FfsAttributes & FFS_ATTRIB_FIXED) == FFS_ATTRIB_FIXED) { + FileAttribute |= EFI_FV_FILE_ATTRIB_FIXED; + } + + return FileAttribute; +} + /** Returns the file state set by the highest zero bit in the State field @@ -1312,7 +1354,10 @@ PeiFfsFvPpiGetFileInfo ( FileHeader = (EFI_FFS_FILE_HEADER *)FileHandle; CopyMem (&FileInfo->FileName, &FileHeader->Name, sizeof(EFI_GUID)); FileInfo->FileType = FileHeader->Type; - FileInfo->FileAttributes = FileHeader->Attributes; + FileInfo->FileAttributes = FfsAttributes2FvFileAttributes (FileHeader->Attributes); + if ((CoreFvHandle->FvHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == EFI_FVB2_MEMORY_MAPPED) { + FileInfo->FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED; + } if (IS_FFS_FILE2 (FileHeader)) { ASSERT (FFS_FILE2_SIZE (FileHeader) > 0x00FFFFFF); if (!FwVolInstance->IsFfs3Fv) { -- 2.39.2