]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiDpLib/DpUtilities.c
ShellPkg/tftp: Convert from NULL class library to Dynamic Command
[mirror_edk2.git] / ShellPkg / Library / UefiDpLib / DpUtilities.c
index 5237459e5b005f2d9a490afc16c9b34e2de9bac1..c60d27d8613f0572ee13ead10644c71423138f53 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Utility functions used by the Dp application.\r
 \r
-  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.\r
-  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
+  (C) Copyright 2015-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
@@ -17,7 +17,6 @@
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/TimerLib.h>\r
 #include <Library/PeCoffGetEntryPointLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/HiiLib.h>\r
@@ -68,6 +67,10 @@ GetDuration (
   UINT64    Duration;\r
   BOOLEAN   Error;\r
 \r
+  if (Measurement->EndTimeStamp == 0) {\r
+    return 0;\r
+  }\r
+\r
   // PERF_START macros are called with a value of 1 to indicate\r
   // the beginning of time.  So, adjust the start ticker value\r
   // to the real beginning of time.\r
@@ -151,7 +154,7 @@ DpGetShortPdbFileName (
     for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)\r
       ;\r
     for (IndexA = 0; PdbFileName[IndexA] != 0; IndexA++) {\r
-      if (PdbFileName[IndexA] == '\\') {\r
+      if ((PdbFileName[IndexA] == '\\') || (PdbFileName[IndexA] == '/')) {\r
         StartIndex = IndexA + 1;\r
       }\r
 \r
@@ -164,8 +167,8 @@ DpGetShortPdbFileName (
     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
@@ -206,6 +209,10 @@ DpGetNameFromHandle (
   CHAR8                       *PlatformLanguage;\r
   EFI_COMPONENT_NAME2_PROTOCOL      *ComponentName2;\r
 \r
+  Image = NULL;\r
+  LoadedImageDevicePath = NULL;\r
+  DevicePath = NULL;\r
+\r
   //\r
   // Method 1: Get the name string from image PDB\r
   //\r
@@ -275,9 +282,13 @@ DpGetNameFromHandle (
                   );\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
@@ -320,7 +331,7 @@ DpGetNameFromHandle (
       //\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
         StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, NameString, DP_GAUGE_STRING_LENGTH);\r
         mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r