If DataSize or VariableNameSize is near MAX_ADDRESS, this can cause the computed...
[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
bd07919c 4Copyright (c) 2006 - 2012, 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
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
e9b3cd55
RN
973/**\r
974 Converts a text device path node to PCIE root 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 PCIE root device path structure.\r
979\r
980**/\r
981EFI_DEVICE_PATH_PROTOCOL *\r
982DevPathFromTextPcieRoot (\r
983 IN CHAR16 *TextDeviceNode\r
984 )\r
985{\r
986 return ConvertFromTextAcpi (TextDeviceNode, 0x0a08);\r
987}\r
988\r
572f5d8a 989/**\r
990 Converts a text device path node to Floppy 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 Floppy device path structure.\r
995\r
996**/\r
95276127 997EFI_DEVICE_PATH_PROTOCOL *\r
998DevPathFromTextFloppy (\r
999 IN CHAR16 *TextDeviceNode\r
1000 )\r
1001{\r
cf40f28a 1002 return ConvertFromTextAcpi (TextDeviceNode, 0x0604);\r
95276127 1003}\r
1004\r
572f5d8a 1005/**\r
1006 Converts a text device path node to Keyboard 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 Keyboard device path structure.\r
1011\r
1012**/\r
95276127 1013EFI_DEVICE_PATH_PROTOCOL *\r
1014DevPathFromTextKeyboard (\r
1015 IN CHAR16 *TextDeviceNode\r
1016 )\r
1017{\r
cf40f28a 1018 return ConvertFromTextAcpi (TextDeviceNode, 0x0301);\r
95276127 1019}\r
1020\r
572f5d8a 1021/**\r
1022 Converts a text device path node to Serial 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 Serial device path structure.\r
1027\r
1028**/\r
95276127 1029EFI_DEVICE_PATH_PROTOCOL *\r
1030DevPathFromTextSerial (\r
1031 IN CHAR16 *TextDeviceNode\r
1032 )\r
1033{\r
cf40f28a 1034 return ConvertFromTextAcpi (TextDeviceNode, 0x0501);\r
95276127 1035}\r
1036\r
572f5d8a 1037/**\r
1038 Converts a text device path node to Parallel Port device path structure.\r
1039\r
1040 @param TextDeviceNode The input Text device path node.\r
1041\r
1042 @return A pointer to the newly-created Parallel Port device path structure.\r
1043\r
1044**/\r
95276127 1045EFI_DEVICE_PATH_PROTOCOL *\r
1046DevPathFromTextParallelPort (\r
1047 IN CHAR16 *TextDeviceNode\r
1048 )\r
1049{\r
cf40f28a 1050 return ConvertFromTextAcpi (TextDeviceNode, 0x0401);\r
95276127 1051}\r
1052\r
572f5d8a 1053/**\r
5755841f 1054 Converts a text device path node to ACPI extension device path structure.\r
572f5d8a 1055\r
1056 @param TextDeviceNode The input Text device path node.\r
1057\r
5755841f 1058 @return A pointer to the newly-created ACPI extension device path structure.\r
572f5d8a 1059\r
1060**/\r
95276127 1061EFI_DEVICE_PATH_PROTOCOL *\r
1062DevPathFromTextAcpiEx (\r
1063 IN CHAR16 *TextDeviceNode\r
1064 )\r
1065{\r
cf40f28a 1066 CHAR16 *HIDStr;\r
1067 CHAR16 *CIDStr;\r
1068 CHAR16 *UIDStr;\r
1069 CHAR16 *HIDSTRStr;\r
1070 CHAR16 *CIDSTRStr;\r
1071 CHAR16 *UIDSTRStr;\r
1072 CHAR8 *AsciiStr;\r
1073 UINT16 Length;\r
1074 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r
95276127 1075\r
1076 HIDStr = GetNextParamStr (&TextDeviceNode);\r
1077 CIDStr = GetNextParamStr (&TextDeviceNode);\r
1078 UIDStr = GetNextParamStr (&TextDeviceNode);\r
1079 HIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
1080 CIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
1081 UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
1082\r
1083 Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (HIDSTRStr) + 1);\r
1084 Length = (UINT16) (Length + StrLen (UIDSTRStr) + 1);\r
1085 Length = (UINT16) (Length + StrLen (CIDSTRStr) + 1);\r
cf40f28a 1086 AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r
1087 ACPI_DEVICE_PATH,\r
1088 ACPI_EXTENDED_DP,\r
1089 Length\r
1090 );\r
95276127 1091\r
cf40f28a 1092 EisaIdFromText (HIDStr, &AcpiEx->HID);\r
1093 EisaIdFromText (CIDStr, &AcpiEx->CID);\r
1094 AcpiEx->UID = (UINT32) Strtoi (UIDStr);\r
95276127 1095\r
cf40f28a 1096 AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
95276127 1097 StrToAscii (HIDSTRStr, &AsciiStr);\r
1098 StrToAscii (UIDSTRStr, &AsciiStr);\r
1099 StrToAscii (CIDSTRStr, &AsciiStr);\r
cf40f28a 1100\r
1101 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r
95276127 1102}\r
1103\r
572f5d8a 1104/**\r
5755841f 1105 Converts a text device path node to ACPI extension device path structure.\r
572f5d8a 1106\r
1107 @param TextDeviceNode The input Text device path node.\r
1108\r
5755841f 1109 @return A pointer to the newly-created ACPI extension device path structure.\r
572f5d8a 1110\r
1111**/\r
95276127 1112EFI_DEVICE_PATH_PROTOCOL *\r
1113DevPathFromTextAcpiExp (\r
1114 IN CHAR16 *TextDeviceNode\r
1115 )\r
1116{\r
cf40f28a 1117 CHAR16 *HIDStr;\r
1118 CHAR16 *CIDStr;\r
1119 CHAR16 *UIDSTRStr;\r
1120 CHAR8 *AsciiStr;\r
1121 UINT16 Length;\r
1122 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r
95276127 1123\r
1124 HIDStr = GetNextParamStr (&TextDeviceNode);\r
1125 CIDStr = GetNextParamStr (&TextDeviceNode);\r
1126 UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
d074a8e1 1127 Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (UIDSTRStr) + 3);\r
cf40f28a 1128 AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r
1129 ACPI_DEVICE_PATH,\r
1130 ACPI_EXTENDED_DP,\r
1131 Length\r
1132 );\r
95276127 1133\r
cf40f28a 1134 EisaIdFromText (HIDStr, &AcpiEx->HID);\r
1135 EisaIdFromText (CIDStr, &AcpiEx->CID);\r
1136 AcpiEx->UID = 0;\r
95276127 1137\r
cf40f28a 1138 AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
95276127 1139 //\r
1140 // HID string is NULL\r
1141 //\r
cf40f28a 1142 *AsciiStr = '\0';\r
95276127 1143 //\r
1144 // Convert UID string\r
1145 //\r
1146 AsciiStr++;\r
1147 StrToAscii (UIDSTRStr, &AsciiStr);\r
1148 //\r
1149 // CID string is NULL\r
1150 //\r
cf40f28a 1151 *AsciiStr = '\0';\r
95276127 1152\r
cf40f28a 1153 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r
95276127 1154}\r
1155\r
5b84091f
RN
1156/**\r
1157 Converts a text device path node to ACPI _ADR device path structure.\r
1158\r
1159 @param TextDeviceNode The input Text device path node.\r
1160\r
1161 @return A pointer to the newly-created ACPI _ADR device path structure.\r
1162\r
1163**/\r
1164EFI_DEVICE_PATH_PROTOCOL *\r
1165DevPathFromTextAcpiAdr (\r
1166 IN CHAR16 *TextDeviceNode\r
1167 )\r
1168{\r
1169 CHAR16 *DisplayDeviceStr;\r
1170 ACPI_ADR_DEVICE_PATH *AcpiAdr;\r
1171 UINTN Index;\r
b36653bc 1172 UINTN Length;\r
5b84091f
RN
1173\r
1174 AcpiAdr = (ACPI_ADR_DEVICE_PATH *) CreateDeviceNode (\r
1175 ACPI_DEVICE_PATH,\r
1176 ACPI_ADR_DP,\r
e7cc9dcc 1177 (UINT16) sizeof (ACPI_ADR_DEVICE_PATH)\r
5b84091f
RN
1178 );\r
1179 ASSERT (AcpiAdr != NULL);\r
1180\r
1181 for (Index = 0; ; Index++) {\r
1182 DisplayDeviceStr = GetNextParamStr (&TextDeviceNode);\r
1183 if (IS_NULL (*DisplayDeviceStr)) {\r
1184 break;\r
1185 }\r
1186 if (Index > 0) {\r
b36653bc 1187 Length = DevicePathNodeLength (AcpiAdr);\r
5b84091f 1188 AcpiAdr = ReallocatePool (\r
b36653bc
RN
1189 Length,\r
1190 Length + sizeof (UINT32),\r
5b84091f
RN
1191 AcpiAdr\r
1192 );\r
1193 ASSERT (AcpiAdr != NULL);\r
b36653bc 1194 SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));\r
5b84091f
RN
1195 }\r
1196 \r
1197 (&AcpiAdr->ADR)[Index] = (UINT32) Strtoi (DisplayDeviceStr);\r
1198 }\r
1199\r
1200 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr;\r
1201}\r
1202\r
572f5d8a 1203/**\r
1204 Converts a text device path node to Parallel Port device path structure.\r
1205\r
1206 @param TextDeviceNode The input Text device path node.\r
1207\r
1208 @return A pointer to the newly-created Parallel Port device path structure.\r
1209\r
1210**/\r
95276127 1211EFI_DEVICE_PATH_PROTOCOL *\r
1212DevPathFromTextAta (\r
1213 IN CHAR16 *TextDeviceNode\r
1214 )\r
1215{\r
1216 CHAR16 *PrimarySecondaryStr;\r
1217 CHAR16 *SlaveMasterStr;\r
1218 CHAR16 *LunStr;\r
1219 ATAPI_DEVICE_PATH *Atapi;\r
1220\r
1221 Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (\r
1222 MESSAGING_DEVICE_PATH,\r
1223 MSG_ATAPI_DP,\r
c9325700 1224 (UINT16) sizeof (ATAPI_DEVICE_PATH)\r
95276127 1225 );\r
1226\r
1227 PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);\r
1228 SlaveMasterStr = GetNextParamStr (&TextDeviceNode);\r
1229 LunStr = GetNextParamStr (&TextDeviceNode);\r
1230\r
1231 Atapi->PrimarySecondary = (UINT8) ((StrCmp (PrimarySecondaryStr, L"Primary") == 0) ? 0 : 1);\r
1232 Atapi->SlaveMaster = (UINT8) ((StrCmp (SlaveMasterStr, L"Master") == 0) ? 0 : 1);\r
cf40f28a 1233 Atapi->Lun = (UINT16) Strtoi (LunStr);\r
95276127 1234\r
1235 return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;\r
1236}\r
1237\r
572f5d8a 1238/**\r
1239 Converts a text device path node to SCSI 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 SCSI device path structure.\r
1244\r
1245**/\r
95276127 1246EFI_DEVICE_PATH_PROTOCOL *\r
1247DevPathFromTextScsi (\r
1248 IN CHAR16 *TextDeviceNode\r
1249 )\r
1250{\r
1251 CHAR16 *PunStr;\r
1252 CHAR16 *LunStr;\r
1253 SCSI_DEVICE_PATH *Scsi;\r
1254\r
1255 PunStr = GetNextParamStr (&TextDeviceNode);\r
1256 LunStr = GetNextParamStr (&TextDeviceNode);\r
1257 Scsi = (SCSI_DEVICE_PATH *) CreateDeviceNode (\r
1258 MESSAGING_DEVICE_PATH,\r
1259 MSG_SCSI_DP,\r
c9325700 1260 (UINT16) sizeof (SCSI_DEVICE_PATH)\r
95276127 1261 );\r
1262\r
cf40f28a 1263 Scsi->Pun = (UINT16) Strtoi (PunStr);\r
1264 Scsi->Lun = (UINT16) Strtoi (LunStr);\r
95276127 1265\r
1266 return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;\r
1267}\r
1268\r
572f5d8a 1269/**\r
1270 Converts a text device path node to Fibre device path structure.\r
1271\r
1272 @param TextDeviceNode The input Text device path node.\r
1273\r
1274 @return A pointer to the newly-created Fibre device path structure.\r
1275\r
1276**/\r
95276127 1277EFI_DEVICE_PATH_PROTOCOL *\r
1278DevPathFromTextFibre (\r
1279 IN CHAR16 *TextDeviceNode\r
1280 )\r
1281{\r
1282 CHAR16 *WWNStr;\r
1283 CHAR16 *LunStr;\r
1284 FIBRECHANNEL_DEVICE_PATH *Fibre;\r
1285\r
1286 WWNStr = GetNextParamStr (&TextDeviceNode);\r
1287 LunStr = GetNextParamStr (&TextDeviceNode);\r
1288 Fibre = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (\r
1289 MESSAGING_DEVICE_PATH,\r
1290 MSG_FIBRECHANNEL_DP,\r
c9325700 1291 (UINT16) sizeof (FIBRECHANNEL_DEVICE_PATH)\r
95276127 1292 );\r
1293\r
1294 Fibre->Reserved = 0;\r
cf40f28a 1295 Strtoi64 (WWNStr, &Fibre->WWN);\r
1296 Strtoi64 (LunStr, &Fibre->Lun);\r
95276127 1297\r
1298 return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;\r
1299}\r
1300\r
e9b3cd55
RN
1301/**\r
1302 Converts a text device path node to FibreEx device path structure.\r
1303\r
1304 @param TextDeviceNode The input Text device path node.\r
1305\r
1306 @return A pointer to the newly-created FibreEx device path structure.\r
1307\r
1308**/\r
1309EFI_DEVICE_PATH_PROTOCOL *\r
1310DevPathFromTextFibreEx (\r
1311 IN CHAR16 *TextDeviceNode\r
1312 )\r
1313{\r
1314 CHAR16 *WWNStr;\r
1315 CHAR16 *LunStr;\r
1316 FIBRECHANNELEX_DEVICE_PATH *FibreEx;\r
1317\r
1318 WWNStr = GetNextParamStr (&TextDeviceNode);\r
1319 LunStr = GetNextParamStr (&TextDeviceNode);\r
1320 FibreEx = (FIBRECHANNELEX_DEVICE_PATH *) CreateDeviceNode (\r
1321 MESSAGING_DEVICE_PATH,\r
1322 MSG_FIBRECHANNELEX_DP,\r
1323 (UINT16) sizeof (FIBRECHANNELEX_DEVICE_PATH)\r
1324 );\r
1325\r
1326 FibreEx->Reserved = 0;\r
1327 Strtoi64 (WWNStr, (UINT64 *) (&FibreEx->WWN));\r
1328 Strtoi64 (LunStr, (UINT64 *) (&FibreEx->Lun));\r
1329\r
1330 *(UINT64 *) (&FibreEx->WWN) = SwapBytes64 (*(UINT64 *) (&FibreEx->WWN));\r
1331 *(UINT64 *) (&FibreEx->Lun) = SwapBytes64 (*(UINT64 *) (&FibreEx->Lun));\r
1332\r
1333 return (EFI_DEVICE_PATH_PROTOCOL *) FibreEx;\r
1334}\r
1335\r
572f5d8a 1336/**\r
1337 Converts a text device path node to 1394 device path structure.\r
1338\r
1339 @param TextDeviceNode The input Text device path node.\r
1340\r
1341 @return A pointer to the newly-created 1394 device path structure.\r
1342\r
1343**/\r
95276127 1344EFI_DEVICE_PATH_PROTOCOL *\r
1345DevPathFromText1394 (\r
1346 IN CHAR16 *TextDeviceNode\r
1347 )\r
1348{\r
1349 CHAR16 *GuidStr;\r
572f5d8a 1350 F1394_DEVICE_PATH *F1394DevPath;\r
95276127 1351\r
1352 GuidStr = GetNextParamStr (&TextDeviceNode);\r
572f5d8a 1353 F1394DevPath = (F1394_DEVICE_PATH *) CreateDeviceNode (\r
1354 MESSAGING_DEVICE_PATH,\r
1355 MSG_1394_DP,\r
c9325700 1356 (UINT16) sizeof (F1394_DEVICE_PATH)\r
572f5d8a 1357 );\r
95276127 1358\r
572f5d8a 1359 F1394DevPath->Reserved = 0;\r
1360 Xtoi64 (GuidStr, &F1394DevPath->Guid);\r
95276127 1361\r
572f5d8a 1362 return (EFI_DEVICE_PATH_PROTOCOL *) F1394DevPath;\r
95276127 1363}\r
1364\r
572f5d8a 1365/**\r
1366 Converts a text device path node to USB device path structure.\r
1367\r
1368 @param TextDeviceNode The input Text device path node.\r
1369\r
1370 @return A pointer to the newly-created USB device path structure.\r
1371\r
1372**/\r
95276127 1373EFI_DEVICE_PATH_PROTOCOL *\r
1374DevPathFromTextUsb (\r
1375 IN CHAR16 *TextDeviceNode\r
1376 )\r
1377{\r
1378 CHAR16 *PortStr;\r
1379 CHAR16 *InterfaceStr;\r
1380 USB_DEVICE_PATH *Usb;\r
1381\r
1382 PortStr = GetNextParamStr (&TextDeviceNode);\r
1383 InterfaceStr = GetNextParamStr (&TextDeviceNode);\r
1384 Usb = (USB_DEVICE_PATH *) CreateDeviceNode (\r
1385 MESSAGING_DEVICE_PATH,\r
1386 MSG_USB_DP,\r
c9325700 1387 (UINT16) sizeof (USB_DEVICE_PATH)\r
95276127 1388 );\r
1389\r
cf40f28a 1390 Usb->ParentPortNumber = (UINT8) Strtoi (PortStr);\r
1391 Usb->InterfaceNumber = (UINT8) Strtoi (InterfaceStr);\r
95276127 1392\r
1393 return (EFI_DEVICE_PATH_PROTOCOL *) Usb;\r
1394}\r
1395\r
572f5d8a 1396/**\r
1397 Converts a text device path node to I20 device path structure.\r
1398\r
1399 @param TextDeviceNode The input Text device path node.\r
1400\r
1401 @return A pointer to the newly-created I20 device path structure.\r
1402\r
1403**/\r
95276127 1404EFI_DEVICE_PATH_PROTOCOL *\r
1405DevPathFromTextI2O (\r
1406 IN CHAR16 *TextDeviceNode\r
1407 )\r
1408{\r
1409 CHAR16 *TIDStr;\r
572f5d8a 1410 I2O_DEVICE_PATH *I2ODevPath;\r
95276127 1411\r
572f5d8a 1412 TIDStr = GetNextParamStr (&TextDeviceNode);\r
1413 I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode (\r
95276127 1414 MESSAGING_DEVICE_PATH,\r
1415 MSG_I2O_DP,\r
c9325700 1416 (UINT16) sizeof (I2O_DEVICE_PATH)\r
95276127 1417 );\r
1418\r
572f5d8a 1419 I2ODevPath->Tid = (UINT32) Strtoi (TIDStr);\r
95276127 1420\r
572f5d8a 1421 return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath;\r
95276127 1422}\r
1423\r
572f5d8a 1424/**\r
1425 Converts a text device path node to Infini Band device path structure.\r
1426\r
1427 @param TextDeviceNode The input Text device path node.\r
1428\r
1429 @return A pointer to the newly-created Infini Band device path structure.\r
1430\r
1431**/\r
95276127 1432EFI_DEVICE_PATH_PROTOCOL *\r
1433DevPathFromTextInfiniband (\r
1434 IN CHAR16 *TextDeviceNode\r
1435 )\r
1436{\r
1437 CHAR16 *FlagsStr;\r
1438 CHAR16 *GuidStr;\r
1439 CHAR16 *SidStr;\r
1440 CHAR16 *TidStr;\r
1441 CHAR16 *DidStr;\r
1442 EFI_GUID PortGid;\r
1443 INFINIBAND_DEVICE_PATH *InfiniBand;\r
1444\r
1445 FlagsStr = GetNextParamStr (&TextDeviceNode);\r
1446 GuidStr = GetNextParamStr (&TextDeviceNode);\r
1447 SidStr = GetNextParamStr (&TextDeviceNode);\r
1448 TidStr = GetNextParamStr (&TextDeviceNode);\r
1449 DidStr = GetNextParamStr (&TextDeviceNode);\r
1450 InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (\r
1451 MESSAGING_DEVICE_PATH,\r
1452 MSG_INFINIBAND_DP,\r
c9325700 1453 (UINT16) sizeof (INFINIBAND_DEVICE_PATH)\r
95276127 1454 );\r
1455\r
cf40f28a 1456 InfiniBand->ResourceFlags = (UINT32) Strtoi (FlagsStr);\r
95276127 1457 StrToGuid (GuidStr, &PortGid);\r
1458 CopyMem (InfiniBand->PortGid, &PortGid, sizeof (EFI_GUID));\r
cf40f28a 1459 Strtoi64 (SidStr, &InfiniBand->ServiceId);\r
1460 Strtoi64 (TidStr, &InfiniBand->TargetPortId);\r
1461 Strtoi64 (DidStr, &InfiniBand->DeviceId);\r
95276127 1462\r
1463 return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;\r
1464}\r
1465\r
572f5d8a 1466/**\r
1467 Converts a text device path node to Vendor-Defined Messaging device path structure.\r
1468\r
1469 @param TextDeviceNode The input Text device path node.\r
1470\r
1471 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.\r
1472\r
1473**/\r
95276127 1474EFI_DEVICE_PATH_PROTOCOL *\r
1475DevPathFromTextVenMsg (\r
1476 IN CHAR16 *TextDeviceNode\r
1477 )\r
1478{\r
1479 return ConvertFromTextVendor (\r
1480 TextDeviceNode,\r
1481 MESSAGING_DEVICE_PATH,\r
1482 MSG_VENDOR_DP\r
1483 );\r
1484}\r
1485\r
572f5d8a 1486/**\r
1487 Converts a text device path node to Vendor defined PC-ANSI device path structure.\r
1488\r
1489 @param TextDeviceNode The input Text device path node.\r
1490\r
1491 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.\r
1492\r
1493**/\r
95276127 1494EFI_DEVICE_PATH_PROTOCOL *\r
1495DevPathFromTextVenPcAnsi (\r
1496 IN CHAR16 *TextDeviceNode\r
1497 )\r
1498{\r
1499 VENDOR_DEVICE_PATH *Vendor;\r
1500\r
1501 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1502 MESSAGING_DEVICE_PATH,\r
1503 MSG_VENDOR_DP,\r
c9325700 1504 (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
95276127 1505 CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);\r
1506\r
1507 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
1508}\r
1509\r
572f5d8a 1510/**\r
1511 Converts a text device path node to Vendor defined VT100 device path structure.\r
1512\r
1513 @param TextDeviceNode The input Text device path node.\r
1514\r
1515 @return A pointer to the newly-created Vendor defined VT100 device path structure.\r
1516\r
1517**/\r
95276127 1518EFI_DEVICE_PATH_PROTOCOL *\r
1519DevPathFromTextVenVt100 (\r
1520 IN CHAR16 *TextDeviceNode\r
1521 )\r
1522{\r
1523 VENDOR_DEVICE_PATH *Vendor;\r
1524\r
1525 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1526 MESSAGING_DEVICE_PATH,\r
1527 MSG_VENDOR_DP,\r
c9325700 1528 (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
95276127 1529 CopyGuid (&Vendor->Guid, &gEfiVT100Guid);\r
1530\r
1531 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
1532}\r
1533\r
572f5d8a 1534/**\r
1535 Converts a text device path node to Vendor defined VT100 Plus device path structure.\r
1536\r
1537 @param TextDeviceNode The input Text device path node.\r
1538\r
1539 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.\r
1540\r
1541**/\r
95276127 1542EFI_DEVICE_PATH_PROTOCOL *\r
1543DevPathFromTextVenVt100Plus (\r
1544 IN CHAR16 *TextDeviceNode\r
1545 )\r
1546{\r
1547 VENDOR_DEVICE_PATH *Vendor;\r
1548\r
1549 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1550 MESSAGING_DEVICE_PATH,\r
1551 MSG_VENDOR_DP,\r
c9325700 1552 (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
95276127 1553 CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);\r
1554\r
1555 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
1556}\r
1557\r
572f5d8a 1558/**\r
1559 Converts a text device path node to Vendor defined UTF8 device path structure.\r
1560\r
1561 @param TextDeviceNode The input Text device path node.\r
1562\r
1563 @return A pointer to the newly-created Vendor defined UTF8 device path structure.\r
1564\r
1565**/\r
95276127 1566EFI_DEVICE_PATH_PROTOCOL *\r
1567DevPathFromTextVenUtf8 (\r
1568 IN CHAR16 *TextDeviceNode\r
1569 )\r
1570{\r
1571 VENDOR_DEVICE_PATH *Vendor;\r
1572\r
1573 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1574 MESSAGING_DEVICE_PATH,\r
1575 MSG_VENDOR_DP,\r
c9325700 1576 (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
95276127 1577 CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);\r
1578\r
1579 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
1580}\r
1581\r
572f5d8a 1582/**\r
1583 Converts a text device path node to UART Flow Control device path structure.\r
1584\r
1585 @param TextDeviceNode The input Text device path node.\r
1586\r
1587 @return A pointer to the newly-created UART Flow Control device path structure.\r
1588\r
1589**/\r
95276127 1590EFI_DEVICE_PATH_PROTOCOL *\r
1591DevPathFromTextUartFlowCtrl (\r
1592 IN CHAR16 *TextDeviceNode\r
1593 )\r
1594{\r
1595 CHAR16 *ValueStr;\r
1596 UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;\r
1597\r
1598 ValueStr = GetNextParamStr (&TextDeviceNode);\r
1599 UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (\r
1600 MESSAGING_DEVICE_PATH,\r
1601 MSG_VENDOR_DP,\r
c9325700 1602 (UINT16) sizeof (UART_FLOW_CONTROL_DEVICE_PATH)\r
95276127 1603 );\r
1604\r
48557c65 1605 CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);\r
95276127 1606 if (StrCmp (ValueStr, L"XonXoff") == 0) {\r
1607 UartFlowControl->FlowControlMap = 2;\r
1608 } else if (StrCmp (ValueStr, L"Hardware") == 0) {\r
1609 UartFlowControl->FlowControlMap = 1;\r
1610 } else {\r
1611 UartFlowControl->FlowControlMap = 0;\r
1612 }\r
1613\r
1614 return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;\r
1615}\r
1616\r
572f5d8a 1617/**\r
1618 Converts a text device path node to Serial Attached SCSI device path structure.\r
1619\r
1620 @param TextDeviceNode The input Text device path node.\r
1621\r
1622 @return A pointer to the newly-created Serial Attached SCSI device path structure.\r
1623\r
1624**/\r
95276127 1625EFI_DEVICE_PATH_PROTOCOL *\r
1626DevPathFromTextSAS (\r
1627 IN CHAR16 *TextDeviceNode\r
1628 )\r
1629{\r
1630 CHAR16 *AddressStr;\r
1631 CHAR16 *LunStr;\r
1632 CHAR16 *RTPStr;\r
1633 CHAR16 *SASSATAStr;\r
1634 CHAR16 *LocationStr;\r
1635 CHAR16 *ConnectStr;\r
1636 CHAR16 *DriveBayStr;\r
1637 CHAR16 *ReservedStr;\r
1638 UINT16 Info;\r
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
1649 Info = 0x0000;\r
1650 Sas = (SAS_DEVICE_PATH *) CreateDeviceNode (\r
1651 MESSAGING_DEVICE_PATH,\r
1652 MSG_VENDOR_DP,\r
c9325700 1653 (UINT16) sizeof (SAS_DEVICE_PATH)\r
95276127 1654 );\r
1655\r
48557c65 1656 CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid);\r
cf40f28a 1657 Strtoi64 (AddressStr, &Sas->SasAddress);\r
1658 Strtoi64 (LunStr, &Sas->Lun);\r
1659 Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr);\r
1660 if (StrCmp (SASSATAStr, L"NoTopology") != 0) {\r
95276127 1661 if (StrCmp (DriveBayStr, L"0") == 0) {\r
1662 Info |= 0x0001;\r
1663 } else {\r
1664 Info |= 0x0002;\r
cf40f28a 1665 Info = (UINT16) (Info | (Strtoi (DriveBayStr) << 8));\r
95276127 1666 }\r
1667\r
1668 if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
1669 Info |= 0x0010;\r
1670 }\r
1671\r
1672 if (StrCmp (LocationStr, L"External") == 0) {\r
1673 Info |= 0x0020;\r
1674 }\r
1675\r
1676 if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
1677 Info |= 0x0040;\r
1678 }\r
1679 }\r
1680\r
1681 Sas->DeviceTopology = Info;\r
cf40f28a 1682 Sas->Reserved = (UINT32) Strtoi (ReservedStr);\r
95276127 1683\r
1684 return (EFI_DEVICE_PATH_PROTOCOL *) Sas;\r
1685}\r
1686\r
501793fa
RN
1687/**\r
1688 Converts a text device path node to Serial Attached SCSI Ex device path structure.\r
1689\r
1690 @param TextDeviceNode The input Text device path node.\r
1691\r
1692 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.\r
1693\r
1694**/\r
1695EFI_DEVICE_PATH_PROTOCOL *\r
1696DevPathFromTextSasEx (\r
1697 IN CHAR16 *TextDeviceNode\r
1698 )\r
1699{\r
1700 CHAR16 *AddressStr;\r
1701 CHAR16 *LunStr;\r
1702 CHAR16 *RTPStr;\r
1703 CHAR16 *SASSATAStr;\r
1704 CHAR16 *LocationStr;\r
1705 CHAR16 *ConnectStr;\r
1706 CHAR16 *DriveBayStr;\r
1707 UINT16 Info;\r
1708 SASEX_DEVICE_PATH *SasEx;\r
1709\r
1710 AddressStr = GetNextParamStr (&TextDeviceNode);\r
1711 LunStr = GetNextParamStr (&TextDeviceNode);\r
1712 RTPStr = GetNextParamStr (&TextDeviceNode);\r
1713 SASSATAStr = GetNextParamStr (&TextDeviceNode);\r
1714 LocationStr = GetNextParamStr (&TextDeviceNode);\r
1715 ConnectStr = GetNextParamStr (&TextDeviceNode);\r
1716 DriveBayStr = GetNextParamStr (&TextDeviceNode);\r
1717 Info = 0x0000;\r
1718 SasEx = (SASEX_DEVICE_PATH *) CreateDeviceNode (\r
1719 MESSAGING_DEVICE_PATH,\r
1720 MSG_SASEX_DP,\r
1721 (UINT16) sizeof (SASEX_DEVICE_PATH)\r
1722 );\r
1723\r
1724 Strtoi64 (AddressStr, (UINT64 *) &SasEx->SasAddress);\r
1725 Strtoi64 (LunStr, (UINT64 *) &SasEx->Lun);\r
1726 *(UINT64 *) &SasEx->SasAddress = SwapBytes64 (*(UINT64 *) &SasEx->SasAddress);\r
1727 *(UINT64 *) &SasEx->Lun = SwapBytes64 (*(UINT64 *) &SasEx->Lun);\r
1728 SasEx->RelativeTargetPort = (UINT16) Strtoi (RTPStr);\r
1729 if (StrCmp (SASSATAStr, L"NoTopology") != 0) {\r
1730 if (StrCmp (DriveBayStr, L"0") == 0) {\r
1731 Info |= 0x0001;\r
1732 } else {\r
1733 Info |= 0x0002;\r
1734 Info = (UINT16) (Info | (Strtoi (DriveBayStr) << 8));\r
1735 }\r
1736\r
1737 if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
1738 Info |= 0x0010;\r
1739 }\r
1740\r
1741 if (StrCmp (LocationStr, L"External") == 0) {\r
1742 Info |= 0x0020;\r
1743 }\r
1744\r
1745 if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
1746 Info |= 0x0040;\r
1747 }\r
1748 }\r
1749\r
1750 SasEx->DeviceTopology = Info;\r
1751\r
1752 return (EFI_DEVICE_PATH_PROTOCOL *) SasEx;\r
1753}\r
1754\r
572f5d8a 1755/**\r
1756 Converts a text device path node to Debug Port device path structure.\r
1757\r
1758 @param TextDeviceNode The input Text device path node.\r
1759\r
1760 @return A pointer to the newly-created Debug Port device path structure.\r
1761\r
1762**/\r
95276127 1763EFI_DEVICE_PATH_PROTOCOL *\r
1764DevPathFromTextDebugPort (\r
1765 IN CHAR16 *TextDeviceNode\r
1766 )\r
1767{\r
1768 VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend;\r
1769\r
1770 Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (\r
1771 MESSAGING_DEVICE_PATH,\r
1772 MSG_VENDOR_DP,\r
c9325700 1773 (UINT16) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)\r
95276127 1774 );\r
1775\r
1776 CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);\r
1777\r
1778 return (EFI_DEVICE_PATH_PROTOCOL *) Vend;\r
1779}\r
1780\r
572f5d8a 1781/**\r
1782 Converts a text device path node to MAC device path structure.\r
1783\r
1784 @param TextDeviceNode The input Text device path node.\r
1785\r
1786 @return A pointer to the newly-created MAC device path structure.\r
1787\r
1788**/\r
95276127 1789EFI_DEVICE_PATH_PROTOCOL *\r
1790DevPathFromTextMAC (\r
1791 IN CHAR16 *TextDeviceNode\r
1792 )\r
1793{\r
1794 CHAR16 *AddressStr;\r
1795 CHAR16 *IfTypeStr;\r
1796 UINTN Length;\r
572f5d8a 1797 MAC_ADDR_DEVICE_PATH *MACDevPath;\r
95276127 1798\r
1799 AddressStr = GetNextParamStr (&TextDeviceNode);\r
1800 IfTypeStr = GetNextParamStr (&TextDeviceNode);\r
572f5d8a 1801 MACDevPath = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (\r
95276127 1802 MESSAGING_DEVICE_PATH,\r
1803 MSG_MAC_ADDR_DP,\r
c9325700 1804 (UINT16) sizeof (MAC_ADDR_DEVICE_PATH)\r
95276127 1805 );\r
1806\r
572f5d8a 1807 MACDevPath->IfType = (UINT8) Strtoi (IfTypeStr);\r
95276127 1808\r
1809 Length = sizeof (EFI_MAC_ADDRESS);\r
572f5d8a 1810 StrToBuf (&MACDevPath->MacAddress.Addr[0], Length, AddressStr);\r
95276127 1811\r
572f5d8a 1812 return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;\r
95276127 1813}\r
1814\r
052019e1 1815\r
1816/**\r
1817 Converts a text format to the network protocol ID.\r
1818\r
1819 @param Text String of protocol field.\r
1820\r
1821 @return Network protocol ID .\r
1822\r
1823**/\r
1824UINTN\r
1825NetworkProtocolFromText (\r
1826 IN CHAR16 *Text\r
1827 )\r
1828{\r
1829 if (StrCmp (Text, L"UDP") == 0) {\r
1830 return RFC_1700_UDP_PROTOCOL;\r
1831 }\r
1832\r
1833 if (StrCmp (Text, L"TCP") == 0) {\r
1834 return RFC_1700_TCP_PROTOCOL;\r
1835 }\r
1836\r
1837 return Strtoi (Text);\r
1838}\r
1839\r
1840\r
572f5d8a 1841/**\r
1842 Converts a text device path node to IPV4 device path structure.\r
1843\r
1844 @param TextDeviceNode The input Text device path node.\r
1845\r
1846 @return A pointer to the newly-created IPV4 device path structure.\r
1847\r
1848**/\r
95276127 1849EFI_DEVICE_PATH_PROTOCOL *\r
1850DevPathFromTextIPv4 (\r
1851 IN CHAR16 *TextDeviceNode\r
1852 )\r
1853{\r
1854 CHAR16 *RemoteIPStr;\r
1855 CHAR16 *ProtocolStr;\r
1856 CHAR16 *TypeStr;\r
1857 CHAR16 *LocalIPStr;\r
e9b3cd55
RN
1858 CHAR16 *GatewayIPStr;\r
1859 CHAR16 *SubnetMaskStr;\r
95276127 1860 IPv4_DEVICE_PATH *IPv4;\r
1861\r
1862 RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r
1863 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
1864 TypeStr = GetNextParamStr (&TextDeviceNode);\r
1865 LocalIPStr = GetNextParamStr (&TextDeviceNode);\r
e9b3cd55
RN
1866 GatewayIPStr = GetNextParamStr (&TextDeviceNode);\r
1867 SubnetMaskStr = GetNextParamStr (&TextDeviceNode);\r
95276127 1868 IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (\r
1869 MESSAGING_DEVICE_PATH,\r
1870 MSG_IPv4_DP,\r
c9325700 1871 (UINT16) sizeof (IPv4_DEVICE_PATH)\r
95276127 1872 );\r
1873\r
1874 StrToIPv4Addr (&RemoteIPStr, &IPv4->RemoteIpAddress);\r
052019e1 1875 IPv4->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
95276127 1876 if (StrCmp (TypeStr, L"Static") == 0) {\r
1877 IPv4->StaticIpAddress = TRUE;\r
1878 } else {\r
1879 IPv4->StaticIpAddress = FALSE;\r
1880 }\r
1881\r
1882 StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress);\r
e9b3cd55
RN
1883 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*SubnetMaskStr)) {\r
1884 StrToIPv4Addr (&GatewayIPStr, &IPv4->GatewayIpAddress);\r
1885 StrToIPv4Addr (&SubnetMaskStr, &IPv4->SubnetMask);\r
1886 } else {\r
1887 ZeroMem (&IPv4->GatewayIpAddress, sizeof (IPv4->GatewayIpAddress));\r
1888 ZeroMem (&IPv4->SubnetMask, sizeof (IPv4->SubnetMask));\r
1889 }\r
95276127 1890\r
cf40f28a 1891 IPv4->LocalPort = 0;\r
1892 IPv4->RemotePort = 0;\r
95276127 1893\r
1894 return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;\r
1895}\r
1896\r
572f5d8a 1897/**\r
1898 Converts a text device path node to IPV6 device path structure.\r
1899\r
1900 @param TextDeviceNode The input Text device path node.\r
1901\r
1902 @return A pointer to the newly-created IPV6 device path structure.\r
1903\r
1904**/\r
95276127 1905EFI_DEVICE_PATH_PROTOCOL *\r
1906DevPathFromTextIPv6 (\r
1907 IN CHAR16 *TextDeviceNode\r
1908 )\r
1909{\r
1910 CHAR16 *RemoteIPStr;\r
1911 CHAR16 *ProtocolStr;\r
1912 CHAR16 *TypeStr;\r
1913 CHAR16 *LocalIPStr;\r
501793fa
RN
1914 CHAR16 *GatewayIPStr;\r
1915 CHAR16 *PrefixLengthStr;\r
95276127 1916 IPv6_DEVICE_PATH *IPv6;\r
1917\r
1918 RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r
1919 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
1920 TypeStr = GetNextParamStr (&TextDeviceNode);\r
1921 LocalIPStr = GetNextParamStr (&TextDeviceNode);\r
501793fa
RN
1922 PrefixLengthStr = GetNextParamStr (&TextDeviceNode);\r
1923 GatewayIPStr = GetNextParamStr (&TextDeviceNode);\r
95276127 1924 IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (\r
1925 MESSAGING_DEVICE_PATH,\r
1926 MSG_IPv6_DP,\r
c9325700 1927 (UINT16) sizeof (IPv6_DEVICE_PATH)\r
95276127 1928 );\r
1929\r
1930 StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);\r
052019e1 1931 IPv6->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
95276127 1932 if (StrCmp (TypeStr, L"Static") == 0) {\r
501793fa
RN
1933 IPv6->IpAddressOrigin = 0;\r
1934 } else if (StrCmp (TypeStr, L"StatelessAutoConfigure") == 0) {\r
1935 IPv6->IpAddressOrigin = 1;\r
95276127 1936 } else {\r
501793fa 1937 IPv6->IpAddressOrigin = 2;\r
95276127 1938 }\r
1939\r
1940 StrToIPv6Addr (&LocalIPStr, &IPv6->LocalIpAddress);\r
501793fa
RN
1941 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*PrefixLengthStr)) {\r
1942 StrToIPv6Addr (&GatewayIPStr, &IPv6->GatewayIpAddress);\r
1943 IPv6->PrefixLength = (UINT8) Strtoi (PrefixLengthStr);\r
1944 } else {\r
1945 ZeroMem (&IPv6->GatewayIpAddress, sizeof (IPv6->GatewayIpAddress));\r
1946 IPv6->PrefixLength = 0;\r
1947 }\r
95276127 1948\r
1949 IPv6->LocalPort = 0;\r
1950 IPv6->RemotePort = 0;\r
1951\r
1952 return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;\r
1953}\r
1954\r
572f5d8a 1955/**\r
1956 Converts a text device path node to UART device path structure.\r
1957\r
1958 @param TextDeviceNode The input Text device path node.\r
1959\r
1960 @return A pointer to the newly-created UART device path structure.\r
1961\r
1962**/\r
95276127 1963EFI_DEVICE_PATH_PROTOCOL *\r
1964DevPathFromTextUart (\r
1965 IN CHAR16 *TextDeviceNode\r
1966 )\r
1967{\r
1968 CHAR16 *BaudStr;\r
1969 CHAR16 *DataBitsStr;\r
1970 CHAR16 *ParityStr;\r
1971 CHAR16 *StopBitsStr;\r
1972 UART_DEVICE_PATH *Uart;\r
1973\r
1974 BaudStr = GetNextParamStr (&TextDeviceNode);\r
1975 DataBitsStr = GetNextParamStr (&TextDeviceNode);\r
1976 ParityStr = GetNextParamStr (&TextDeviceNode);\r
1977 StopBitsStr = GetNextParamStr (&TextDeviceNode);\r
1978 Uart = (UART_DEVICE_PATH *) CreateDeviceNode (\r
1979 MESSAGING_DEVICE_PATH,\r
1980 MSG_UART_DP,\r
c9325700 1981 (UINT16) sizeof (UART_DEVICE_PATH)\r
95276127 1982 );\r
1983\r
cf40f28a 1984 Uart->BaudRate = (StrCmp (BaudStr, L"DEFAULT") == 0) ? 115200 : Dtoi (BaudStr);\r
1985 Uart->DataBits = (UINT8) ((StrCmp (DataBitsStr, L"DEFAULT") == 0) ? 8 : Dtoi (DataBitsStr));\r
95276127 1986 switch (*ParityStr) {\r
1987 case L'D':\r
1988 Uart->Parity = 0;\r
1989 break;\r
1990\r
1991 case L'N':\r
1992 Uart->Parity = 1;\r
1993 break;\r
1994\r
1995 case L'E':\r
1996 Uart->Parity = 2;\r
1997 break;\r
1998\r
1999 case L'O':\r
2000 Uart->Parity = 3;\r
2001 break;\r
2002\r
2003 case L'M':\r
2004 Uart->Parity = 4;\r
2005 break;\r
2006\r
2007 case L'S':\r
2008 Uart->Parity = 5;\r
bd07919c 2009 break;\r
95276127 2010\r
2011 default:\r
2012 Uart->Parity = 0xff;\r
2013 }\r
2014\r
2015 if (StrCmp (StopBitsStr, L"D") == 0) {\r
2016 Uart->StopBits = (UINT8) 0;\r
2017 } else if (StrCmp (StopBitsStr, L"1") == 0) {\r
2018 Uart->StopBits = (UINT8) 1;\r
2019 } else if (StrCmp (StopBitsStr, L"1.5") == 0) {\r
2020 Uart->StopBits = (UINT8) 2;\r
2021 } else if (StrCmp (StopBitsStr, L"2") == 0) {\r
2022 Uart->StopBits = (UINT8) 3;\r
2023 } else {\r
2024 Uart->StopBits = 0xff;\r
2025 }\r
2026\r
2027 return (EFI_DEVICE_PATH_PROTOCOL *) Uart;\r
2028}\r
2029\r
572f5d8a 2030/**\r
2031 Converts a text device path node to USB class device path structure.\r
2032\r
2033 @param TextDeviceNode The input Text device path node.\r
2034 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.\r
2035\r
2036 @return A pointer to the newly-created USB class device path structure.\r
2037\r
2038**/\r
95276127 2039EFI_DEVICE_PATH_PROTOCOL *\r
2040ConvertFromTextUsbClass (\r
2041 IN CHAR16 *TextDeviceNode,\r
2042 IN USB_CLASS_TEXT *UsbClassText\r
2043 )\r
2044{\r
2045 CHAR16 *VIDStr;\r
2046 CHAR16 *PIDStr;\r
2047 CHAR16 *ClassStr;\r
2048 CHAR16 *SubClassStr;\r
2049 CHAR16 *ProtocolStr;\r
2050 USB_CLASS_DEVICE_PATH *UsbClass;\r
2051\r
2052 UsbClass = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (\r
2053 MESSAGING_DEVICE_PATH,\r
2054 MSG_USB_CLASS_DP,\r
c9325700 2055 (UINT16) sizeof (USB_CLASS_DEVICE_PATH)\r
95276127 2056 );\r
2057\r
2058 VIDStr = GetNextParamStr (&TextDeviceNode);\r
2059 PIDStr = GetNextParamStr (&TextDeviceNode);\r
2060 if (UsbClassText->ClassExist) {\r
2061 ClassStr = GetNextParamStr (&TextDeviceNode);\r
cf40f28a 2062 UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);\r
95276127 2063 } else {\r
2064 UsbClass->DeviceClass = UsbClassText->Class;\r
2065 }\r
2066 if (UsbClassText->SubClassExist) {\r
2067 SubClassStr = GetNextParamStr (&TextDeviceNode);\r
cf40f28a 2068 UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);\r
95276127 2069 } else {\r
2070 UsbClass->DeviceSubClass = UsbClassText->SubClass;\r
572f5d8a 2071 }\r
95276127 2072\r
2073 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
2074\r
cf40f28a 2075 UsbClass->VendorId = (UINT16) Strtoi (VIDStr);\r
2076 UsbClass->ProductId = (UINT16) Strtoi (PIDStr);\r
2077 UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);\r
95276127 2078\r
2079 return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;\r
2080}\r
2081\r
2082\r
572f5d8a 2083/**\r
2084 Converts a text device path node to USB class device path structure.\r
2085\r
2086 @param TextDeviceNode The input Text device path node.\r
2087\r
2088 @return A pointer to the newly-created USB class device path structure.\r
2089\r
2090**/\r
95276127 2091EFI_DEVICE_PATH_PROTOCOL *\r
2092DevPathFromTextUsbClass (\r
2093 IN CHAR16 *TextDeviceNode\r
2094 )\r
2095{\r
2096 USB_CLASS_TEXT UsbClassText;\r
2097\r
2098 UsbClassText.ClassExist = TRUE;\r
2099 UsbClassText.SubClassExist = TRUE;\r
2100\r
2101 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2102}\r
2103\r
572f5d8a 2104/**\r
2105 Converts a text device path node to USB audio device path structure.\r
2106\r
2107 @param TextDeviceNode The input Text device path node.\r
2108\r
2109 @return A pointer to the newly-created USB audio device path structure.\r
2110\r
2111**/\r
95276127 2112EFI_DEVICE_PATH_PROTOCOL *\r
2113DevPathFromTextUsbAudio (\r
2114 IN CHAR16 *TextDeviceNode\r
2115 )\r
2116{\r
2117 USB_CLASS_TEXT UsbClassText;\r
2118\r
2119 UsbClassText.ClassExist = FALSE;\r
2120 UsbClassText.Class = USB_CLASS_AUDIO;\r
2121 UsbClassText.SubClassExist = TRUE;\r
2122\r
2123 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2124}\r
2125\r
572f5d8a 2126/**\r
2127 Converts a text device path node to USB CDC Control device path structure.\r
2128\r
2129 @param TextDeviceNode The input Text device path node.\r
2130\r
2131 @return A pointer to the newly-created USB CDC Control device path structure.\r
2132\r
2133**/\r
95276127 2134EFI_DEVICE_PATH_PROTOCOL *\r
2135DevPathFromTextUsbCDCControl (\r
2136 IN CHAR16 *TextDeviceNode\r
2137 )\r
2138{\r
2139 USB_CLASS_TEXT UsbClassText;\r
2140\r
2141 UsbClassText.ClassExist = FALSE;\r
2142 UsbClassText.Class = USB_CLASS_CDCCONTROL;\r
2143 UsbClassText.SubClassExist = TRUE;\r
2144\r
2145 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2146}\r
2147\r
572f5d8a 2148/**\r
2149 Converts a text device path node to USB HID device path structure.\r
2150\r
2151 @param TextDeviceNode The input Text device path node.\r
2152\r
2153 @return A pointer to the newly-created USB HID device path structure.\r
2154\r
2155**/\r
95276127 2156EFI_DEVICE_PATH_PROTOCOL *\r
2157DevPathFromTextUsbHID (\r
2158 IN CHAR16 *TextDeviceNode\r
2159 )\r
2160{\r
2161 USB_CLASS_TEXT UsbClassText;\r
2162\r
2163 UsbClassText.ClassExist = FALSE;\r
2164 UsbClassText.Class = USB_CLASS_HID;\r
2165 UsbClassText.SubClassExist = TRUE;\r
2166\r
2167 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2168}\r
2169\r
572f5d8a 2170/**\r
2171 Converts a text device path node to USB Image device path structure.\r
2172\r
2173 @param TextDeviceNode The input Text device path node.\r
2174\r
2175 @return A pointer to the newly-created USB Image device path structure.\r
2176\r
2177**/\r
95276127 2178EFI_DEVICE_PATH_PROTOCOL *\r
2179DevPathFromTextUsbImage (\r
2180 IN CHAR16 *TextDeviceNode\r
2181 )\r
2182{\r
2183 USB_CLASS_TEXT UsbClassText;\r
2184\r
2185 UsbClassText.ClassExist = FALSE;\r
2186 UsbClassText.Class = USB_CLASS_IMAGE;\r
2187 UsbClassText.SubClassExist = TRUE;\r
2188\r
2189 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2190}\r
2191\r
572f5d8a 2192/**\r
2193 Converts a text device path node to USB Print device path structure.\r
2194\r
2195 @param TextDeviceNode The input Text device path node.\r
2196\r
2197 @return A pointer to the newly-created USB Print device path structure.\r
2198\r
2199**/\r
95276127 2200EFI_DEVICE_PATH_PROTOCOL *\r
2201DevPathFromTextUsbPrinter (\r
2202 IN CHAR16 *TextDeviceNode\r
2203 )\r
2204{\r
2205 USB_CLASS_TEXT UsbClassText;\r
2206\r
2207 UsbClassText.ClassExist = FALSE;\r
2208 UsbClassText.Class = USB_CLASS_PRINTER;\r
2209 UsbClassText.SubClassExist = TRUE;\r
2210\r
2211 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2212}\r
2213\r
572f5d8a 2214/**\r
2215 Converts a text device path node to USB mass storage device path structure.\r
2216\r
2217 @param TextDeviceNode The input Text device path node.\r
2218\r
2219 @return A pointer to the newly-created USB mass storage device path structure.\r
2220\r
2221**/\r
95276127 2222EFI_DEVICE_PATH_PROTOCOL *\r
2223DevPathFromTextUsbMassStorage (\r
2224 IN CHAR16 *TextDeviceNode\r
2225 )\r
2226{\r
2227 USB_CLASS_TEXT UsbClassText;\r
2228\r
2229 UsbClassText.ClassExist = FALSE;\r
2230 UsbClassText.Class = USB_CLASS_MASS_STORAGE;\r
2231 UsbClassText.SubClassExist = TRUE;\r
2232\r
2233 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2234}\r
2235\r
572f5d8a 2236/**\r
2237 Converts a text device path node to USB HUB device path structure.\r
2238\r
2239 @param TextDeviceNode The input Text device path node.\r
2240\r
2241 @return A pointer to the newly-created USB HUB device path structure.\r
2242\r
2243**/\r
95276127 2244EFI_DEVICE_PATH_PROTOCOL *\r
2245DevPathFromTextUsbHub (\r
2246 IN CHAR16 *TextDeviceNode\r
2247 )\r
2248{\r
2249 USB_CLASS_TEXT UsbClassText;\r
2250\r
2251 UsbClassText.ClassExist = FALSE;\r
2252 UsbClassText.Class = USB_CLASS_HUB;\r
2253 UsbClassText.SubClassExist = TRUE;\r
2254\r
2255 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2256}\r
2257\r
572f5d8a 2258/**\r
2259 Converts a text device path node to USB CDC data device path structure.\r
2260\r
2261 @param TextDeviceNode The input Text device path node.\r
2262\r
2263 @return A pointer to the newly-created USB CDC data device path structure.\r
2264\r
2265**/\r
95276127 2266EFI_DEVICE_PATH_PROTOCOL *\r
2267DevPathFromTextUsbCDCData (\r
2268 IN CHAR16 *TextDeviceNode\r
2269 )\r
2270{\r
2271 USB_CLASS_TEXT UsbClassText;\r
2272\r
2273 UsbClassText.ClassExist = FALSE;\r
2274 UsbClassText.Class = USB_CLASS_CDCDATA;\r
2275 UsbClassText.SubClassExist = TRUE;\r
2276\r
2277 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2278}\r
2279\r
572f5d8a 2280/**\r
2281 Converts a text device path node to USB smart card device path structure.\r
2282\r
2283 @param TextDeviceNode The input Text device path node.\r
2284\r
2285 @return A pointer to the newly-created USB smart card device path structure.\r
2286\r
2287**/\r
95276127 2288EFI_DEVICE_PATH_PROTOCOL *\r
2289DevPathFromTextUsbSmartCard (\r
2290 IN CHAR16 *TextDeviceNode\r
2291 )\r
2292{\r
2293 USB_CLASS_TEXT UsbClassText;\r
2294\r
2295 UsbClassText.ClassExist = FALSE;\r
2296 UsbClassText.Class = USB_CLASS_SMART_CARD;\r
2297 UsbClassText.SubClassExist = TRUE;\r
2298\r
2299 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2300}\r
2301\r
572f5d8a 2302/**\r
2303 Converts a text device path node to USB video device path structure.\r
2304\r
2305 @param TextDeviceNode The input Text device path node.\r
2306\r
2307 @return A pointer to the newly-created USB video device path structure.\r
2308\r
2309**/\r
95276127 2310EFI_DEVICE_PATH_PROTOCOL *\r
2311DevPathFromTextUsbVideo (\r
2312 IN CHAR16 *TextDeviceNode\r
2313 )\r
2314{\r
2315 USB_CLASS_TEXT UsbClassText;\r
2316\r
2317 UsbClassText.ClassExist = FALSE;\r
2318 UsbClassText.Class = USB_CLASS_VIDEO;\r
2319 UsbClassText.SubClassExist = TRUE;\r
2320\r
2321 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2322}\r
2323\r
572f5d8a 2324/**\r
2325 Converts a text device path node to USB diagnostic device path structure.\r
2326\r
2327 @param TextDeviceNode The input Text device path node.\r
2328\r
2329 @return A pointer to the newly-created USB diagnostic device path structure.\r
2330\r
2331**/\r
95276127 2332EFI_DEVICE_PATH_PROTOCOL *\r
2333DevPathFromTextUsbDiagnostic (\r
2334 IN CHAR16 *TextDeviceNode\r
2335 )\r
2336{\r
2337 USB_CLASS_TEXT UsbClassText;\r
2338\r
2339 UsbClassText.ClassExist = FALSE;\r
2340 UsbClassText.Class = USB_CLASS_DIAGNOSTIC;\r
2341 UsbClassText.SubClassExist = TRUE;\r
2342\r
2343 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2344}\r
2345\r
572f5d8a 2346/**\r
2347 Converts a text device path node to USB wireless device path structure.\r
2348\r
2349 @param TextDeviceNode The input Text device path node.\r
2350\r
2351 @return A pointer to the newly-created USB wireless device path structure.\r
2352\r
2353**/\r
95276127 2354EFI_DEVICE_PATH_PROTOCOL *\r
2355DevPathFromTextUsbWireless (\r
2356 IN CHAR16 *TextDeviceNode\r
2357 )\r
2358{\r
2359 USB_CLASS_TEXT UsbClassText;\r
2360\r
2361 UsbClassText.ClassExist = FALSE;\r
2362 UsbClassText.Class = USB_CLASS_WIRELESS;\r
2363 UsbClassText.SubClassExist = TRUE;\r
2364\r
2365 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2366}\r
2367\r
572f5d8a 2368/**\r
2369 Converts a text device path node to USB device firmware update device path structure.\r
2370\r
2371 @param TextDeviceNode The input Text device path node.\r
2372\r
2373 @return A pointer to the newly-created USB device firmware update device path structure.\r
2374\r
2375**/\r
95276127 2376EFI_DEVICE_PATH_PROTOCOL *\r
2377DevPathFromTextUsbDeviceFirmwareUpdate (\r
2378 IN CHAR16 *TextDeviceNode\r
2379 )\r
2380{\r
2381 USB_CLASS_TEXT UsbClassText;\r
2382\r
2383 UsbClassText.ClassExist = FALSE;\r
2384 UsbClassText.Class = USB_CLASS_RESERVE;\r
2385 UsbClassText.SubClassExist = FALSE;\r
2386 UsbClassText.SubClass = USB_SUBCLASS_FW_UPDATE;\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 IRDA bridge 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 IRDA bridge device path structure.\r
2397\r
2398**/\r
95276127 2399EFI_DEVICE_PATH_PROTOCOL *\r
2400DevPathFromTextUsbIrdaBridge (\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_RESERVE;\r
2408 UsbClassText.SubClassExist = FALSE;\r
2409 UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE;\r
2410\r
2411 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2412}\r
2413\r
572f5d8a 2414/**\r
2415 Converts a text device path node to USB text and measurement device path structure.\r
2416\r
2417 @param TextDeviceNode The input Text device path node.\r
2418\r
2419 @return A pointer to the newly-created USB text and measurement device path structure.\r
2420\r
2421**/\r
95276127 2422EFI_DEVICE_PATH_PROTOCOL *\r
2423DevPathFromTextUsbTestAndMeasurement (\r
2424 IN CHAR16 *TextDeviceNode\r
2425 )\r
2426{\r
2427 USB_CLASS_TEXT UsbClassText;\r
2428\r
2429 UsbClassText.ClassExist = FALSE;\r
2430 UsbClassText.Class = USB_CLASS_RESERVE;\r
2431 UsbClassText.SubClassExist = FALSE;\r
2432 UsbClassText.SubClass = USB_SUBCLASS_TEST;\r
2433\r
2434 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2435}\r
2436\r
572f5d8a 2437/**\r
2438 Converts a text device path node to USB WWID device path structure.\r
2439\r
2440 @param TextDeviceNode The input Text device path node.\r
2441\r
2442 @return A pointer to the newly-created USB WWID device path structure.\r
2443\r
2444**/\r
95276127 2445EFI_DEVICE_PATH_PROTOCOL *\r
2446DevPathFromTextUsbWwid (\r
2447 IN CHAR16 *TextDeviceNode\r
2448 )\r
2449{\r
2450 CHAR16 *VIDStr;\r
2451 CHAR16 *PIDStr;\r
2452 CHAR16 *InterfaceNumStr;\r
cf40f28a 2453 CHAR16 *SerialNumberStr;\r
95276127 2454 USB_WWID_DEVICE_PATH *UsbWwid;\r
2455\r
2456 VIDStr = GetNextParamStr (&TextDeviceNode);\r
2457 PIDStr = GetNextParamStr (&TextDeviceNode);\r
2458 InterfaceNumStr = GetNextParamStr (&TextDeviceNode);\r
cf40f28a 2459 SerialNumberStr = GetNextParamStr (&TextDeviceNode);\r
95276127 2460 UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (\r
2461 MESSAGING_DEVICE_PATH,\r
2462 MSG_USB_WWID_DP,\r
cf40f28a 2463 (UINT16) (sizeof (USB_WWID_DEVICE_PATH) + StrSize (SerialNumberStr))\r
95276127 2464 );\r
2465\r
cf40f28a 2466 UsbWwid->VendorId = (UINT16) Strtoi (VIDStr);\r
2467 UsbWwid->ProductId = (UINT16) Strtoi (PIDStr);\r
2468 UsbWwid->InterfaceNumber = (UINT16) Strtoi (InterfaceNumStr);\r
2469 StrCpy ((CHAR16 *) ((UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH)), SerialNumberStr);\r
95276127 2470\r
2471 return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;\r
2472}\r
2473\r
572f5d8a 2474/**\r
2475 Converts a text device path node to Logic Unit device path structure.\r
2476\r
2477 @param TextDeviceNode The input Text device path node.\r
2478\r
2479 @return A pointer to the newly-created Logic Unit device path structure.\r
2480\r
2481**/\r
95276127 2482EFI_DEVICE_PATH_PROTOCOL *\r
2483DevPathFromTextUnit (\r
2484 IN CHAR16 *TextDeviceNode\r
2485 )\r
2486{\r
2487 CHAR16 *LunStr;\r
2488 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
2489\r
2490 LunStr = GetNextParamStr (&TextDeviceNode);\r
2491 LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (\r
2492 MESSAGING_DEVICE_PATH,\r
2493 MSG_DEVICE_LOGICAL_UNIT_DP,\r
cf40f28a 2494 (UINT16) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)\r
95276127 2495 );\r
2496\r
cf40f28a 2497 LogicalUnit->Lun = (UINT8) Strtoi (LunStr);\r
95276127 2498\r
2499 return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;\r
2500}\r
2501\r
572f5d8a 2502/**\r
2503 Converts a text device path node to iSCSI device path structure.\r
2504\r
2505 @param TextDeviceNode The input Text device path node.\r
2506\r
2507 @return A pointer to the newly-created iSCSI device path structure.\r
2508\r
2509**/\r
95276127 2510EFI_DEVICE_PATH_PROTOCOL *\r
2511DevPathFromTextiSCSI (\r
2512 IN CHAR16 *TextDeviceNode\r
2513 )\r
2514{\r
2515 UINT16 Options;\r
2516 CHAR16 *NameStr;\r
2517 CHAR16 *PortalGroupStr;\r
2518 CHAR16 *LunStr;\r
2519 CHAR16 *HeaderDigestStr;\r
2520 CHAR16 *DataDigestStr;\r
2521 CHAR16 *AuthenticationStr;\r
2522 CHAR16 *ProtocolStr;\r
cf40f28a 2523 CHAR8 *AsciiStr;\r
572f5d8a 2524 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
95276127 2525\r
2526 NameStr = GetNextParamStr (&TextDeviceNode);\r
2527 PortalGroupStr = GetNextParamStr (&TextDeviceNode);\r
2528 LunStr = GetNextParamStr (&TextDeviceNode);\r
2529 HeaderDigestStr = GetNextParamStr (&TextDeviceNode);\r
2530 DataDigestStr = GetNextParamStr (&TextDeviceNode);\r
2531 AuthenticationStr = GetNextParamStr (&TextDeviceNode);\r
2532 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
572f5d8a 2533 ISCSIDevPath = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (\r
95276127 2534 MESSAGING_DEVICE_PATH,\r
2535 MSG_ISCSI_DP,\r
047c6449 2536 (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))\r
95276127 2537 );\r
2538\r
184f7d83 2539 AsciiStr = ISCSIDevPath->TargetName;\r
cf40f28a 2540 StrToAscii (NameStr, &AsciiStr);\r
2541\r
572f5d8a 2542 ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);\r
2543 Strtoi64 (LunStr, &ISCSIDevPath->Lun);\r
95276127 2544\r
2545 Options = 0x0000;\r
2546 if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {\r
2547 Options |= 0x0002;\r
2548 }\r
2549\r
2550 if (StrCmp (DataDigestStr, L"CRC32C") == 0) {\r
2551 Options |= 0x0008;\r
2552 }\r
2553\r
2554 if (StrCmp (AuthenticationStr, L"None") == 0) {\r
2555 Options |= 0x0800;\r
2556 }\r
2557\r
2558 if (StrCmp (AuthenticationStr, L"CHAP_UNI") == 0) {\r
2559 Options |= 0x1000;\r
2560 }\r
2561\r
572f5d8a 2562 ISCSIDevPath->LoginOption = (UINT16) Options;\r
95276127 2563\r
572f5d8a 2564 ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP");\r
95276127 2565\r
572f5d8a 2566 return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;\r
95276127 2567}\r
2568\r
8f97f911 2569/**\r
2570 Converts a text device path node to VLAN 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 VLAN device path structure.\r
2575\r
2576**/\r
2577EFI_DEVICE_PATH_PROTOCOL *\r
2578DevPathFromTextVlan (\r
2579 IN CHAR16 *TextDeviceNode\r
2580 )\r
2581{\r
2582 CHAR16 *VlanStr;\r
2583 VLAN_DEVICE_PATH *Vlan;\r
2584\r
2585 VlanStr = GetNextParamStr (&TextDeviceNode);\r
2586 Vlan = (VLAN_DEVICE_PATH *) CreateDeviceNode (\r
2587 MESSAGING_DEVICE_PATH,\r
2588 MSG_VLAN_DP,\r
c9325700 2589 (UINT16) sizeof (VLAN_DEVICE_PATH)\r
8f97f911 2590 );\r
2591\r
2592 Vlan->VlanId = (UINT16) Strtoi (VlanStr);\r
2593\r
2594 return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;\r
2595}\r
2596\r
572f5d8a 2597/**\r
2598 Converts a text device path node to HD device path structure.\r
2599\r
2600 @param TextDeviceNode The input Text device path node.\r
2601\r
2602 @return A pointer to the newly-created HD device path structure.\r
2603\r
2604**/\r
95276127 2605EFI_DEVICE_PATH_PROTOCOL *\r
2606DevPathFromTextHD (\r
2607 IN CHAR16 *TextDeviceNode\r
2608 )\r
2609{\r
2610 CHAR16 *PartitionStr;\r
2611 CHAR16 *TypeStr;\r
2612 CHAR16 *SignatureStr;\r
2613 CHAR16 *StartStr;\r
2614 CHAR16 *SizeStr;\r
2615 UINT32 Signature32;\r
2616 EFI_GUID SignatureGuid;\r
2617 HARDDRIVE_DEVICE_PATH *Hd;\r
2618\r
2619 PartitionStr = GetNextParamStr (&TextDeviceNode);\r
2620 TypeStr = GetNextParamStr (&TextDeviceNode);\r
2621 SignatureStr = GetNextParamStr (&TextDeviceNode);\r
2622 StartStr = GetNextParamStr (&TextDeviceNode);\r
2623 SizeStr = GetNextParamStr (&TextDeviceNode);\r
2624 Hd = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (\r
2625 MEDIA_DEVICE_PATH,\r
2626 MEDIA_HARDDRIVE_DP,\r
c9325700 2627 (UINT16) sizeof (HARDDRIVE_DEVICE_PATH)\r
95276127 2628 );\r
2629\r
cf40f28a 2630 Hd->PartitionNumber = (UINT32) Dtoi (PartitionStr);\r
95276127 2631\r
2632 ZeroMem (Hd->Signature, 16);\r
2633 Hd->MBRType = (UINT8) 0;\r
2634\r
cf40f28a 2635 if (StrCmp (TypeStr, L"MBR") == 0) {\r
95276127 2636 Hd->SignatureType = SIGNATURE_TYPE_MBR;\r
2637 Hd->MBRType = 0x01;\r
2638\r
cf40f28a 2639 Signature32 = (UINT32) Strtoi (SignatureStr);\r
95276127 2640 CopyMem (Hd->Signature, &Signature32, sizeof (UINT32));\r
cf40f28a 2641 } else if (StrCmp (TypeStr, L"GPT") == 0) {\r
95276127 2642 Hd->SignatureType = SIGNATURE_TYPE_GUID;\r
2643 Hd->MBRType = 0x02;\r
2644\r
2645 StrToGuid (SignatureStr, &SignatureGuid);\r
2646 CopyMem (Hd->Signature, &SignatureGuid, sizeof (EFI_GUID));\r
2647 } else {\r
cf40f28a 2648 Hd->SignatureType = (UINT8) Strtoi (TypeStr);\r
95276127 2649 }\r
2650\r
cf40f28a 2651 Strtoi64 (StartStr, &Hd->PartitionStart);\r
2652 Strtoi64 (SizeStr, &Hd->PartitionSize);\r
95276127 2653\r
2654 return (EFI_DEVICE_PATH_PROTOCOL *) Hd;\r
2655}\r
2656\r
572f5d8a 2657/**\r
2658 Converts a text device path node to CDROM device path structure.\r
2659\r
2660 @param TextDeviceNode The input Text device path node.\r
2661\r
2662 @return A pointer to the newly-created CDROM device path structure.\r
2663\r
2664**/\r
95276127 2665EFI_DEVICE_PATH_PROTOCOL *\r
2666DevPathFromTextCDROM (\r
2667 IN CHAR16 *TextDeviceNode\r
2668 )\r
2669{\r
2670 CHAR16 *EntryStr;\r
2671 CHAR16 *StartStr;\r
2672 CHAR16 *SizeStr;\r
572f5d8a 2673 CDROM_DEVICE_PATH *CDROMDevPath;\r
95276127 2674\r
2675 EntryStr = GetNextParamStr (&TextDeviceNode);\r
2676 StartStr = GetNextParamStr (&TextDeviceNode);\r
2677 SizeStr = GetNextParamStr (&TextDeviceNode);\r
572f5d8a 2678 CDROMDevPath = (CDROM_DEVICE_PATH *) CreateDeviceNode (\r
95276127 2679 MEDIA_DEVICE_PATH,\r
2680 MEDIA_CDROM_DP,\r
c9325700 2681 (UINT16) sizeof (CDROM_DEVICE_PATH)\r
95276127 2682 );\r
2683\r
572f5d8a 2684 CDROMDevPath->BootEntry = (UINT32) Strtoi (EntryStr);\r
2685 Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);\r
2686 Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);\r
95276127 2687\r
572f5d8a 2688 return (EFI_DEVICE_PATH_PROTOCOL *) CDROMDevPath;\r
95276127 2689}\r
2690\r
572f5d8a 2691/**\r
2692 Converts a text device path node to Vendor-defined media device path structure.\r
2693\r
2694 @param TextDeviceNode The input Text device path node.\r
2695\r
2696 @return A pointer to the newly-created Vendor-defined media device path structure.\r
2697\r
2698**/\r
95276127 2699EFI_DEVICE_PATH_PROTOCOL *\r
2700DevPathFromTextVenMEDIA (\r
2701 IN CHAR16 *TextDeviceNode\r
2702 )\r
2703{\r
2704 return ConvertFromTextVendor (\r
2705 TextDeviceNode,\r
2706 MEDIA_DEVICE_PATH,\r
2707 MEDIA_VENDOR_DP\r
2708 );\r
2709}\r
2710\r
572f5d8a 2711/**\r
2712 Converts a text device path node to File device path structure.\r
2713\r
2714 @param TextDeviceNode The input Text device path node.\r
2715\r
2716 @return A pointer to the newly-created File device path structure.\r
2717\r
2718**/\r
95276127 2719EFI_DEVICE_PATH_PROTOCOL *\r
2720DevPathFromTextFilePath (\r
2721 IN CHAR16 *TextDeviceNode\r
2722 )\r
2723{\r
2724 FILEPATH_DEVICE_PATH *File;\r
2725\r
2726 File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r
2727 MEDIA_DEVICE_PATH,\r
2728 MEDIA_FILEPATH_DP,\r
d074a8e1 2729 (UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)\r
95276127 2730 );\r
2731\r
2732 StrCpy (File->PathName, TextDeviceNode);\r
2733\r
2734 return (EFI_DEVICE_PATH_PROTOCOL *) File;\r
2735}\r
2736\r
572f5d8a 2737/**\r
2738 Converts a text device path node to Media protocol device path structure.\r
2739\r
2740 @param TextDeviceNode The input Text device path node.\r
2741\r
2742 @return A pointer to the newly-created Media protocol device path structure.\r
2743\r
2744**/\r
95276127 2745EFI_DEVICE_PATH_PROTOCOL *\r
2746DevPathFromTextMedia (\r
2747 IN CHAR16 *TextDeviceNode\r
2748 )\r
2749{\r
2750 CHAR16 *GuidStr;\r
2751 MEDIA_PROTOCOL_DEVICE_PATH *Media;\r
2752\r
2753 GuidStr = GetNextParamStr (&TextDeviceNode);\r
2754 Media = (MEDIA_PROTOCOL_DEVICE_PATH *) CreateDeviceNode (\r
2755 MEDIA_DEVICE_PATH,\r
2756 MEDIA_PROTOCOL_DP,\r
c9325700 2757 (UINT16) sizeof (MEDIA_PROTOCOL_DEVICE_PATH)\r
95276127 2758 );\r
2759\r
2760 StrToGuid (GuidStr, &Media->Protocol);\r
2761\r
2762 return (EFI_DEVICE_PATH_PROTOCOL *) Media;\r
2763}\r
2764\r
572f5d8a 2765/**\r
2766 Converts a text device path node to firmware volume device path structure.\r
2767\r
2768 @param TextDeviceNode The input Text device path node.\r
2769\r
2770 @return A pointer to the newly-created firmware volume device path structure.\r
2771\r
2772**/\r
cf40f28a 2773EFI_DEVICE_PATH_PROTOCOL *\r
2774DevPathFromTextFv (\r
2775 IN CHAR16 *TextDeviceNode\r
2776 )\r
2777{\r
2778 CHAR16 *GuidStr;\r
2779 MEDIA_FW_VOL_DEVICE_PATH *Fv;\r
2780\r
2781 GuidStr = GetNextParamStr (&TextDeviceNode);\r
2782 Fv = (MEDIA_FW_VOL_DEVICE_PATH *) CreateDeviceNode (\r
2783 MEDIA_DEVICE_PATH,\r
2784 MEDIA_PIWG_FW_VOL_DP,\r
c9325700 2785 (UINT16) sizeof (MEDIA_FW_VOL_DEVICE_PATH)\r
cf40f28a 2786 );\r
2787\r
2788 StrToGuid (GuidStr, &Fv->FvName);\r
2789\r
2790 return (EFI_DEVICE_PATH_PROTOCOL *) Fv;\r
2791}\r
2792\r
572f5d8a 2793/**\r
2794 Converts a text device path node to firmware file device path structure.\r
2795\r
2796 @param TextDeviceNode The input Text device path node.\r
2797\r
2798 @return A pointer to the newly-created firmware file device path structure.\r
2799\r
2800**/\r
cf40f28a 2801EFI_DEVICE_PATH_PROTOCOL *\r
2802DevPathFromTextFvFile (\r
2803 IN CHAR16 *TextDeviceNode\r
2804 )\r
2805{\r
2806 CHAR16 *GuidStr;\r
2807 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;\r
2808\r
2809 GuidStr = GetNextParamStr (&TextDeviceNode);\r
2810 FvFile = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r
2811 MEDIA_DEVICE_PATH,\r
2812 MEDIA_PIWG_FW_FILE_DP,\r
c9325700 2813 (UINT16) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)\r
cf40f28a 2814 );\r
2815\r
2816 StrToGuid (GuidStr, &FvFile->FvFileName);\r
2817\r
2818 return (EFI_DEVICE_PATH_PROTOCOL *) FvFile;\r
2819}\r
2820\r
192b057b 2821/**\r
2822 Converts a text device path node to text relative offset device path structure.\r
2823\r
2824 @param TextDeviceNode The input Text device path node.\r
2825\r
2826 @return A pointer to the newly-created Text device path structure.\r
2827\r
2828**/\r
2829EFI_DEVICE_PATH_PROTOCOL *\r
2830DevPathFromTextRelativeOffsetRange (\r
2831 IN CHAR16 *TextDeviceNode\r
2832 )\r
2833{\r
395ed063 2834 CHAR16 *StartingOffsetStr;\r
2835 CHAR16 *EndingOffsetStr;\r
2836 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
192b057b 2837\r
2838 StartingOffsetStr = GetNextParamStr (&TextDeviceNode);\r
2839 EndingOffsetStr = GetNextParamStr (&TextDeviceNode);\r
395ed063 2840 Offset = (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *) CreateDeviceNode (\r
2841 MEDIA_DEVICE_PATH,\r
2842 MEDIA_RELATIVE_OFFSET_RANGE_DP,\r
c9325700 2843 (UINT16) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH)\r
395ed063 2844 );\r
2845\r
792a1534 2846 Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);\r
2847 Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);\r
192b057b 2848\r
2849 return (EFI_DEVICE_PATH_PROTOCOL *) Offset;\r
2850}\r
2851\r
572f5d8a 2852/**\r
2853 Converts a text device path node to BIOS Boot Specification device path structure.\r
2854\r
2855 @param TextDeviceNode The input Text device path node.\r
2856\r
5755841f 2857 @return A pointer to the newly-created BIOS Boot Specification device path structure.\r
572f5d8a 2858\r
2859**/\r
95276127 2860EFI_DEVICE_PATH_PROTOCOL *\r
2861DevPathFromTextBBS (\r
2862 IN CHAR16 *TextDeviceNode\r
2863 )\r
2864{\r
2865 CHAR16 *TypeStr;\r
2866 CHAR16 *IdStr;\r
2867 CHAR16 *FlagsStr;\r
cf40f28a 2868 CHAR8 *AsciiStr;\r
95276127 2869 BBS_BBS_DEVICE_PATH *Bbs;\r
2870\r
2871 TypeStr = GetNextParamStr (&TextDeviceNode);\r
2872 IdStr = GetNextParamStr (&TextDeviceNode);\r
2873 FlagsStr = GetNextParamStr (&TextDeviceNode);\r
2874 Bbs = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode (\r
2875 BBS_DEVICE_PATH,\r
2876 BBS_BBS_DP,\r
d074a8e1 2877 (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr))\r
95276127 2878 );\r
2879\r
2880 if (StrCmp (TypeStr, L"Floppy") == 0) {\r
2881 Bbs->DeviceType = BBS_TYPE_FLOPPY;\r
2882 } else if (StrCmp (TypeStr, L"HD") == 0) {\r
2883 Bbs->DeviceType = BBS_TYPE_HARDDRIVE;\r
2884 } else if (StrCmp (TypeStr, L"CDROM") == 0) {\r
2885 Bbs->DeviceType = BBS_TYPE_CDROM;\r
2886 } else if (StrCmp (TypeStr, L"PCMCIA") == 0) {\r
2887 Bbs->DeviceType = BBS_TYPE_PCMCIA;\r
2888 } else if (StrCmp (TypeStr, L"USB") == 0) {\r
2889 Bbs->DeviceType = BBS_TYPE_USB;\r
2890 } else if (StrCmp (TypeStr, L"Network") == 0) {\r
2891 Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK;\r
2892 } else {\r
cf40f28a 2893 Bbs->DeviceType = (UINT16) Strtoi (TypeStr);\r
95276127 2894 }\r
2895\r
cf40f28a 2896 AsciiStr = Bbs->String;\r
2897 StrToAscii (IdStr, &AsciiStr);\r
95276127 2898\r
cf40f28a 2899 Bbs->StatusFlag = (UINT16) Strtoi (FlagsStr);\r
95276127 2900\r
2901 return (EFI_DEVICE_PATH_PROTOCOL *) Bbs;\r
2902}\r