From f6e0c4b401e52c5cc14452e1130d3bbaea5f9dbf Mon Sep 17 00:00:00 2001 From: Huajing Li Date: Thu, 21 Sep 2017 14:13:59 +0800 Subject: ShellPkg/dh: Modify the dump of "ImageDevicePath" and "DevicePath" Reviewed-by: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Huajing Li Reviewed-by: Jaben Carsey --- .../UefiHandleParsingLib/UefiHandleParsingLib.c | 68 +++++++++++++++------- 1 file changed, 46 insertions(+), 22 deletions(-) (limited to 'ShellPkg') diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index d3ee068eba..1f2ca92bdd 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -847,6 +847,50 @@ ConvertDevicePathToShortText( return (Temp); } +/** + Function to dump protocol information. + + 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. + @param[in] Protocol The protocol is needed to dump. + + @retval A pointer to a string containing the information. +**/ +STATIC CHAR16* +EFIAPI +DevicePathProtocolDumpInformationEx ( + IN CONST EFI_HANDLE TheHandle, + IN CONST BOOLEAN Verbose, + IN EFI_GUID *Protocol +) +{ + EFI_DEVICE_PATH_PROTOCOL *DevPath; + CHAR16 *DevPathStr; + CHAR16 *DevPathStrTemp; + UINTN Size; + EFI_STATUS Status; + DevPathStr = NULL; + DevPathStrTemp = NULL; + Status = gBS->OpenProtocol(TheHandle, Protocol, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (!EFI_ERROR(Status)) { + DevPathStr = ConvertDevicePathToShortText (DevPath, Verbose, 30); + if (Verbose) { + Size = StrSize(DevPathStr) + sizeof(CHAR16) * 2; + DevPathStrTemp = AllocateZeroPool (Size); + if (DevPathStrTemp != NULL) { + StrnCatS (DevPathStrTemp, Size/sizeof(CHAR16), L" ", 2); + StrnCatS (DevPathStrTemp, Size/sizeof(CHAR16), DevPathStr, StrLen (DevPathStr)); + } + FreePool (DevPathStr); + DevPathStr = DevPathStrTemp; + } + gBS->CloseProtocol(TheHandle, Protocol, gImageHandle, NULL); + } + return DevPathStr; +} + /** Function to dump information about DevicePath protocol. @@ -864,17 +908,7 @@ DevicePathProtocolDumpInformation( IN CONST BOOLEAN Verbose ) { - EFI_DEVICE_PATH_PROTOCOL *DevPath; - CHAR16 *Temp; - EFI_STATUS Status; - Temp = NULL; - - Status = gBS->OpenProtocol(TheHandle, &gEfiDevicePathProtocolGuid, (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); + return DevicePathProtocolDumpInformationEx (TheHandle, Verbose, &gEfiDevicePathProtocolGuid); } /** @@ -894,17 +928,7 @@ LoadedImageDevicePathProtocolDumpInformation( 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); + return DevicePathProtocolDumpInformationEx (TheHandle, Verbose, &gEfiLoadedImageDevicePathProtocolGuid); } /** -- cgit v1.2.3