Follow UEFI spec to convert unrecognized device path structure from/to hex dump text.
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15119 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
DevicePathToText protocol as defined in the UEFI 2.0 specification.
|
||||
|
||||
Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -1755,6 +1755,15 @@ DevPathToTextEndInstance (
|
||||
UefiDevicePathLibCatPrint (Str, L",");
|
||||
}
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_GENERIC_TABLE mUefiDevicePathLibToTextTableGeneric[] = {
|
||||
{HARDWARE_DEVICE_PATH, L"HardwarePath" },
|
||||
{ACPI_DEVICE_PATH, L"AcpiPath" },
|
||||
{MESSAGING_DEVICE_PATH, L"Msg" },
|
||||
{MEDIA_DEVICE_PATH, L"MediaPath" },
|
||||
{BBS_DEVICE_PATH, L"BbsPath" },
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
/**
|
||||
Converts an unknown device path structure to its string representative.
|
||||
|
||||
@@ -1769,17 +1778,48 @@ DevPathToTextEndInstance (
|
||||
|
||||
**/
|
||||
VOID
|
||||
DevPathToTextNodeUnknown (
|
||||
DevPathToTextNodeGeneric (
|
||||
IN OUT POOL_PRINT *Str,
|
||||
IN VOID *DevPath,
|
||||
IN BOOLEAN DisplayOnly,
|
||||
IN BOOLEAN AllowShortcuts
|
||||
)
|
||||
{
|
||||
UefiDevicePathLibCatPrint (Str, L"?");
|
||||
EFI_DEVICE_PATH_PROTOCOL *Node;
|
||||
UINTN Index;
|
||||
|
||||
Node = DevPath;
|
||||
|
||||
for (Index = 0; mUefiDevicePathLibToTextTableGeneric[Index].Text != NULL; Index++) {
|
||||
if (DevicePathType (Node) == mUefiDevicePathLibToTextTableGeneric[Index].Type) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mUefiDevicePathLibToTextTableGeneric[Index].Text == NULL) {
|
||||
//
|
||||
// It's a node whose type cannot be recognized
|
||||
//
|
||||
UefiDevicePathLibCatPrint (Str, L"Path(%d,%d", DevicePathType (Node), DevicePathSubType (Node));
|
||||
} else {
|
||||
//
|
||||
// It's a node whose type can be recognized
|
||||
//
|
||||
UefiDevicePathLibCatPrint (Str, L"%s(%d", mUefiDevicePathLibToTextTableGeneric[Index].Text, DevicePathSubType (Node));
|
||||
}
|
||||
|
||||
Index = sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
||||
if (Index < DevicePathNodeLength (Node)) {
|
||||
UefiDevicePathLibCatPrint (Str, L",");
|
||||
for (; Index < DevicePathNodeLength (Node); Index++) {
|
||||
UefiDevicePathLibCatPrint (Str, L"%02x", ((UINT8 *) Node)[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
UefiDevicePathLibCatPrint (Str, L")");
|
||||
}
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibDevPathToTextTable[] = {
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = {
|
||||
{HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci },
|
||||
{HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard },
|
||||
{HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap },
|
||||
@@ -1858,12 +1898,12 @@ UefiDevicePathLibConvertDeviceNodeToText (
|
||||
// Process the device path node
|
||||
// If not found, use a generic function
|
||||
//
|
||||
ToText = DevPathToTextNodeUnknown;
|
||||
for (Index = 0; mUefiDevicePathLibDevPathToTextTable[Index].Function != NULL; Index++) {
|
||||
if (DevicePathType (DeviceNode) == mUefiDevicePathLibDevPathToTextTable[Index].Type &&
|
||||
DevicePathSubType (DeviceNode) == mUefiDevicePathLibDevPathToTextTable[Index].SubType
|
||||
ToText = DevPathToTextNodeGeneric;
|
||||
for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index++) {
|
||||
if (DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type &&
|
||||
DevicePathSubType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].SubType
|
||||
) {
|
||||
ToText = mUefiDevicePathLibDevPathToTextTable[Index].Function;
|
||||
ToText = mUefiDevicePathLibToTextTable[Index].Function;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1921,13 +1961,13 @@ UefiDevicePathLibConvertDevicePathToText (
|
||||
// Find the handler to dump this device path node
|
||||
// If not found, use a generic function
|
||||
//
|
||||
ToText = DevPathToTextNodeUnknown;
|
||||
for (Index = 0; mUefiDevicePathLibDevPathToTextTable[Index].Function != NULL; Index += 1) {
|
||||
ToText = DevPathToTextNodeGeneric;
|
||||
for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index += 1) {
|
||||
|
||||
if (DevicePathType (Node) == mUefiDevicePathLibDevPathToTextTable[Index].Type &&
|
||||
DevicePathSubType (Node) == mUefiDevicePathLibDevPathToTextTable[Index].SubType
|
||||
if (DevicePathType (Node) == mUefiDevicePathLibToTextTable[Index].Type &&
|
||||
DevicePathSubType (Node) == mUefiDevicePathLibToTextTable[Index].SubType
|
||||
) {
|
||||
ToText = mUefiDevicePathLibDevPathToTextTable[Index].Function;
|
||||
ToText = mUefiDevicePathLibToTextTable[Index].Function;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user