summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Core
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2007-09-29 08:04:29 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2007-09-29 08:04:29 +0000
commit18fd8d651d7383c429cbcdf3a4262aa32268cd6c (patch)
treed31fc2e92d412bee496274523ae295b3ec347110 /MdeModulePkg/Core
parent53b62461462e199e7d8afe9f15099982ed6fbf28 (diff)
downloadedk2-18fd8d651d7383c429cbcdf3a4262aa32268cd6c.tar.gz
edk2-18fd8d651d7383c429cbcdf3a4262aa32268cd6c.tar.bz2
edk2-18fd8d651d7383c429cbcdf3a4262aa32268cd6c.zip
1. Add ExtractGuidedSectionLib library to replace customdecompress library.
2. Add PeiDxeExtractGuidedSectionLib library instance and one PCD PcdMaximumGuidedExtractHandler in MdePkg. 3. Update DxeIpl and DxeMain to consume new library. 4. Update BaseUefiTianoCustomDecompressLib to register TianoDecomress extractguidedsection handler. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3980 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r--MdeModulePkg/Core/Dxe/DxeMain.h2
-rw-r--r--MdeModulePkg/Core/Dxe/DxeMain.inf2
-rw-r--r--MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c152
-rw-r--r--MdeModulePkg/Core/DxeIplPeim/DxeIpl.h2
-rw-r--r--MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf2
-rw-r--r--MdeModulePkg/Core/DxeIplPeim/DxeLoad.c123
6 files changed, 141 insertions, 142 deletions
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h
index b033009275..26fb9190e3 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.h
+++ b/MdeModulePkg/Core/Dxe/DxeMain.h
@@ -78,7 +78,7 @@ Revision History
#include <Library/HobLib.h>
#include <Library/PerformanceLib.h>
#include <Library/UefiDecompressLib.h>
-#include <Library/CustomDecompressLib.h>
+#include <Library/ExtractGuidedSectionLib.h>
#include <Library/CacheMaintenanceLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/PeCoffLib.h>
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf
index 9d6ecd0fba..b50263c0e0 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -79,7 +79,6 @@
BaseMemoryLib
CacheMaintenanceLib
UefiDecompressLib
- CustomDecompressLib
PerformanceLib
HobLib
BaseLib
@@ -87,6 +86,7 @@
DebugLib
DxeCoreEntryPoint
PeCoffLib
+ ExtractGuidedSectionLib
[Guids]
gEfiEventLegacyBootGuid # ALWAYS_CONSUMED
diff --git a/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c b/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
index adc590d8f5..1a98e97e9a 100644
--- a/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
+++ b/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
@@ -214,7 +214,7 @@ IsValidSectionStream (
);
EFI_STATUS
-CustomDecompressExtractSection (
+CustomGuidedSectionExtract (
IN CONST EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *This,
IN CONST VOID *InputSection,
OUT VOID **OutputBuffer,
@@ -234,8 +234,8 @@ EFI_SECTION_EXTRACTION_PROTOCOL mSectionExtraction = {
CloseSectionStream
};
-EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL mCustomDecompressExtraction = {
- CustomDecompressExtractSection
+EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL mCustomGuidedSectionExtractionProtocol = {
+ CustomGuidedSectionExtract
};
EFI_STATUS
@@ -261,8 +261,8 @@ Returns:
--*/
{
EFI_STATUS Status;
- EFI_GUID **DecompressGuidList;
- UINT32 DecompressMethodNumber;
+ EFI_GUID *ExtractHandlerGuidTable;
+ UINTN ExtractHandlerNumber;
//
// Install SEP to a new handle
@@ -276,32 +276,22 @@ Returns:
ASSERT_EFI_ERROR (Status);
//
- // Get custom decompress method guid list
+ // Get custom extract guided section method guid list
//
- DecompressGuidList = NULL;
- DecompressMethodNumber = 0;
- Status = CustomDecompressGetAlgorithms (DecompressGuidList, &DecompressMethodNumber);
- if (Status == EFI_OUT_OF_RESOURCES) {
- DecompressGuidList = (EFI_GUID **) CoreAllocateBootServicesPool (DecompressMethodNumber * sizeof (EFI_GUID *));
- ASSERT (DecompressGuidList != NULL);
- Status = CustomDecompressGetAlgorithms (DecompressGuidList, &DecompressMethodNumber);
- }
- ASSERT_EFI_ERROR(Status);
+ ExtractHandlerNumber = ExtractGuidedSectionGetGuidList (&ExtractHandlerGuidTable);
//
- // Install custom decompress guided extraction protocol
+ // Install custom guided extraction protocol
//
- while (DecompressMethodNumber-- > 0) {
+ while (ExtractHandlerNumber-- > 0) {
Status = CoreInstallProtocolInterface (
&mSectionExtractionHandle,
- DecompressGuidList [DecompressMethodNumber],
+ &ExtractHandlerGuidTable [ExtractHandlerNumber],
EFI_NATIVE_INTERFACE,
- &mCustomDecompressExtraction
+ &mCustomGuidedSectionExtractionProtocol
);
ASSERT_EFI_ERROR (Status);
}
-
- CoreFreePool (DecompressGuidList);
return Status;
}
@@ -1464,7 +1454,7 @@ Returns:
**/
EFI_STATUS
-CustomDecompressExtractSection (
+CustomGuidedSectionExtract (
IN CONST EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *This,
IN CONST VOID *InputSection,
OUT VOID **OutputBuffer,
@@ -1473,77 +1463,97 @@ CustomDecompressExtractSection (
)
{
EFI_STATUS Status;
- UINT8 *ScratchBuffer;
- UINT32 DestinationSize;
- UINT32 ScratchSize;
- UINT32 SectionLength;
+ VOID *ScratchBuffer;
+ VOID *AllocatedOutputBuffer;
+ UINT32 OutputBufferSize;
+ UINT32 ScratchBufferSize;
+ UINT16 SectionAttribute;
//
- // Set authentic value to zero.
- //
- *AuthenticationStatus = 0;
+ // Init local variable
//
- // Calculate Section data Size
- //
- SectionLength = *(UINT32 *) (((EFI_COMMON_SECTION_HEADER *) InputSection)->Size) & 0x00ffffff;
+ ScratchBuffer = NULL;
+ AllocatedOutputBuffer = NULL;
+
//
- // Get compressed data information
+ // Call GetInfo to get the size and attribute of input guided section data.
//
- Status = CustomDecompressGetInfo (
- (GUID *) ((UINT8 *) InputSection + sizeof (EFI_COMMON_SECTION_HEADER)),
- (UINT8 *) InputSection + sizeof (EFI_GUID_DEFINED_SECTION),
- SectionLength - sizeof (EFI_GUID_DEFINED_SECTION),
- &DestinationSize,
- &ScratchSize
- );
+ Status = ExtractGuidedSectionGetInfo (
+ InputSection,
+ &OutputBufferSize,
+ &ScratchBufferSize,
+ &SectionAttribute
+ );
+
if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "GetInfo from guided section Failed - %r\n", Status));
+ return Status;
+ }
+
+ if (ScratchBufferSize != 0) {
//
- // GetInfo failed
+ // Allocate scratch buffer
//
- DEBUG ((EFI_D_ERROR, "Extract guided section Failed - %r\n", Status));
- return Status;
+ ScratchBuffer = CoreAllocateBootServicesPool (ScratchBufferSize);
+ if (ScratchBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
}
- //
- // Allocate scratch buffer
- //
- ScratchBuffer = CoreAllocateBootServicesPool (ScratchSize);
- if (ScratchBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Allocate destination buffer
- //
- *OutputSize = (UINTN) DestinationSize;
- *OutputBuffer = CoreAllocateBootServicesPool (*OutputSize);
- if (*OutputBuffer == NULL) {
- CoreFreePool (ScratchBuffer);
- return EFI_OUT_OF_RESOURCES;
+ if (OutputBufferSize > 0) {
+ //
+ // Allocate output buffer
+ //
+ AllocatedOutputBuffer = CoreAllocateBootServicesPool (OutputBufferSize);
+ if (AllocatedOutputBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ *OutputBuffer = AllocatedOutputBuffer;
}
//
- // Call decompress function
+ // Call decode function to extract raw data from the guided section.
//
- Status = CustomDecompress (
- (GUID *) ((UINT8 *) InputSection + sizeof (EFI_COMMON_SECTION_HEADER)),
- (UINT8 *) InputSection + sizeof (EFI_GUID_DEFINED_SECTION),
- *OutputBuffer,
- ScratchBuffer
- );
+ Status = ExtractGuidedSectionDecode (
+ InputSection,
+ OutputBuffer,
+ ScratchBuffer,
+ AuthenticationStatus
+ );
if (EFI_ERROR (Status)) {
//
- // Decompress failed
+ // Decode failed
//
- CoreFreePool (ScratchBuffer);
- CoreFreePool (*OutputBuffer);
+ if (AllocatedOutputBuffer != NULL) {
+ CoreFreePool (AllocatedOutputBuffer);
+ }
+ if (ScratchBuffer != NULL) {
+ CoreFreePool (ScratchBuffer);
+ }
DEBUG ((EFI_D_ERROR, "Extract guided section Failed - %r\n", Status));
return Status;
}
-
+
+ if (*OutputBuffer != AllocatedOutputBuffer) {
+ //
+ // OutputBuffer was returned as a different value,
+ // so copy section contents to the allocated memory buffer.
+ //
+ CopyMem (AllocatedOutputBuffer, *OutputBuffer, OutputBufferSize);
+ *OutputBuffer = AllocatedOutputBuffer;
+ }
+
+ //
+ // Set real size of output buffer.
+ //
+ *OutputSize = (UINTN) OutputBufferSize;
+
//
// Free unused scratch buffer.
//
- CoreFreePool (ScratchBuffer);
-
+ if (ScratchBuffer != NULL) {
+ CoreFreePool (ScratchBuffer);
+ }
+
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
index 52df88f1bf..5e47ca1ba8 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
@@ -43,7 +43,7 @@ Abstract:
#include <Library/ReportStatusCodeLib.h>
#include <Library/CacheMaintenanceLib.h>
#include <Library/UefiDecompressLib.h>
-#include <Library/CustomDecompressLib.h>
+#include <Library/ExtractGuidedSectionLib.h>
#include <Library/PeiServicesTablePointerLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
index 9ee0ebfe3d..c28525acaf 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
@@ -67,7 +67,7 @@
MemoryAllocationLib
BaseMemoryLib
PeiServicesTablePointerLib
- CustomDecompressLib
+ ExtractGuidedSectionLib
UefiDecompressLib
CacheMaintenanceLib
ReportStatusCodeLib
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c
index cb13a7d4b0..1359fe99bc 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c
@@ -18,7 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <FrameworkPei.h>
EFI_STATUS
-CustomDecompressExtractSection (
+CustomGuidedSectionExtract (
IN CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *This,
IN CONST VOID *InputSection,
OUT VOID **OutputBuffer,
@@ -47,8 +47,8 @@ static EFI_DXE_IPL_PPI mDxeIplPpi = {
DxeLoadCore
};
-STATIC EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI mCustomDecompressExtractiongPpi = {
- CustomDecompressExtractSection
+STATIC EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI mCustomGuidedSectionExtractionPpi = {
+ CustomGuidedSectionExtract
};
STATIC EFI_PEI_DECOMPRESS_PPI mDecompressPpi = {
@@ -91,8 +91,8 @@ PeimInitializeDxeIpl (
{
EFI_STATUS Status;
EFI_BOOT_MODE BootMode;
- EFI_GUID **DecompressGuidList;
- UINT32 DecompressMethodNumber;
+ EFI_GUID *ExtractHandlerGuidTable;
+ UINTN ExtractHandlerNumber;
EFI_PEI_PPI_DESCRIPTOR *GuidPpi;
Status = PeiServicesGetBootMode (&BootMode);
@@ -110,29 +110,21 @@ PeimInitializeDxeIpl (
gInMemory = TRUE;
//
- // Get custom decompress method guid list
+ // Get custom extract guided section method guid list
//
- DecompressGuidList = NULL;
- DecompressMethodNumber = 0;
- Status = CustomDecompressGetAlgorithms (DecompressGuidList, &DecompressMethodNumber);
- if (Status == EFI_OUT_OF_RESOURCES) {
- DecompressGuidList = (EFI_GUID **) AllocatePages (EFI_SIZE_TO_PAGES (DecompressMethodNumber * sizeof (EFI_GUID *)));
- ASSERT (DecompressGuidList != NULL);
- Status = CustomDecompressGetAlgorithms (DecompressGuidList, &DecompressMethodNumber);
- }
- ASSERT_EFI_ERROR(Status);
+ ExtractHandlerNumber = ExtractGuidedSectionGetGuidList (&ExtractHandlerGuidTable);
//
- // Install custom decompress extraction guid ppi
+ // Install custom extraction guid ppi
//
- if (DecompressMethodNumber > 0) {
+ if (ExtractHandlerNumber > 0) {
GuidPpi = NULL;
- GuidPpi = (EFI_PEI_PPI_DESCRIPTOR *) AllocatePages (EFI_SIZE_TO_PAGES (DecompressMethodNumber * sizeof (EFI_PEI_PPI_DESCRIPTOR)));
+ GuidPpi = (EFI_PEI_PPI_DESCRIPTOR *) AllocatePool (ExtractHandlerNumber * sizeof (EFI_PEI_PPI_DESCRIPTOR));
ASSERT (GuidPpi != NULL);
- while (DecompressMethodNumber-- > 0) {
+ while (ExtractHandlerNumber-- > 0) {
GuidPpi->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
- GuidPpi->Ppi = &mCustomDecompressExtractiongPpi;
- GuidPpi->Guid = DecompressGuidList [DecompressMethodNumber];
+ GuidPpi->Ppi = &mCustomGuidedSectionExtractionPpi;
+ GuidPpi->Guid = &(ExtractHandlerGuidTable [ExtractHandlerNumber]);
Status = PeiServicesInstallPpi (GuidPpi++);
ASSERT_EFI_ERROR(Status);
}
@@ -560,7 +552,7 @@ PeiLoadFile (
GUIDed Section Extraction PPI.
**/
EFI_STATUS
-CustomDecompressExtractSection (
+CustomGuidedSectionExtract (
IN CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *This,
IN CONST VOID *InputSection,
OUT VOID **OutputBuffer,
@@ -570,70 +562,67 @@ CustomDecompressExtractSection (
{
EFI_STATUS Status;
UINT8 *ScratchBuffer;
- UINT32 ScratchSize;
- UINT32 SectionLength;
- UINT32 DestinationSize;
+ UINT32 ScratchBufferSize;
+ UINT32 OutputBufferSize;
+ UINT16 SectionAttribute;
//
- // Set authentic value to zero.
- //
- *AuthenticationStatus = 0;
+ // Init local variable
//
- // Calculate Section data Size
- //
- SectionLength = *(UINT32 *) (((EFI_COMMON_SECTION_HEADER *) InputSection)->Size) & 0x00ffffff;
+ ScratchBuffer = NULL;
+
//
- // Get compressed data information
+ // Call GetInfo to get the size and attribute of input guided section data.
//
- Status = CustomDecompressGetInfo (
- (GUID *) ((UINT8 *) InputSection + sizeof (EFI_COMMON_SECTION_HEADER)),
- (UINT8 *) InputSection + sizeof (EFI_GUID_DEFINED_SECTION),
- SectionLength - sizeof (EFI_GUID_DEFINED_SECTION),
- &DestinationSize,
- &ScratchSize
- );
+ Status = ExtractGuidedSectionGetInfo (
+ InputSection,
+ &OutputBufferSize,
+ &ScratchBufferSize,
+ &SectionAttribute
+ );
+
if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "GetInfo from guided section Failed - %r\n", Status));
+ return Status;
+ }
+
+ if (ScratchBufferSize != 0) {
//
- // GetInfo failed
+ // Allocate scratch buffer
//
- DEBUG ((EFI_D_ERROR, "Extract guided section Failed - %r\n", Status));
- return Status;
+ ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize));
+ if (ScratchBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
}
- //
- // Allocate scratch buffer
- //
- ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchSize));
- if (ScratchBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Allocate destination buffer
- //
- *OutputSize = (UINTN) DestinationSize;
- *OutputBuffer = AllocatePages (EFI_SIZE_TO_PAGES (*OutputSize));
- if (*OutputBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ if ((SectionAttribute & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) && OutputBufferSize > 0) {
+ //
+ // Allocate output buffer
+ //
+ *OutputBuffer = AllocatePages (EFI_SIZE_TO_PAGES (OutputBufferSize));
+ if (*OutputBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
}
-
- //
- // Call decompress function
- //
- Status = CustomDecompress (
- (GUID *) ((UINT8 *) InputSection + sizeof (EFI_COMMON_SECTION_HEADER)),
- (UINT8 *) InputSection + sizeof (EFI_GUID_DEFINED_SECTION),
- *OutputBuffer,
- ScratchBuffer
- );
+
+ Status = ExtractGuidedSectionDecode (
+ InputSection,
+ OutputBuffer,
+ ScratchBuffer,
+ AuthenticationStatus
+ );
if (EFI_ERROR (Status)) {
//
- // Decompress failed
+ // Decode failed
//
DEBUG ((EFI_D_ERROR, "Extract guided section Failed - %r\n", Status));
return Status;
}
+ *OutputSize = (UINTN) OutputBufferSize;
+
return EFI_SUCCESS;
}