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