+\r
+/**\r
+ Locate and return the protocol instance identified by the ProtocolGuid.\r
+\r
+ @param ProtocolGuid The GUID of the protocol.\r
+\r
+ @return A pointer to the protocol instance or NULL when absent.\r
+**/\r
+VOID *\r
+UefiDevicePathLibLocateProtocol (\r
+ EFI_GUID *ProtocolGuid\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ VOID *Protocol;\r
+ Status = gBS->LocateProtocol (\r
+ ProtocolGuid,\r
+ NULL,\r
+ (VOID**) &Protocol\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ } else {\r
+ return Protocol;\r
+ }\r
+}\r
+\r
+/**\r
+ Converts a device node to its string representation.\r
+\r
+ @param DeviceNode A Pointer to the device node to be converted.\r
+ @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
+ of the display node is used, where applicable. If DisplayOnly\r
+ is FALSE, then the longer text representation of the display node\r
+ is used.\r
+ @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
+ representation for a device node can be used, where applicable.\r
+\r
+ @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
+ is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ConvertDeviceNodeToText (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ if (mDevicePathLibDevicePathToText == NULL) {\r
+ mDevicePathLibDevicePathToText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathToTextProtocolGuid);\r
+ }\r
+ if (mDevicePathLibDevicePathToText != NULL) {\r
+ return mDevicePathLibDevicePathToText->ConvertDeviceNodeToText (DeviceNode, DisplayOnly, AllowShortcuts);\r
+ } else {\r
+ return NULL;\r
+ }\r
+}\r
+\r
+/**\r
+ Converts a device path to its text representation.\r
+\r
+ @param DevicePath A Pointer to the device to be converted.\r
+ @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
+ of the display node is used, where applicable. If DisplayOnly\r
+ is FALSE, then the longer text representation of the display node\r
+ is used.\r
+ @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
+ representation for a device node can be used, where applicable.\r
+\r
+ @return A pointer to the allocated text representation of the device path or\r
+ NULL if DeviceNode is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ConvertDevicePathToText (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
+ )\r
+{\r
+ if (mDevicePathLibDevicePathToText == NULL) {\r
+ mDevicePathLibDevicePathToText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathToTextProtocolGuid);\r
+ }\r
+ if (mDevicePathLibDevicePathToText != NULL) {\r
+ return mDevicePathLibDevicePathToText->ConvertDevicePathToText (DevicePath, DisplayOnly, AllowShortcuts);\r
+ } else {\r
+ return NULL;\r
+ }\r
+}\r
+\r
+/**\r
+ Convert text to the binary representation of a device node.\r
+\r
+ @param TextDeviceNode TextDeviceNode points to the text representation of a device\r
+ node. Conversion starts with the first character and continues\r
+ until the first non-device node character.\r
+\r
+ @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
+ insufficient memory or text unsupported.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+ConvertTextToDeviceNode (\r
+ IN CONST CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ if (mDevicePathLibDevicePathFromText == NULL) {\r
+ mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid);\r
+ }\r
+ if (mDevicePathLibDevicePathFromText != NULL) {\r
+ return mDevicePathLibDevicePathFromText->ConvertTextToDeviceNode (TextDeviceNode);\r
+ } else {\r
+ return NULL;\r
+ }\r
+}\r
+\r
+/**\r
+ Convert text to the binary representation of a device path.\r
+\r
+\r
+ @param TextDevicePath TextDevicePath points to the text representation of a device\r
+ path. Conversion starts with the first character and continues\r
+ until the first non-device node character.\r
+\r
+ @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
+ there was insufficient memory.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+ConvertTextToDevicePath (\r
+ IN CONST CHAR16 *TextDevicePath\r
+ )\r
+{\r
+ if (mDevicePathLibDevicePathFromText == NULL) {\r
+ mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid);\r
+ }\r
+ if (mDevicePathLibDevicePathFromText != NULL) {\r
+ return mDevicePathLibDevicePathFromText->ConvertTextToDevicePath (TextDevicePath);\r
+ } else {\r
+ return NULL;\r
+ }\r
+}\r
+\r