MdePkg UefiDevicePathLib: Validate before touch input buffer.
[mirror_edk2.git] / MdePkg / Library / UefiDevicePathLib / DevicePathFromText.c
CommitLineData
13d40edd 1/** @file\r
2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.\r
95276127 3\r
ca2ac9d5 4Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 5This program and the accompanying materials\r
13d40edd 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
95276127 9\r
13d40edd 10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
95276127 12\r
13d40edd 13**/\r
95276127 14\r
4d0a30a4 15#include "UefiDevicePathLib.h"\r
95276127 16\r
572f5d8a 17/**\r
95276127 18\r
572f5d8a 19 Duplicates a string.\r
95276127 20\r
572f5d8a 21 @param Src Source string.\r
95276127 22\r
572f5d8a 23 @return The duplicated string.\r
24\r
25**/\r
26CHAR16 *\r
4d0a30a4 27UefiDevicePathLibStrDuplicate (\r
572f5d8a 28 IN CONST CHAR16 *Src\r
29 )\r
95276127 30{\r
572f5d8a 31 return AllocateCopyPool (StrSize (Src), Src);\r
32}\r
95276127 33\r
572f5d8a 34/**\r
95276127 35\r
572f5d8a 36 Get parameter in a pair of parentheses follow the given node name.\r
37 For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".\r
95276127 38\r
572f5d8a 39 @param Str Device Path Text.\r
40 @param NodeName Name of the node.\r
95276127 41\r
572f5d8a 42 @return Parameter text for the node.\r
43\r
44**/\r
95276127 45CHAR16 *\r
46GetParamByNodeName (\r
47 IN CHAR16 *Str,\r
48 IN CHAR16 *NodeName\r
49 )\r
95276127 50{\r
51 CHAR16 *ParamStr;\r
52 CHAR16 *StrPointer;\r
53 UINTN NodeNameLength;\r
54 UINTN ParameterLength;\r
55\r
56 //\r
57 // Check whether the node name matchs\r
58 //\r
59 NodeNameLength = StrLen (NodeName);\r
4d0a30a4 60 if (StrnCmp (Str, NodeName, NodeNameLength) != 0) {\r
95276127 61 return NULL;\r
62 }\r
63\r
64 ParamStr = Str + NodeNameLength;\r
65 if (!IS_LEFT_PARENTH (*ParamStr)) {\r
66 return NULL;\r
67 }\r
68\r
69 //\r
70 // Skip the found '(' and find first occurrence of ')'\r
71 //\r
72 ParamStr++;\r
73 ParameterLength = 0;\r
74 StrPointer = ParamStr;\r
75 while (!IS_NULL (*StrPointer)) {\r
76 if (IS_RIGHT_PARENTH (*StrPointer)) {\r
77 break;\r
78 }\r
79 StrPointer++;\r
80 ParameterLength++;\r
81 }\r
82 if (IS_NULL (*StrPointer)) {\r
83 //\r
84 // ')' not found\r
85 //\r
86 return NULL;\r
87 }\r
88\r
89 ParamStr = AllocateCopyPool ((ParameterLength + 1) * sizeof (CHAR16), ParamStr);\r
90 if (ParamStr == NULL) {\r
91 return NULL;\r
92 }\r
93 //\r
94 // Terminate the parameter string\r
95 //\r
96 ParamStr[ParameterLength] = L'\0';\r
97\r
98 return ParamStr;\r
99}\r
100\r
572f5d8a 101/**\r
102 Gets current sub-string from a string list, before return\r
103 the list header is moved to next sub-string. The sub-string is separated\r
104 by the specified character. For example, the separator is ',', the string\r
105 list is "2,0,3", it returns "2", the remain list move to "0,3"\r
106\r
107 @param List A string list separated by the specified separator\r
108 @param Separator The separator character\r
109\r
110 @return A pointer to the current sub-string\r
111\r
112**/\r
95276127 113CHAR16 *\r
114SplitStr (\r
115 IN OUT CHAR16 **List,\r
116 IN CHAR16 Separator\r
117 )\r
95276127 118{\r
119 CHAR16 *Str;\r
120 CHAR16 *ReturnStr;\r
121\r
122 Str = *List;\r
123 ReturnStr = Str;\r
124\r
125 if (IS_NULL (*Str)) {\r
126 return ReturnStr;\r
127 }\r
128\r
129 //\r
130 // Find first occurrence of the separator\r
131 //\r
132 while (!IS_NULL (*Str)) {\r
133 if (*Str == Separator) {\r
134 break;\r
135 }\r
136 Str++;\r
137 }\r
138\r
139 if (*Str == Separator) {\r
140 //\r
141 // Find a sub-string, terminate it\r
142 //\r
143 *Str = L'\0';\r
144 Str++;\r
145 }\r
146\r
147 //\r
148 // Move to next sub-string\r
149 //\r
150 *List = Str;\r
151\r
152 return ReturnStr;\r
153}\r
154\r
572f5d8a 155/**\r
156 Gets the next parameter string from the list.\r
157\r
158 @param List A string list separated by the specified separator\r
159\r
160 @return A pointer to the current sub-string\r
161\r
162**/\r
95276127 163CHAR16 *\r
164GetNextParamStr (\r
165 IN OUT CHAR16 **List\r
166 )\r
167{\r
168 //\r
169 // The separator is comma\r
170 //\r
171 return SplitStr (List, L',');\r
172}\r
173\r
572f5d8a 174/**\r
175 Get one device node from entire device path text.\r
176\r
177 @param DevicePath On input, the current Device Path node; on output, the next device path node\r
178 @param IsInstanceEnd This node is the end of a device path instance\r
179\r
180 @return A device node text or NULL if no more device node available\r
181\r
182**/\r
95276127 183CHAR16 *\r
184GetNextDeviceNodeStr (\r
185 IN OUT CHAR16 **DevicePath,\r
186 OUT BOOLEAN *IsInstanceEnd\r
187 )\r
95276127 188{\r
189 CHAR16 *Str;\r
190 CHAR16 *ReturnStr;\r
191 UINTN ParenthesesStack;\r
192\r
193 Str = *DevicePath;\r
194 if (IS_NULL (*Str)) {\r
195 return NULL;\r
196 }\r
197\r
198 //\r
199 // Skip the leading '/', '(', ')' and ','\r
200 //\r
201 while (!IS_NULL (*Str)) {\r
202 if (!IS_SLASH (*Str) &&\r
203 !IS_COMMA (*Str) &&\r
204 !IS_LEFT_PARENTH (*Str) &&\r
205 !IS_RIGHT_PARENTH (*Str)) {\r
206 break;\r
207 }\r
208 Str++;\r
209 }\r
210\r
211 ReturnStr = Str;\r
212\r
213 //\r
214 // Scan for the separator of this device node, '/' or ','\r
215 //\r
216 ParenthesesStack = 0;\r
217 while (!IS_NULL (*Str)) {\r
218 if ((IS_COMMA (*Str) || IS_SLASH (*Str)) && (ParenthesesStack == 0)) {\r
219 break;\r
220 }\r
221\r
222 if (IS_LEFT_PARENTH (*Str)) {\r
223 ParenthesesStack++;\r
224 } else if (IS_RIGHT_PARENTH (*Str)) {\r
225 ParenthesesStack--;\r
226 }\r
227\r
228 Str++;\r
229 }\r
230\r
231 if (ParenthesesStack != 0) {\r
232 //\r
233 // The '(' doesn't pair with ')', invalid device path text\r
234 //\r
235 return NULL;\r
236 }\r
237\r
238 if (IS_COMMA (*Str)) {\r
239 *IsInstanceEnd = TRUE;\r
240 *Str = L'\0';\r
241 Str++;\r
242 } else {\r
243 *IsInstanceEnd = FALSE;\r
244 if (!IS_NULL (*Str)) {\r
245 *Str = L'\0';\r
246 Str++;\r
247 }\r
248 }\r
249\r
250 *DevicePath = Str;\r
251\r
252 return ReturnStr;\r
253}\r
254\r
95276127 255\r
572f5d8a 256/**\r
4d0a30a4 257 Return whether the integer string is a hex string.\r
572f5d8a 258\r
259 @param Str The integer string\r
572f5d8a 260\r
4d0a30a4
RN
261 @retval TRUE Hex string\r
262 @retval FALSE Decimal string\r
572f5d8a 263\r
264**/\r
4d0a30a4
RN
265BOOLEAN\r
266IsHexStr (\r
267 IN CHAR16 *Str\r
95276127 268 )\r
95276127 269{\r
270 //\r
271 // skip preceeding white space\r
272 //\r
4d0a30a4
RN
273 while ((*Str != 0) && *Str == L' ') {\r
274 Str ++;\r
95276127 275 }\r
276 //\r
277 // skip preceeding zeros\r
278 //\r
4d0a30a4
RN
279 while ((*Str != 0) && *Str == L'0') {\r
280 Str ++;\r
cf40f28a 281 }\r
4d0a30a4
RN
282 \r
283 return (BOOLEAN) (*Str == L'x' || *Str == L'X');\r
cf40f28a 284}\r
285\r
572f5d8a 286/**\r
cf40f28a 287\r
288 Convert integer string to uint.\r
289\r
5755841f 290 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.\r
cf40f28a 291\r
572f5d8a 292 @return A UINTN value represented by Str\r
cf40f28a 293\r
572f5d8a 294**/\r
295UINTN\r
296Strtoi (\r
297 IN CHAR16 *Str\r
298 )\r
cf40f28a 299{\r
4d0a30a4
RN
300 if (IsHexStr (Str)) {\r
301 return StrHexToUintn (Str);\r
cf40f28a 302 } else {\r
4d0a30a4 303 return StrDecimalToUintn (Str);\r
cf40f28a 304 }\r
305}\r
306\r
572f5d8a 307/**\r
cf40f28a 308\r
309 Convert integer string to 64 bit data.\r
310\r
5755841f 311 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.\r
572f5d8a 312 @param Data A pointer to the UINT64 value represented by Str\r
cf40f28a 313\r
572f5d8a 314**/\r
315VOID\r
316Strtoi64 (\r
317 IN CHAR16 *Str,\r
318 OUT UINT64 *Data\r
319 )\r
cf40f28a 320{\r
4d0a30a4
RN
321 if (IsHexStr (Str)) {\r
322 *Data = StrHexToUint64 (Str);\r
cf40f28a 323 } else {\r
4d0a30a4 324 *Data = StrDecimalToUint64 (Str);\r
cf40f28a 325 }\r
326}\r
327\r
572f5d8a 328/**\r
329 Converts a list of string to a specified buffer.\r
330\r
331 @param Buf The output buffer that contains the string.\r
332 @param BufferLength The length of the buffer\r
333 @param Str The input string that contains the hex number\r
334\r
335 @retval EFI_SUCCESS The string was successfully converted to the buffer.\r
336\r
337**/\r
338EFI_STATUS\r
95276127 339StrToBuf (\r
340 OUT UINT8 *Buf,\r
341 IN UINTN BufferLength,\r
342 IN CHAR16 *Str\r
343 )\r
344{\r
345 UINTN Index;\r
346 UINTN StrLength;\r
347 UINT8 Digit;\r
348 UINT8 Byte;\r
349\r
6ee5bbdd 350 Digit = 0;\r
351\r
95276127 352 //\r
353 // Two hex char make up one byte\r
354 //\r
355 StrLength = BufferLength * sizeof (CHAR16);\r
356\r
357 for(Index = 0; Index < StrLength; Index++, Str++) {\r
358\r
ac7e320c
LG
359 if ((*Str >= L'a') && (*Str <= L'f')) {\r
360 Digit = (UINT8) (*Str - L'a' + 0x0A);\r
361 } else if ((*Str >= L'A') && (*Str <= L'F')) {\r
362 Digit = (UINT8) (*Str - L'A' + 0x0A);\r
363 } else if ((*Str >= L'0') && (*Str <= L'9')) {\r
364 Digit = (UINT8) (*Str - L'0');\r
365 } else {\r
366 return EFI_INVALID_PARAMETER;\r
367 }\r
95276127 368\r
369 //\r
5755841f 370 // For odd characters, write the upper nibble for each buffer byte,\r
95276127 371 // and for even characters, the lower nibble.\r
372 //\r
373 if ((Index & 1) == 0) {\r
374 Byte = (UINT8) (Digit << 4);\r
375 } else {\r
376 Byte = Buf[Index / 2];\r
377 Byte &= 0xF0;\r
378 Byte = (UINT8) (Byte | Digit);\r
379 }\r
380\r
381 Buf[Index / 2] = Byte;\r
382 }\r
383\r
384 return EFI_SUCCESS;\r
385}\r
386\r
572f5d8a 387/**\r
388 Converts a string to GUID value.\r
ac7e320c 389 Guid Format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\r
572f5d8a 390\r
391 @param Str The registry format GUID string that contains the GUID value.\r
392 @param Guid A pointer to the converted GUID value.\r
393\r
394 @retval EFI_SUCCESS The GUID string was successfully converted to the GUID value.\r
395 @retval EFI_UNSUPPORTED The input string is not in registry format.\r
396 @return others Some error occurred when converting part of GUID value.\r
397\r
398**/\r
95276127 399EFI_STATUS\r
400StrToGuid (\r
401 IN CHAR16 *Str,\r
402 OUT EFI_GUID *Guid\r
403 )\r
404{\r
ac7e320c
LG
405 //\r
406 // Get the first UINT32 data\r
407 //\r
408 Guid->Data1 = (UINT32) StrHexToUint64 (Str);\r
409 while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
410 Str ++;\r
95276127 411 }\r
ac7e320c 412 \r
95276127 413 if (IS_HYPHEN (*Str)) {\r
572f5d8a 414 Str++;\r
95276127 415 } else {\r
416 return EFI_UNSUPPORTED;\r
417 }\r
ac7e320c
LG
418 \r
419 //\r
420 // Get the second UINT16 data\r
421 //\r
422 Guid->Data2 = (UINT16) StrHexToUint64 (Str);\r
423 while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
424 Str ++;\r
95276127 425 }\r
ac7e320c 426\r
95276127 427 if (IS_HYPHEN (*Str)) {\r
428 Str++;\r
429 } else {\r
430 return EFI_UNSUPPORTED;\r
431 }\r
ac7e320c
LG
432 \r
433 //\r
434 // Get the third UINT16 data\r
435 //\r
436 Guid->Data3 = (UINT16) StrHexToUint64 (Str);\r
437 while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
438 Str ++;\r
95276127 439 }\r
ac7e320c 440\r
95276127 441 if (IS_HYPHEN (*Str)) {\r
442 Str++;\r
443 } else {\r
444 return EFI_UNSUPPORTED;\r
445 }\r
446\r
ac7e320c 447 //\r
5755841f 448 // Get the following 8 bytes data\r
ac7e320c 449 // \r
95276127 450 StrToBuf (&Guid->Data4[0], 2, Str);\r
451 //\r
452 // Skip 2 byte hex chars\r
453 //\r
454 Str += 2 * 2;\r
455\r
456 if (IS_HYPHEN (*Str)) {\r
457 Str++;\r
458 } else {\r
459 return EFI_UNSUPPORTED;\r
460 }\r
461 StrToBuf (&Guid->Data4[2], 6, Str);\r
462\r
463 return EFI_SUCCESS;\r
464}\r
465\r
572f5d8a 466/**\r
467 Converts a string to IPv4 address\r
468\r
469 @param Str A string representation of IPv4 address.\r
470 @param IPv4Addr A pointer to the converted IPv4 address.\r
471\r
472**/\r
95276127 473VOID\r
474StrToIPv4Addr (\r
475 IN OUT CHAR16 **Str,\r
476 OUT EFI_IPv4_ADDRESS *IPv4Addr\r
477 )\r
478{\r
479 UINTN Index;\r
480\r
481 for (Index = 0; Index < 4; Index++) {\r
9da38884 482 IPv4Addr->Addr[Index] = (UINT8) Strtoi (SplitStr (Str, L'.'));\r
95276127 483 }\r
484}\r
485\r
572f5d8a 486/**\r
487 Converts a string to IPv4 address\r
488\r
489 @param Str A string representation of IPv6 address.\r
490 @param IPv6Addr A pointer to the converted IPv6 address.\r
491\r
492**/\r
95276127 493VOID\r
494StrToIPv6Addr (\r
495 IN OUT CHAR16 **Str,\r
496 OUT EFI_IPv6_ADDRESS *IPv6Addr\r
497 )\r
498{\r
499 UINTN Index;\r
500 UINT16 Data;\r
501\r
502 for (Index = 0; Index < 8; Index++) {\r
4d0a30a4 503 Data = (UINT16) StrHexToUintn (SplitStr (Str, L':'));\r
95276127 504 IPv6Addr->Addr[Index * 2] = (UINT8) (Data >> 8);\r
505 IPv6Addr->Addr[Index * 2 + 1] = (UINT8) (Data & 0xff);\r
506 }\r
507}\r
508\r
572f5d8a 509/**\r
510 Converts a Unicode string to ASCII string.\r
511\r
5755841f 512 @param Str The equivalent Unicode string\r
572f5d8a 513 @param AsciiStr On input, it points to destination ASCII string buffer; on output, it points\r
514 to the next ASCII string next to it\r
515\r
516**/\r
95276127 517VOID\r
518StrToAscii (\r
519 IN CHAR16 *Str,\r
520 IN OUT CHAR8 **AsciiStr\r
521 )\r
522{\r
523 CHAR8 *Dest;\r
524\r
525 Dest = *AsciiStr;\r
526 while (!IS_NULL (*Str)) {\r
527 *(Dest++) = (CHAR8) *(Str++);\r
528 }\r
529 *Dest = 0;\r
530\r
531 //\r
532 // Return the string next to it\r
533 //\r
534 *AsciiStr = Dest + 1;\r
535}\r
536\r
5d6a5aee
RN
537/**\r
538 Converts a generic text device path node to device path structure.\r
539\r
540 @param Type The type of the device path node.\r
541 @param TextDeviceNode The input text device path node.\r
542\r
543 @return A pointer to device path structure.\r
544**/\r
545EFI_DEVICE_PATH_PROTOCOL *\r
546DevPathFromTextGenericPath (\r
547 IN UINT8 Type,\r
548 IN CHAR16 *TextDeviceNode\r
549 )\r
550{\r
551 EFI_DEVICE_PATH_PROTOCOL *Node;\r
552 CHAR16 *SubtypeStr;\r
553 CHAR16 *DataStr;\r
554 UINTN DataLength;\r
555\r
556 SubtypeStr = GetNextParamStr (&TextDeviceNode);\r
557 DataStr = GetNextParamStr (&TextDeviceNode);\r
558\r
559 if (DataStr == NULL) {\r
560 DataLength = 0;\r
561 } else {\r
562 DataLength = StrLen (DataStr) / 2;\r
563 }\r
564 Node = CreateDeviceNode (\r
565 Type,\r
566 (UINT8) Strtoi (SubtypeStr),\r
567 (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)\r
568 );\r
569\r
66a110d7
RN
570 if (DataLength != 0) {\r
571 StrToBuf ((UINT8 *) (Node + 1), DataLength, DataStr);\r
572 }\r
5d6a5aee
RN
573 return Node;\r
574}\r
575\r
576/**\r
577 Converts a generic text device path node to device path structure.\r
578\r
579 @param TextDeviceNode The input Text device path node.\r
580\r
581 @return A pointer to device path structure.\r
582\r
583**/\r
584EFI_DEVICE_PATH_PROTOCOL *\r
585DevPathFromTextPath (\r
586 IN CHAR16 *TextDeviceNode\r
587 )\r
588{\r
589 CHAR16 *TypeStr;\r
590\r
591 TypeStr = GetNextParamStr (&TextDeviceNode);\r
592\r
593 return DevPathFromTextGenericPath ((UINT8) Strtoi (TypeStr), TextDeviceNode);\r
594}\r
595\r
596/**\r
597 Converts a generic hardware text device path node to Hardware device path structure.\r
598\r
599 @param TextDeviceNode The input Text device path node.\r
600\r
601 @return A pointer to Hardware device path structure.\r
602\r
603**/\r
604EFI_DEVICE_PATH_PROTOCOL *\r
605DevPathFromTextHardwarePath (\r
606 IN CHAR16 *TextDeviceNode\r
607 )\r
608{\r
609 return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH, TextDeviceNode);\r
610}\r
611\r
572f5d8a 612/**\r
613 Converts a text device path node to Hardware PCI device path structure.\r
614\r
615 @param TextDeviceNode The input Text device path node.\r
616\r
617 @return A pointer to Hardware PCI device path structure.\r
618\r
619**/\r
95276127 620EFI_DEVICE_PATH_PROTOCOL *\r
621DevPathFromTextPci (\r
622 IN CHAR16 *TextDeviceNode\r
623 )\r
624{\r
625 CHAR16 *FunctionStr;\r
626 CHAR16 *DeviceStr;\r
627 PCI_DEVICE_PATH *Pci;\r
628\r
95276127 629 DeviceStr = GetNextParamStr (&TextDeviceNode);\r
cf40f28a 630 FunctionStr = GetNextParamStr (&TextDeviceNode);\r
95276127 631 Pci = (PCI_DEVICE_PATH *) CreateDeviceNode (\r
632 HARDWARE_DEVICE_PATH,\r
633 HW_PCI_DP,\r
c9325700 634 (UINT16) sizeof (PCI_DEVICE_PATH)\r
95276127 635 );\r
636\r
cf40f28a 637 Pci->Function = (UINT8) Strtoi (FunctionStr);\r
638 Pci->Device = (UINT8) Strtoi (DeviceStr);\r
95276127 639\r
640 return (EFI_DEVICE_PATH_PROTOCOL *) Pci;\r
641}\r
642\r
572f5d8a 643/**\r
644 Converts a text device path node to Hardware PC card device path structure.\r
645\r
646 @param TextDeviceNode The input Text device path node.\r
647\r
648 @return A pointer to Hardware PC card device path structure.\r
649\r
650**/\r
95276127 651EFI_DEVICE_PATH_PROTOCOL *\r
652DevPathFromTextPcCard (\r
653 IN CHAR16 *TextDeviceNode\r
654 )\r
655{\r
656 CHAR16 *FunctionNumberStr;\r
657 PCCARD_DEVICE_PATH *Pccard;\r
658\r
659 FunctionNumberStr = GetNextParamStr (&TextDeviceNode);\r
660 Pccard = (PCCARD_DEVICE_PATH *) CreateDeviceNode (\r
661 HARDWARE_DEVICE_PATH,\r
662 HW_PCCARD_DP,\r
c9325700 663 (UINT16) sizeof (PCCARD_DEVICE_PATH)\r
95276127 664 );\r
665\r
cf40f28a 666 Pccard->FunctionNumber = (UINT8) Strtoi (FunctionNumberStr);\r
95276127 667\r
668 return (EFI_DEVICE_PATH_PROTOCOL *) Pccard;\r
669}\r
670\r
572f5d8a 671/**\r
672 Converts a text device path node to Hardware memory map device path structure.\r
673\r
674 @param TextDeviceNode The input Text device path node.\r
675\r
676 @return A pointer to Hardware memory map device path structure.\r
677\r
678**/\r
95276127 679EFI_DEVICE_PATH_PROTOCOL *\r
680DevPathFromTextMemoryMapped (\r
681 IN CHAR16 *TextDeviceNode\r
682 )\r
683{\r
cf40f28a 684 CHAR16 *MemoryTypeStr;\r
95276127 685 CHAR16 *StartingAddressStr;\r
686 CHAR16 *EndingAddressStr;\r
687 MEMMAP_DEVICE_PATH *MemMap;\r
688\r
cf40f28a 689 MemoryTypeStr = GetNextParamStr (&TextDeviceNode);\r
95276127 690 StartingAddressStr = GetNextParamStr (&TextDeviceNode);\r
691 EndingAddressStr = GetNextParamStr (&TextDeviceNode);\r
692 MemMap = (MEMMAP_DEVICE_PATH *) CreateDeviceNode (\r
693 HARDWARE_DEVICE_PATH,\r
694 HW_MEMMAP_DP,\r
c9325700 695 (UINT16) sizeof (MEMMAP_DEVICE_PATH)\r
95276127 696 );\r
697\r
cf40f28a 698 MemMap->MemoryType = (UINT32) Strtoi (MemoryTypeStr);\r
699 Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);\r
700 Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);\r
95276127 701\r
702 return (EFI_DEVICE_PATH_PROTOCOL *) MemMap;\r
703}\r
704\r
572f5d8a 705/**\r
706 Converts a text device path node to Vendor device path structure based on the input Type\r
707 and SubType.\r
708\r
709 @param TextDeviceNode The input Text device path node.\r
710 @param Type The type of device path node.\r
711 @param SubType The subtype of device path node.\r
712\r
713 @return A pointer to the newly-created Vendor device path structure.\r
714\r
715**/\r
95276127 716EFI_DEVICE_PATH_PROTOCOL *\r
717ConvertFromTextVendor (\r
718 IN CHAR16 *TextDeviceNode,\r
719 IN UINT8 Type,\r
720 IN UINT8 SubType\r
721 )\r
722{\r
723 CHAR16 *GuidStr;\r
724 CHAR16 *DataStr;\r
725 UINTN Length;\r
726 VENDOR_DEVICE_PATH *Vendor;\r
727\r
728 GuidStr = GetNextParamStr (&TextDeviceNode);\r
729\r
730 DataStr = GetNextParamStr (&TextDeviceNode);\r
731 Length = StrLen (DataStr);\r
732 //\r
733 // Two hex characters make up 1 buffer byte\r
734 //\r
735 Length = (Length + 1) / 2;\r
736\r
737 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
738 Type,\r
739 SubType,\r
d074a8e1 740 (UINT16) (sizeof (VENDOR_DEVICE_PATH) + Length)\r
95276127 741 );\r
742\r
743 StrToGuid (GuidStr, &Vendor->Guid);\r
744 StrToBuf (((UINT8 *) Vendor) + sizeof (VENDOR_DEVICE_PATH), Length, DataStr);\r
745\r
746 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
747}\r
748\r
572f5d8a 749/**\r
750 Converts a text device path node to Vendor Hardware device path structure.\r
751\r
752 @param TextDeviceNode The input Text device path node.\r
753\r
754 @return A pointer to the newly-created Vendor Hardware device path structure.\r
755\r
756**/\r
95276127 757EFI_DEVICE_PATH_PROTOCOL *\r
758DevPathFromTextVenHw (\r
759 IN CHAR16 *TextDeviceNode\r
760 )\r
761{\r
762 return ConvertFromTextVendor (\r
763 TextDeviceNode,\r
764 HARDWARE_DEVICE_PATH,\r
765 HW_VENDOR_DP\r
766 );\r
767}\r
768\r
572f5d8a 769/**\r
770 Converts a text device path node to Hardware Controller device path structure.\r
771\r
772 @param TextDeviceNode The input Text device path node.\r
773\r
774 @return A pointer to the newly-created Hardware Controller device path structure.\r
775\r
776**/\r
95276127 777EFI_DEVICE_PATH_PROTOCOL *\r
778DevPathFromTextCtrl (\r
779 IN CHAR16 *TextDeviceNode\r
780 )\r
781{\r
782 CHAR16 *ControllerStr;\r
783 CONTROLLER_DEVICE_PATH *Controller;\r
784\r
785 ControllerStr = GetNextParamStr (&TextDeviceNode);\r
786 Controller = (CONTROLLER_DEVICE_PATH *) CreateDeviceNode (\r
787 HARDWARE_DEVICE_PATH,\r
788 HW_CONTROLLER_DP,\r
c9325700 789 (UINT16) sizeof (CONTROLLER_DEVICE_PATH)\r
95276127 790 );\r
cf40f28a 791 Controller->ControllerNumber = (UINT32) Strtoi (ControllerStr);\r
95276127 792\r
793 return (EFI_DEVICE_PATH_PROTOCOL *) Controller;\r
794}\r
795\r
624f017e
HW
796/**\r
797 Converts a text device path node to BMC device path structure.\r
798\r
799 @param TextDeviceNode The input Text device path node.\r
800\r
801 @return A pointer to the newly-created BMC device path structure.\r
802\r
803**/\r
804EFI_DEVICE_PATH_PROTOCOL *\r
805DevPathFromTextBmc (\r
806 IN CHAR16 *TextDeviceNode\r
807 )\r
808{\r
809 CHAR16 *InterfaceTypeStr;\r
810 CHAR16 *BaseAddressStr;\r
811 BMC_DEVICE_PATH *BmcDp;\r
812\r
813 InterfaceTypeStr = GetNextParamStr (&TextDeviceNode);\r
814 BaseAddressStr = GetNextParamStr (&TextDeviceNode);\r
815 BmcDp = (BMC_DEVICE_PATH *) CreateDeviceNode (\r
816 HARDWARE_DEVICE_PATH,\r
817 HW_BMC_DP,\r
818 (UINT16) sizeof (BMC_DEVICE_PATH)\r
819 );\r
820\r
821 BmcDp->InterfaceType = (UINT8) Strtoi (InterfaceTypeStr);\r
822 WriteUnaligned64 (\r
823 (UINT64 *) (&BmcDp->BaseAddress),\r
824 StrHexToUint64 (BaseAddressStr)\r
825 );\r
826\r
827 return (EFI_DEVICE_PATH_PROTOCOL *) BmcDp;\r
828}\r
829\r
5d6a5aee
RN
830/**\r
831 Converts a generic ACPI text device path node to ACPI device path structure.\r
832\r
833 @param TextDeviceNode The input Text device path node.\r
834\r
835 @return A pointer to ACPI device path structure.\r
836\r
837**/\r
838EFI_DEVICE_PATH_PROTOCOL *\r
839DevPathFromTextAcpiPath (\r
840 IN CHAR16 *TextDeviceNode\r
841 )\r
842{\r
843 return DevPathFromTextGenericPath (ACPI_DEVICE_PATH, TextDeviceNode);\r
844}\r
845\r
572f5d8a 846/**\r
847 Converts a string to EisaId.\r
848\r
849 @param Text The input string.\r
572f5d8a 850\r
4d0a30a4 851 @return UINT32 EISA ID.\r
572f5d8a 852**/\r
4d0a30a4 853UINT32\r
cf40f28a 854EisaIdFromText (\r
4d0a30a4 855 IN CHAR16 *Text\r
cf40f28a 856 )\r
857{\r
4d0a30a4
RN
858 return (((Text[0] - 'A' + 1) & 0x1f) << 10)\r
859 + (((Text[1] - 'A' + 1) & 0x1f) << 5)\r
860 + (((Text[2] - 'A' + 1) & 0x1f) << 0)\r
861 + (UINT32) (StrHexToUintn (&Text[3]) << 16)\r
862 ;\r
cf40f28a 863}\r
864\r
572f5d8a 865/**\r
866 Converts a text device path node to ACPI HID device path structure.\r
867\r
868 @param TextDeviceNode The input Text device path node.\r
869\r
870 @return A pointer to the newly-created ACPI HID device path structure.\r
871\r
872**/\r
95276127 873EFI_DEVICE_PATH_PROTOCOL *\r
874DevPathFromTextAcpi (\r
875 IN CHAR16 *TextDeviceNode\r
876 )\r
877{\r
878 CHAR16 *HIDStr;\r
879 CHAR16 *UIDStr;\r
880 ACPI_HID_DEVICE_PATH *Acpi;\r
881\r
882 HIDStr = GetNextParamStr (&TextDeviceNode);\r
883 UIDStr = GetNextParamStr (&TextDeviceNode);\r
884 Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r
885 ACPI_DEVICE_PATH,\r
886 ACPI_DP,\r
c9325700 887 (UINT16) sizeof (ACPI_HID_DEVICE_PATH)\r
95276127 888 );\r
889\r
4d0a30a4 890 Acpi->HID = EisaIdFromText (HIDStr);\r
cf40f28a 891 Acpi->UID = (UINT32) Strtoi (UIDStr);\r
95276127 892\r
893 return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r
894}\r
895\r
572f5d8a 896/**\r
897 Converts a text device path node to ACPI HID device path structure.\r
898\r
899 @param TextDeviceNode The input Text device path node.\r
900 @param PnPId The input plug and play identification.\r
901\r
902 @return A pointer to the newly-created ACPI HID device path structure.\r
903\r
904**/\r
95276127 905EFI_DEVICE_PATH_PROTOCOL *\r
906ConvertFromTextAcpi (\r
907 IN CHAR16 *TextDeviceNode,\r
cf40f28a 908 IN UINT32 PnPId\r
95276127 909 )\r
910{\r
911 CHAR16 *UIDStr;\r
912 ACPI_HID_DEVICE_PATH *Acpi;\r
913\r
914 UIDStr = GetNextParamStr (&TextDeviceNode);\r
915 Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r
916 ACPI_DEVICE_PATH,\r
917 ACPI_DP,\r
c9325700 918 (UINT16) sizeof (ACPI_HID_DEVICE_PATH)\r
95276127 919 );\r
920\r
cf40f28a 921 Acpi->HID = EFI_PNP_ID (PnPId);\r
922 Acpi->UID = (UINT32) Strtoi (UIDStr);\r
95276127 923\r
924 return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r
925}\r
926\r
572f5d8a 927/**\r
928 Converts a text device path node to PCI root device path structure.\r
929\r
930 @param TextDeviceNode The input Text device path node.\r
931\r
932 @return A pointer to the newly-created PCI root device path structure.\r
933\r
934**/\r
95276127 935EFI_DEVICE_PATH_PROTOCOL *\r
936DevPathFromTextPciRoot (\r
937 IN CHAR16 *TextDeviceNode\r
938 )\r
939{\r
cf40f28a 940 return ConvertFromTextAcpi (TextDeviceNode, 0x0a03);\r
95276127 941}\r
942\r
e9b3cd55
RN
943/**\r
944 Converts a text device path node to PCIE root device path structure.\r
945\r
946 @param TextDeviceNode The input Text device path node.\r
947\r
948 @return A pointer to the newly-created PCIE root device path structure.\r
949\r
950**/\r
951EFI_DEVICE_PATH_PROTOCOL *\r
952DevPathFromTextPcieRoot (\r
953 IN CHAR16 *TextDeviceNode\r
954 )\r
955{\r
956 return ConvertFromTextAcpi (TextDeviceNode, 0x0a08);\r
957}\r
958\r
572f5d8a 959/**\r
960 Converts a text device path node to Floppy device path structure.\r
961\r
962 @param TextDeviceNode The input Text device path node.\r
963\r
964 @return A pointer to the newly-created Floppy device path structure.\r
965\r
966**/\r
95276127 967EFI_DEVICE_PATH_PROTOCOL *\r
968DevPathFromTextFloppy (\r
969 IN CHAR16 *TextDeviceNode\r
970 )\r
971{\r
cf40f28a 972 return ConvertFromTextAcpi (TextDeviceNode, 0x0604);\r
95276127 973}\r
974\r
572f5d8a 975/**\r
976 Converts a text device path node to Keyboard device path structure.\r
977\r
978 @param TextDeviceNode The input Text device path node.\r
979\r
980 @return A pointer to the newly-created Keyboard device path structure.\r
981\r
982**/\r
95276127 983EFI_DEVICE_PATH_PROTOCOL *\r
984DevPathFromTextKeyboard (\r
985 IN CHAR16 *TextDeviceNode\r
986 )\r
987{\r
cf40f28a 988 return ConvertFromTextAcpi (TextDeviceNode, 0x0301);\r
95276127 989}\r
990\r
572f5d8a 991/**\r
992 Converts a text device path node to Serial device path structure.\r
993\r
994 @param TextDeviceNode The input Text device path node.\r
995\r
996 @return A pointer to the newly-created Serial device path structure.\r
997\r
998**/\r
95276127 999EFI_DEVICE_PATH_PROTOCOL *\r
1000DevPathFromTextSerial (\r
1001 IN CHAR16 *TextDeviceNode\r
1002 )\r
1003{\r
cf40f28a 1004 return ConvertFromTextAcpi (TextDeviceNode, 0x0501);\r
95276127 1005}\r
1006\r
572f5d8a 1007/**\r
1008 Converts a text device path node to Parallel Port device path structure.\r
1009\r
1010 @param TextDeviceNode The input Text device path node.\r
1011\r
1012 @return A pointer to the newly-created Parallel Port device path structure.\r
1013\r
1014**/\r
95276127 1015EFI_DEVICE_PATH_PROTOCOL *\r
1016DevPathFromTextParallelPort (\r
1017 IN CHAR16 *TextDeviceNode\r
1018 )\r
1019{\r
cf40f28a 1020 return ConvertFromTextAcpi (TextDeviceNode, 0x0401);\r
95276127 1021}\r
1022\r
572f5d8a 1023/**\r
5755841f 1024 Converts a text device path node to ACPI extension device path structure.\r
572f5d8a 1025\r
1026 @param TextDeviceNode The input Text device path node.\r
1027\r
5755841f 1028 @return A pointer to the newly-created ACPI extension device path structure.\r
572f5d8a 1029\r
1030**/\r
95276127 1031EFI_DEVICE_PATH_PROTOCOL *\r
1032DevPathFromTextAcpiEx (\r
1033 IN CHAR16 *TextDeviceNode\r
1034 )\r
1035{\r
cf40f28a 1036 CHAR16 *HIDStr;\r
1037 CHAR16 *CIDStr;\r
1038 CHAR16 *UIDStr;\r
1039 CHAR16 *HIDSTRStr;\r
1040 CHAR16 *CIDSTRStr;\r
1041 CHAR16 *UIDSTRStr;\r
1042 CHAR8 *AsciiStr;\r
1043 UINT16 Length;\r
1044 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r
95276127 1045\r
1046 HIDStr = GetNextParamStr (&TextDeviceNode);\r
1047 CIDStr = GetNextParamStr (&TextDeviceNode);\r
1048 UIDStr = GetNextParamStr (&TextDeviceNode);\r
1049 HIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
1050 CIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
1051 UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
1052\r
1053 Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (HIDSTRStr) + 1);\r
1054 Length = (UINT16) (Length + StrLen (UIDSTRStr) + 1);\r
1055 Length = (UINT16) (Length + StrLen (CIDSTRStr) + 1);\r
cf40f28a 1056 AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r
1057 ACPI_DEVICE_PATH,\r
1058 ACPI_EXTENDED_DP,\r
1059 Length\r
1060 );\r
95276127 1061\r
4d0a30a4
RN
1062 AcpiEx->HID = EisaIdFromText (HIDStr);\r
1063 AcpiEx->CID = EisaIdFromText (CIDStr);\r
cf40f28a 1064 AcpiEx->UID = (UINT32) Strtoi (UIDStr);\r
95276127 1065\r
cf40f28a 1066 AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
95276127 1067 StrToAscii (HIDSTRStr, &AsciiStr);\r
1068 StrToAscii (UIDSTRStr, &AsciiStr);\r
1069 StrToAscii (CIDSTRStr, &AsciiStr);\r
cf40f28a 1070\r
1071 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r
95276127 1072}\r
1073\r
572f5d8a 1074/**\r
5755841f 1075 Converts a text device path node to ACPI extension device path structure.\r
572f5d8a 1076\r
1077 @param TextDeviceNode The input Text device path node.\r
1078\r
5755841f 1079 @return A pointer to the newly-created ACPI extension device path structure.\r
572f5d8a 1080\r
1081**/\r
95276127 1082EFI_DEVICE_PATH_PROTOCOL *\r
1083DevPathFromTextAcpiExp (\r
1084 IN CHAR16 *TextDeviceNode\r
1085 )\r
1086{\r
cf40f28a 1087 CHAR16 *HIDStr;\r
1088 CHAR16 *CIDStr;\r
1089 CHAR16 *UIDSTRStr;\r
1090 CHAR8 *AsciiStr;\r
1091 UINT16 Length;\r
1092 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r
95276127 1093\r
1094 HIDStr = GetNextParamStr (&TextDeviceNode);\r
1095 CIDStr = GetNextParamStr (&TextDeviceNode);\r
1096 UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
d074a8e1 1097 Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (UIDSTRStr) + 3);\r
cf40f28a 1098 AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r
1099 ACPI_DEVICE_PATH,\r
1100 ACPI_EXTENDED_DP,\r
1101 Length\r
1102 );\r
95276127 1103\r
4d0a30a4
RN
1104 AcpiEx->HID = EisaIdFromText (HIDStr);\r
1105 AcpiEx->CID = EisaIdFromText (CIDStr);\r
cf40f28a 1106 AcpiEx->UID = 0;\r
95276127 1107\r
cf40f28a 1108 AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
95276127 1109 //\r
1110 // HID string is NULL\r
1111 //\r
cf40f28a 1112 *AsciiStr = '\0';\r
95276127 1113 //\r
1114 // Convert UID string\r
1115 //\r
1116 AsciiStr++;\r
1117 StrToAscii (UIDSTRStr, &AsciiStr);\r
1118 //\r
1119 // CID string is NULL\r
1120 //\r
cf40f28a 1121 *AsciiStr = '\0';\r
95276127 1122\r
cf40f28a 1123 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r
95276127 1124}\r
1125\r
5b84091f
RN
1126/**\r
1127 Converts a text device path node to ACPI _ADR device path structure.\r
1128\r
1129 @param TextDeviceNode The input Text device path node.\r
1130\r
1131 @return A pointer to the newly-created ACPI _ADR device path structure.\r
1132\r
1133**/\r
1134EFI_DEVICE_PATH_PROTOCOL *\r
1135DevPathFromTextAcpiAdr (\r
1136 IN CHAR16 *TextDeviceNode\r
1137 )\r
1138{\r
1139 CHAR16 *DisplayDeviceStr;\r
1140 ACPI_ADR_DEVICE_PATH *AcpiAdr;\r
1141 UINTN Index;\r
b36653bc 1142 UINTN Length;\r
5b84091f
RN
1143\r
1144 AcpiAdr = (ACPI_ADR_DEVICE_PATH *) CreateDeviceNode (\r
1145 ACPI_DEVICE_PATH,\r
1146 ACPI_ADR_DP,\r
e7cc9dcc 1147 (UINT16) sizeof (ACPI_ADR_DEVICE_PATH)\r
5b84091f
RN
1148 );\r
1149 ASSERT (AcpiAdr != NULL);\r
1150\r
1151 for (Index = 0; ; Index++) {\r
1152 DisplayDeviceStr = GetNextParamStr (&TextDeviceNode);\r
1153 if (IS_NULL (*DisplayDeviceStr)) {\r
1154 break;\r
1155 }\r
1156 if (Index > 0) {\r
b36653bc 1157 Length = DevicePathNodeLength (AcpiAdr);\r
5b84091f 1158 AcpiAdr = ReallocatePool (\r
b36653bc
RN
1159 Length,\r
1160 Length + sizeof (UINT32),\r
5b84091f
RN
1161 AcpiAdr\r
1162 );\r
1163 ASSERT (AcpiAdr != NULL);\r
b36653bc 1164 SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));\r
5b84091f
RN
1165 }\r
1166 \r
1167 (&AcpiAdr->ADR)[Index] = (UINT32) Strtoi (DisplayDeviceStr);\r
1168 }\r
1169\r
1170 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr;\r
1171}\r
1172\r
5d6a5aee
RN
1173/**\r
1174 Converts a generic messaging text device path node to messaging device path structure.\r
1175\r
1176 @param TextDeviceNode The input Text device path node.\r
1177\r
1178 @return A pointer to messaging device path structure.\r
1179\r
1180**/\r
1181EFI_DEVICE_PATH_PROTOCOL *\r
1182DevPathFromTextMsg (\r
1183 IN CHAR16 *TextDeviceNode\r
1184 )\r
1185{\r
1186 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH, TextDeviceNode);\r
1187}\r
1188\r
572f5d8a 1189/**\r
1190 Converts a text device path node to Parallel Port device path structure.\r
1191\r
1192 @param TextDeviceNode The input Text device path node.\r
1193\r
1194 @return A pointer to the newly-created Parallel Port device path structure.\r
1195\r
1196**/\r
95276127 1197EFI_DEVICE_PATH_PROTOCOL *\r
1198DevPathFromTextAta (\r
9da38884
RN
1199IN CHAR16 *TextDeviceNode\r
1200)\r
95276127 1201{\r
1202 CHAR16 *PrimarySecondaryStr;\r
1203 CHAR16 *SlaveMasterStr;\r
1204 CHAR16 *LunStr;\r
1205 ATAPI_DEVICE_PATH *Atapi;\r
1206\r
1207 Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (\r
9da38884
RN
1208 MESSAGING_DEVICE_PATH,\r
1209 MSG_ATAPI_DP,\r
1210 (UINT16) sizeof (ATAPI_DEVICE_PATH)\r
1211 );\r
1212\r
1213 PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);\r
1214 SlaveMasterStr = GetNextParamStr (&TextDeviceNode);\r
1215 LunStr = GetNextParamStr (&TextDeviceNode);\r
1216\r
1217 if (StrCmp (PrimarySecondaryStr, L"Primary") == 0) {\r
1218 Atapi->PrimarySecondary = 0;\r
1219 } else if (StrCmp (PrimarySecondaryStr, L"Secondary") == 0) {\r
1220 Atapi->PrimarySecondary = 1;\r
1221 } else {\r
1222 Atapi->PrimarySecondary = (UINT8) Strtoi (PrimarySecondaryStr);\r
1223 }\r
1224 if (StrCmp (SlaveMasterStr, L"Master") == 0) {\r
1225 Atapi->SlaveMaster = 0;\r
1226 } else if (StrCmp (SlaveMasterStr, L"Slave") == 0) {\r
1227 Atapi->SlaveMaster = 1;\r
1228 } else {\r
1229 Atapi->SlaveMaster = (UINT8) Strtoi (SlaveMasterStr);\r
1230 }\r
95276127 1231\r
9da38884 1232 Atapi->Lun = (UINT16) Strtoi (LunStr);\r
95276127 1233\r
1234 return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;\r
1235}\r
1236\r
572f5d8a 1237/**\r
1238 Converts a text device path node to SCSI device path structure.\r
1239\r
1240 @param TextDeviceNode The input Text device path node.\r
1241\r
1242 @return A pointer to the newly-created SCSI device path structure.\r
1243\r
1244**/\r
95276127 1245EFI_DEVICE_PATH_PROTOCOL *\r
1246DevPathFromTextScsi (\r
1247 IN CHAR16 *TextDeviceNode\r
1248 )\r
1249{\r
1250 CHAR16 *PunStr;\r
1251 CHAR16 *LunStr;\r
1252 SCSI_DEVICE_PATH *Scsi;\r
1253\r
1254 PunStr = GetNextParamStr (&TextDeviceNode);\r
1255 LunStr = GetNextParamStr (&TextDeviceNode);\r
1256 Scsi = (SCSI_DEVICE_PATH *) CreateDeviceNode (\r
1257 MESSAGING_DEVICE_PATH,\r
1258 MSG_SCSI_DP,\r
c9325700 1259 (UINT16) sizeof (SCSI_DEVICE_PATH)\r
95276127 1260 );\r
1261\r
cf40f28a 1262 Scsi->Pun = (UINT16) Strtoi (PunStr);\r
1263 Scsi->Lun = (UINT16) Strtoi (LunStr);\r
95276127 1264\r
1265 return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;\r
1266}\r
1267\r
572f5d8a 1268/**\r
1269 Converts a text device path node to Fibre device path structure.\r
1270\r
1271 @param TextDeviceNode The input Text device path node.\r
1272\r
1273 @return A pointer to the newly-created Fibre device path structure.\r
1274\r
1275**/\r
95276127 1276EFI_DEVICE_PATH_PROTOCOL *\r
1277DevPathFromTextFibre (\r
1278 IN CHAR16 *TextDeviceNode\r
1279 )\r
1280{\r
1281 CHAR16 *WWNStr;\r
1282 CHAR16 *LunStr;\r
1283 FIBRECHANNEL_DEVICE_PATH *Fibre;\r
1284\r
1285 WWNStr = GetNextParamStr (&TextDeviceNode);\r
1286 LunStr = GetNextParamStr (&TextDeviceNode);\r
1287 Fibre = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (\r
1288 MESSAGING_DEVICE_PATH,\r
1289 MSG_FIBRECHANNEL_DP,\r
c9325700 1290 (UINT16) sizeof (FIBRECHANNEL_DEVICE_PATH)\r
95276127 1291 );\r
1292\r
1293 Fibre->Reserved = 0;\r
cf40f28a 1294 Strtoi64 (WWNStr, &Fibre->WWN);\r
1295 Strtoi64 (LunStr, &Fibre->Lun);\r
95276127 1296\r
1297 return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;\r
1298}\r
1299\r
e9b3cd55
RN
1300/**\r
1301 Converts a text device path node to FibreEx device path structure.\r
1302\r
1303 @param TextDeviceNode The input Text device path node.\r
1304\r
1305 @return A pointer to the newly-created FibreEx device path structure.\r
1306\r
1307**/\r
1308EFI_DEVICE_PATH_PROTOCOL *\r
1309DevPathFromTextFibreEx (\r
1310 IN CHAR16 *TextDeviceNode\r
1311 )\r
1312{\r
1313 CHAR16 *WWNStr;\r
1314 CHAR16 *LunStr;\r
1315 FIBRECHANNELEX_DEVICE_PATH *FibreEx;\r
1316\r
1317 WWNStr = GetNextParamStr (&TextDeviceNode);\r
1318 LunStr = GetNextParamStr (&TextDeviceNode);\r
1319 FibreEx = (FIBRECHANNELEX_DEVICE_PATH *) CreateDeviceNode (\r
1320 MESSAGING_DEVICE_PATH,\r
1321 MSG_FIBRECHANNELEX_DP,\r
1322 (UINT16) sizeof (FIBRECHANNELEX_DEVICE_PATH)\r
1323 );\r
1324\r
1325 FibreEx->Reserved = 0;\r
1326 Strtoi64 (WWNStr, (UINT64 *) (&FibreEx->WWN));\r
1327 Strtoi64 (LunStr, (UINT64 *) (&FibreEx->Lun));\r
1328\r
1329 *(UINT64 *) (&FibreEx->WWN) = SwapBytes64 (*(UINT64 *) (&FibreEx->WWN));\r
1330 *(UINT64 *) (&FibreEx->Lun) = SwapBytes64 (*(UINT64 *) (&FibreEx->Lun));\r
1331\r
1332 return (EFI_DEVICE_PATH_PROTOCOL *) FibreEx;\r
1333}\r
1334\r
572f5d8a 1335/**\r
1336 Converts a text device path node to 1394 device path structure.\r
1337\r
1338 @param TextDeviceNode The input Text device path node.\r
1339\r
1340 @return A pointer to the newly-created 1394 device path structure.\r
1341\r
1342**/\r
95276127 1343EFI_DEVICE_PATH_PROTOCOL *\r
1344DevPathFromText1394 (\r
1345 IN CHAR16 *TextDeviceNode\r
1346 )\r
1347{\r
1348 CHAR16 *GuidStr;\r
572f5d8a 1349 F1394_DEVICE_PATH *F1394DevPath;\r
95276127 1350\r
1351 GuidStr = GetNextParamStr (&TextDeviceNode);\r
572f5d8a 1352 F1394DevPath = (F1394_DEVICE_PATH *) CreateDeviceNode (\r
1353 MESSAGING_DEVICE_PATH,\r
1354 MSG_1394_DP,\r
c9325700 1355 (UINT16) sizeof (F1394_DEVICE_PATH)\r
572f5d8a 1356 );\r
95276127 1357\r
572f5d8a 1358 F1394DevPath->Reserved = 0;\r
4d0a30a4 1359 F1394DevPath->Guid = StrHexToUint64 (GuidStr);\r
95276127 1360\r
572f5d8a 1361 return (EFI_DEVICE_PATH_PROTOCOL *) F1394DevPath;\r
95276127 1362}\r
1363\r
572f5d8a 1364/**\r
1365 Converts a text device path node to USB device path structure.\r
1366\r
1367 @param TextDeviceNode The input Text device path node.\r
1368\r
1369 @return A pointer to the newly-created USB device path structure.\r
1370\r
1371**/\r
95276127 1372EFI_DEVICE_PATH_PROTOCOL *\r
1373DevPathFromTextUsb (\r
1374 IN CHAR16 *TextDeviceNode\r
1375 )\r
1376{\r
1377 CHAR16 *PortStr;\r
1378 CHAR16 *InterfaceStr;\r
1379 USB_DEVICE_PATH *Usb;\r
1380\r
1381 PortStr = GetNextParamStr (&TextDeviceNode);\r
1382 InterfaceStr = GetNextParamStr (&TextDeviceNode);\r
1383 Usb = (USB_DEVICE_PATH *) CreateDeviceNode (\r
1384 MESSAGING_DEVICE_PATH,\r
1385 MSG_USB_DP,\r
c9325700 1386 (UINT16) sizeof (USB_DEVICE_PATH)\r
95276127 1387 );\r
1388\r
cf40f28a 1389 Usb->ParentPortNumber = (UINT8) Strtoi (PortStr);\r
1390 Usb->InterfaceNumber = (UINT8) Strtoi (InterfaceStr);\r
95276127 1391\r
1392 return (EFI_DEVICE_PATH_PROTOCOL *) Usb;\r
1393}\r
1394\r
572f5d8a 1395/**\r
1396 Converts a text device path node to I20 device path structure.\r
1397\r
1398 @param TextDeviceNode The input Text device path node.\r
1399\r
1400 @return A pointer to the newly-created I20 device path structure.\r
1401\r
1402**/\r
95276127 1403EFI_DEVICE_PATH_PROTOCOL *\r
1404DevPathFromTextI2O (\r
1405 IN CHAR16 *TextDeviceNode\r
1406 )\r
1407{\r
1408 CHAR16 *TIDStr;\r
572f5d8a 1409 I2O_DEVICE_PATH *I2ODevPath;\r
95276127 1410\r
572f5d8a 1411 TIDStr = GetNextParamStr (&TextDeviceNode);\r
1412 I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode (\r
95276127 1413 MESSAGING_DEVICE_PATH,\r
1414 MSG_I2O_DP,\r
c9325700 1415 (UINT16) sizeof (I2O_DEVICE_PATH)\r
95276127 1416 );\r
1417\r
572f5d8a 1418 I2ODevPath->Tid = (UINT32) Strtoi (TIDStr);\r
95276127 1419\r
572f5d8a 1420 return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath;\r
95276127 1421}\r
1422\r
572f5d8a 1423/**\r
1424 Converts a text device path node to Infini Band device path structure.\r
1425\r
1426 @param TextDeviceNode The input Text device path node.\r
1427\r
1428 @return A pointer to the newly-created Infini Band device path structure.\r
1429\r
1430**/\r
95276127 1431EFI_DEVICE_PATH_PROTOCOL *\r
1432DevPathFromTextInfiniband (\r
1433 IN CHAR16 *TextDeviceNode\r
1434 )\r
1435{\r
1436 CHAR16 *FlagsStr;\r
1437 CHAR16 *GuidStr;\r
1438 CHAR16 *SidStr;\r
1439 CHAR16 *TidStr;\r
1440 CHAR16 *DidStr;\r
1441 EFI_GUID PortGid;\r
1442 INFINIBAND_DEVICE_PATH *InfiniBand;\r
1443\r
1444 FlagsStr = GetNextParamStr (&TextDeviceNode);\r
1445 GuidStr = GetNextParamStr (&TextDeviceNode);\r
1446 SidStr = GetNextParamStr (&TextDeviceNode);\r
1447 TidStr = GetNextParamStr (&TextDeviceNode);\r
1448 DidStr = GetNextParamStr (&TextDeviceNode);\r
1449 InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (\r
1450 MESSAGING_DEVICE_PATH,\r
1451 MSG_INFINIBAND_DP,\r
c9325700 1452 (UINT16) sizeof (INFINIBAND_DEVICE_PATH)\r
95276127 1453 );\r
1454\r
cf40f28a 1455 InfiniBand->ResourceFlags = (UINT32) Strtoi (FlagsStr);\r
95276127 1456 StrToGuid (GuidStr, &PortGid);\r
1457 CopyMem (InfiniBand->PortGid, &PortGid, sizeof (EFI_GUID));\r
cf40f28a 1458 Strtoi64 (SidStr, &InfiniBand->ServiceId);\r
1459 Strtoi64 (TidStr, &InfiniBand->TargetPortId);\r
1460 Strtoi64 (DidStr, &InfiniBand->DeviceId);\r
95276127 1461\r
1462 return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;\r
1463}\r
1464\r
572f5d8a 1465/**\r
1466 Converts a text device path node to Vendor-Defined Messaging device path structure.\r
1467\r
1468 @param TextDeviceNode The input Text device path node.\r
1469\r
1470 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.\r
1471\r
1472**/\r
95276127 1473EFI_DEVICE_PATH_PROTOCOL *\r
1474DevPathFromTextVenMsg (\r
1475 IN CHAR16 *TextDeviceNode\r
1476 )\r
1477{\r
1478 return ConvertFromTextVendor (\r
1479 TextDeviceNode,\r
1480 MESSAGING_DEVICE_PATH,\r
1481 MSG_VENDOR_DP\r
1482 );\r
1483}\r
1484\r
572f5d8a 1485/**\r
1486 Converts a text device path node to Vendor defined PC-ANSI device path structure.\r
1487\r
1488 @param TextDeviceNode The input Text device path node.\r
1489\r
1490 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.\r
1491\r
1492**/\r
95276127 1493EFI_DEVICE_PATH_PROTOCOL *\r
1494DevPathFromTextVenPcAnsi (\r
1495 IN CHAR16 *TextDeviceNode\r
1496 )\r
1497{\r
1498 VENDOR_DEVICE_PATH *Vendor;\r
1499\r
1500 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1501 MESSAGING_DEVICE_PATH,\r
1502 MSG_VENDOR_DP,\r
c9325700 1503 (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
95276127 1504 CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);\r
1505\r
1506 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
1507}\r
1508\r
572f5d8a 1509/**\r
1510 Converts a text device path node to Vendor defined VT100 device path structure.\r
1511\r
1512 @param TextDeviceNode The input Text device path node.\r
1513\r
1514 @return A pointer to the newly-created Vendor defined VT100 device path structure.\r
1515\r
1516**/\r
95276127 1517EFI_DEVICE_PATH_PROTOCOL *\r
1518DevPathFromTextVenVt100 (\r
1519 IN CHAR16 *TextDeviceNode\r
1520 )\r
1521{\r
1522 VENDOR_DEVICE_PATH *Vendor;\r
1523\r
1524 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1525 MESSAGING_DEVICE_PATH,\r
1526 MSG_VENDOR_DP,\r
c9325700 1527 (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
95276127 1528 CopyGuid (&Vendor->Guid, &gEfiVT100Guid);\r
1529\r
1530 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
1531}\r
1532\r
572f5d8a 1533/**\r
1534 Converts a text device path node to Vendor defined VT100 Plus device path structure.\r
1535\r
1536 @param TextDeviceNode The input Text device path node.\r
1537\r
1538 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.\r
1539\r
1540**/\r
95276127 1541EFI_DEVICE_PATH_PROTOCOL *\r
1542DevPathFromTextVenVt100Plus (\r
1543 IN CHAR16 *TextDeviceNode\r
1544 )\r
1545{\r
1546 VENDOR_DEVICE_PATH *Vendor;\r
1547\r
1548 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1549 MESSAGING_DEVICE_PATH,\r
1550 MSG_VENDOR_DP,\r
c9325700 1551 (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
95276127 1552 CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);\r
1553\r
1554 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
1555}\r
1556\r
572f5d8a 1557/**\r
1558 Converts a text device path node to Vendor defined UTF8 device path structure.\r
1559\r
1560 @param TextDeviceNode The input Text device path node.\r
1561\r
1562 @return A pointer to the newly-created Vendor defined UTF8 device path structure.\r
1563\r
1564**/\r
95276127 1565EFI_DEVICE_PATH_PROTOCOL *\r
1566DevPathFromTextVenUtf8 (\r
1567 IN CHAR16 *TextDeviceNode\r
1568 )\r
1569{\r
1570 VENDOR_DEVICE_PATH *Vendor;\r
1571\r
1572 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1573 MESSAGING_DEVICE_PATH,\r
1574 MSG_VENDOR_DP,\r
c9325700 1575 (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
95276127 1576 CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);\r
1577\r
1578 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
1579}\r
1580\r
572f5d8a 1581/**\r
1582 Converts a text device path node to UART Flow Control device path structure.\r
1583\r
1584 @param TextDeviceNode The input Text device path node.\r
1585\r
1586 @return A pointer to the newly-created UART Flow Control device path structure.\r
1587\r
1588**/\r
95276127 1589EFI_DEVICE_PATH_PROTOCOL *\r
1590DevPathFromTextUartFlowCtrl (\r
1591 IN CHAR16 *TextDeviceNode\r
1592 )\r
1593{\r
1594 CHAR16 *ValueStr;\r
1595 UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;\r
1596\r
1597 ValueStr = GetNextParamStr (&TextDeviceNode);\r
1598 UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (\r
1599 MESSAGING_DEVICE_PATH,\r
1600 MSG_VENDOR_DP,\r
c9325700 1601 (UINT16) sizeof (UART_FLOW_CONTROL_DEVICE_PATH)\r
95276127 1602 );\r
1603\r
48557c65 1604 CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);\r
95276127 1605 if (StrCmp (ValueStr, L"XonXoff") == 0) {\r
1606 UartFlowControl->FlowControlMap = 2;\r
1607 } else if (StrCmp (ValueStr, L"Hardware") == 0) {\r
1608 UartFlowControl->FlowControlMap = 1;\r
1609 } else {\r
1610 UartFlowControl->FlowControlMap = 0;\r
1611 }\r
1612\r
1613 return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;\r
1614}\r
1615\r
572f5d8a 1616/**\r
1617 Converts a text device path node to Serial Attached SCSI device path structure.\r
1618\r
1619 @param TextDeviceNode The input Text device path node.\r
1620\r
1621 @return A pointer to the newly-created Serial Attached SCSI device path structure.\r
1622\r
1623**/\r
95276127 1624EFI_DEVICE_PATH_PROTOCOL *\r
1625DevPathFromTextSAS (\r
1626 IN CHAR16 *TextDeviceNode\r
1627 )\r
1628{\r
1629 CHAR16 *AddressStr;\r
1630 CHAR16 *LunStr;\r
1631 CHAR16 *RTPStr;\r
1632 CHAR16 *SASSATAStr;\r
1633 CHAR16 *LocationStr;\r
1634 CHAR16 *ConnectStr;\r
1635 CHAR16 *DriveBayStr;\r
1636 CHAR16 *ReservedStr;\r
1637 UINT16 Info;\r
562fce0b 1638 UINT16 Uint16;\r
95276127 1639 SAS_DEVICE_PATH *Sas;\r
1640\r
1641 AddressStr = GetNextParamStr (&TextDeviceNode);\r
1642 LunStr = GetNextParamStr (&TextDeviceNode);\r
1643 RTPStr = GetNextParamStr (&TextDeviceNode);\r
1644 SASSATAStr = GetNextParamStr (&TextDeviceNode);\r
1645 LocationStr = GetNextParamStr (&TextDeviceNode);\r
1646 ConnectStr = GetNextParamStr (&TextDeviceNode);\r
1647 DriveBayStr = GetNextParamStr (&TextDeviceNode);\r
1648 ReservedStr = GetNextParamStr (&TextDeviceNode);\r
95276127 1649 Sas = (SAS_DEVICE_PATH *) CreateDeviceNode (\r
1650 MESSAGING_DEVICE_PATH,\r
1651 MSG_VENDOR_DP,\r
c9325700 1652 (UINT16) sizeof (SAS_DEVICE_PATH)\r
95276127 1653 );\r
1654\r
48557c65 1655 CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid);\r
cf40f28a 1656 Strtoi64 (AddressStr, &Sas->SasAddress);\r
1657 Strtoi64 (LunStr, &Sas->Lun);\r
1658 Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr);\r
562fce0b
RN
1659\r
1660 if (StrCmp (SASSATAStr, L"NoTopology") == 0) {\r
1661 Info = 0x0;\r
1662\r
1663 } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {\r
1664\r
1665 Uint16 = (UINT16) Strtoi (DriveBayStr);\r
1666 if (Uint16 == 0) {\r
1667 Info = 0x1;\r
95276127 1668 } else {\r
562fce0b 1669 Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));\r
95276127 1670 }\r
1671\r
1672 if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
562fce0b 1673 Info |= BIT4;\r
95276127 1674 }\r
1675\r
562fce0b
RN
1676 //\r
1677 // Location is an integer between 0 and 1 or else\r
1678 // the keyword Internal (0) or External (1).\r
1679 //\r
95276127 1680 if (StrCmp (LocationStr, L"External") == 0) {\r
562fce0b
RN
1681 Uint16 = 1;\r
1682 } else if (StrCmp (LocationStr, L"Internal") == 0) {\r
1683 Uint16 = 0;\r
1684 } else {\r
2d34b53e 1685 Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);\r
95276127 1686 }\r
562fce0b 1687 Info |= (Uint16 << 5);\r
95276127 1688\r
562fce0b
RN
1689 //\r
1690 // Connect is an integer between 0 and 3 or else\r
1691 // the keyword Direct (0) or Expanded (1).\r
1692 //\r
95276127 1693 if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
562fce0b
RN
1694 Uint16 = 1;\r
1695 } else if (StrCmp (ConnectStr, L"Direct") == 0) {\r
1696 Uint16 = 0;\r
1697 } else {\r
2d34b53e 1698 Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));\r
95276127 1699 }\r
562fce0b
RN
1700 Info |= (Uint16 << 6);\r
1701\r
1702 } else {\r
1703 Info = (UINT16) Strtoi (SASSATAStr);\r
95276127 1704 }\r
1705\r
1706 Sas->DeviceTopology = Info;\r
cf40f28a 1707 Sas->Reserved = (UINT32) Strtoi (ReservedStr);\r
95276127 1708\r
1709 return (EFI_DEVICE_PATH_PROTOCOL *) Sas;\r
1710}\r
1711\r
501793fa
RN
1712/**\r
1713 Converts a text device path node to Serial Attached SCSI Ex device path structure.\r
1714\r
1715 @param TextDeviceNode The input Text device path node.\r
1716\r
1717 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.\r
1718\r
1719**/\r
1720EFI_DEVICE_PATH_PROTOCOL *\r
1721DevPathFromTextSasEx (\r
1722 IN CHAR16 *TextDeviceNode\r
1723 )\r
1724{\r
1725 CHAR16 *AddressStr;\r
1726 CHAR16 *LunStr;\r
1727 CHAR16 *RTPStr;\r
1728 CHAR16 *SASSATAStr;\r
1729 CHAR16 *LocationStr;\r
1730 CHAR16 *ConnectStr;\r
1731 CHAR16 *DriveBayStr;\r
1732 UINT16 Info;\r
562fce0b
RN
1733 UINT16 Uint16;\r
1734 UINT64 SasAddress;\r
1735 UINT64 Lun;\r
501793fa
RN
1736 SASEX_DEVICE_PATH *SasEx;\r
1737\r
1738 AddressStr = GetNextParamStr (&TextDeviceNode);\r
1739 LunStr = GetNextParamStr (&TextDeviceNode);\r
1740 RTPStr = GetNextParamStr (&TextDeviceNode);\r
1741 SASSATAStr = GetNextParamStr (&TextDeviceNode);\r
1742 LocationStr = GetNextParamStr (&TextDeviceNode);\r
1743 ConnectStr = GetNextParamStr (&TextDeviceNode);\r
1744 DriveBayStr = GetNextParamStr (&TextDeviceNode);\r
501793fa
RN
1745 SasEx = (SASEX_DEVICE_PATH *) CreateDeviceNode (\r
1746 MESSAGING_DEVICE_PATH,\r
1747 MSG_SASEX_DP,\r
1748 (UINT16) sizeof (SASEX_DEVICE_PATH)\r
1749 );\r
1750\r
562fce0b
RN
1751 Strtoi64 (AddressStr, &SasAddress);\r
1752 Strtoi64 (LunStr, &Lun);\r
1753 WriteUnaligned64 ((UINT64 *) &SasEx->SasAddress, SwapBytes64 (SasAddress));\r
1754 WriteUnaligned64 ((UINT64 *) &SasEx->Lun, SwapBytes64 (Lun));\r
501793fa 1755 SasEx->RelativeTargetPort = (UINT16) Strtoi (RTPStr);\r
562fce0b
RN
1756\r
1757 if (StrCmp (SASSATAStr, L"NoTopology") == 0) {\r
1758 Info = 0x0;\r
1759\r
1760 } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {\r
1761\r
1762 Uint16 = (UINT16) Strtoi (DriveBayStr);\r
1763 if (Uint16 == 0) {\r
1764 Info = 0x1;\r
501793fa 1765 } else {\r
562fce0b 1766 Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));\r
501793fa
RN
1767 }\r
1768\r
1769 if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
562fce0b 1770 Info |= BIT4;\r
501793fa
RN
1771 }\r
1772\r
562fce0b
RN
1773 //\r
1774 // Location is an integer between 0 and 1 or else\r
1775 // the keyword Internal (0) or External (1).\r
1776 //\r
501793fa 1777 if (StrCmp (LocationStr, L"External") == 0) {\r
562fce0b
RN
1778 Uint16 = 1;\r
1779 } else if (StrCmp (LocationStr, L"Internal") == 0) {\r
1780 Uint16 = 0;\r
1781 } else {\r
2d34b53e 1782 Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);\r
501793fa 1783 }\r
562fce0b 1784 Info |= (Uint16 << 5);\r
501793fa 1785\r
562fce0b
RN
1786 //\r
1787 // Connect is an integer between 0 and 3 or else\r
1788 // the keyword Direct (0) or Expanded (1).\r
1789 //\r
501793fa 1790 if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
562fce0b
RN
1791 Uint16 = 1;\r
1792 } else if (StrCmp (ConnectStr, L"Direct") == 0) {\r
1793 Uint16 = 0;\r
1794 } else {\r
2d34b53e 1795 Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));\r
501793fa 1796 }\r
562fce0b
RN
1797 Info |= (Uint16 << 6);\r
1798\r
1799 } else {\r
1800 Info = (UINT16) Strtoi (SASSATAStr);\r
501793fa
RN
1801 }\r
1802\r
1803 SasEx->DeviceTopology = Info;\r
1804\r
1805 return (EFI_DEVICE_PATH_PROTOCOL *) SasEx;\r
1806}\r
1807\r
a06ec3e2
RN
1808/**\r
1809 Converts a text device path node to NVM Express Namespace device path structure.\r
1810\r
1811 @param TextDeviceNode The input Text device path node.\r
1812\r
1813 @return A pointer to the newly-created NVM Express Namespace device path structure.\r
1814\r
1815**/\r
1816EFI_DEVICE_PATH_PROTOCOL *\r
1817DevPathFromTextNVMe (\r
1818 IN CHAR16 *TextDeviceNode\r
1819 )\r
1820{\r
1821 CHAR16 *NamespaceIdStr;\r
1822 CHAR16 *NamespaceUuidStr;\r
1823 NVME_NAMESPACE_DEVICE_PATH *Nvme;\r
1824 UINT8 *Uuid;\r
1825 UINTN Index;\r
1826\r
1827 NamespaceIdStr = GetNextParamStr (&TextDeviceNode);\r
1828 NamespaceUuidStr = GetNextParamStr (&TextDeviceNode);\r
1829 Nvme = (NVME_NAMESPACE_DEVICE_PATH *) CreateDeviceNode (\r
1830 MESSAGING_DEVICE_PATH,\r
1831 MSG_NVME_NAMESPACE_DP,\r
1832 (UINT16) sizeof (NVME_NAMESPACE_DEVICE_PATH)\r
1833 );\r
1834\r
1835 Nvme->NamespaceId = (UINT32) Strtoi (NamespaceIdStr);\r
1836 Uuid = (UINT8 *) &Nvme->NamespaceUuid;\r
1837\r
1838 Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);\r
1839 while (Index-- != 0) {\r
1840 Uuid[Index] = (UINT8) StrHexToUintn (SplitStr (&NamespaceUuidStr, L'-'));\r
1841 }\r
1842\r
1843 return (EFI_DEVICE_PATH_PROTOCOL *) Nvme;\r
1844}\r
1845\r
52306166
FT
1846/**\r
1847 Converts a text device path node to UFS device path structure.\r
1848\r
1849 @param TextDeviceNode The input Text device path node.\r
1850\r
1851 @return A pointer to the newly-created UFS device path structure.\r
1852\r
1853**/\r
1854EFI_DEVICE_PATH_PROTOCOL *\r
1855DevPathFromTextUfs (\r
1856 IN CHAR16 *TextDeviceNode\r
1857 )\r
1858{\r
1859 CHAR16 *PunStr;\r
1860 CHAR16 *LunStr;\r
1861 UFS_DEVICE_PATH *Ufs;\r
1862\r
1863 PunStr = GetNextParamStr (&TextDeviceNode);\r
1864 LunStr = GetNextParamStr (&TextDeviceNode);\r
1865 Ufs = (UFS_DEVICE_PATH *) CreateDeviceNode (\r
1866 MESSAGING_DEVICE_PATH,\r
1867 MSG_UFS_DP,\r
1868 (UINT16) sizeof (UFS_DEVICE_PATH)\r
1869 );\r
1870\r
1871 Ufs->Pun = (UINT8) Strtoi (PunStr);\r
1872 Ufs->Lun = (UINT8) Strtoi (LunStr);\r
1873\r
1874 return (EFI_DEVICE_PATH_PROTOCOL *) Ufs;\r
1875}\r
1876\r
ab8686b8
FT
1877/**\r
1878 Converts a text device path node to SD (Secure Digital) device path structure.\r
1879\r
1880 @param TextDeviceNode The input Text device path node.\r
1881\r
1882 @return A pointer to the newly-created SD device path structure.\r
1883\r
1884**/\r
1885EFI_DEVICE_PATH_PROTOCOL *\r
1886DevPathFromTextSd (\r
1887 IN CHAR16 *TextDeviceNode\r
1888 )\r
1889{\r
1890 CHAR16 *SlotNumberStr;\r
1891 SD_DEVICE_PATH *Sd;\r
1892\r
1893 SlotNumberStr = GetNextParamStr (&TextDeviceNode);\r
1894 Sd = (SD_DEVICE_PATH *) CreateDeviceNode (\r
1895 MESSAGING_DEVICE_PATH,\r
1896 MSG_SD_DP,\r
1897 (UINT16) sizeof (SD_DEVICE_PATH)\r
1898 );\r
1899\r
1900 Sd->SlotNumber = (UINT8) Strtoi (SlotNumberStr);\r
1901\r
1902 return (EFI_DEVICE_PATH_PROTOCOL *) Sd;\r
1903}\r
1904\r
5c67fb2f
FT
1905/**\r
1906 Converts a text device path node to EMMC (Embedded MMC) device path structure.\r
1907\r
1908 @param TextDeviceNode The input Text device path node.\r
1909\r
1910 @return A pointer to the newly-created EMMC device path structure.\r
1911\r
1912**/\r
1913EFI_DEVICE_PATH_PROTOCOL *\r
1914DevPathFromTextEmmc (\r
1915 IN CHAR16 *TextDeviceNode\r
1916 )\r
1917{\r
1918 CHAR16 *SlotNumberStr;\r
1919 EMMC_DEVICE_PATH *Emmc;\r
1920\r
1921 SlotNumberStr = GetNextParamStr (&TextDeviceNode);\r
1922 Emmc = (EMMC_DEVICE_PATH *) CreateDeviceNode (\r
1923 MESSAGING_DEVICE_PATH,\r
1924 MSG_EMMC_DP,\r
1925 (UINT16) sizeof (EMMC_DEVICE_PATH)\r
1926 );\r
1927\r
1928 Emmc->SlotNumber = (UINT8) Strtoi (SlotNumberStr);\r
1929\r
1930 return (EFI_DEVICE_PATH_PROTOCOL *) Emmc;\r
1931}\r
1932\r
572f5d8a 1933/**\r
1934 Converts a text device path node to Debug Port device path structure.\r
1935\r
1936 @param TextDeviceNode The input Text device path node.\r
1937\r
1938 @return A pointer to the newly-created Debug Port device path structure.\r
1939\r
1940**/\r
95276127 1941EFI_DEVICE_PATH_PROTOCOL *\r
1942DevPathFromTextDebugPort (\r
1943 IN CHAR16 *TextDeviceNode\r
1944 )\r
1945{\r
1946 VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend;\r
1947\r
1948 Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (\r
1949 MESSAGING_DEVICE_PATH,\r
1950 MSG_VENDOR_DP,\r
c9325700 1951 (UINT16) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)\r
95276127 1952 );\r
1953\r
1954 CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);\r
1955\r
1956 return (EFI_DEVICE_PATH_PROTOCOL *) Vend;\r
1957}\r
1958\r
572f5d8a 1959/**\r
1960 Converts a text device path node to MAC device path structure.\r
1961\r
1962 @param TextDeviceNode The input Text device path node.\r
1963\r
1964 @return A pointer to the newly-created MAC device path structure.\r
1965\r
1966**/\r
95276127 1967EFI_DEVICE_PATH_PROTOCOL *\r
1968DevPathFromTextMAC (\r
1969 IN CHAR16 *TextDeviceNode\r
1970 )\r
1971{\r
1972 CHAR16 *AddressStr;\r
1973 CHAR16 *IfTypeStr;\r
1974 UINTN Length;\r
572f5d8a 1975 MAC_ADDR_DEVICE_PATH *MACDevPath;\r
95276127 1976\r
1977 AddressStr = GetNextParamStr (&TextDeviceNode);\r
1978 IfTypeStr = GetNextParamStr (&TextDeviceNode);\r
572f5d8a 1979 MACDevPath = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (\r
95276127 1980 MESSAGING_DEVICE_PATH,\r
1981 MSG_MAC_ADDR_DP,\r
c9325700 1982 (UINT16) sizeof (MAC_ADDR_DEVICE_PATH)\r
95276127 1983 );\r
1984\r
572f5d8a 1985 MACDevPath->IfType = (UINT8) Strtoi (IfTypeStr);\r
95276127 1986\r
1987 Length = sizeof (EFI_MAC_ADDRESS);\r
572f5d8a 1988 StrToBuf (&MACDevPath->MacAddress.Addr[0], Length, AddressStr);\r
95276127 1989\r
572f5d8a 1990 return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;\r
95276127 1991}\r
1992\r
052019e1 1993\r
1994/**\r
1995 Converts a text format to the network protocol ID.\r
1996\r
1997 @param Text String of protocol field.\r
1998\r
1999 @return Network protocol ID .\r
2000\r
2001**/\r
2002UINTN\r
2003NetworkProtocolFromText (\r
2004 IN CHAR16 *Text\r
2005 )\r
2006{\r
2007 if (StrCmp (Text, L"UDP") == 0) {\r
2008 return RFC_1700_UDP_PROTOCOL;\r
2009 }\r
2010\r
2011 if (StrCmp (Text, L"TCP") == 0) {\r
2012 return RFC_1700_TCP_PROTOCOL;\r
2013 }\r
2014\r
2015 return Strtoi (Text);\r
2016}\r
2017\r
2018\r
572f5d8a 2019/**\r
2020 Converts a text device path node to IPV4 device path structure.\r
2021\r
2022 @param TextDeviceNode The input Text device path node.\r
2023\r
2024 @return A pointer to the newly-created IPV4 device path structure.\r
2025\r
2026**/\r
95276127 2027EFI_DEVICE_PATH_PROTOCOL *\r
2028DevPathFromTextIPv4 (\r
2029 IN CHAR16 *TextDeviceNode\r
2030 )\r
2031{\r
2032 CHAR16 *RemoteIPStr;\r
2033 CHAR16 *ProtocolStr;\r
2034 CHAR16 *TypeStr;\r
2035 CHAR16 *LocalIPStr;\r
e9b3cd55
RN
2036 CHAR16 *GatewayIPStr;\r
2037 CHAR16 *SubnetMaskStr;\r
95276127 2038 IPv4_DEVICE_PATH *IPv4;\r
2039\r
2040 RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r
2041 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
2042 TypeStr = GetNextParamStr (&TextDeviceNode);\r
2043 LocalIPStr = GetNextParamStr (&TextDeviceNode);\r
e9b3cd55
RN
2044 GatewayIPStr = GetNextParamStr (&TextDeviceNode);\r
2045 SubnetMaskStr = GetNextParamStr (&TextDeviceNode);\r
95276127 2046 IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (\r
2047 MESSAGING_DEVICE_PATH,\r
2048 MSG_IPv4_DP,\r
c9325700 2049 (UINT16) sizeof (IPv4_DEVICE_PATH)\r
95276127 2050 );\r
2051\r
2052 StrToIPv4Addr (&RemoteIPStr, &IPv4->RemoteIpAddress);\r
052019e1 2053 IPv4->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
95276127 2054 if (StrCmp (TypeStr, L"Static") == 0) {\r
2055 IPv4->StaticIpAddress = TRUE;\r
2056 } else {\r
2057 IPv4->StaticIpAddress = FALSE;\r
2058 }\r
2059\r
2060 StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress);\r
e9b3cd55
RN
2061 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*SubnetMaskStr)) {\r
2062 StrToIPv4Addr (&GatewayIPStr, &IPv4->GatewayIpAddress);\r
2063 StrToIPv4Addr (&SubnetMaskStr, &IPv4->SubnetMask);\r
2064 } else {\r
2065 ZeroMem (&IPv4->GatewayIpAddress, sizeof (IPv4->GatewayIpAddress));\r
2066 ZeroMem (&IPv4->SubnetMask, sizeof (IPv4->SubnetMask));\r
2067 }\r
95276127 2068\r
cf40f28a 2069 IPv4->LocalPort = 0;\r
2070 IPv4->RemotePort = 0;\r
95276127 2071\r
2072 return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;\r
2073}\r
2074\r
572f5d8a 2075/**\r
2076 Converts a text device path node to IPV6 device path structure.\r
2077\r
2078 @param TextDeviceNode The input Text device path node.\r
2079\r
2080 @return A pointer to the newly-created IPV6 device path structure.\r
2081\r
2082**/\r
95276127 2083EFI_DEVICE_PATH_PROTOCOL *\r
2084DevPathFromTextIPv6 (\r
2085 IN CHAR16 *TextDeviceNode\r
2086 )\r
2087{\r
2088 CHAR16 *RemoteIPStr;\r
2089 CHAR16 *ProtocolStr;\r
2090 CHAR16 *TypeStr;\r
2091 CHAR16 *LocalIPStr;\r
501793fa
RN
2092 CHAR16 *GatewayIPStr;\r
2093 CHAR16 *PrefixLengthStr;\r
95276127 2094 IPv6_DEVICE_PATH *IPv6;\r
2095\r
2096 RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r
2097 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
2098 TypeStr = GetNextParamStr (&TextDeviceNode);\r
2099 LocalIPStr = GetNextParamStr (&TextDeviceNode);\r
501793fa
RN
2100 PrefixLengthStr = GetNextParamStr (&TextDeviceNode);\r
2101 GatewayIPStr = GetNextParamStr (&TextDeviceNode);\r
95276127 2102 IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (\r
2103 MESSAGING_DEVICE_PATH,\r
2104 MSG_IPv6_DP,\r
c9325700 2105 (UINT16) sizeof (IPv6_DEVICE_PATH)\r
95276127 2106 );\r
2107\r
2108 StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);\r
052019e1 2109 IPv6->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
95276127 2110 if (StrCmp (TypeStr, L"Static") == 0) {\r
501793fa
RN
2111 IPv6->IpAddressOrigin = 0;\r
2112 } else if (StrCmp (TypeStr, L"StatelessAutoConfigure") == 0) {\r
2113 IPv6->IpAddressOrigin = 1;\r
95276127 2114 } else {\r
501793fa 2115 IPv6->IpAddressOrigin = 2;\r
95276127 2116 }\r
2117\r
2118 StrToIPv6Addr (&LocalIPStr, &IPv6->LocalIpAddress);\r
501793fa
RN
2119 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*PrefixLengthStr)) {\r
2120 StrToIPv6Addr (&GatewayIPStr, &IPv6->GatewayIpAddress);\r
2121 IPv6->PrefixLength = (UINT8) Strtoi (PrefixLengthStr);\r
2122 } else {\r
2123 ZeroMem (&IPv6->GatewayIpAddress, sizeof (IPv6->GatewayIpAddress));\r
2124 IPv6->PrefixLength = 0;\r
2125 }\r
95276127 2126\r
2127 IPv6->LocalPort = 0;\r
2128 IPv6->RemotePort = 0;\r
2129\r
2130 return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;\r
2131}\r
2132\r
572f5d8a 2133/**\r
2134 Converts a text device path node to UART device path structure.\r
2135\r
2136 @param TextDeviceNode The input Text device path node.\r
2137\r
2138 @return A pointer to the newly-created UART device path structure.\r
2139\r
2140**/\r
95276127 2141EFI_DEVICE_PATH_PROTOCOL *\r
2142DevPathFromTextUart (\r
2143 IN CHAR16 *TextDeviceNode\r
2144 )\r
2145{\r
2146 CHAR16 *BaudStr;\r
2147 CHAR16 *DataBitsStr;\r
2148 CHAR16 *ParityStr;\r
2149 CHAR16 *StopBitsStr;\r
2150 UART_DEVICE_PATH *Uart;\r
2151\r
2152 BaudStr = GetNextParamStr (&TextDeviceNode);\r
2153 DataBitsStr = GetNextParamStr (&TextDeviceNode);\r
2154 ParityStr = GetNextParamStr (&TextDeviceNode);\r
2155 StopBitsStr = GetNextParamStr (&TextDeviceNode);\r
2156 Uart = (UART_DEVICE_PATH *) CreateDeviceNode (\r
2157 MESSAGING_DEVICE_PATH,\r
2158 MSG_UART_DP,\r
c9325700 2159 (UINT16) sizeof (UART_DEVICE_PATH)\r
95276127 2160 );\r
2161\r
9da38884
RN
2162 if (StrCmp (BaudStr, L"DEFAULT") == 0) {\r
2163 Uart->BaudRate = 115200;\r
2164 } else {\r
2165 Strtoi64 (BaudStr, &Uart->BaudRate);\r
2166 }\r
2167 Uart->DataBits = (UINT8) ((StrCmp (DataBitsStr, L"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr));\r
95276127 2168 switch (*ParityStr) {\r
2169 case L'D':\r
2170 Uart->Parity = 0;\r
2171 break;\r
2172\r
2173 case L'N':\r
2174 Uart->Parity = 1;\r
2175 break;\r
2176\r
2177 case L'E':\r
2178 Uart->Parity = 2;\r
2179 break;\r
2180\r
2181 case L'O':\r
2182 Uart->Parity = 3;\r
2183 break;\r
2184\r
2185 case L'M':\r
2186 Uart->Parity = 4;\r
2187 break;\r
2188\r
2189 case L'S':\r
2190 Uart->Parity = 5;\r
bd07919c 2191 break;\r
95276127 2192\r
2193 default:\r
9da38884
RN
2194 Uart->Parity = (UINT8) Strtoi (ParityStr);\r
2195 break;\r
95276127 2196 }\r
2197\r
2198 if (StrCmp (StopBitsStr, L"D") == 0) {\r
2199 Uart->StopBits = (UINT8) 0;\r
2200 } else if (StrCmp (StopBitsStr, L"1") == 0) {\r
2201 Uart->StopBits = (UINT8) 1;\r
2202 } else if (StrCmp (StopBitsStr, L"1.5") == 0) {\r
2203 Uart->StopBits = (UINT8) 2;\r
2204 } else if (StrCmp (StopBitsStr, L"2") == 0) {\r
2205 Uart->StopBits = (UINT8) 3;\r
2206 } else {\r
9da38884 2207 Uart->StopBits = (UINT8) Strtoi (StopBitsStr);\r
95276127 2208 }\r
2209\r
2210 return (EFI_DEVICE_PATH_PROTOCOL *) Uart;\r
2211}\r
2212\r
572f5d8a 2213/**\r
2214 Converts a text device path node to USB class device path structure.\r
2215\r
2216 @param TextDeviceNode The input Text device path node.\r
2217 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.\r
2218\r
2219 @return A pointer to the newly-created USB class device path structure.\r
2220\r
2221**/\r
95276127 2222EFI_DEVICE_PATH_PROTOCOL *\r
2223ConvertFromTextUsbClass (\r
2224 IN CHAR16 *TextDeviceNode,\r
2225 IN USB_CLASS_TEXT *UsbClassText\r
2226 )\r
2227{\r
2228 CHAR16 *VIDStr;\r
2229 CHAR16 *PIDStr;\r
2230 CHAR16 *ClassStr;\r
2231 CHAR16 *SubClassStr;\r
2232 CHAR16 *ProtocolStr;\r
2233 USB_CLASS_DEVICE_PATH *UsbClass;\r
2234\r
2235 UsbClass = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (\r
2236 MESSAGING_DEVICE_PATH,\r
2237 MSG_USB_CLASS_DP,\r
c9325700 2238 (UINT16) sizeof (USB_CLASS_DEVICE_PATH)\r
95276127 2239 );\r
2240\r
2241 VIDStr = GetNextParamStr (&TextDeviceNode);\r
2242 PIDStr = GetNextParamStr (&TextDeviceNode);\r
2243 if (UsbClassText->ClassExist) {\r
2244 ClassStr = GetNextParamStr (&TextDeviceNode);\r
cf40f28a 2245 UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);\r
95276127 2246 } else {\r
2247 UsbClass->DeviceClass = UsbClassText->Class;\r
2248 }\r
2249 if (UsbClassText->SubClassExist) {\r
2250 SubClassStr = GetNextParamStr (&TextDeviceNode);\r
cf40f28a 2251 UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);\r
95276127 2252 } else {\r
2253 UsbClass->DeviceSubClass = UsbClassText->SubClass;\r
572f5d8a 2254 }\r
95276127 2255\r
2256 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
2257\r
cf40f28a 2258 UsbClass->VendorId = (UINT16) Strtoi (VIDStr);\r
2259 UsbClass->ProductId = (UINT16) Strtoi (PIDStr);\r
2260 UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);\r
95276127 2261\r
2262 return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;\r
2263}\r
2264\r
2265\r
572f5d8a 2266/**\r
2267 Converts a text device path node to USB class device path structure.\r
2268\r
2269 @param TextDeviceNode The input Text device path node.\r
2270\r
2271 @return A pointer to the newly-created USB class device path structure.\r
2272\r
2273**/\r
95276127 2274EFI_DEVICE_PATH_PROTOCOL *\r
2275DevPathFromTextUsbClass (\r
2276 IN CHAR16 *TextDeviceNode\r
2277 )\r
2278{\r
2279 USB_CLASS_TEXT UsbClassText;\r
2280\r
2281 UsbClassText.ClassExist = TRUE;\r
2282 UsbClassText.SubClassExist = TRUE;\r
2283\r
2284 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2285}\r
2286\r
572f5d8a 2287/**\r
2288 Converts a text device path node to USB audio device path structure.\r
2289\r
2290 @param TextDeviceNode The input Text device path node.\r
2291\r
2292 @return A pointer to the newly-created USB audio device path structure.\r
2293\r
2294**/\r
95276127 2295EFI_DEVICE_PATH_PROTOCOL *\r
2296DevPathFromTextUsbAudio (\r
2297 IN CHAR16 *TextDeviceNode\r
2298 )\r
2299{\r
2300 USB_CLASS_TEXT UsbClassText;\r
2301\r
2302 UsbClassText.ClassExist = FALSE;\r
2303 UsbClassText.Class = USB_CLASS_AUDIO;\r
2304 UsbClassText.SubClassExist = TRUE;\r
2305\r
2306 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2307}\r
2308\r
572f5d8a 2309/**\r
2310 Converts a text device path node to USB CDC Control device path structure.\r
2311\r
2312 @param TextDeviceNode The input Text device path node.\r
2313\r
2314 @return A pointer to the newly-created USB CDC Control device path structure.\r
2315\r
2316**/\r
95276127 2317EFI_DEVICE_PATH_PROTOCOL *\r
2318DevPathFromTextUsbCDCControl (\r
2319 IN CHAR16 *TextDeviceNode\r
2320 )\r
2321{\r
2322 USB_CLASS_TEXT UsbClassText;\r
2323\r
2324 UsbClassText.ClassExist = FALSE;\r
2325 UsbClassText.Class = USB_CLASS_CDCCONTROL;\r
2326 UsbClassText.SubClassExist = TRUE;\r
2327\r
2328 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2329}\r
2330\r
572f5d8a 2331/**\r
2332 Converts a text device path node to USB HID device path structure.\r
2333\r
2334 @param TextDeviceNode The input Text device path node.\r
2335\r
2336 @return A pointer to the newly-created USB HID device path structure.\r
2337\r
2338**/\r
95276127 2339EFI_DEVICE_PATH_PROTOCOL *\r
2340DevPathFromTextUsbHID (\r
2341 IN CHAR16 *TextDeviceNode\r
2342 )\r
2343{\r
2344 USB_CLASS_TEXT UsbClassText;\r
2345\r
2346 UsbClassText.ClassExist = FALSE;\r
2347 UsbClassText.Class = USB_CLASS_HID;\r
2348 UsbClassText.SubClassExist = TRUE;\r
2349\r
2350 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2351}\r
2352\r
572f5d8a 2353/**\r
2354 Converts a text device path node to USB Image device path structure.\r
2355\r
2356 @param TextDeviceNode The input Text device path node.\r
2357\r
2358 @return A pointer to the newly-created USB Image device path structure.\r
2359\r
2360**/\r
95276127 2361EFI_DEVICE_PATH_PROTOCOL *\r
2362DevPathFromTextUsbImage (\r
2363 IN CHAR16 *TextDeviceNode\r
2364 )\r
2365{\r
2366 USB_CLASS_TEXT UsbClassText;\r
2367\r
2368 UsbClassText.ClassExist = FALSE;\r
2369 UsbClassText.Class = USB_CLASS_IMAGE;\r
2370 UsbClassText.SubClassExist = TRUE;\r
2371\r
2372 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2373}\r
2374\r
572f5d8a 2375/**\r
2376 Converts a text device path node to USB Print device path structure.\r
2377\r
2378 @param TextDeviceNode The input Text device path node.\r
2379\r
2380 @return A pointer to the newly-created USB Print device path structure.\r
2381\r
2382**/\r
95276127 2383EFI_DEVICE_PATH_PROTOCOL *\r
2384DevPathFromTextUsbPrinter (\r
2385 IN CHAR16 *TextDeviceNode\r
2386 )\r
2387{\r
2388 USB_CLASS_TEXT UsbClassText;\r
2389\r
2390 UsbClassText.ClassExist = FALSE;\r
2391 UsbClassText.Class = USB_CLASS_PRINTER;\r
2392 UsbClassText.SubClassExist = TRUE;\r
2393\r
2394 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2395}\r
2396\r
572f5d8a 2397/**\r
2398 Converts a text device path node to USB mass storage device path structure.\r
2399\r
2400 @param TextDeviceNode The input Text device path node.\r
2401\r
2402 @return A pointer to the newly-created USB mass storage device path structure.\r
2403\r
2404**/\r
95276127 2405EFI_DEVICE_PATH_PROTOCOL *\r
2406DevPathFromTextUsbMassStorage (\r
2407 IN CHAR16 *TextDeviceNode\r
2408 )\r
2409{\r
2410 USB_CLASS_TEXT UsbClassText;\r
2411\r
2412 UsbClassText.ClassExist = FALSE;\r
2413 UsbClassText.Class = USB_CLASS_MASS_STORAGE;\r
2414 UsbClassText.SubClassExist = TRUE;\r
2415\r
2416 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2417}\r
2418\r
572f5d8a 2419/**\r
2420 Converts a text device path node to USB HUB device path structure.\r
2421\r
2422 @param TextDeviceNode The input Text device path node.\r
2423\r
2424 @return A pointer to the newly-created USB HUB device path structure.\r
2425\r
2426**/\r
95276127 2427EFI_DEVICE_PATH_PROTOCOL *\r
2428DevPathFromTextUsbHub (\r
2429 IN CHAR16 *TextDeviceNode\r
2430 )\r
2431{\r
2432 USB_CLASS_TEXT UsbClassText;\r
2433\r
2434 UsbClassText.ClassExist = FALSE;\r
2435 UsbClassText.Class = USB_CLASS_HUB;\r
2436 UsbClassText.SubClassExist = TRUE;\r
2437\r
2438 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2439}\r
2440\r
572f5d8a 2441/**\r
2442 Converts a text device path node to USB CDC data device path structure.\r
2443\r
2444 @param TextDeviceNode The input Text device path node.\r
2445\r
2446 @return A pointer to the newly-created USB CDC data device path structure.\r
2447\r
2448**/\r
95276127 2449EFI_DEVICE_PATH_PROTOCOL *\r
2450DevPathFromTextUsbCDCData (\r
2451 IN CHAR16 *TextDeviceNode\r
2452 )\r
2453{\r
2454 USB_CLASS_TEXT UsbClassText;\r
2455\r
2456 UsbClassText.ClassExist = FALSE;\r
2457 UsbClassText.Class = USB_CLASS_CDCDATA;\r
2458 UsbClassText.SubClassExist = TRUE;\r
2459\r
2460 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2461}\r
2462\r
572f5d8a 2463/**\r
2464 Converts a text device path node to USB smart card device path structure.\r
2465\r
2466 @param TextDeviceNode The input Text device path node.\r
2467\r
2468 @return A pointer to the newly-created USB smart card device path structure.\r
2469\r
2470**/\r
95276127 2471EFI_DEVICE_PATH_PROTOCOL *\r
2472DevPathFromTextUsbSmartCard (\r
2473 IN CHAR16 *TextDeviceNode\r
2474 )\r
2475{\r
2476 USB_CLASS_TEXT UsbClassText;\r
2477\r
2478 UsbClassText.ClassExist = FALSE;\r
2479 UsbClassText.Class = USB_CLASS_SMART_CARD;\r
2480 UsbClassText.SubClassExist = TRUE;\r
2481\r
2482 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2483}\r
2484\r
572f5d8a 2485/**\r
2486 Converts a text device path node to USB video device path structure.\r
2487\r
2488 @param TextDeviceNode The input Text device path node.\r
2489\r
2490 @return A pointer to the newly-created USB video device path structure.\r
2491\r
2492**/\r
95276127 2493EFI_DEVICE_PATH_PROTOCOL *\r
2494DevPathFromTextUsbVideo (\r
2495 IN CHAR16 *TextDeviceNode\r
2496 )\r
2497{\r
2498 USB_CLASS_TEXT UsbClassText;\r
2499\r
2500 UsbClassText.ClassExist = FALSE;\r
2501 UsbClassText.Class = USB_CLASS_VIDEO;\r
2502 UsbClassText.SubClassExist = TRUE;\r
2503\r
2504 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2505}\r
2506\r
572f5d8a 2507/**\r
2508 Converts a text device path node to USB diagnostic device path structure.\r
2509\r
2510 @param TextDeviceNode The input Text device path node.\r
2511\r
2512 @return A pointer to the newly-created USB diagnostic device path structure.\r
2513\r
2514**/\r
95276127 2515EFI_DEVICE_PATH_PROTOCOL *\r
2516DevPathFromTextUsbDiagnostic (\r
2517 IN CHAR16 *TextDeviceNode\r
2518 )\r
2519{\r
2520 USB_CLASS_TEXT UsbClassText;\r
2521\r
2522 UsbClassText.ClassExist = FALSE;\r
2523 UsbClassText.Class = USB_CLASS_DIAGNOSTIC;\r
2524 UsbClassText.SubClassExist = TRUE;\r
2525\r
2526 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2527}\r
2528\r
572f5d8a 2529/**\r
2530 Converts a text device path node to USB wireless device path structure.\r
2531\r
2532 @param TextDeviceNode The input Text device path node.\r
2533\r
2534 @return A pointer to the newly-created USB wireless device path structure.\r
2535\r
2536**/\r
95276127 2537EFI_DEVICE_PATH_PROTOCOL *\r
2538DevPathFromTextUsbWireless (\r
2539 IN CHAR16 *TextDeviceNode\r
2540 )\r
2541{\r
2542 USB_CLASS_TEXT UsbClassText;\r
2543\r
2544 UsbClassText.ClassExist = FALSE;\r
2545 UsbClassText.Class = USB_CLASS_WIRELESS;\r
2546 UsbClassText.SubClassExist = TRUE;\r
2547\r
2548 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2549}\r
2550\r
572f5d8a 2551/**\r
2552 Converts a text device path node to USB device firmware update device path structure.\r
2553\r
2554 @param TextDeviceNode The input Text device path node.\r
2555\r
2556 @return A pointer to the newly-created USB device firmware update device path structure.\r
2557\r
2558**/\r
95276127 2559EFI_DEVICE_PATH_PROTOCOL *\r
2560DevPathFromTextUsbDeviceFirmwareUpdate (\r
2561 IN CHAR16 *TextDeviceNode\r
2562 )\r
2563{\r
2564 USB_CLASS_TEXT UsbClassText;\r
2565\r
2566 UsbClassText.ClassExist = FALSE;\r
2567 UsbClassText.Class = USB_CLASS_RESERVE;\r
2568 UsbClassText.SubClassExist = FALSE;\r
2569 UsbClassText.SubClass = USB_SUBCLASS_FW_UPDATE;\r
2570\r
2571 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2572}\r
2573\r
572f5d8a 2574/**\r
2575 Converts a text device path node to USB IRDA bridge device path structure.\r
2576\r
2577 @param TextDeviceNode The input Text device path node.\r
2578\r
2579 @return A pointer to the newly-created USB IRDA bridge device path structure.\r
2580\r
2581**/\r
95276127 2582EFI_DEVICE_PATH_PROTOCOL *\r
2583DevPathFromTextUsbIrdaBridge (\r
2584 IN CHAR16 *TextDeviceNode\r
2585 )\r
2586{\r
2587 USB_CLASS_TEXT UsbClassText;\r
2588\r
2589 UsbClassText.ClassExist = FALSE;\r
2590 UsbClassText.Class = USB_CLASS_RESERVE;\r
2591 UsbClassText.SubClassExist = FALSE;\r
2592 UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE;\r
2593\r
2594 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2595}\r
2596\r
572f5d8a 2597/**\r
2598 Converts a text device path node to USB text and measurement device path structure.\r
2599\r
2600 @param TextDeviceNode The input Text device path node.\r
2601\r
2602 @return A pointer to the newly-created USB text and measurement device path structure.\r
2603\r
2604**/\r
95276127 2605EFI_DEVICE_PATH_PROTOCOL *\r
2606DevPathFromTextUsbTestAndMeasurement (\r
2607 IN CHAR16 *TextDeviceNode\r
2608 )\r
2609{\r
2610 USB_CLASS_TEXT UsbClassText;\r
2611\r
2612 UsbClassText.ClassExist = FALSE;\r
2613 UsbClassText.Class = USB_CLASS_RESERVE;\r
2614 UsbClassText.SubClassExist = FALSE;\r
2615 UsbClassText.SubClass = USB_SUBCLASS_TEST;\r
2616\r
2617 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2618}\r
2619\r
572f5d8a 2620/**\r
2621 Converts a text device path node to USB WWID device path structure.\r
2622\r
2623 @param TextDeviceNode The input Text device path node.\r
2624\r
2625 @return A pointer to the newly-created USB WWID device path structure.\r
2626\r
2627**/\r
95276127 2628EFI_DEVICE_PATH_PROTOCOL *\r
2629DevPathFromTextUsbWwid (\r
2630 IN CHAR16 *TextDeviceNode\r
2631 )\r
2632{\r
2633 CHAR16 *VIDStr;\r
2634 CHAR16 *PIDStr;\r
2635 CHAR16 *InterfaceNumStr;\r
cf40f28a 2636 CHAR16 *SerialNumberStr;\r
95276127 2637 USB_WWID_DEVICE_PATH *UsbWwid;\r
9da38884
RN
2638 UINTN SerialNumberStrLen;\r
2639\r
2640 VIDStr = GetNextParamStr (&TextDeviceNode);\r
2641 PIDStr = GetNextParamStr (&TextDeviceNode);\r
2642 InterfaceNumStr = GetNextParamStr (&TextDeviceNode);\r
2643 SerialNumberStr = GetNextParamStr (&TextDeviceNode);\r
2644 SerialNumberStrLen = StrLen (SerialNumberStr);\r
2645 if (SerialNumberStrLen >= 2 &&\r
2646 SerialNumberStr[0] == L'\"' &&\r
2647 SerialNumberStr[SerialNumberStrLen - 1] == L'\"'\r
2648 ) {\r
2649 SerialNumberStr[SerialNumberStrLen - 1] = L'\0';\r
2650 SerialNumberStr++;\r
2651 SerialNumberStrLen -= 2;\r
2652 }\r
2653 UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (\r
95276127 2654 MESSAGING_DEVICE_PATH,\r
2655 MSG_USB_WWID_DP,\r
9da38884 2656 (UINT16) (sizeof (USB_WWID_DEVICE_PATH) + SerialNumberStrLen * sizeof (CHAR16))\r
95276127 2657 );\r
9da38884
RN
2658 UsbWwid->VendorId = (UINT16) Strtoi (VIDStr);\r
2659 UsbWwid->ProductId = (UINT16) Strtoi (PIDStr);\r
2660 UsbWwid->InterfaceNumber = (UINT16) Strtoi (InterfaceNumStr);\r
750b4513
HW
2661\r
2662 //\r
2663 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.\r
2664 // Therefore, the '\0' will not be copied.\r
2665 //\r
2666 CopyMem (\r
2667 (UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH),\r
2668 SerialNumberStr,\r
2669 SerialNumberStrLen * sizeof (CHAR16)\r
2670 );\r
95276127 2671\r
2672 return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;\r
2673}\r
2674\r
572f5d8a 2675/**\r
2676 Converts a text device path node to Logic Unit device path structure.\r
2677\r
2678 @param TextDeviceNode The input Text device path node.\r
2679\r
2680 @return A pointer to the newly-created Logic Unit device path structure.\r
2681\r
2682**/\r
95276127 2683EFI_DEVICE_PATH_PROTOCOL *\r
2684DevPathFromTextUnit (\r
2685 IN CHAR16 *TextDeviceNode\r
2686 )\r
2687{\r
2688 CHAR16 *LunStr;\r
2689 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
2690\r
2691 LunStr = GetNextParamStr (&TextDeviceNode);\r
2692 LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (\r
2693 MESSAGING_DEVICE_PATH,\r
2694 MSG_DEVICE_LOGICAL_UNIT_DP,\r
cf40f28a 2695 (UINT16) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)\r
95276127 2696 );\r
2697\r
cf40f28a 2698 LogicalUnit->Lun = (UINT8) Strtoi (LunStr);\r
95276127 2699\r
2700 return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;\r
2701}\r
2702\r
572f5d8a 2703/**\r
2704 Converts a text device path node to iSCSI device path structure.\r
2705\r
2706 @param TextDeviceNode The input Text device path node.\r
2707\r
2708 @return A pointer to the newly-created iSCSI device path structure.\r
2709\r
2710**/\r
95276127 2711EFI_DEVICE_PATH_PROTOCOL *\r
2712DevPathFromTextiSCSI (\r
2713 IN CHAR16 *TextDeviceNode\r
2714 )\r
2715{\r
2716 UINT16 Options;\r
2717 CHAR16 *NameStr;\r
2718 CHAR16 *PortalGroupStr;\r
2719 CHAR16 *LunStr;\r
2720 CHAR16 *HeaderDigestStr;\r
2721 CHAR16 *DataDigestStr;\r
2722 CHAR16 *AuthenticationStr;\r
2723 CHAR16 *ProtocolStr;\r
cf40f28a 2724 CHAR8 *AsciiStr;\r
572f5d8a 2725 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
95276127 2726\r
2727 NameStr = GetNextParamStr (&TextDeviceNode);\r
2728 PortalGroupStr = GetNextParamStr (&TextDeviceNode);\r
2729 LunStr = GetNextParamStr (&TextDeviceNode);\r
2730 HeaderDigestStr = GetNextParamStr (&TextDeviceNode);\r
2731 DataDigestStr = GetNextParamStr (&TextDeviceNode);\r
2732 AuthenticationStr = GetNextParamStr (&TextDeviceNode);\r
2733 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
572f5d8a 2734 ISCSIDevPath = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (\r
95276127 2735 MESSAGING_DEVICE_PATH,\r
2736 MSG_ISCSI_DP,\r
047c6449 2737 (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))\r
95276127 2738 );\r
2739\r
184f7d83 2740 AsciiStr = ISCSIDevPath->TargetName;\r
cf40f28a 2741 StrToAscii (NameStr, &AsciiStr);\r
2742\r
572f5d8a 2743 ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);\r
2744 Strtoi64 (LunStr, &ISCSIDevPath->Lun);\r
95276127 2745\r
2746 Options = 0x0000;\r
2747 if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {\r
2748 Options |= 0x0002;\r
2749 }\r
2750\r
2751 if (StrCmp (DataDigestStr, L"CRC32C") == 0) {\r
2752 Options |= 0x0008;\r
2753 }\r
2754\r
2755 if (StrCmp (AuthenticationStr, L"None") == 0) {\r
2756 Options |= 0x0800;\r
2757 }\r
2758\r
2759 if (StrCmp (AuthenticationStr, L"CHAP_UNI") == 0) {\r
2760 Options |= 0x1000;\r
2761 }\r
2762\r
572f5d8a 2763 ISCSIDevPath->LoginOption = (UINT16) Options;\r
95276127 2764\r
572f5d8a 2765 ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP");\r
95276127 2766\r
572f5d8a 2767 return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;\r
95276127 2768}\r
2769\r
8f97f911 2770/**\r
2771 Converts a text device path node to VLAN device path structure.\r
2772\r
2773 @param TextDeviceNode The input Text device path node.\r
2774\r
2775 @return A pointer to the newly-created VLAN device path structure.\r
2776\r
2777**/\r
2778EFI_DEVICE_PATH_PROTOCOL *\r
2779DevPathFromTextVlan (\r
2780 IN CHAR16 *TextDeviceNode\r
2781 )\r
2782{\r
2783 CHAR16 *VlanStr;\r
2784 VLAN_DEVICE_PATH *Vlan;\r
2785\r
2786 VlanStr = GetNextParamStr (&TextDeviceNode);\r
2787 Vlan = (VLAN_DEVICE_PATH *) CreateDeviceNode (\r
2788 MESSAGING_DEVICE_PATH,\r
2789 MSG_VLAN_DP,\r
c9325700 2790 (UINT16) sizeof (VLAN_DEVICE_PATH)\r
8f97f911 2791 );\r
2792\r
2793 Vlan->VlanId = (UINT16) Strtoi (VlanStr);\r
2794\r
2795 return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;\r
2796}\r
2797\r
7795c8f9
QS
2798/**\r
2799 Converts a text device path node to Bluetooth device path structure.\r
2800\r
2801 @param TextDeviceNode The input Text device path node.\r
2802\r
2803 @return A pointer to the newly-created Bluetooth device path structure.\r
2804\r
2805**/\r
2806EFI_DEVICE_PATH_PROTOCOL *\r
2807DevPathFromTextBluetooth (\r
2808 IN CHAR16 *TextDeviceNode\r
2809 )\r
2810{\r
2811 CHAR16 *BluetoothStr;\r
2812 CHAR16 *Walker;\r
2813 CHAR16 *TempNumBuffer;\r
2814 UINTN TempBufferSize;\r
2815 INT32 Index;\r
2816 BLUETOOTH_DEVICE_PATH *BluetoothDp;\r
2817\r
2818 BluetoothStr = GetNextParamStr (&TextDeviceNode);\r
2819 BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (\r
2820 MESSAGING_DEVICE_PATH,\r
2821 MSG_BLUETOOTH_DP,\r
2822 (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)\r
2823 );\r
2824\r
2825 Index = sizeof (BLUETOOTH_ADDRESS) - 1;\r
6252f271
QS
2826 Walker = BluetoothStr;\r
2827 while (!IS_NULL(*Walker) && Index >= 0) {\r
2828 TempBufferSize = 2 * sizeof(CHAR16) + StrSize(L"0x");\r
7795c8f9
QS
2829 TempNumBuffer = AllocateZeroPool (TempBufferSize);\r
2830 if (TempNumBuffer == NULL) {\r
2831 break;\r
2832 }\r
750b4513 2833 StrCpyS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), L"0x");\r
6252f271 2834 StrnCatS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), Walker, 2);\r
7795c8f9
QS
2835 BluetoothDp->BD_ADDR.Address[Index] = (UINT8)Strtoi (TempNumBuffer);\r
2836 FreePool (TempNumBuffer);\r
6252f271 2837 Walker += 2;\r
7795c8f9
QS
2838 Index--;\r
2839 }\r
2840 \r
2841 return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothDp;\r
2842}\r
2843\r
3bafd562
HW
2844/**\r
2845 Converts a text device path node to Wi-Fi device path structure.\r
2846\r
2847 @param TextDeviceNode The input Text device path node.\r
2848\r
2849 @return A pointer to the newly-created Wi-Fi device path structure.\r
2850\r
2851**/\r
2852EFI_DEVICE_PATH_PROTOCOL *\r
2853DevPathFromTextWiFi (\r
2854 IN CHAR16 *TextDeviceNode\r
2855 )\r
2856{\r
2857 CHAR16 *SSIdStr;\r
0cd35d73
HW
2858 CHAR8 AsciiStr[33];\r
2859 UINTN DataLen;\r
3bafd562
HW
2860 WIFI_DEVICE_PATH *WiFiDp;\r
2861\r
2862 SSIdStr = GetNextParamStr (&TextDeviceNode);\r
2863 WiFiDp = (WIFI_DEVICE_PATH *) CreateDeviceNode (\r
2864 MESSAGING_DEVICE_PATH,\r
2865 MSG_WIFI_DP,\r
2866 (UINT16) sizeof (WIFI_DEVICE_PATH)\r
2867 );\r
2868\r
0cd35d73
HW
2869 if (NULL != SSIdStr) {\r
2870 DataLen = StrLen (SSIdStr);\r
2871 if (StrLen (SSIdStr) > 32) {\r
2872 SSIdStr[32] = L'\0';\r
2873 DataLen = 32;\r
2874 }\r
2875\r
ca2ac9d5 2876 UnicodeStrToAsciiStrS (SSIdStr, AsciiStr, sizeof (AsciiStr));\r
0cd35d73
HW
2877 CopyMem (WiFiDp->SSId, AsciiStr, DataLen);\r
2878 }\r
3bafd562
HW
2879\r
2880 return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp;\r
2881}\r
2882\r
c808ac7b
RN
2883/**\r
2884 Converts a text device path node to URI device path structure.\r
2885\r
2886 @param TextDeviceNode The input Text device path node.\r
2887\r
2888 @return A pointer to the newly-created URI device path structure.\r
2889\r
2890**/\r
2891EFI_DEVICE_PATH_PROTOCOL *\r
2892DevPathFromTextUri (\r
2893 IN CHAR16 *TextDeviceNode\r
2894 )\r
2895{\r
2896 CHAR16 *UriStr;\r
2897 UINTN UriLength;\r
2898 URI_DEVICE_PATH *Uri;\r
2899\r
2900 UriStr = GetNextParamStr (&TextDeviceNode);\r
2901 UriLength = StrnLenS (UriStr, MAX_UINT16 - sizeof (URI_DEVICE_PATH));\r
2902 Uri = (URI_DEVICE_PATH *) CreateDeviceNode (\r
2903 MESSAGING_DEVICE_PATH,\r
2904 MSG_URI_DP,\r
2905 (UINT16) (sizeof (URI_DEVICE_PATH) + UriLength)\r
2906 );\r
2907\r
2908 while (UriLength-- != 0) {\r
2909 Uri->Uri[UriLength] = (CHAR8) UriStr[UriLength];\r
2910 }\r
2911\r
2912 return (EFI_DEVICE_PATH_PROTOCOL *) Uri;\r
2913}\r
2914\r
5d6a5aee
RN
2915/**\r
2916 Converts a media text device path node to media device path structure.\r
2917\r
2918 @param TextDeviceNode The input Text device path node.\r
2919\r
2920 @return A pointer to media device path structure.\r
2921\r
2922**/\r
2923EFI_DEVICE_PATH_PROTOCOL *\r
2924DevPathFromTextMediaPath (\r
2925 IN CHAR16 *TextDeviceNode\r
2926 )\r
2927{\r
2928 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH, TextDeviceNode);\r
2929}\r
2930\r
572f5d8a 2931/**\r
2932 Converts a text device path node to HD device path structure.\r
2933\r
2934 @param TextDeviceNode The input Text device path node.\r