diff options
author | Huajing Li <huajing.li@intel.com> | 2017-09-21 14:13:59 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2017-09-25 08:32:16 +0800 |
commit | f6e0c4b401e52c5cc14452e1130d3bbaea5f9dbf (patch) | |
tree | 90be1cb98f262023762bd8c3bb6219af90a9d92f /ShellPkg/Library/UefiHandleParsingLib | |
parent | 7f04c460266cdfb45edd20af5db1a7a331d4d3f2 (diff) | |
download | edk2-f6e0c4b401e52c5cc14452e1130d3bbaea5f9dbf.zip edk2-f6e0c4b401e52c5cc14452e1130d3bbaea5f9dbf.tar.gz edk2-f6e0c4b401e52c5cc14452e1130d3bbaea5f9dbf.tar.bz2 |
ShellPkg/dh: Modify the dump of "ImageDevicePath" and "DevicePath"
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Huajing Li <huajing.li@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Diffstat (limited to 'ShellPkg/Library/UefiHandleParsingLib')
-rw-r--r-- | ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c | 68 |
1 files changed, 46 insertions, 22 deletions
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index d3ee068..1f2ca92 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -848,6 +848,50 @@ ConvertDevicePathToShortText( }
/**
+ 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.
This will allocate the return buffer from boot services pool.
@@ -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);
}
/**
|