]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Import DxeCorePerformanceLib DxePerformanceLib PeiPerformanceLib and EdkDxePrintLib
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 3 Jul 2007 08:33:07 +0000 (08:33 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 3 Jul 2007 08:33:07 +0000 (08:33 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2995 6f19259b-4bc3-4df7-8a09-765794883524

13 files changed:
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c [new file with mode: 0644]
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf [new file with mode: 0644]
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.msa [new file with mode: 0644]
MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c [new file with mode: 0644]
MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf [new file with mode: 0644]
MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.msa [new file with mode: 0644]
MdeModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.inf [new file with mode: 0644]
MdeModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.msa [new file with mode: 0644]
MdeModulePkg/Library/EdkDxePrintLib/PrintLib.c [new file with mode: 0644]
MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c [new file with mode: 0644]
MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf [new file with mode: 0644]
MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.msa [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dsc

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
new file mode 100644 (file)
index 0000000..bc1a67e
--- /dev/null
@@ -0,0 +1,659 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. 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
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  DxeCorePerformance.c\r
+\r
+Abstract:\r
+\r
+  Support for measurement of DXE performance \r
+\r
+--*/\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/Performance.h>\r
+#include <Guid/PeiPerformanceHob.h>\r
+//\r
+// The Library classes this module consumes\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
+//\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
+\r
+//\r
+// Definition for global variables.\r
+//\r
+STATIC GAUGE_DATA_HEADER    *mGaugeData;\r
+STATIC UINT32               mMaxGaugeRecords;\r
+\r
+EFI_HANDLE           mHandle = NULL;\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
+  This internal function searches for the gauge entry in the gauge array.\r
+  If there is an entry that exactly matches the given key word triple\r
+  and its end time stamp is zero, then the index of that gauge entry is returned;\r
+  otherwise, the the number of gauge entries in the array is returned.\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
+\r
+  @retval The index of gauge entry in the array.\r
+\r
+**/\r
+STATIC\r
+UINT32\r
+InternalSearchForGaugeEntry (\r
+  IN CONST VOID                 *Handle,  OPTIONAL\r
+  IN CONST CHAR8                *Token,   OPTIONAL\r
+  IN CONST CHAR8                *Module   OPTIONAL\r
+  )\r
+{\r
+  UINT32                    Index;\r
+  UINT32                    NumberOfEntries;\r
+  GAUGE_DATA_ENTRY          *GaugeEntryArray;\r
+\r
+  if (Token == NULL) {\r
+    Token = "";\r
+  }\r
+  if (Module == NULL) {\r
+    Module = "";\r
+  }\r
+\r
+  NumberOfEntries = mGaugeData->NumberOfEntries;\r
+  GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);\r
+\r
+  for (Index = 0; Index < NumberOfEntries; Index++) {\r
+    if ((GaugeEntryArray[Index].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&\r
+         AsciiStrnCmp (GaugeEntryArray[Index].Token, Token, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&\r
+         AsciiStrnCmp (GaugeEntryArray[Index].Module, Module, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&\r
+         GaugeEntryArray[Index].EndTimeStamp == 0\r
+       ) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  return Index;\r
+}\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
+  GAUGE_DATA_ENTRY          *GaugeEntryArray;\r
+  UINTN                     GaugeDataSize;\r
+  UINTN                     OldGaugeDataSize;\r
+  GAUGE_DATA_HEADER         *OldGaugeData;\r
+  UINT32                    Index;\r
+\r
+  Index = mGaugeData->NumberOfEntries;\r
+  if (Index >= mMaxGaugeRecords) {\r
+    //\r
+    // Try to enlarge the scale of gauge arrary.\r
+    //\r
+    OldGaugeData      = mGaugeData;\r
+    OldGaugeDataSize  = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;\r
+\r
+    mMaxGaugeRecords *= 2;\r
+    GaugeDataSize     = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;\r
+\r
+    mGaugeData = AllocateZeroPool (GaugeDataSize);\r
+    if (mGaugeData == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    //\r
+    // Initialize new data arry and migrate old data one.\r
+    //\r
+    mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize);\r
+\r
+    FreePool (OldGaugeData);\r
+  }\r
+\r
+  GaugeEntryArray               = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);\r
+  GaugeEntryArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;\r
+\r
+  if (Token != NULL) {\r
+    AsciiStrnCpy (GaugeEntryArray[Index].Token, Token, DXE_PERFORMANCE_STRING_LENGTH);\r
+  }\r
+  if (Module != NULL) {\r
+    AsciiStrnCpy (GaugeEntryArray[Index].Module, Module, DXE_PERFORMANCE_STRING_LENGTH);\r
+  }\r
+\r
+  if (TimeStamp == 0) {\r
+    TimeStamp = GetPerformanceCounter ();\r
+  }\r
+  GaugeEntryArray[Index].StartTimeStamp = TimeStamp;\r
+\r
+  mGaugeData->NumberOfEntries++;\r
+\r
+  return EFI_SUCCESS;\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
+  GAUGE_DATA_ENTRY  *GaugeEntryArray;\r
+  UINT32            Index;\r
+\r
+  if (TimeStamp == 0) {\r
+    TimeStamp = GetPerformanceCounter ();\r
+  }\r
+\r
+  Index = InternalSearchForGaugeEntry (Handle, Token, Module);\r
+  if (Index >= mGaugeData->NumberOfEntries) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  GaugeEntryArray = (GAUGE_DATA_ENTRY  *) (mGaugeData + 1);\r
+  GaugeEntryArray[Index].EndTimeStamp = TimeStamp;\r
+\r
+  return EFI_SUCCESS;\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
+{\r
+  UINTN               NumberOfEntries;\r
+  GAUGE_DATA_ENTRY    *LogEntryArray;\r
+\r
+  NumberOfEntries = (UINTN) (mGaugeData->NumberOfEntries);\r
+  if (LogEntryKey > NumberOfEntries) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  if (LogEntryKey == NumberOfEntries) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  LogEntryArray   = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);\r
+\r
+  if (GaugeDataEntry == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  *GaugeDataEntry = &LogEntryArray[LogEntryKey];\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Dumps all the PEI performance log to DXE performance gauge array.\r
+\r
+  This internal function dumps all the PEI performance log to the DXE performance gauge array.\r
+  It retrieves the optional GUID HOB for PEI performance and then saves the performance data\r
+  to DXE performance data structures.\r
+\r
+**/\r
+STATIC\r
+VOID\r
+InternalGetPeiPerformance (\r
+  VOID\r
+  )\r
+{\r
+  EFI_HOB_GUID_TYPE                 *GuidHob;\r
+  PEI_PERFORMANCE_LOG_HEADER        *LogHob;\r
+  PEI_PERFORMANCE_LOG_ENTRY         *LogEntryArray;\r
+  GAUGE_DATA_ENTRY                  *GaugeEntryArray;\r
+  UINT32                            Index;\r
+  UINT32                            NumberOfEntries;\r
+\r
+  NumberOfEntries = 0;\r
+  GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);\r
+\r
+  //\r
+  // Dump PEI Log Entries to DXE Guage Data structure.\r
+  //\r
+  GuidHob = GetFirstGuidHob (&gPeiPerformanceHobGuid);\r
+  if (GuidHob != NULL) {\r
+    LogHob          = GET_GUID_HOB_DATA (GuidHob);\r
+    LogEntryArray   = (PEI_PERFORMANCE_LOG_ENTRY *) (LogHob + 1);\r
+    GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);\r
+\r
+    NumberOfEntries = LogHob->NumberOfEntries;\r
+    for (Index = 0; Index < NumberOfEntries; Index++) {\r
+      GaugeEntryArray[Index].Handle         = LogEntryArray[Index].Handle;\r
+      AsciiStrnCpy (GaugeEntryArray[Index].Token,  LogEntryArray[Index].Token,  DXE_PERFORMANCE_STRING_LENGTH);\r
+      AsciiStrnCpy (GaugeEntryArray[Index].Module, LogEntryArray[Index].Module, DXE_PERFORMANCE_STRING_LENGTH);\r
+      GaugeEntryArray[Index].StartTimeStamp = LogEntryArray[Index].StartTimeStamp;\r
+      GaugeEntryArray[Index].EndTimeStamp   = LogEntryArray[Index].EndTimeStamp;\r
+    }\r
+  }\r
+  mGaugeData->NumberOfEntries = NumberOfEntries;\r
+}\r
+\r
+/**\r
+  The constructor function initializes Performance infrastructure for DXE phase.\r
+\r
+  The constructor function publishes Performance protocol, allocates memory to log DXE performance\r
+  and merges PEI performance data to DXE performance log.\r
+  It will ASSERT() if one of these operations 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
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeCorePerformanceLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\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
+  Status = gBS->InstallProtocolInterface (\r
+                  &mHandle,\r
+                  &gPerformanceProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &mPerformanceInterface\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  mMaxGaugeRecords = INIT_DXE_GAUGE_DATA_ENTRIES + PcdGet8 (PcdMaxPeiPerformanceLogEntries);\r
+\r
+  mGaugeData = AllocateZeroPool (sizeof (GAUGE_DATA_HEADER) + (sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords));\r
+  ASSERT (mGaugeData != NULL);\r
+\r
+  InternalGetPeiPerformance ();\r
+\r
+  return Status;\r
+}\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 RETURN_SUCCESS          The start of the measurement was recorded.\r
+  @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StartPerformanceMeasurement (\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
+  EFI_STATUS  Status;\r
+\r
+  Status = StartGauge (Handle, Token, Module, TimeStamp);\r
+  return (RETURN_STATUS) Status;\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 RETURN_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 RETURN_SUCCESS          The end of  the measurement was recorded.\r
+  @retval RETURN_NOT_FOUND        The specified measurement record could not be found.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+EndPerformanceMeasurement (\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
+  EFI_STATUS  Status;\r
+\r
+  Status = EndGauge (Handle, Token, Module, TimeStamp);\r
+  return (RETURN_STATUS) Status;\r
+}\r
+\r
+/**\r
+  Attempts to retrieve a performance measurement log entry from the performance measurement log.\r
+\r
+  Attempts to retrieve the performance log entry specified by LogEntryKey.  If LogEntryKey is\r
+  zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r
+  and the key for the second entry in the log is returned.  If the performance log is empty,\r
+  then no entry is retrieved and zero is returned.  If LogEntryKey is not zero, then the performance\r
+  log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r
+  returned.  If LogEntryKey is the key for the last entry in the log, then the last log entry is\r
+  retrieved and an implementation specific non-zero key value that specifies the end of the performance\r
+  log is returned.  If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r
+  is retrieved and zero is returned.  In the cases where a performance log entry can be returned,\r
+  the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.\r
+  If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r
+  If Handle is NULL, then ASSERT().\r
+  If Token is NULL, then ASSERT().\r
+  If Module is NULL, then ASSERT().\r
+  If StartTimeStamp is NULL, then ASSERT().\r
+  If EndTimeStamp is NULL, then ASSERT().\r
+\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
+  @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
+                                  being measured.\r
+  @param  Module                  Pointer to a Null-terminated ASCII string that identifies the module\r
+                                  being measured.\r
+  @param  StartTimeStamp          Pointer to the 64-bit time stamp that was recorded when the measurement\r
+                                  was started.\r
+  @param  EndTimeStamp            Pointer to the 64-bit time stamp that was recorded when the measurement\r
+                                  was ended.\r
+\r
+  @return The key for the next performance log entry (in general case).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GetPerformanceMeasurement (\r
+  IN  UINTN       LogEntryKey,\r
+  OUT CONST VOID  **Handle,\r
+  OUT CONST CHAR8 **Token,\r
+  OUT CONST CHAR8 **Module,\r
+  OUT UINT64      *StartTimeStamp,\r
+  OUT UINT64      *EndTimeStamp\r
+  )\r
+{\r
+  EFI_STATUS        Status;\r
+  GAUGE_DATA_ENTRY  *GaugeData;\r
+\r
+  ASSERT (Handle != NULL);\r
+  ASSERT (Token != NULL);\r
+  ASSERT (Module != NULL);\r
+  ASSERT (StartTimeStamp != NULL);\r
+  ASSERT (EndTimeStamp != NULL);\r
+\r
+  Status = GetGauge (LogEntryKey++, &GaugeData);\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
+\r
+  return LogEntryKey;\r
+}\r
+\r
+/**\r
+  Returns TRUE if the performance measurement macros are enabled.\r
+\r
+  This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
+  PcdPerformanceLibraryPropertyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval TRUE                    The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
+                                  PcdPerformanceLibraryPropertyMask is set.\r
+  @retval FALSE                   The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
+                                  PcdPerformanceLibraryPropertyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PerformanceMeasurementEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);\r
+}\r
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
new file mode 100644 (file)
index 0000000..df9f15a
--- /dev/null
@@ -0,0 +1,118 @@
+#/** @file\r
+# Component description file for DxeCore Performance Library\r
+#\r
+# This library provides intrastructure for DxeCore to log performance.\r
+# Copyright (c) 2006, Intel Corporation.\r
+#\r
+#  All rights reserved. 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
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DxeCorePerformanceLib\r
+  FILE_GUID                      = D0F78BBF-0A30-4c63-8A48-0F618A4AFACD\r
+  MODULE_TYPE                    = DXE_CORE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PerformanceLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  CONSTRUCTOR                    = DxeCorePerformanceLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  DxeCorePerformanceLib.c\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  MemoryAllocationLib\r
+  UefiBootServicesTableLib\r
+  PcdLib\r
+  TimerLib\r
+  BaseMemoryLib\r
+  BaseLib\r
+  HobLib\r
+  DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Guids]\r
+  gPeiPerformanceHobGuid                        # ALWAYS_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+#                           that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+  gPerformanceProtocolGuid                      # PROTOCOL ALWAYS_PRODUCED\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd FIXED_AT_BUILD - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsFixedAtBuild.common]\r
+  PcdPerformanceLibraryPropertyMask|gEfiMdePkgTokenSpaceGuid\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd DYNAMIC - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsDynamic.common]\r
+  PcdMaxPeiPerformanceLogEntries|gEfiEdkModulePkgTokenSpaceGuid\r
+\r
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.msa b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.msa
new file mode 100644 (file)
index 0000000..444867a
--- /dev/null
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>DxeCorePerformanceLib</ModuleName>\r
+    <ModuleType>DXE_CORE</ModuleType>\r
+    <GuidValue>D0F78BBF-0A30-4c63-8A48-0F618A4AFACD</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for DxeCore Performance Library</Abstract>\r
+    <Description>This library provides intrastructure for DxeCore to log performance.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials
+      are licensed and made available under the terms and conditions of the BSD License
+      which accompanies this distribution.  The full text of the license may be found at
+      http://opensource.org/licenses/bsd-license.php
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>DxeCorePerformanceLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER">\r
+      <Keyword>PerformanceLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>TimerLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PcdLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>MemoryAllocationLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>DxeCorePerformanceLib.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_PRODUCED">\r
+      <ProtocolCName>gPerformanceProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Guids>\r
+    <GuidCNames Usage="ALWAYS_CONSUMED">\r
+      <GuidCName>gPeiPerformanceHobGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+    <Extern>\r
+      <Constructor>DxeCorePerformanceLibConstructor</Constructor>\r
+    </Extern>\r
+  </Externs>\r
+  <PcdCoded>\r
+    <PcdEntry PcdItemType="FIXED_AT_BUILD">\r
+      <C_Name>PcdPerformanceLibraryPropertyMask</C_Name>\r
+      <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>The bitmask of flags that specify the enable/disable of
+                Performance Measurement.</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdMaxPeiPerformanceLogEntries</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>Maximun number of performance log entries during PEI phase.</HelpText>\r
+    </PcdEntry>\r
+  </PcdCoded>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c
new file mode 100644 (file)
index 0000000..fbfba26
--- /dev/null
@@ -0,0 +1,266 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. 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
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DxePerformanceLib.c\r
+\r
+Abstract:\r
+\r
+  Performance Library\r
+\r
+--*/\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/Performance.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/PerformanceLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+STATIC PERFORMANCE_PROTOCOL    *mPerformance = NULL;\r
+\r
+/**\r
+  The constructor function caches the pointer to Performance protocol.\r
+\r
+  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
+  @retval EFI_SUCCESS     Performance protocol is successfully located.\r
+  @retval Other           Performance protocol is not located to log performance.\r
+\r
+**/\r
+STATIC\r
+EFI_STATUS\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 **) &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
+\r
+/**\r
+  Creates a record for the beginning of a performance measurement.\r
+\r
+  Creates a record that contains the Handle, Token, and Module.\r
+  If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r
+  If TimeStamp is zero, then this function reads the current time stamp\r
+  and adds that time stamp value to the record as the start time.\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 RETURN_SUCCESS          The start of the measurement was recorded.\r
+  @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StartPerformanceMeasurement (\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
+  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
+  return (RETURN_STATUS) Status;\r
+}\r
+\r
+/**\r
+  Fills in the end time of a performance measurement.\r
+\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
+  If the record is found and TimeStamp is zero, then this function reads\r
+  the current time stamp and adds that time stamp value to the record as the end time.\r
+  If this function is called multiple times for the same record, then the end time is overwritten.\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 RETURN_SUCCESS          The end of  the measurement was recorded.\r
+  @retval RETURN_NOT_FOUND        The specified measurement record could not be found.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+EndPerformanceMeasurement (\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
+  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
+}\r
+\r
+/**\r
+  Attempts to retrieve a performance measurement log entry from the performance measurement log.\r
+\r
+  Attempts to retrieve the performance log entry specified by LogEntryKey.  If LogEntryKey is\r
+  zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r
+  and the key for the second entry in the log is returned.  If the performance log is empty,\r
+  then no entry is retrieved and zero is returned.  If LogEntryKey is not zero, then the performance\r
+  log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r
+  returned.  If LogEntryKey is the key for the last entry in the log, then the last log entry is\r
+  retrieved and an implementation specific non-zero key value that specifies the end of the performance\r
+  log is returned.  If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r
+  is retrieved and zero is returned.  In the cases where a performance log entry can be returned,\r
+  the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.\r
+  If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r
+  If Handle is NULL, then ASSERT().\r
+  If Token is NULL, then ASSERT().\r
+  If Module is NULL, then ASSERT().\r
+  If StartTimeStamp is NULL, then ASSERT().\r
+  If EndTimeStamp is NULL, then ASSERT().\r
+\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
+  @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
+                                  being measured.\r
+  @param  Module                  Pointer to a Null-terminated ASCII string that identifies the module\r
+                                  being measured.\r
+  @param  StartTimeStamp          Pointer to the 64-bit time stamp that was recorded when the measurement\r
+                                  was started.\r
+  @param  EndTimeStamp            Pointer to the 64-bit time stamp that was recorded when the measurement\r
+                                  was ended.\r
+\r
+  @return The key for the next performance log entry (in general case).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GetPerformanceMeasurement (\r
+  IN  UINTN       LogEntryKey,\r
+  OUT CONST VOID  **Handle,\r
+  OUT CONST CHAR8 **Token,\r
+  OUT CONST CHAR8 **Module,\r
+  OUT UINT64      *StartTimeStamp,\r
+  OUT UINT64      *EndTimeStamp\r
+  )\r
+{\r
+  EFI_STATUS        Status;\r
+  GAUGE_DATA_ENTRY  *GaugeData;\r
+\r
+  ASSERT (Handle != NULL);\r
+  ASSERT (Token != NULL);\r
+  ASSERT (Module != NULL);\r
+  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
+  // 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
+\r
+  return LogEntryKey;\r
+}\r
+\r
+/**\r
+  Returns TRUE if the performance measurement macros are enabled.\r
+\r
+  This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
+  PcdPerformanceLibraryPropertyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval TRUE                    The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
+                                  PcdPerformanceLibraryPropertyMask is set.\r
+  @retval FALSE                   The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
+                                  PcdPerformanceLibraryPropertyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PerformanceMeasurementEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);\r
+}\r
diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
new file mode 100644 (file)
index 0000000..95500f3
--- /dev/null
@@ -0,0 +1,93 @@
+#/** @file\r
+# Component description file for Dxe Performance Library\r
+#\r
+# This library provides intrastructure for Dxe driver to log performance.\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+#  All rights reserved. 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
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DxePerformanceLib\r
+  FILE_GUID                      = 8B8B4CCC-65FC-41a5-8067-308B8E42CCF2\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PerformanceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  DxePerformanceLib.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  PcdLib\r
+  UefiBootServicesTableLib\r
+  DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+#                           that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+  gPerformanceProtocolGuid                      # PROTOCOL ALWAYS_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd FIXED_AT_BUILD - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsFixedAtBuild.common]\r
+  PcdPerformanceLibraryPropertyMask|gEfiMdePkgTokenSpaceGuid\r
+\r
diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.msa b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.msa
new file mode 100644 (file)
index 0000000..3555a24
--- /dev/null
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>DxePerformanceLib</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>8B8B4CCC-65FC-41a5-8067-308B8E42CCF2</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for Dxe Performance Library</Abstract>\r
+    <Description>This library provides intrastructure for Dxe driver to log performance.</Description>\r
+    <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials
+      are licensed and made available under the terms and conditions of the BSD License
+      which accompanies this distribution.  The full text of the license may be found at
+      http://opensource.org/licenses/bsd-license.php
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>DxePerformanceLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER">\r
+      <Keyword>PerformanceLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PcdLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>DxePerformanceLib.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gPerformanceProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+  <PcdCoded>\r
+    <PcdEntry PcdItemType="FIXED_AT_BUILD">\r
+      <C_Name>PcdPerformanceLibraryPropertyMask</C_Name>\r
+      <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>The bitmask of flags that specify the enable/disable of
+                Performance Measurement.</HelpText>\r
+    </PcdEntry>\r
+  </PcdCoded>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/MdeModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.inf b/MdeModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.inf
new file mode 100644 (file)
index 0000000..89f4e31
--- /dev/null
@@ -0,0 +1,81 @@
+#/** @file\r
+# DXE Print library\r
+#\r
+# Print Library based on EFI_PRINT_PROTOCOL\r
+# Copyright (c) 2006 - 2007, Intel Corporation.\r
+#\r
+#  All rights reserved. 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
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EdkDxePrintLib\r
+  FILE_GUID                      = 50bcb105-6634-441d-b403-659110a03ad2\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PrintLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  PrintLib.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names\r
+#                           that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Protocols]\r
+  gEfiPrintProtocolGuid                         # PROTOCOL ALWAYS_CONSUMED\r
+\r
diff --git a/MdeModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.msa b/MdeModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.msa
new file mode 100644 (file)
index 0000000..d302a8b
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>EdkDxePrintLib</ModuleName>\r
+    <ModuleType>DXE_DRIVER</ModuleType>\r
+    <GuidValue>50bcb105-6634-441d-b403-659110a03ad2</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>DXE Print library</Abstract>\r
+    <Description>Print Library based on EFI_PRINT_PROTOCOL</Description>\r
+    <Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials
+      are licensed and made available under the terms and conditions of the BSD License
+      which accompanies this distribution.  The full text of the license may be found at
+      http://opensource.org/licenses/bsd-license.php
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>EdkDxePrintLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER">\r
+      <Keyword>PrintLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>UefiBootServicesTableLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>PrintLib.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+  </PackageDependencies>\r
+  <Protocols>\r
+    <Protocol Usage="ALWAYS_CONSUMED">\r
+      <ProtocolCName>gEfiPrintProtocolGuid</ProtocolCName>\r
+    </Protocol>\r
+  </Protocols>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file
diff --git a/MdeModulePkg/Library/EdkDxePrintLib/PrintLib.c b/MdeModulePkg/Library/EdkDxePrintLib/PrintLib.c
new file mode 100644 (file)
index 0000000..7dbbcb7
--- /dev/null
@@ -0,0 +1,159 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. 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
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  PrintLib.c\r
+\r
+Abstract:\r
+\r
+  Print Library\r
+\r
+--*/\r
+\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/Print.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/PrintLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+static EFI_PRINT_PROTOCOL  *gPrintProtocol = NULL;\r
+\r
+UINTN\r
+UnicodeVSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  const CHAR16  *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint function to process format and place the results in Buffer. Since a\r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus\r
+  this is the main print working routine\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize    - Maximum number of characters to put into buffer. Zero means\r
+                  no limit.\r
+\r
+  FormatString  - Unicode format string see file header for more details.\r
+\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (gPrintProtocol == NULL) {\r
+    Status = gBS->LocateProtocol (\r
+                    &gEfiPrintProtocolGuid,\r
+                    NULL,\r
+                    (VOID **)&gPrintProtocol\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      gPrintProtocol = NULL;\r
+    }\r
+    if (gPrintProtocol == NULL) {\r
+      return 0;\r
+    }\r
+  }\r
+  return gPrintProtocol->VSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
+}\r
+\r
+UINTN\r
+UnicodeSPrint (\r
+  OUT CHAR16        *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  const CHAR16  *FormatString,\r
+  ...\r
+  )\r
+\r
+{\r
+  UINTN    Return;\r
+  VA_LIST  Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  Return = UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
+  VA_END (Marker);\r
+  return Return;\r
+}\r
+\r
+UINTN\r
+AsciiVSPrint (\r
+  OUT CHAR8         *StartOfBuffer,\r
+  IN  UINTN         BufferSize,\r
+  IN  const CHAR8   *FormatString,\r
+  IN  VA_LIST       Marker\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  VSPrint function to process format and place the results in Buffer. Since a\r
+  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus\r
+  this is the main print working routine\r
+\r
+Arguments:\r
+\r
+  StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.\r
+\r
+  BufferSize    - Maximum number of characters to put into buffer. Zero means\r
+                  no limit.\r
+\r
+  FormatString  - Unicode format string see file header for more details.\r
+\r
+  Marker        - Vararg list consumed by processing Format.\r
+\r
+Returns:\r
+\r
+  Number of characters printed.\r
+\r
+--*/\r
+{\r
+  return 0;\r
+}\r
+\r
+UINTN\r
+AsciiSPrint (\r
+  OUT CHAR8        *StartOfBuffer,\r
+  IN  UINTN        BufferSize,\r
+  IN  const CHAR8  *FormatString,\r
+  ...\r
+  )\r
+\r
+{\r
+  UINTN    Return;\r
+  VA_LIST  Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  Return = AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);\r
+  VA_END (Marker);\r
+  return Return;\r
+}\r
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
new file mode 100644 (file)
index 0000000..aa23184
--- /dev/null
@@ -0,0 +1,352 @@
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. 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
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  PeiPerformanceLib.c\r
+\r
+Abstract:\r
+\r
+  Performance Library\r
+\r
+--*/\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Guid/PeiPerformanceHob.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/PerformanceLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+\r
+/**\r
+  Gets PEI the GUID HOB for PEI performance.\r
+\r
+  This internal function searches for the GUID HOB for PEI performance.\r
+  If that GUID HOB is not found, it will build a new one.\r
+  It returns the data area of that GUID HOB to record performance log.\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
+\r
+  @retval The index of log entry in the array.\r
+\r
+**/\r
+STATIC\r
+PEI_PERFORMANCE_LOG_HEADER *\r
+InternalGetPerformanceHobLog (\r
+  VOID\r
+  )\r
+{\r
+  EFI_HOB_GUID_TYPE           *GuidHob;\r
+  PEI_PERFORMANCE_LOG_HEADER  *PeiPerformanceLog;\r
+  UINTN                       PeiPerformanceLogSize;\r
+\r
+  GuidHob = GetFirstGuidHob (&gPeiPerformanceHobGuid);\r
+\r
+  if (GuidHob != NULL) {\r
+    //\r
+    // PEI Performance HOB was found, then return the existing one.\r
+    //\r
+    PeiPerformanceLog = GET_GUID_HOB_DATA (GuidHob);\r
+  } else {\r
+    //\r
+    // PEI Performance HOB was not found, then build one.\r
+    //\r
+    PeiPerformanceLogSize = sizeof (PEI_PERFORMANCE_LOG_HEADER) +\r
+                            sizeof (PEI_PERFORMANCE_LOG_ENTRY) * PcdGet8 (PcdMaxPeiPerformanceLogEntries);\r
+    PeiPerformanceLog     = BuildGuidHob (&gPeiPerformanceHobGuid, PeiPerformanceLogSize);\r
+    PeiPerformanceLog     = ZeroMem (PeiPerformanceLog, PeiPerformanceLogSize);\r
+  }\r
+\r
+  return PeiPerformanceLog;\r
+}\r
+\r
+/**\r
+  Searches in the log array with keyword Handle, Token and Module.\r
+\r
+  This internal function searches for the log entry in the log array.\r
+  If there is an entry that exactly matches the given key word triple\r
+  and its end time stamp is zero, then the index of that log entry is returned;\r
+  otherwise, the the number of log entries in the array is returned.\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
+\r
+  @retval The index of log entry in the array.\r
+\r
+**/\r
+STATIC\r
+UINT32\r
+InternalSearchForLogEntry (\r
+  IN PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog,\r
+  IN CONST VOID                 *Handle,  OPTIONAL\r
+  IN CONST CHAR8                *Token,   OPTIONAL\r
+  IN CONST CHAR8                *Module   OPTIONAL\r
+  )\r
+{\r
+  UINT32                    Index;\r
+  UINT32                    NumberOfEntries;\r
+  PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;\r
+\r
+\r
+  if (Token == NULL) {\r
+    Token = "";\r
+  }\r
+  if (Module == NULL) {\r
+    Module = "";\r
+  }\r
+  NumberOfEntries = PeiPerformanceLog->NumberOfEntries;\r
+  LogEntryArray   = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);\r
+\r
+  for (Index = 0; Index < NumberOfEntries; Index++) {\r
+    if ((LogEntryArray[Index].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&\r
+         AsciiStrnCmp (LogEntryArray[Index].Token, Token, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&\r
+         AsciiStrnCmp (LogEntryArray[Index].Module, Module, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&\r
+         LogEntryArray[Index].EndTimeStamp == 0\r
+       ) {\r
+      break;\r
+    }\r
+  }\r
+  return Index;\r
+}\r
+\r
+/**\r
+  Creates a record for the beginning of a performance measurement.\r
+\r
+  Creates a record that contains the Handle, Token, and Module.\r
+  If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r
+  If TimeStamp is zero, then this function reads the current time stamp\r
+  and adds that time stamp value to the record as the start time.\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 RETURN_SUCCESS          The start of the measurement was recorded.\r
+  @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StartPerformanceMeasurement (\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
+  PEI_PERFORMANCE_LOG_HEADER  *PeiPerformanceLog;\r
+  PEI_PERFORMANCE_LOG_ENTRY   *LogEntryArray;\r
+  UINT32                      Index;\r
+\r
+  PeiPerformanceLog = InternalGetPerformanceHobLog ();\r
+\r
+  if (PeiPerformanceLog->NumberOfEntries >= PcdGet8 (PcdMaxPeiPerformanceLogEntries)) {\r
+    return RETURN_OUT_OF_RESOURCES;\r
+  }\r
+  Index                       = PeiPerformanceLog->NumberOfEntries++;\r
+  LogEntryArray               = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);\r
+  LogEntryArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;\r
+\r
+  if (Token != NULL) {\r
+    AsciiStrnCpy (LogEntryArray[Index].Token, Token, PEI_PERFORMANCE_STRING_LENGTH);\r
+  }\r
+  if (Module != NULL) {\r
+    AsciiStrnCpy (LogEntryArray[Index].Module, Module, PEI_PERFORMANCE_STRING_LENGTH);\r
+  }\r
+\r
+  if (TimeStamp == 0) {\r
+    TimeStamp = GetPerformanceCounter ();\r
+  }\r
+  LogEntryArray[Index].StartTimeStamp = TimeStamp;\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Fills in the end time of a performance measurement.\r
+\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
+  If the record is found and TimeStamp is zero, then this function reads\r
+  the current time stamp and adds that time stamp value to the record as the end time.\r
+  If this function is called multiple times for the same record, then the end time is overwritten.\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 RETURN_SUCCESS          The end of  the measurement was recorded.\r
+  @retval RETURN_NOT_FOUND        The specified measurement record could not be found.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+EndPerformanceMeasurement (\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
+  PEI_PERFORMANCE_LOG_HEADER  *PeiPerformanceLog;\r
+  PEI_PERFORMANCE_LOG_ENTRY   *LogEntryArray;\r
+  UINT32                      Index;\r
+\r
+  if (TimeStamp == 0) {\r
+    TimeStamp = GetPerformanceCounter ();\r
+  }\r
+\r
+  PeiPerformanceLog = InternalGetPerformanceHobLog ();\r
+  Index             = InternalSearchForLogEntry (PeiPerformanceLog, Handle, Token, Module);\r
+  if (Index >= PeiPerformanceLog->NumberOfEntries) {\r
+    return RETURN_NOT_FOUND;\r
+  }\r
+  LogEntryArray     = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);\r
+  LogEntryArray[Index].EndTimeStamp = TimeStamp;\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Attempts to retrieve a performance measurement log entry from the performance measurement log.\r
+\r
+  Attempts to retrieve the performance log entry specified by LogEntryKey.  If LogEntryKey is\r
+  zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r
+  and the key for the second entry in the log is returned.  If the performance log is empty,\r
+  then no entry is retrieved and zero is returned.  If LogEntryKey is not zero, then the performance\r
+  log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r
+  returned.  If LogEntryKey is the key for the last entry in the log, then the last log entry is\r
+  retrieved and an implementation specific non-zero key value that specifies the end of the performance\r
+  log is returned.  If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r
+  is retrieved and zero is returned.  In the cases where a performance log entry can be returned,\r
+  the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.\r
+  If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r
+  If Handle is NULL, then ASSERT().\r
+  If Token is NULL, then ASSERT().\r
+  If Module is NULL, then ASSERT().\r
+  If StartTimeStamp is NULL, then ASSERT().\r
+  If EndTimeStamp is NULL, then ASSERT().\r
+\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
+  @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
+                                  being measured.\r
+  @param  Module                  Pointer to a Null-terminated ASCII string that identifies the module\r
+                                  being measured.\r
+  @param  StartTimeStamp          Pointer to the 64-bit time stamp that was recorded when the measurement\r
+                                  was started.\r
+  @param  EndTimeStamp            Pointer to the 64-bit time stamp that was recorded when the measurement\r
+                                  was ended.\r
+\r
+  @return The key for the next performance log entry (in general case).\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GetPerformanceMeasurement (\r
+  IN  UINTN       LogEntryKey,\r
+  OUT CONST VOID  **Handle,\r
+  OUT CONST CHAR8 **Token,\r
+  OUT CONST CHAR8 **Module,\r
+  OUT UINT64      *StartTimeStamp,\r
+  OUT UINT64      *EndTimeStamp\r
+  )\r
+{\r
+  PEI_PERFORMANCE_LOG_HEADER  *PeiPerformanceLog;\r
+  PEI_PERFORMANCE_LOG_ENTRY   *CurrentLogEntry;\r
+  PEI_PERFORMANCE_LOG_ENTRY   *LogEntryArray;\r
+  UINTN                       NumberOfEntries;\r
+\r
+  ASSERT (Handle != NULL);\r
+  ASSERT (Token != NULL);\r
+  ASSERT (Module != NULL);\r
+  ASSERT (StartTimeStamp != NULL);\r
+  ASSERT (EndTimeStamp != NULL);\r
+\r
+  PeiPerformanceLog = InternalGetPerformanceHobLog ();\r
+\r
+  NumberOfEntries   = (UINTN) (PeiPerformanceLog->NumberOfEntries);\r
+  LogEntryArray     = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);\r
+  //\r
+  // Make sure that LogEntryKey is a valid log entry key.\r
+  //\r
+  ASSERT (LogEntryKey <= NumberOfEntries);\r
+\r
+  if (LogEntryKey == NumberOfEntries) {\r
+    return 0;\r
+  }\r
+\r
+  CurrentLogEntry = &(LogEntryArray[LogEntryKey++]);\r
+\r
+  *Handle         = (VOID *) (UINTN) (CurrentLogEntry->Handle);\r
+  *Token          = CurrentLogEntry->Token;\r
+  *Module         = CurrentLogEntry->Module;\r
+  *StartTimeStamp = CurrentLogEntry->StartTimeStamp;\r
+  *EndTimeStamp   = CurrentLogEntry->EndTimeStamp;\r
+\r
+  return LogEntryKey;\r
+}\r
+\r
+/**\r
+  Returns TRUE if the performance measurement macros are enabled.\r
+\r
+  This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
+  PcdPerformanceLibraryPropertyMask is set.  Otherwise FALSE is returned.\r
+\r
+  @retval TRUE                    The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
+                                  PcdPerformanceLibraryPropertyMask is set.\r
+  @retval FALSE                   The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
+                                  PcdPerformanceLibraryPropertyMask is clear.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PerformanceMeasurementEnabled (\r
+  VOID\r
+  )\r
+{\r
+  return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);\r
+}\r
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
new file mode 100644 (file)
index 0000000..07c0841
--- /dev/null
@@ -0,0 +1,105 @@
+#/** @file\r
+# Memory-only library functions with no library constructor/destructor\r
+#\r
+# This module provides the performance measurement interfaces in PEI phase, it is one instance of Performance Libarary.\r
+# Copyright (c) 2006, Intel Corporation\r
+#\r
+#  All rights reserved. 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
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PeiPerformanceLib\r
+  FILE_GUID                      = F72DE735-B24F-4ef6-897F-70A85D01A047\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PerformanceLib|PEIM PEI_CORE\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  PeiPerformanceLib.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  BaseMemoryLib\r
+  PcdLib\r
+  TimerLib\r
+  BaseLib\r
+  HobLib\r
+  DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# Guid C Name Section - list of Guids that this module uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Guids]\r
+  gPeiPerformanceHobGuid                        # SOMETIMES_CONSUMED\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd FIXED_AT_BUILD - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsFixedAtBuild.common]\r
+  PcdPerformanceLibraryPropertyMask|gEfiMdePkgTokenSpaceGuid\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd DYNAMIC - list of PCDs that this module is coded for.\r
+#\r
+################################################################################\r
+\r
+[PcdsDynamic.common]\r
+  PcdMaxPeiPerformanceLogEntries|gEfiEdkModulePkgTokenSpaceGuid\r
+\r
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.msa b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.msa
new file mode 100644 (file)
index 0000000..85ce0ad
--- /dev/null
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>PeiPerformanceLib</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>F72DE735-B24F-4ef6-897F-70A85D01A047</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Memory-only library functions with no library constructor/destructor</Abstract>\r
+    <Description>This module provides the performance measurement interfaces in PEI phase, it is one instance of Performance Libarary.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials
+      are licensed and made available under the terms and conditions of the BSD License
+      which accompanies this distribution.  The full text of the license may be found at
+      http://opensource.org/licenses/bsd-license.php
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>PeiPerformanceLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="PEIM PEI_CORE">\r
+      <Keyword>PerformanceLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>HobLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>TimerLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PcdLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>PeiPerformanceLib.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+  </PackageDependencies>\r
+  <Guids>\r
+    <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+      <GuidCName>gPeiPerformanceHobGuid</GuidCName>\r
+    </GuidCNames>\r
+  </Guids>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+  <PcdCoded>\r
+    <PcdEntry PcdItemType="FIXED_AT_BUILD">\r
+      <C_Name>PcdPerformanceLibraryPropertyMask</C_Name>\r
+      <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>The bitmask of flags that specify the enable/disable of
+                Performance Measurement.</HelpText>\r
+    </PcdEntry>\r
+    <PcdEntry PcdItemType="DYNAMIC">\r
+      <C_Name>PcdMaxPeiPerformanceLogEntries</C_Name>\r
+      <TokenSpaceGuidCName>gEfiEdkModulePkgTokenSpaceGuid</TokenSpaceGuidCName>\r
+      <HelpText>Maximun number of performance log entries during PEI phase.</HelpText>\r
+    </PcdEntry>\r
+  </PcdCoded>\r
+</ModuleSurfaceArea>
\ No newline at end of file
index cfc2b8970e6f0e8298227c211351e9ebb3f26639..31ec78dd4f92651abd3f83b0678bf46efb6c8b42 100644 (file)
   PcdFlashNvStorageFtwWorkingSize|gEfiGenericPlatformTokenSpaceGuid|0x0\r
   PcdFlashNvStorageVariableBase|gEfiGenericPlatformTokenSpaceGuid|0x0\r
   PcdFlashNvStorageVariableSize|gEfiGenericPlatformTokenSpaceGuid|0x0\r
   PcdFlashNvStorageFtwWorkingSize|gEfiGenericPlatformTokenSpaceGuid|0x0\r
   PcdFlashNvStorageVariableBase|gEfiGenericPlatformTokenSpaceGuid|0x0\r
   PcdFlashNvStorageVariableSize|gEfiGenericPlatformTokenSpaceGuid|0x0\r
+  PcdMaxPeiPerformanceLogEntries|gEfiEdkModulePkgTokenSpaceGuid|28\r
 \r
 [PcdsPatchableInModule.common]\r
   PcdDebugPrintErrorLevel|gEfiMdePkgTokenSpaceGuid|0x80000000\r
 \r
 [PcdsPatchableInModule.common]\r
   PcdDebugPrintErrorLevel|gEfiMdePkgTokenSpaceGuid|0x80000000\r
 \r
 [Components.Ia32]\r
   ${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
 \r
 [Components.Ia32]\r
   ${WORKSPACE}/MdeModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.inf\r
+  ${WORKSPACE}/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf\r
+  ${WORKSPACE}/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf\r
+  ${WORKSPACE}/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf\r
+  ${WORKSPACE}/MdeModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.inf\r
   ${WORKSPACE}/MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
   ${WORKSPACE}/MdeModulePkg/Universal/Disk/DiskIo/Dxe/DiskIo.inf\r
   ${WORKSPACE}/MdeModulePkg/Universal/Disk/Partition/Dxe/Partition.inf\r
   ${WORKSPACE}/MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
   ${WORKSPACE}/MdeModulePkg/Universal/Disk/DiskIo/Dxe/DiskIo.inf\r
   ${WORKSPACE}/MdeModulePkg/Universal/Disk/Partition/Dxe/Partition.inf\r