]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/Smi.c
MdeModulePkg PI SMM Core: Unregister handler for SMM Ready To Lock event in SmmReadyT...
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / Smi.c
index 62c1cf60732b9b629ad8f7b847b4de8aca74e17f..1868bbf9e195be969ba07a220ea3b3bdd34ad6b0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SMI management.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2012, 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
@@ -109,10 +109,10 @@ SmmCoreFindSmiEntry (
   @param  CommBuffer     Points to the optional communication buffer.\r
   @param  CommBufferSize Points to the size of the optional communication buffer.\r
 \r
-  @retval EFI_SUCCESS                        Interrupt source was processed successfully but not quiesced.\r
+  @retval EFI_WARN_INTERRUPT_SOURCE_PENDING  Interrupt source was processed successfully but not quiesced.\r
   @retval EFI_INTERRUPT_PENDING              One or more SMI sources could not be quiesced.\r
-  @retval EFI_WARN_INTERRUPT_SOURCE_PENDING  Interrupt source was not handled or quiesced.\r
-  @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED Interrupt source was handled and quiesced.\r
+  @retval EFI_NOT_FOUND                      Interrupt source was not handled or quiesced.\r
+  @retval EFI_SUCCESS                        Interrupt source was handled and quiesced.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -131,42 +131,29 @@ SmiManage (
   BOOLEAN      InterruptQuiesced;\r
   EFI_STATUS   Status;\r
   \r
+  Status = EFI_NOT_FOUND;\r
+  InterruptQuiesced = FALSE;\r
   if (HandlerType == NULL) {\r
     //\r
     // Root SMI handler\r
     //\r
-    Status = EFI_WARN_INTERRUPT_SOURCE_PENDING;\r
 \r
     Head = &mRootSmiHandlerList;\r
-    for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {\r
-      SmiHandler = CR (Link, SMI_HANDLER, Link, SMI_HANDLER_SIGNATURE);\r
-\r
-      Status = SmiHandler->Handler (\r
-                 (EFI_HANDLE) SmiHandler,\r
-                 Context,\r
-                 CommBuffer,\r
-                 CommBufferSize\r
-                 );\r
-      if (Status == EFI_SUCCESS || Status == EFI_INTERRUPT_PENDING) {\r
-        return Status;\r
-      }\r
-    }\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Non-root SMI handler\r
-  //\r
-  SmiEntry = SmmCoreFindSmiEntry ((EFI_GUID *) HandlerType, FALSE);\r
-  if (SmiEntry == NULL) {\r
+  } else {\r
     //\r
-    // There is no handler registered for this interrupt source\r
+    // Non-root SMI handler\r
     //\r
-    return EFI_WARN_INTERRUPT_SOURCE_PENDING;\r
+    SmiEntry = SmmCoreFindSmiEntry ((EFI_GUID *) HandlerType, FALSE);\r
+    if (SmiEntry == NULL) {\r
+      //\r
+      // There is no handler registered for this interrupt source\r
+      //\r
+      return Status;\r
+    }\r
+\r
+    Head = &SmiEntry->SmiHandlers;\r
   }\r
 \r
-  InterruptQuiesced = FALSE;\r
-  Head = &SmiEntry->SmiHandlers;\r
   for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {\r
     SmiHandler = CR (Link, SMI_HANDLER, Link, SMI_HANDLER_SIGNATURE);\r
 \r
@@ -180,42 +167,46 @@ SmiManage (
     switch (Status) {\r
     case EFI_INTERRUPT_PENDING:\r
       //\r
-      // If a handler returns EFI_INTERRUPT_PENDING, the interrupt could not be\r
-      // quiesced, then no additional handlers will be processed,\r
-      // and EFI_INTERRUPT_PENDING will be returned\r
+      // If a handler returns EFI_INTERRUPT_PENDING then no additional handlers \r
+      // will be processed and EFI_INTERRUPT_PENDING will be returned.\r
       //\r
       return EFI_INTERRUPT_PENDING;\r
 \r
     case EFI_SUCCESS:\r
       //\r
-      // If handler return EFI_SUCCESS, the interrupt was handled and quiesced,\r
-      // no other handlers should still be called,\r
-      // and EFI_WARN_INTERRUPT_SOURCE_QUIESCED will be returned\r
+      // If a handler returns EFI_SUCCESS then no additional handlers will be processed.\r
+      // then the function will return EFI_SUCCESS.\r
       //\r
-      return EFI_WARN_INTERRUPT_SOURCE_QUIESCED;\r
+      return EFI_SUCCESS;\r
 \r
     case EFI_WARN_INTERRUPT_SOURCE_QUIESCED:\r
       //\r
-      // If at least one of the handlers report EFI_WARN_INTERRUPT_SOURCE_QUIESCED,\r
-      // then this function will return EFI_WARN_INTERRUPT_SOURCE_QUIESCED\r
+      // If at least one of the handlers returns EFI_WARN_INTERRUPT_SOURCE_QUIESCED\r
+      // then the function will return EFI_SUCCESS. \r
       //\r
       InterruptQuiesced = TRUE;\r
       break;\r
 \r
+    case EFI_WARN_INTERRUPT_SOURCE_PENDING:\r
+      //\r
+      // If all the handlers returned EFI_WARN_INTERRUPT_SOURCE_PENDING\r
+      // then EFI_WARN_INTERRUPT_SOURCE_PENDING will be returned.\r
+      //\r
+      break;\r
+\r
     default:\r
+      //\r
+      // Unexpected status code returned.\r
+      //\r
+      ASSERT (FALSE);\r
       break;\r
     }\r
   }\r
 \r
   if (InterruptQuiesced) {\r
-    Status = EFI_WARN_INTERRUPT_SOURCE_QUIESCED;\r
-  } else {\r
-    //\r
-    // If no handler report EFI_WARN_INTERRUPT_SOURCE_QUIESCED, then this\r
-    // function will return EFI_INTERRUPT_PENDING\r
-    //\r
-    Status = EFI_INTERRUPT_PENDING;\r
+    Status = EFI_SUCCESS;\r
   }\r
+\r
   return Status;\r
 }\r
 \r