]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Library / DxeCorePerformanceLib / DxeCorePerformanceLib.c
index 9772f9732522e0c0608a474801434356f921b772..1cf4fb1da34f8f0c294895b9d8bf770f9d7cd984 100644 (file)
@@ -1,8 +1,17 @@
 /** @file\r
-  Support for measurement of DXE performance\r
+  Performance library instance mainly used by DxeCore.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+  This library provides the performance measurement interfaces and initializes performance\r
+  logging for DXE phase. It first initializes its private global data structure for\r
+  performance logging and saves the performance GUIDed HOB passed from PEI phase. \r
+  It initializes DXE phase performance logging by publishing the Performance Protocol,\r
+  which is consumed by DxePerformanceLib to logging performance data in DXE phase.\r
+\r
+  This library is mainly used by DxeCore to start performance logging to ensure that\r
+  Performance Protocol is installed at the very beginning of DXE phase.\r
+\r
+Copyright (c) 2006 - 2008, 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
 http://opensource.org/licenses/bsd-license.php\r
@@ -13,131 +22,35 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 \r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/Performance.h>\r
-#include <Guid/PeiPerformanceHob.h>\r
+#include "DxeCorePerformanceLibInternal.h"\r
 \r
-#include <Library/PerformanceLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/TimerLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
 \r
 //\r
-// Interface declarations for Performance Protocol.\r
+// The data structure to hold global performance data.\r
 //\r
-/**\r
-  Adds a record at the end of the performance measurement log\r
-  that records the start time of a performance measurement.\r
-\r
-  Adds a record to the end of the performance measurement log\r
-  that contains the Handle, Token, and Module.\r
-  The end time of the new record must be set to zero.\r
-  If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.\r
-  If TimeStamp is zero, the start time in the record is filled in with the value\r
-  read from the current time stamp.\r
-\r
-  @param  Handle                  Pointer to environment specific context used\r
-                                  to identify the component being measured.\r
-  @param  Token                   Pointer to a Null-terminated ASCII string\r
-                                  that identifies the component being measured.\r
-  @param  Module                  Pointer to a Null-terminated ASCII string\r
-                                  that identifies the module being measured.\r
-  @param  TimeStamp               64-bit time stamp.\r
-\r
-  @retval EFI_SUCCESS             The data was read correctly from the device.\r
-  @retval EFI_OUT_OF_RESOURCES    There are not enough resources to record the measurement.\r
-\r
-**/\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-StartGauge (\r
-  IN CONST VOID   *Handle,  OPTIONAL\r
-  IN CONST CHAR8  *Token,   OPTIONAL\r
-  IN CONST CHAR8  *Module,  OPTIONAL\r
-  IN UINT64       TimeStamp\r
-  );\r
-\r
-/**\r
-  Searches the performance measurement log from the beginning of the log\r
-  for the first matching record that contains a zero end time and fills in a valid end time.\r
-\r
-  Searches the performance measurement log from the beginning of the log\r
-  for the first record that matches Handle, Token, and Module and has an end time value of zero.\r
-  If the record can not be found then return EFI_NOT_FOUND.\r
-  If the record is found and TimeStamp is not zero,\r
-  then the end time in the record is filled in with the value specified by TimeStamp.\r
-  If the record is found and TimeStamp is zero, then the end time in the matching record\r
-  is filled in with the current time stamp value.\r
-\r
-  @param  Handle                  Pointer to environment specific context used\r
-                                  to identify the component being measured.\r
-  @param  Token                   Pointer to a Null-terminated ASCII string\r
-                                  that identifies the component being measured.\r
-  @param  Module                  Pointer to a Null-terminated ASCII string\r
-                                  that identifies the module being measured.\r
-  @param  TimeStamp               64-bit time stamp.\r
-\r
-  @retval EFI_SUCCESS             The end of  the measurement was recorded.\r
-  @retval EFI_NOT_FOUND           The specified measurement record could not be found.\r
-\r
-**/\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-EndGauge (\r
-  IN CONST VOID   *Handle,  OPTIONAL\r
-  IN CONST CHAR8  *Token,   OPTIONAL\r
-  IN CONST CHAR8  *Module,  OPTIONAL\r
-  IN UINT64       TimeStamp\r
-  );\r
-\r
-/**\r
-  Retrieves a previously logged performance measurement.\r
-\r
-  Retrieves the performance log entry from the performance log specified by LogEntryKey.\r
-  If it stands for a valid entry, then EFI_SUCCESS is returned and\r
-  GaugeDataEntry stores the pointer to that entry.\r
-\r
-  @param  LogEntryKey             The key for the previous performance measurement log entry.\r
-                                  If 0, then the first performance measurement log entry is retrieved.\r
-  @param  GaugeDataEntry          The indirect pointer to the gauge data entry specified by LogEntryKey\r
-                                  if the retrieval is successful.\r
-\r
-  @retval EFI_SUCCESS             The GuageDataEntry is successfuly found based on LogEntryKey.\r
-  @retval EFI_NOT_FOUND           The LogEntryKey is the last entry (equals to the total entry number).\r
-  @retval EFI_INVALIDE_PARAMETER  The LogEntryKey is not a valid entry (greater than the total entry number).\r
-  @retval EFI_INVALIDE_PARAMETER  GaugeDataEntry is NULL.\r
-\r
-**/\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-GetGauge (\r
-  IN  UINTN               LogEntryKey,\r
-  OUT GAUGE_DATA_ENTRY    **GaugeDataEntry\r
-  );\r
+GAUGE_DATA_HEADER    *mGaugeData;\r
 \r
 //\r
