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