]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c
MdeModulePkg: Update Performance instances to use new protocol
[mirror_edk2.git] / MdeModulePkg / Library / DxePerformanceLib / DxePerformanceLib.c
index cb62d522f3d606dc7be6cfa2e6337bf2a59f6907..9ed50d22b8d42b0ff4ad4a2c2675e5bc676fb340 100644 (file)
@@ -20,7 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <PiDxe.h>\r
 \r
-#include <Guid/Performance.h>\r
+#include <Guid/PerformanceMeasurement.h>\r
 \r
 #include <Library/PerformanceLib.h>\r
 #include <Library/DebugLib.h>\r
@@ -30,8 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 // The cached Performance Protocol and PerformanceEx Protocol interface.\r
 //\r
-PERFORMANCE_PROTOCOL        *mPerformance = NULL;\r
-PERFORMANCE_EX_PROTOCOL     *mPerformanceEx = NULL;\r
+EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL      *mPerformanceMeasurement = NULL;\r
 \r
 /**\r
   The function caches the pointers to PerformanceEx protocol and Performance Protocol.\r
@@ -43,35 +42,24 @@ PERFORMANCE_EX_PROTOCOL     *mPerformanceEx = NULL;
 \r
 **/\r
 EFI_STATUS\r
-GetPerformanceProtocol (\r
+GetPerformanceMeasurementProtocol (\r
   VOID\r
   )\r
 {\r
   EFI_STATUS                Status;\r
-  PERFORMANCE_PROTOCOL      *Performance;\r
-  PERFORMANCE_EX_PROTOCOL   *PerformanceEx;\r
+  EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL   *PerformanceMeasurement;\r
 \r
-  if (mPerformanceEx != NULL || mPerformance != NULL) {\r
+  if (mPerformanceMeasurement != NULL) {\r
     return EFI_SUCCESS;\r
   }\r
 \r
-  Status = gBS->LocateProtocol (&gPerformanceExProtocolGuid, NULL, (VOID **) &PerformanceEx);\r
+  Status = gBS->LocateProtocol (&gEdkiiPerformanceMeasurementProtocolGuid, NULL, (VOID **) &PerformanceMeasurement);\r
   if (!EFI_ERROR (Status)) {\r
-    ASSERT (PerformanceEx != NULL);\r
+    ASSERT (PerformanceMeasurement != NULL);\r
     //\r
-    // Cache PerformanceEx Protocol.\r
+    // Cache PerformanceMeasurement Protocol.\r
     //\r
-    mPerformanceEx = PerformanceEx;\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Status = gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID **) &Performance);\r
-  if (!EFI_ERROR (Status)) {\r
-    ASSERT (Performance != NULL);\r
-    //\r
-    // Cache performance protocol.\r
-    //\r
-    mPerformance = Performance;\r
+    mPerformanceMeasurement = PerformanceMeasurement;\r
     return EFI_SUCCESS;\r
   }\r
 \r
@@ -110,17 +98,24 @@ StartPerformanceMeasurementEx (
   IN UINT32       Identifier\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
+  EFI_STATUS    Status;\r
+  CONST CHAR8*  String;\r
 \r
-  Status = GetPerformanceProtocol ();\r
+  Status = GetPerformanceMeasurementProtocol ();\r
   if (EFI_ERROR (Status)) {\r
-    return RETURN_OUT_OF_RESOURCES;\r
+    return RETURN_NOT_FOUND;\r
+  }\r
+\r
+  if (Token != NULL) {\r
+    String = Token;\r
+  } else if (Module != NULL) {\r
+    String = Module;\r
+  } else {\r
+    String = NULL;\r
   }\r
 \r
-  if (mPerformanceEx != NULL) {\r
-    Status = mPerformanceEx->StartGaugeEx (Handle, Token, Module, TimeStamp, Identifier);\r
-  } else if (mPerformance != NULL) {\r
-    Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp);\r
+  if (mPerformanceMeasurement != NULL) {\r
+    Status = mPerformanceMeasurement->CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfStartEntry);\r
   } else {\r
     ASSERT (FALSE);\r
   }\r
@@ -162,17 +157,24 @@ EndPerformanceMeasurementEx (
   IN UINT32       Identifier\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
+  EFI_STATUS    Status;\r
+  CONST CHAR8*  String;\r
 \r
-  Status = GetPerformanceProtocol ();\r
+  Status = GetPerformanceMeasurementProtocol ();\r
   if (EFI_ERROR (Status)) {\r
     return RETURN_NOT_FOUND;\r
   }\r
 \r
-  if (mPerformanceEx != NULL) {\r
-    Status = mPerformanceEx->EndGaugeEx (Handle, Token, Module, TimeStamp, Identifier);\r
-  } else if (mPerformance != NULL) {\r
-    Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp);\r
+  if (Token != NULL) {\r
+    String = Token;\r
+  } else if (Module != NULL) {\r
+    String = Module;\r
+  } else {\r
+    String = NULL;\r
+  }\r
+\r
+  if (mPerformanceMeasurement != NULL) {\r
+    Status = mPerformanceMeasurement->CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfEndEntry);\r
   } else {\r
     ASSERT (FALSE);\r
   }\r
@@ -233,58 +235,8 @@ GetPerformanceMeasurementEx (
   OUT UINT32      *Identifier\r
   )\r
 {\r
-  EFI_STATUS            Status;\r
-  GAUGE_DATA_ENTRY_EX   *GaugeData;\r
-\r
-  GaugeData = NULL;\r
-\r
-  ASSERT (Handle != NULL);\r
-  ASSERT (Token != NULL);\r
-  ASSERT (Module != NULL);\r
-  ASSERT (StartTimeStamp != NULL);\r
-  ASSERT (EndTimeStamp != NULL);\r
-  ASSERT (Identifier != NULL);\r
-\r
-  Status = GetPerformanceProtocol ();\r
-  if (EFI_ERROR (Status)) {\r
-    return 0;\r
-  }\r
-\r
-  if (mPerformanceEx != NULL) {\r
-    Status = mPerformanceEx->GetGaugeEx (LogEntryKey++, &GaugeData);\r
-  } else if (mPerformance != NULL) {\r
-    Status = mPerformance->GetGauge (LogEntryKey++, (GAUGE_DATA_ENTRY **) &GaugeData);\r
-  } else {\r
-    ASSERT (FALSE);\r
-    return 0;\r
-  }\r
-\r
-  //\r
-  // Make sure that LogEntryKey is a valid log entry key,\r
-  //\r
-  ASSERT (Status != EFI_INVALID_PARAMETER);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // The LogEntryKey is the last entry (equals to the total entry number).\r
-    //\r
-    return 0;\r
-  }\r
-\r
-  ASSERT (GaugeData != NULL);\r
-\r
-  *Handle         = (VOID *) (UINTN) GaugeData->Handle;\r
-  *Token          = GaugeData->Token;\r
-  *Module         = GaugeData->Module;\r
-  *StartTimeStamp = GaugeData->StartTimeStamp;\r
-  *EndTimeStamp   = GaugeData->EndTimeStamp;\r
-  if (mPerformanceEx != NULL) {\r
-    *Identifier   = GaugeData->Identifier;\r
-  } else {\r
-    *Identifier   = 0;\r
-  }\r
+  return 0;\r
 \r
-  return LogEntryKey;\r
 }\r
 \r
 /**\r
@@ -403,8 +355,7 @@ GetPerformanceMeasurement (
   OUT UINT64      *EndTimeStamp\r
   )\r
 {\r
-  UINT32 Identifier;\r
-  return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, StartTimeStamp, EndTimeStamp, &Identifier);\r
+  return 0;\r
 }\r
 \r
 /**\r