]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
Close the corresponding GUIDed section extraction protocol notify event in CloseSecti...
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / SectionExtraction / CoreSectionExtraction.c
index 8d8f9c8641d00b3f38a87013708dd84d13b2365e..40304b925c992929388492e8d56e0dab536e0c09 100644 (file)
@@ -66,6 +66,11 @@ typedef struct {
   //\r
   UINTN                       EncapsulatedStreamHandle;\r
   EFI_GUID                    *EncapsulationGuid;\r
+  //\r
+  // If the section REQUIRES an extraction protocol, register for RPN \r
+  // when the required GUIDed extraction protocol becomes available.\r
+  //\r
+  EFI_EVENT                   Event;\r
 } CORE_SECTION_CHILD_NODE;\r
 \r
 #define CORE_SECTION_STREAM_SIGNATURE SIGNATURE_32('S','X','S','S')\r
@@ -91,7 +96,6 @@ typedef struct {
   CORE_SECTION_CHILD_NODE     *ChildNode;\r
   CORE_SECTION_STREAM_NODE    *ParentStream;\r
   VOID                        *Registration;\r
-  EFI_EVENT                   Event;\r
 } RPN_EVENT_CONTEXT;\r
 \r
 \r
@@ -558,6 +562,7 @@ NotifyGuidedExtraction (
   //  Close the event when done.\r
   //\r
   gBS->CloseEvent (Event);\r
+  Context->ChildNode->Event = NULL;\r
   FreePool (Context);\r
 }  \r
 \r
@@ -585,13 +590,13 @@ CreateGuidedExtractionRpnEvent (
   Context->ChildNode = ChildNode;\r
   Context->ParentStream = ParentStream;\r
  \r
-  Context->Event = EfiCreateProtocolNotifyEvent (\r
-                    Context->ChildNode->EncapsulationGuid,\r
-                    TPL_NOTIFY,\r
-                    NotifyGuidedExtraction,\r
-                    Context,\r
-                    &Context->Registration\r
-                    );\r
+  Context->ChildNode->Event = EfiCreateProtocolNotifyEvent (\r
+                                Context->ChildNode->EncapsulationGuid,\r
+                                TPL_NOTIFY,\r
+                                NotifyGuidedExtraction,\r
+                                Context,\r
+                                &Context->Registration\r
+                                );\r
 }\r
 \r
 /**\r
@@ -646,7 +651,7 @@ CreateChildNode (
   //\r
   // Allocate a new node\r
   //\r
-  *ChildNode = AllocatePool (sizeof (CORE_SECTION_CHILD_NODE));\r
+  *ChildNode = AllocateZeroPool (sizeof (CORE_SECTION_CHILD_NODE));\r
   Node = *ChildNode;\r
   if (Node == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -1289,6 +1294,11 @@ FreeChildNode (
     //\r
     CloseSectionStream (ChildNode->EncapsulatedStreamHandle);\r
   }\r
+\r
+  if (ChildNode->Event != NULL) {\r
+    gBS->CloseEvent (ChildNode->Event);\r
+  }\r
+\r
   //\r
   // Last, free the child node itself\r
   //\r