]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
MdeModulePkg: Update PerformanceLib instances not to check Identifier.
[mirror_edk2.git] / MdeModulePkg / Library / DxeCorePerformanceLib / DxeCorePerformanceLib.c
index 08d295ca5a6b956588638a4159305fb3036a09c5..4739bb842661e834d1c65b05d74824342e3218c4 100644 (file)
@@ -10,7 +10,8 @@
   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 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
@@ -88,6 +89,7 @@ InternalSearchForGaugeEntry (
   )\r
 {\r
   UINT32                    Index;\r
+  UINT32                    Index2;\r
   UINT32                    NumberOfEntries;\r
   GAUGE_DATA_ENTRY_EX       *GaugeEntryExArray;\r
 \r
@@ -101,13 +103,15 @@ InternalSearchForGaugeEntry (
   NumberOfEntries = mGaugeData->NumberOfEntries;\r
   GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);\r
 \r
+  Index2 = 0;\r
+\r
   for (Index = 0; Index < NumberOfEntries; Index++) {\r
-    if ((GaugeEntryExArray[Index].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&\r
-         AsciiStrnCmp (GaugeEntryExArray[Index].Token, Token, DXE_PERFORMANCE_STRING_LENGTH) == 0 &&\r
-         AsciiStrnCmp (GaugeEntryExArray[Index].Module, Module, DXE_PERFORMANCE_STRING_LENGTH) == 0 &&\r
-         (GaugeEntryExArray[Index].Identifier == Identifier) &&\r
-         GaugeEntryExArray[Index].EndTimeStamp == 0\r
-       ) {\r
+    Index2 = NumberOfEntries - 1 - Index;\r
+    if (GaugeEntryExArray[Index2].EndTimeStamp == 0 &&\r
+        (GaugeEntryExArray[Index2].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&\r
+        AsciiStrnCmp (GaugeEntryExArray[Index2].Token, Token, DXE_PERFORMANCE_STRING_LENGTH) == 0 &&\r
+        AsciiStrnCmp (GaugeEntryExArray[Index2].Module, Module, DXE_PERFORMANCE_STRING_LENGTH) == 0) {\r
+      Index = Index2;\r
       break;\r
     }\r
   }\r
@@ -187,10 +191,10 @@ StartGaugeEx (
   GaugeEntryExArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;\r
 \r
   if (Token != NULL) {\r
-    AsciiStrnCpy (GaugeEntryExArray[Index].Token, Token, DXE_PERFORMANCE_STRING_LENGTH);\r
+    AsciiStrnCpyS (GaugeEntryExArray[Index].Token, DXE_PERFORMANCE_STRING_SIZE, Token, DXE_PERFORMANCE_STRING_LENGTH);\r
   }\r
   if (Module != NULL) {\r
-    AsciiStrnCpy (GaugeEntryExArray[Index].Module, Module, DXE_PERFORMANCE_STRING_LENGTH);\r
+    AsciiStrnCpyS (GaugeEntryExArray[Index].Module, DXE_PERFORMANCE_STRING_SIZE, Module, DXE_PERFORMANCE_STRING_LENGTH);\r
   }\r
 \r
   GaugeEntryExArray[Index].EndTimeStamp = 0;\r
@@ -211,7 +215,7 @@ StartGaugeEx (
   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, Module and Identifier and has an end time value of zero.\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
@@ -408,6 +412,8 @@ GetGauge (
   EFI_STATUS          Status;\r
   GAUGE_DATA_ENTRY_EX *GaugeEntryEx;\r
 \r
+  GaugeEntryEx = NULL;\r
+\r
   Status = GetGaugeEx (LogEntryKey, &GaugeEntryEx);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -457,8 +463,8 @@ InternalGetPeiPerformance (
     NumberOfEntries = LogHob->NumberOfEntries;\r
     for (Index = 0; Index < NumberOfEntries; Index++) {\r
       GaugeEntryExArray[Index].Handle         = LogEntryArray[Index].Handle;\r
-      AsciiStrnCpy (GaugeEntryExArray[Index].Token,  LogEntryArray[Index].Token,  DXE_PERFORMANCE_STRING_LENGTH);\r
-      AsciiStrnCpy (GaugeEntryExArray[Index].Module, LogEntryArray[Index].Module, DXE_PERFORMANCE_STRING_LENGTH);\r
+      AsciiStrCpyS (GaugeEntryExArray[Index].Token,  DXE_PERFORMANCE_STRING_SIZE, LogEntryArray[Index].Token);\r
+      AsciiStrCpyS (GaugeEntryExArray[Index].Module, DXE_PERFORMANCE_STRING_SIZE, LogEntryArray[Index].Module);\r
       GaugeEntryExArray[Index].StartTimeStamp = LogEntryArray[Index].StartTimeStamp;\r
       GaugeEntryExArray[Index].EndTimeStamp   = LogEntryArray[Index].EndTimeStamp;\r
       GaugeEntryExArray[Index].Identifier     = 0;\r
@@ -516,7 +522,9 @@ DxeCorePerformanceLibConstructor (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  mMaxGaugeRecords = INIT_DXE_GAUGE_DATA_ENTRIES + PcdGet8 (PcdMaxPeiPerformanceLogEntries);\r
+  mMaxGaugeRecords = INIT_DXE_GAUGE_DATA_ENTRIES + (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ?\r
+                                                             PcdGet16 (PcdMaxPeiPerformanceLogEntries16) :\r
+                                                             PcdGet8 (PcdMaxPeiPerformanceLogEntries));\r
 \r
   mGaugeData = AllocateZeroPool (sizeof (GAUGE_DATA_HEADER) + (sizeof (GAUGE_DATA_ENTRY_EX) * mMaxGaugeRecords));\r
   ASSERT (mGaugeData != NULL);\r
@@ -569,7 +577,7 @@ StartPerformanceMeasurementEx (
   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, Module and Identifier and has an end time value of zero.\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