]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/UefiHandleParsing: Show handle's loaded image device path
authorRuiyu Ni <ruiyu.ni@intel.com>
Thu, 16 Jun 2016 06:33:10 +0000 (14:33 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Tue, 21 Jun 2016 07:59:26 +0000 (15:59 +0800)
The patch fixed a bug in UefiHandleParsingLib to show handle's loaded
image device path.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c

index 97894718922fdd609d3f51f12fe8e4ae149d3cb9..b82f925c9218293a09d8ed45b936dba7668f304f 100644 (file)
@@ -731,6 +731,42 @@ DriverEfiVersionProtocolDumpInformation(
   UnicodeSPrint(RetVal, VersionStringSize, L"0x%08x", DriverEfiVersion->FirmwareVersion);\r
   return (RetVal);\r
 }\r
+/**\r
+  Function to convert device path to string.\r
+\r
+  This will allocate the return buffer from boot services pool.\r
+\r
+  @param[in] DevPath        Pointer to device path instance.\r
+  @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
+  @param[in] Length         Maximum allowed text length of the device path.\r
+\r
+  @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+ConvertDevicePathToShortText(\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath,\r
+  IN CONST BOOLEAN                  Verbose,\r
+  IN CONST UINTN                    Length\r
+  )\r
+{\r
+  CHAR16                            *Temp;\r
+  CHAR16                            *Temp2;\r
+  UINTN                             Size;\r
+\r
+  //\r
+  // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)\r
+  //\r
+  Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);\r
+  if (!Verbose && Temp != NULL && StrLen(Temp) > Length) {\r
+    Temp2 = NULL;\r
+    Size  = 0;\r
+    Temp2 = StrnCatGrow(&Temp2, &Size, L"..", 0);\r
+    Temp2 = StrnCatGrow(&Temp2, &Size, Temp+(StrLen(Temp) - (Length - 2)), 0);\r
+    FreePool(Temp);\r
+    Temp = Temp2;\r
+  }\r
+  return (Temp);\r
+}\r
 \r
 /**\r
   Function to dump information about DevicePath protocol.\r
@@ -740,7 +776,7 @@ DriverEfiVersionProtocolDumpInformation(
   @param[in] TheHandle      The handle that has the protocol installed.\r
   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
 \r
-  @retval A poitner to a string containing the information.\r
+  @retval A pointer to a string containing the information.\r
 **/\r
 CHAR16*\r
 EFIAPI\r
@@ -751,26 +787,43 @@ DevicePathProtocolDumpInformation(
 {\r
   EFI_DEVICE_PATH_PROTOCOL          *DevPath;\r
   CHAR16                            *Temp;\r
-  CHAR16                            *Temp2;\r
   EFI_STATUS                        Status;\r
-  UINTN                             Size;\r
   Temp = NULL;\r
 \r
   Status = gBS->OpenProtocol(TheHandle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
   if (!EFI_ERROR(Status)) {\r
-    //\r
-    // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)\r
-    //\r
-    Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);\r
+    Temp = ConvertDevicePathToShortText (DevPath, Verbose, 30);\r
     gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);\r
   }\r
-  if (!Verbose && Temp != NULL && StrLen(Temp) > 30) {\r
-    Temp2 = NULL;\r
-    Size  = 0;\r
-    Temp2 = StrnCatGrow(&Temp2, &Size, L"..", 0);\r
-    Temp2 = StrnCatGrow(&Temp2, &Size, Temp+(StrLen(Temp) - 28), 0);\r
-    FreePool(Temp);\r
-    Temp = Temp2;\r
+  return (Temp);\r
+}\r
+\r
+/**\r
+  Function to dump information about LoadedImageDevicePath protocol.\r
+\r
+  This will allocate the return buffer from boot services pool.\r
+\r
+  @param[in] TheHandle      The handle that has the protocol installed.\r
+  @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
+\r
+  @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+LoadedImageDevicePathProtocolDumpInformation(\r
+  IN CONST EFI_HANDLE TheHandle,\r
+  IN CONST BOOLEAN    Verbose\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL          *DevPath;\r
+  CHAR16                            *Temp;\r
+  EFI_STATUS                        Status;\r
+  Temp = NULL;\r
+\r
+  Status = gBS->OpenProtocol(TheHandle, &gEfiLoadedImageDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
+  if (!EFI_ERROR(Status)) {\r
+    Temp = ConvertDevicePathToShortText (DevPath, Verbose, 30);\r
+    gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);\r
   }\r
   return (Temp);\r
 }\r
@@ -1454,7 +1507,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringListNT[] = {
 STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {\r
   {STRING_TOKEN(STR_LOADED_IMAGE),          &gEfiLoadedImageProtocolGuid,                     LoadedImageProtocolDumpInformation},\r
   {STRING_TOKEN(STR_DEVICE_PATH),           &gEfiDevicePathProtocolGuid,                      DevicePathProtocolDumpInformation},\r
-  {STRING_TOKEN(STR_IMAGE_PATH),            &gEfiLoadedImageDevicePathProtocolGuid,           DevicePathProtocolDumpInformation},\r
+  {STRING_TOKEN(STR_IMAGE_PATH),            &gEfiLoadedImageDevicePathProtocolGuid,           LoadedImageDevicePathProtocolDumpInformation},\r
   {STRING_TOKEN(STR_DEVICE_PATH_UTIL),      &gEfiDevicePathUtilitiesProtocolGuid,             NULL},\r
   {STRING_TOKEN(STR_DEVICE_PATH_TXT),       &gEfiDevicePathToTextProtocolGuid,                NULL},\r
   {STRING_TOKEN(STR_DEVICE_PATH_FTXT),      &gEfiDevicePathFromTextProtocolGuid,              NULL},\r