]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/Smi.c
MdeModulePkg/PeiCore: Fix ConverSinglePpiPointer () typo.
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / Smi.c
index 62c1cf60732b9b629ad8f7b847b4de8aca74e17f..816d0f51936042bbf1c98b0b72ca3c8169e40a75 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 - 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
@@ -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
@@ -128,45 +128,32 @@ SmiManage (
   LIST_ENTRY   *Head;\r
   SMI_ENTRY    *SmiEntry;\r
   SMI_HANDLER  *SmiHandler;\r
-  BOOLEAN      InterruptQuiesced;\r
+  BOOLEAN      SuccessReturn;\r
   EFI_STATUS   Status;\r
   \r
+  Status = EFI_NOT_FOUND;\r
+  SuccessReturn = 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,54 @@ 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 and HandlerType is not NULL then\r
+      // no additional handlers will be processed and EFI_INTERRUPT_PENDING will be returned.\r
       //\r
-      return EFI_INTERRUPT_PENDING;\r
+      if (HandlerType != NULL) {\r
+        return EFI_INTERRUPT_PENDING;\r
+      }\r
+      break;\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 at least one of the handlers returns EFI_SUCCESS then the function will return\r
+      // EFI_SUCCESS. If a handler returns EFI_SUCCESS and HandlerType is not NULL then no\r
+      // additional handlers will be processed.\r
       //\r
-      return EFI_WARN_INTERRUPT_SOURCE_QUIESCED;\r
+      if (HandlerType != NULL) {\r
+        return EFI_SUCCESS;\r
+      }\r
+      SuccessReturn = TRUE;\r
+      break;\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
+      SuccessReturn = 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
-      InterruptQuiesced = TRUE;\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
+  if (SuccessReturn) {\r
+    Status = EFI_SUCCESS;\r
   }\r
+\r
   return Status;\r
 }\r
 \r