MdePkg: Refine the device path text format for Bluetooth to follow spec.
[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
7795c8f9 4Copyright (c) 2013 - 2015, 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
572f5d8a 1905/**\r
1906 Converts a text device path node to Debug Port 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 Debug Port device path structure.\r
1911\r
1912**/\r
95276127 1913EFI_DEVICE_PATH_PROTOCOL *\r
1914DevPathFromTextDebugPort (\r
1915 IN CHAR16 *TextDeviceNode\r
1916 )\r
1917{\r
1918 VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend;\r
1919\r
1920 Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (\r
1921 MESSAGING_DEVICE_PATH,\r
1922 MSG_VENDOR_DP,\r
c9325700 1923 (UINT16) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)\r
95276127 1924 );\r
1925\r
1926 CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);\r
1927\r
1928 return (EFI_DEVICE_PATH_PROTOCOL *) Vend;\r
1929}\r
1930\r
572f5d8a 1931/**\r
1932 Converts a text device path node to MAC device path structure.\r
1933\r
1934 @param TextDeviceNode The input Text device path node.\r
1935\r
1936 @return A pointer to the newly-created MAC device path structure.\r
1937\r
1938**/\r
95276127 1939EFI_DEVICE_PATH_PROTOCOL *\r
1940DevPathFromTextMAC (\r
1941 IN CHAR16 *TextDeviceNode\r
1942 )\r
1943{\r
1944 CHAR16 *AddressStr;\r
1945 CHAR16 *IfTypeStr;\r
1946 UINTN Length;\r
572f5d8a 1947 MAC_ADDR_DEVICE_PATH *MACDevPath;\r
95276127 1948\r
1949 AddressStr = GetNextParamStr (&TextDeviceNode);\r
1950 IfTypeStr = GetNextParamStr (&TextDeviceNode);\r
572f5d8a 1951 MACDevPath = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (\r
95276127 1952 MESSAGING_DEVICE_PATH,\r
1953 MSG_MAC_ADDR_DP,\r
c9325700 1954 (UINT16) sizeof (MAC_ADDR_DEVICE_PATH)\r
95276127 1955 );\r
1956\r
572f5d8a 1957 MACDevPath->IfType = (UINT8) Strtoi (IfTypeStr);\r
95276127 1958\r
1959 Length = sizeof (EFI_MAC_ADDRESS);\r
572f5d8a 1960 StrToBuf (&MACDevPath->MacAddress.Addr[0], Length, AddressStr);\r
95276127 1961\r
572f5d8a 1962 return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;\r
95276127 1963}\r
1964\r
052019e1 1965\r
1966/**\r
1967 Converts a text format to the network protocol ID.\r
1968\r
1969 @param Text String of protocol field.\r
1970\r
1971 @return Network protocol ID .\r
1972\r
1973**/\r
1974UINTN\r
1975NetworkProtocolFromText (\r
1976 IN CHAR16 *Text\r
1977 )\r
1978{\r
1979 if (StrCmp (Text, L"UDP") == 0) {\r
1980 return RFC_1700_UDP_PROTOCOL;\r
1981 }\r
1982\r
1983 if (StrCmp (Text, L"TCP") == 0) {\r
1984 return RFC_1700_TCP_PROTOCOL;\r
1985 }\r
1986\r
1987 return Strtoi (Text);\r
1988}\r
1989\r
1990\r
572f5d8a 1991/**\r
1992 Converts a text device path node to IPV4 device path structure.\r
1993\r
1994 @param TextDeviceNode The input Text device path node.\r
1995\r
1996 @return A pointer to the newly-created IPV4 device path structure.\r
1997\r
1998**/\r
95276127 1999EFI_DEVICE_PATH_PROTOCOL *\r
2000DevPathFromTextIPv4 (\r
2001 IN CHAR16 *TextDeviceNode\r
2002 )\r
2003{\r
2004 CHAR16 *RemoteIPStr;\r
2005 CHAR16 *ProtocolStr;\r
2006 CHAR16 *TypeStr;\r
2007 CHAR16 *LocalIPStr;\r
e9b3cd55
RN
2008 CHAR16 *GatewayIPStr;\r
2009 CHAR16 *SubnetMaskStr;\r
95276127 2010 IPv4_DEVICE_PATH *IPv4;\r
2011\r
2012 RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r
2013 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
2014 TypeStr = GetNextParamStr (&TextDeviceNode);\r
2015 LocalIPStr = GetNextParamStr (&TextDeviceNode);\r
e9b3cd55
RN
2016 GatewayIPStr = GetNextParamStr (&TextDeviceNode);\r
2017 SubnetMaskStr = GetNextParamStr (&TextDeviceNode);\r
95276127 2018 IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (\r
2019 MESSAGING_DEVICE_PATH,\r
2020 MSG_IPv4_DP,\r
c9325700 2021 (UINT16) sizeof (IPv4_DEVICE_PATH)\r
95276127 2022 );\r
2023\r
2024 StrToIPv4Addr (&RemoteIPStr, &IPv4->RemoteIpAddress);\r
052019e1 2025 IPv4->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
95276127 2026 if (StrCmp (TypeStr, L"Static") == 0) {\r
2027 IPv4->StaticIpAddress = TRUE;\r
2028 } else {\r
2029 IPv4->StaticIpAddress = FALSE;\r
2030 }\r
2031\r
2032 StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress);\r
e9b3cd55
RN
2033 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*SubnetMaskStr)) {\r
2034 StrToIPv4Addr (&GatewayIPStr, &IPv4->GatewayIpAddress);\r
2035 StrToIPv4Addr (&SubnetMaskStr, &IPv4->SubnetMask);\r
2036 } else {\r
2037 ZeroMem (&IPv4->GatewayIpAddress, sizeof (IPv4->GatewayIpAddress));\r
2038 ZeroMem (&IPv4->SubnetMask, sizeof (IPv4->SubnetMask));\r
2039 }\r
95276127 2040\r
cf40f28a 2041 IPv4->LocalPort = 0;\r
2042 IPv4->RemotePort = 0;\r
95276127 2043\r
2044 return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;\r
2045}\r
2046\r
572f5d8a 2047/**\r
2048 Converts a text device path node to IPV6 device path structure.\r
2049\r
2050 @param TextDeviceNode The input Text device path node.\r
2051\r
2052 @return A pointer to the newly-created IPV6 device path structure.\r
2053\r
2054**/\r
95276127 2055EFI_DEVICE_PATH_PROTOCOL *\r
2056DevPathFromTextIPv6 (\r
2057 IN CHAR16 *TextDeviceNode\r
2058 )\r
2059{\r
2060 CHAR16 *RemoteIPStr;\r
2061 CHAR16 *ProtocolStr;\r
2062 CHAR16 *TypeStr;\r
2063 CHAR16 *LocalIPStr;\r
501793fa
RN
2064 CHAR16 *GatewayIPStr;\r
2065 CHAR16 *PrefixLengthStr;\r
95276127 2066 IPv6_DEVICE_PATH *IPv6;\r
2067\r
2068 RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r
2069 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
2070 TypeStr = GetNextParamStr (&TextDeviceNode);\r
2071 LocalIPStr = GetNextParamStr (&TextDeviceNode);\r
501793fa
RN
2072 PrefixLengthStr = GetNextParamStr (&TextDeviceNode);\r
2073 GatewayIPStr = GetNextParamStr (&TextDeviceNode);\r
95276127 2074 IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (\r
2075 MESSAGING_DEVICE_PATH,\r
2076 MSG_IPv6_DP,\r
c9325700 2077 (UINT16) sizeof (IPv6_DEVICE_PATH)\r
95276127 2078 );\r
2079\r
2080 StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);\r
052019e1 2081 IPv6->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
95276127 2082 if (StrCmp (TypeStr, L"Static") == 0) {\r
501793fa
RN
2083 IPv6->IpAddressOrigin = 0;\r
2084 } else if (StrCmp (TypeStr, L"StatelessAutoConfigure") == 0) {\r
2085 IPv6->IpAddressOrigin = 1;\r
95276127 2086 } else {\r
501793fa 2087 IPv6->IpAddressOrigin = 2;\r
95276127 2088 }\r
2089\r
2090 StrToIPv6Addr (&LocalIPStr, &IPv6->LocalIpAddress);\r
501793fa
RN
2091 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*PrefixLengthStr)) {\r
2092 StrToIPv6Addr (&GatewayIPStr, &IPv6->GatewayIpAddress);\r
2093 IPv6->PrefixLength = (UINT8) Strtoi (PrefixLengthStr);\r
2094 } else {\r
2095 ZeroMem (&IPv6->GatewayIpAddress, sizeof (IPv6->GatewayIpAddress));\r
2096 IPv6->PrefixLength = 0;\r
2097 }\r
95276127 2098\r
2099 IPv6->LocalPort = 0;\r
2100 IPv6->RemotePort = 0;\r
2101\r
2102 return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;\r
2103}\r
2104\r
572f5d8a 2105/**\r
2106 Converts a text device path node to UART device path structure.\r
2107\r
2108 @param TextDeviceNode The input Text device path node.\r
2109\r
2110 @return A pointer to the newly-created UART device path structure.\r
2111\r
2112**/\r
95276127 2113EFI_DEVICE_PATH_PROTOCOL *\r
2114DevPathFromTextUart (\r
2115 IN CHAR16 *TextDeviceNode\r
2116 )\r
2117{\r
2118 CHAR16 *BaudStr;\r
2119 CHAR16 *DataBitsStr;\r
2120 CHAR16 *ParityStr;\r
2121 CHAR16 *StopBitsStr;\r
2122 UART_DEVICE_PATH *Uart;\r
2123\r
2124 BaudStr = GetNextParamStr (&TextDeviceNode);\r
2125 DataBitsStr = GetNextParamStr (&TextDeviceNode);\r
2126 ParityStr = GetNextParamStr (&TextDeviceNode);\r
2127 StopBitsStr = GetNextParamStr (&TextDeviceNode);\r
2128 Uart = (UART_DEVICE_PATH *) CreateDeviceNode (\r
2129 MESSAGING_DEVICE_PATH,\r
2130 MSG_UART_DP,\r
c9325700 2131 (UINT16) sizeof (UART_DEVICE_PATH)\r
95276127 2132 );\r
2133\r
9da38884
RN
2134 if (StrCmp (BaudStr, L"DEFAULT") == 0) {\r
2135 Uart->BaudRate = 115200;\r
2136 } else {\r
2137 Strtoi64 (BaudStr, &Uart->BaudRate);\r
2138 }\r
2139 Uart->DataBits = (UINT8) ((StrCmp (DataBitsStr, L"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr));\r
95276127 2140 switch (*ParityStr) {\r
2141 case L'D':\r
2142 Uart->Parity = 0;\r
2143 break;\r
2144\r
2145 case L'N':\r
2146 Uart->Parity = 1;\r
2147 break;\r
2148\r
2149 case L'E':\r
2150 Uart->Parity = 2;\r
2151 break;\r
2152\r
2153 case L'O':\r
2154 Uart->Parity = 3;\r
2155 break;\r
2156\r
2157 case L'M':\r
2158 Uart->Parity = 4;\r
2159 break;\r
2160\r
2161 case L'S':\r
2162 Uart->Parity = 5;\r
bd07919c 2163 break;\r
95276127 2164\r
2165 default:\r
9da38884
RN
2166 Uart->Parity = (UINT8) Strtoi (ParityStr);\r
2167 break;\r
95276127 2168 }\r
2169\r
2170 if (StrCmp (StopBitsStr, L"D") == 0) {\r
2171 Uart->StopBits = (UINT8) 0;\r
2172 } else if (StrCmp (StopBitsStr, L"1") == 0) {\r
2173 Uart->StopBits = (UINT8) 1;\r
2174 } else if (StrCmp (StopBitsStr, L"1.5") == 0) {\r
2175 Uart->StopBits = (UINT8) 2;\r
2176 } else if (StrCmp (StopBitsStr, L"2") == 0) {\r
2177 Uart->StopBits = (UINT8) 3;\r
2178 } else {\r
9da38884 2179 Uart->StopBits = (UINT8) Strtoi (StopBitsStr);\r
95276127 2180 }\r
2181\r
2182 return (EFI_DEVICE_PATH_PROTOCOL *) Uart;\r
2183}\r
2184\r
572f5d8a 2185/**\r
2186 Converts a text device path node to USB class device path structure.\r
2187\r
2188 @param TextDeviceNode The input Text device path node.\r
2189 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.\r
2190\r
2191 @return A pointer to the newly-created USB class device path structure.\r
2192\r
2193**/\r
95276127 2194EFI_DEVICE_PATH_PROTOCOL *\r
2195ConvertFromTextUsbClass (\r
2196 IN CHAR16 *TextDeviceNode,\r
2197 IN USB_CLASS_TEXT *UsbClassText\r
2198 )\r
2199{\r
2200 CHAR16 *VIDStr;\r
2201 CHAR16 *PIDStr;\r
2202 CHAR16 *ClassStr;\r
2203 CHAR16 *SubClassStr;\r
2204 CHAR16 *ProtocolStr;\r
2205 USB_CLASS_DEVICE_PATH *UsbClass;\r
2206\r
2207 UsbClass = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (\r
2208 MESSAGING_DEVICE_PATH,\r
2209 MSG_USB_CLASS_DP,\r
c9325700 2210 (UINT16) sizeof (USB_CLASS_DEVICE_PATH)\r
95276127 2211 );\r
2212\r
2213 VIDStr = GetNextParamStr (&TextDeviceNode);\r
2214 PIDStr = GetNextParamStr (&TextDeviceNode);\r
2215 if (UsbClassText->ClassExist) {\r
2216 ClassStr = GetNextParamStr (&TextDeviceNode);\r
cf40f28a 2217 UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);\r
95276127 2218 } else {\r
2219 UsbClass->DeviceClass = UsbClassText->Class;\r
2220 }\r
2221 if (UsbClassText->SubClassExist) {\r
2222 SubClassStr = GetNextParamStr (&TextDeviceNode);\r
cf40f28a 2223 UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);\r
95276127 2224 } else {\r
2225 UsbClass->DeviceSubClass = UsbClassText->SubClass;\r
572f5d8a 2226 }\r
95276127 2227\r
2228 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
2229\r
cf40f28a 2230 UsbClass->VendorId = (UINT16) Strtoi (VIDStr);\r
2231 UsbClass->ProductId = (UINT16) Strtoi (PIDStr);\r
2232 UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);\r
95276127 2233\r
2234 return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;\r
2235}\r
2236\r
2237\r
572f5d8a 2238/**\r
2239 Converts a text device path node to USB class device path structure.\r
2240\r
2241 @param TextDeviceNode The input Text device path node.\r
2242\r
2243 @return A pointer to the newly-created USB class device path structure.\r
2244\r
2245**/\r
95276127 2246EFI_DEVICE_PATH_PROTOCOL *\r
2247DevPathFromTextUsbClass (\r
2248 IN CHAR16 *TextDeviceNode\r
2249 )\r
2250{\r
2251 USB_CLASS_TEXT UsbClassText;\r
2252\r
2253 UsbClassText.ClassExist = TRUE;\r
2254 UsbClassText.SubClassExist = TRUE;\r
2255\r
2256 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2257}\r
2258\r
572f5d8a 2259/**\r
2260 Converts a text device path node to USB audio device path structure.\r
2261\r
2262 @param TextDeviceNode The input Text device path node.\r
2263\r
2264 @return A pointer to the newly-created USB audio device path structure.\r
2265\r
2266**/\r
95276127 2267EFI_DEVICE_PATH_PROTOCOL *\r
2268DevPathFromTextUsbAudio (\r
2269 IN CHAR16 *TextDeviceNode\r
2270 )\r
2271{\r
2272 USB_CLASS_TEXT UsbClassText;\r
2273\r
2274 UsbClassText.ClassExist = FALSE;\r
2275 UsbClassText.Class = USB_CLASS_AUDIO;\r
2276 UsbClassText.SubClassExist = TRUE;\r
2277\r
2278 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2279}\r
2280\r
572f5d8a 2281/**\r
2282 Converts a text device path node to USB CDC Control device path structure.\r
2283\r
2284 @param TextDeviceNode The input Text device path node.\r
2285\r
2286 @return A pointer to the newly-created USB CDC Control device path structure.\r
2287\r
2288**/\r
95276127 2289EFI_DEVICE_PATH_PROTOCOL *\r
2290DevPathFromTextUsbCDCControl (\r
2291 IN CHAR16 *TextDeviceNode\r
2292 )\r
2293{\r
2294 USB_CLASS_TEXT UsbClassText;\r
2295\r
2296 UsbClassText.ClassExist = FALSE;\r
2297 UsbClassText.Class = USB_CLASS_CDCCONTROL;\r
2298 UsbClassText.SubClassExist = TRUE;\r
2299\r
2300 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2301}\r
2302\r
572f5d8a 2303/**\r
2304 Converts a text device path node to USB HID device path structure.\r
2305\r
2306 @param TextDeviceNode The input Text device path node.\r
2307\r
2308 @return A pointer to the newly-created USB HID device path structure.\r
2309\r
2310**/\r
95276127 2311EFI_DEVICE_PATH_PROTOCOL *\r
2312DevPathFromTextUsbHID (\r
2313 IN CHAR16 *TextDeviceNode\r
2314 )\r
2315{\r
2316 USB_CLASS_TEXT UsbClassText;\r
2317\r
2318 UsbClassText.ClassExist = FALSE;\r
2319 UsbClassText.Class = USB_CLASS_HID;\r
2320 UsbClassText.SubClassExist = TRUE;\r
2321\r
2322 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2323}\r
2324\r
572f5d8a 2325/**\r
2326 Converts a text device path node to USB Image device path structure.\r
2327\r
2328 @param TextDeviceNode The input Text device path node.\r
2329\r
2330 @return A pointer to the newly-created USB Image device path structure.\r
2331\r
2332**/\r
95276127 2333EFI_DEVICE_PATH_PROTOCOL *\r
2334DevPathFromTextUsbImage (\r
2335 IN CHAR16 *TextDeviceNode\r
2336 )\r
2337{\r
2338 USB_CLASS_TEXT UsbClassText;\r
2339\r
2340 UsbClassText.ClassExist = FALSE;\r
2341 UsbClassText.Class = USB_CLASS_IMAGE;\r
2342 UsbClassText.SubClassExist = TRUE;\r
2343\r
2344 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2345}\r
2346\r
572f5d8a 2347/**\r
2348 Converts a text device path node to USB Print device path structure.\r
2349\r
2350 @param TextDeviceNode The input Text device path node.\r
2351\r
2352 @return A pointer to the newly-created USB Print device path structure.\r
2353\r
2354**/\r
95276127 2355EFI_DEVICE_PATH_PROTOCOL *\r
2356DevPathFromTextUsbPrinter (\r
2357 IN CHAR16 *TextDeviceNode\r
2358 )\r
2359{\r
2360 USB_CLASS_TEXT UsbClassText;\r
2361\r
2362 UsbClassText.ClassExist = FALSE;\r
2363 UsbClassText.Class = USB_CLASS_PRINTER;\r
2364 UsbClassText.SubClassExist = TRUE;\r
2365\r
2366 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2367}\r
2368\r
572f5d8a 2369/**\r
2370 Converts a text device path node to USB mass storage device path structure.\r
2371\r
2372 @param TextDeviceNode The input Text device path node.\r
2373\r
2374 @return A pointer to the newly-created USB mass storage device path structure.\r
2375\r
2376**/\r
95276127 2377EFI_DEVICE_PATH_PROTOCOL *\r
2378DevPathFromTextUsbMassStorage (\r
2379 IN CHAR16 *TextDeviceNode\r
2380 )\r
2381{\r
2382 USB_CLASS_TEXT UsbClassText;\r
2383\r
2384 UsbClassText.ClassExist = FALSE;\r
2385 UsbClassText.Class = USB_CLASS_MASS_STORAGE;\r
2386 UsbClassText.SubClassExist = TRUE;\r
2387\r
2388 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2389}\r
2390\r
572f5d8a 2391/**\r
2392 Converts a text device path node to USB HUB device path structure.\r
2393\r
2394 @param TextDeviceNode The input Text device path node.\r
2395\r
2396 @return A pointer to the newly-created USB HUB device path structure.\r
2397\r
2398**/\r
95276127 2399EFI_DEVICE_PATH_PROTOCOL *\r
2400DevPathFromTextUsbHub (\r
2401 IN CHAR16 *TextDeviceNode\r
2402 )\r
2403{\r
2404 USB_CLASS_TEXT UsbClassText;\r
2405\r
2406 UsbClassText.ClassExist = FALSE;\r
2407 UsbClassText.Class = USB_CLASS_HUB;\r
2408 UsbClassText.SubClassExist = TRUE;\r
2409\r
2410 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2411}\r
2412\r
572f5d8a 2413/**\r
2414 Converts a text device path node to USB CDC data device path structure.\r
2415\r
2416 @param TextDeviceNode The input Text device path node.\r
2417\r
2418 @return A pointer to the newly-created USB CDC data device path structure.\r
2419\r
2420**/\r
95276127 2421EFI_DEVICE_PATH_PROTOCOL *\r
2422DevPathFromTextUsbCDCData (\r
2423 IN CHAR16 *TextDeviceNode\r
2424 )\r
2425{\r
2426 USB_CLASS_TEXT UsbClassText;\r
2427\r
2428 UsbClassText.ClassExist = FALSE;\r
2429 UsbClassText.Class = USB_CLASS_CDCDATA;\r
2430 UsbClassText.SubClassExist = TRUE;\r
2431\r
2432 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2433}\r
2434\r
572f5d8a 2435/**\r
2436 Converts a text device path node to USB smart card device path structure.\r
2437\r
2438 @param TextDeviceNode The input Text device path node.\r
2439\r
2440 @return A pointer to the newly-created USB smart card device path structure.\r
2441\r
2442**/\r
95276127 2443EFI_DEVICE_PATH_PROTOCOL *\r
2444DevPathFromTextUsbSmartCard (\r
2445 IN CHAR16 *TextDeviceNode\r
2446 )\r
2447{\r
2448 USB_CLASS_TEXT UsbClassText;\r
2449\r
2450 UsbClassText.ClassExist = FALSE;\r
2451 UsbClassText.Class = USB_CLASS_SMART_CARD;\r
2452 UsbClassText.SubClassExist = TRUE;\r
2453\r
2454 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2455}\r
2456\r
572f5d8a 2457/**\r
2458 Converts a text device path node to USB video device path structure.\r
2459\r
2460 @param TextDeviceNode The input Text device path node.\r
2461\r
2462 @return A pointer to the newly-created USB video device path structure.\r
2463\r
2464**/\r
95276127 2465EFI_DEVICE_PATH_PROTOCOL *\r
2466DevPathFromTextUsbVideo (\r
2467 IN CHAR16 *TextDeviceNode\r
2468 )\r
2469{\r
2470 USB_CLASS_TEXT UsbClassText;\r
2471\r
2472 UsbClassText.ClassExist = FALSE;\r
2473 UsbClassText.Class = USB_CLASS_VIDEO;\r
2474 UsbClassText.SubClassExist = TRUE;\r
2475\r
2476 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2477}\r
2478\r
572f5d8a 2479/**\r
2480 Converts a text device path node to USB diagnostic device path structure.\r
2481\r
2482 @param TextDeviceNode The input Text device path node.\r
2483\r
2484 @return A pointer to the newly-created USB diagnostic device path structure.\r
2485\r
2486**/\r
95276127 2487EFI_DEVICE_PATH_PROTOCOL *\r
2488DevPathFromTextUsbDiagnostic (\r
2489 IN CHAR16 *TextDeviceNode\r
2490 )\r
2491{\r
2492 USB_CLASS_TEXT UsbClassText;\r
2493\r
2494 UsbClassText.ClassExist = FALSE;\r
2495 UsbClassText.Class = USB_CLASS_DIAGNOSTIC;\r
2496 UsbClassText.SubClassExist = TRUE;\r
2497\r
2498 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2499}\r
2500\r
572f5d8a 2501/**\r
2502 Converts a text device path node to USB wireless device path structure.\r
2503\r
2504 @param TextDeviceNode The input Text device path node.\r
2505\r
2506 @return A pointer to the newly-created USB wireless device path structure.\r
2507\r
2508**/\r
95276127 2509EFI_DEVICE_PATH_PROTOCOL *\r
2510DevPathFromTextUsbWireless (\r
2511 IN CHAR16 *TextDeviceNode\r
2512 )\r
2513{\r
2514 USB_CLASS_TEXT UsbClassText;\r
2515\r
2516 UsbClassText.ClassExist = FALSE;\r
2517 UsbClassText.Class = USB_CLASS_WIRELESS;\r
2518 UsbClassText.SubClassExist = TRUE;\r
2519\r
2520 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2521}\r
2522\r
572f5d8a 2523/**\r
2524 Converts a text device path node to USB device firmware update device path structure.\r
2525\r
2526 @param TextDeviceNode The input Text device path node.\r
2527\r
2528 @return A pointer to the newly-created USB device firmware update device path structure.\r
2529\r
2530**/\r
95276127 2531EFI_DEVICE_PATH_PROTOCOL *\r
2532DevPathFromTextUsbDeviceFirmwareUpdate (\r
2533 IN CHAR16 *TextDeviceNode\r
2534 )\r
2535{\r
2536 USB_CLASS_TEXT UsbClassText;\r
2537\r
2538 UsbClassText.ClassExist = FALSE;\r
2539 UsbClassText.Class = USB_CLASS_RESERVE;\r
2540 UsbClassText.SubClassExist = FALSE;\r
2541 UsbClassText.SubClass = USB_SUBCLASS_FW_UPDATE;\r
2542\r
2543 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2544}\r
2545\r
572f5d8a 2546/**\r
2547 Converts a text device path node to USB IRDA bridge device path structure.\r
2548\r
2549 @param TextDeviceNode The input Text device path node.\r
2550\r
2551 @return A pointer to the newly-created USB IRDA bridge device path structure.\r
2552\r
2553**/\r
95276127 2554EFI_DEVICE_PATH_PROTOCOL *\r
2555DevPathFromTextUsbIrdaBridge (\r
2556 IN CHAR16 *TextDeviceNode\r
2557 )\r
2558{\r
2559 USB_CLASS_TEXT UsbClassText;\r
2560\r
2561 UsbClassText.ClassExist = FALSE;\r
2562 UsbClassText.Class = USB_CLASS_RESERVE;\r
2563 UsbClassText.SubClassExist = FALSE;\r
2564 UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE;\r
2565\r
2566 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2567}\r
2568\r
572f5d8a 2569/**\r
2570 Converts a text device path node to USB text and measurement device path structure.\r
2571\r
2572 @param TextDeviceNode The input Text device path node.\r
2573\r
2574 @return A pointer to the newly-created USB text and measurement device path structure.\r
2575\r
2576**/\r
95276127 2577EFI_DEVICE_PATH_PROTOCOL *\r
2578DevPathFromTextUsbTestAndMeasurement (\r
2579 IN CHAR16 *TextDeviceNode\r
2580 )\r
2581{\r
2582 USB_CLASS_TEXT UsbClassText;\r
2583\r
2584 UsbClassText.ClassExist = FALSE;\r
2585 UsbClassText.Class = USB_CLASS_RESERVE;\r
2586 UsbClassText.SubClassExist = FALSE;\r
2587 UsbClassText.SubClass = USB_SUBCLASS_TEST;\r
2588\r
2589 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2590}\r
2591\r
572f5d8a 2592/**\r
2593 Converts a text device path node to USB WWID device path structure.\r
2594\r
2595 @param TextDeviceNode The input Text device path node.\r
2596\r
2597 @return A pointer to the newly-created USB WWID device path structure.\r
2598\r
2599**/\r
95276127 2600EFI_DEVICE_PATH_PROTOCOL *\r
2601DevPathFromTextUsbWwid (\r
2602 IN CHAR16 *TextDeviceNode\r
2603 )\r
2604{\r
2605 CHAR16 *VIDStr;\r
2606 CHAR16 *PIDStr;\r
2607 CHAR16 *InterfaceNumStr;\r
cf40f28a 2608 CHAR16 *SerialNumberStr;\r
95276127 2609 USB_WWID_DEVICE_PATH *UsbWwid;\r
9da38884
RN
2610 UINTN SerialNumberStrLen;\r
2611\r
2612 VIDStr = GetNextParamStr (&TextDeviceNode);\r
2613 PIDStr = GetNextParamStr (&TextDeviceNode);\r
2614 InterfaceNumStr = GetNextParamStr (&TextDeviceNode);\r
2615 SerialNumberStr = GetNextParamStr (&TextDeviceNode);\r
2616 SerialNumberStrLen = StrLen (SerialNumberStr);\r
2617 if (SerialNumberStrLen >= 2 &&\r
2618 SerialNumberStr[0] == L'\"' &&\r
2619 SerialNumberStr[SerialNumberStrLen - 1] == L'\"'\r
2620 ) {\r
2621 SerialNumberStr[SerialNumberStrLen - 1] = L'\0';\r
2622 SerialNumberStr++;\r
2623 SerialNumberStrLen -= 2;\r
2624 }\r
2625 UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (\r
95276127 2626 MESSAGING_DEVICE_PATH,\r
2627 MSG_USB_WWID_DP,\r
9da38884 2628 (UINT16) (sizeof (USB_WWID_DEVICE_PATH) + SerialNumberStrLen * sizeof (CHAR16))\r
95276127 2629 );\r
9da38884
RN
2630 UsbWwid->VendorId = (UINT16) Strtoi (VIDStr);\r
2631 UsbWwid->ProductId = (UINT16) Strtoi (PIDStr);\r
2632 UsbWwid->InterfaceNumber = (UINT16) Strtoi (InterfaceNumStr);\r
750b4513
HW
2633\r
2634 //\r
2635 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.\r
2636 // Therefore, the '\0' will not be copied.\r
2637 //\r
2638 CopyMem (\r
2639 (UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH),\r
2640 SerialNumberStr,\r
2641 SerialNumberStrLen * sizeof (CHAR16)\r
2642 );\r
95276127 2643\r
2644 return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;\r
2645}\r
2646\r
572f5d8a 2647/**\r
2648 Converts a text device path node to Logic Unit device path structure.\r
2649\r
2650 @param TextDeviceNode The input Text device path node.\r
2651\r
2652 @return A pointer to the newly-created Logic Unit device path structure.\r
2653\r
2654**/\r
95276127 2655EFI_DEVICE_PATH_PROTOCOL *\r
2656DevPathFromTextUnit (\r
2657 IN CHAR16 *TextDeviceNode\r
2658 )\r
2659{\r
2660 CHAR16 *LunStr;\r
2661 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
2662\r
2663 LunStr = GetNextParamStr (&TextDeviceNode);\r
2664 LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (\r
2665 MESSAGING_DEVICE_PATH,\r
2666 MSG_DEVICE_LOGICAL_UNIT_DP,\r
cf40f28a 2667 (UINT16) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)\r
95276127 2668 );\r
2669\r
cf40f28a 2670 LogicalUnit->Lun = (UINT8) Strtoi (LunStr);\r
95276127 2671\r
2672 return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;\r
2673}\r
2674\r
572f5d8a 2675/**\r
2676 Converts a text device path node to iSCSI 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 iSCSI device path structure.\r
2681\r
2682**/\r
95276127 2683EFI_DEVICE_PATH_PROTOCOL *\r
2684DevPathFromTextiSCSI (\r
2685 IN CHAR16 *TextDeviceNode\r
2686 )\r
2687{\r
2688 UINT16 Options;\r
2689 CHAR16 *NameStr;\r
2690 CHAR16 *PortalGroupStr;\r
2691 CHAR16 *LunStr;\r
2692 CHAR16 *HeaderDigestStr;\r
2693 CHAR16 *DataDigestStr;\r
2694 CHAR16 *AuthenticationStr;\r
2695 CHAR16 *ProtocolStr;\r
cf40f28a 2696 CHAR8 *AsciiStr;\r
572f5d8a 2697 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
95276127 2698\r
2699 NameStr = GetNextParamStr (&TextDeviceNode);\r
2700 PortalGroupStr = GetNextParamStr (&TextDeviceNode);\r
2701 LunStr = GetNextParamStr (&TextDeviceNode);\r
2702 HeaderDigestStr = GetNextParamStr (&TextDeviceNode);\r
2703 DataDigestStr = GetNextParamStr (&TextDeviceNode);\r
2704 AuthenticationStr = GetNextParamStr (&TextDeviceNode);\r
2705 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
572f5d8a 2706 ISCSIDevPath = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (\r
95276127 2707 MESSAGING_DEVICE_PATH,\r
2708 MSG_ISCSI_DP,\r
047c6449 2709 (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))\r
95276127 2710 );\r
2711\r
184f7d83 2712 AsciiStr = ISCSIDevPath->TargetName;\r
cf40f28a 2713 StrToAscii (NameStr, &AsciiStr);\r
2714\r
572f5d8a 2715 ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);\r
2716 Strtoi64 (LunStr, &ISCSIDevPath->Lun);\r
95276127 2717\r
2718 Options = 0x0000;\r
2719 if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {\r
2720 Options |= 0x0002;\r
2721 }\r
2722\r
2723 if (StrCmp (DataDigestStr, L"CRC32C") == 0) {\r
2724 Options |= 0x0008;\r
2725 }\r
2726\r
2727 if (StrCmp (AuthenticationStr, L"None") == 0) {\r
2728 Options |= 0x0800;\r
2729 }\r
2730\r
2731 if (StrCmp (AuthenticationStr, L"CHAP_UNI") == 0) {\r
2732 Options |= 0x1000;\r
2733 }\r
2734\r
572f5d8a 2735 ISCSIDevPath->LoginOption = (UINT16) Options;\r
95276127 2736\r
572f5d8a 2737 ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP");\r
95276127 2738\r
572f5d8a 2739 return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;\r
95276127 2740}\r
2741\r
8f97f911 2742/**\r
2743 Converts a text device path node to VLAN device path structure.\r
2744\r
2745 @param TextDeviceNode The input Text device path node.\r
2746\r
2747 @return A pointer to the newly-created VLAN device path structure.\r
2748\r
2749**/\r
2750EFI_DEVICE_PATH_PROTOCOL *\r
2751DevPathFromTextVlan (\r
2752 IN CHAR16 *TextDeviceNode\r
2753 )\r
2754{\r
2755 CHAR16 *VlanStr;\r
2756 VLAN_DEVICE_PATH *Vlan;\r
2757\r
2758 VlanStr = GetNextParamStr (&TextDeviceNode);\r
2759 Vlan = (VLAN_DEVICE_PATH *) CreateDeviceNode (\r
2760 MESSAGING_DEVICE_PATH,\r
2761 MSG_VLAN_DP,\r
c9325700 2762 (UINT16) sizeof (VLAN_DEVICE_PATH)\r
8f97f911 2763 );\r
2764\r
2765 Vlan->VlanId = (UINT16) Strtoi (VlanStr);\r
2766\r
2767 return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;\r
2768}\r
2769\r
7795c8f9
QS
2770/**\r
2771 Converts a text device path node to Bluetooth 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 Bluetooth device path structure.\r
2776\r
2777**/\r
2778EFI_DEVICE_PATH_PROTOCOL *\r
2779DevPathFromTextBluetooth (\r
2780 IN CHAR16 *TextDeviceNode\r
2781 )\r
2782{\r
2783 CHAR16 *BluetoothStr;\r
2784 CHAR16 *Walker;\r
2785 CHAR16 *TempNumBuffer;\r
2786 UINTN TempBufferSize;\r
2787 INT32 Index;\r
2788 BLUETOOTH_DEVICE_PATH *BluetoothDp;\r
2789\r
2790 BluetoothStr = GetNextParamStr (&TextDeviceNode);\r
2791 BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (\r
2792 MESSAGING_DEVICE_PATH,\r
2793 MSG_BLUETOOTH_DP,\r
2794 (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)\r
2795 );\r
2796\r
2797 Index = sizeof (BLUETOOTH_ADDRESS) - 1;\r
6252f271
QS
2798 Walker = BluetoothStr;\r
2799 while (!IS_NULL(*Walker) && Index >= 0) {\r
2800 TempBufferSize = 2 * sizeof(CHAR16) + StrSize(L"0x");\r
7795c8f9
QS
2801 TempNumBuffer = AllocateZeroPool (TempBufferSize);\r
2802 if (TempNumBuffer == NULL) {\r
2803 break;\r
2804 }\r
750b4513 2805 StrCpyS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), L"0x");\r
6252f271 2806 StrnCatS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), Walker, 2);\r
7795c8f9
QS
2807 BluetoothDp->BD_ADDR.Address[Index] = (UINT8)Strtoi (TempNumBuffer);\r
2808 FreePool (TempNumBuffer);\r
6252f271 2809 Walker += 2;\r
7795c8f9
QS
2810 Index--;\r
2811 }\r
2812 \r
2813 return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothDp;\r
2814}\r
2815\r
3bafd562
HW
2816/**\r
2817 Converts a text device path node to Wi-Fi device path structure.\r
2818\r
2819 @param TextDeviceNode The input Text device path node.\r
2820\r
2821 @return A pointer to the newly-created Wi-Fi device path structure.\r
2822\r
2823**/\r
2824EFI_DEVICE_PATH_PROTOCOL *\r
2825DevPathFromTextWiFi (\r
2826 IN CHAR16 *TextDeviceNode\r
2827 )\r
2828{\r
2829 CHAR16 *SSIdStr;\r
2830 CHAR8 *AsciiStr;\r
2831 WIFI_DEVICE_PATH *WiFiDp;\r
2832\r
2833 SSIdStr = GetNextParamStr (&TextDeviceNode);\r
2834 WiFiDp = (WIFI_DEVICE_PATH *) CreateDeviceNode (\r
2835 MESSAGING_DEVICE_PATH,\r
2836 MSG_WIFI_DP,\r
2837 (UINT16) sizeof (WIFI_DEVICE_PATH)\r
2838 );\r
2839\r
1d13077b 2840 AsciiStr = (CHAR8 *) WiFiDp->SSId;\r
3bafd562
HW
2841 StrToAscii (SSIdStr, &AsciiStr);\r
2842\r
2843 return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp;\r
2844}\r
2845\r
c808ac7b
RN
2846/**\r
2847 Converts a text device path node to URI device path structure.\r
2848\r
2849 @param TextDeviceNode The input Text device path node.\r
2850\r
2851 @return A pointer to the newly-created URI device path structure.\r
2852\r
2853**/\r
2854EFI_DEVICE_PATH_PROTOCOL *\r
2855DevPathFromTextUri (\r
2856 IN CHAR16 *TextDeviceNode\r
2857 )\r
2858{\r
2859 CHAR16 *UriStr;\r
2860 UINTN UriLength;\r
2861 URI_DEVICE_PATH *Uri;\r
2862\r
2863 UriStr = GetNextParamStr (&TextDeviceNode);\r
2864 UriLength = StrnLenS (UriStr, MAX_UINT16 - sizeof (URI_DEVICE_PATH));\r
2865 Uri = (URI_DEVICE_PATH *) CreateDeviceNode (\r
2866 MESSAGING_DEVICE_PATH,\r
2867 MSG_URI_DP,\r
2868 (UINT16) (sizeof (URI_DEVICE_PATH) + UriLength)\r
2869 );\r
2870\r
2871 while (UriLength-- != 0) {\r
2872 Uri->Uri[UriLength] = (CHAR8) UriStr[UriLength];\r
2873 }\r
2874\r
2875 return (EFI_DEVICE_PATH_PROTOCOL *) Uri;\r
2876}\r
2877\r
5d6a5aee
RN
2878/**\r
2879 Converts a media text device path node to media device path structure.\r
2880\r
2881 @param TextDeviceNode The input Text device path node.\r
2882\r
2883 @return A pointer to media device path structure.\r
2884\r
2885**/\r
2886EFI_DEVICE_PATH_PROTOCOL *\r
2887DevPathFromTextMediaPath (\r
2888 IN CHAR16 *TextDeviceNode\r
2889 )\r
2890{\r
2891 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH, TextDeviceNode);\r
2892}\r
2893\r
572f5d8a 2894/**\r
2895 Converts a text device path node to HD device path structure.\r
2896\r
2897 @param TextDeviceNode The input Text device path node.\r
2898\r
2899 @return A pointer to the newly-created HD device path structure.\r
2900\r
2901**/\r
95276127 2902EFI_DEVICE_PATH_PROTOCOL *\r
2903DevPathFromTextHD (\r
2904 IN CHAR16 *TextDeviceNode\r
2905 )\r
2906{\r
2907 CHAR16 *PartitionStr;\r
2908 CHAR16 *TypeStr;\r
2909 CHAR16 *SignatureStr;\r
2910 CHAR16 *StartStr;\r
2911 CHAR16 *SizeStr;\r
2912 UINT32 Signature32;\r
2913 EFI_GUID SignatureGuid;\r
2914 HARDDRIVE_DEVICE_PATH *Hd;\r
2915\r
2916 PartitionStr = GetNextParamStr (&TextDeviceNode);\r
2917 TypeStr = GetNextParamStr (&TextDeviceNode);\r
2918 SignatureStr = GetNextParamStr (&TextDeviceNode);\r
2919 StartStr = GetNextParamStr (&TextDeviceNode);\r
2920 SizeStr = GetNextParamStr (&TextDeviceNode);\r
2921 Hd = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (\r
2922 MEDIA_DEVICE_PATH,\r
2923 MEDIA_HARDDRIVE_DP,\r
c9325700 2924 (UINT16) sizeof (HARDDRIVE_DEVICE_PATH)\r
95276127 2925 );\r
2926\r
9da38884 2927 Hd->PartitionNumber = (UINT32) Strtoi (PartitionStr);\r
95276127 2928\r
2929 ZeroMem (Hd->Signature, 16);\r
2930 Hd->MBRType = (UINT8) 0;\r
2931\r