]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/Notify.c
MdeModulePkg PiSmmCore: Update comments in InitializeMemoryServices
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / Notify.c
index 8654f6e459df1085f30b64f665625fb95070fafc..0054fe66aab825cd81903159a05a1960b5b0ec40 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Support functions for UEFI protocol notification infrastructure.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation.  All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available \r
   under the terms and conditions of the BSD License which accompanies this \r
   distribution.  The full text of the license may be found at        \r
@@ -91,9 +91,11 @@ SmmRemoveInterfaceFromProtocol (
   @param  Function               Points to the notification function\r
   @param  Registration           Returns the registration record\r
 \r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter\r
   @retval EFI_SUCCESS            Successfully returned the registration record\r
-                                 that has been added\r
+                                 that has been added or unhooked\r
+  @retval EFI_INVALID_PARAMETER  Protocol is NULL or Registration is NULL\r
+  @retval EFI_OUT_OF_RESOURCES   Not enough memory resource to finish the request\r
+  @retval EFI_NOT_FOUND          If the registration is not found when Function == NULL\r
 \r
 **/\r
 EFI_STATUS\r
@@ -109,10 +111,40 @@ SmmRegisterProtocolNotify (
   LIST_ENTRY       *Link;\r
   EFI_STATUS       Status;\r
 \r
-  if ((Protocol == NULL) || (Function == NULL) || (Registration == NULL))  {\r
+  if (Protocol == NULL || Registration == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  if (Function == NULL) {\r
+       //\r
+    // Get the protocol entry per Protocol\r
+    //\r
+    ProtEntry = SmmFindProtocolEntry ((EFI_GUID *) Protocol, FALSE);\r
+    if (ProtEntry != NULL) {\r
+      ProtNotify = (PROTOCOL_NOTIFY * )*Registration;\r
+      for (Link = ProtEntry->Notify.ForwardLink;\r
+           Link != &ProtEntry->Notify;\r
+           Link = Link->ForwardLink) {\r
+        //\r
+        // Compare the notification record \r
+        //\r
+        if (ProtNotify == (CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE))){\r
+          //\r
+          // If Registration is an existing registration, then unhook it\r
+          //\r
+          ProtNotify->Signature = 0;\r
+          RemoveEntryList (&ProtNotify->Link);\r
+          FreePool (ProtNotify);\r
+          return EFI_SUCCESS;\r
+        }\r
+      }\r
+    }\r
+    //\r
+    // If the registration is not found\r
+    //\r
+    return EFI_NOT_FOUND;\r
+  } \r
+\r
   ProtNotify = NULL;\r
 \r
   //\r