]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
MdePkg: Fix typos in comments
[mirror_edk2.git] / MdePkg / Library / DxeExtractGuidedSectionLib / DxeExtractGuidedSectionLib.c
index 1587e872fa2062dfb339bff7f10a1a0278ddee4b..8b8e52829b2f5e09014a7dbaf4ae33aa43281ec2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provide generic extract guided section functions for Dxe phase.\r
 \r
-  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -18,6 +18,7 @@
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/ExtractGuidedSectionLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
 \r
 #define EXTRACT_HANDLER_TABLE_SIZE   0x10\r
 \r
@@ -175,8 +176,10 @@ ExtractGuidedSectionRegisterHandlers (
   )\r
 {\r
   UINT32 Index;\r
+  VOID   *GuidData;\r
+\r
   //\r
-  // Check input paramter.\r
+  // Check input parameter.\r
   //\r
   ASSERT (SectionGuid != NULL);\r
   ASSERT (GetInfoHandler != NULL);\r
@@ -211,7 +214,16 @@ ExtractGuidedSectionRegisterHandlers (
   CopyGuid (&mExtractHandlerGuidTable [mNumberOfExtractHandler], SectionGuid);\r
   mExtractDecodeHandlerTable [mNumberOfExtractHandler] = DecodeHandler;\r
   mExtractGetInfoHandlerTable [mNumberOfExtractHandler++] = GetInfoHandler;\r
-  \r
+\r
+  //\r
+  // Install the Guided Section GUID configuration table to record the GUID itself.\r
+  // Then the content of the configuration table buffer will be the same as the GUID value itself.\r
+  //\r
+  GuidData = AllocateCopyPool (sizeof (GUID), (VOID *) SectionGuid);\r
+  if (GuidData != NULL) {\r
+    gBS->InstallConfigurationTable ((EFI_GUID *) SectionGuid, GuidData);\r
+  }\r
+\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -259,17 +271,24 @@ ExtractGuidedSectionGetInfo (
   )\r
 {\r
   UINT32 Index;\r
+  EFI_GUID *SectionDefinitionGuid;\r
 \r
   ASSERT (InputSection != NULL);  \r
   ASSERT (OutputBufferSize != NULL);\r
   ASSERT (ScratchBufferSize != NULL);\r
   ASSERT (SectionAttribute != NULL);\r
+\r
+  if (IS_SECTION2 (InputSection)) {\r
+    SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);\r
+  } else {\r
+    SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);\r
+  }\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
+    if (CompareGuid (&mExtractHandlerGuidTable[Index], SectionDefinitionGuid)) {\r
       //\r
       // Call the match handler to getinfo for the input section data.\r
       //\r
@@ -333,6 +352,7 @@ ExtractGuidedSectionDecode (
   )\r
 {\r
   UINT32 Index;\r
+  EFI_GUID *SectionDefinitionGuid;\r
   \r
   //\r
   // Check the input parameters\r
@@ -341,11 +361,17 @@ ExtractGuidedSectionDecode (
   ASSERT (OutputBuffer != NULL);\r
   ASSERT (AuthenticationStatus != NULL);\r
 \r
+  if (IS_SECTION2 (InputSection)) {\r
+    SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);\r
+  } else {\r
+    SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);\r
+  }\r
+\r
   //\r
   // Search the match registered extract 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
+    if (CompareGuid (&mExtractHandlerGuidTable[Index], SectionDefinitionGuid)) {\r
       //\r
       // Call the match handler to extract raw data for the input section data.\r
       //\r
@@ -363,3 +389,66 @@ ExtractGuidedSectionDecode (
   //\r
   return RETURN_UNSUPPORTED;\r
 }\r
+\r
+/**\r
+  Retrieves handlers of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER and \r
+  EXTRACT_GUIDED_SECTION_DECODE_HANDLER for a specific GUID section type.\r
+  \r
+  Retrieves the handlers associated with SectionGuid and returns them in \r
+  GetInfoHandler and DecodeHandler.\r
+\r
+  If the GUID value specified by SectionGuid has not been registered, then \r
+  return RETURN_NOT_FOUND.\r
+  \r
+  If SectionGuid is NULL, then ASSERT().\r
+\r
+  @param[in]  SectionGuid    A pointer to the GUID associated with the handlersof the GUIDed \r
+                             section type being retrieved.\r
+  @param[out] GetInfoHandler Pointer to a function that examines a GUIDed section and returns \r
+                             the size of the decoded buffer and the size of an optional scratch \r
+                             buffer required to actually decode the data in a GUIDed section.  \r
+                             This is an optional parameter that may be NULL. If it is NULL, then \r
+                             the previously registered handler is not returned.\r
+  @param[out] DecodeHandler  Pointer to a function that decodes a GUIDed section into a caller\r
+                             allocated output buffer. This is an optional parameter that may be NULL.\r
+                             If it is NULL, then the previously registered handler is not returned.\r
+\r
+  @retval  RETURN_SUCCESS     The handlers were retrieved.\r
+  @retval  RETURN_NOT_FOUND   No handlers have been registered with the specified GUID.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtractGuidedSectionGetHandlers (\r
+  IN CONST   GUID                                     *SectionGuid,\r
+  OUT        EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER  *GetInfoHandler,  OPTIONAL\r
+  OUT        EXTRACT_GUIDED_SECTION_DECODE_HANDLER    *DecodeHandler    OPTIONAL\r
+  )\r
+{\r
+  UINT32 Index; \r
+\r
+  //\r
+  // Check input parameter.\r
+  //\r
+  ASSERT (SectionGuid != 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], SectionGuid)) {\r
+      \r
+      //\r
+      // If the guided handler has been registered before, then return the registered handlers.\r
+      //\r
+      if (GetInfoHandler != NULL) {\r
+        *GetInfoHandler = mExtractGetInfoHandlerTable[Index];\r
+      }\r
+      if (DecodeHandler != NULL) {\r
+        *DecodeHandler = mExtractDecodeHandlerTable[Index];\r
+      }\r
+      return RETURN_SUCCESS;\r
+    }\r
+  }\r
+  return RETURN_NOT_FOUND;\r
+}\r