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