summaryrefslogtreecommitdiff
path: root/ShellPkg/Library/UefiHandleParsingLib
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2016-06-16 14:33:10 +0800
committerHao Wu <hao.a.wu@intel.com>2016-07-13 20:43:44 +0800
commit312f112538a0c469239c88943493a0133d6ba110 (patch)
tree1ef62b7e6ccb1d5cb7fe6acfeeeb50a8f28c1b9f /ShellPkg/Library/UefiHandleParsingLib
parent4af19364f44e5eec47c93dcebed215cd6e8504e6 (diff)
downloadedk2-platforms-312f112538a0c469239c88943493a0133d6ba110.tar.xz
ShellPkg/UefiHandleParsing: Show handle's loaded image device path
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> (cherry picked from commit 5e32460d8050fbc088230183151865c671a4e2df)
Diffstat (limited to 'ShellPkg/Library/UefiHandleParsingLib')
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c83
1 files changed, 68 insertions, 15 deletions
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 9789471892..b82f925c92 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -731,6 +731,42 @@ DriverEfiVersionProtocolDumpInformation(
UnicodeSPrint(RetVal, VersionStringSize, L"0x%08x", DriverEfiVersion->FirmwareVersion);
return (RetVal);
}
+/**
+ Function to convert device path to string.
+
+ This will allocate the return buffer from boot services pool.
+
+ @param[in] DevPath Pointer to device path instance.
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.
+ @param[in] Length Maximum allowed text length of the device path.
+
+ @retval A pointer to a string containing the information.
+**/
+CHAR16*
+ConvertDevicePathToShortText(
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath,
+ IN CONST BOOLEAN Verbose,
+ IN CONST UINTN Length
+ )
+{
+ CHAR16 *Temp;
+ CHAR16 *Temp2;
+ UINTN Size;
+
+ //
+ // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)
+ //
+ Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);
+ if (!Verbose && Temp != NULL && StrLen(Temp) > Length) {
+ Temp2 = NULL;
+ Size = 0;
+ Temp2 = StrnCatGrow(&Temp2, &Size, L"..", 0);
+ Temp2 = StrnCatGrow(&Temp2, &Size, Temp+(StrLen(Temp) - (Length - 2)), 0);
+ FreePool(Temp);
+ Temp = Temp2;
+ }
+ return (Temp);
+}
/**
Function to dump information about DevicePath protocol.
@@ -740,7 +776,7 @@ DriverEfiVersionProtocolDumpInformation(
@param[in] TheHandle The handle that has the protocol installed.
@param[in] Verbose TRUE for additional information, FALSE otherwise.
- @retval A poitner to a string containing the information.
+ @retval A pointer to a string containing the information.
**/
CHAR16*
EFIAPI
@@ -751,26 +787,43 @@ DevicePathProtocolDumpInformation(
{
EFI_DEVICE_PATH_PROTOCOL *DevPath;
CHAR16 *Temp;
- CHAR16 *Temp2;
EFI_STATUS Status;
- UINTN Size;
Temp = NULL;
Status = gBS->OpenProtocol(TheHandle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (!EFI_ERROR(Status)) {
- //
- // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)
- //
- Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);
+ Temp = ConvertDevicePathToShortText (DevPath, Verbose, 30);
gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);
}
- if (!Verbose && Temp != NULL && StrLen(Temp) > 30) {
- Temp2 = NULL;
- Size = 0;
- Temp2 = StrnCatGrow(&Temp2, &Size, L"..", 0);
- Temp2 = StrnCatGrow(&Temp2, &Size, Temp+(StrLen(Temp) - 28), 0);
- FreePool(Temp);
- Temp = Temp2;
+ return (Temp);
+}
+
+/**
+ Function to dump information about LoadedImageDevicePath protocol.
+
+ This will allocate the return buffer from boot services pool.
+
+ @param[in] TheHandle The handle that has the protocol installed.
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.
+
+ @retval A pointer to a string containing the information.
+**/
+CHAR16*
+EFIAPI
+LoadedImageDevicePathProtocolDumpInformation(
+ IN CONST EFI_HANDLE TheHandle,
+ IN CONST BOOLEAN Verbose
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;
+ CHAR16 *Temp;
+ EFI_STATUS Status;
+ Temp = NULL;
+
+ Status = gBS->OpenProtocol(TheHandle, &gEfiLoadedImageDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (!EFI_ERROR(Status)) {
+ Temp = ConvertDevicePathToShortText (DevPath, Verbose, 30);
+ gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);
}
return (Temp);
}
@@ -1454,7 +1507,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringListNT[] = {
STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
{STRING_TOKEN(STR_LOADED_IMAGE), &gEfiLoadedImageProtocolGuid, LoadedImageProtocolDumpInformation},
{STRING_TOKEN(STR_DEVICE_PATH), &gEfiDevicePathProtocolGuid, DevicePathProtocolDumpInformation},
- {STRING_TOKEN(STR_IMAGE_PATH), &gEfiLoadedImageDevicePathProtocolGuid, DevicePathProtocolDumpInformation},
+ {STRING_TOKEN(STR_IMAGE_PATH), &gEfiLoadedImageDevicePathProtocolGuid, LoadedImageDevicePathProtocolDumpInformation},
{STRING_TOKEN(STR_DEVICE_PATH_UTIL), &gEfiDevicePathUtilitiesProtocolGuid, NULL},
{STRING_TOKEN(STR_DEVICE_PATH_TXT), &gEfiDevicePathToTextProtocolGuid, NULL},
{STRING_TOKEN(STR_DEVICE_PATH_FTXT), &gEfiDevicePathFromTextProtocolGuid, NULL},