-// Definition for global variables.\r
+// The current maximum number of logging entries. If current number of \r
+// entries exceeds this value, it will re-allocate a larger array and\r
+// migration the old data to the larger array.\r
 //\r
-STATIC GAUGE_DATA_HEADER    *mGaugeData;\r
-STATIC UINT32               mMaxGaugeRecords;\r
+UINT32               mMaxGaugeRecords;\r
 \r
+//\r
+// The handle to install Performance Protocol instance.\r
+//\r
 EFI_HANDLE           mHandle = NULL;\r
+\r
+//\r
+// Interfaces for performance protocol.\r
+//\r
 PERFORMANCE_PROTOCOL mPerformanceInterface = {\r
   StartGauge,\r
   EndGauge,\r
   GetGauge\r
   };\r
 \r
-\r
 /**\r
   Searches in the gauge array with keyword Handle, Token and Module.\r
 \r
@@ -156,7 +69,6 @@ PERFORMANCE_PROTOCOL mPerformanceInterface = {
   @retval The index of gauge entry in the array.\r
 \r
 **/\r
-STATIC\r
 UINT32\r
 InternalSearchForGaugeEntry (\r
   IN CONST VOID                 *Handle,  OPTIONAL\r
@@ -214,7 +126,6 @@ InternalSearchForGaugeEntry (
   @retval EFI_OUT_OF_RESOURCES    There are not enough resources to record the measurement.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 StartGauge (\r
@@ -233,7 +144,7 @@ StartGauge (
   Index = mGaugeData->NumberOfEntries;\r
   if (Index >= mMaxGaugeRecords) {\r
     //\r
-    // Try to enlarge the scale of gauge arrary.\r
+    // Try to enlarge the scale of gauge array.\r
     //\r
     OldGaugeData      = mGaugeData;\r
     OldGaugeDataSize  = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;\r
@@ -246,7 +157,7 @@ StartGauge (
       return EFI_OUT_OF_RESOURCES;\r
     }\r
     //\r
-    // Initialize new data arry and migrate old data one.\r
+    // Initialize new data array and migrate old data one.\r
     //\r
     mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize);\r
 \r
@@ -297,7 +208,6 @@ StartGauge (
   @retval EFI_NOT_FOUND           The specified measurement record could not be found.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 EndGauge (\r
@@ -336,13 +246,12 @@ EndGauge (
   @param  GaugeDataEntry          The indirect pointer to the gauge data entry specified by LogEntryKey\r
                                   if the retrieval is successful.\r
 \r
-  @retval EFI_SUCCESS             The GuageDataEntry is successfuly found based on LogEntryKey.\r
+  @retval EFI_SUCCESS             The GuageDataEntry is successfully found based on LogEntryKey.\r
   @retval EFI_NOT_FOUND           The LogEntryKey is the last entry (equals to the total entry number).\r
   @retval EFI_INVALIDE_PARAMETER  The LogEntryKey is not a valid entry (greater than the total entry number).\r
   @retval EFI_INVALIDE_PARAMETER  GaugeDataEntry is NULL.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 GetGauge (\r
@@ -379,7 +288,6 @@ GetGauge (
   to DXE performance data structures.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 InternalGetPeiPerformance (\r
   VOID\r
@@ -398,7 +306,7 @@ InternalGetPeiPerformance (
   //\r
   // Dump PEI Log Entries to DXE Guage Data structure.\r
   //\r
-  GuidHob = GetFirstGuidHob (&gPeiPerformanceHobGuid);\r
+  GuidHob = GetFirstGuidHob (&gPerformanceProtocolGuid);\r
   if (GuidHob != NULL) {\r
     LogHob          = GET_GUID_HOB_DATA (GuidHob);\r
     LogEntryArray   = (PEI_PERFORMANCE_LOG_ENTRY *) (LogHob + 1);\r
@@ -564,7 +472,7 @@ EndPerformanceMeasurement (
 \r
   @param  LogEntryKey             On entry, the key of the performance measurement log entry to retrieve.\r
                                   0, then the first performance measurement log entry is retrieved.\r
-                                  On exit, the key of the next performance lof entry entry.\r
+                                  On exit, the key of the next performance log entry.\r
   @param  Handle                  Pointer to environment specific context used to identify the component\r
                                   being measured.\r
   @param  Token                   Pointer to a Null-terminated ASCII string that identifies the component\r