]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c
MdeModulePkg DxeSmmPerformanceLib: Cover no SMM performance data case.
[mirror_edk2.git] / MdeModulePkg / Library / DxeSmmPerformanceLib / DxeSmmPerformanceLib.c
index 3c69ceeb7d6a0297a2a5fff7d8f60bd5c2f91902..3c7cfc17fe742d52ab3aa73064ed9eb3af06696c 100644 (file)
@@ -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
@@ -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