]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/Notify.c
Support unhook notification function for Smst->SmmRegisterProtocolNotify() per PI...
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / Notify.c
index eb5059dd7038407edd5565a57ded8782edb0d0f6..5ec0aa71a86fc2eb534b15ae01e11f1502f545a4 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 - 2013, 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
@@ -94,6 +94,8 @@ SmmRemoveInterfaceFromProtocol (
   @retval EFI_INVALID_PARAMETER  Invalid parameter\r
   @retval EFI_SUCCESS            Successfully returned the registration record\r
                                  that has been added\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