summaryrefslogtreecommitdiff
path: root/MdePkg/Library/UefiDevicePathLib
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/UefiDevicePathLib')
-rw-r--r--MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c151
-rw-r--r--MdePkg/Library/UefiDevicePathLib/DevicePathToText.c68
-rw-r--r--MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h7
3 files changed, 210 insertions, 16 deletions
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index 8943191bd..008ec0b96 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -1,7 +1,7 @@
/** @file
DevicePathFromText 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
@@ -535,6 +535,79 @@ StrToAscii (
}
/**
+ Converts a generic text device path node to device path structure.
+
+ @param Type The type of the device path node.
+ @param TextDeviceNode The input text device path node.
+
+ @return A pointer to device path structure.
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextGenericPath (
+ IN UINT8 Type,
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+ CHAR16 *SubtypeStr;
+ CHAR16 *DataStr;
+ UINTN DataLength;
+
+ SubtypeStr = GetNextParamStr (&TextDeviceNode);
+ DataStr = GetNextParamStr (&TextDeviceNode);
+
+ if (DataStr == NULL) {
+ DataLength = 0;
+ } else {
+ DataLength = StrLen (DataStr) / 2;
+ }
+ Node = CreateDeviceNode (
+ Type,
+ (UINT8) Strtoi (SubtypeStr),
+ (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)
+ );
+
+ StrToBuf ((UINT8 *) (Node + 1), DataLength, DataStr);
+ return Node;
+}
+
+/**
+ Converts a generic text device path node to device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextPath (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *TypeStr;
+
+ TypeStr = GetNextParamStr (&TextDeviceNode);
+
+ return DevPathFromTextGenericPath ((UINT8) Strtoi (TypeStr), TextDeviceNode);
+}
+
+/**
+ Converts a generic hardware text device path node to Hardware device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to Hardware device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextHardwarePath (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH, TextDeviceNode);
+}
+
+/**
Converts a text device path node to Hardware PCI device path structure.
@param TextDeviceNode The input Text device path node.
@@ -719,6 +792,22 @@ DevPathFromTextCtrl (
}
/**
+ Converts a generic ACPI text device path node to ACPI device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to ACPI device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextAcpiPath (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return DevPathFromTextGenericPath (ACPI_DEVICE_PATH, TextDeviceNode);
+}
+
+/**
Converts a string to EisaId.
@param Text The input string.
@@ -1046,6 +1135,22 @@ DevPathFromTextAcpiAdr (
}
/**
+ Converts a generic messaging text device path node to messaging device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to messaging device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextMsg (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH, TextDeviceNode);
+}
+
+/**
Converts a text device path node to Parallel Port device path structure.
@param TextDeviceNode The input Text device path node.
@@ -2521,6 +2626,22 @@ DevPathFromTextVlan (
}
/**
+ Converts a media text device path node to media device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to media device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextMediaPath (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH, TextDeviceNode);
+}
+
+/**
Converts a text device path node to HD device path structure.
@param TextDeviceNode The input Text device path node.
@@ -2775,6 +2896,23 @@ DevPathFromTextRelativeOffsetRange (
return (EFI_DEVICE_PATH_PROTOCOL *) Offset;
}
+
+/**
+ Converts a BBS text device path node to BBS device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to BBS device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextBbsPath (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ return DevPathFromTextGenericPath (BBS_DEVICE_PATH, TextDeviceNode);
+}
+
/**
Converts a text device path node to BIOS Boot Specification device path structure.
@@ -2862,11 +3000,16 @@ DevPathFromTextSata (
}
GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable[] = {
+ {L"Path", DevPathFromTextPath },
+
+ {L"HardwarePath", DevPathFromTextHardwarePath },
{L"Pci", DevPathFromTextPci },
{L"PcCard", DevPathFromTextPcCard },
{L"MemoryMapped", DevPathFromTextMemoryMapped },
{L"VenHw", DevPathFromTextVenHw },
{L"Ctrl", DevPathFromTextCtrl },
+
+ {L"AcpiPath", DevPathFromTextAcpiPath },
{L"Acpi", DevPathFromTextAcpi },
{L"PciRoot", DevPathFromTextPciRoot },
{L"PcieRoot", DevPathFromTextPcieRoot },
@@ -2877,6 +3020,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
{L"AcpiEx", DevPathFromTextAcpiEx },
{L"AcpiExp", DevPathFromTextAcpiExp },
{L"AcpiAdr", DevPathFromTextAcpiAdr },
+
+ {L"Msg", DevPathFromTextMsg },
{L"Ata", DevPathFromTextAta },
{L"Scsi", DevPathFromTextScsi },
{L"Fibre", DevPathFromTextFibre },
@@ -2918,6 +3063,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
{L"Unit", DevPathFromTextUnit },
{L"iSCSI", DevPathFromTextiSCSI },
{L"Vlan", DevPathFromTextVlan },
+
+ {L"MediaPath", DevPathFromTextMediaPath },
{L"HD", DevPathFromTextHD },
{L"CDROM", DevPathFromTextCDROM },
{L"VenMedia", DevPathFromTextVenMedia },
@@ -2925,6 +3072,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
{L"Fv", DevPathFromTextFv },
{L"FvFile", DevPathFromTextFvFile },
{L"Offset", DevPathFromTextRelativeOffsetRange },
+
+ {L"BbsPath", DevPathFromTextBbsPath },
{L"BBS", DevPathFromTextBBS },
{L"Sata", DevPathFromTextSata },
{NULL, NULL}
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index eebdbf239..9b1ca8e28 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -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;
}
}
diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h
index a7ed53189..233844cfc 100644
--- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h
+++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h
@@ -1,7 +1,7 @@
/** @file
Definition for Device Path library.
-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
@@ -69,6 +69,11 @@ typedef struct {
} DEVICE_PATH_TO_TEXT_TABLE;
typedef struct {
+ UINT8 Type;
+ CHAR16 *Text;
+} DEVICE_PATH_TO_TEXT_GENERIC_TABLE;
+
+typedef struct {
CHAR16 *DevicePathNodeText;
DEVICE_PATH_FROM_TEXT Function;
} DEVICE_PATH_FROM_TEXT_TABLE;