]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Add ExtractGuidedSectionLib library to replace customdecompress library.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 29 Sep 2007 08:04:29 +0000 (08:04 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 29 Sep 2007 08:04:29 +0000 (08:04 +0000)
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

16 files changed:
IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.c
IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf
IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLibInternals.h
MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg/Core/Dxe/DxeMain.inf
MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
MdeModulePkg/Core/DxeIplPeim/DxeIpl.h
MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
MdeModulePkg/Core/DxeIplPeim/DxeLoad.c
MdeModulePkg/MdeModulePkg.dsc
MdePkg/Include/Library/ExtractGuidedSectionLib.h [new file with mode: 0644]
MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.c [new file with mode: 0644]
MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf [new file with mode: 0644]
MdePkg/MdePkg.dec
MdePkg/MdePkg.dsc
Nt32Pkg/Nt32Pkg.dsc

index 61585c7d623740f92c4c89c0c9826c5b1a407f23..14d549d4d6bee35da166b1f4939f4b9789b00e0c 100644 (file)
@@ -629,19 +629,18 @@ Returns:
   ASSERT (DestinationSize != NULL);\r
   ASSERT (ScratchSize != NULL);\r
 \r
-  *ScratchSize  = sizeof (SCRATCH_DATA);\r
-\r
   if (SourceSize < 8) {\r
     return RETURN_INVALID_PARAMETER;\r
   }\r
 \r
-  CopyMem (&CompressedSize, Source, sizeof (UINT32));\r
-  CopyMem (DestinationSize, (VOID *)((UINT8 *)Source + 4), sizeof (UINT32));\r
-\r
+  CompressedSize   = *(UINT32 *) Source;\r
   if (SourceSize < (CompressedSize + 8)) {\r
     return RETURN_INVALID_PARAMETER;\r
   }\r
 \r
+  *ScratchSize  = sizeof (SCRATCH_DATA);\r
+  *DestinationSize = *((UINT32 *) Source + 1);\r
+\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -775,104 +774,117 @@ Returns:
 \r
 RETURN_STATUS\r
 EFIAPI\r
-CustomDecompressGetInfo (\r
-  IN  CONST GUID *DecompressGuid,\r
-  IN  CONST VOID  *Source,\r
-  IN  UINT32      SourceSize,\r
-  OUT UINT32      *DestinationSize,\r
-  OUT UINT32      *ScratchSize\r
+TianoDecompressGetInfo (\r
+  IN  CONST VOID  *InputSection,\r
+  OUT UINT32      *OutputBufferSize,\r
+  OUT UINT32      *ScratchBufferSize,\r
+  OUT UINT16      *SectionAttribute\r
   )\r
 /*++\r
 \r
 Routine Description:\r
 \r
-  The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().\r
+  The internal implementation of Tiano decompress GetInfo.\r
 \r
 Arguments:\r
-  DecompressGuid    The guid matches this decompress method.\r
-  Source          - The source buffer containing the compressed data.\r
-  SourceSize      - The size of source buffer\r
-  DestinationSize - The size of destination buffer.\r
-  ScratchSize     - The size of scratch buffer.\r
+  InputSection          Buffer containing the input GUIDed section to be processed. \r
+  OutputBufferSize      The size of OutputBuffer.\r
+  ScratchBufferSize     The size of ScratchBuffer.\r
+  SectionAttribute      The attribute of the input guided section.\r
 \r
 Returns:\r
 \r
   RETURN_SUCCESS           - The size of destination buffer and the size of scratch buffer are successull retrieved.\r
   RETURN_INVALID_PARAMETER - The source data is corrupted\r
-  RETURN_UNSUPPORTED       - Decompress method is not supported.\r
 \r
 --*/\r
 {\r
-  if (CompareGuid (DecompressGuid, &gTianoCustomDecompressGuid)) {\r
-    return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r
-  } else {\r
-    return RETURN_UNSUPPORTED;\r
+  ASSERT (SectionAttribute != NULL);\r
+\r
+  if (InputSection == NULL) {\r
+    return RETURN_INVALID_PARAMETER;\r
   }\r
+  //\r
+  // Get guid attribute of guid section. \r
+  //\r
+  *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;\r
+\r
+  //\r
+  // Call Tiano GetInfo to get the required size info.\r
+  //\r
+  return UefiDecompressGetInfo (\r
+          (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
+          *(UINT32 *) (((EFI_COMMON_SECTION_HEADER *) InputSection)->Size) & 0x00ffffff - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
+          OutputBufferSize,\r
+          ScratchBufferSize\r
+         );\r
 }\r
 \r
 RETURN_STATUS\r
 EFIAPI\r
-CustomDecompress (\r
-  IN  CONST GUID *DecompressGuid,\r
-  IN CONST VOID  *Source,\r
-  IN OUT VOID    *Destination,\r
-  IN OUT VOID    *Scratch\r
+TianoDecompress (\r
+  IN CONST  VOID    *InputSection,\r
+  OUT       VOID    **OutputBuffer,\r
+  IN        VOID    *ScratchBuffer,        OPTIONAL\r
+  OUT       UINT32  *AuthenticationStatus\r
   )\r
 /*++\r
 \r
 Routine Description:\r
 \r
-  The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().\r
+  The implementation of Tiano Decompress().\r
 \r
 Arguments:\r
-  DecompressGuid    The guid matches this decompress method.\r
-  Source          - The source buffer containing the compressed data.\r
-  Destination     - The destination buffer to store the decompressed data\r
-  Scratch         - The buffer used internally by the decompress routine. This  buffer is needed to store intermediate data.\r
+  InputSection           Buffer containing the input GUIDed section to be processed. \r
+  OutputBuffer           OutputBuffer to point to the start of the section's contents.\r
+                         if guided data is not prcessed. Otherwise,\r
+                         OutputBuffer to contain the output data, which is allocated by the caller.\r
+  ScratchBuffer          A pointer to a caller-allocated buffer for function internal use. \r
+  AuthenticationStatus   A pointer to a caller-allocated UINT32 that indicates the\r
+                         authentication status of the output buffer. 
 \r
 Returns:\r
 \r
   RETURN_SUCCESS           - Decompression is successfull\r
   RETURN_INVALID_PARAMETER - The source data is corrupted\r
-  RETURN_UNSUPPORTED       - Decompress method is not supported.\r
 \r
 --*/\r
 {\r
-  if (CompareGuid (DecompressGuid, &gTianoCustomDecompressGuid)) {\r
-    return UefiTianoDecompress (Source, Destination, Scratch, 2);\r
-  } else {\r
-    return RETURN_UNSUPPORTED;\r
-  }\r
+  ASSERT (OutputBuffer != NULL);\r
+\r
+  if (InputSection == NULL) {\r
+    return RETURN_INVALID_PARAMETER;\r
+  }  \r
+  //\r
+  // Set Authentication to Zero.\r
+  //\r
+  *AuthenticationStatus = 0;\r
+  \r
+  //\r
+  // Call Tiano Decompress to get the raw data\r
+  //\r
+  return UefiTianoDecompress (\r
+          (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,\r
+          *OutputBuffer,\r
+          ScratchBuffer,\r
+          2\r
+         );\r
 }\r
 \r
 /**
-  Get decompress method guid list.\r
-\r
-  @param[in, out]  AlgorithmGuidTable   The decompress method guid list.
-  @param[in, out]  NumberOfAlgorithms   The number of decompress methods.
+  Register TianoDecompress handler.\r
 
-  @retval  RETURN_SUCCESS            Get all algorithmes list successfully.\r
-  @retval  RETURN_OUT_OF_RESOURCES   Source is not enough.\r
-\r
+  @retval  RETURN_SUCCESS            Register successfully.\r
+  @retval  RETURN_OUT_OF_RESOURCES   No enough memory to store this handler.
 **/\r
-RETURN_STATUS\r
+EFI_STATUS\r
 EFIAPI\r
-CustomDecompressGetAlgorithms (\r
-   IN OUT  GUID    **AlgorithmGuidTable,\r
-   IN OUT  UINT32  *NumberOfAlgorithms\r
-  )\r
+TianoDecompressLibConstructor (\r
+)\r
 {\r
-  ASSERT (NumberOfAlgorithms != NULL);\r
-  \r
-  if (*NumberOfAlgorithms < 1) {\r
-    *NumberOfAlgorithms = 1;\r
-    return RETURN_OUT_OF_RESOURCES;\r
-  }\r
-  \r
-  ASSERT (AlgorithmGuidTable != NULL);\r
-\r
-  AlgorithmGuidTable [0] = &gTianoCustomDecompressGuid;\r
-  *NumberOfAlgorithms = 1;\r
-  \r
-  return RETURN_SUCCESS;  \r
+  return ExtractGuidedSectionRegisterHandlers (\r
+          &gTianoCustomDecompressGuid,\r
+          TianoDecompressGetInfo,\r
+          TianoDecompress\r
+          );      \r
 }\r
index 84f20254289b78f9c1e4931638f3c2952e843444..18e1f49a27a7c1ec0f0cda0990278419a473e108 100644 (file)
   FILE_GUID                      = d774c4d9-c121-4da3-a5e2-0f317e3c630c\r
   MODULE_TYPE                    = BASE\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = CustomDecompressLib\r
   LIBRARY_CLASS                  = UefiDecompressLib\r
   EDK_RELEASE_VERSION            = 0x00020000\r
   EFI_SPECIFICATION_VERSION      = 0x00020000\r
 \r
+  CONSTRUCTOR                    = TianoDecompressLibConstructor\r
+\r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
   BaseUefiTianoCustomDecompressLibInternals.h\r
   BaseUefiTianoCustomDecompressLib.c\r
 \r
-\r
 [Packages]\r
   MdePkg/MdePkg.dec\r
   IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
 \r
 [LibraryClasses]\r
-  BaseMemoryLib\r
   DebugLib\r
+  ExtractGuidedSectionLib\r
 \r
 [Guids]\r
   gTianoCustomDecompressGuid \r
index 903de3fba018e99eaf6ed5461d0d83c54c3e0e6d..29995387b49835f4d58b1c66ee2a173bd2913009 100644 (file)
 #ifndef __BASE_UEFI_TIANO_CUSTOM_DECOMPRESS_LIB_INTERNALS_H__\r
 #define __BASE_UEFI_TIANO_CUSTOM_DECOMPRESS_LIB_INTERNALS_H__\r
 \r
-\r
-#include <Base.h>\r
+#include <PiPei.h>\r
 \r
 #include <Library/UefiDecompressLib.h>\r
-#include <Library/CustomDecompressLib.h>\r
 #include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
+#include <Library/ExtractGuidedSectionLib.h>\r
 \r
 //\r
 // Decompression algorithm begins here\r
index b0330092754a12073ead876d495c20eca10995cb..26fb9190e3e0bd7392ee7d63800acc5e4d3bc4ba 100644 (file)
@@ -78,7 +78,7 @@ Revision History
 #include <Library/HobLib.h>\r
 #include <Library/PerformanceLib.h>\r
 #include <Library/UefiDecompressLib.h>\r
-#include <Library/CustomDecompressLib.h>\r
+#include <Library/ExtractGuidedSectionLib.h>\r
 #include <Library/CacheMaintenanceLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/PeCoffLib.h>\r
index 9d6ecd0fba468c315176d3d1619327e253521aca..b50263c0e08170221e05154c746c51afea023a23 100644 (file)
@@ -79,7 +79,6 @@
   BaseMemoryLib\r
   CacheMaintenanceLib\r
   UefiDecompressLib\r
-  CustomDecompressLib\r
   PerformanceLib\r
   HobLib\r
   BaseLib\r
@@ -87,6 +86,7 @@
   DebugLib\r
   DxeCoreEntryPoint\r
   PeCoffLib\r
+  ExtractGuidedSectionLib\r
 \r
 [Guids]\r
   gEfiEventLegacyBootGuid                       # ALWAYS_CONSUMED\r
index adc590d8f51fd10fb66702c7d2345ea32eb744a1..1a98e97e9a6738d1b9f013bdab597103f9c635e3 100644 (file)
@@ -214,7 +214,7 @@ IsValidSectionStream (
   );\r
 \r
 EFI_STATUS\r
-CustomDecompressExtractSection (\r
+CustomGuidedSectionExtract (\r
   IN CONST  EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *This,\r
   IN CONST  VOID                                   *InputSection,\r
   OUT       VOID                                   **OutputBuffer,\r
@@ -234,8 +234,8 @@ EFI_SECTION_EXTRACTION_PROTOCOL mSectionExtraction = {
   CloseSectionStream\r
 };\r
 \r
-EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL mCustomDecompressExtraction = {\r
-  CustomDecompressExtractSection\r
+EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL mCustomGuidedSectionExtractionProtocol = {\r
+  CustomGuidedSectionExtract\r
 };\r
                                              \r
 EFI_STATUS\r
@@ -261,8 +261,8 @@ Returns:
 --*/\r
 {\r
   EFI_STATUS                         Status;\r
-  EFI_GUID                           **DecompressGuidList;\r
-  UINT32                             DecompressMethodNumber;\r
+  EFI_GUID                           *ExtractHandlerGuidTable;\r
+  UINTN                              ExtractHandlerNumber;\r
 \r
   //\r
   // Install SEP to a new handle\r
@@ -276,32 +276,22 @@ Returns:
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
-  // Get custom decompress method guid list \r
+  // Get custom extract guided section method guid list \r
   //\r
-  DecompressGuidList     = NULL;\r
-  DecompressMethodNumber = 0;\r
-  Status = CustomDecompressGetAlgorithms (DecompressGuidList, &DecompressMethodNumber);\r
-  if (Status == EFI_OUT_OF_RESOURCES) {\r
-    DecompressGuidList = (EFI_GUID **) CoreAllocateBootServicesPool (DecompressMethodNumber * sizeof (EFI_GUID *));\r
-    ASSERT (DecompressGuidList != NULL);\r
-    Status = CustomDecompressGetAlgorithms (DecompressGuidList, &DecompressMethodNumber);\r
-  }\r
-  ASSERT_EFI_ERROR(Status);\r
+  ExtractHandlerNumber = ExtractGuidedSectionGetGuidList (&ExtractHandlerGuidTable);\r
 \r
   //\r
-  // Install custom decompress guided extraction protocol \r
+  // Install custom guided extraction protocol \r
   //\r
-  while (DecompressMethodNumber-- > 0) {\r
+  while (ExtractHandlerNumber-- > 0) {\r
     Status = CoreInstallProtocolInterface (\r
               &mSectionExtractionHandle,\r
-              DecompressGuidList [DecompressMethodNumber],\r
+              &ExtractHandlerGuidTable [ExtractHandlerNumber],\r
               EFI_NATIVE_INTERFACE,\r
-              &mCustomDecompressExtraction\r
+              &mCustomGuidedSectionExtractionProtocol\r
               );\r
     ASSERT_EFI_ERROR (Status);\r
   }\r
-  \r
-  CoreFreePool (DecompressGuidList);\r
 \r
   return Status;\r
 }\r
@@ -1464,7 +1454,7 @@ Returns:
 \r
 **/\r
 EFI_STATUS\r
-CustomDecompressExtractSection (\r
+CustomGuidedSectionExtract (\r
   IN CONST  EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *This,\r
   IN CONST  VOID                                   *InputSection,\r
   OUT       VOID                                   **OutputBuffer,\r
@@ -1473,77 +1463,97 @@ CustomDecompressExtractSection (
   )\r
 {\r
   EFI_STATUS      Status;\r
-  UINT8           *ScratchBuffer;\r
-  UINT32          DestinationSize;\r
-  UINT32          ScratchSize;\r
-  UINT32          SectionLength;  \r
+  VOID            *ScratchBuffer;\r
+  VOID            *AllocatedOutputBuffer;\r
+  UINT32          OutputBufferSize;\r
+  UINT32          ScratchBufferSize;\r
+  UINT16          SectionAttribute;\r
   \r
   //\r
-  // Set authentic value to zero.\r
-  //\r
-  *AuthenticationStatus = 0;\r
+  // Init local variable\r
   //\r
-  // Calculate Section data Size\r
-  //\r
-  SectionLength   = *(UINT32 *) (((EFI_COMMON_SECTION_HEADER *) InputSection)->Size) & 0x00ffffff;\r
+  ScratchBuffer         = NULL;\r
+  AllocatedOutputBuffer = NULL;\r
+\r
   //\r
-  // Get compressed data information\r
+  // Call GetInfo to get the size and attribute of input guided section data.\r
   //\r
-  Status = CustomDecompressGetInfo (\r
-             (GUID *) ((UINT8 *) InputSection + sizeof (EFI_COMMON_SECTION_HEADER)),\r
-             (UINT8 *) InputSection + sizeof (EFI_GUID_DEFINED_SECTION),\r
-             SectionLength - sizeof (EFI_GUID_DEFINED_SECTION),\r
-             &DestinationSize,\r
-             &ScratchSize\r
-             );\r
+  Status = ExtractGuidedSectionGetInfo (\r
+            InputSection,\r
+            &OutputBufferSize,\r
+            &ScratchBufferSize,\r
+            &SectionAttribute\r
+           );\r
+  \r
   if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "GetInfo from guided section Failed - %r\n", Status));\r
+    return Status;\r
+  }\r
+  \r
+  if (ScratchBufferSize != 0) {\r
     //\r
-    // GetInfo failed\r
+    // Allocate scratch buffer\r
     //\r
-    DEBUG ((EFI_D_ERROR, "Extract guided section Failed - %r\n", Status));\r
-    return Status;\r
+    ScratchBuffer = CoreAllocateBootServicesPool (ScratchBufferSize);\r
+    if (ScratchBuffer == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
   }\r
 \r
-  //\r
-  // Allocate scratch buffer\r
-  //\r
-  ScratchBuffer = CoreAllocateBootServicesPool (ScratchSize);\r
-  if (ScratchBuffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Allocate destination buffer\r
-  //\r
-  *OutputSize = (UINTN) DestinationSize;\r
-  *OutputBuffer = CoreAllocateBootServicesPool (*OutputSize);\r
-  if (*OutputBuffer == NULL) {\r
-    CoreFreePool (ScratchBuffer);\r
-    return EFI_OUT_OF_RESOURCES;\r
+  if (OutputBufferSize > 0) {  \r
+    //\r
+    // Allocate output buffer\r
+    //\r
+    AllocatedOutputBuffer = CoreAllocateBootServicesPool (OutputBufferSize);\r
+    if (AllocatedOutputBuffer == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    *OutputBuffer = AllocatedOutputBuffer;\r
   }\r
 \r
   //\r
-  // Call decompress function\r
+  // Call decode function to extract raw data from the guided section.\r
   //\r
-  Status = CustomDecompress (\r
-             (GUID *) ((UINT8 *) InputSection + sizeof (EFI_COMMON_SECTION_HEADER)),\r
-             (UINT8 *) InputSection + sizeof (EFI_GUID_DEFINED_SECTION),\r
-             *OutputBuffer,\r
-             ScratchBuffer\r
-             );\r
+  Status = ExtractGuidedSectionDecode (\r
+             InputSection, \r
+             OutputBuffer,\r
+             ScratchBuffer,\r
+             AuthenticationStatus\r
+           );\r
   if (EFI_ERROR (Status)) {\r
     //\r
-    // Decompress failed\r
+    // Decode failed\r
     //\r
-    CoreFreePool (ScratchBuffer);\r
-    CoreFreePool (*OutputBuffer);\r
+    if (AllocatedOutputBuffer != NULL) {\r
+      CoreFreePool (AllocatedOutputBuffer);\r
+    }\r
+    if (ScratchBuffer != NULL) {\r
+      CoreFreePool (ScratchBuffer);\r
+    }\r
     DEBUG ((EFI_D_ERROR, "Extract guided section Failed - %r\n", Status));\r
     return Status;\r
   }\r
-  \r
+\r
+  if (*OutputBuffer != AllocatedOutputBuffer) {\r
+    //\r
+    // OutputBuffer was returned as a different value, \r
+    // so copy section contents to the allocated memory buffer.\r
+    // \r
+    CopyMem (AllocatedOutputBuffer, *OutputBuffer, OutputBufferSize);\r
+    *OutputBuffer = AllocatedOutputBuffer;\r
+  }\r
+\r
+  //\r
+  // Set real size of output buffer.\r
+  //\r
+  *OutputSize = (UINTN) OutputBufferSize;\r
+\r
   //\r
   // Free unused scratch buffer.\r
   //\r
-  CoreFreePool (ScratchBuffer);\r
-  \r
+  if (ScratchBuffer != NULL) {\r
+    CoreFreePool (ScratchBuffer);\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 }\r
index 52df88f1bfdebb8ef088215bfcf6e03e970ee35f..5e47ca1ba8c031ae52b7b52ede85d31872ced104 100644 (file)
@@ -43,7 +43,7 @@ Abstract:
 #include <Library/ReportStatusCodeLib.h>\r
 #include <Library/CacheMaintenanceLib.h>\r
 #include <Library/UefiDecompressLib.h>\r
-#include <Library/CustomDecompressLib.h>\r
+#include <Library/ExtractGuidedSectionLib.h>\r
 #include <Library/PeiServicesTablePointerLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
index 9ee0ebfe3db76f0f8a9b0ed9c5a62bd5dae683be..c28525acaf3dc4ac8120de08dd1ae54ae761de04 100644 (file)
@@ -67,7 +67,7 @@
   MemoryAllocationLib\r
   BaseMemoryLib\r
   PeiServicesTablePointerLib\r
-  CustomDecompressLib\r
+  ExtractGuidedSectionLib\r
   UefiDecompressLib\r
   CacheMaintenanceLib\r
   ReportStatusCodeLib\r
index cb13a7d4b08564b7318cc3ddf4bdf1cdc391f99c..1359fe99bc9ca176b78adeae502b572e568782b7 100644 (file)
@@ -18,7 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <FrameworkPei.h>\r
 \r
 EFI_STATUS\r
-CustomDecompressExtractSection (\r
+CustomGuidedSectionExtract (\r
   IN CONST  EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *This,\r
   IN CONST  VOID                                  *InputSection,\r
   OUT       VOID                                  **OutputBuffer,\r
@@ -47,8 +47,8 @@ static EFI_DXE_IPL_PPI mDxeIplPpi = {
   DxeLoadCore\r
 };\r
 \r
-STATIC EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI mCustomDecompressExtractiongPpi = {\r
-  CustomDecompressExtractSection\r
+STATIC EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI mCustomGuidedSectionExtractionPpi = {\r
+  CustomGuidedSectionExtract\r
 };\r
 \r
 STATIC EFI_PEI_DECOMPRESS_PPI mDecompressPpi = {\r
@@ -91,8 +91,8 @@ PeimInitializeDxeIpl (
 {\r
   EFI_STATUS                                Status;\r
   EFI_BOOT_MODE                             BootMode;\r
-  EFI_GUID                                  **DecompressGuidList;\r
-  UINT32                                    DecompressMethodNumber;\r
+  EFI_GUID                                  *ExtractHandlerGuidTable;\r
+  UINTN                                     ExtractHandlerNumber;\r
   EFI_PEI_PPI_DESCRIPTOR                    *GuidPpi;\r
   \r
   Status = PeiServicesGetBootMode (&BootMode);\r
@@ -110,29 +110,21 @@ PeimInitializeDxeIpl (
       gInMemory = TRUE;\r
       \r
       //\r
-      // Get custom decompress method guid list \r
+      // Get custom extract guided section method guid list \r
       //\r
-      DecompressGuidList     = NULL;\r
-      DecompressMethodNumber = 0;\r
-      Status = CustomDecompressGetAlgorithms (DecompressGuidList, &DecompressMethodNumber);\r
-      if (Status == EFI_OUT_OF_RESOURCES) {\r
-      DecompressGuidList = (EFI_GUID **) AllocatePages (EFI_SIZE_TO_PAGES (DecompressMethodNumber * sizeof (EFI_GUID *)));\r
-      ASSERT (DecompressGuidList != NULL);\r
-      Status = CustomDecompressGetAlgorithms (DecompressGuidList, &DecompressMethodNumber);\r
-      }\r
-      ASSERT_EFI_ERROR(Status);\r
+      ExtractHandlerNumber = ExtractGuidedSectionGetGuidList (&ExtractHandlerGuidTable);\r
       \r
       //\r
-      // Install custom decompress extraction guid ppi\r
+      // Install custom extraction guid ppi\r
       //\r
-      if (DecompressMethodNumber > 0) {\r
+      if (ExtractHandlerNumber > 0) {\r
        GuidPpi = NULL;\r
-       GuidPpi = (EFI_PEI_PPI_DESCRIPTOR *) AllocatePages (EFI_SIZE_TO_PAGES (DecompressMethodNumber * sizeof (EFI_PEI_PPI_DESCRIPTOR)));\r
+       GuidPpi = (EFI_PEI_PPI_DESCRIPTOR *) AllocatePool (ExtractHandlerNumber * sizeof (EFI_PEI_PPI_DESCRIPTOR));\r
        ASSERT (GuidPpi != NULL);\r
-       while (DecompressMethodNumber-- > 0) {\r
+       while (ExtractHandlerNumber-- > 0) {\r
          GuidPpi->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r
-         GuidPpi->Ppi   = &mCustomDecompressExtractiongPpi;\r
-         GuidPpi->Guid  = DecompressGuidList [DecompressMethodNumber];\r
+         GuidPpi->Ppi   = &mCustomGuidedSectionExtractionPpi;\r
+         GuidPpi->Guid  = &(ExtractHandlerGuidTable [ExtractHandlerNumber]);\r
          Status = PeiServicesInstallPpi (GuidPpi++);\r
          ASSERT_EFI_ERROR(Status);\r
        }\r
@@ -560,7 +552,7 @@ PeiLoadFile (
                                 GUIDed Section Extraction PPI.\r
 **/\r
 EFI_STATUS\r
-CustomDecompressExtractSection (\r
+CustomGuidedSectionExtract (\r
   IN CONST  EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *This,\r
   IN CONST  VOID                                  *InputSection,\r
   OUT       VOID                                  **OutputBuffer,\r
@@ -570,70 +562,67 @@ CustomDecompressExtractSection (
 {\r
   EFI_STATUS      Status;\r
   UINT8           *ScratchBuffer;\r
-  UINT32          ScratchSize;\r
-  UINT32          SectionLength;\r
-  UINT32          DestinationSize;  \r
+  UINT32          ScratchBufferSize;\r
+  UINT32          OutputBufferSize;\r
+  UINT16          SectionAttribute;\r
   \r
   //\r
-  // Set authentic value to zero.\r
-  //\r
-  *AuthenticationStatus = 0;\r
+  // Init local variable\r
   //\r
-  // Calculate Section data Size\r
-  //\r
-  SectionLength   = *(UINT32 *) (((EFI_COMMON_SECTION_HEADER *) InputSection)->Size) & 0x00ffffff;\r
+  ScratchBuffer = NULL;\r
+\r
   //\r
-  // Get compressed data information\r
+  // Call GetInfo to get the size and attribute of input guided section data.\r
   //\r
-  Status = CustomDecompressGetInfo (\r
-             (GUID *) ((UINT8 *) InputSection + sizeof (EFI_COMMON_SECTION_HEADER)),\r
-             (UINT8 *) InputSection + sizeof (EFI_GUID_DEFINED_SECTION),\r
-             SectionLength - sizeof (EFI_GUID_DEFINED_SECTION),\r
-             &DestinationSize,\r
-             &ScratchSize\r
-             );\r
+  Status = ExtractGuidedSectionGetInfo (\r
+            InputSection,\r
+            &OutputBufferSize,\r
+            &ScratchBufferSize,\r
+            &SectionAttribute\r
+           );\r
+  \r
   if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "GetInfo from guided section Failed - %r\n", Status));\r
+    return Status;\r
+  }\r
+  \r
+  if (ScratchBufferSize != 0) {\r
     //\r
-    // GetInfo failed\r
+    // Allocate scratch buffer\r
     //\r
-    DEBUG ((EFI_D_ERROR, "Extract guided section Failed - %r\n", Status));\r
-    return Status;\r
+    ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchBufferSize));\r
+    if (ScratchBuffer == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
   }\r
 \r
-  //\r
-  // Allocate scratch buffer\r
-  //\r
-  ScratchBuffer = AllocatePages (EFI_SIZE_TO_PAGES (ScratchSize));\r
-  if (ScratchBuffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  //\r
-  // Allocate destination buffer\r
-  //\r
-  *OutputSize   = (UINTN) DestinationSize;\r
-  *OutputBuffer = AllocatePages (EFI_SIZE_TO_PAGES (*OutputSize));\r
-  if (*OutputBuffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
+  if ((SectionAttribute & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) && OutputBufferSize > 0) {  \r
+    //\r
+    // Allocate output buffer\r
+    //\r
+    *OutputBuffer = AllocatePages (EFI_SIZE_TO_PAGES (OutputBufferSize));\r
+    if (*OutputBuffer == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
   }\r
-\r
-  //\r
-  // Call decompress function\r
-  //\r
-  Status = CustomDecompress (\r
-             (GUID *) ((UINT8 *) InputSection + sizeof (EFI_COMMON_SECTION_HEADER)),\r
-             (UINT8 *) InputSection + sizeof (EFI_GUID_DEFINED_SECTION),\r
-             *OutputBuffer,\r
-             ScratchBuffer\r
-             );\r
+  \r
+  Status = ExtractGuidedSectionDecode (\r
+             InputSection, \r
+             OutputBuffer,\r
+             ScratchBuffer,\r
+             AuthenticationStatus\r
+           );\r
 \r
   if (EFI_ERROR (Status)) {\r
     //\r
-    // Decompress failed\r
+    // Decode failed\r
     //\r
     DEBUG ((EFI_D_ERROR, "Extract guided section Failed - %r\n", Status));\r
     return Status;\r
   }\r
   \r
+  *OutputSize = (UINTN) OutputBufferSize;\r
+  \r
   return EFI_SUCCESS;\r
 }\r
 \r
index 70cf913620e7b07c6b62278c8c01edc572589a78..55f5e392e3dada6ecf4e6a6a408fbedb4cb2d718 100644 (file)
@@ -41,9 +41,9 @@
   PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
   TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf\r
   UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf\r
-  CustomDecompressLib|MdePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.inf\r
   S3Lib|MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf\r
   RecoveryLib|MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf\r
+  ExtractGuidedSectionLib|MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf\r
 \r
 [LibraryClasses.IA32]\r
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1\r
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1\r
   gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|0\r
-\r
+  gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10\r
 \r
 [PcdsFixedAtBuild.IPF]\r
   gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000\r
diff --git a/MdePkg/Include/Library/ExtractGuidedSectionLib.h b/MdePkg/Include/Library/ExtractGuidedSectionLib.h
new file mode 100644 (file)
index 0000000..c3fcfe0
--- /dev/null
@@ -0,0 +1,166 @@
+/** @file\r
+  Extract Guided Section Library class\r
+\r
+  Copyright (c) 2007, Intel Corporation\r
+  All rights reserved. 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
+\r
+  ExtractGuidedSectionLib.h\r
+**/\r
+#ifndef __EXTRACT_GUIDED_SECTION_H__\r
+#define __EXTRACT_GUIDED_SECTION_H__\r
+\r
+/**
+  Get information Handler for the input guided section data.\r
+  It will ASSERT () if the pointer to OutputBufferSize is NULL.\r
+  It will ASSERT () if the pointer to ScratchBufferSize is NULL.
+  It will ASSERT () if the pointer to SectionAttribute is NULL.\r
+\r
+  @param[in]  InputSection          Buffer containing the input GUIDed section to be processed. \r
+  @param[out] OutputBufferSize      The size of OutputBuffer.\r
+  @param[out] ScratchBufferSize     The size of ScratchBuffer.\r
+  @param[out] SectionAttribute      The attribute of the input guided section.\r
+
+  @retval  RETURN_SUCCESS           Get the required information successfully.\r
+  @retval  RETURN_INVALID_PARAMETER The input data can't be parsed correctly.\r
+\r
+**/\r
+typedef\r
+RETURN_STATUS\r
+(EFIAPI *EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER)(\r
+  IN CONST  VOID    *InputSection,\r
+  OUT       UINT32  *OutputBufferSize,\r
+  OUT       UINT32  *ScratchBufferSize,\r
+  OUT       UINT16  *SectionAttribute\r
+  );\r
+\r
+/**
+  Extract data Handler for one specific guided section.
+  It will ASSERT () if the pointer to OutputBuffer is NULL.\r
+  It will ASSERT () if the pointer to AuthenticationStatus is NULL.\r
+\r
+  @param[in]  InputSection  Buffer containing the input GUIDed section to be processed. \r
+  @param[out] OutputBuffer  OutputBuffer to point to the start of the section's contents.\r
+                            if guided data is not prcessed. Otherwise,\r
+                            OutputBuffer to contain the output data, which is allocated by the caller.\r
+  @param[out] ScratchBuffer A pointer to a caller-allocated buffer for function internal use. \r
+  @param[out] AuthenticationStatus \r
+                            A pointer to a caller-allocated UINT32 that indicates the\r
+                            authentication status of the output buffer. 
+
+  @retval  RETURN_SUCCESS               Get the output data and AuthenticationStatus successfully.\r
+  @retval  RETURN_INVALID_PARAMETER The input data can't be parsed correctly.\r
+\r
+**/\r
+typedef\r
+RETURN_STATUS\r
+(EFIAPI *EXTRACT_GUIDED_SECTION_DECODE_HANDLER)(\r
+  IN CONST  VOID    *InputSection,\r
+  OUT       VOID    **OutputBuffer,\r
+  IN        VOID    *ScratchBuffer,        OPTIONAL\r
+  OUT       UINT32  *AuthenticationStatus\r
+  );\r
+\r
+/**
+  Register Guided Section Extract and GetInfo Handler.\r
+\r
+  @param[in]     SectionGuid    The guid matches this Extraction Handler.
+  @param[in]     GetInfoHandler Handler to get info from guided section.\r
+  @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. \r
+  @retval  RETURN_INVALID_PARAMETER Input pointer to Guid value is not valid.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionRegisterHandlers (\r
+  IN CONST  GUID                                     *SectionGuid,\r
+  IN        EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER  GetInfoHandler,\r
+  IN        EXTRACT_GUIDED_SECTION_DECODE_HANDLER    DecodeHandler\r
+  );\r
+\r
+/**
+  Get the supported exract guided section Handler guid list.\r
+  It will ASSERT () if ExtractHandlerGuidTable = NULL.\r
+\r
+  @param[in, out]  ExtractHandlerGuidTable   The extract Handler guid pointer list.
+\r
+  @retval  return the number of the supported extract guided Handler.
+**/\r
+UINTN\r
+EFIAPI\r
+ExtractGuidedSectionGetGuidList (\r
+  IN OUT  GUID  **ExtractHandlerGuidTable\r
+  );\r
+\r
+/**
+  Get information from the guided section. This function first gets the guid value\r
+  from guided section header, then match this guid in the registered extract Handler list\r
+  to its corresponding getinfo Handler. \r
+  If not found, RETURN_UNSUPPORTED will be return. \r
+  If found, it will call the getinfo Handler to get the required size and attribute.\r
+\r
+  It will ASSERT () if the pointer to OutputBufferSize is NULL.\r
+  It will ASSERT () if the pointer to ScratchBufferSize is NULL.
+  It will ASSERT () if the pointer to SectionAttribute is NULL.\r
+\r
+  @param[in]  InputSection          Buffer containing the input GUIDed section to be processed. \r
+  @param[out] OutputBufferSize      The size of OutputBuffer.\r
+  @param[out] ScratchBufferSize     The size of ScratchBuffer.  \r
+  @param[out] SectionAttribute      The attribute of the input guided section.\r
+
+  @retval  RETURN_SUCCESS           Get the required information successfully.\r
+  @retval  RETURN_UNSUPPORTED       Guided section data is not supported.\r
+  @retval  RETURN_INVALID_PARAMETER The input data can't be parsed correctly.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionGetInfo (\r
+  IN  CONST VOID    *InputSection,\r
+  OUT       UINT32  *OutputBufferSize,\r
+  OUT       UINT32  *ScratchBufferSize,\r
+  OUT       UINT16  *SectionAttribute   \r
+  );\r
+\r
+/**
+  Extract data from the guided section. This function first gets the guid value\r
+  from guided section header, then match this guid in the registered extract Handler list\r
+  to its corresponding extract Handler. \r
+  If not found, RETURN_UNSUPPORTED will be return. \r
+  If found, it will call this extract Handler to get output data and AuthenticationStatus.
+\r
+  It will ASSERT () if the pointer to OutputBuffer is NULL.\r
+  It will ASSERT () if the pointer to AuthenticationStatus is NULL.\r
+\r
+  @param[in]  InputSection  Buffer containing the input GUIDed section to be processed. \r
+  @param[out] OutputBuffer  OutputBuffer to point the start of the section's contents \r
+                            if guided data is not required prcessing. Otherwise,\r
+                            OutputBuffer to contain the output data, which is \r
+                            allocated by the caller.\r
+  @param[out] ScratchBuffer A pointer to a caller-allocated buffer for function internal use. \r
+  @param[out] AuthenticationStatus \r
+                            A pointer to a caller-allocated UINT32 that indicates the\r
+                            authentication status of the output buffer. 
+
+  @retval  RETURN_SUCCESS           Get the output data, size and AuthenticationStatus successfully.\r
+  @retval  RETURN_UNSUPPORTED       Guided section data is not supported to be decoded.\r
+  @retval  RETURN_INVALID_PARAMETER The input data can't be parsed correctly.
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionDecode (\r
+  IN  CONST VOID    *InputSection,\r
+  OUT       VOID    **OutputBuffer,\r
+  OUT       VOID    *ScratchBuffer,        OPTIONAL\r
+  OUT       UINT32  *AuthenticationStatus  \r
+  );\r
+\r
+#endif\r
diff --git a/MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.c b/MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.c
new file mode 100644 (file)
index 0000000..5de312a
--- /dev/null
@@ -0,0 +1,270 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation\r
+All rights reserved. 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
+\r
+Module Name:\r
+\r
+  PeiDxeExtractGuidedSectionLib.c\r
+\r
+Abstract:\r
+\r
+  Provide generic extract guided section functions. \r
+\r
+--*/\r
+\r
+#include <PiPei.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/ExtractGuidedSectionLib.h>\r
+\r
+STATIC GUID                 *mExtractHandlerGuidTable;\r
+STATIC UINT32               mNumberOfExtractHandler;\r
+\r
+STATIC EXTRACT_GUIDED_SECTION_DECODE_HANDLER   *mExtractDecodeHandlerTable;\r
+STATIC EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *mExtractGetInfoHandlerTable;\r
+\r
+/**
+  Construtor allocates the global memory to store the registered guid and Handler list.\r
+
+  @retval  RETURN_SUCCESS            Allocate the global memory space to store guid and funciton tables.\r
+  @retval  RETURN_OUT_OF_RESOURCES   No enough memory to allocated.
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeiDxeExtractGuidedSectionLibConstructor (\r
+  )\r
+{\r
+  //\r
+  // Allocate global pool space to store the registered handler and its guid value.\r
+  //\r
+  mExtractHandlerGuidTable    = (GUID *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (GUID));\r
+  if (mExtractHandlerGuidTable == NULL) {\r
+    return RETURN_OUT_OF_RESOURCES;\r
+  }\r
+  \r
+  mExtractDecodeHandlerTable  = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER));\r
+  if (mExtractDecodeHandlerTable == NULL) {\r
+    return RETURN_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  mExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER));\r
+  if (mExtractGetInfoHandlerTable == NULL) {\r
+    return RETURN_OUT_OF_RESOURCES;\r
+  }\r
+  \r
+  //\r
+  // the initialized number is Zero.\r
+  //\r
+  mNumberOfExtractHandler = 0;\r
+  \r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**
+  Get the supported exract guided section Handler guid list.\r
+  If ExtractHandlerGuidTable = NULL, then ASSERT.\r
+\r
+  @param[in, out]  ExtractHandlerGuidTable   The extract Handler guid pointer list.
+\r
+  @retval  return the number of the supported extract guided Handler.
+**/\r
+UINTN\r
+EFIAPI\r
+ExtractGuidedSectionGetGuidList (\r
+  IN OUT  GUID  **ExtractHandlerGuidTable\r
+  )\r
+{\r
+  ASSERT (ExtractHandlerGuidTable != NULL);\r
+\r
+  *ExtractHandlerGuidTable = mExtractHandlerGuidTable;\r
+  return mNumberOfExtractHandler;\r
+}\r
+\r
+/**
+  Register Guided Section Extract and GetInfo handler.\r
+\r
+  @param[in]     SectionGuid    The guid matches this Extraction function.
+  @param[in]     GetInfoHandler Function to get info from guided section.\r
+  @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. \r
+  @retval  RETURN_INVALID_PARAMETER Input pointer to Guid value is not valid.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionRegisterHandlers (\r
+  IN CONST  GUID                                     *SectionGuid,\r
+  IN        EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER  GetInfoHandler,\r
+  IN        EXTRACT_GUIDED_SECTION_DECODE_HANDLER    DecodeHandler\r
+  )\r
+{\r
+  //\r
+  // Check input paramter.\r
+  //\r
+  if (SectionGuid == NULL) {\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Check the global table is enough to contain new Handler.\r
+  //\r
+  if (mNumberOfExtractHandler >= PcdGet32 (PcdMaximumGuidedExtractHandler)) {\r
+    return RETURN_OUT_OF_RESOURCES;\r
+  }\r
+  \r
+  //\r
+  // Register new Handler and guid value.\r
+  //\r
+  CopyGuid (&mExtractHandlerGuidTable [mNumberOfExtractHandler], SectionGuid);\r
+  mExtractDecodeHandlerTable [mNumberOfExtractHandler] = DecodeHandler;\r
+  mExtractGetInfoHandlerTable [mNumberOfExtractHandler++] = GetInfoHandler;\r
+  \r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**
+  Get information from the guided section. This function first gets the guid value\r
+  from guided section header, then match this guid in the registered extract Handler list\r
+  to its corresponding getinfo Handler. \r
+  If not found, RETURN_UNSUPPORTED will be return. \r
+  If found, it will call the getinfo Handler to get the required size and attribute.\r
+\r
+  It will ASSERT () if the pointer to OutputBufferSize is NULL.\r
+  It will ASSERT () if the pointer to ScratchBufferSize is NULL.
+  It will ASSERT () if the pointer to SectionAttribute is NULL.\r
+\r
+  @param[in]  InputSection          Buffer containing the input GUIDed section to be processed. \r
+  @param[out] OutputBufferSize      The size of OutputBuffer.\r
+  @param[out] ScratchBufferSize     The size of ScratchBuffer.  \r
+  @param[out] SectionAttribute      The attribute of the input guided section.\r
+
+  @retval  RETURN_SUCCESS           Get the required information successfully.\r
+  @retval  RETURN_UNSUPPORTED       Guided section data is not supported.\r
+  @retval  RETURN_INVALID_PARAMETER The input data can't be parsed correctly.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionGetInfo (\r
+  IN  CONST VOID    *InputSection,\r
+  OUT       UINT32  *OutputBufferSize,\r
+  OUT       UINT32  *ScratchBufferSize,\r
+  OUT       UINT16  *SectionAttribute   \r
+  )\r
+{\r
+  UINT32 Index;\r
+  \r
+  if (InputSection == NULL) {\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+  \r
+  ASSERT (OutputBufferSize != NULL);\r
+  ASSERT (ScratchBufferSize != NULL);\r
+  ASSERT (SectionAttribute != NULL);\r
\r
+  //\r
+  // Search the match registered GetInfo handler for the input guided section.\r
+  //\r
+  for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {\r
+    if (CompareGuid (&mExtractHandlerGuidTable[Index], &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Not found, the input guided section is not supported. \r
+  //\r
+  if (Index == mNumberOfExtractHandler) {\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Call the match handler to getinfo for the input section data.\r
+  //\r
+  return mExtractGetInfoHandlerTable [Index] (\r
+            InputSection,\r
+            OutputBufferSize,\r
+            ScratchBufferSize,\r
+            SectionAttribute\r
+          );\r
+}\r
+\r
+/**
+  Extract data from the guided section. This function first gets the guid value\r
+  from guided section header, then match this guid in the registered extract Handler list\r
+  to its corresponding extract Handler. \r
+  If not found, RETURN_UNSUPPORTED will be return. \r
+  If found, it will call this extract Handler to get output data and AuthenticationStatus.
+\r
+  It will ASSERT () if the pointer to OutputBuffer is NULL.\r
+  It will ASSERT () if the pointer to AuthenticationStatus is NULL.\r
+\r
+  @param[in]  InputSection  Buffer containing the input GUIDed section to be processed. \r
+  @param[out] OutputBuffer  OutputBuffer to point the start of the section's contents \r
+                            if guided data is not required prcessing. Otherwise,\r
+                            OutputBuffer to contain the output data, which is \r
+                            allocated by the caller.\r
+  @param[out] ScratchBuffer A pointer to a caller-allocated buffer for function internal use. \r
+  @param[out] AuthenticationStatus \r
+                            A pointer to a caller-allocated UINT32 that indicates the\r
+                            authentication status of the output buffer. 
+
+  @retval  RETURN_SUCCESS           Get the output data, size and AuthenticationStatus successfully.\r
+  @retval  RETURN_UNSUPPORTED       Guided section data is not supported to be decoded.\r
+  @retval  RETURN_INVALID_PARAMETER The input data can't be parsed correctly.\r
+
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionDecode (\r
+  IN  CONST VOID    *InputSection,\r
+  OUT       VOID    **OutputBuffer,\r
+  OUT       VOID    *ScratchBuffer,        OPTIONAL\r
+  OUT       UINT32  *AuthenticationStatus  \r
+  )\r
+{\r
+  UINT32 Index;\r
+  \r
+  if (InputSection == NULL) {\r
+    return RETURN_INVALID_PARAMETER;\r
+  }\r
+  \r
+  ASSERT (OutputBuffer != NULL);\r
+  ASSERT (AuthenticationStatus != NULL);\r
+\r
+  //\r
+  // Search the match registered GetInfo handler for the input guided section.\r
+  //\r
+  for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {\r
+    if (CompareGuid (&mExtractHandlerGuidTable[Index], &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Not found, the input guided section is not supported. \r
+  //\r
+  if (Index == mNumberOfExtractHandler) {\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Call the match handler to getinfo for the input section data.\r
+  //\r
+  return mExtractDecodeHandlerTable [Index] (\r
+            InputSection,\r
+            OutputBuffer,\r
+            ScratchBuffer,\r
+            AuthenticationStatus\r
+          );\r
+}\r
diff --git a/MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf b/MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf
new file mode 100644 (file)
index 0000000..0316107
--- /dev/null
@@ -0,0 +1,50 @@
+#/** @file\r
+# Component description file for DxeCore Performance Library\r
+#\r
+# This library provides intrastructure for DxeCore to log performance.\r
+# Copyright (c) 2007, Intel Corporation.\r
+#\r
+#  All rights reserved. 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
+#  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
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PeiDxeExtractGuidedSectionLib\r
+  FILE_GUID                      = EF97E3EB-9321-4dfc-8353-CF473FD98F03\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = ExtractGuidedSectionLib\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  CONSTRUCTOR                    = PeiDxeExtractGuidedSectionLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  PeiDxeExtractGuidedSectionLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+  MemoryAllocationLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+\r
+[FixedPcd.common]\r
+  gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler \r
+\r
+\r
index a932af45a8fffbbb51869e609d0bf72a09f9e2d0..e0216f12fb9cca92499c9677fe0a579ae084061c 100644 (file)
@@ -38,7 +38,6 @@
   Include/Ebc\r
 \r
 [LibraryClasses.common]\r
-  CustomDecompressLib|Include/Library/CustomDecompressLib.h\r
   UsbLib|Include/Library/UsbLib.h\r
   UefiRuntimeServicesTableLib|Include/Library/UefiRuntimeServicesTableLib.h\r
   UefiRuntimeLib|Include/Library/UefiRuntimeLib.h\r
@@ -83,6 +82,7 @@
   BaseLib|Include/Library/BaseLib.h\r
   BasePeCoffLib|Include/Library/PeCoffLib.h\r
   GraphicsLib|Include/Library/GraphicsLib.h\r
+  ExtractGuidedSectionLib|Include/Library/ExtractGuidedSectionLib.h\r
 \r
 [LibraryClasses.IPF]\r
   SalLib|Include/Library/SalLib.h\r
   gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueRemoteConsoleReset|0x01040001|UINT32|0x00000018        # EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_PC_RESET\r
   gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueRemoteConsoleInputError|0x01040007|UINT32|0x00000019   # EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_INPUT_ERROR\r
   gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueRemoteConsoleOutputError|0x01040008|UINT32|0x0000001a  # EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_OUTPUT_ERROR\r
+  gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10|UINT32|0x0000001b\r
 \r
 [PcdsFixedAtBuild.IPF]\r
   gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000|UINT64|0x0000000f\r
index 4f0e19dd6d704d47add5cbec2b7c2042333edec1..c4cb309c9907c6c66a3cfa39f6743c8fb1c299ed 100644 (file)
@@ -44,6 +44,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000\r
   gEfiMdePkgTokenSpaceGuid.PcdFSBClock|200000000\r
   gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320\r
+  gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10\r
 \r
 [PcdsFixedAtBuild.IPF]\r
   gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000\r
   MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
   MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
   MdePkg/Library/DxeMemoryLib/DxeMemoryLib.inf\r
-  MdePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.inf\r
   MdePkg/Library/DxeDebugLibSerialPort/DxeDebugLibSerialPort.inf\r
   MdePkg/Library/UefiUsbLib/UefiUsbLib.inf\r
   MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+  MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf\r
 \r
 [Components.IA32]\r
   MdePkg/Library/BaseMemoryLibSse2/BaseMemoryLibSse2.inf\r
index b469cb632dd98250049e56423bee027caca32873..90c4913e2f5dbdfadc4ba629af066c13e545cef9 100644 (file)
   GraphicsLib|IntelFrameworkModulePkg/Library/GraphicsLib/GraphicsLib.inf\r
   FvbServiceLib|MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
-  CustomDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf\r
   UefiDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf\r
   HiiLibFramework|IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf\r
   S3Lib|MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf\r
   RecoveryLib|MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf\r
-\r
+  ExtractGuidedSectionLib|MdePkg/Library/PeiDxeExtractGuidedSectionLib/PeiDxeExtractGuidedSectionLib.inf\r
   \r
 [LibraryClasses.common.BASE]\r
   DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x10000\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x2000\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x00c000\r
+  gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10\r
 \r
 [PcdsFeatureFlag.IA32]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdPeiPcdDatabaseTraverseEnabled|TRUE\r
   Nt32Pkg/WinNtFirmwareVolumePei/WinNtFirmwareVolumePei.inf\r
   Nt32Pkg/WinNtThunkPPIToProtocolPei/WinNtThunkPPIToProtocolPei.inf\r
   MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf\r
-\r
   ##\r
   #  DXE Phase modules\r
   ##\r