]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.c
Update ExtractGuidedSectionLib instance to cover the same handler is registered multi...
[mirror_edk2.git] / MdePkg / Library / PeiExtractGuidedSectionLib / PeiExtractGuidedSectionLib.c
index bbe6b508727eca6cfb938edd77f0f2565cd499cd..ce42a5dcd21cfcffe155cdf8624a6587e1630128 100644 (file)
@@ -151,6 +151,7 @@ ExtractGuidedSectionRegisterHandlers (
   )\r
 {\r
   EFI_STATUS Status;\r
+  UINT32     Index;\r
   PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;\r
 \r
   //\r
@@ -167,6 +168,25 @@ ExtractGuidedSectionRegisterHandlers (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
+\r
+  //\r
+  // Search the match registered GetInfo handler for the input guided section.\r
+  //\r
+  for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {\r
+    if (CompareGuid (&(HandlerInfo->ExtractHandlerGuidTable[Index]), SectionGuid)) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  //\r
+  // If the guided handler has been registered before, only update its handler.\r
+  //\r
+  if (Index < HandlerInfo->NumberOfExtractHandler) {\r
+    HandlerInfo->ExtractDecodeHandlerTable [Index] = DecodeHandler;\r
+    HandlerInfo->ExtractGetInfoHandlerTable [Index] = GetInfoHandler;\r
+    return RETURN_SUCCESS;\r
+  }\r
+\r
   //\r
   // Check the global table is enough to contain new Handler.\r
   //\r