]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
1. Add two performance measurement points for SMM performance measurement;
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / PiSmmCore.c
index 0a50b5b70e1fdc8570915f0d17aea35797191c47..a5e4b6e9803f229fdd8dbc56ea1444216b2d3d98 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SMM Core Main Entry Point\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation.  All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2011, 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
@@ -245,13 +245,19 @@ SmmEntryPoint (
 {\r
   EFI_STATUS                  Status;\r
   EFI_SMM_COMMUNICATE_HEADER  *CommunicateHeader;\r
-  BOOLEAN                     OldInSmm;\r
+\r
+  PERF_START (NULL, "SMM", NULL, 0) ;\r
 \r
   //\r
   // Update SMST using the context\r
   //\r
   CopyMem (&gSmmCoreSmst.SmmStartupThisAp, SmmEntryContext, sizeof (EFI_SMM_ENTRY_CONTEXT));\r
 \r
+  //\r
+  // Call platform hook before Smm Dispatch\r
+  //\r
+  PlatformHookBeforeSmmDispatch ();\r
+\r
   //\r
   // If a legacy boot has occured, then make sure gSmmCorePrivate is not accessed\r
   //\r
@@ -264,9 +270,8 @@ SmmEntryPoint (
   }\r
 \r
   //\r
-  // Save current InSmm state and set InSmm state to TRUE, it will be used by SmmBase2 protocol\r
+  // Mark the InSmm flag as TRUE, it will be used by SmmBase2 protocol\r
   //\r
-  OldInSmm = gSmmCorePrivate->InSmm;\r
   gSmmCorePrivate->InSmm = TRUE;\r
 \r
   //\r
@@ -278,19 +283,19 @@ SmmEntryPoint (
     // Synchronous SMI for SMM Core or request from Communicate protocol\r
     //\r
     CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *)gSmmCorePrivate->CommunicationBuffer;\r
-    *gSmmCorePrivate->BufferSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);\r
+    gSmmCorePrivate->BufferSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);\r
     Status = SmiManage (\r
                &CommunicateHeader->HeaderGuid, \r
                NULL, \r
                CommunicateHeader->Data, \r
-               gSmmCorePrivate->BufferSize\r
+               &gSmmCorePrivate->BufferSize\r
                );\r
 \r
     //\r
     // Update CommunicationBuffer, BufferSize and ReturnStatus\r
     // Communicate service finished, reset the pointer to CommBuffer to NULL\r
     //\r
-    *gSmmCorePrivate->BufferSize += OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);\r
+    gSmmCorePrivate->BufferSize += OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);\r
     gSmmCorePrivate->CommunicationBuffer = NULL;\r
     gSmmCorePrivate->ReturnStatus = (Status == EFI_WARN_INTERRUPT_SOURCE_QUIESCED) ? EFI_SUCCESS : EFI_NOT_FOUND;\r
   } else {\r
@@ -299,11 +304,18 @@ SmmEntryPoint (
     //\r
     SmiManage (NULL, NULL, NULL, NULL);\r
   }\r
+  \r
+  //\r
+  // Call platform hook after Smm Dispatch\r
+  //\r
+  PlatformHookAfterSmmDispatch ();\r
 \r
   //\r
-  // Restore original InSmm state as we are going to leave SMM\r
+  // Clear the InSmm flag as we are going to leave SMM\r
   //\r
-  gSmmCorePrivate->InSmm = OldInSmm;\r
+  gSmmCorePrivate->InSmm = FALSE;\r
+\r
+  PERF_END (NULL, "SMM", NULL, 0) ;\r
 }\r
 \r
 /**\r