]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
MdePkg: Handle USBxxx device path when optional para is not specified
[mirror_edk2.git] / MdePkg / Library / UefiDevicePathLib / DevicePathFromText.c
... / ...
CommitLineData
1/** @file\r
2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.\r
3\r
4Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
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
9\r
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
12\r
13**/\r
14\r
15#include "UefiDevicePathLib.h"\r
16\r
17/**\r
18\r
19 Duplicates a string.\r
20\r
21 @param Src Source string.\r
22\r
23 @return The duplicated string.\r
24\r
25**/\r
26CHAR16 *\r
27UefiDevicePathLibStrDuplicate (\r
28 IN CONST CHAR16 *Src\r
29 )\r
30{\r
31 return AllocateCopyPool (StrSize (Src), Src);\r
32}\r
33\r
34/**\r
35\r
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
38\r
39 @param Str Device Path Text.\r
40 @param NodeName Name of the node.\r
41\r
42 @return Parameter text for the node.\r
43\r
44**/\r
45CHAR16 *\r
46GetParamByNodeName (\r
47 IN CHAR16 *Str,\r
48 IN CHAR16 *NodeName\r
49 )\r
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
60 if (StrnCmp (Str, NodeName, NodeNameLength) != 0) {\r
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
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
113CHAR16 *\r
114SplitStr (\r
115 IN OUT CHAR16 **List,\r
116 IN CHAR16 Separator\r
117 )\r
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
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
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
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
183CHAR16 *\r
184GetNextDeviceNodeStr (\r
185 IN OUT CHAR16 **DevicePath,\r
186 OUT BOOLEAN *IsInstanceEnd\r
187 )\r
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
255\r
256/**\r
257 Return whether the integer string is a hex string.\r
258\r
259 @param Str The integer string\r
260\r
261 @retval TRUE Hex string\r
262 @retval FALSE Decimal string\r
263\r
264**/\r
265BOOLEAN\r
266IsHexStr (\r
267 IN CHAR16 *Str\r
268 )\r
269{\r
270 //\r
271 // skip preceeding white space\r
272 //\r
273 while ((*Str != 0) && *Str == L' ') {\r
274 Str ++;\r
275 }\r
276 //\r
277 // skip preceeding zeros\r
278 //\r
279 while ((*Str != 0) && *Str == L'0') {\r
280 Str ++;\r
281 }\r
282\r
283 return (BOOLEAN) (*Str == L'x' || *Str == L'X');\r
284}\r
285\r
286/**\r
287\r
288 Convert integer string to uint.\r
289\r
290 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.\r
291\r
292 @return A UINTN value represented by Str\r
293\r
294**/\r
295UINTN\r
296Strtoi (\r
297 IN CHAR16 *Str\r
298 )\r
299{\r
300 if (IsHexStr (Str)) {\r
301 return StrHexToUintn (Str);\r
302 } else {\r
303 return StrDecimalToUintn (Str);\r
304 }\r
305}\r
306\r
307/**\r
308\r
309 Convert integer string to 64 bit data.\r
310\r
311 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.\r
312 @param Data A pointer to the UINT64 value represented by Str\r
313\r
314**/\r
315VOID\r
316Strtoi64 (\r
317 IN CHAR16 *Str,\r
318 OUT UINT64 *Data\r
319 )\r
320{\r
321 if (IsHexStr (Str)) {\r
322 *Data = StrHexToUint64 (Str);\r
323 } else {\r
324 *Data = StrDecimalToUint64 (Str);\r
325 }\r
326}\r
327\r
328/**\r
329 Converts a Unicode string to ASCII string.\r
330\r
331 @param Str The equivalent Unicode string\r
332 @param AsciiStr On input, it points to destination ASCII string buffer; on output, it points\r
333 to the next ASCII string next to it\r
334\r
335**/\r
336VOID\r
337StrToAscii (\r
338 IN CHAR16 *Str,\r
339 IN OUT CHAR8 **AsciiStr\r
340 )\r
341{\r
342 CHAR8 *Dest;\r
343\r
344 Dest = *AsciiStr;\r
345 while (!IS_NULL (*Str)) {\r
346 *(Dest++) = (CHAR8) *(Str++);\r
347 }\r
348 *Dest = 0;\r
349\r
350 //\r
351 // Return the string next to it\r
352 //\r
353 *AsciiStr = Dest + 1;\r
354}\r
355\r
356/**\r
357 Converts a generic text device path node to device path structure.\r
358\r
359 @param Type The type of the device path node.\r
360 @param TextDeviceNode The input text device path node.\r
361\r
362 @return A pointer to device path structure.\r
363**/\r
364EFI_DEVICE_PATH_PROTOCOL *\r
365DevPathFromTextGenericPath (\r
366 IN UINT8 Type,\r
367 IN CHAR16 *TextDeviceNode\r
368 )\r
369{\r
370 EFI_DEVICE_PATH_PROTOCOL *Node;\r
371 CHAR16 *SubtypeStr;\r
372 CHAR16 *DataStr;\r
373 UINTN DataLength;\r
374\r
375 SubtypeStr = GetNextParamStr (&TextDeviceNode);\r
376 DataStr = GetNextParamStr (&TextDeviceNode);\r
377\r
378 if (DataStr == NULL) {\r
379 DataLength = 0;\r
380 } else {\r
381 DataLength = StrLen (DataStr) / 2;\r
382 }\r
383 Node = CreateDeviceNode (\r
384 Type,\r
385 (UINT8) Strtoi (SubtypeStr),\r
386 (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)\r
387 );\r
388\r
389 StrHexToBytes (DataStr, DataLength * 2, (UINT8 *) (Node + 1), DataLength);\r
390 return Node;\r
391}\r
392\r
393/**\r
394 Converts a generic text device path node to device path structure.\r
395\r
396 @param TextDeviceNode The input Text device path node.\r
397\r
398 @return A pointer to device path structure.\r
399\r
400**/\r
401EFI_DEVICE_PATH_PROTOCOL *\r
402DevPathFromTextPath (\r
403 IN CHAR16 *TextDeviceNode\r
404 )\r
405{\r
406 CHAR16 *TypeStr;\r
407\r
408 TypeStr = GetNextParamStr (&TextDeviceNode);\r
409\r
410 return DevPathFromTextGenericPath ((UINT8) Strtoi (TypeStr), TextDeviceNode);\r
411}\r
412\r
413/**\r
414 Converts a generic hardware text device path node to Hardware device path structure.\r
415\r
416 @param TextDeviceNode The input Text device path node.\r
417\r
418 @return A pointer to Hardware device path structure.\r
419\r
420**/\r
421EFI_DEVICE_PATH_PROTOCOL *\r
422DevPathFromTextHardwarePath (\r
423 IN CHAR16 *TextDeviceNode\r
424 )\r
425{\r
426 return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH, TextDeviceNode);\r
427}\r
428\r
429/**\r
430 Converts a text device path node to Hardware PCI device path structure.\r
431\r
432 @param TextDeviceNode The input Text device path node.\r
433\r
434 @return A pointer to Hardware PCI device path structure.\r
435\r
436**/\r
437EFI_DEVICE_PATH_PROTOCOL *\r
438DevPathFromTextPci (\r
439 IN CHAR16 *TextDeviceNode\r
440 )\r
441{\r
442 CHAR16 *FunctionStr;\r
443 CHAR16 *DeviceStr;\r
444 PCI_DEVICE_PATH *Pci;\r
445\r
446 DeviceStr = GetNextParamStr (&TextDeviceNode);\r
447 FunctionStr = GetNextParamStr (&TextDeviceNode);\r
448 Pci = (PCI_DEVICE_PATH *) CreateDeviceNode (\r
449 HARDWARE_DEVICE_PATH,\r
450 HW_PCI_DP,\r
451 (UINT16) sizeof (PCI_DEVICE_PATH)\r
452 );\r
453\r
454 Pci->Function = (UINT8) Strtoi (FunctionStr);\r
455 Pci->Device = (UINT8) Strtoi (DeviceStr);\r
456\r
457 return (EFI_DEVICE_PATH_PROTOCOL *) Pci;\r
458}\r
459\r
460/**\r
461 Converts a text device path node to Hardware PC card device path structure.\r
462\r
463 @param TextDeviceNode The input Text device path node.\r
464\r
465 @return A pointer to Hardware PC card device path structure.\r
466\r
467**/\r
468EFI_DEVICE_PATH_PROTOCOL *\r
469DevPathFromTextPcCard (\r
470 IN CHAR16 *TextDeviceNode\r
471 )\r
472{\r
473 CHAR16 *FunctionNumberStr;\r
474 PCCARD_DEVICE_PATH *Pccard;\r
475\r
476 FunctionNumberStr = GetNextParamStr (&TextDeviceNode);\r
477 Pccard = (PCCARD_DEVICE_PATH *) CreateDeviceNode (\r
478 HARDWARE_DEVICE_PATH,\r
479 HW_PCCARD_DP,\r
480 (UINT16) sizeof (PCCARD_DEVICE_PATH)\r
481 );\r
482\r
483 Pccard->FunctionNumber = (UINT8) Strtoi (FunctionNumberStr);\r
484\r
485 return (EFI_DEVICE_PATH_PROTOCOL *) Pccard;\r
486}\r
487\r
488/**\r
489 Converts a text device path node to Hardware memory map device path structure.\r
490\r
491 @param TextDeviceNode The input Text device path node.\r
492\r
493 @return A pointer to Hardware memory map device path structure.\r
494\r
495**/\r
496EFI_DEVICE_PATH_PROTOCOL *\r
497DevPathFromTextMemoryMapped (\r
498 IN CHAR16 *TextDeviceNode\r
499 )\r
500{\r
501 CHAR16 *MemoryTypeStr;\r
502 CHAR16 *StartingAddressStr;\r
503 CHAR16 *EndingAddressStr;\r
504 MEMMAP_DEVICE_PATH *MemMap;\r
505\r
506 MemoryTypeStr = GetNextParamStr (&TextDeviceNode);\r
507 StartingAddressStr = GetNextParamStr (&TextDeviceNode);\r
508 EndingAddressStr = GetNextParamStr (&TextDeviceNode);\r
509 MemMap = (MEMMAP_DEVICE_PATH *) CreateDeviceNode (\r
510 HARDWARE_DEVICE_PATH,\r
511 HW_MEMMAP_DP,\r
512 (UINT16) sizeof (MEMMAP_DEVICE_PATH)\r
513 );\r
514\r
515 MemMap->MemoryType = (UINT32) Strtoi (MemoryTypeStr);\r
516 Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);\r
517 Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);\r
518\r
519 return (EFI_DEVICE_PATH_PROTOCOL *) MemMap;\r
520}\r
521\r
522/**\r
523 Converts a text device path node to Vendor device path structure based on the input Type\r
524 and SubType.\r
525\r
526 @param TextDeviceNode The input Text device path node.\r
527 @param Type The type of device path node.\r
528 @param SubType The subtype of device path node.\r
529\r
530 @return A pointer to the newly-created Vendor device path structure.\r
531\r
532**/\r
533EFI_DEVICE_PATH_PROTOCOL *\r
534ConvertFromTextVendor (\r
535 IN CHAR16 *TextDeviceNode,\r
536 IN UINT8 Type,\r
537 IN UINT8 SubType\r
538 )\r
539{\r
540 CHAR16 *GuidStr;\r
541 CHAR16 *DataStr;\r
542 UINTN Length;\r
543 VENDOR_DEVICE_PATH *Vendor;\r
544\r
545 GuidStr = GetNextParamStr (&TextDeviceNode);\r
546\r
547 DataStr = GetNextParamStr (&TextDeviceNode);\r
548 Length = StrLen (DataStr);\r
549 //\r
550 // Two hex characters make up 1 buffer byte\r
551 //\r
552 Length = (Length + 1) / 2;\r
553\r
554 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
555 Type,\r
556 SubType,\r
557 (UINT16) (sizeof (VENDOR_DEVICE_PATH) + Length)\r
558 );\r
559\r
560 StrToGuid (GuidStr, &Vendor->Guid);\r
561 StrHexToBytes (DataStr, Length * 2, (UINT8 *) (Vendor + 1), Length);\r
562\r
563 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
564}\r
565\r
566/**\r
567 Converts a text device path node to Vendor Hardware device path structure.\r
568\r
569 @param TextDeviceNode The input Text device path node.\r
570\r
571 @return A pointer to the newly-created Vendor Hardware device path structure.\r
572\r
573**/\r
574EFI_DEVICE_PATH_PROTOCOL *\r
575DevPathFromTextVenHw (\r
576 IN CHAR16 *TextDeviceNode\r
577 )\r
578{\r
579 return ConvertFromTextVendor (\r
580 TextDeviceNode,\r
581 HARDWARE_DEVICE_PATH,\r
582 HW_VENDOR_DP\r
583 );\r
584}\r
585\r
586/**\r
587 Converts a text device path node to Hardware Controller device path structure.\r
588\r
589 @param TextDeviceNode The input Text device path node.\r
590\r
591 @return A pointer to the newly-created Hardware Controller device path structure.\r
592\r
593**/\r
594EFI_DEVICE_PATH_PROTOCOL *\r
595DevPathFromTextCtrl (\r
596 IN CHAR16 *TextDeviceNode\r
597 )\r
598{\r
599 CHAR16 *ControllerStr;\r
600 CONTROLLER_DEVICE_PATH *Controller;\r
601\r
602 ControllerStr = GetNextParamStr (&TextDeviceNode);\r
603 Controller = (CONTROLLER_DEVICE_PATH *) CreateDeviceNode (\r
604 HARDWARE_DEVICE_PATH,\r
605 HW_CONTROLLER_DP,\r
606 (UINT16) sizeof (CONTROLLER_DEVICE_PATH)\r
607 );\r
608 Controller->ControllerNumber = (UINT32) Strtoi (ControllerStr);\r
609\r
610 return (EFI_DEVICE_PATH_PROTOCOL *) Controller;\r
611}\r
612\r
613/**\r
614 Converts a text device path node to BMC device path structure.\r
615\r
616 @param TextDeviceNode The input Text device path node.\r
617\r
618 @return A pointer to the newly-created BMC device path structure.\r
619\r
620**/\r
621EFI_DEVICE_PATH_PROTOCOL *\r
622DevPathFromTextBmc (\r
623 IN CHAR16 *TextDeviceNode\r
624 )\r
625{\r
626 CHAR16 *InterfaceTypeStr;\r
627 CHAR16 *BaseAddressStr;\r
628 BMC_DEVICE_PATH *BmcDp;\r
629\r
630 InterfaceTypeStr = GetNextParamStr (&TextDeviceNode);\r
631 BaseAddressStr = GetNextParamStr (&TextDeviceNode);\r
632 BmcDp = (BMC_DEVICE_PATH *) CreateDeviceNode (\r
633 HARDWARE_DEVICE_PATH,\r
634 HW_BMC_DP,\r
635 (UINT16) sizeof (BMC_DEVICE_PATH)\r
636 );\r
637\r
638 BmcDp->InterfaceType = (UINT8) Strtoi (InterfaceTypeStr);\r
639 WriteUnaligned64 (\r
640 (UINT64 *) (&BmcDp->BaseAddress),\r
641 StrHexToUint64 (BaseAddressStr)\r
642 );\r
643\r
644 return (EFI_DEVICE_PATH_PROTOCOL *) BmcDp;\r
645}\r
646\r
647/**\r
648 Converts a generic ACPI text device path node to ACPI device path structure.\r
649\r
650 @param TextDeviceNode The input Text device path node.\r
651\r
652 @return A pointer to ACPI device path structure.\r
653\r
654**/\r
655EFI_DEVICE_PATH_PROTOCOL *\r
656DevPathFromTextAcpiPath (\r
657 IN CHAR16 *TextDeviceNode\r
658 )\r
659{\r
660 return DevPathFromTextGenericPath (ACPI_DEVICE_PATH, TextDeviceNode);\r
661}\r
662\r
663/**\r
664 Converts a string to EisaId.\r
665\r
666 @param Text The input string.\r
667\r
668 @return UINT32 EISA ID.\r
669**/\r
670UINT32\r
671EisaIdFromText (\r
672 IN CHAR16 *Text\r
673 )\r
674{\r
675 return (((Text[0] - 'A' + 1) & 0x1f) << 10)\r
676 + (((Text[1] - 'A' + 1) & 0x1f) << 5)\r
677 + (((Text[2] - 'A' + 1) & 0x1f) << 0)\r
678 + (UINT32) (StrHexToUintn (&Text[3]) << 16)\r
679 ;\r
680}\r
681\r
682/**\r
683 Converts a text device path node to ACPI HID device path structure.\r
684\r
685 @param TextDeviceNode The input Text device path node.\r
686\r
687 @return A pointer to the newly-created ACPI HID device path structure.\r
688\r
689**/\r
690EFI_DEVICE_PATH_PROTOCOL *\r
691DevPathFromTextAcpi (\r
692 IN CHAR16 *TextDeviceNode\r
693 )\r
694{\r
695 CHAR16 *HIDStr;\r
696 CHAR16 *UIDStr;\r
697 ACPI_HID_DEVICE_PATH *Acpi;\r
698\r
699 HIDStr = GetNextParamStr (&TextDeviceNode);\r
700 UIDStr = GetNextParamStr (&TextDeviceNode);\r
701 Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r
702 ACPI_DEVICE_PATH,\r
703 ACPI_DP,\r
704 (UINT16) sizeof (ACPI_HID_DEVICE_PATH)\r
705 );\r
706\r
707 Acpi->HID = EisaIdFromText (HIDStr);\r
708 Acpi->UID = (UINT32) Strtoi (UIDStr);\r
709\r
710 return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r
711}\r
712\r
713/**\r
714 Converts a text device path node to ACPI HID device path structure.\r
715\r
716 @param TextDeviceNode The input Text device path node.\r
717 @param PnPId The input plug and play identification.\r
718\r
719 @return A pointer to the newly-created ACPI HID device path structure.\r
720\r
721**/\r
722EFI_DEVICE_PATH_PROTOCOL *\r
723ConvertFromTextAcpi (\r
724 IN CHAR16 *TextDeviceNode,\r
725 IN UINT32 PnPId\r
726 )\r
727{\r
728 CHAR16 *UIDStr;\r
729 ACPI_HID_DEVICE_PATH *Acpi;\r
730\r
731 UIDStr = GetNextParamStr (&TextDeviceNode);\r
732 Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r
733 ACPI_DEVICE_PATH,\r
734 ACPI_DP,\r
735 (UINT16) sizeof (ACPI_HID_DEVICE_PATH)\r
736 );\r
737\r
738 Acpi->HID = EFI_PNP_ID (PnPId);\r
739 Acpi->UID = (UINT32) Strtoi (UIDStr);\r
740\r
741 return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r
742}\r
743\r
744/**\r
745 Converts a text device path node to PCI root device path structure.\r
746\r
747 @param TextDeviceNode The input Text device path node.\r
748\r
749 @return A pointer to the newly-created PCI root device path structure.\r
750\r
751**/\r
752EFI_DEVICE_PATH_PROTOCOL *\r
753DevPathFromTextPciRoot (\r
754 IN CHAR16 *TextDeviceNode\r
755 )\r
756{\r
757 return ConvertFromTextAcpi (TextDeviceNode, 0x0a03);\r
758}\r
759\r
760/**\r
761 Converts a text device path node to PCIE root device path structure.\r
762\r
763 @param TextDeviceNode The input Text device path node.\r
764\r
765 @return A pointer to the newly-created PCIE root device path structure.\r
766\r
767**/\r
768EFI_DEVICE_PATH_PROTOCOL *\r
769DevPathFromTextPcieRoot (\r
770 IN CHAR16 *TextDeviceNode\r
771 )\r
772{\r
773 return ConvertFromTextAcpi (TextDeviceNode, 0x0a08);\r
774}\r
775\r
776/**\r
777 Converts a text device path node to Floppy device path structure.\r
778\r
779 @param TextDeviceNode The input Text device path node.\r
780\r
781 @return A pointer to the newly-created Floppy device path structure.\r
782\r
783**/\r
784EFI_DEVICE_PATH_PROTOCOL *\r
785DevPathFromTextFloppy (\r
786 IN CHAR16 *TextDeviceNode\r
787 )\r
788{\r
789 return ConvertFromTextAcpi (TextDeviceNode, 0x0604);\r
790}\r
791\r
792/**\r
793 Converts a text device path node to Keyboard device path structure.\r
794\r
795 @param TextDeviceNode The input Text device path node.\r
796\r
797 @return A pointer to the newly-created Keyboard device path structure.\r
798\r
799**/\r
800EFI_DEVICE_PATH_PROTOCOL *\r
801DevPathFromTextKeyboard (\r
802 IN CHAR16 *TextDeviceNode\r
803 )\r
804{\r
805 return ConvertFromTextAcpi (TextDeviceNode, 0x0301);\r
806}\r
807\r
808/**\r
809 Converts a text device path node to Serial device path structure.\r
810\r
811 @param TextDeviceNode The input Text device path node.\r
812\r
813 @return A pointer to the newly-created Serial device path structure.\r
814\r
815**/\r
816EFI_DEVICE_PATH_PROTOCOL *\r
817DevPathFromTextSerial (\r
818 IN CHAR16 *TextDeviceNode\r
819 )\r
820{\r
821 return ConvertFromTextAcpi (TextDeviceNode, 0x0501);\r
822}\r
823\r
824/**\r
825 Converts a text device path node to Parallel Port device path structure.\r
826\r
827 @param TextDeviceNode The input Text device path node.\r
828\r
829 @return A pointer to the newly-created Parallel Port device path structure.\r
830\r
831**/\r
832EFI_DEVICE_PATH_PROTOCOL *\r
833DevPathFromTextParallelPort (\r
834 IN CHAR16 *TextDeviceNode\r
835 )\r
836{\r
837 return ConvertFromTextAcpi (TextDeviceNode, 0x0401);\r
838}\r
839\r
840/**\r
841 Converts a text device path node to ACPI extension device path structure.\r
842\r
843 @param TextDeviceNode The input Text device path node.\r
844\r
845 @return A pointer to the newly-created ACPI extension device path structure.\r
846\r
847**/\r
848EFI_DEVICE_PATH_PROTOCOL *\r
849DevPathFromTextAcpiEx (\r
850 IN CHAR16 *TextDeviceNode\r
851 )\r
852{\r
853 CHAR16 *HIDStr;\r
854 CHAR16 *CIDStr;\r
855 CHAR16 *UIDStr;\r
856 CHAR16 *HIDSTRStr;\r
857 CHAR16 *CIDSTRStr;\r
858 CHAR16 *UIDSTRStr;\r
859 CHAR8 *AsciiStr;\r
860 UINT16 Length;\r
861 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r
862\r
863 HIDStr = GetNextParamStr (&TextDeviceNode);\r
864 CIDStr = GetNextParamStr (&TextDeviceNode);\r
865 UIDStr = GetNextParamStr (&TextDeviceNode);\r
866 HIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
867 CIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
868 UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
869\r
870 Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (HIDSTRStr) + 1);\r
871 Length = (UINT16) (Length + StrLen (UIDSTRStr) + 1);\r
872 Length = (UINT16) (Length + StrLen (CIDSTRStr) + 1);\r
873 AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r
874 ACPI_DEVICE_PATH,\r
875 ACPI_EXTENDED_DP,\r
876 Length\r
877 );\r
878\r
879 AcpiEx->HID = EisaIdFromText (HIDStr);\r
880 AcpiEx->CID = EisaIdFromText (CIDStr);\r
881 AcpiEx->UID = (UINT32) Strtoi (UIDStr);\r
882\r
883 AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
884 StrToAscii (HIDSTRStr, &AsciiStr);\r
885 StrToAscii (UIDSTRStr, &AsciiStr);\r
886 StrToAscii (CIDSTRStr, &AsciiStr);\r
887\r
888 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r
889}\r
890\r
891/**\r
892 Converts a text device path node to ACPI extension device path structure.\r
893\r
894 @param TextDeviceNode The input Text device path node.\r
895\r
896 @return A pointer to the newly-created ACPI extension device path structure.\r
897\r
898**/\r
899EFI_DEVICE_PATH_PROTOCOL *\r
900DevPathFromTextAcpiExp (\r
901 IN CHAR16 *TextDeviceNode\r
902 )\r
903{\r
904 CHAR16 *HIDStr;\r
905 CHAR16 *CIDStr;\r
906 CHAR16 *UIDSTRStr;\r
907 CHAR8 *AsciiStr;\r
908 UINT16 Length;\r
909 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r
910\r
911 HIDStr = GetNextParamStr (&TextDeviceNode);\r
912 CIDStr = GetNextParamStr (&TextDeviceNode);\r
913 UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
914 Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (UIDSTRStr) + 3);\r
915 AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r
916 ACPI_DEVICE_PATH,\r
917 ACPI_EXTENDED_DP,\r
918 Length\r
919 );\r
920\r
921 AcpiEx->HID = EisaIdFromText (HIDStr);\r
922 AcpiEx->CID = EisaIdFromText (CIDStr);\r
923 AcpiEx->UID = 0;\r
924\r
925 AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
926 //\r
927 // HID string is NULL\r
928 //\r
929 *AsciiStr = '\0';\r
930 //\r
931 // Convert UID string\r
932 //\r
933 AsciiStr++;\r
934 StrToAscii (UIDSTRStr, &AsciiStr);\r
935 //\r
936 // CID string is NULL\r
937 //\r
938 *AsciiStr = '\0';\r
939\r
940 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r
941}\r
942\r
943/**\r
944 Converts a text device path node to ACPI _ADR device path structure.\r
945\r
946 @param TextDeviceNode The input Text device path node.\r
947\r
948 @return A pointer to the newly-created ACPI _ADR device path structure.\r
949\r
950**/\r
951EFI_DEVICE_PATH_PROTOCOL *\r
952DevPathFromTextAcpiAdr (\r
953 IN CHAR16 *TextDeviceNode\r
954 )\r
955{\r
956 CHAR16 *DisplayDeviceStr;\r
957 ACPI_ADR_DEVICE_PATH *AcpiAdr;\r
958 UINTN Index;\r
959 UINTN Length;\r
960\r
961 AcpiAdr = (ACPI_ADR_DEVICE_PATH *) CreateDeviceNode (\r
962 ACPI_DEVICE_PATH,\r
963 ACPI_ADR_DP,\r
964 (UINT16) sizeof (ACPI_ADR_DEVICE_PATH)\r
965 );\r
966 ASSERT (AcpiAdr != NULL);\r
967\r
968 for (Index = 0; ; Index++) {\r
969 DisplayDeviceStr = GetNextParamStr (&TextDeviceNode);\r
970 if (IS_NULL (*DisplayDeviceStr)) {\r
971 break;\r
972 }\r
973 if (Index > 0) {\r
974 Length = DevicePathNodeLength (AcpiAdr);\r
975 AcpiAdr = ReallocatePool (\r
976 Length,\r
977 Length + sizeof (UINT32),\r
978 AcpiAdr\r
979 );\r
980 ASSERT (AcpiAdr != NULL);\r
981 SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));\r
982 }\r
983\r
984 (&AcpiAdr->ADR)[Index] = (UINT32) Strtoi (DisplayDeviceStr);\r
985 }\r
986\r
987 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr;\r
988}\r
989\r
990/**\r
991 Converts a generic messaging text device path node to messaging device path structure.\r
992\r
993 @param TextDeviceNode The input Text device path node.\r
994\r
995 @return A pointer to messaging device path structure.\r
996\r
997**/\r
998EFI_DEVICE_PATH_PROTOCOL *\r
999DevPathFromTextMsg (\r
1000 IN CHAR16 *TextDeviceNode\r
1001 )\r
1002{\r
1003 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH, TextDeviceNode);\r
1004}\r
1005\r
1006/**\r
1007 Converts a text device path node to Parallel Port device path structure.\r
1008\r
1009 @param TextDeviceNode The input Text device path node.\r
1010\r
1011 @return A pointer to the newly-created Parallel Port device path structure.\r
1012\r
1013**/\r
1014EFI_DEVICE_PATH_PROTOCOL *\r
1015DevPathFromTextAta (\r
1016IN CHAR16 *TextDeviceNode\r
1017)\r
1018{\r
1019 CHAR16 *PrimarySecondaryStr;\r
1020 CHAR16 *SlaveMasterStr;\r
1021 CHAR16 *LunStr;\r
1022 ATAPI_DEVICE_PATH *Atapi;\r
1023\r
1024 Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (\r
1025 MESSAGING_DEVICE_PATH,\r
1026 MSG_ATAPI_DP,\r
1027 (UINT16) sizeof (ATAPI_DEVICE_PATH)\r
1028 );\r
1029\r
1030 PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);\r
1031 SlaveMasterStr = GetNextParamStr (&TextDeviceNode);\r
1032 LunStr = GetNextParamStr (&TextDeviceNode);\r
1033\r
1034 if (StrCmp (PrimarySecondaryStr, L"Primary") == 0) {\r
1035 Atapi->PrimarySecondary = 0;\r
1036 } else if (StrCmp (PrimarySecondaryStr, L"Secondary") == 0) {\r
1037 Atapi->PrimarySecondary = 1;\r
1038 } else {\r
1039 Atapi->PrimarySecondary = (UINT8) Strtoi (PrimarySecondaryStr);\r
1040 }\r
1041 if (StrCmp (SlaveMasterStr, L"Master") == 0) {\r
1042 Atapi->SlaveMaster = 0;\r
1043 } else if (StrCmp (SlaveMasterStr, L"Slave") == 0) {\r
1044 Atapi->SlaveMaster = 1;\r
1045 } else {\r
1046 Atapi->SlaveMaster = (UINT8) Strtoi (SlaveMasterStr);\r
1047 }\r
1048\r
1049 Atapi->Lun = (UINT16) Strtoi (LunStr);\r
1050\r
1051 return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;\r
1052}\r
1053\r
1054/**\r
1055 Converts a text device path node to SCSI device path structure.\r
1056\r
1057 @param TextDeviceNode The input Text device path node.\r
1058\r
1059 @return A pointer to the newly-created SCSI device path structure.\r
1060\r
1061**/\r
1062EFI_DEVICE_PATH_PROTOCOL *\r
1063DevPathFromTextScsi (\r
1064 IN CHAR16 *TextDeviceNode\r
1065 )\r
1066{\r
1067 CHAR16 *PunStr;\r
1068 CHAR16 *LunStr;\r
1069 SCSI_DEVICE_PATH *Scsi;\r
1070\r
1071 PunStr = GetNextParamStr (&TextDeviceNode);\r
1072 LunStr = GetNextParamStr (&TextDeviceNode);\r
1073 Scsi = (SCSI_DEVICE_PATH *) CreateDeviceNode (\r
1074 MESSAGING_DEVICE_PATH,\r
1075 MSG_SCSI_DP,\r
1076 (UINT16) sizeof (SCSI_DEVICE_PATH)\r
1077 );\r
1078\r
1079 Scsi->Pun = (UINT16) Strtoi (PunStr);\r
1080 Scsi->Lun = (UINT16) Strtoi (LunStr);\r
1081\r
1082 return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;\r
1083}\r
1084\r
1085/**\r
1086 Converts a text device path node to Fibre device path structure.\r
1087\r
1088 @param TextDeviceNode The input Text device path node.\r
1089\r
1090 @return A pointer to the newly-created Fibre device path structure.\r
1091\r
1092**/\r
1093EFI_DEVICE_PATH_PROTOCOL *\r
1094DevPathFromTextFibre (\r
1095 IN CHAR16 *TextDeviceNode\r
1096 )\r
1097{\r
1098 CHAR16 *WWNStr;\r
1099 CHAR16 *LunStr;\r
1100 FIBRECHANNEL_DEVICE_PATH *Fibre;\r
1101\r
1102 WWNStr = GetNextParamStr (&TextDeviceNode);\r
1103 LunStr = GetNextParamStr (&TextDeviceNode);\r
1104 Fibre = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (\r
1105 MESSAGING_DEVICE_PATH,\r
1106 MSG_FIBRECHANNEL_DP,\r
1107 (UINT16) sizeof (FIBRECHANNEL_DEVICE_PATH)\r
1108 );\r
1109\r
1110 Fibre->Reserved = 0;\r
1111 Strtoi64 (WWNStr, &Fibre->WWN);\r
1112 Strtoi64 (LunStr, &Fibre->Lun);\r
1113\r
1114 return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;\r
1115}\r
1116\r
1117/**\r
1118 Converts a text device path node to FibreEx device path structure.\r
1119\r
1120 @param TextDeviceNode The input Text device path node.\r
1121\r
1122 @return A pointer to the newly-created FibreEx device path structure.\r
1123\r
1124**/\r
1125EFI_DEVICE_PATH_PROTOCOL *\r
1126DevPathFromTextFibreEx (\r
1127 IN CHAR16 *TextDeviceNode\r
1128 )\r
1129{\r
1130 CHAR16 *WWNStr;\r
1131 CHAR16 *LunStr;\r
1132 FIBRECHANNELEX_DEVICE_PATH *FibreEx;\r
1133\r
1134 WWNStr = GetNextParamStr (&TextDeviceNode);\r
1135 LunStr = GetNextParamStr (&TextDeviceNode);\r
1136 FibreEx = (FIBRECHANNELEX_DEVICE_PATH *) CreateDeviceNode (\r
1137 MESSAGING_DEVICE_PATH,\r
1138 MSG_FIBRECHANNELEX_DP,\r
1139 (UINT16) sizeof (FIBRECHANNELEX_DEVICE_PATH)\r
1140 );\r
1141\r
1142 FibreEx->Reserved = 0;\r
1143 Strtoi64 (WWNStr, (UINT64 *) (&FibreEx->WWN));\r
1144 Strtoi64 (LunStr, (UINT64 *) (&FibreEx->Lun));\r
1145\r
1146 *(UINT64 *) (&FibreEx->WWN) = SwapBytes64 (*(UINT64 *) (&FibreEx->WWN));\r
1147 *(UINT64 *) (&FibreEx->Lun) = SwapBytes64 (*(UINT64 *) (&FibreEx->Lun));\r
1148\r
1149 return (EFI_DEVICE_PATH_PROTOCOL *) FibreEx;\r
1150}\r
1151\r
1152/**\r
1153 Converts a text device path node to 1394 device path structure.\r
1154\r
1155 @param TextDeviceNode The input Text device path node.\r
1156\r
1157 @return A pointer to the newly-created 1394 device path structure.\r
1158\r
1159**/\r
1160EFI_DEVICE_PATH_PROTOCOL *\r
1161DevPathFromText1394 (\r
1162 IN CHAR16 *TextDeviceNode\r
1163 )\r
1164{\r
1165 CHAR16 *GuidStr;\r
1166 F1394_DEVICE_PATH *F1394DevPath;\r
1167\r
1168 GuidStr = GetNextParamStr (&TextDeviceNode);\r
1169 F1394DevPath = (F1394_DEVICE_PATH *) CreateDeviceNode (\r
1170 MESSAGING_DEVICE_PATH,\r
1171 MSG_1394_DP,\r
1172 (UINT16) sizeof (F1394_DEVICE_PATH)\r
1173 );\r
1174\r
1175 F1394DevPath->Reserved = 0;\r
1176 F1394DevPath->Guid = StrHexToUint64 (GuidStr);\r
1177\r
1178 return (EFI_DEVICE_PATH_PROTOCOL *) F1394DevPath;\r
1179}\r
1180\r
1181/**\r
1182 Converts a text device path node to USB device path structure.\r
1183\r
1184 @param TextDeviceNode The input Text device path node.\r
1185\r
1186 @return A pointer to the newly-created USB device path structure.\r
1187\r
1188**/\r
1189EFI_DEVICE_PATH_PROTOCOL *\r
1190DevPathFromTextUsb (\r
1191 IN CHAR16 *TextDeviceNode\r
1192 )\r
1193{\r
1194 CHAR16 *PortStr;\r
1195 CHAR16 *InterfaceStr;\r
1196 USB_DEVICE_PATH *Usb;\r
1197\r
1198 PortStr = GetNextParamStr (&TextDeviceNode);\r
1199 InterfaceStr = GetNextParamStr (&TextDeviceNode);\r
1200 Usb = (USB_DEVICE_PATH *) CreateDeviceNode (\r
1201 MESSAGING_DEVICE_PATH,\r
1202 MSG_USB_DP,\r
1203 (UINT16) sizeof (USB_DEVICE_PATH)\r
1204 );\r
1205\r
1206 Usb->ParentPortNumber = (UINT8) Strtoi (PortStr);\r
1207 Usb->InterfaceNumber = (UINT8) Strtoi (InterfaceStr);\r
1208\r
1209 return (EFI_DEVICE_PATH_PROTOCOL *) Usb;\r
1210}\r
1211\r
1212/**\r
1213 Converts a text device path node to I20 device path structure.\r
1214\r
1215 @param TextDeviceNode The input Text device path node.\r
1216\r
1217 @return A pointer to the newly-created I20 device path structure.\r
1218\r
1219**/\r
1220EFI_DEVICE_PATH_PROTOCOL *\r
1221DevPathFromTextI2O (\r
1222 IN CHAR16 *TextDeviceNode\r
1223 )\r
1224{\r
1225 CHAR16 *TIDStr;\r
1226 I2O_DEVICE_PATH *I2ODevPath;\r
1227\r
1228 TIDStr = GetNextParamStr (&TextDeviceNode);\r
1229 I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode (\r
1230 MESSAGING_DEVICE_PATH,\r
1231 MSG_I2O_DP,\r
1232 (UINT16) sizeof (I2O_DEVICE_PATH)\r
1233 );\r
1234\r
1235 I2ODevPath->Tid = (UINT32) Strtoi (TIDStr);\r
1236\r
1237 return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath;\r
1238}\r
1239\r
1240/**\r
1241 Converts a text device path node to Infini Band device path structure.\r
1242\r
1243 @param TextDeviceNode The input Text device path node.\r
1244\r
1245 @return A pointer to the newly-created Infini Band device path structure.\r
1246\r
1247**/\r
1248EFI_DEVICE_PATH_PROTOCOL *\r
1249DevPathFromTextInfiniband (\r
1250 IN CHAR16 *TextDeviceNode\r
1251 )\r
1252{\r
1253 CHAR16 *FlagsStr;\r
1254 CHAR16 *GuidStr;\r
1255 CHAR16 *SidStr;\r
1256 CHAR16 *TidStr;\r
1257 CHAR16 *DidStr;\r
1258 INFINIBAND_DEVICE_PATH *InfiniBand;\r
1259\r
1260 FlagsStr = GetNextParamStr (&TextDeviceNode);\r
1261 GuidStr = GetNextParamStr (&TextDeviceNode);\r
1262 SidStr = GetNextParamStr (&TextDeviceNode);\r
1263 TidStr = GetNextParamStr (&TextDeviceNode);\r
1264 DidStr = GetNextParamStr (&TextDeviceNode);\r
1265 InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (\r
1266 MESSAGING_DEVICE_PATH,\r
1267 MSG_INFINIBAND_DP,\r
1268 (UINT16) sizeof (INFINIBAND_DEVICE_PATH)\r
1269 );\r
1270\r
1271 InfiniBand->ResourceFlags = (UINT32) Strtoi (FlagsStr);\r
1272 StrToGuid (GuidStr, (EFI_GUID *) InfiniBand->PortGid);\r
1273 Strtoi64 (SidStr, &InfiniBand->ServiceId);\r
1274 Strtoi64 (TidStr, &InfiniBand->TargetPortId);\r
1275 Strtoi64 (DidStr, &InfiniBand->DeviceId);\r
1276\r
1277 return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;\r
1278}\r
1279\r
1280/**\r
1281 Converts a text device path node to Vendor-Defined Messaging device path structure.\r
1282\r
1283 @param TextDeviceNode The input Text device path node.\r
1284\r
1285 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.\r
1286\r
1287**/\r
1288EFI_DEVICE_PATH_PROTOCOL *\r
1289DevPathFromTextVenMsg (\r
1290 IN CHAR16 *TextDeviceNode\r
1291 )\r
1292{\r
1293 return ConvertFromTextVendor (\r
1294 TextDeviceNode,\r
1295 MESSAGING_DEVICE_PATH,\r
1296 MSG_VENDOR_DP\r
1297 );\r
1298}\r
1299\r
1300/**\r
1301 Converts a text device path node to Vendor defined PC-ANSI device path structure.\r
1302\r
1303 @param TextDeviceNode The input Text device path node.\r
1304\r
1305 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.\r
1306\r
1307**/\r
1308EFI_DEVICE_PATH_PROTOCOL *\r
1309DevPathFromTextVenPcAnsi (\r
1310 IN CHAR16 *TextDeviceNode\r
1311 )\r
1312{\r
1313 VENDOR_DEVICE_PATH *Vendor;\r
1314\r
1315 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1316 MESSAGING_DEVICE_PATH,\r
1317 MSG_VENDOR_DP,\r
1318 (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
1319 CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);\r
1320\r
1321 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
1322}\r
1323\r
1324/**\r
1325 Converts a text device path node to Vendor defined VT100 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 VT100 device path structure.\r
1330\r
1331**/\r
1332EFI_DEVICE_PATH_PROTOCOL *\r
1333DevPathFromTextVenVt100 (\r
1334 IN CHAR16 *TextDeviceNode\r
1335 )\r
1336{\r
1337 VENDOR_DEVICE_PATH *Vendor;\r
1338\r
1339 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1340 MESSAGING_DEVICE_PATH,\r
1341 MSG_VENDOR_DP,\r
1342 (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
1343 CopyGuid (&Vendor->Guid, &gEfiVT100Guid);\r
1344\r
1345 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
1346}\r
1347\r
1348/**\r
1349 Converts a text device path node to Vendor defined VT100 Plus device path structure.\r
1350\r
1351 @param TextDeviceNode The input Text device path node.\r
1352\r
1353 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.\r
1354\r
1355**/\r
1356EFI_DEVICE_PATH_PROTOCOL *\r
1357DevPathFromTextVenVt100Plus (\r
1358 IN CHAR16 *TextDeviceNode\r
1359 )\r
1360{\r
1361 VENDOR_DEVICE_PATH *Vendor;\r
1362\r
1363 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1364 MESSAGING_DEVICE_PATH,\r
1365 MSG_VENDOR_DP,\r
1366 (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
1367 CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);\r
1368\r
1369 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
1370}\r
1371\r
1372/**\r
1373 Converts a text device path node to Vendor defined UTF8 device path structure.\r
1374\r
1375 @param TextDeviceNode The input Text device path node.\r
1376\r
1377 @return A pointer to the newly-created Vendor defined UTF8 device path structure.\r
1378\r
1379**/\r
1380EFI_DEVICE_PATH_PROTOCOL *\r
1381DevPathFromTextVenUtf8 (\r
1382 IN CHAR16 *TextDeviceNode\r
1383 )\r
1384{\r
1385 VENDOR_DEVICE_PATH *Vendor;\r
1386\r
1387 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1388 MESSAGING_DEVICE_PATH,\r
1389 MSG_VENDOR_DP,\r
1390 (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
1391 CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);\r
1392\r
1393 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
1394}\r
1395\r
1396/**\r
1397 Converts a text device path node to UART Flow Control device path structure.\r
1398\r
1399 @param TextDeviceNode The input Text device path node.\r
1400\r
1401 @return A pointer to the newly-created UART Flow Control device path structure.\r
1402\r
1403**/\r
1404EFI_DEVICE_PATH_PROTOCOL *\r
1405DevPathFromTextUartFlowCtrl (\r
1406 IN CHAR16 *TextDeviceNode\r
1407 )\r
1408{\r
1409 CHAR16 *ValueStr;\r
1410 UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;\r
1411\r
1412 ValueStr = GetNextParamStr (&TextDeviceNode);\r
1413 UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (\r
1414 MESSAGING_DEVICE_PATH,\r
1415 MSG_VENDOR_DP,\r
1416 (UINT16) sizeof (UART_FLOW_CONTROL_DEVICE_PATH)\r
1417 );\r
1418\r
1419 CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);\r
1420 if (StrCmp (ValueStr, L"XonXoff") == 0) {\r
1421 UartFlowControl->FlowControlMap = 2;\r
1422 } else if (StrCmp (ValueStr, L"Hardware") == 0) {\r
1423 UartFlowControl->FlowControlMap = 1;\r
1424 } else {\r
1425 UartFlowControl->FlowControlMap = 0;\r
1426 }\r
1427\r
1428 return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;\r
1429}\r
1430\r
1431/**\r
1432 Converts a text device path node to Serial Attached SCSI 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 Serial Attached SCSI device path structure.\r
1437\r
1438**/\r
1439EFI_DEVICE_PATH_PROTOCOL *\r
1440DevPathFromTextSAS (\r
1441 IN CHAR16 *TextDeviceNode\r
1442 )\r
1443{\r
1444 CHAR16 *AddressStr;\r
1445 CHAR16 *LunStr;\r
1446 CHAR16 *RTPStr;\r
1447 CHAR16 *SASSATAStr;\r
1448 CHAR16 *LocationStr;\r
1449 CHAR16 *ConnectStr;\r
1450 CHAR16 *DriveBayStr;\r
1451 CHAR16 *ReservedStr;\r
1452 UINT16 Info;\r
1453 UINT16 Uint16;\r
1454 SAS_DEVICE_PATH *Sas;\r
1455\r
1456 AddressStr = GetNextParamStr (&TextDeviceNode);\r
1457 LunStr = GetNextParamStr (&TextDeviceNode);\r
1458 RTPStr = GetNextParamStr (&TextDeviceNode);\r
1459 SASSATAStr = GetNextParamStr (&TextDeviceNode);\r
1460 LocationStr = GetNextParamStr (&TextDeviceNode);\r
1461 ConnectStr = GetNextParamStr (&TextDeviceNode);\r
1462 DriveBayStr = GetNextParamStr (&TextDeviceNode);\r
1463 ReservedStr = GetNextParamStr (&TextDeviceNode);\r
1464 Sas = (SAS_DEVICE_PATH *) CreateDeviceNode (\r
1465 MESSAGING_DEVICE_PATH,\r
1466 MSG_VENDOR_DP,\r
1467 (UINT16) sizeof (SAS_DEVICE_PATH)\r
1468 );\r
1469\r
1470 CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid);\r
1471 Strtoi64 (AddressStr, &Sas->SasAddress);\r
1472 Strtoi64 (LunStr, &Sas->Lun);\r
1473 Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr);\r
1474\r
1475 if (StrCmp (SASSATAStr, L"NoTopology") == 0) {\r
1476 Info = 0x0;\r
1477\r
1478 } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {\r
1479\r
1480 Uint16 = (UINT16) Strtoi (DriveBayStr);\r
1481 if (Uint16 == 0) {\r
1482 Info = 0x1;\r
1483 } else {\r
1484 Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));\r
1485 }\r
1486\r
1487 if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
1488 Info |= BIT4;\r
1489 }\r
1490\r
1491 //\r
1492 // Location is an integer between 0 and 1 or else\r
1493 // the keyword Internal (0) or External (1).\r
1494 //\r
1495 if (StrCmp (LocationStr, L"External") == 0) {\r
1496 Uint16 = 1;\r
1497 } else if (StrCmp (LocationStr, L"Internal") == 0) {\r
1498 Uint16 = 0;\r
1499 } else {\r
1500 Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);\r
1501 }\r
1502 Info |= (Uint16 << 5);\r
1503\r
1504 //\r
1505 // Connect is an integer between 0 and 3 or else\r
1506 // the keyword Direct (0) or Expanded (1).\r
1507 //\r
1508 if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
1509 Uint16 = 1;\r
1510 } else if (StrCmp (ConnectStr, L"Direct") == 0) {\r
1511 Uint16 = 0;\r
1512 } else {\r
1513 Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));\r
1514 }\r
1515 Info |= (Uint16 << 6);\r
1516\r
1517 } else {\r
1518 Info = (UINT16) Strtoi (SASSATAStr);\r
1519 }\r
1520\r
1521 Sas->DeviceTopology = Info;\r
1522 Sas->Reserved = (UINT32) Strtoi (ReservedStr);\r
1523\r
1524 return (EFI_DEVICE_PATH_PROTOCOL *) Sas;\r
1525}\r
1526\r
1527/**\r
1528 Converts a text device path node to Serial Attached SCSI Ex device path structure.\r
1529\r
1530 @param TextDeviceNode The input Text device path node.\r
1531\r
1532 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.\r
1533\r
1534**/\r
1535EFI_DEVICE_PATH_PROTOCOL *\r
1536DevPathFromTextSasEx (\r
1537 IN CHAR16 *TextDeviceNode\r
1538 )\r
1539{\r
1540 CHAR16 *AddressStr;\r
1541 CHAR16 *LunStr;\r
1542 CHAR16 *RTPStr;\r
1543 CHAR16 *SASSATAStr;\r
1544 CHAR16 *LocationStr;\r
1545 CHAR16 *ConnectStr;\r
1546 CHAR16 *DriveBayStr;\r
1547 UINT16 Info;\r
1548 UINT16 Uint16;\r
1549 UINT64 SasAddress;\r
1550 UINT64 Lun;\r
1551 SASEX_DEVICE_PATH *SasEx;\r
1552\r
1553 AddressStr = GetNextParamStr (&TextDeviceNode);\r
1554 LunStr = GetNextParamStr (&TextDeviceNode);\r
1555 RTPStr = GetNextParamStr (&TextDeviceNode);\r
1556 SASSATAStr = GetNextParamStr (&TextDeviceNode);\r
1557 LocationStr = GetNextParamStr (&TextDeviceNode);\r
1558 ConnectStr = GetNextParamStr (&TextDeviceNode);\r
1559 DriveBayStr = GetNextParamStr (&TextDeviceNode);\r
1560 SasEx = (SASEX_DEVICE_PATH *) CreateDeviceNode (\r
1561 MESSAGING_DEVICE_PATH,\r
1562 MSG_SASEX_DP,\r
1563 (UINT16) sizeof (SASEX_DEVICE_PATH)\r
1564 );\r
1565\r
1566 Strtoi64 (AddressStr, &SasAddress);\r
1567 Strtoi64 (LunStr, &Lun);\r
1568 WriteUnaligned64 ((UINT64 *) &SasEx->SasAddress, SwapBytes64 (SasAddress));\r
1569 WriteUnaligned64 ((UINT64 *) &SasEx->Lun, SwapBytes64 (Lun));\r
1570 SasEx->RelativeTargetPort = (UINT16) Strtoi (RTPStr);\r
1571\r
1572 if (StrCmp (SASSATAStr, L"NoTopology") == 0) {\r
1573 Info = 0x0;\r
1574\r
1575 } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {\r
1576\r
1577 Uint16 = (UINT16) Strtoi (DriveBayStr);\r
1578 if (Uint16 == 0) {\r
1579 Info = 0x1;\r
1580 } else {\r
1581 Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));\r
1582 }\r
1583\r
1584 if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
1585 Info |= BIT4;\r
1586 }\r
1587\r
1588 //\r
1589 // Location is an integer between 0 and 1 or else\r
1590 // the keyword Internal (0) or External (1).\r
1591 //\r
1592 if (StrCmp (LocationStr, L"External") == 0) {\r
1593 Uint16 = 1;\r
1594 } else if (StrCmp (LocationStr, L"Internal") == 0) {\r
1595 Uint16 = 0;\r
1596 } else {\r
1597 Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);\r
1598 }\r
1599 Info |= (Uint16 << 5);\r
1600\r
1601 //\r
1602 // Connect is an integer between 0 and 3 or else\r
1603 // the keyword Direct (0) or Expanded (1).\r
1604 //\r
1605 if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
1606 Uint16 = 1;\r
1607 } else if (StrCmp (ConnectStr, L"Direct") == 0) {\r
1608 Uint16 = 0;\r
1609 } else {\r
1610 Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));\r
1611 }\r
1612 Info |= (Uint16 << 6);\r
1613\r
1614 } else {\r
1615 Info = (UINT16) Strtoi (SASSATAStr);\r
1616 }\r
1617\r
1618 SasEx->DeviceTopology = Info;\r
1619\r
1620 return (EFI_DEVICE_PATH_PROTOCOL *) SasEx;\r
1621}\r
1622\r
1623/**\r
1624 Converts a text device path node to NVM Express Namespace device path structure.\r
1625\r
1626 @param TextDeviceNode The input Text device path node.\r
1627\r
1628 @return A pointer to the newly-created NVM Express Namespace device path structure.\r
1629\r
1630**/\r
1631EFI_DEVICE_PATH_PROTOCOL *\r
1632DevPathFromTextNVMe (\r
1633 IN CHAR16 *TextDeviceNode\r
1634 )\r
1635{\r
1636 CHAR16 *NamespaceIdStr;\r
1637 CHAR16 *NamespaceUuidStr;\r
1638 NVME_NAMESPACE_DEVICE_PATH *Nvme;\r
1639 UINT8 *Uuid;\r
1640 UINTN Index;\r
1641\r
1642 NamespaceIdStr = GetNextParamStr (&TextDeviceNode);\r
1643 NamespaceUuidStr = GetNextParamStr (&TextDeviceNode);\r
1644 Nvme = (NVME_NAMESPACE_DEVICE_PATH *) CreateDeviceNode (\r
1645 MESSAGING_DEVICE_PATH,\r
1646 MSG_NVME_NAMESPACE_DP,\r
1647 (UINT16) sizeof (NVME_NAMESPACE_DEVICE_PATH)\r
1648 );\r
1649\r
1650 Nvme->NamespaceId = (UINT32) Strtoi (NamespaceIdStr);\r
1651 Uuid = (UINT8 *) &Nvme->NamespaceUuid;\r
1652\r
1653 Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);\r
1654 while (Index-- != 0) {\r
1655 Uuid[Index] = (UINT8) StrHexToUintn (SplitStr (&NamespaceUuidStr, L'-'));\r
1656 }\r
1657\r
1658 return (EFI_DEVICE_PATH_PROTOCOL *) Nvme;\r
1659}\r
1660\r
1661/**\r
1662 Converts a text device path node to UFS device path structure.\r
1663\r
1664 @param TextDeviceNode The input Text device path node.\r
1665\r
1666 @return A pointer to the newly-created UFS device path structure.\r
1667\r
1668**/\r
1669EFI_DEVICE_PATH_PROTOCOL *\r
1670DevPathFromTextUfs (\r
1671 IN CHAR16 *TextDeviceNode\r
1672 )\r
1673{\r
1674 CHAR16 *PunStr;\r
1675 CHAR16 *LunStr;\r
1676 UFS_DEVICE_PATH *Ufs;\r
1677\r
1678 PunStr = GetNextParamStr (&TextDeviceNode);\r
1679 LunStr = GetNextParamStr (&TextDeviceNode);\r
1680 Ufs = (UFS_DEVICE_PATH *) CreateDeviceNode (\r
1681 MESSAGING_DEVICE_PATH,\r
1682 MSG_UFS_DP,\r
1683 (UINT16) sizeof (UFS_DEVICE_PATH)\r
1684 );\r
1685\r
1686 Ufs->Pun = (UINT8) Strtoi (PunStr);\r
1687 Ufs->Lun = (UINT8) Strtoi (LunStr);\r
1688\r
1689 return (EFI_DEVICE_PATH_PROTOCOL *) Ufs;\r
1690}\r
1691\r
1692/**\r
1693 Converts a text device path node to SD (Secure Digital) device path structure.\r
1694\r
1695 @param TextDeviceNode The input Text device path node.\r
1696\r
1697 @return A pointer to the newly-created SD device path structure.\r
1698\r
1699**/\r
1700EFI_DEVICE_PATH_PROTOCOL *\r
1701DevPathFromTextSd (\r
1702 IN CHAR16 *TextDeviceNode\r
1703 )\r
1704{\r
1705 CHAR16 *SlotNumberStr;\r
1706 SD_DEVICE_PATH *Sd;\r
1707\r
1708 SlotNumberStr = GetNextParamStr (&TextDeviceNode);\r
1709 Sd = (SD_DEVICE_PATH *) CreateDeviceNode (\r
1710 MESSAGING_DEVICE_PATH,\r
1711 MSG_SD_DP,\r
1712 (UINT16) sizeof (SD_DEVICE_PATH)\r
1713 );\r
1714\r
1715 Sd->SlotNumber = (UINT8) Strtoi (SlotNumberStr);\r
1716\r
1717 return (EFI_DEVICE_PATH_PROTOCOL *) Sd;\r
1718}\r
1719\r
1720/**\r
1721 Converts a text device path node to EMMC (Embedded MMC) device path structure.\r
1722\r
1723 @param TextDeviceNode The input Text device path node.\r
1724\r
1725 @return A pointer to the newly-created EMMC device path structure.\r
1726\r
1727**/\r
1728EFI_DEVICE_PATH_PROTOCOL *\r
1729DevPathFromTextEmmc (\r
1730 IN CHAR16 *TextDeviceNode\r
1731 )\r
1732{\r
1733 CHAR16 *SlotNumberStr;\r
1734 EMMC_DEVICE_PATH *Emmc;\r
1735\r
1736 SlotNumberStr = GetNextParamStr (&TextDeviceNode);\r
1737 Emmc = (EMMC_DEVICE_PATH *) CreateDeviceNode (\r
1738 MESSAGING_DEVICE_PATH,\r
1739 MSG_EMMC_DP,\r
1740 (UINT16) sizeof (EMMC_DEVICE_PATH)\r
1741 );\r
1742\r
1743 Emmc->SlotNumber = (UINT8) Strtoi (SlotNumberStr);\r
1744\r
1745 return (EFI_DEVICE_PATH_PROTOCOL *) Emmc;\r
1746}\r
1747\r
1748/**\r
1749 Converts a text device path node to Debug Port device path structure.\r
1750\r
1751 @param TextDeviceNode The input Text device path node.\r
1752\r
1753 @return A pointer to the newly-created Debug Port device path structure.\r
1754\r
1755**/\r
1756EFI_DEVICE_PATH_PROTOCOL *\r
1757DevPathFromTextDebugPort (\r
1758 IN CHAR16 *TextDeviceNode\r
1759 )\r
1760{\r
1761 VENDOR_DEVICE_PATH *Vend;\r
1762\r
1763 Vend = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
1764 MESSAGING_DEVICE_PATH,\r
1765 MSG_VENDOR_DP,\r
1766 (UINT16) sizeof (VENDOR_DEVICE_PATH)\r
1767 );\r
1768\r
1769 CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);\r
1770\r
1771 return (EFI_DEVICE_PATH_PROTOCOL *) Vend;\r
1772}\r
1773\r
1774/**\r
1775 Converts a text device path node to MAC 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 MAC device path structure.\r
1780\r
1781**/\r
1782EFI_DEVICE_PATH_PROTOCOL *\r
1783DevPathFromTextMAC (\r
1784 IN CHAR16 *TextDeviceNode\r
1785 )\r
1786{\r
1787 CHAR16 *AddressStr;\r
1788 CHAR16 *IfTypeStr;\r
1789 UINTN Length;\r
1790 MAC_ADDR_DEVICE_PATH *MACDevPath;\r
1791\r
1792 AddressStr = GetNextParamStr (&TextDeviceNode);\r
1793 IfTypeStr = GetNextParamStr (&TextDeviceNode);\r
1794 MACDevPath = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (\r
1795 MESSAGING_DEVICE_PATH,\r
1796 MSG_MAC_ADDR_DP,\r
1797 (UINT16) sizeof (MAC_ADDR_DEVICE_PATH)\r
1798 );\r
1799\r
1800 MACDevPath->IfType = (UINT8) Strtoi (IfTypeStr);\r
1801\r
1802 Length = sizeof (EFI_MAC_ADDRESS);\r
1803 if (MACDevPath->IfType == 0x01 || MACDevPath->IfType == 0x00) {\r
1804 Length = 6;\r
1805 }\r
1806\r
1807 StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length);\r
1808\r
1809 return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;\r
1810}\r
1811\r
1812\r
1813/**\r
1814 Converts a text format to the network protocol ID.\r
1815\r
1816 @param Text String of protocol field.\r
1817\r
1818 @return Network protocol ID .\r
1819\r
1820**/\r
1821UINTN\r
1822NetworkProtocolFromText (\r
1823 IN CHAR16 *Text\r
1824 )\r
1825{\r
1826 if (StrCmp (Text, L"UDP") == 0) {\r
1827 return RFC_1700_UDP_PROTOCOL;\r
1828 }\r
1829\r
1830 if (StrCmp (Text, L"TCP") == 0) {\r
1831 return RFC_1700_TCP_PROTOCOL;\r
1832 }\r
1833\r
1834 return Strtoi (Text);\r
1835}\r
1836\r
1837\r
1838/**\r
1839 Converts a text device path node to IPV4 device path structure.\r
1840\r
1841 @param TextDeviceNode The input Text device path node.\r
1842\r
1843 @return A pointer to the newly-created IPV4 device path structure.\r
1844\r
1845**/\r
1846EFI_DEVICE_PATH_PROTOCOL *\r
1847DevPathFromTextIPv4 (\r
1848 IN CHAR16 *TextDeviceNode\r
1849 )\r
1850{\r
1851 CHAR16 *RemoteIPStr;\r
1852 CHAR16 *ProtocolStr;\r
1853 CHAR16 *TypeStr;\r
1854 CHAR16 *LocalIPStr;\r
1855 CHAR16 *GatewayIPStr;\r
1856 CHAR16 *SubnetMaskStr;\r
1857 IPv4_DEVICE_PATH *IPv4;\r
1858\r
1859 RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r
1860 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
1861 TypeStr = GetNextParamStr (&TextDeviceNode);\r
1862 LocalIPStr = GetNextParamStr (&TextDeviceNode);\r
1863 GatewayIPStr = GetNextParamStr (&TextDeviceNode);\r
1864 SubnetMaskStr = GetNextParamStr (&TextDeviceNode);\r
1865 IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (\r
1866 MESSAGING_DEVICE_PATH,\r
1867 MSG_IPv4_DP,\r
1868 (UINT16) sizeof (IPv4_DEVICE_PATH)\r
1869 );\r
1870\r
1871 StrToIpv4Address (RemoteIPStr, NULL, &IPv4->RemoteIpAddress, NULL);\r
1872 IPv4->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
1873 if (StrCmp (TypeStr, L"Static") == 0) {\r
1874 IPv4->StaticIpAddress = TRUE;\r
1875 } else {\r
1876 IPv4->StaticIpAddress = FALSE;\r
1877 }\r
1878\r
1879 StrToIpv4Address (LocalIPStr, NULL, &IPv4->LocalIpAddress, NULL);\r
1880 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*SubnetMaskStr)) {\r
1881 StrToIpv4Address (GatewayIPStr, NULL, &IPv4->GatewayIpAddress, NULL);\r
1882 StrToIpv4Address (SubnetMaskStr, NULL, &IPv4->SubnetMask, NULL);\r
1883 } else {\r
1884 ZeroMem (&IPv4->GatewayIpAddress, sizeof (IPv4->GatewayIpAddress));\r
1885 ZeroMem (&IPv4->SubnetMask, sizeof (IPv4->SubnetMask));\r
1886 }\r
1887\r
1888 IPv4->LocalPort = 0;\r
1889 IPv4->RemotePort = 0;\r
1890\r
1891 return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;\r
1892}\r
1893\r
1894/**\r
1895 Converts a text device path node to IPV6 device path structure.\r
1896\r
1897 @param TextDeviceNode The input Text device path node.\r
1898\r
1899 @return A pointer to the newly-created IPV6 device path structure.\r
1900\r
1901**/\r
1902EFI_DEVICE_PATH_PROTOCOL *\r
1903DevPathFromTextIPv6 (\r
1904 IN CHAR16 *TextDeviceNode\r
1905 )\r
1906{\r
1907 CHAR16 *RemoteIPStr;\r
1908 CHAR16 *ProtocolStr;\r
1909 CHAR16 *TypeStr;\r
1910 CHAR16 *LocalIPStr;\r
1911 CHAR16 *GatewayIPStr;\r
1912 CHAR16 *PrefixLengthStr;\r
1913 IPv6_DEVICE_PATH *IPv6;\r
1914\r
1915 RemoteIPStr = GetNextParamStr (&TextDeviceNode);\r
1916 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
1917 TypeStr = GetNextParamStr (&TextDeviceNode);\r
1918 LocalIPStr = GetNextParamStr (&TextDeviceNode);\r
1919 PrefixLengthStr = GetNextParamStr (&TextDeviceNode);\r
1920 GatewayIPStr = GetNextParamStr (&TextDeviceNode);\r
1921 IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (\r
1922 MESSAGING_DEVICE_PATH,\r
1923 MSG_IPv6_DP,\r
1924 (UINT16) sizeof (IPv6_DEVICE_PATH)\r
1925 );\r
1926\r
1927 StrToIpv6Address (RemoteIPStr, NULL, &IPv6->RemoteIpAddress, NULL);\r
1928 IPv6->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
1929 if (StrCmp (TypeStr, L"Static") == 0) {\r
1930 IPv6->IpAddressOrigin = 0;\r
1931 } else if (StrCmp (TypeStr, L"StatelessAutoConfigure") == 0) {\r
1932 IPv6->IpAddressOrigin = 1;\r
1933 } else {\r
1934 IPv6->IpAddressOrigin = 2;\r
1935 }\r
1936\r
1937 StrToIpv6Address (LocalIPStr, NULL, &IPv6->LocalIpAddress, NULL);\r
1938 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*PrefixLengthStr)) {\r
1939 StrToIpv6Address (GatewayIPStr, NULL, &IPv6->GatewayIpAddress, NULL);\r
1940 IPv6->PrefixLength = (UINT8) Strtoi (PrefixLengthStr);\r
1941 } else {\r
1942 ZeroMem (&IPv6->GatewayIpAddress, sizeof (IPv6->GatewayIpAddress));\r
1943 IPv6->PrefixLength = 0;\r
1944 }\r
1945\r
1946 IPv6->LocalPort = 0;\r
1947 IPv6->RemotePort = 0;\r
1948\r
1949 return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;\r
1950}\r
1951\r
1952/**\r
1953 Converts a text device path node to UART device path structure.\r
1954\r
1955 @param TextDeviceNode The input Text device path node.\r
1956\r
1957 @return A pointer to the newly-created UART device path structure.\r
1958\r
1959**/\r
1960EFI_DEVICE_PATH_PROTOCOL *\r
1961DevPathFromTextUart (\r
1962 IN CHAR16 *TextDeviceNode\r
1963 )\r
1964{\r
1965 CHAR16 *BaudStr;\r
1966 CHAR16 *DataBitsStr;\r
1967 CHAR16 *ParityStr;\r
1968 CHAR16 *StopBitsStr;\r
1969 UART_DEVICE_PATH *Uart;\r
1970\r
1971 BaudStr = GetNextParamStr (&TextDeviceNode);\r
1972 DataBitsStr = GetNextParamStr (&TextDeviceNode);\r
1973 ParityStr = GetNextParamStr (&TextDeviceNode);\r
1974 StopBitsStr = GetNextParamStr (&TextDeviceNode);\r
1975 Uart = (UART_DEVICE_PATH *) CreateDeviceNode (\r
1976 MESSAGING_DEVICE_PATH,\r
1977 MSG_UART_DP,\r
1978 (UINT16) sizeof (UART_DEVICE_PATH)\r
1979 );\r
1980\r
1981 if (StrCmp (BaudStr, L"DEFAULT") == 0) {\r
1982 Uart->BaudRate = 115200;\r
1983 } else {\r
1984 Strtoi64 (BaudStr, &Uart->BaudRate);\r
1985 }\r
1986 Uart->DataBits = (UINT8) ((StrCmp (DataBitsStr, L"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr));\r
1987 switch (*ParityStr) {\r
1988 case L'D':\r
1989 Uart->Parity = 0;\r
1990 break;\r
1991\r
1992 case L'N':\r
1993 Uart->Parity = 1;\r
1994 break;\r
1995\r
1996 case L'E':\r
1997 Uart->Parity = 2;\r
1998 break;\r
1999\r
2000 case L'O':\r
2001 Uart->Parity = 3;\r
2002 break;\r
2003\r
2004 case L'M':\r
2005 Uart->Parity = 4;\r
2006 break;\r
2007\r
2008 case L'S':\r
2009 Uart->Parity = 5;\r
2010 break;\r
2011\r
2012 default:\r
2013 Uart->Parity = (UINT8) Strtoi (ParityStr);\r
2014 break;\r
2015 }\r
2016\r
2017 if (StrCmp (StopBitsStr, L"D") == 0) {\r
2018 Uart->StopBits = (UINT8) 0;\r
2019 } else if (StrCmp (StopBitsStr, L"1") == 0) {\r
2020 Uart->StopBits = (UINT8) 1;\r
2021 } else if (StrCmp (StopBitsStr, L"1.5") == 0) {\r
2022 Uart->StopBits = (UINT8) 2;\r
2023 } else if (StrCmp (StopBitsStr, L"2") == 0) {\r
2024 Uart->StopBits = (UINT8) 3;\r
2025 } else {\r
2026 Uart->StopBits = (UINT8) Strtoi (StopBitsStr);\r
2027 }\r
2028\r
2029 return (EFI_DEVICE_PATH_PROTOCOL *) Uart;\r
2030}\r
2031\r
2032/**\r
2033 Converts a text device path node to USB class device path structure.\r
2034\r
2035 @param TextDeviceNode The input Text device path node.\r
2036 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.\r
2037\r
2038 @return A pointer to the newly-created USB class device path structure.\r
2039\r
2040**/\r
2041EFI_DEVICE_PATH_PROTOCOL *\r
2042ConvertFromTextUsbClass (\r
2043 IN CHAR16 *TextDeviceNode,\r
2044 IN USB_CLASS_TEXT *UsbClassText\r
2045 )\r
2046{\r
2047 CHAR16 *VIDStr;\r
2048 CHAR16 *PIDStr;\r
2049 CHAR16 *ClassStr;\r
2050 CHAR16 *SubClassStr;\r
2051 CHAR16 *ProtocolStr;\r
2052 USB_CLASS_DEVICE_PATH *UsbClass;\r
2053\r
2054 UsbClass = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (\r
2055 MESSAGING_DEVICE_PATH,\r
2056 MSG_USB_CLASS_DP,\r
2057 (UINT16) sizeof (USB_CLASS_DEVICE_PATH)\r
2058 );\r
2059\r
2060 VIDStr = GetNextParamStr (&TextDeviceNode);\r
2061 PIDStr = GetNextParamStr (&TextDeviceNode);\r
2062 if (UsbClassText->ClassExist) {\r
2063 ClassStr = GetNextParamStr (&TextDeviceNode);\r
2064 if (*ClassStr == L'\0') {\r
2065 UsbClass->DeviceClass = 0xFF;\r
2066 } else {\r
2067 UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);\r
2068 }\r
2069 } else {\r
2070 UsbClass->DeviceClass = UsbClassText->Class;\r
2071 }\r
2072 if (UsbClassText->SubClassExist) {\r
2073 SubClassStr = GetNextParamStr (&TextDeviceNode);\r
2074 if (*SubClassStr == L'\0') {\r
2075 UsbClass->DeviceSubClass = 0xFF;\r
2076 } else {\r
2077 UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);\r
2078 }\r
2079 } else {\r
2080 UsbClass->DeviceSubClass = UsbClassText->SubClass;\r
2081 }\r
2082\r
2083 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
2084\r
2085 if (*VIDStr == L'\0') {\r
2086 UsbClass->VendorId = 0xFFFF;\r
2087 } else {\r
2088 UsbClass->VendorId = (UINT16) Strtoi (VIDStr);\r
2089 }\r
2090 if (*PIDStr == L'\0') {\r
2091 UsbClass->ProductId = 0xFFFF;\r
2092 } else {\r
2093 UsbClass->ProductId = (UINT16) Strtoi (PIDStr);\r
2094 }\r
2095 if (*ProtocolStr == L'\0') {\r
2096 UsbClass->DeviceProtocol = 0xFF;\r
2097 } else {\r
2098 UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);\r
2099 }\r
2100\r
2101 return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;\r
2102}\r
2103\r
2104\r
2105/**\r
2106 Converts a text device path node to USB class device path structure.\r
2107\r
2108 @param TextDeviceNode The input Text device path node.\r
2109\r
2110 @return A pointer to the newly-created USB class device path structure.\r
2111\r
2112**/\r
2113EFI_DEVICE_PATH_PROTOCOL *\r
2114DevPathFromTextUsbClass (\r
2115 IN CHAR16 *TextDeviceNode\r
2116 )\r
2117{\r
2118 USB_CLASS_TEXT UsbClassText;\r
2119\r
2120 UsbClassText.ClassExist = TRUE;\r
2121 UsbClassText.SubClassExist = TRUE;\r
2122\r
2123 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2124}\r
2125\r
2126/**\r
2127 Converts a text device path node to USB audio device path structure.\r
2128\r
2129 @param TextDeviceNode The input Text device path node.\r
2130\r
2131 @return A pointer to the newly-created USB audio device path structure.\r
2132\r
2133**/\r
2134EFI_DEVICE_PATH_PROTOCOL *\r
2135DevPathFromTextUsbAudio (\r
2136 IN CHAR16 *TextDeviceNode\r
2137 )\r
2138{\r
2139 USB_CLASS_TEXT UsbClassText;\r
2140\r
2141 UsbClassText.ClassExist = FALSE;\r
2142 UsbClassText.Class = USB_CLASS_AUDIO;\r
2143 UsbClassText.SubClassExist = TRUE;\r
2144\r
2145 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2146}\r
2147\r
2148/**\r
2149 Converts a text device path node to USB CDC Control device path structure.\r
2150\r
2151 @param TextDeviceNode The input Text device path node.\r
2152\r
2153 @return A pointer to the newly-created USB CDC Control device path structure.\r
2154\r
2155**/\r
2156EFI_DEVICE_PATH_PROTOCOL *\r
2157DevPathFromTextUsbCDCControl (\r
2158 IN CHAR16 *TextDeviceNode\r
2159 )\r
2160{\r
2161 USB_CLASS_TEXT UsbClassText;\r
2162\r
2163 UsbClassText.ClassExist = FALSE;\r
2164 UsbClassText.Class = USB_CLASS_CDCCONTROL;\r
2165 UsbClassText.SubClassExist = TRUE;\r
2166\r
2167 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2168}\r
2169\r
2170/**\r
2171 Converts a text device path node to USB HID device path structure.\r
2172\r
2173 @param TextDeviceNode The input Text device path node.\r
2174\r
2175 @return A pointer to the newly-created USB HID device path structure.\r
2176\r
2177**/\r
2178EFI_DEVICE_PATH_PROTOCOL *\r
2179DevPathFromTextUsbHID (\r
2180 IN CHAR16 *TextDeviceNode\r
2181 )\r
2182{\r
2183 USB_CLASS_TEXT UsbClassText;\r
2184\r
2185 UsbClassText.ClassExist = FALSE;\r
2186 UsbClassText.Class = USB_CLASS_HID;\r
2187 UsbClassText.SubClassExist = TRUE;\r
2188\r
2189 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2190}\r
2191\r
2192/**\r
2193 Converts a text device path node to USB Image device path structure.\r
2194\r
2195 @param TextDeviceNode The input Text device path node.\r
2196\r
2197 @return A pointer to the newly-created USB Image device path structure.\r
2198\r
2199**/\r
2200EFI_DEVICE_PATH_PROTOCOL *\r
2201DevPathFromTextUsbImage (\r
2202 IN CHAR16 *TextDeviceNode\r
2203 )\r
2204{\r
2205 USB_CLASS_TEXT UsbClassText;\r
2206\r
2207 UsbClassText.ClassExist = FALSE;\r
2208 UsbClassText.Class = USB_CLASS_IMAGE;\r
2209 UsbClassText.SubClassExist = TRUE;\r
2210\r
2211 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2212}\r
2213\r
2214/**\r
2215 Converts a text device path node to USB Print device path structure.\r
2216\r
2217 @param TextDeviceNode The input Text device path node.\r
2218\r
2219 @return A pointer to the newly-created USB Print device path structure.\r
2220\r
2221**/\r
2222EFI_DEVICE_PATH_PROTOCOL *\r
2223DevPathFromTextUsbPrinter (\r
2224 IN CHAR16 *TextDeviceNode\r
2225 )\r
2226{\r
2227 USB_CLASS_TEXT UsbClassText;\r
2228\r
2229 UsbClassText.ClassExist = FALSE;\r
2230 UsbClassText.Class = USB_CLASS_PRINTER;\r
2231 UsbClassText.SubClassExist = TRUE;\r
2232\r
2233 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2234}\r
2235\r
2236/**\r
2237 Converts a text device path node to USB mass storage device path structure.\r
2238\r
2239 @param TextDeviceNode The input Text device path node.\r
2240\r
2241 @return A pointer to the newly-created USB mass storage device path structure.\r
2242\r
2243**/\r
2244EFI_DEVICE_PATH_PROTOCOL *\r
2245DevPathFromTextUsbMassStorage (\r
2246 IN CHAR16 *TextDeviceNode\r
2247 )\r
2248{\r
2249 USB_CLASS_TEXT UsbClassText;\r
2250\r
2251 UsbClassText.ClassExist = FALSE;\r
2252 UsbClassText.Class = USB_CLASS_MASS_STORAGE;\r
2253 UsbClassText.SubClassExist = TRUE;\r
2254\r
2255 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2256}\r
2257\r
2258/**\r
2259 Converts a text device path node to USB HUB device path structure.\r
2260\r
2261 @param TextDeviceNode The input Text device path node.\r
2262\r
2263 @return A pointer to the newly-created USB HUB device path structure.\r
2264\r
2265**/\r
2266EFI_DEVICE_PATH_PROTOCOL *\r
2267DevPathFromTextUsbHub (\r
2268 IN CHAR16 *TextDeviceNode\r
2269 )\r
2270{\r
2271 USB_CLASS_TEXT UsbClassText;\r
2272\r
2273 UsbClassText.ClassExist = FALSE;\r
2274 UsbClassText.Class = USB_CLASS_HUB;\r
2275 UsbClassText.SubClassExist = TRUE;\r
2276\r
2277 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2278}\r
2279\r
2280/**\r
2281 Converts a text device path node to USB CDC data device path structure.\r
2282\r
2283 @param TextDeviceNode The input Text device path node.\r
2284\r
2285 @return A pointer to the newly-created USB CDC data device path structure.\r
2286\r
2287**/\r
2288EFI_DEVICE_PATH_PROTOCOL *\r
2289DevPathFromTextUsbCDCData (\r
2290 IN CHAR16 *TextDeviceNode\r
2291 )\r
2292{\r
2293 USB_CLASS_TEXT UsbClassText;\r
2294\r
2295 UsbClassText.ClassExist = FALSE;\r
2296 UsbClassText.Class = USB_CLASS_CDCDATA;\r
2297 UsbClassText.SubClassExist = TRUE;\r
2298\r
2299 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2300}\r
2301\r
2302/**\r
2303 Converts a text device path node to USB smart card device path structure.\r
2304\r
2305 @param TextDeviceNode The input Text device path node.\r
2306\r
2307 @return A pointer to the newly-created USB smart card device path structure.\r
2308\r
2309**/\r
2310EFI_DEVICE_PATH_PROTOCOL *\r
2311DevPathFromTextUsbSmartCard (\r
2312 IN CHAR16 *TextDeviceNode\r
2313 )\r
2314{\r
2315 USB_CLASS_TEXT UsbClassText;\r
2316\r
2317 UsbClassText.ClassExist = FALSE;\r
2318 UsbClassText.Class = USB_CLASS_SMART_CARD;\r
2319 UsbClassText.SubClassExist = TRUE;\r
2320\r
2321 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2322}\r
2323\r
2324/**\r
2325 Converts a text device path node to USB video device path structure.\r
2326\r
2327 @param TextDeviceNode The input Text device path node.\r
2328\r
2329 @return A pointer to the newly-created USB video device path structure.\r
2330\r
2331**/\r
2332EFI_DEVICE_PATH_PROTOCOL *\r
2333DevPathFromTextUsbVideo (\r
2334 IN CHAR16 *TextDeviceNode\r
2335 )\r
2336{\r
2337 USB_CLASS_TEXT UsbClassText;\r
2338\r
2339 UsbClassText.ClassExist = FALSE;\r
2340 UsbClassText.Class = USB_CLASS_VIDEO;\r
2341 UsbClassText.SubClassExist = TRUE;\r
2342\r
2343 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2344}\r
2345\r
2346/**\r
2347 Converts a text device path node to USB diagnostic device path structure.\r
2348\r
2349 @param TextDeviceNode The input Text device path node.\r
2350\r
2351 @return A pointer to the newly-created USB diagnostic device path structure.\r
2352\r
2353**/\r
2354EFI_DEVICE_PATH_PROTOCOL *\r
2355DevPathFromTextUsbDiagnostic (\r
2356 IN CHAR16 *TextDeviceNode\r
2357 )\r
2358{\r
2359 USB_CLASS_TEXT UsbClassText;\r
2360\r
2361 UsbClassText.ClassExist = FALSE;\r
2362 UsbClassText.Class = USB_CLASS_DIAGNOSTIC;\r
2363 UsbClassText.SubClassExist = TRUE;\r
2364\r
2365 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2366}\r
2367\r
2368/**\r
2369 Converts a text device path node to USB wireless device path structure.\r
2370\r
2371 @param TextDeviceNode The input Text device path node.\r
2372\r
2373 @return A pointer to the newly-created USB wireless device path structure.\r
2374\r
2375**/\r
2376EFI_DEVICE_PATH_PROTOCOL *\r
2377DevPathFromTextUsbWireless (\r
2378 IN CHAR16 *TextDeviceNode\r
2379 )\r
2380{\r
2381 USB_CLASS_TEXT UsbClassText;\r
2382\r
2383 UsbClassText.ClassExist = FALSE;\r
2384 UsbClassText.Class = USB_CLASS_WIRELESS;\r
2385 UsbClassText.SubClassExist = TRUE;\r
2386\r
2387 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2388}\r
2389\r
2390/**\r
2391 Converts a text device path node to USB device firmware update device path structure.\r
2392\r
2393 @param TextDeviceNode The input Text device path node.\r
2394\r
2395 @return A pointer to the newly-created USB device firmware update device path structure.\r
2396\r
2397**/\r
2398EFI_DEVICE_PATH_PROTOCOL *\r
2399DevPathFromTextUsbDeviceFirmwareUpdate (\r
2400 IN CHAR16 *TextDeviceNode\r
2401 )\r
2402{\r
2403 USB_CLASS_TEXT UsbClassText;\r
2404\r
2405 UsbClassText.ClassExist = FALSE;\r
2406 UsbClassText.Class = USB_CLASS_RESERVE;\r
2407 UsbClassText.SubClassExist = FALSE;\r
2408 UsbClassText.SubClass = USB_SUBCLASS_FW_UPDATE;\r
2409\r
2410 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2411}\r
2412\r
2413/**\r
2414 Converts a text device path node to USB IRDA bridge device path structure.\r
2415\r
2416 @param TextDeviceNode The input Text device path node.\r
2417\r
2418 @return A pointer to the newly-created USB IRDA bridge device path structure.\r
2419\r
2420**/\r
2421EFI_DEVICE_PATH_PROTOCOL *\r
2422DevPathFromTextUsbIrdaBridge (\r
2423 IN CHAR16 *TextDeviceNode\r
2424 )\r
2425{\r
2426 USB_CLASS_TEXT UsbClassText;\r
2427\r
2428 UsbClassText.ClassExist = FALSE;\r
2429 UsbClassText.Class = USB_CLASS_RESERVE;\r
2430 UsbClassText.SubClassExist = FALSE;\r
2431 UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE;\r
2432\r
2433 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2434}\r
2435\r
2436/**\r
2437 Converts a text device path node to USB text and measurement device path structure.\r
2438\r
2439 @param TextDeviceNode The input Text device path node.\r
2440\r
2441 @return A pointer to the newly-created USB text and measurement device path structure.\r
2442\r
2443**/\r
2444EFI_DEVICE_PATH_PROTOCOL *\r
2445DevPathFromTextUsbTestAndMeasurement (\r
2446 IN CHAR16 *TextDeviceNode\r
2447 )\r
2448{\r
2449 USB_CLASS_TEXT UsbClassText;\r
2450\r
2451 UsbClassText.ClassExist = FALSE;\r
2452 UsbClassText.Class = USB_CLASS_RESERVE;\r
2453 UsbClassText.SubClassExist = FALSE;\r
2454 UsbClassText.SubClass = USB_SUBCLASS_TEST;\r
2455\r
2456 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
2457}\r
2458\r
2459/**\r
2460 Converts a text device path node to USB WWID device path structure.\r
2461\r
2462 @param TextDeviceNode The input Text device path node.\r
2463\r
2464 @return A pointer to the newly-created USB WWID device path structure.\r
2465\r
2466**/\r
2467EFI_DEVICE_PATH_PROTOCOL *\r
2468DevPathFromTextUsbWwid (\r
2469 IN CHAR16 *TextDeviceNode\r
2470 )\r
2471{\r
2472 CHAR16 *VIDStr;\r
2473 CHAR16 *PIDStr;\r
2474 CHAR16 *InterfaceNumStr;\r
2475 CHAR16 *SerialNumberStr;\r
2476 USB_WWID_DEVICE_PATH *UsbWwid;\r
2477 UINTN SerialNumberStrLen;\r
2478\r
2479 VIDStr = GetNextParamStr (&TextDeviceNode);\r
2480 PIDStr = GetNextParamStr (&TextDeviceNode);\r
2481 InterfaceNumStr = GetNextParamStr (&TextDeviceNode);\r
2482 SerialNumberStr = GetNextParamStr (&TextDeviceNode);\r
2483 SerialNumberStrLen = StrLen (SerialNumberStr);\r
2484 if (SerialNumberStrLen >= 2 &&\r
2485 SerialNumberStr[0] == L'\"' &&\r
2486 SerialNumberStr[SerialNumberStrLen - 1] == L'\"'\r
2487 ) {\r
2488 SerialNumberStr[SerialNumberStrLen - 1] = L'\0';\r
2489 SerialNumberStr++;\r
2490 SerialNumberStrLen -= 2;\r
2491 }\r
2492 UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (\r
2493 MESSAGING_DEVICE_PATH,\r
2494 MSG_USB_WWID_DP,\r
2495 (UINT16) (sizeof (USB_WWID_DEVICE_PATH) + SerialNumberStrLen * sizeof (CHAR16))\r
2496 );\r
2497 UsbWwid->VendorId = (UINT16) Strtoi (VIDStr);\r
2498 UsbWwid->ProductId = (UINT16) Strtoi (PIDStr);\r
2499 UsbWwid->InterfaceNumber = (UINT16) Strtoi (InterfaceNumStr);\r
2500\r
2501 //\r
2502 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.\r
2503 // Therefore, the '\0' will not be copied.\r
2504 //\r
2505 CopyMem (\r
2506 (UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH),\r
2507 SerialNumberStr,\r
2508 SerialNumberStrLen * sizeof (CHAR16)\r
2509 );\r
2510\r
2511 return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;\r
2512}\r
2513\r
2514/**\r
2515 Converts a text device path node to Logic Unit device path structure.\r
2516\r
2517 @param TextDeviceNode The input Text device path node.\r
2518\r
2519 @return A pointer to the newly-created Logic Unit device path structure.\r
2520\r
2521**/\r
2522EFI_DEVICE_PATH_PROTOCOL *\r
2523DevPathFromTextUnit (\r
2524 IN CHAR16 *TextDeviceNode\r
2525 )\r
2526{\r
2527 CHAR16 *LunStr;\r
2528 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
2529\r
2530 LunStr = GetNextParamStr (&TextDeviceNode);\r
2531 LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (\r
2532 MESSAGING_DEVICE_PATH,\r
2533 MSG_DEVICE_LOGICAL_UNIT_DP,\r
2534 (UINT16) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)\r
2535 );\r
2536\r
2537 LogicalUnit->Lun = (UINT8) Strtoi (LunStr);\r
2538\r
2539 return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;\r
2540}\r
2541\r
2542/**\r
2543 Converts a text device path node to iSCSI device path structure.\r
2544\r
2545 @param TextDeviceNode The input Text device path node.\r
2546\r
2547 @return A pointer to the newly-created iSCSI device path structure.\r
2548\r
2549**/\r
2550EFI_DEVICE_PATH_PROTOCOL *\r
2551DevPathFromTextiSCSI (\r
2552 IN CHAR16 *TextDeviceNode\r
2553 )\r
2554{\r
2555 UINT16 Options;\r
2556 CHAR16 *NameStr;\r
2557 CHAR16 *PortalGroupStr;\r
2558 CHAR16 *LunStr;\r
2559 CHAR16 *HeaderDigestStr;\r
2560 CHAR16 *DataDigestStr;\r
2561 CHAR16 *AuthenticationStr;\r
2562 CHAR16 *ProtocolStr;\r
2563 CHAR8 *AsciiStr;\r
2564 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
2565 UINT64 Lun;\r
2566\r
2567 NameStr = GetNextParamStr (&TextDeviceNode);\r
2568 PortalGroupStr = GetNextParamStr (&TextDeviceNode);\r
2569 LunStr = GetNextParamStr (&TextDeviceNode);\r
2570 HeaderDigestStr = GetNextParamStr (&TextDeviceNode);\r
2571 DataDigestStr = GetNextParamStr (&TextDeviceNode);\r
2572 AuthenticationStr = GetNextParamStr (&TextDeviceNode);\r
2573 ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
2574 ISCSIDevPath = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (\r
2575 MESSAGING_DEVICE_PATH,\r
2576 MSG_ISCSI_DP,\r
2577 (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))\r
2578 );\r
2579\r
2580 AsciiStr = ISCSIDevPath->TargetName;\r
2581 StrToAscii (NameStr, &AsciiStr);\r
2582\r
2583 ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);\r
2584 Strtoi64 (LunStr, &Lun);\r
2585 WriteUnaligned64 ((UINT64 *) &ISCSIDevPath->Lun, SwapBytes64 (Lun));\r
2586\r
2587 Options = 0x0000;\r
2588 if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {\r
2589 Options |= 0x0002;\r
2590 }\r
2591\r
2592 if (StrCmp (DataDigestStr, L"CRC32C") == 0) {\r
2593 Options |= 0x0008;\r
2594 }\r
2595\r
2596 if (StrCmp (AuthenticationStr, L"None") == 0) {\r
2597 Options |= 0x0800;\r
2598 }\r
2599\r
2600 if (StrCmp (AuthenticationStr, L"CHAP_UNI") == 0) {\r
2601 Options |= 0x1000;\r
2602 }\r
2603\r
2604 ISCSIDevPath->LoginOption = (UINT16) Options;\r
2605\r
2606 if (IS_NULL (*ProtocolStr) || (StrCmp (ProtocolStr, L"TCP") == 0)) {\r
2607 ISCSIDevPath->NetworkProtocol = 0;\r
2608 } else {\r
2609 //\r
2610 // Undefined and reserved.\r
2611 //\r
2612 ISCSIDevPath->NetworkProtocol = 1;\r
2613 }\r
2614\r
2615 return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;\r
2616}\r
2617\r
2618/**\r
2619 Converts a text device path node to VLAN device path structure.\r
2620\r
2621 @param TextDeviceNode The input Text device path node.\r
2622\r
2623 @return A pointer to the newly-created VLAN device path structure.\r
2624\r
2625**/\r
2626EFI_DEVICE_PATH_PROTOCOL *\r
2627DevPathFromTextVlan (\r
2628 IN CHAR16 *TextDeviceNode\r
2629 )\r
2630{\r
2631 CHAR16 *VlanStr;\r
2632 VLAN_DEVICE_PATH *Vlan;\r
2633\r
2634 VlanStr = GetNextParamStr (&TextDeviceNode);\r
2635 Vlan = (VLAN_DEVICE_PATH *) CreateDeviceNode (\r
2636 MESSAGING_DEVICE_PATH,\r
2637 MSG_VLAN_DP,\r
2638 (UINT16) sizeof (VLAN_DEVICE_PATH)\r
2639 );\r
2640\r
2641 Vlan->VlanId = (UINT16) Strtoi (VlanStr);\r
2642\r
2643 return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;\r
2644}\r
2645\r
2646/**\r
2647 Converts a text device path node to Bluetooth 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 Bluetooth device path structure.\r
2652\r
2653**/\r
2654EFI_DEVICE_PATH_PROTOCOL *\r
2655DevPathFromTextBluetooth (\r
2656 IN CHAR16 *TextDeviceNode\r
2657 )\r
2658{\r
2659 CHAR16 *BluetoothStr;\r
2660 BLUETOOTH_DEVICE_PATH *BluetoothDp;\r
2661\r
2662 BluetoothStr = GetNextParamStr (&TextDeviceNode);\r
2663 BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (\r
2664 MESSAGING_DEVICE_PATH,\r
2665 MSG_BLUETOOTH_DP,\r
2666 (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)\r
2667 );\r
2668 StrHexToBytes (\r
2669 BluetoothStr,\r
2670 sizeof (BLUETOOTH_ADDRESS) * 2,\r
2671 BluetoothDp->BD_ADDR.Address,\r
2672 sizeof (BLUETOOTH_ADDRESS)\r
2673 );\r
2674 return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothDp;\r
2675}\r
2676\r
2677/**\r
2678 Converts a text device path node to Wi-Fi device path structure.\r
2679\r
2680 @param TextDeviceNode The input Text device path node.\r
2681\r
2682 @return A pointer to the newly-created Wi-Fi device path structure.\r
2683\r
2684**/\r
2685EFI_DEVICE_PATH_PROTOCOL *\r
2686DevPathFromTextWiFi (\r
2687 IN CHAR16 *TextDeviceNode\r
2688 )\r
2689{\r
2690 CHAR16 *SSIdStr;\r
2691 CHAR8 AsciiStr[33];\r
2692 UINTN DataLen;\r
2693 WIFI_DEVICE_PATH *WiFiDp;\r
2694\r
2695 SSIdStr = GetNextParamStr (&TextDeviceNode);\r
2696 WiFiDp = (WIFI_DEVICE_PATH *) CreateDeviceNode (\r
2697 MESSAGING_DEVICE_PATH,\r
2698 MSG_WIFI_DP,\r
2699 (UINT16) sizeof (WIFI_DEVICE_PATH)\r
2700 );\r
2701\r
2702 if (NULL != SSIdStr) {\r
2703 DataLen = StrLen (SSIdStr);\r
2704 if (StrLen (SSIdStr) > 32) {\r
2705 SSIdStr[32] = L'\0';\r
2706 DataLen = 32;\r
2707 }\r
2708\r
2709 UnicodeStrToAsciiStrS (SSIdStr, AsciiStr, sizeof (AsciiStr));\r
2710 CopyMem (WiFiDp->SSId, AsciiStr, DataLen);\r
2711 }\r
2712\r
2713 return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp;\r
2714}\r
2715\r
2716/**\r
2717 Converts a text device path node to Bluetooth LE device path structure.\r
2718\r
2719 @param TextDeviceNode The input Text device path node.\r
2720\r
2721 @return A pointer to the newly-created Bluetooth LE device path structure.\r
2722\r
2723**/\r
2724EFI_DEVICE_PATH_PROTOCOL *\r
2725DevPathFromTextBluetoothLE (\r
2726 IN CHAR16 *TextDeviceNode\r
2727 )\r
2728{\r
2729 CHAR16 *BluetoothLeAddrStr;\r
2730 CHAR16 *BluetoothLeAddrTypeStr;\r
2731 BLUETOOTH_LE_DEVICE_PATH *BluetoothLeDp;\r
2732\r
2733 BluetoothLeAddrStr = GetNextParamStr (&TextDeviceNode);\r
2734 BluetoothLeAddrTypeStr = GetNextParamStr (&TextDeviceNode);\r
2735 BluetoothLeDp = (BLUETOOTH_LE_DEVICE_PATH *) CreateDeviceNode (\r
2736 MESSAGING_DEVICE_PATH,\r
2737 MSG_BLUETOOTH_LE_DP,\r
2738 (UINT16) sizeof (BLUETOOTH_LE_DEVICE_PATH)\r
2739 );\r
2740\r
2741 BluetoothLeDp->Address.Type = (UINT8) Strtoi (BluetoothLeAddrTypeStr);\r
2742 StrHexToBytes (\r
2743 BluetoothLeAddrStr, sizeof (BluetoothLeDp->Address.Address) * 2,\r
2744 BluetoothLeDp->Address.Address, sizeof (BluetoothLeDp->Address.Address)\r
2745 );\r
2746 return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothLeDp;\r
2747}\r
2748\r
2749/**\r
2750 Converts a text device path node to DNS device path structure.\r
2751\r
2752 @param TextDeviceNode The input Text device path node.\r
2753\r
2754 @return A pointer to the newly-created DNS device path structure.\r
2755\r
2756**/\r
2757EFI_DEVICE_PATH_PROTOCOL *\r
2758DevPathFromTextDns (\r
2759 IN CHAR16 *TextDeviceNode\r
2760 )\r
2761{\r
2762 CHAR16 *DeviceNodeStr;\r
2763 CHAR16 *DeviceNodeStrPtr;\r
2764 UINT32 DnsServerIpCount;\r
2765 UINT16 DnsDeviceNodeLength;\r
2766 DNS_DEVICE_PATH *DnsDeviceNode;\r
2767 UINT32 DnsServerIpIndex;\r
2768 CHAR16 *DnsServerIp;\r
2769\r
2770\r
2771 //\r
2772 // Count the DNS server address number.\r
2773 //\r
2774 DeviceNodeStr = UefiDevicePathLibStrDuplicate (TextDeviceNode);\r
2775 if (DeviceNodeStr == NULL) {\r
2776 return NULL;\r
2777 }\r
2778\r
2779 DeviceNodeStrPtr = DeviceNodeStr;\r
2780\r
2781 DnsServerIpCount = 0;\r
2782 while (DeviceNodeStrPtr != NULL && *DeviceNodeStrPtr != L'\0') {\r
2783 GetNextParamStr (&DeviceNodeStrPtr);\r
2784 DnsServerIpCount ++;\r
2785 }\r
2786\r
2787 FreePool (DeviceNodeStr);\r
2788 DeviceNodeStr = NULL;\r
2789\r
2790 //\r
2791 // One or more instances of the DNS server address in EFI_IP_ADDRESS,\r
2792 // otherwise, NULL will be returned.\r
2793 //\r
2794 if (DnsServerIpCount == 0) {\r
2795 return NULL;\r
2796 }\r
2797\r
2798 //\r
2799 // Create the DNS DeviceNode.\r
2800 //\r
2801 DnsDeviceNodeLength = (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (UINT8) + DnsServerIpCount * sizeof (EFI_IP_ADDRESS));\r
2802 DnsDeviceNode = (DNS_DEVICE_PATH *) CreateDeviceNode (\r
2803 MESSAGING_DEVICE_PATH,\r
2804 MSG_DNS_DP,\r
2805 DnsDeviceNodeLength\r
2806 );\r
2807 if (DnsDeviceNode == NULL) {\r
2808 return NULL;\r
2809 }\r
2810\r
2811 //\r
2812 // Confirm the DNS server address is IPv4 or IPv6 type.\r
2813 //\r
2814 DeviceNodeStrPtr = TextDeviceNode;\r
2815 while (!IS_NULL (*DeviceNodeStrPtr)) {\r
2816 if (*DeviceNodeStrPtr == L'.') {\r
2817 DnsDeviceNode->IsIPv6 = 0x00;\r
2818 break;\r
2819 }\r
2820\r
2821 if (*DeviceNodeStrPtr == L':') {\r
2822 DnsDeviceNode->IsIPv6 = 0x01;\r
2823 break;\r
2824 }\r
2825\r
2826 DeviceNodeStrPtr++;\r
2827 }\r
2828\r
2829 for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; DnsServerIpIndex++) {\r
2830 DnsServerIp = GetNextParamStr (&TextDeviceNode);\r
2831 if (DnsDeviceNode->IsIPv6 == 0x00) {\r
2832 StrToIpv4Address (DnsServerIp, NULL, &(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v4), NULL);\r
2833 } else {\r
2834 StrToIpv6Address (DnsServerIp, NULL, &(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v6), NULL);\r
2835 }\r
2836 }\r
2837\r
2838 return (EFI_DEVICE_PATH_PROTOCOL *) DnsDeviceNode;\r
2839}\r
2840\r
2841/**\r
2842 Converts a text device path node to URI device path structure.\r
2843\r
2844 @param TextDeviceNode The input Text device path node.\r
2845\r
2846 @return A pointer to the newly-created URI device path structure.\r
2847\r
2848**/\r
2849EFI_DEVICE_PATH_PROTOCOL *\r
2850DevPathFromTextUri (\r
2851 IN CHAR16 *TextDeviceNode\r
2852 )\r
2853{\r
2854 CHAR16 *UriStr;\r
2855 UINTN UriLength;\r
2856 URI_DEVICE_PATH *Uri;\r
2857\r
2858 UriStr = GetNextParamStr (&TextDeviceNode);\r
2859 UriLength = StrnLenS (UriStr, MAX_UINT16 - sizeof (URI_DEVICE_PATH));\r
2860 Uri = (URI_DEVICE_PATH *) CreateDeviceNode (\r
2861 MESSAGING_DEVICE_PATH,\r
2862 MSG_URI_DP,\r
2863 (UINT16) (sizeof (URI_DEVICE_PATH) + UriLength)\r
2864 );\r
2865\r
2866 while (UriLength-- != 0) {\r
2867 Uri->Uri[UriLength] = (CHAR8) UriStr[UriLength];\r
2868 }\r
2869\r
2870 return (EFI_DEVICE_PATH_PROTOCOL *) Uri;\r
2871}\r
2872\r
2873/**\r
2874 Converts a media text device path node to media device path structure.\r
2875\r
2876 @param TextDeviceNode The input Text device path node.\r
2877\r
2878 @return A pointer to media device path structure.\r
2879\r
2880**/\r
2881EFI_DEVICE_PATH_PROTOCOL *\r
2882DevPathFromTextMediaPath (\r
2883 IN CHAR16 *TextDeviceNode\r
2884 )\r
2885{\r
2886 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH, TextDeviceNode);\r
2887}\r
2888\r
2889/**\r
2890 Converts a text device path node to HD device path structure.\r
2891\r
2892 @param TextDeviceNode The input Text device path node.\r
2893\r
2894 @return A pointer to the newly-created HD device path structure.\r
2895\r
2896**/\r
2897EFI_DEVICE_PATH_PROTOCOL *\r
2898DevPathFromTextHD (\r
2899 IN CHAR16 *TextDeviceNode\r
2900 )\r
2901{\r
2902 CHAR16 *PartitionStr;\r
2903 CHAR16 *TypeStr;\r
2904 CHAR16 *SignatureStr;\r
2905 CHAR16 *StartStr;\r
2906 CHAR16 *SizeStr;\r
2907 UINT32 Signature32;\r
2908 HARDDRIVE_DEVICE_PATH *Hd;\r
2909\r
2910 PartitionStr = GetNextParamStr (&TextDeviceNode);\r
2911 TypeStr = GetNextParamStr (&TextDeviceNode);\r
2912 SignatureStr = GetNextParamStr (&TextDeviceNode);\r
2913 StartStr = GetNextParamStr (&TextDeviceNode);\r
2914 SizeStr = GetNextParamStr (&TextDeviceNode);\r
2915 Hd = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (\r
2916 MEDIA_DEVICE_PATH,\r
2917 MEDIA_HARDDRIVE_DP,\r
2918 (UINT16) sizeof (HARDDRIVE_DEVICE_PATH)\r
2919 );\r
2920\r
2921 Hd->PartitionNumber = (UINT32) Strtoi (PartitionStr);\r
2922\r
2923 ZeroMem (Hd->Signature, 16);\r
2924 Hd->MBRType = (UINT8) 0;\r
2925\r
2926 if (StrCmp (TypeStr, L"MBR") == 0) {\r
2927 Hd->SignatureType = SIGNATURE_TYPE_MBR;\r
2928 Hd->MBRType = 0x01;\r
2929\r
2930 Signature32 = (UINT32) Strtoi (SignatureStr);\r
2931 CopyMem (Hd->Signature, &Signature32, sizeof (UINT32));\r
2932 } else if (StrCmp (TypeStr, L"GPT") == 0) {\r
2933 Hd->SignatureType = SIGNATURE_TYPE_GUID;\r
2934 Hd->MBRType = 0x02;\r
2935\r
2936 StrToGuid (SignatureStr, (EFI_GUID *) Hd->Signature);\r
2937 } else {\r
2938 Hd->SignatureType = (UINT8) Strtoi (TypeStr);\r
2939 }\r
2940\r
2941 Strtoi64 (StartStr, &Hd->PartitionStart);\r
2942 Strtoi64 (SizeStr, &Hd->PartitionSize);\r
2943\r
2944 return (EFI_DEVICE_PATH_PROTOCOL *) Hd;\r
2945}\r
2946\r
2947/**\r
2948 Converts a text device path node to CDROM device path structure.\r
2949\r
2950 @param TextDeviceNode The input Text device path node.\r
2951\r
2952 @return A pointer to the newly-created CDROM device path structure.\r
2953\r
2954**/\r
2955EFI_DEVICE_PATH_PROTOCOL *\r
2956DevPathFromTextCDROM (\r
2957 IN CHAR16 *TextDeviceNode\r
2958 )\r
2959{\r
2960 CHAR16 *EntryStr;\r
2961 CHAR16 *StartStr;\r
2962 CHAR16 *SizeStr;\r
2963 CDROM_DEVICE_PATH *CDROMDevPath;\r
2964\r
2965 EntryStr = GetNextParamStr (&TextDeviceNode);\r
2966 StartStr = GetNextParamStr (&TextDeviceNode);\r
2967 SizeStr = GetNextParamStr (&TextDeviceNode);\r
2968 CDROMDevPath = (CDROM_DEVICE_PATH *) CreateDeviceNode (\r
2969 MEDIA_DEVICE_PATH,\r
2970 MEDIA_CDROM_DP,\r
2971 (UINT16) sizeof (CDROM_DEVICE_PATH)\r
2972 );\r
2973\r
2974 CDROMDevPath->BootEntry = (UINT32) Strtoi (EntryStr);\r
2975 Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);\r
2976 Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);\r
2977\r
2978 return (EFI_DEVICE_PATH_PROTOCOL *) CDROMDevPath;\r
2979}\r
2980\r
2981/**\r
2982 Converts a text device path node to Vendor-defined media device path structure.\r
2983\r
2984 @param TextDeviceNode The input Text device path node.\r
2985\r
2986 @return A pointer to the newly-created Vendor-defined media device path structure.\r
2987\r
2988**/\r
2989EFI_DEVICE_PATH_PROTOCOL *\r
2990DevPathFromTextVenMedia (\r
2991 IN CHAR16 *TextDeviceNode\r
2992 )\r
2993{\r
2994 return ConvertFromTextVendor (\r
2995 TextDeviceNode,\r
2996 MEDIA_DEVICE_PATH,\r
2997 MEDIA_VENDOR_DP\r
2998 );\r
2999}\r
3000\r
3001/**\r
3002 Converts a text device path node to File device path structure.\r
3003\r
3004 @param TextDeviceNode The input Text device path node.\r
3005\r
3006 @return A pointer to the newly-created File device path structure.\r
3007\r
3008**/\r
3009EFI_DEVICE_PATH_PROTOCOL *\r
3010DevPathFromTextFilePath (\r
3011 IN CHAR16 *TextDeviceNode\r
3012 )\r
3013{\r
3014 FILEPATH_DEVICE_PATH *File;\r
3015\r
3016 File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r
3017 MEDIA_DEVICE_PATH,\r
3018 MEDIA_FILEPATH_DP,\r
3019 (UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)\r
3020 );\r
3021\r
3022 StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);\r
3023\r
3024 return (EFI_DEVICE_PATH_PROTOCOL *) File;\r
3025}\r
3026\r
3027/**\r
3028 Converts a text device path node to Media protocol device path structure.\r
3029\r
3030 @param TextDeviceNode The input Text device path node.\r
3031\r
3032 @return A pointer to the newly-created Media protocol device path structure.\r
3033\r
3034**/\r
3035EFI_DEVICE_PATH_PROTOCOL *\r
3036DevPathFromTextMedia (\r
3037 IN CHAR16 *TextDeviceNode\r
3038 )\r
3039{\r
3040 CHAR16 *GuidStr;\r
3041 MEDIA_PROTOCOL_DEVICE_PATH *Media;\r
3042\r
3043 GuidStr = GetNextParamStr (&TextDeviceNode);\r
3044 Media = (MEDIA_PROTOCOL_DEVICE_PATH *) CreateDeviceNode (\r
3045 MEDIA_DEVICE_PATH,\r
3046 MEDIA_PROTOCOL_DP,\r
3047 (UINT16) sizeof (MEDIA_PROTOCOL_DEVICE_PATH)\r
3048 );\r
3049\r
3050 StrToGuid (GuidStr, &Media->Protocol);\r
3051\r
3052 return (EFI_DEVICE_PATH_PROTOCOL *) Media;\r
3053}\r
3054\r
3055/**\r
3056 Converts a text device path node to firmware volume device path structure.\r
3057\r
3058 @param TextDeviceNode The input Text device path node.\r
3059\r
3060 @return A pointer to the newly-created firmware volume device path structure.\r
3061\r
3062**/\r
3063EFI_DEVICE_PATH_PROTOCOL *\r
3064DevPathFromTextFv (\r
3065 IN CHAR16 *TextDeviceNode\r
3066 )\r
3067{\r
3068 CHAR16 *GuidStr;\r
3069 MEDIA_FW_VOL_DEVICE_PATH *Fv;\r
3070\r
3071 GuidStr = GetNextParamStr (&TextDeviceNode);\r
3072 Fv = (MEDIA_FW_VOL_DEVICE_PATH *) CreateDeviceNode (\r
3073 MEDIA_DEVICE_PATH,\r
3074 MEDIA_PIWG_FW_VOL_DP,\r
3075 (UINT16) sizeof (MEDIA_FW_VOL_DEVICE_PATH)\r
3076 );\r
3077\r
3078 StrToGuid (GuidStr, &Fv->FvName);\r
3079\r
3080 return (EFI_DEVICE_PATH_PROTOCOL *) Fv;\r
3081}\r
3082\r
3083/**\r
3084 Converts a text device path node to firmware file device path structure.\r
3085\r
3086 @param TextDeviceNode The input Text device path node.\r
3087\r
3088 @return A pointer to the newly-created firmware file device path structure.\r
3089\r
3090**/\r
3091EFI_DEVICE_PATH_PROTOCOL *\r
3092DevPathFromTextFvFile (\r
3093 IN CHAR16 *TextDeviceNode\r
3094 )\r
3095{\r
3096 CHAR16 *GuidStr;\r
3097 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;\r
3098\r
3099 GuidStr = GetNextParamStr (&TextDeviceNode);\r
3100 FvFile = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r
3101 MEDIA_DEVICE_PATH,\r
3102 MEDIA_PIWG_FW_FILE_DP,\r
3103 (UINT16) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)\r
3104 );\r
3105\r
3106 StrToGuid (GuidStr, &FvFile->FvFileName);\r
3107\r
3108 return (EFI_DEVICE_PATH_PROTOCOL *) FvFile;\r
3109}\r
3110\r
3111/**\r
3112 Converts a text device path node to text relative offset device path structure.\r
3113\r
3114 @param TextDeviceNode The input Text device path node.\r
3115\r
3116 @return A pointer to the newly-created Text device path structure.\r
3117\r
3118**/\r
3119EFI_DEVICE_PATH_PROTOCOL *\r
3120DevPathFromTextRelativeOffsetRange (\r
3121 IN CHAR16 *TextDeviceNode\r
3122 )\r
3123{\r
3124 CHAR16 *StartingOffsetStr;\r
3125 CHAR16 *EndingOffsetStr;\r
3126 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
3127\r
3128 StartingOffsetStr = GetNextParamStr (&TextDeviceNode);\r
3129 EndingOffsetStr = GetNextParamStr (&TextDeviceNode);\r
3130 Offset = (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *) CreateDeviceNode (\r
3131 MEDIA_DEVICE_PATH,\r
3132 MEDIA_RELATIVE_OFFSET_RANGE_DP,\r
3133 (UINT16) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH)\r
3134 );\r
3135\r
3136 Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);\r
3137 Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);\r
3138\r
3139 return (EFI_DEVICE_PATH_PROTOCOL *) Offset;\r
3140}\r
3141\r
3142/**\r
3143 Converts a text device path node to text ram disk device path structure.\r
3144\r
3145 @param TextDeviceNode The input Text device path node.\r
3146\r
3147 @return A pointer to the newly-created Text device path structure.\r
3148\r
3149**/\r
3150EFI_DEVICE_PATH_PROTOCOL *\r
3151DevPathFromTextRamDisk (\r
3152 IN CHAR16 *TextDeviceNode\r
3153 )\r
3154{\r
3155 CHAR16 *StartingAddrStr;\r
3156 CHAR16 *EndingAddrStr;\r
3157 CHAR16 *TypeGuidStr;\r
3158 CHAR16 *InstanceStr;\r
3159 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;\r
3160 UINT64 StartingAddr;\r
3161 UINT64 EndingAddr;\r
3162\r
3163 StartingAddrStr = GetNextParamStr (&TextDeviceNode);\r
3164 EndingAddrStr = GetNextParamStr (&TextDeviceNode);\r
3165 InstanceStr = GetNextParamStr (&TextDeviceNode);\r
3166 TypeGuidStr = GetNextParamStr (&TextDeviceNode);\r
3167 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (\r
3168 MEDIA_DEVICE_PATH,\r
3169 MEDIA_RAM_DISK_DP,\r
3170 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)\r
3171 );\r
3172\r
3173 Strtoi64 (StartingAddrStr, &StartingAddr);\r
3174 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);\r
3175 Strtoi64 (EndingAddrStr, &EndingAddr);\r
3176 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);\r
3177 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);\r
3178 StrToGuid (TypeGuidStr, &RamDisk->TypeGuid);\r
3179\r
3180 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;\r
3181}\r
3182\r
3183/**\r
3184 Converts a text device path node to text virtual disk device path structure.\r
3185\r
3186 @param TextDeviceNode The input Text device path node.\r
3187\r
3188 @return A pointer to the newly-created Text device path structure.\r
3189\r
3190**/\r
3191EFI_DEVICE_PATH_PROTOCOL *\r
3192DevPathFromTextVirtualDisk (\r
3193 IN CHAR16 *TextDeviceNode\r
3194 )\r
3195{\r
3196 CHAR16 *StartingAddrStr;\r
3197 CHAR16 *EndingAddrStr;\r
3198 CHAR16 *InstanceStr;\r
3199 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;\r
3200 UINT64 StartingAddr;\r
3201 UINT64 EndingAddr;\r
3202\r
3203 StartingAddrStr = GetNextParamStr (&TextDeviceNode);\r
3204 EndingAddrStr = GetNextParamStr (&TextDeviceNode);\r
3205 InstanceStr = GetNextParamStr (&TextDeviceNode);\r
3206\r
3207 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (\r
3208 MEDIA_DEVICE_PATH,\r
3209 MEDIA_RAM_DISK_DP,\r
3210 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)\r
3211 );\r
3212\r
3213 Strtoi64 (StartingAddrStr, &StartingAddr);\r
3214 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);\r
3215 Strtoi64 (EndingAddrStr, &EndingAddr);\r
3216 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);\r
3217 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);\r
3218 CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid);\r
3219\r
3220 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;\r
3221}\r
3222\r
3223/**\r
3224 Converts a text device path node to text virtual cd device path structure.\r
3225\r
3226 @param TextDeviceNode The input Text device path node.\r
3227\r
3228 @return A pointer to the newly-created Text device path structure.\r
3229\r
3230**/\r
3231EFI_DEVICE_PATH_PROTOCOL *\r
3232DevPathFromTextVirtualCd (\r
3233 IN CHAR16 *TextDeviceNode\r
3234 )\r
3235{\r
3236 CHAR16 *StartingAddrStr;\r
3237 CHAR16 *EndingAddrStr;\r
3238 CHAR16 *InstanceStr;\r
3239 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;\r
3240 UINT64 StartingAddr;\r
3241 UINT64 EndingAddr;\r
3242\r
3243 StartingAddrStr = GetNextParamStr (&TextDeviceNode);\r
3244 EndingAddrStr = GetNextParamStr (&TextDeviceNode);\r
3245 InstanceStr = GetNextParamStr (&TextDeviceNode);\r
3246\r
3247 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (\r
3248 MEDIA_DEVICE_PATH,\r
3249 MEDIA_RAM_DISK_DP,\r
3250 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)\r
3251 );\r
3252\r
3253 Strtoi64 (StartingAddrStr, &StartingAddr);\r
3254 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);\r
3255 Strtoi64 (EndingAddrStr, &EndingAddr);\r
3256 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);\r
3257 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);\r
3258 CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid);\r
3259\r
3260 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;\r
3261}\r
3262\r
3263/**\r
3264 Converts a text device path node to text persistent virtual disk device path structure.\r
3265\r
3266 @param TextDeviceNode The input Text device path node.\r
3267\r
3268 @return A pointer to the newly-created Text device path structure.\r
3269\r
3270**/\r
3271EFI_DEVICE_PATH_PROTOCOL *\r
3272DevPathFromTextPersistentVirtualDisk (\r
3273 IN CHAR16 *TextDeviceNode\r
3274 )\r
3275{\r
3276 CHAR16 *StartingAddrStr;\r
3277 CHAR16 *EndingAddrStr;\r
3278 CHAR16 *InstanceStr;\r
3279 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;\r
3280 UINT64 StartingAddr;\r
3281 UINT64 EndingAddr;\r
3282\r
3283 StartingAddrStr = GetNextParamStr (&TextDeviceNode);\r
3284 EndingAddrStr = GetNextParamStr (&TextDeviceNode);\r
3285 InstanceStr = GetNextParamStr (&TextDeviceNode);\r
3286\r
3287 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (\r
3288 MEDIA_DEVICE_PATH,\r
3289 MEDIA_RAM_DISK_DP,\r
3290 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)\r
3291 );\r
3292\r
3293 Strtoi64 (StartingAddrStr, &StartingAddr);\r
3294 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);\r
3295 Strtoi64 (EndingAddrStr, &EndingAddr);\r
3296 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);\r
3297 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);\r
3298 CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid);\r
3299\r
3300 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;\r
3301}\r
3302\r
3303/**\r
3304 Converts a text device path node to text persistent virtual cd device path structure.\r
3305\r
3306 @param TextDeviceNode The input Text device path node.\r
3307\r
3308 @return A pointer to the newly-created Text device path structure.\r
3309\r
3310**/\r
3311EFI_DEVICE_PATH_PROTOCOL *\r
3312DevPathFromTextPersistentVirtualCd (\r
3313 IN CHAR16 *TextDeviceNode\r
3314 )\r
3315{\r
3316 CHAR16 *StartingAddrStr;\r
3317 CHAR16 *EndingAddrStr;\r
3318 CHAR16 *InstanceStr;\r
3319 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;\r
3320 UINT64 StartingAddr;\r
3321 UINT64 EndingAddr;\r
3322\r
3323 StartingAddrStr = GetNextParamStr (&TextDeviceNode);\r
3324 EndingAddrStr = GetNextParamStr (&TextDeviceNode);\r
3325 InstanceStr = GetNextParamStr (&TextDeviceNode);\r
3326\r
3327 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (\r
3328 MEDIA_DEVICE_PATH,\r
3329 MEDIA_RAM_DISK_DP,\r
3330 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)\r
3331 );\r
3332\r
3333 Strtoi64 (StartingAddrStr, &StartingAddr);\r
3334 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);\r
3335 Strtoi64 (EndingAddrStr, &EndingAddr);\r
3336 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);\r
3337 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);\r
3338 CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid);\r
3339\r
3340 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;\r
3341}\r
3342\r
3343/**\r
3344 Converts a BBS text device path node to BBS device path structure.\r
3345\r
3346 @param TextDeviceNode The input Text device path node.\r
3347\r
3348 @return A pointer to BBS device path structure.\r
3349\r
3350**/\r
3351EFI_DEVICE_PATH_PROTOCOL *\r
3352DevPathFromTextBbsPath (\r
3353 IN CHAR16 *TextDeviceNode\r
3354 )\r
3355{\r
3356 return DevPathFromTextGenericPath (BBS_DEVICE_PATH, TextDeviceNode);\r
3357}\r
3358\r
3359/**\r
3360 Converts a text device path node to BIOS Boot Specification device path structure.\r
3361\r
3362 @param TextDeviceNode The input Text device path node.\r
3363\r
3364 @return A pointer to the newly-created BIOS Boot Specification device path structure.\r
3365\r
3366**/\r
3367EFI_DEVICE_PATH_PROTOCOL *\r
3368DevPathFromTextBBS (\r
3369 IN CHAR16 *TextDeviceNode\r
3370 )\r
3371{\r
3372 CHAR16 *TypeStr;\r
3373 CHAR16 *IdStr;\r
3374 CHAR16 *FlagsStr;\r
3375 CHAR8 *AsciiStr;\r
3376 BBS_BBS_DEVICE_PATH *Bbs;\r
3377\r
3378 TypeStr = GetNextParamStr (&TextDeviceNode);\r
3379 IdStr = GetNextParamStr (&TextDeviceNode);\r
3380 FlagsStr = GetNextParamStr (&TextDeviceNode);\r
3381 Bbs = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode (\r
3382 BBS_DEVICE_PATH,\r
3383 BBS_BBS_DP,\r
3384 (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr))\r
3385 );\r
3386\r
3387 if (StrCmp (TypeStr, L"Floppy") == 0) {\r
3388 Bbs->DeviceType = BBS_TYPE_FLOPPY;\r
3389 } else if (StrCmp (TypeStr, L"HD") == 0) {\r
3390 Bbs->DeviceType = BBS_TYPE_HARDDRIVE;\r
3391 } else if (StrCmp (TypeStr, L"CDROM") == 0) {\r
3392 Bbs->DeviceType = BBS_TYPE_CDROM;\r
3393 } else if (StrCmp (TypeStr, L"PCMCIA") == 0) {\r
3394 Bbs->DeviceType = BBS_TYPE_PCMCIA;\r
3395 } else if (StrCmp (TypeStr, L"USB") == 0) {\r
3396 Bbs->DeviceType = BBS_TYPE_USB;\r
3397 } else if (StrCmp (TypeStr, L"Network") == 0) {\r
3398 Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK;\r
3399 } else {\r
3400 Bbs->DeviceType = (UINT16) Strtoi (TypeStr);\r
3401 }\r
3402\r
3403 AsciiStr = Bbs->String;\r
3404 StrToAscii (IdStr, &AsciiStr);\r
3405\r
3406 Bbs->StatusFlag = (UINT16) Strtoi (FlagsStr);\r
3407\r
3408 return (EFI_DEVICE_PATH_PROTOCOL *) Bbs;\r
3409}\r
3410\r
3411/**\r
3412 Converts a text device path node to SATA device path structure.\r
3413\r
3414 @param TextDeviceNode The input Text device path node.\r
3415\r
3416 @return A pointer to the newly-created SATA device path structure.\r
3417\r
3418**/\r
3419EFI_DEVICE_PATH_PROTOCOL *\r
3420DevPathFromTextSata (\r
3421 IN CHAR16 *TextDeviceNode\r
3422 )\r
3423{\r
3424 SATA_DEVICE_PATH *Sata;\r
3425 CHAR16 *Param1;\r
3426 CHAR16 *Param2;\r
3427 CHAR16 *Param3;\r
3428\r
3429 Param1 = GetNextParamStr (&TextDeviceNode);\r
3430 Param2 = GetNextParamStr (&TextDeviceNode);\r
3431 Param3 = GetNextParamStr (&TextDeviceNode);\r
3432\r
3433 Sata = (SATA_DEVICE_PATH *) CreateDeviceNode (\r
3434 MESSAGING_DEVICE_PATH,\r
3435 MSG_SATA_DP,\r
3436 (UINT16) sizeof (SATA_DEVICE_PATH)\r
3437 );\r
3438 Sata->HBAPortNumber = (UINT16) Strtoi (Param1);\r
3439\r
3440 //\r
3441 // According to UEFI spec, if PMPN is not provided, the default is 0xFFFF\r
3442 //\r
3443 if (*Param2 == L'\0' ) {\r
3444 Sata->PortMultiplierPortNumber = 0xFFFF;\r
3445 } else {\r
3446 Sata->PortMultiplierPortNumber = (UINT16) Strtoi (Param2);\r
3447 }\r
3448 Sata->Lun = (UINT16) Strtoi (Param3);\r
3449\r
3450 return (EFI_DEVICE_PATH_PROTOCOL *) Sata;\r
3451}\r
3452\r
3453GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable[] = {\r
3454 {L"Path", DevPathFromTextPath },\r
3455\r
3456 {L"HardwarePath", DevPathFromTextHardwarePath },\r
3457 {L"Pci", DevPathFromTextPci },\r
3458 {L"PcCard", DevPathFromTextPcCard },\r
3459 {L"MemoryMapped", DevPathFromTextMemoryMapped },\r
3460 {L"VenHw", DevPathFromTextVenHw },\r
3461 {L"Ctrl", DevPathFromTextCtrl },\r
3462 {L"BMC", DevPathFromTextBmc },\r
3463\r
3464 {L"AcpiPath", DevPathFromTextAcpiPath },\r
3465 {L"Acpi", DevPathFromTextAcpi },\r
3466 {L"PciRoot", DevPathFromTextPciRoot },\r
3467 {L"PcieRoot", DevPathFromTextPcieRoot },\r
3468 {L"Floppy", DevPathFromTextFloppy },\r
3469 {L"Keyboard", DevPathFromTextKeyboard },\r
3470 {L"Serial", DevPathFromTextSerial },\r
3471 {L"ParallelPort", DevPathFromTextParallelPort },\r
3472 {L"AcpiEx", DevPathFromTextAcpiEx },\r
3473 {L"AcpiExp", DevPathFromTextAcpiExp },\r
3474 {L"AcpiAdr", DevPathFromTextAcpiAdr },\r
3475\r
3476 {L"Msg", DevPathFromTextMsg },\r
3477 {L"Ata", DevPathFromTextAta },\r
3478 {L"Scsi", DevPathFromTextScsi },\r
3479 {L"Fibre", DevPathFromTextFibre },\r
3480 {L"FibreEx", DevPathFromTextFibreEx },\r
3481 {L"I1394", DevPathFromText1394 },\r
3482 {L"USB", DevPathFromTextUsb },\r
3483 {L"I2O", DevPathFromTextI2O },\r
3484 {L"Infiniband", DevPathFromTextInfiniband },\r
3485 {L"VenMsg", DevPathFromTextVenMsg },\r
3486 {L"VenPcAnsi", DevPathFromTextVenPcAnsi },\r
3487 {L"VenVt100", DevPathFromTextVenVt100 },\r
3488 {L"VenVt100Plus", DevPathFromTextVenVt100Plus },\r
3489 {L"VenUtf8", DevPathFromTextVenUtf8 },\r
3490 {L"UartFlowCtrl", DevPathFromTextUartFlowCtrl },\r
3491 {L"SAS", DevPathFromTextSAS },\r
3492 {L"SasEx", DevPathFromTextSasEx },\r
3493 {L"NVMe", DevPathFromTextNVMe },\r
3494 {L"UFS", DevPathFromTextUfs },\r
3495 {L"SD", DevPathFromTextSd },\r
3496 {L"eMMC", DevPathFromTextEmmc },\r
3497 {L"DebugPort", DevPathFromTextDebugPort },\r
3498 {L"MAC", DevPathFromTextMAC },\r
3499 {L"IPv4", DevPathFromTextIPv4 },\r
3500 {L"IPv6", DevPathFromTextIPv6 },\r
3501 {L"Uart", DevPathFromTextUart },\r
3502 {L"UsbClass", DevPathFromTextUsbClass },\r
3503 {L"UsbAudio", DevPathFromTextUsbAudio },\r
3504 {L"UsbCDCControl", DevPathFromTextUsbCDCControl },\r
3505 {L"UsbHID", DevPathFromTextUsbHID },\r
3506 {L"UsbImage", DevPathFromTextUsbImage },\r
3507 {L"UsbPrinter", DevPathFromTextUsbPrinter },\r
3508 {L"UsbMassStorage", DevPathFromTextUsbMassStorage },\r
3509 {L"UsbHub", DevPathFromTextUsbHub },\r
3510 {L"UsbCDCData", DevPathFromTextUsbCDCData },\r
3511 {L"UsbSmartCard", DevPathFromTextUsbSmartCard },\r
3512 {L"UsbVideo", DevPathFromTextUsbVideo },\r
3513 {L"UsbDiagnostic", DevPathFromTextUsbDiagnostic },\r
3514 {L"UsbWireless", DevPathFromTextUsbWireless },\r
3515 {L"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate },\r
3516 {L"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge },\r
3517 {L"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement },\r
3518 {L"UsbWwid", DevPathFromTextUsbWwid },\r
3519 {L"Unit", DevPathFromTextUnit },\r
3520 {L"iSCSI", DevPathFromTextiSCSI },\r
3521 {L"Vlan", DevPathFromTextVlan },\r
3522 {L"Dns", DevPathFromTextDns },\r
3523 {L"Uri", DevPathFromTextUri },\r
3524 {L"Bluetooth", DevPathFromTextBluetooth },\r
3525 {L"Wi-Fi", DevPathFromTextWiFi },\r
3526 {L"BluetoothLE", DevPathFromTextBluetoothLE },\r
3527 {L"MediaPath", DevPathFromTextMediaPath },\r
3528 {L"HD", DevPathFromTextHD },\r
3529 {L"CDROM", DevPathFromTextCDROM },\r
3530 {L"VenMedia", DevPathFromTextVenMedia },\r
3531 {L"Media", DevPathFromTextMedia },\r
3532 {L"Fv", DevPathFromTextFv },\r
3533 {L"FvFile", DevPathFromTextFvFile },\r
3534 {L"Offset", DevPathFromTextRelativeOffsetRange },\r
3535 {L"RamDisk", DevPathFromTextRamDisk },\r
3536 {L"VirtualDisk", DevPathFromTextVirtualDisk },\r
3537 {L"VirtualCD", DevPathFromTextVirtualCd },\r
3538 {L"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk },\r
3539 {L"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd },\r
3540\r
3541 {L"BbsPath", DevPathFromTextBbsPath },\r
3542 {L"BBS", DevPathFromTextBBS },\r
3543 {L"Sata", DevPathFromTextSata },\r
3544 {NULL, NULL}\r
3545};\r
3546\r
3547/**\r
3548 Convert text to the binary representation of a device node.\r
3549\r
3550 @param TextDeviceNode TextDeviceNode points to the text representation of a device\r
3551 node. Conversion starts with the first character and continues\r
3552 until the first non-device node character.\r
3553\r
3554 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
3555 insufficient memory or text unsupported.\r
3556\r
3557**/\r
3558EFI_DEVICE_PATH_PROTOCOL *\r
3559EFIAPI\r
3560UefiDevicePathLibConvertTextToDeviceNode (\r
3561 IN CONST CHAR16 *TextDeviceNode\r
3562 )\r
3563{\r
3564 DEVICE_PATH_FROM_TEXT FromText;\r
3565 CHAR16 *ParamStr;\r
3566 EFI_DEVICE_PATH_PROTOCOL *DeviceNode;\r
3567 CHAR16 *DeviceNodeStr;\r
3568 UINTN Index;\r
3569\r
3570 if ((TextDeviceNode == NULL) || (IS_NULL (*TextDeviceNode))) {\r
3571 return NULL;\r
3572 }\r
3573\r
3574 ParamStr = NULL;\r
3575 FromText = NULL;\r
3576 DeviceNodeStr = UefiDevicePathLibStrDuplicate (TextDeviceNode);\r
3577 ASSERT (DeviceNodeStr != NULL);\r
3578\r
3579 for (Index = 0; mUefiDevicePathLibDevPathFromTextTable[Index].Function != NULL; Index++) {\r
3580 ParamStr = GetParamByNodeName (DeviceNodeStr, mUefiDevicePathLibDevPathFromTextTable[Index].DevicePathNodeText);\r
3581 if (ParamStr != NULL) {\r
3582 FromText = mUefiDevicePathLibDevPathFromTextTable[Index].Function;\r
3583 break;\r
3584 }\r
3585 }\r
3586\r
3587 if (FromText == NULL) {\r
3588 //\r
3589 // A file path\r
3590 //\r
3591 FromText = DevPathFromTextFilePath;\r
3592 DeviceNode = FromText (DeviceNodeStr);\r
3593 } else {\r
3594 DeviceNode = FromText (ParamStr);\r
3595 FreePool (ParamStr);\r
3596 }\r
3597\r
3598 FreePool (DeviceNodeStr);\r
3599\r
3600 return DeviceNode;\r
3601}\r
3602\r
3603/**\r
3604 Convert text to the binary representation of a device path.\r
3605\r
3606\r
3607 @param TextDevicePath TextDevicePath points to the text representation of a device\r
3608 path. Conversion starts with the first character and continues\r
3609 until the first non-device node character.\r
3610\r
3611 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
3612 there was insufficient memory.\r
3613\r
3614**/\r
3615EFI_DEVICE_PATH_PROTOCOL *\r
3616EFIAPI\r
3617UefiDevicePathLibConvertTextToDevicePath (\r
3618 IN CONST CHAR16 *TextDevicePath\r
3619 )\r
3620{\r
3621 EFI_DEVICE_PATH_PROTOCOL *DeviceNode;\r
3622 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r
3623 CHAR16 *DevicePathStr;\r
3624 CHAR16 *Str;\r
3625 CHAR16 *DeviceNodeStr;\r
3626 BOOLEAN IsInstanceEnd;\r
3627 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
3628\r
3629 if ((TextDevicePath == NULL) || (IS_NULL (*TextDevicePath))) {\r
3630 return NULL;\r
3631 }\r
3632\r
3633 DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
3634 ASSERT (DevicePath != NULL);\r
3635 SetDevicePathEndNode (DevicePath);\r
3636\r
3637 DevicePathStr = UefiDevicePathLibStrDuplicate (TextDevicePath);\r
3638\r
3639 Str = DevicePathStr;\r
3640 while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {\r
3641 DeviceNode = UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr);\r
3642\r
3643 NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);\r
3644 FreePool (DevicePath);\r
3645 FreePool (DeviceNode);\r
3646 DevicePath = NewDevicePath;\r
3647\r
3648 if (IsInstanceEnd) {\r
3649 DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
3650 ASSERT (DeviceNode != NULL);\r
3651 SetDevicePathEndNode (DeviceNode);\r
3652 DeviceNode->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;\r
3653\r
3654 NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);\r
3655 FreePool (DevicePath);\r
3656 FreePool (DeviceNode);\r
3657 DevicePath = NewDevicePath;\r
3658 }\r
3659 }\r
3660\r
3661 FreePool (DevicePathStr);\r
3662 return DevicePath;\r
3663}\r