summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c138
-rw-r--r--IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf6
-rw-r--r--IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLibInternals.h6
-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
-rw-r--r--MdeModulePkg/MdeModulePkg.dsc4
-rw-r--r--MdePkg/Include/Library/ExtractGuidedSectionLib.h166
-rw-r--r--MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.c270
-rw-r--r--MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf50
-rw-r--r--MdePkg/MdePkg.dec3
-rw-r--r--MdePkg/MdePkg.dsc3
-rw-r--r--Nt32Pkg/Nt32Pkg.dsc5
16 files changed, 715 insertions, 219 deletions
diff --git a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
index 61585c7d62..14d549d4d6 100644
--- a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
+++ b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
@@ -629,19 +629,18 @@ Returns:
ASSERT (DestinationSize != NULL);
ASSERT (ScratchSize != NULL);
- *ScratchSize = sizeof (SCRATCH_DATA);
-
if (SourceSize < 8) {
return RETURN_INVALID_PARAMETER;
}
- CopyMem (&CompressedSize, Source, sizeof (UINT32));
- CopyMem (DestinationSize, (VOID *)((UINT8 *)Source + 4), sizeof (UINT32));
-
+ CompressedSize = *(UINT32 *) Source;
if (SourceSize < (CompressedSize + 8)) {
return RETURN_INVALID_PARAMETER;
}
+ *ScratchSize = sizeof (SCRATCH_DATA);
+ *DestinationSize = *((UINT32 *) Source + 1);
+
return RETURN_SUCCESS;
}
@@ -775,104 +774,117 @@ Returns:
RETURN_STATUS
EFIAPI
-CustomDecompressGetInfo (
- IN CONST GUID *DecompressGuid,
- IN CONST VOID *Source,
- IN UINT32 SourceSize,
- OUT UINT32 *DestinationSize,
- OUT UINT32 *ScratchSize
+TianoDecompressGetInfo (
+ IN CONST VOID *InputSection,
+ OUT UINT32 *OutputBufferSize,
+ OUT UINT32 *ScratchBufferSize,
+ OUT UINT16 *SectionAttribute
)
/*++
Routine Description:
- The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().
+ The internal implementation of Tiano decompress GetInfo.
Arguments:
- DecompressGuid The guid matches this decompress method.
- Source - The source buffer containing the compressed data.
- SourceSize - The size of source buffer
- DestinationSize - The size of destination buffer.
- ScratchSize - The size of scratch buffer.
+ InputSection Buffer containing the input GUIDed section to be processed.
+ OutputBufferSize The size of OutputBuffer.
+ ScratchBufferSize The size of ScratchBuffer.
+ SectionAttribute The attribute of the input guided section.
Returns:
RETURN_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
RETURN_INVALID_PARAMETER - The source data is corrupted
- RETURN_UNSUPPORTED - Decompress method is not supported.
--*/
{
- if (CompareGuid (DecompressGuid, &gTianoCustomDecompressGuid)) {
- return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);
- } else {
- return RETURN_UNSUPPORTED;
+ ASSERT (SectionAttribute != NULL);
+
+ if (InputSection == NULL) {
+ return RETURN_INVALID_PARAMETER;
}
+ //
+ // Get guid attribute of guid section.
+ //
+ *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
+
+ //
+ // Call Tiano GetInfo to get the required size info.
+ //
+ return UefiDecompressGetInfo (
+ (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
+ *(UINT32 *) (((EFI_COMMON_SECTION_HEADER *) InputSection)->Size) & 0x00ffffff - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
+ OutputBufferSize,
+ ScratchBufferSize
+ );
}
RETURN_STATUS
EFIAPI
-CustomDecompress (
- IN CONST GUID *DecompressGuid,
- IN CONST VOID *Source,
- IN OUT VOID *Destination,
- IN OUT VOID *Scratch
+TianoDecompress (
+ IN CONST VOID *InputSection,
+ OUT VOID **OutputBuffer,
+ IN VOID *ScratchBuffer, OPTIONAL
+ OUT UINT32 *AuthenticationStatus
)
/*++
Routine Description:
- The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
+ The implementation of Tiano Decompress().
Arguments:
- DecompressGuid The guid matches this decompress method.
- Source - The source buffer containing the compressed data.
- Destination - The destination buffer to store the decompressed data
- Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ InputSection Buffer containing the input GUIDed section to be processed.
+ OutputBuffer OutputBuffer to point to the start of the section's contents.
+ if guided data is not prcessed. Otherwise,
+ OutputBuffer to contain the output data, which is allocated by the caller.
+ ScratchBuffer A pointer to a caller-allocated buffer for function internal use.
+ AuthenticationStatus A pointer to a caller-allocated UINT32 that indicates the
+ authentication status of the output buffer.
Returns:
RETURN_SUCCESS - Decompression is successfull
RETURN_INVALID_PARAMETER - The source data is corrupted
- RETURN_UNSUPPORTED - Decompress method is not supported.
--*/
{
- if (CompareGuid (DecompressGuid, &gTianoCustomDecompressGuid)) {
- return UefiTianoDecompress (Source, Destination, Scratch, 2);
- } else {
- return RETURN_UNSUPPORTED;
- }
+ ASSERT (OutputBuffer != NULL);
+
+ if (InputSection == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+ //
+ // Set Authentication to Zero.
+ //
+ *AuthenticationStatus = 0;
+
+ //
+ // Call Tiano Decompress to get the raw data
+ //
+ return UefiTianoDecompress (
+ (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
+ *OutputBuffer,
+ ScratchBuffer,
+ 2
+ );
}
/**
- Get decompress method guid list.
-
- @param[in, out] AlgorithmGuidTable The decompress method guid list.
- @param[in, out] NumberOfAlgorithms The number of decompress methods.
+ Register TianoDecompress handler.
- @retval RETURN_SUCCESS Get all algorithmes list successfully.
- @retval RETURN_OUT_OF_RESOURCES Source is not enough.
-
+ @retval RETURN_SUCCESS Register successfully.
+ @retval RETURN_OUT_OF_RESOURCES No enough memory to store this handler.
**/
-RETURN_STATUS
+EFI_STATUS
EFIAPI
-CustomDecompressGetAlgorithms (
- IN OUT GUID **AlgorithmGuidTable,
- IN OUT UINT32 *NumberOfAlgorithms
- )
+TianoDecompressLibConstructor (
+)
{
- ASSERT (NumberOfAlgorithms != NULL);
-
- if (*NumberOfAlgorithms < 1) {
- *NumberOfAlgorithms = 1;
- return RETURN_OUT_OF_RESOURCES;
- }
-
- ASSERT (AlgorithmGuidTable != NULL);
-
- AlgorithmGuidTable [0] = &gTianoCustomDecompressGuid;
- *NumberOfAlgorithms = 1;
-
- return RETURN_SUCCESS;
+ return ExtractGuidedSectionRegisterHandlers (
+ &gTianoCustomDecompressGuid,
+ TianoDecompressGetInfo,
+ TianoDecompress
+ );
}
diff --git a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf
index 84f2025428..18e1f49a27 100644
--- a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf
+++ b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf
@@ -20,11 +20,12 @@
FILE_GUID = d774c4d9-c121-4da3-a5e2-0f317e3c630c
MODULE_TYPE = BASE
VERSION_STRING = 1.0
- LIBRARY_CLASS = CustomDecompressLib
LIBRARY_CLASS = UefiDecompressLib
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
+ CONSTRUCTOR = TianoDecompressLibConstructor
+
#
# The following information is for reference only and not required by the build tools.
#
@@ -35,14 +36,13 @@
BaseUefiTianoCustomDecompressLibInternals.h
BaseUefiTianoCustomDecompressLib.c
-
[Packages]
MdePkg/MdePkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
[LibraryClasses]
- BaseMemoryLib
DebugLib
+ ExtractGuidedSectionLib
[Guids]
gTianoCustomDecompressGuid
diff --git a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLibInternals.h b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLibInternals.h
index 903de3fba0..29995387b4 100644
--- a/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLibInternals.h
+++ b/IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLibInternals.h
@@ -17,13 +17,11 @@
#ifndef __BASE_UEFI_TIANO_CUSTOM_DECOMPRESS_LIB_INTERNALS_H__
#define __BASE_UEFI_TIANO_CUSTOM_DECOMPRESS_LIB_INTERNALS_H__
-
-#include <Base.h>
+#include <PiPei.h>
#include <Library/UefiDecompressLib.h>
-#include <Library/CustomDecompressLib.h>
#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
+#include <Library/ExtractGuidedSectionLib.h>
//
// Decompression algorithm begins here
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;
}
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 70cf913620..55f5e392e3 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -41,9 +41,9 @@
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
- CustomDecompressLib|MdePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.inf
S3Lib|MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf
RecoveryLib|MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf
+ ExtractGuidedSectionLib|MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf
[LibraryClasses.IA32]
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
@@ -358,7 +358,7 @@
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1
gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|0
-
+ gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
[PcdsFixedAtBuild.IPF]
gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000
diff --git a/MdePkg/Include/Library/ExtractGuidedSectionLib.h b/MdePkg/Include/Library/ExtractGuidedSectionLib.h
new file mode 100644
index 0000000000..c3fcfe0947
--- /dev/null
+++ b/MdePkg/Include/Library/ExtractGuidedSectionLib.h
@@ -0,0 +1,166 @@
+/** @file
+ Extract Guided Section Library class
+
+ Copyright (c) 2007, 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.
+
+ ExtractGuidedSectionLib.h
+**/
+#ifndef __EXTRACT_GUIDED_SECTION_H__
+#define __EXTRACT_GUIDED_SECTION_H__
+
+/**
+ Get information Handler for the input guided section data.
+ It will ASSERT () if the pointer to OutputBufferSize is NULL.
+ It will ASSERT () if the pointer to ScratchBufferSize is NULL.
+ It will ASSERT () if the pointer to SectionAttribute is NULL.
+
+ @param[in] InputSection Buffer containing the input GUIDed section to be processed.
+ @param[out] OutputBufferSize The size of OutputBuffer.
+ @param[out] ScratchBufferSize The size of ScratchBuffer.
+ @param[out] SectionAttribute The attribute of the input guided section.
+
+ @retval RETURN_SUCCESS Get the required information successfully.
+ @retval RETURN_INVALID_PARAMETER The input data can't be parsed correctly.
+
+**/
+typedef
+RETURN_STATUS
+(EFIAPI *EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER)(
+ IN CONST VOID *InputSection,
+ OUT UINT32 *OutputBufferSize,
+ OUT UINT32 *ScratchBufferSize,
+ OUT UINT16 *SectionAttribute
+ );
+
+/**
+ Extract data Handler for one specific guided section.
+ It will ASSERT () if the pointer to OutputBuffer is NULL.
+ It will ASSERT () if the pointer to AuthenticationStatus is NULL.
+
+ @param[in] InputSection Buffer containing the input GUIDed section to be processed.
+ @param[out] OutputBuffer OutputBuffer to point to the start of the section's contents.
+ if guided data is not prcessed. Otherwise,
+ OutputBuffer to contain the output data, which is allocated by the caller.
+ @param[out] ScratchBuffer A pointer to a caller-allocated buffer for function internal use.
+ @param[out] AuthenticationStatus
+ A pointer to a caller-allocated UINT32 that indicates the
+ authentication status of the output buffer.
+
+ @retval RETURN_SUCCESS Get the output data and AuthenticationStatus successfully.
+ @retval RETURN_INVALID_PARAMETER The input data can't be parsed correctly.
+
+**/
+typedef
+RETURN_STATUS
+(EFIAPI *EXTRACT_GUIDED_SECTION_DECODE_HANDLER)(
+ IN CONST VOID *InputSection,
+ OUT VOID **OutputBuffer,
+ IN VOID *ScratchBuffer, OPTIONAL
+ OUT UINT32 *AuthenticationStatus
+ );
+
+/**
+ Register Guided Section Extract and GetInfo Handler.
+
+ @param[in] SectionGuid The guid matches this Extraction Handler.
+ @param[in] GetInfoHandler Handler to get info from guided section.
+ @param[in] DecodeHandler Handler to extract guided section.
+
+ @retval RETURN_SUCCESS Register Guided Section Extract Handler successfully.
+ @retval RETURN_OUT_OF_RESOURCES Resource is not enough to register new Handler.
+ @retval RETURN_INVALID_PARAMETER Input pointer to Guid value is not valid.
+
+**/
+RETURN_STATUS
+EFIAPI
+ExtractGuidedSectionRegisterHandlers (
+ IN CONST GUID *SectionGuid,
+ IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER GetInfoHandler,
+ IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER DecodeHandler
+ );
+
+/**
+ Get the supported exract guided section Handler guid list.
+ It will ASSERT () if ExtractHandlerGuidTable = NULL.
+
+ @param[in, out] ExtractHandlerGuidTable The extract Handler guid pointer list.
+
+ @retval return the number of the supported extract guided Handler.
+**/
+UINTN
+EFIAPI
+ExtractGuidedSectionGetGuidList (
+ IN OUT GUID **ExtractHandlerGuidTable
+ );
+
+/**
+ Get information from the guided section. This function first gets the guid value
+ from guided section header, then match this guid in the registered extract Handler list
+ to its corresponding getinfo Handler.
+ If not found, RETURN_UNSUPPORTED will be return.
+ If found, it will call the getinfo Handler to get the required size and attribute.
+
+ It will ASSERT () if the pointer to OutputBufferSize is NULL.
+ It will ASSERT () if the pointer to ScratchBufferSize is NULL.
+ It will ASSERT () if the pointer to SectionAttribute is NULL.
+
+ @param[in] InputSection Buffer containing the input GUIDed section to be processed.
+ @param[out] OutputBufferSize The size of OutputBuffer.
+ @param[out] ScratchBufferSize The size of ScratchBuffer.
+ @param[out] SectionAttribute The attribute of the input guided section.
+
+ @retval RETURN_SUCCESS Get the required information successfully.
+ @retval RETURN_UNSUPPORTED Guided section data is not supported.
+ @retval RETURN_INVALID_PARAMETER The input data can't be parsed correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+ExtractGuidedSectionGetInfo (
+ IN CONST VOID *InputSection,
+ OUT UINT32 *OutputBufferSize,
+ OUT UINT32 *ScratchBufferSize,
+ OUT UINT16 *SectionAttribute
+ );
+
+/**
+ Extract data from the guided section. This function first gets the guid value
+ from guided section header, then match this guid in the registered extract Handler list
+ to its corresponding extract Handler.
+ If not found, RETURN_UNSUPPORTED will be return.
+ If found, it will call this extract Handler to get output data and AuthenticationStatus.
+
+ It will ASSERT () if the pointer to OutputBuffer is NULL.
+ It will ASSERT () if the pointer to AuthenticationStatus is NULL.
+
+ @param[in] InputSection Buffer containing the input GUIDed section to be processed.
+ @param[out] OutputBuffer OutputBuffer to point the start of the section's contents
+ if guided data is not required prcessing. Otherwise,
+ OutputBuffer to contain the output data, which is
+ allocated by the caller.
+ @param[out] ScratchBuffer A pointer to a caller-allocated buffer for function internal use.
+ @param[out] AuthenticationStatus
+ A pointer to a caller-allocated UINT32 that indicates the
+ authentication status of the output buffer.
+
+ @retval RETURN_SUCCESS Get the output data, size and AuthenticationStatus successfully.
+ @retval RETURN_UNSUPPORTED Guided section data is not supported to be decoded.
+ @retval RETURN_INVALID_PARAMETER The input data can't be parsed correctly.
+**/
+RETURN_STATUS
+EFIAPI
+ExtractGuidedSectionDecode (
+ IN CONST VOID *InputSection,
+ OUT VOID **OutputBuffer,
+ OUT VOID *ScratchBuffer, OPTIONAL
+ OUT UINT32 *AuthenticationStatus
+ );
+
+#endif
diff --git a/MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.c b/MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.c
new file mode 100644
index 0000000000..5de312aa92
--- /dev/null
+++ b/MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.c
@@ -0,0 +1,270 @@
+/*++
+
+Copyright (c) 2007, 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:
+
+ PeiDxeExtractGuidedSectionLib.c
+
+Abstract:
+
+ Provide generic extract guided section functions.
+
+--*/
+
+#include <PiPei.h>
+
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/ExtractGuidedSectionLib.h>
+
+STATIC GUID *mExtractHandlerGuidTable;
+STATIC UINT32 mNumberOfExtractHandler;
+
+STATIC EXTRACT_GUIDED_SECTION_DECODE_HANDLER *mExtractDecodeHandlerTable;
+STATIC EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *mExtractGetInfoHandlerTable;
+
+/**
+ Construtor allocates the global memory to store the registered guid and Handler list.
+
+ @retval RETURN_SUCCESS Allocate the global memory space to store guid and funciton tables.
+ @retval RETURN_OUT_OF_RESOURCES No enough memory to allocated.
+**/
+RETURN_STATUS
+EFIAPI
+PeiDxeExtractGuidedSectionLibConstructor (
+ )
+{
+ //
+ // Allocate global pool space to store the registered handler and its guid value.
+ //
+ mExtractHandlerGuidTable = (GUID *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (GUID));
+ if (mExtractHandlerGuidTable == NULL) {
+ return RETURN_OUT_OF_RESOURCES;
+ }
+
+ mExtractDecodeHandlerTable = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER));
+ if (mExtractDecodeHandlerTable == NULL) {
+ return RETURN_OUT_OF_RESOURCES;
+ }
+
+ mExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER));
+ if (mExtractGetInfoHandlerTable == NULL) {
+ return RETURN_OUT_OF_RESOURCES;
+ }
+
+ //
+ // the initialized number is Zero.
+ //
+ mNumberOfExtractHandler = 0;
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Get the supported exract guided section Handler guid list.
+ If ExtractHandlerGuidTable = NULL, then ASSERT.
+
+ @param[in, out] ExtractHandlerGuidTable The extract Handler guid pointer list.
+
+ @retval return the number of the supported extract guided Handler.
+**/
+UINTN
+EFIAPI
+ExtractGuidedSectionGetGuidList (
+ IN OUT GUID **ExtractHandlerGuidTable
+ )
+{
+ ASSERT (ExtractHandlerGuidTable != NULL);
+
+ *ExtractHandlerGuidTable = mExtractHandlerGuidTable;
+ return mNumberOfExtractHandler;
+}
+
+/**
+ Register Guided Section Extract and GetInfo handler.
+
+ @param[in] SectionGuid The guid matches this Extraction function.
+ @param[in] GetInfoHandler Function to get info from guided section.
+ @param[in] DecodeHandler Function to extract guided section.
+
+ @retval RETURN_SUCCESS Register Guided Section Extract function successfully.
+ @retval RETURN_OUT_OF_RESOURCES Resource is not enough to register new function.
+ @retval RETURN_INVALID_PARAMETER Input pointer to Guid value is not valid.
+**/
+RETURN_STATUS
+EFIAPI
+ExtractGuidedSectionRegisterHandlers (
+ IN CONST GUID *SectionGuid,
+ IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER GetInfoHandler,
+ IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER DecodeHandler
+ )
+{
+ //
+ // Check input paramter.
+ //
+ if (SectionGuid == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+ //
+ // Check the global table is enough to contain new Handler.
+ //
+ if (mNumberOfExtractHandler >= PcdGet32 (PcdMaximumGuidedExtractHandler)) {
+ return RETURN_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Register new Handler and guid value.
+ //
+ CopyGuid (&mExtractHandlerGuidTable [mNumberOfExtractHandler], SectionGuid);
+ mExtractDecodeHandlerTable [mNumberOfExtractHandler] = DecodeHandler;
+ mExtractGetInfoHandlerTable [mNumberOfExtractHandler++] = GetInfoHandler;
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Get information from the guided section. This function first gets the guid value
+ from guided section header, then match this guid in the registered extract Handler list
+ to its corresponding getinfo Handler.
+ If not found, RETURN_UNSUPPORTED will be return.
+ If found, it will call the getinfo Handler to get the required size and attribute.
+
+ It will ASSERT () if the pointer to OutputBufferSize is NULL.
+ It will ASSERT () if the pointer to ScratchBufferSize is NULL.
+ It will ASSERT () if the pointer to SectionAttribute is NULL.
+
+ @param[in] InputSection Buffer containing the input GUIDed section to be processed.
+ @param[out] OutputBufferSize The size of OutputBuffer.
+ @param[out] ScratchBufferSize The size of ScratchBuffer.
+ @param[out] SectionAttribute The attribute of the input guided section.
+
+ @retval RETURN_SUCCESS Get the required information successfully.
+ @retval RETURN_UNSUPPORTED Guided section data is not supported.
+ @retval RETURN_INVALID_PARAMETER The input data can't be parsed correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+ExtractGuidedSectionGetInfo (
+ IN CONST VOID *InputSection,
+ OUT UINT32 *OutputBufferSize,
+ OUT UINT32 *ScratchBufferSize,
+ OUT UINT16 *SectionAttribute
+ )
+{
+ UINT32 Index;
+
+ if (InputSection == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ ASSERT (OutputBufferSize != NULL);
+ ASSERT (ScratchBufferSize != NULL);
+ ASSERT (SectionAttribute != NULL);
+
+ //
+ // Search the match registered GetInfo handler for the input guided section.
+ //
+ for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {
+ if (CompareGuid (&mExtractHandlerGuidTable[Index], &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
+ break;
+ }
+ }
+
+ //
+ // Not found, the input guided section is not supported.
+ //
+ if (Index == mNumberOfExtractHandler) {
+ return RETURN_UNSUPPORTED;
+ }
+
+ //
+ // Call the match handler to getinfo for the input section data.
+ //
+ return mExtractGetInfoHandlerTable [Index] (
+ InputSection,
+ OutputBufferSize,
+ ScratchBufferSize,
+ SectionAttribute
+ );
+}
+
+/**
+ Extract data from the guided section. This function first gets the guid value
+ from guided section header, then match this guid in the registered extract Handler list
+ to its corresponding extract Handler.
+ If not found, RETURN_UNSUPPORTED will be return.
+ If found, it will call this extract Handler to get output data and AuthenticationStatus.
+
+ It will ASSERT () if the pointer to OutputBuffer is NULL.
+ It will ASSERT () if the pointer to AuthenticationStatus is NULL.
+
+ @param[in] InputSection Buffer containing the input GUIDed section to be processed.
+ @param[out] OutputBuffer OutputBuffer to point the start of the section's contents
+ if guided data is not required prcessing. Otherwise,
+ OutputBuffer to contain the output data, which is
+ allocated by the caller.
+ @param[out] ScratchBuffer A pointer to a caller-allocated buffer for function internal use.
+ @param[out] AuthenticationStatus
+ A pointer to a caller-allocated UINT32 that indicates the
+ authentication status of the output buffer.
+
+ @retval RETURN_SUCCESS Get the output data, size and AuthenticationStatus successfully.
+ @retval RETURN_UNSUPPORTED Guided section data is not supported to be decoded.
+ @retval RETURN_INVALID_PARAMETER The input data can't be parsed correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+ExtractGuidedSectionDecode (
+ IN CONST VOID *InputSection,
+ OUT VOID **OutputBuffer,
+ OUT VOID *ScratchBuffer, OPTIONAL
+ OUT UINT32 *AuthenticationStatus
+ )
+{
+ UINT32 Index;
+
+ if (InputSection == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ ASSERT (OutputBuffer != NULL);
+ ASSERT (AuthenticationStatus != NULL);
+
+ //
+ // Search the match registered GetInfo handler for the input guided section.
+ //
+ for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {
+ if (CompareGuid (&mExtractHandlerGuidTable[Index], &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
+ break;
+ }
+ }
+
+ //
+ // Not found, the input guided section is not supported.
+ //
+ if (Index == mNumberOfExtractHandler) {
+ return RETURN_UNSUPPORTED;
+ }
+
+ //
+ // Call the match handler to getinfo for the input section data.
+ //
+ return mExtractDecodeHandlerTable [Index] (
+ InputSection,
+ OutputBuffer,
+ ScratchBuffer,
+ AuthenticationStatus
+ );
+}
diff --git a/MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf b/MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf
new file mode 100644
index 0000000000..0316107219
--- /dev/null
+++ b/MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf
@@ -0,0 +1,50 @@
+#/** @file
+# Component description file for DxeCore Performance Library
+#
+# This library provides intrastructure for DxeCore to log performance.
+# Copyright (c) 2007, 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.
+#
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiDxeExtractGuidedSectionLib
+ FILE_GUID = EF97E3EB-9321-4dfc-8353-CF473FD98F03
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ExtractGuidedSectionLib
+ EDK_RELEASE_VERSION = 0x00020000
+ EFI_SPECIFICATION_VERSION = 0x00020000
+
+ CONSTRUCTOR = PeiDxeExtractGuidedSectionLibConstructor
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources.common]
+ PeiDxeExtractGuidedSectionLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+
+[LibraryClasses]
+ MemoryAllocationLib
+ BaseMemoryLib
+ DebugLib
+
+[FixedPcd.common]
+ gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler
+
+
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index a932af45a8..e0216f12fb 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -38,7 +38,6 @@
Include/Ebc
[LibraryClasses.common]
- CustomDecompressLib|Include/Library/CustomDecompressLib.h
UsbLib|Include/Library/UsbLib.h
UefiRuntimeServicesTableLib|Include/Library/UefiRuntimeServicesTableLib.h
UefiRuntimeLib|Include/Library/UefiRuntimeLib.h
@@ -83,6 +82,7 @@
BaseLib|Include/Library/BaseLib.h
BasePeCoffLib|Include/Library/PeCoffLib.h
GraphicsLib|Include/Library/GraphicsLib.h
+ ExtractGuidedSectionLib|Include/Library/ExtractGuidedSectionLib.h
[LibraryClasses.IPF]
SalLib|Include/Library/SalLib.h
@@ -303,6 +303,7 @@
gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueRemoteConsoleReset|0x01040001|UINT32|0x00000018 # EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_PC_RESET
gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueRemoteConsoleInputError|0x01040007|UINT32|0x00000019 # EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_INPUT_ERROR
gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueRemoteConsoleOutputError|0x01040008|UINT32|0x0000001a # EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_OUTPUT_ERROR
+ gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10|UINT32|0x0000001b
[PcdsFixedAtBuild.IPF]
gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000|UINT64|0x0000000f
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index 4f0e19dd6d..c4cb309c99 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -44,6 +44,7 @@
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|200000000
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320
+ gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
[PcdsFixedAtBuild.IPF]
gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000
@@ -99,10 +100,10 @@
MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
MdePkg/Library/DxeMemoryLib/DxeMemoryLib.inf
- MdePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.inf
MdePkg/Library/DxeDebugLibSerialPort/DxeDebugLibSerialPort.inf
MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+ MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf
[Components.IA32]
MdePkg/Library/BaseMemoryLibSse2/BaseMemoryLibSse2.inf
diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc
index b469cb632d..90c4913e2f 100644
--- a/Nt32Pkg/Nt32Pkg.dsc
+++ b/Nt32Pkg/Nt32Pkg.dsc
@@ -62,12 +62,11 @@
GraphicsLib|IntelFrameworkModulePkg/Library/GraphicsLib/GraphicsLib.inf
FvbServiceLib|MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
- CustomDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf
UefiDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf
HiiLibFramework|IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf
S3Lib|MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf
RecoveryLib|MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf
-
+ ExtractGuidedSectionLib|MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf
[LibraryClasses.common.BASE]
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
@@ -288,6 +287,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x10000
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x2000
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x00c000
+ gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
[PcdsFeatureFlag.IA32]
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiPcdDatabaseTraverseEnabled|TRUE
@@ -378,7 +378,6 @@
Nt32Pkg/WinNtFirmwareVolumePei/WinNtFirmwareVolumePei.inf
Nt32Pkg/WinNtThunkPPIToProtocolPei/WinNtThunkPPIToProtocolPei.inf
MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
-
##
# DXE Phase modules
##