]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/Notify.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / Notify.c
index eb5059dd7038407edd5565a57ded8782edb0d0f6..8e078f7572aa8aabed5ee6b6c66423fb1ae47634 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   Support functions for UEFI protocol notification infrastructure.\r
 \r
-  Copyright (c) 2009 - 2010, 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
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -91,9 +85,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 +105,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