]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
MdePkg: Update MorLock comment to latest doc.
[mirror_edk2.git] / MdeModulePkg / Library / PeiPerformanceLib / PeiPerformanceLib.c
index 49011b701c3749bb36d5c8545a0614be29708502..9674bbc6210f6d3dacd514925300430c050cf614 100644 (file)
@@ -6,7 +6,8 @@
   performance data to the GUIDed HOB. Due to the limitation of temporary RAM, the maximum\r
   number of performance logging entry is specified by PcdMaxPeiPerformanceLogEntries.  \r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 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
@@ -90,6 +91,7 @@ InternalGetPerformanceHobLog (
 \r
   @param  PeiPerformanceLog       Pointer to the data structure containing PEI \r
                                   performance data.\r
+  @param  PeiPerformanceIdArray   Pointer to PEI performance identifier array.\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
@@ -112,6 +114,7 @@ InternalSearchForLogEntry (
   )\r
 {\r
   UINT32                    Index;\r
+  UINT32                    Index2;\r
   UINT32                    NumberOfEntries;\r
   PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;\r
 \r
@@ -125,13 +128,16 @@ InternalSearchForLogEntry (
   NumberOfEntries = PeiPerformanceLog->NumberOfEntries;\r
   LogEntryArray   = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);\r
 \r
+  Index2 = 0;\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
-         (PeiPerformanceIdArray[Index] == Identifier) &&\r
-         LogEntryArray[Index].EndTimeStamp == 0\r
-       ) {\r
+    Index2 = NumberOfEntries - 1 - Index;\r
+    if (LogEntryArray[Index2].EndTimeStamp == 0 &&\r
+        (LogEntryArray[Index2].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&\r
+        AsciiStrnCmp (LogEntryArray[Index2].Token, Token, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&\r
+        AsciiStrnCmp (LogEntryArray[Index2].Module, Module, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&\r
+        (PeiPerformanceIdArray[Index2] == Identifier)) {\r
+      Index = Index2;\r
       break;\r
     }\r
   }\r
@@ -178,6 +184,7 @@ StartPerformanceMeasurementEx (
   InternalGetPerformanceHobLog (&PeiPerformanceLog, &PeiPerformanceIdArray);\r
 \r
   if (PeiPerformanceLog->NumberOfEntries >= PcdGet8 (PcdMaxPeiPerformanceLogEntries)) {\r
+    DEBUG ((DEBUG_ERROR, "PEI performance log array out of resources\n"));\r
     return RETURN_OUT_OF_RESOURCES;\r
   }\r
   Index                       = PeiPerformanceLog->NumberOfEntries++;\r
@@ -185,10 +192,10 @@ StartPerformanceMeasurementEx (
   LogEntryArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;\r
 \r
   if (Token != NULL) {\r
-    AsciiStrnCpy (LogEntryArray[Index].Token, Token, PEI_PERFORMANCE_STRING_LENGTH);\r
+    AsciiStrnCpyS (LogEntryArray[Index].Token, PEI_PERFORMANCE_STRING_SIZE, Token, PEI_PERFORMANCE_STRING_LENGTH);\r
   }\r
   if (Module != NULL) {\r
-    AsciiStrnCpy (LogEntryArray[Index].Module, Module, PEI_PERFORMANCE_STRING_LENGTH);\r
+    AsciiStrnCpyS (LogEntryArray[Index].Module, PEI_PERFORMANCE_STRING_SIZE, Module, PEI_PERFORMANCE_STRING_LENGTH);\r
   }\r
 \r
   LogEntryArray[Index].EndTimeStamp = 0;\r