Revision: 14823
          http://sourceforge.net/p/edk2/code/14823
Author:   vanjeff
Date:     2013-11-05 13:32:32 +0000 (Tue, 05 Nov 2013)
Log Message:
-----------
Support unhook notification function for Smst->SmmRegisterProtocolNotify() per 
PI specification.

Signed-off-by: Jeff Fan <[email protected]>
Reviewed-by: Jiewen Yao <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Core/PiSmmCore/Notify.c
    trunk/edk2/MdePkg/Include/Pi/PiSmmCis.h

Modified: trunk/edk2/MdeModulePkg/Core/PiSmmCore/Notify.c
===================================================================
--- trunk/edk2/MdeModulePkg/Core/PiSmmCore/Notify.c     2013-11-04 03:13:54 UTC 
(rev 14822)
+++ trunk/edk2/MdeModulePkg/Core/PiSmmCore/Notify.c     2013-11-05 13:32:32 UTC 
(rev 14823)
@@ -1,7 +1,7 @@
 /** @file
   Support functions for UEFI protocol notification infrastructure.
 
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials are licensed and made available 
   under the terms and conditions of the BSD License which accompanies this 
   distribution.  The full text of the license may be found at        
@@ -94,6 +94,8 @@
   @retval EFI_INVALID_PARAMETER  Invalid parameter
   @retval EFI_SUCCESS            Successfully returned the registration record
                                  that has been added
+  @retval EFI_OUT_OF_RESOURCES   Not enough memory resource to finish the 
request
+  @retval EFI_NOT_FOUND          If the registration is not found when 
Function == NULL
 
 **/
 EFI_STATUS
@@ -109,10 +111,40 @@
   LIST_ENTRY       *Link;
   EFI_STATUS       Status;
 
-  if ((Protocol == NULL) || (Function == NULL) || (Registration == NULL))  {
+  if (Protocol == NULL || Registration == NULL) {
     return EFI_INVALID_PARAMETER;
   }
 
+  if (Function == NULL) {
+       //
+    // Get the protocol entry per Protocol
+    //
+    ProtEntry = SmmFindProtocolEntry ((EFI_GUID *) Protocol, FALSE);
+    if (ProtEntry != NULL) {
+      ProtNotify = (PROTOCOL_NOTIFY * )*Registration;
+      for (Link = ProtEntry->Notify.ForwardLink;
+           Link != &ProtEntry->Notify;
+           Link = Link->ForwardLink) {
+        //
+        // Compare the notification record 
+        //
+        if (ProtNotify == (CR(Link, PROTOCOL_NOTIFY, Link, 
PROTOCOL_NOTIFY_SIGNATURE))){
+          //
+          // If Registration is an existing registration, then unhook it
+          //
+          ProtNotify->Signature = 0;
+          RemoveEntryList (&ProtNotify->Link);
+          FreePool (ProtNotify);
+          return EFI_SUCCESS;
+        }
+      }
+    }
+    //
+    // If the registration is not found
+    //
+    return EFI_NOT_FOUND;
+  } 
+
   ProtNotify = NULL;
 
   //

Modified: trunk/edk2/MdePkg/Include/Pi/PiSmmCis.h
===================================================================
--- trunk/edk2/MdePkg/Include/Pi/PiSmmCis.h     2013-11-04 03:13:54 UTC (rev 
14822)
+++ trunk/edk2/MdePkg/Include/Pi/PiSmmCis.h     2013-11-05 13:32:32 UTC (rev 
14823)
@@ -2,7 +2,7 @@
   Common definitions in the Platform Initialization Specification version 1.2
   VOLUME 4 System Management Mode Core Interface version.
 
-  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -106,6 +106,7 @@
   The SmmRegisterProtocolNotify() function creates a registration Function 
that is to be 
   called whenever a protocol interface is installed for Protocol by 
   SmmInstallProtocolInterface().
+  If Function == NULL and Registration is an existing registration, then the 
callback is unhooked.
 
   @param[in]  Protocol          The unique ID of the protocol for which the 
event is to be registered.
   @param[in]  Function          Points to the notification function.
@@ -114,6 +115,7 @@
   @retval EFI_SUCCESS           Successfully returned the registration record 
that has been added.
   @retval EFI_INVALID_PARAMETER One or more of Protocol, Function and 
Registration is NULL.
   @retval EFI_OUT_OF_RESOURCES  Not enough memory resource to finish the 
request.
+  @retval EFI_NOT_FOUND         If the registration is not found when Function 
== NULL.
 **/
 typedef
 EFI_STATUS

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to