]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.c
MdePkg/ProcessorBind: add defines for page allocation granularity
[mirror_edk2.git] / MdePkg / Library / PeiExtractGuidedSectionLib / PeiExtractGuidedSectionLib.c
index fa382ae3c80e449c6f30e111c162335aa8a459c1..d7bc98b180229c6314910b71243c3a7a2c6f44f4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provide generic extract guided section functions for PEI 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
@@ -156,6 +156,7 @@ ExtractGuidedSectionGetGuidList (
   //\r
   // Get GuidTable and Table Number\r
   //\r
+  ASSERT (HandlerInfo != NULL);\r
   *ExtractHandlerGuidTable = HandlerInfo->ExtractHandlerGuidTable;\r
   return HandlerInfo->NumberOfExtractHandler;\r
 }\r
@@ -197,7 +198,7 @@ ExtractGuidedSectionRegisterHandlers (
   PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r
 \r
   //\r
-  // Check input paramter\r
+  // Check input parameter\r
   //\r
   ASSERT (SectionGuid != NULL);\r
   ASSERT (GetInfoHandler != NULL);\r
@@ -216,6 +217,7 @@ ExtractGuidedSectionRegisterHandlers (
   //\r
   // Search the match registered GetInfo handler for the input guided section.\r
   //\r
+  ASSERT (HandlerInfo != NULL);\r
   for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r
     if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionGuid)) {\r
       //\r
@@ -241,6 +243,16 @@ ExtractGuidedSectionRegisterHandlers (
   HandlerInfo->ExtractDecodeHandlerTable [HandlerInfo->NumberOfExtractHandler] = DecodeHandler;\r
   HandlerInfo->ExtractGetInfoHandlerTable [HandlerInfo->NumberOfExtractHandler++] = GetInfoHandler;\r
 \r
+  //\r
+  // Build the Guided Section GUID HOB to record the GUID itself.\r
+  // Then the content of the GUIDed HOB will be the same as the GUID value itself.\r
+  //\r
+  BuildGuidDataHob (\r
+    (EFI_GUID *) SectionGuid,\r
+    (VOID *) SectionGuid,\r
+    sizeof (GUID)\r
+    );\r
+\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -290,9 +302,10 @@ ExtractGuidedSectionGetInfo (
   UINT32 Index;\r
   EFI_STATUS Status;\r
   PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r
+  EFI_GUID *SectionDefinitionGuid;\r
   \r
   //\r
-  // Check input paramter\r
+  // Check input parameter\r
   //\r
   ASSERT (InputSection != NULL);\r
   ASSERT (OutputBufferSize != NULL);\r
@@ -306,12 +319,19 @@ ExtractGuidedSectionGetInfo (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  \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
+  ASSERT (HandlerInfo != NULL);\r
   for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r
-    if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
+    if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionDefinitionGuid)) {\r
       //\r
       // Call the match handler to get information for the input section data.\r
       //\r
@@ -377,6 +397,7 @@ ExtractGuidedSectionDecode (
   UINT32     Index;\r
   EFI_STATUS Status;\r
   PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r
+  EFI_GUID *SectionDefinitionGuid;\r
   \r
   //\r
   // Check input parameter\r
@@ -393,11 +414,18 @@ ExtractGuidedSectionDecode (
     return Status;\r
   }\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
+  ASSERT (HandlerInfo != NULL);\r
   for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r
-    if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {\r
+    if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionDefinitionGuid)) {\r
       //\r
       // Call the match handler to extract raw data for the input guided section.\r
       //\r