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