+/**\r
+ Transfer the device path string to binary format.\r
+\r
+ @param StringPtr The device path string info.\r
+\r
+ @retval Device path binary info.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+ConvertDevicePathFromText (\r
+ IN CHAR16 *StringPtr\r
+ )\r
+{\r
+ UINTN BufferSize;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ CHAR16 TemStr[2];\r
+ UINT8 *DevicePathBuffer;\r
+ UINTN Index;\r
+ UINT8 DigitUint8;\r
+\r
+ ASSERT (StringPtr != NULL);\r
+\r
+ BufferSize = StrLen (StringPtr) / 2;\r
+ DevicePath = AllocatePool (BufferSize);\r
+ ASSERT (DevicePath != NULL);\r
+ \r
+ //\r
+ // Convert from Device Path String to DevicePath Buffer in the reverse order.\r
+ //\r
+ DevicePathBuffer = (UINT8 *) DevicePath;\r
+ for (Index = 0; StringPtr[Index] != L'\0'; Index ++) {\r
+ TemStr[0] = StringPtr[Index];\r
+ DigitUint8 = (UINT8) StrHexToUint64 (TemStr);\r
+ if (DigitUint8 == 0 && TemStr[0] != L'0') {\r
+ //\r
+ // Invalid Hex Char as the tail.\r
+ //\r
+ break;\r
+ }\r
+ if ((Index & 1) == 0) {\r
+ DevicePathBuffer [Index/2] = DigitUint8;\r
+ } else {\r
+ DevicePathBuffer [Index/2] = (UINT8) ((DevicePathBuffer [Index/2] << 4) + DigitUint8);\r
+ }\r
+ }\r
+\r
+ return DevicePath;\r
+}\r
+\r