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