]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PerformancePkg/Dp_App/DpUtilities.c
MdePkg: Call CoreInitializeMemoryAttributesTable() in DXE Entrypoint.
[mirror_edk2.git] / PerformancePkg / Dp_App / DpUtilities.c
index 38d2293d8516027631f4459668b60ff7cf6e4369..b49844a058b8a3efe8e7db45f1c791ed56223351 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Utility functions used by the Dp application.\r
 \r
-  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -156,10 +156,10 @@ GetShortPdbFileName (
   UINTN StartIndex;\r
   UINTN EndIndex;\r
 \r
-  ZeroMem (UnicodeBuffer, DXE_PERFORMANCE_STRING_LENGTH * sizeof (CHAR16));\r
+  ZeroMem (UnicodeBuffer, (DP_GAUGE_STRING_LENGTH + 1) * sizeof (CHAR16));\r
 \r
   if (PdbFileName == NULL) {\r
-    StrCpyS (UnicodeBuffer, DXE_PERFORMANCE_STRING_SIZE, L" ");\r
+    StrCpyS (UnicodeBuffer, DP_GAUGE_STRING_LENGTH + 1, L" ");\r
   } else {\r
     StartIndex = 0;\r
     for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)\r
@@ -178,8 +178,8 @@ GetShortPdbFileName (
     for (IndexA = StartIndex; IndexA < EndIndex; IndexA++) {\r
       UnicodeBuffer[IndexU] = (CHAR16) PdbFileName[IndexA];\r
       IndexU++;\r
-      if (IndexU >= DXE_PERFORMANCE_STRING_LENGTH) {\r
-        UnicodeBuffer[DXE_PERFORMANCE_STRING_LENGTH] = 0;\r
+      if (IndexU >= DP_GAUGE_STRING_LENGTH) {\r
+        UnicodeBuffer[DP_GAUGE_STRING_LENGTH] = 0;\r
         break;\r
       }\r
     }\r
@@ -221,6 +221,9 @@ GetNameFromHandle (
   CHAR8                       *BestLanguage;\r
   EFI_COMPONENT_NAME2_PROTOCOL      *ComponentName2;\r
 \r
+  Image = NULL;\r
+  LoadedImageDevicePath = NULL;\r
+  DevicePath = NULL;\r
   BestLanguage     = NULL;\r
   PlatformLanguage = NULL;\r
 \r
@@ -290,10 +293,11 @@ GetNameFromHandle (
                                );\r
     SafeFreePool (BestLanguage);\r
     if (!EFI_ERROR (Status)) {\r
-      StrCpyS (\r
+      StrnCpyS (\r
         mGaugeString,\r
         DP_GAUGE_STRING_LENGTH + 1,\r
-        StringPtr\r
+        StringPtr,\r
+        DP_GAUGE_STRING_LENGTH\r
         );\r
       return;\r
     }\r
@@ -306,9 +310,13 @@ GetNameFromHandle (
                   );\r
   if (!EFI_ERROR (Status) && (LoadedImageDevicePath != NULL)) {\r
     DevicePath = LoadedImageDevicePath;\r
+  } else if (Image != NULL) {\r
+    DevicePath = Image->FilePath;\r
+  }\r
 \r
+  if (DevicePath != NULL) {\r
     //\r
-    // Try to get image GUID from LoadedImageDevicePath protocol\r
+    // Try to get image GUID from image DevicePath\r
     //\r
     NameGuid = NULL;\r
     while (!IsDevicePathEndType (DevicePath)) {\r
@@ -337,10 +345,11 @@ GetNameFromHandle (
         //\r
         // Method 3. Get the name string from FFS UI section\r
         //\r
-        StrCpyS (\r
+        StrnCpyS (\r
           mGaugeString,\r
           DP_GAUGE_STRING_LENGTH + 1,\r
-          NameString\r
+          NameString,\r
+          DP_GAUGE_STRING_LENGTH\r
           );\r
         FreePool (NameString);\r
       } else {\r
@@ -354,12 +363,13 @@ GetNameFromHandle (
       //\r
       // Method 5: Get the name string from image DevicePath\r
       //\r
-      NameString = ConvertDevicePathToText (LoadedImageDevicePath, TRUE, FALSE);\r
+      NameString = ConvertDevicePathToText (DevicePath, TRUE, FALSE);\r
       if (NameString != NULL) {\r
-        StrCpyS (\r
+        StrnCpyS (\r
           mGaugeString,\r
           DP_GAUGE_STRING_LENGTH + 1,\r
-          NameString\r
+          NameString,\r
+          DP_GAUGE_STRING_LENGTH\r
           );\r
         FreePool (NameString);\r
         return;\r