\r
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
\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
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
EFI_STATUS\r
FindFileEx (\r
IN CONST EFI_PEI_FV_HANDLE FvHandle,\r
- IN CONST EFI_GUID *FileName, OPTIONAL\r
+ IN CONST EFI_GUID *FileName OPTIONAL,\r
IN EFI_FV_FILETYPE SearchType,\r
IN OUT EFI_PEI_FILE_HANDLE *FileHandle\r
)\r
UINT32 SectionLength;\r
UINT32 ParsedLength;\r
EFI_COMPRESSION_SECTION *CompressionSection;\r
+ EFI_COMPRESSION_SECTION2 *CompressionSection2;\r
UINT32 DstBufferSize;\r
VOID *ScratchBuffer;\r
UINT32 ScratchBufferSize;\r
VOID *DstBuffer;\r
UINT16 SectionAttribute;\r
UINT32 AuthenticationStatus;\r
+ CHAR8 *CompressedData;\r
+ UINTN CompressedDataLength;\r
\r
\r
*OutputBuffer = NULL;\r
ParsedLength = 0;\r
Status = EFI_NOT_FOUND;\r
while (ParsedLength < SectionSize) {\r
+ if (IS_SECTION2 (Section)) {\r
+ ASSERT (SECTION2_SIZE (Section) > 0x00FFFFFF);\r
+ }\r
+\r
if (Section->Type == SectionType) {\r
- *OutputBuffer = (VOID *)(Section + 1);\r
+ if (IS_SECTION2 (Section)) {\r
+ *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2));\r
+ } else {\r
+ *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER));\r
+ }\r
\r
return EFI_SUCCESS;\r
} else if ((Section->Type == EFI_SECTION_COMPRESSION) || (Section->Type == EFI_SECTION_GUID_DEFINED)) {\r
\r
if (Section->Type == EFI_SECTION_COMPRESSION) {\r
- CompressionSection = (EFI_COMPRESSION_SECTION *) Section;\r
- SectionLength = *(UINT32 *)Section->Size & 0x00FFFFFF;\r
-\r
- if (CompressionSection->CompressionType != EFI_STANDARD_COMPRESSION) {\r
- return EFI_UNSUPPORTED;\r
+ if (IS_SECTION2 (Section)) {\r
+ CompressionSection2 = (EFI_COMPRESSION_SECTION2 *) Section;\r
+ SectionLength = SECTION2_SIZE (Section);\r
+\r
+ if (CompressionSection2->CompressionType != EFI_STANDARD_COMPRESSION) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ CompressedData = (CHAR8 *) ((EFI_COMPRESSION_SECTION2 *) Section + 1);\r
+ CompressedDataLength = (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION2);\r
+ } else {\r
+ CompressionSection = (EFI_COMPRESSION_SECTION *) Section;\r
+ SectionLength = SECTION_SIZE (Section);\r
+\r
+ if (CompressionSection->CompressionType != EFI_STANDARD_COMPRESSION) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ CompressedData = (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1);\r
+ CompressedDataLength = (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION);\r
}\r
\r
Status = UefiDecompressGetInfo (\r
- (UINT8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),\r
- (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION),\r
+ CompressedData,\r
+ CompressedDataLength,\r
&DstBufferSize,\r
&ScratchBufferSize\r
);\r
//\r
// GetInfo failed\r
//\r
- DEBUG ((EFI_D_ERROR, "Decompress GetInfo Failed - %r\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "Decompress GetInfo Failed - %r\n", Status));\r
return EFI_NOT_FOUND;\r
}\r
//\r
// DstBuffer still is one section. Adjust DstBuffer offset, skip EFI section header\r
// to make section data at page alignment.\r
//\r
- DstBuffer = (UINT8 *)DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER);\r
+ if (IS_SECTION2 (Section))\r
+ DstBuffer = (UINT8 *)DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER2);\r
+ else\r
+ DstBuffer = (UINT8 *)DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER);\r
//\r
// Call decompress function\r
//\r
if (Section->Type == EFI_SECTION_COMPRESSION) {\r
+ if (IS_SECTION2 (Section)) {\r
+ CompressedData = (CHAR8 *) ((EFI_COMPRESSION_SECTION2 *) Section + 1);\r
+ }\r
+ else {\r
+ CompressedData = (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1);\r
+ }\r
+\r
Status = UefiDecompress (\r
- (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1),\r
+ CompressedData,\r
DstBuffer,\r
ScratchBuffer\r
);\r
//\r
// Decompress failed\r
//\r
- DEBUG ((EFI_D_ERROR, "Decompress Failed - %r\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "Decompress Failed - %r\n", Status));\r
return EFI_NOT_FOUND;\r
} else {\r
return FfsProcessSection (\r
}\r
}\r
\r
+ if (IS_SECTION2 (Section)) {\r
+ SectionLength = SECTION2_SIZE (Section);\r
+ } else {\r
+ SectionLength = SECTION_SIZE (Section);\r
+ }\r
//\r
- // Size is 24 bits wide so mask upper 8 bits.\r
// SectionLength is adjusted it is 4 byte aligned.\r
// Go to the next section\r
//\r
- SectionLength = *(UINT32 *)Section->Size & 0x00FFFFFF;\r
SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);\r
ASSERT (SectionLength != 0);\r
ParsedLength += SectionLength;\r
Search through every FV until you find a file of type FileType\r
\r
@param FileType File handle of a Fv type file.\r
- @param Volumehandle On succes Volume Handle of the match\r
+ @param Volumehandle On success Volume Handle of the match\r
@param FileHandle On success File Handle of the match\r
\r
@retval EFI_NOT_FOUND FV image can't be found.\r
\r
\r
//\r
- // Inform HOB consumer phase, i.e. DXE core, the existance of this FV\r
+ // Inform HOB consumer phase, i.e. DXE core, the existence of this FV\r
//\r
BuildFvHob ((EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart, FvImageInfo.FvSize);\r
\r
\r
return EFI_SUCCESS;\r
}\r
-\r
-\r