summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2016-06-16 14:33:10 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2016-06-21 15:59:26 +0800
commit5e32460d8050fbc088230183151865c671a4e2df (patch)
tree12d171c821d366ef9ae735a80c9e2980c9b0339a /ShellPkg
parent37e86e267be46ec4e2b7f97e70059e25912cea6b (diff)
downloadedk2-platforms-5e32460d8050fbc088230183151865c671a4e2df.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>
Diffstat (limited to 'ShellPkg')
-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},