]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c
MdeModulePkg: Update PerformanceLib instances not to check Identifier.
[mirror_edk2.git] / MdeModulePkg / Library / DxeSmmPerformanceLib / DxeSmmPerformanceLib.c
index 3c69ceeb7d6a0297a2a5fff7d8f60bd5c2f91902..218cf8b4a7977ab5b86c4e7c5049b5a074e51b85 100644 (file)
@@ -5,7 +5,7 @@
   StartPerformanceMeasurement(), EndPerformanceMeasurement(), StartPerformanceMeasurementEx()\r
   and EndPerformanceMeasurementEx() are not implemented.\r
 \r
-  Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -41,6 +41,9 @@ UINTN                           mGaugeNumberOfEntries = 0;
 GAUGE_DATA_ENTRY_EX             *mGaugeDataEx = NULL;\r
 UINTN                           mGaugeNumberOfEntriesEx = 0;\r
 \r
+BOOLEAN                         mNoSmmPerfHandler = FALSE;\r
+BOOLEAN                         mNoSmmPerfExHandler = FALSE;\r
+\r
 //\r
 // The cached Performance Protocol and PerformanceEx Protocol interface.\r
 //\r
@@ -163,7 +166,7 @@ StartPerformanceMeasurementEx (
 /**\r
   Fills in the end time of a performance measurement.\r
 \r
-  Looks up the record that matches Handle, Token, Module and Identifier.\r
+  Looks up the record that matches Handle, Token and Module.\r
   If the record can not be found then return RETURN_NOT_FOUND.\r
   If the record is found and TimeStamp is not zero,\r
   then TimeStamp is added to the record as the end time.\r
@@ -372,7 +375,7 @@ GetByPerformanceProtocol (
                                   On exit, the key of the next performance log entry.\r
 \r
   @retval !NULL           Get all gauge data success.\r
-  @retval NULL            Get all guage data failed.\r
+  @retval NULL            Get all gauge data failed.\r
 **/\r
 GAUGE_DATA_ENTRY *\r
 EFIAPI\r
@@ -386,13 +389,21 @@ GetAllSmmGaugeData (
   UINTN                       CommSize;\r
   UINTN                       DataSize;\r
 \r
+  if (mNoSmmPerfHandler) {\r
+    //\r
+    // Not try to get the SMM gauge data again\r
+    // if no SMM Performance handler found.\r
+    //\r
+    return NULL;\r
+  }\r
+\r
   if (LogEntryKey != 0) {\r
     if (mGaugeData != NULL) {\r
       return mGaugeData;\r
     }\r
   } else {\r
     //\r
-    // Reget the SMM guage data at the first entry get.\r
+    // Reget the SMM gauge data at the first entry get.\r
     //\r
     if (mGaugeData != NULL) {\r
       FreePool (mGaugeData);\r
@@ -418,10 +429,13 @@ GetAllSmmGaugeData (
   CommSize = SMM_PERFORMANCE_COMMUNICATION_BUFFER_SIZE;\r
 \r
   //\r
-  // Get totol number of SMM gauge entries\r
+  // Get total number of SMM gauge entries\r
   //\r
   SmmPerfCommData->Function = SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER;\r
   Status = mSmmCommunication->Communicate (mSmmCommunication, mSmmPerformanceBuffer, &CommSize);\r
+  if (Status == EFI_NOT_FOUND) {\r
+    mNoSmmPerfHandler = TRUE;\r
+  }\r
   if (EFI_ERROR (Status) || EFI_ERROR (SmmPerfCommData->ReturnStatus) || SmmPerfCommData->NumberOfEntries == 0) {\r
     return NULL;\r
   }\r
@@ -459,7 +473,7 @@ GetAllSmmGaugeData (
                                   On exit, the key of the next performance log entry.\r
 \r
   @retval !NULL           Get all gauge data success.\r
-  @retval NULL            Get all guage data failed.\r
+  @retval NULL            Get all gauge data failed.\r
 **/\r
 GAUGE_DATA_ENTRY_EX *\r
 EFIAPI\r
@@ -473,13 +487,21 @@ GetAllSmmGaugeDataEx (
   UINTN                       CommSize;\r
   UINTN                       DataSize;\r
 \r
+  if (mNoSmmPerfExHandler) {\r
+    //\r
+    // Not try to get the SMM gauge data again\r
+    // if no SMM PerformanceEx handler found.\r
+    //\r
+    return NULL;\r
+  }\r
+\r
   if (LogEntryKey != 0) {\r
     if (mGaugeDataEx != NULL) {\r
       return mGaugeDataEx;\r
     }\r
   } else {\r
     //\r
-    // Reget the SMM guage data at the first entry get.\r
+    // Reget the SMM gauge data at the first entry get.\r
     //\r
     if (mGaugeDataEx != NULL) {\r
       FreePool (mGaugeDataEx);\r
@@ -505,10 +527,13 @@ GetAllSmmGaugeDataEx (
   CommSize = SMM_PERFORMANCE_COMMUNICATION_BUFFER_SIZE;\r
 \r
   //\r
-  // Get totol number of SMM gauge entries\r
+  // Get total number of SMM gauge entries\r
   //\r
   SmmPerfCommData->Function = SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER;\r
   Status = mSmmCommunication->Communicate (mSmmCommunication, mSmmPerformanceBuffer, &CommSize);\r
+  if (Status == EFI_NOT_FOUND) {\r
+    mNoSmmPerfExHandler = TRUE;\r
+  }\r
   if (EFI_ERROR (Status) || EFI_ERROR (SmmPerfCommData->ReturnStatus) || SmmPerfCommData->NumberOfEntries == 0) {\r
     return NULL;\r
   }\r
@@ -658,7 +683,15 @@ GetPerformanceMeasurementEx (
       GaugeData = (GAUGE_DATA_ENTRY_EX *) &mGaugeData[LogEntryKey++];\r
       *Identifier = 0;\r
     } else {\r
-      return 0;\r
+      return GetByPerformanceProtocol (\r
+               LogEntryKey,\r
+               Handle,\r
+               Token,\r
+               Module,\r
+               StartTimeStamp,\r
+               EndTimeStamp,\r
+               Identifier\r
+               );\r
     }\r
   }\r
 \r