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