]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Modify the implementation of performance library so that:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 28 Aug 2006 08:36:01 +0000 (08:36 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 28 Aug 2006 08:36:01 +0000 (08:36 +0000)
PcdPerformanceLibraryPropertyMask can turn on/off performance measurement.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1395 6f19259b-4bc3-4df7-8a09-765794883524

EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
EdkModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c
EdkModulePkg/Library/DxePerformanceLib/DxePerformanceLib.msa

index 5874902e2e37c0f6521a6bc3bb08a06887ca4bd7..64c7454c662631a9b97282493bbab4a0d9849542 100644 (file)
@@ -236,7 +236,7 @@ StartGauge (
     //\r
     mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize);\r
     \r
-    gBS->FreePool (OldGaugeData); \r
+    FreePool (OldGaugeData); \r
   }\r
   \r
   GaugeEntryArray               = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);\r
@@ -421,6 +421,12 @@ DxeCorePerformanceLibConstructor (
 {\r
   EFI_STATUS                Status;\r
 \r
+  if (!PerformanceMeasurementEnabled ()) {\r
+    //\r
+    // Do not initialize performance infrastructure if not required.\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
   //\r
   // Install the protocol interfaces.\r
   //\r
index 8a3ac4053f1813133ec3b4d096263840f2d79e95..74d71c54d96afde54feb5ff61e227263b14b74af 100644 (file)
@@ -27,24 +27,30 @@ STATIC PERFORMANCE_PROTOCOL    *mPerformance = NULL;
   The constructor function locates Performance protocol from protocol database.\r
   It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
 \r
-  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
-  @param  SystemTable   A pointer to the EFI System Table.\r
-  \r
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+  @retval EFI_SUCCESS     Performance protocol is successfully located.\r
+  @retval Other           Performance protocol is not located to log performance.  \r
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
-PerformanceLibConstructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
+GetPerformanceProtocol (\r
+  VOID\r
   )\r
 {\r
   EFI_STATUS            Status;\r
+  PERFORMANCE_PROTOCOL  *Performance;\r
+\r
+  if (mPerformance != NULL) {\r
+    return EFI_SUCCESS;\r
+  }\r
 \r
-  Status = gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID **) &mPerformance);\r
-  ASSERT_EFI_ERROR (Status);\r
-  ASSERT (mPerformance != NULL);\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
+  }\r
 \r
   return Status;\r
 }\r
@@ -79,9 +85,14 @@ StartPerformanceMeasurement (
   )\r
 {\r
   EFI_STATUS  Status;\r
+\r
+  Status = GetPerformanceProtocol ();\r
+  if (EFI_ERROR (Status)) {\r
+    return RETURN_OUT_OF_RESOURCES;\r
+  }\r
   \r
   Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp);\r
-\r
+  \r
   return (RETURN_STATUS) Status;\r
 }\r
 \r
@@ -119,6 +130,11 @@ EndPerformanceMeasurement (
 {\r
   EFI_STATUS  Status;\r
 \r
+  Status = GetPerformanceProtocol ();\r
+  if (EFI_ERROR (Status)) {\r
+    return RETURN_NOT_FOUND;\r
+  }\r
+\r
   Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp);\r
 \r
   return (RETURN_STATUS) Status;\r
@@ -181,6 +197,11 @@ GetPerformanceMeasurement (
   ASSERT (StartTimeStamp != NULL);\r
   ASSERT (EndTimeStamp != NULL);\r
 \r
+  Status = GetPerformanceProtocol ();\r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
   Status = mPerformance->GetGauge (LogEntryKey++, &GaugeData);\r
   \r
   //\r
index 3ec7a0b6efd080623549a4e88283646c209e2457..3be18f90ddc77d7fd7ba1952ff6579f56461be9a 100644 (file)
@@ -63,9 +63,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   <Externs>\r
     <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
     <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
-    <Extern>\r
-      <Constructor>PerformanceLibConstructor</Constructor>\r
-    </Extern>\r
   </Externs>\r
   <PcdCoded>\r
     <PcdEntry PcdItemType="FIXED_AT_BUILD">\r