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