From 4afc6a7bf2e75801630c298a312a0ab552a1369f Mon Sep 17 00:00:00 2001 From: lgao4 Date: Thu, 7 Dec 2006 11:32:26 +0000 Subject: (1) Using EfiCompress in place of TianoCompress as EFI_STANDARD_COMPRESSION type to conform to spec. (2) Remove unused library class EdkPeCoffLoaderX64Lib and library instance EdkPeCoffLoaderX64Lib, because current BasePeCoffLib can supports IA32, EBC, & X64 images all. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2069 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Dxe/SectionExtraction/CoreSectionExtraction.c | 2 +- EdkModulePkg/Core/DxeIplPeim/DxeLoad.c | 108 +++++++++++++-------- EdkModulePkg/EdkModulePkg.spd | 9 -- .../Include/Library/EdkPeCoffLoaderX64Lib.h | 33 ------- 4 files changed, 69 insertions(+), 83 deletions(-) delete mode 100644 EdkModulePkg/Include/Library/EdkPeCoffLoaderX64Lib.h (limited to 'EdkModulePkg') diff --git a/EdkModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c b/EdkModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c index e98b80cddf..89dd9afcc1 100644 --- a/EdkModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c +++ b/EdkModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c @@ -805,7 +805,7 @@ Returns: // Decompress the stream // if (CompressionHeader->CompressionType == EFI_STANDARD_COMPRESSION) { - Status = CoreLocateProtocol (&gEfiTianoDecompressProtocolGuid, NULL, (VOID **)&Decompress); + Status = CoreLocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID **)&Decompress); } else { Status = CoreLocateProtocol (&gEfiCustomizedDecompressProtocolGuid, NULL, (VOID **)&Decompress); } diff --git a/EdkModulePkg/Core/DxeIplPeim/DxeLoad.c b/EdkModulePkg/Core/DxeIplPeim/DxeLoad.c index 8dbc3763d6..6a4c53b922 100644 --- a/EdkModulePkg/Core/DxeIplPeim/DxeLoad.c +++ b/EdkModulePkg/Core/DxeIplPeim/DxeLoad.c @@ -669,6 +669,13 @@ Returns: EFI_COMPRESSION_SECTION *CompressionSection; UINT32 FvAlignment; + // + // Initialize local variables. + // + DecompressLibrary = NULL; + DstBuffer = NULL; + DstBufferSize = 0; + Status = PeiServicesFfsFindSectionData ( EFI_SECTION_COMPRESSION, FfsFileHeader, @@ -784,8 +791,11 @@ Returns: switch (CompressionSection->CompressionType) { case EFI_STANDARD_COMPRESSION: + // + // Load EFI standard compression. + // if (FeaturePcdGet (PcdDxeIplSupportTianoDecompress)) { - DecompressLibrary = &gTianoDecompress; + DecompressLibrary = &gEfiDecompress; } else { ASSERT (FALSE); return EFI_NOT_FOUND; @@ -794,7 +804,7 @@ Returns: case EFI_CUSTOMIZED_COMPRESSION: // - // Load user customized compression protocol. + // Load user customized compression. // if (FeaturePcdGet (PcdDxeIplSupportCustomDecompress)) { DecompressLibrary = &gCustomDecompress; @@ -805,52 +815,71 @@ Returns: break; case EFI_NOT_COMPRESSED: + // + // Allocate destination buffer + // + DstBufferSize = CompressionSection->UncompressedLength; + DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize)); + if (DstBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + // + // stream is not actually compressed, just encapsulated. So just copy it. + // + CopyMem (DstBuffer, CompressionSection + 1, DstBufferSize); + break; + default: // - // Need to support not compressed file + // Don't support other unknown compression type. // ASSERT_EFI_ERROR (Status); return EFI_NOT_FOUND; } - - Status = DecompressLibrary->GetInfo ( - (UINT8 *) ((EFI_COMPRESSION_SECTION *) Section + 1), - (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION), - &DstBufferSize, - &ScratchBufferSize - ); - if (EFI_ERROR (Status)) { + + if (CompressionSection->CompressionType != EFI_NOT_COMPRESSED) { // - // GetInfo failed + // For compressed data, decompress them to dstbuffer. // - return EFI_NOT_FOUND; - } - - // - // Allocate scratch buffer - // - ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize)); - if (ScratchBuffer == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Allocate destination buffer - // - DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize)); - if (DstBuffer == NULL) { - return EFI_OUT_OF_RESOURCES; + Status = DecompressLibrary->GetInfo ( + (UINT8 *) ((EFI_COMPRESSION_SECTION *) Section + 1), + (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION), + &DstBufferSize, + &ScratchBufferSize + ); + if (EFI_ERROR (Status)) { + // + // GetInfo failed + // + return EFI_NOT_FOUND; + } + + // + // Allocate scratch buffer + // + ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize)); + if (ScratchBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Allocate destination buffer + // + DstBuffer = AllocatePages (EFI_SIZE_TO_PAGES (DstBufferSize)); + if (DstBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Call decompress function + // + Status = DecompressLibrary->Decompress ( + (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1), + DstBuffer, + ScratchBuffer + ); } - - // - // Call decompress function - // - Status = DecompressLibrary->Decompress ( - (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1), - DstBuffer, - ScratchBuffer - ); - + CmpSection = (EFI_COMMON_SECTION_HEADER *) DstBuffer; if (CmpSection->Type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE) { // @@ -909,7 +938,6 @@ Returns: } else { return EFI_NOT_FOUND; } - } } // diff --git a/EdkModulePkg/EdkModulePkg.spd b/EdkModulePkg/EdkModulePkg.spd index f720d1a94d..e63427f955 100644 --- a/EdkModulePkg/EdkModulePkg.spd +++ b/EdkModulePkg/EdkModulePkg.spd @@ -44,10 +44,6 @@ Include/Library/EdkPeCoffLoaderLib.h - - Include/Library/EdkPeCoffLoaderX64Lib.h - - Include/Library/EdkScsiLib.h @@ -210,10 +206,6 @@ Include/Library/EdkPeCoffLoaderLib.h - - Include/Library/EdkPeCoffLoaderX64Lib.h - - Include/Library/EdkScsiLib.h @@ -399,7 +391,6 @@ Library/EdkIfrSupportLib/EdkIfrSupportLib.msa Library/EdkNullCustomizedDecompressLib/EdkNullCustomizedDecompressLib.msa Library/EdkPeCoffLoaderLib/EdkPeCoffLoaderLib.msa - Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64Lib.msa Library/PeiPerformanceLib/PeiPerformanceLib.msa Library/EdkScsiLib/EdkScsiLib.msa Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.msa diff --git a/EdkModulePkg/Include/Library/EdkPeCoffLoaderX64Lib.h b/EdkModulePkg/Include/Library/EdkPeCoffLoaderX64Lib.h deleted file mode 100644 index 47756d3cf5..0000000000 --- a/EdkModulePkg/Include/Library/EdkPeCoffLoaderX64Lib.h +++ /dev/null @@ -1,33 +0,0 @@ -/*++ - -Copyright (c) 2006, 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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - EdkPeCoffLoaderX64Lib.h - -Abstract: - Wrap the Base PE/COFF loader with the PE COFF Protocol - - - ---*/ - -#ifndef __EDK_PE_COFF_LOADER_X64_LIB__ -#define __EDK_PE_COFF_LOADER_X64_LIB__ - -EFI_PEI_PE_COFF_LOADER_PROTOCOL * -EFIAPI -GetPeCoffLoaderX64Protocol ( - VOID - ); - -#endif - -- cgit v1.2.3