X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FCore%2FDxe%2FFwVol%2FFwVolRead.c;h=f2c0dd5de42e0593211750d299de93d39f17d680;hb=523f48e771b1088c6e2cfddc5c56cde1ef9a2ab0;hp=0b53af27d1fd8902b7caea6c8fed7891a43feaa4;hpb=d613c2a88b3db6b7b451d0b90b08343666792d04;p=mirror_edk2.git diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c index 0b53af27d1..f2c0dd5de4 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.
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
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 @@ -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. @@ -119,7 +121,6 @@ FvGetNextFile ( UINTN *KeyValue; LIST_ENTRY *Link; FFS_FILE_LIST_ENTRY *FfsFileEntry; - UINTN FileLength; FvDevice = FV_DEVICE_FROM_THIS (This); @@ -200,16 +201,18 @@ FvGetNextFile ( *FileType = FfsFileHeader->Type; 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; + 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 // - *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; } @@ -320,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; @@ -333,7 +339,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) { @@ -437,6 +447,7 @@ FvReadFileSection ( if (EFI_ERROR (Status)) { return Status; } + ASSERT (FileBuffer != NULL); // // Check to see that the file actually HAS sections before we go any further. @@ -447,7 +458,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,9 +481,17 @@ FvReadFileSection ( (SectionType == 0) ? 0 : SectionInstance, Buffer, BufferSize, - AuthenticationStatus + AuthenticationStatus, + FvDevice->IsFfs3Fv ); + if (!EFI_ERROR (Status)) { + // + // Inherit the authentication status. + // + *AuthenticationStatus |= FvDevice->AuthenticationStatus; + } + // // Close of stream defered to close of FfsHeader list to allow SEP to cache data //