2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
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.
15 #include "DevicePath.h"
22 @param Src Source string.
24 @return The duplicated string.
32 return AllocateCopyPool (StrSize (Src
), Src
);
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".
40 @param Str Device Path Text.
41 @param NodeName Name of the node.
43 @return Parameter text for the node.
55 UINTN ParameterLength
;
58 // Check whether the node name matchs
60 NodeNameLength
= StrLen (NodeName
);
61 if (CompareMem (Str
, NodeName
, NodeNameLength
* sizeof (CHAR16
)) != 0) {
65 ParamStr
= Str
+ NodeNameLength
;
66 if (!IS_LEFT_PARENTH (*ParamStr
)) {
71 // Skip the found '(' and find first occurrence of ')'
75 StrPointer
= ParamStr
;
76 while (!IS_NULL (*StrPointer
)) {
77 if (IS_RIGHT_PARENTH (*StrPointer
)) {
83 if (IS_NULL (*StrPointer
)) {
90 ParamStr
= AllocateCopyPool ((ParameterLength
+ 1) * sizeof (CHAR16
), ParamStr
);
91 if (ParamStr
== NULL
) {
95 // Terminate the parameter string
97 ParamStr
[ParameterLength
] = L
'\0';
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"
108 @param List A string list separated by the specified separator
109 @param Separator The separator character
111 @return A pointer to the current sub-string
116 IN OUT CHAR16
**List
,
126 if (IS_NULL (*Str
)) {
131 // Find first occurrence of the separator
133 while (!IS_NULL (*Str
)) {
134 if (*Str
== Separator
) {
140 if (*Str
== Separator
) {
142 // Find a sub-string, terminate it
149 // Move to next sub-string
157 Gets the next parameter string from the list.
159 @param List A string list separated by the specified separator
161 @return A pointer to the current sub-string
170 // The separator is comma
172 return SplitStr (List
, L
',');
176 Get one device node from entire device path text.
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
181 @return A device node text or NULL if no more device node available
185 GetNextDeviceNodeStr (
186 IN OUT CHAR16
**DevicePath
,
187 OUT BOOLEAN
*IsInstanceEnd
192 UINTN ParenthesesStack
;
195 if (IS_NULL (*Str
)) {
200 // Skip the leading '/', '(', ')' and ','
202 while (!IS_NULL (*Str
)) {
203 if (!IS_SLASH (*Str
) &&
205 !IS_LEFT_PARENTH (*Str
) &&
206 !IS_RIGHT_PARENTH (*Str
)) {
215 // Scan for the separator of this device node, '/' or ','
217 ParenthesesStack
= 0;
218 while (!IS_NULL (*Str
)) {
219 if ((IS_COMMA (*Str
) || IS_SLASH (*Str
)) && (ParenthesesStack
== 0)) {
223 if (IS_LEFT_PARENTH (*Str
)) {
225 } else if (IS_RIGHT_PARENTH (*Str
)) {
232 if (ParenthesesStack
!= 0) {
234 // The '(' doesn't pair with ')', invalid device path text
239 if (IS_COMMA (*Str
)) {
240 *IsInstanceEnd
= TRUE
;
244 *IsInstanceEnd
= FALSE
;
245 if (!IS_NULL (*Str
)) {
258 Skip the leading white space and '0x' or '0X' of a integer string
260 @param Str The integer string
261 @param IsHex TRUE: Hex string, FALSE: Decimal string
263 @return The trimmed Hex string.
275 // skip preceeding white space
277 while ((*Str
!= 0) && *Str
== ' ') {
281 // skip preceeding zeros
283 while ((*Str
!= 0) && *Str
== '0') {
287 // skip preceeding character 'x' or 'X'
289 if ((*Str
!= 0) && (*Str
== 'x' || *Str
== 'X')) {
299 Convert hex string to uint.
301 @param Str The hex string
303 @return A UINTN value represented by Str
311 return StrHexToUintn (Str
);
316 Convert hex string to 64 bit data.
318 @param Str The hex string
319 @param Data A pointer to the UINT64 value represented by Str
328 *Data
= StrHexToUint64 (Str
);
333 Convert decimal string to uint.
335 @param Str The decimal string
337 @return A UINTN value represented by Str
350 ASSERT (Str
!= NULL
);
352 High
= (UINTN
) -1 / 10;
353 Low
= (UINTN
) -1 % 10;
355 // skip preceeding white space
357 while ((*Str
!= 0) && *Str
== ' ') {
366 if (Char
>= '0' && Char
<= '9') {
367 if ((Rvalue
> High
|| Rvalue
== High
) && (Char
- '0' > (INTN
) Low
)) {
371 Rvalue
= (Rvalue
* 10) + Char
- '0';
384 Convert decimal string to uint.
386 @param Str The decimal string
387 @param Data A pointer to the UINT64 value represented by Str
401 ASSERT (Str
!= NULL
);
402 ASSERT (Data
!= NULL
);
405 // skip preceeding white space
407 while ((*Str
!= 0) && *Str
== ' ') {
416 if (Char
>= '0' && Char
<= '9') {
417 High
= LShiftU64 (Rvalue
, 3);
418 Low
= LShiftU64 (Rvalue
, 1);
419 Rvalue
= High
+ Low
+ Char
- '0';
432 Convert integer string to uint.
434 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
436 @return A UINTN value represented by Str
446 Str
= TrimHexStr (Str
, &IsHex
);
457 Convert integer string to 64 bit data.
459 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
460 @param Data A pointer to the UINT64 value represented by Str
471 Str
= TrimHexStr (Str
, &IsHex
);
481 Converts a list of string to a specified buffer.
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
487 @retval EFI_SUCCESS The string was successfully converted to the buffer.
493 IN UINTN BufferLength
,
505 // Two hex char make up one byte
507 StrLength
= BufferLength
* sizeof (CHAR16
);
509 for(Index
= 0; Index
< StrLength
; Index
++, Str
++) {
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');
518 return EFI_INVALID_PARAMETER
;
522 // For odd characters, write the upper nibble for each buffer byte,
523 // and for even characters, the lower nibble.
525 if ((Index
& 1) == 0) {
526 Byte
= (UINT8
) (Digit
<< 4);
528 Byte
= Buf
[Index
/ 2];
530 Byte
= (UINT8
) (Byte
| Digit
);
533 Buf
[Index
/ 2] = Byte
;
540 Converts a string to GUID value.
541 Guid Format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
543 @param Str The registry format GUID string that contains the GUID value.
544 @param Guid A pointer to the converted GUID value.
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.
558 // Get the first UINT32 data
560 Guid
->Data1
= (UINT32
) StrHexToUint64 (Str
);
561 while (!IS_HYPHEN (*Str
) && !IS_NULL (*Str
)) {
565 if (IS_HYPHEN (*Str
)) {
568 return EFI_UNSUPPORTED
;
572 // Get the second UINT16 data
574 Guid
->Data2
= (UINT16
) StrHexToUint64 (Str
);
575 while (!IS_HYPHEN (*Str
) && !IS_NULL (*Str
)) {
579 if (IS_HYPHEN (*Str
)) {
582 return EFI_UNSUPPORTED
;
586 // Get the third UINT16 data
588 Guid
->Data3
= (UINT16
) StrHexToUint64 (Str
);
589 while (!IS_HYPHEN (*Str
) && !IS_NULL (*Str
)) {
593 if (IS_HYPHEN (*Str
)) {
596 return EFI_UNSUPPORTED
;
600 // Get the following 8 bytes data
602 StrToBuf (&Guid
->Data4
[0], 2, Str
);
604 // Skip 2 byte hex chars
608 if (IS_HYPHEN (*Str
)) {
611 return EFI_UNSUPPORTED
;
613 StrToBuf (&Guid
->Data4
[2], 6, Str
);
619 Converts a string to IPv4 address
621 @param Str A string representation of IPv4 address.
622 @param IPv4Addr A pointer to the converted IPv4 address.
628 OUT EFI_IPv4_ADDRESS
*IPv4Addr
633 for (Index
= 0; Index
< 4; Index
++) {
634 IPv4Addr
->Addr
[Index
] = (UINT8
) Dtoi (SplitStr (Str
, L
'.'));
639 Converts a string to IPv4 address
641 @param Str A string representation of IPv6 address.
642 @param IPv6Addr A pointer to the converted IPv6 address.
648 OUT EFI_IPv6_ADDRESS
*IPv6Addr
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);
662 Converts a Unicode string to ASCII string.
664 @param Str The equivalent 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
672 IN OUT CHAR8
**AsciiStr
678 while (!IS_NULL (*Str
)) {
679 *(Dest
++) = (CHAR8
) *(Str
++);
684 // Return the string next to it
686 *AsciiStr
= Dest
+ 1;
690 Converts a text device path node to Hardware PCI device path structure.
692 @param TextDeviceNode The input Text device path node.
694 @return A pointer to Hardware PCI device path structure.
697 EFI_DEVICE_PATH_PROTOCOL
*
699 IN CHAR16
*TextDeviceNode
704 PCI_DEVICE_PATH
*Pci
;
706 DeviceStr
= GetNextParamStr (&TextDeviceNode
);
707 FunctionStr
= GetNextParamStr (&TextDeviceNode
);
708 Pci
= (PCI_DEVICE_PATH
*) CreateDeviceNode (
709 HARDWARE_DEVICE_PATH
,
711 (UINT16
) sizeof (PCI_DEVICE_PATH
)
714 Pci
->Function
= (UINT8
) Strtoi (FunctionStr
);
715 Pci
->Device
= (UINT8
) Strtoi (DeviceStr
);
717 return (EFI_DEVICE_PATH_PROTOCOL
*) Pci
;
721 Converts a text device path node to Hardware PC card device path structure.
723 @param TextDeviceNode The input Text device path node.
725 @return A pointer to Hardware PC card device path structure.
728 EFI_DEVICE_PATH_PROTOCOL
*
729 DevPathFromTextPcCard (
730 IN CHAR16
*TextDeviceNode
733 CHAR16
*FunctionNumberStr
;
734 PCCARD_DEVICE_PATH
*Pccard
;
736 FunctionNumberStr
= GetNextParamStr (&TextDeviceNode
);
737 Pccard
= (PCCARD_DEVICE_PATH
*) CreateDeviceNode (
738 HARDWARE_DEVICE_PATH
,
740 (UINT16
) sizeof (PCCARD_DEVICE_PATH
)
743 Pccard
->FunctionNumber
= (UINT8
) Strtoi (FunctionNumberStr
);
745 return (EFI_DEVICE_PATH_PROTOCOL
*) Pccard
;
749 Converts a text device path node to Hardware memory map device path structure.
751 @param TextDeviceNode The input Text device path node.
753 @return A pointer to Hardware memory map device path structure.
756 EFI_DEVICE_PATH_PROTOCOL
*
757 DevPathFromTextMemoryMapped (
758 IN CHAR16
*TextDeviceNode
761 CHAR16
*MemoryTypeStr
;
762 CHAR16
*StartingAddressStr
;
763 CHAR16
*EndingAddressStr
;
764 MEMMAP_DEVICE_PATH
*MemMap
;
766 MemoryTypeStr
= GetNextParamStr (&TextDeviceNode
);
767 StartingAddressStr
= GetNextParamStr (&TextDeviceNode
);
768 EndingAddressStr
= GetNextParamStr (&TextDeviceNode
);
769 MemMap
= (MEMMAP_DEVICE_PATH
*) CreateDeviceNode (
770 HARDWARE_DEVICE_PATH
,
772 (UINT16
) sizeof (MEMMAP_DEVICE_PATH
)
775 MemMap
->MemoryType
= (UINT32
) Strtoi (MemoryTypeStr
);
776 Strtoi64 (StartingAddressStr
, &MemMap
->StartingAddress
);
777 Strtoi64 (EndingAddressStr
, &MemMap
->EndingAddress
);
779 return (EFI_DEVICE_PATH_PROTOCOL
*) MemMap
;
783 Converts a text device path node to Vendor device path structure based on the input Type
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.
790 @return A pointer to the newly-created Vendor device path structure.
793 EFI_DEVICE_PATH_PROTOCOL
*
794 ConvertFromTextVendor (
795 IN CHAR16
*TextDeviceNode
,
803 VENDOR_DEVICE_PATH
*Vendor
;
805 GuidStr
= GetNextParamStr (&TextDeviceNode
);
807 DataStr
= GetNextParamStr (&TextDeviceNode
);
808 Length
= StrLen (DataStr
);
810 // Two hex characters make up 1 buffer byte
812 Length
= (Length
+ 1) / 2;
814 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
817 (UINT16
) (sizeof (VENDOR_DEVICE_PATH
) + Length
)
820 StrToGuid (GuidStr
, &Vendor
->Guid
);
821 StrToBuf (((UINT8
*) Vendor
) + sizeof (VENDOR_DEVICE_PATH
), Length
, DataStr
);
823 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
827 Converts a text device path node to Vendor Hardware device path structure.
829 @param TextDeviceNode The input Text device path node.
831 @return A pointer to the newly-created Vendor Hardware device path structure.
834 EFI_DEVICE_PATH_PROTOCOL
*
835 DevPathFromTextVenHw (
836 IN CHAR16
*TextDeviceNode
839 return ConvertFromTextVendor (
841 HARDWARE_DEVICE_PATH
,
847 Converts a text device path node to Hardware Controller device path structure.
849 @param TextDeviceNode The input Text device path node.
851 @return A pointer to the newly-created Hardware Controller device path structure.
854 EFI_DEVICE_PATH_PROTOCOL
*
855 DevPathFromTextCtrl (
856 IN CHAR16
*TextDeviceNode
859 CHAR16
*ControllerStr
;
860 CONTROLLER_DEVICE_PATH
*Controller
;
862 ControllerStr
= GetNextParamStr (&TextDeviceNode
);
863 Controller
= (CONTROLLER_DEVICE_PATH
*) CreateDeviceNode (
864 HARDWARE_DEVICE_PATH
,
866 (UINT16
) sizeof (CONTROLLER_DEVICE_PATH
)
868 Controller
->ControllerNumber
= (UINT32
) Strtoi (ControllerStr
);
870 return (EFI_DEVICE_PATH_PROTOCOL
*) Controller
;
874 Converts a string to EisaId.
876 @param Text The input string.
877 @param EisaId A pointer to the output EisaId.
888 PnpId
= Xtoi (Text
+ 3);
889 *EisaId
= (((Text
[0] - '@') & 0x1f) << 10) +
890 (((Text
[1] - '@') & 0x1f) << 5) +
891 ((Text
[2] - '@') & 0x1f) +
892 (UINT32
) (PnpId
<< 16);
896 Converts a text device path node to ACPI HID device path structure.
898 @param TextDeviceNode The input Text device path node.
900 @return A pointer to the newly-created ACPI HID device path structure.
903 EFI_DEVICE_PATH_PROTOCOL
*
904 DevPathFromTextAcpi (
905 IN CHAR16
*TextDeviceNode
910 ACPI_HID_DEVICE_PATH
*Acpi
;
912 HIDStr
= GetNextParamStr (&TextDeviceNode
);
913 UIDStr
= GetNextParamStr (&TextDeviceNode
);
914 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
917 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
920 EisaIdFromText (HIDStr
, &Acpi
->HID
);
921 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
923 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
927 Converts a text device path node to ACPI HID device path structure.
929 @param TextDeviceNode The input Text device path node.
930 @param PnPId The input plug and play identification.
932 @return A pointer to the newly-created ACPI HID device path structure.
935 EFI_DEVICE_PATH_PROTOCOL
*
936 ConvertFromTextAcpi (
937 IN CHAR16
*TextDeviceNode
,
942 ACPI_HID_DEVICE_PATH
*Acpi
;
944 UIDStr
= GetNextParamStr (&TextDeviceNode
);
945 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
948 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
951 Acpi
->HID
= EFI_PNP_ID (PnPId
);
952 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
954 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
958 Converts a text device path node to PCI root device path structure.
960 @param TextDeviceNode The input Text device path node.
962 @return A pointer to the newly-created PCI root device path structure.
965 EFI_DEVICE_PATH_PROTOCOL
*
966 DevPathFromTextPciRoot (
967 IN CHAR16
*TextDeviceNode
970 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a03);
974 Converts a text device path node to Floppy device path structure.
976 @param TextDeviceNode The input Text device path node.
978 @return A pointer to the newly-created Floppy device path structure.
981 EFI_DEVICE_PATH_PROTOCOL
*
982 DevPathFromTextFloppy (
983 IN CHAR16
*TextDeviceNode
986 return ConvertFromTextAcpi (TextDeviceNode
, 0x0604);
990 Converts a text device path node to Keyboard device path structure.
992 @param TextDeviceNode The input Text device path node.
994 @return A pointer to the newly-created Keyboard device path structure.
997 EFI_DEVICE_PATH_PROTOCOL
*
998 DevPathFromTextKeyboard (
999 IN CHAR16
*TextDeviceNode
1002 return ConvertFromTextAcpi (TextDeviceNode
, 0x0301);
1006 Converts a text device path node to Serial device path structure.
1008 @param TextDeviceNode The input Text device path node.
1010 @return A pointer to the newly-created Serial device path structure.
1013 EFI_DEVICE_PATH_PROTOCOL
*
1014 DevPathFromTextSerial (
1015 IN CHAR16
*TextDeviceNode
1018 return ConvertFromTextAcpi (TextDeviceNode
, 0x0501);
1022 Converts a text device path node to Parallel Port device path structure.
1024 @param TextDeviceNode The input Text device path node.
1026 @return A pointer to the newly-created Parallel Port device path structure.
1029 EFI_DEVICE_PATH_PROTOCOL
*
1030 DevPathFromTextParallelPort (
1031 IN CHAR16
*TextDeviceNode
1034 return ConvertFromTextAcpi (TextDeviceNode
, 0x0401);
1038 Converts a text device path node to ACPI extension device path structure.
1040 @param TextDeviceNode The input Text device path node.
1042 @return A pointer to the newly-created ACPI extension device path structure.
1045 EFI_DEVICE_PATH_PROTOCOL
*
1046 DevPathFromTextAcpiEx (
1047 IN CHAR16
*TextDeviceNode
1058 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
1060 HIDStr
= GetNextParamStr (&TextDeviceNode
);
1061 CIDStr
= GetNextParamStr (&TextDeviceNode
);
1062 UIDStr
= GetNextParamStr (&TextDeviceNode
);
1063 HIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1064 CIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1065 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
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 (
1076 EisaIdFromText (HIDStr
, &AcpiEx
->HID
);
1077 EisaIdFromText (CIDStr
, &AcpiEx
->CID
);
1078 AcpiEx
->UID
= (UINT32
) Strtoi (UIDStr
);
1080 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
1081 StrToAscii (HIDSTRStr
, &AsciiStr
);
1082 StrToAscii (UIDSTRStr
, &AsciiStr
);
1083 StrToAscii (CIDSTRStr
, &AsciiStr
);
1085 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
1089 Converts a text device path node to ACPI extension device path structure.
1091 @param TextDeviceNode The input Text device path node.
1093 @return A pointer to the newly-created ACPI extension device path structure.
1096 EFI_DEVICE_PATH_PROTOCOL
*
1097 DevPathFromTextAcpiExp (
1098 IN CHAR16
*TextDeviceNode
1106 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
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 (
1118 EisaIdFromText (HIDStr
, &AcpiEx
->HID
);
1119 EisaIdFromText (CIDStr
, &AcpiEx
->CID
);
1122 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
1124 // HID string is NULL
1128 // Convert UID string
1131 StrToAscii (UIDSTRStr
, &AsciiStr
);
1133 // CID string is NULL
1137 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
1141 Converts a text device path node to ACPI _ADR device path structure.
1143 @param TextDeviceNode The input Text device path node.
1145 @return A pointer to the newly-created ACPI _ADR device path structure.
1148 EFI_DEVICE_PATH_PROTOCOL
*
1149 DevPathFromTextAcpiAdr (
1150 IN CHAR16
*TextDeviceNode
1153 CHAR16
*DisplayDeviceStr
;
1154 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
1158 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*) CreateDeviceNode (
1161 (UINT16
) sizeof (ACPI_ADR_DEVICE_PATH
)
1163 ASSERT (AcpiAdr
!= NULL
);
1165 for (Index
= 0; ; Index
++) {
1166 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
1167 if (IS_NULL (*DisplayDeviceStr
)) {
1171 Length
= DevicePathNodeLength (AcpiAdr
);
1172 AcpiAdr
= ReallocatePool (
1174 Length
+ sizeof (UINT32
),
1177 ASSERT (AcpiAdr
!= NULL
);
1178 SetDevicePathNodeLength (AcpiAdr
, Length
+ sizeof (UINT32
));
1181 (&AcpiAdr
->ADR
)[Index
] = (UINT32
) Strtoi (DisplayDeviceStr
);
1184 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
;
1188 Converts a text device path node to Parallel Port device path structure.
1190 @param TextDeviceNode The input Text device path node.
1192 @return A pointer to the newly-created Parallel Port device path structure.
1195 EFI_DEVICE_PATH_PROTOCOL
*
1196 DevPathFromTextAta (
1197 IN CHAR16
*TextDeviceNode
1200 CHAR16
*PrimarySecondaryStr
;
1201 CHAR16
*SlaveMasterStr
;
1203 ATAPI_DEVICE_PATH
*Atapi
;
1205 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
1206 MESSAGING_DEVICE_PATH
,
1208 (UINT16
) sizeof (ATAPI_DEVICE_PATH
)
1211 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
1212 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
1213 LunStr
= GetNextParamStr (&TextDeviceNode
);
1215 Atapi
->PrimarySecondary
= (UINT8
) ((StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) ? 0 : 1);
1216 Atapi
->SlaveMaster
= (UINT8
) ((StrCmp (SlaveMasterStr
, L
"Master") == 0) ? 0 : 1);
1217 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
1219 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
1223 Converts a text device path node to SCSI device path structure.
1225 @param TextDeviceNode The input Text device path node.
1227 @return A pointer to the newly-created SCSI device path structure.
1230 EFI_DEVICE_PATH_PROTOCOL
*
1231 DevPathFromTextScsi (
1232 IN CHAR16
*TextDeviceNode
1237 SCSI_DEVICE_PATH
*Scsi
;
1239 PunStr
= GetNextParamStr (&TextDeviceNode
);
1240 LunStr
= GetNextParamStr (&TextDeviceNode
);
1241 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
1242 MESSAGING_DEVICE_PATH
,
1244 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
1247 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
1248 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
1250 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
1254 Converts a text device path node to Fibre device path structure.
1256 @param TextDeviceNode The input Text device path node.
1258 @return A pointer to the newly-created Fibre device path structure.
1261 EFI_DEVICE_PATH_PROTOCOL
*
1262 DevPathFromTextFibre (
1263 IN CHAR16
*TextDeviceNode
1268 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
1270 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1271 LunStr
= GetNextParamStr (&TextDeviceNode
);
1272 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
1273 MESSAGING_DEVICE_PATH
,
1274 MSG_FIBRECHANNEL_DP
,
1275 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
1278 Fibre
->Reserved
= 0;
1279 Strtoi64 (WWNStr
, &Fibre
->WWN
);
1280 Strtoi64 (LunStr
, &Fibre
->Lun
);
1282 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
1286 Converts a text device path node to 1394 device path structure.
1288 @param TextDeviceNode The input Text device path node.
1290 @return A pointer to the newly-created 1394 device path structure.
1293 EFI_DEVICE_PATH_PROTOCOL
*
1294 DevPathFromText1394 (
1295 IN CHAR16
*TextDeviceNode
1299 F1394_DEVICE_PATH
*F1394DevPath
;
1301 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1302 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1303 MESSAGING_DEVICE_PATH
,
1305 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1308 F1394DevPath
->Reserved
= 0;
1309 Xtoi64 (GuidStr
, &F1394DevPath
->Guid
);
1311 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1315 Converts a text device path node to USB device path structure.
1317 @param TextDeviceNode The input Text device path node.
1319 @return A pointer to the newly-created USB device path structure.
1322 EFI_DEVICE_PATH_PROTOCOL
*
1323 DevPathFromTextUsb (
1324 IN CHAR16
*TextDeviceNode
1328 CHAR16
*InterfaceStr
;
1329 USB_DEVICE_PATH
*Usb
;
1331 PortStr
= GetNextParamStr (&TextDeviceNode
);
1332 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1333 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1334 MESSAGING_DEVICE_PATH
,
1336 (UINT16
) sizeof (USB_DEVICE_PATH
)
1339 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1340 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1342 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1346 Converts a text device path node to I20 device path structure.
1348 @param TextDeviceNode The input Text device path node.
1350 @return A pointer to the newly-created I20 device path structure.
1353 EFI_DEVICE_PATH_PROTOCOL
*
1354 DevPathFromTextI2O (
1355 IN CHAR16
*TextDeviceNode
1359 I2O_DEVICE_PATH
*I2ODevPath
;
1361 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1362 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1363 MESSAGING_DEVICE_PATH
,
1365 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1368 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1370 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1374 Converts a text device path node to Infini Band device path structure.
1376 @param TextDeviceNode The input Text device path node.
1378 @return A pointer to the newly-created Infini Band device path structure.
1381 EFI_DEVICE_PATH_PROTOCOL
*
1382 DevPathFromTextInfiniband (
1383 IN CHAR16
*TextDeviceNode
1392 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1394 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1395 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1396 SidStr
= GetNextParamStr (&TextDeviceNode
);
1397 TidStr
= GetNextParamStr (&TextDeviceNode
);
1398 DidStr
= GetNextParamStr (&TextDeviceNode
);
1399 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1400 MESSAGING_DEVICE_PATH
,
1402 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1405 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1406 StrToGuid (GuidStr
, &PortGid
);
1407 CopyMem (InfiniBand
->PortGid
, &PortGid
, sizeof (EFI_GUID
));
1408 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1409 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1410 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1412 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1416 Converts a text device path node to Vendor-Defined Messaging device path structure.
1418 @param TextDeviceNode The input Text device path node.
1420 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1423 EFI_DEVICE_PATH_PROTOCOL
*
1424 DevPathFromTextVenMsg (
1425 IN CHAR16
*TextDeviceNode
1428 return ConvertFromTextVendor (
1430 MESSAGING_DEVICE_PATH
,
1436 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1438 @param TextDeviceNode The input Text device path node.
1440 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1443 EFI_DEVICE_PATH_PROTOCOL
*
1444 DevPathFromTextVenPcAnsi (
1445 IN CHAR16
*TextDeviceNode
1448 VENDOR_DEVICE_PATH
*Vendor
;
1450 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1451 MESSAGING_DEVICE_PATH
,
1453 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1454 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1456 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1460 Converts a text device path node to Vendor defined VT100 device path structure.
1462 @param TextDeviceNode The input Text device path node.
1464 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1467 EFI_DEVICE_PATH_PROTOCOL
*
1468 DevPathFromTextVenVt100 (
1469 IN CHAR16
*TextDeviceNode
1472 VENDOR_DEVICE_PATH
*Vendor
;
1474 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1475 MESSAGING_DEVICE_PATH
,
1477 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1478 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1480 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1484 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1486 @param TextDeviceNode The input Text device path node.
1488 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1491 EFI_DEVICE_PATH_PROTOCOL
*
1492 DevPathFromTextVenVt100Plus (
1493 IN CHAR16
*TextDeviceNode
1496 VENDOR_DEVICE_PATH
*Vendor
;
1498 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1499 MESSAGING_DEVICE_PATH
,
1501 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1502 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1504 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1508 Converts a text device path node to Vendor defined UTF8 device path structure.
1510 @param TextDeviceNode The input Text device path node.
1512 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1515 EFI_DEVICE_PATH_PROTOCOL
*
1516 DevPathFromTextVenUtf8 (
1517 IN CHAR16
*TextDeviceNode
1520 VENDOR_DEVICE_PATH
*Vendor
;
1522 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1523 MESSAGING_DEVICE_PATH
,
1525 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1526 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1528 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1532 Converts a text device path node to UART Flow Control device path structure.
1534 @param TextDeviceNode The input Text device path node.
1536 @return A pointer to the newly-created UART Flow Control device path structure.
1539 EFI_DEVICE_PATH_PROTOCOL
*
1540 DevPathFromTextUartFlowCtrl (
1541 IN CHAR16
*TextDeviceNode
1545 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1547 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1548 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1549 MESSAGING_DEVICE_PATH
,
1551 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1554 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1555 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1556 UartFlowControl
->FlowControlMap
= 2;
1557 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1558 UartFlowControl
->FlowControlMap
= 1;
1560 UartFlowControl
->FlowControlMap
= 0;
1563 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1567 Converts a text device path node to Serial Attached SCSI device path structure.
1569 @param TextDeviceNode The input Text device path node.
1571 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1574 EFI_DEVICE_PATH_PROTOCOL
*
1575 DevPathFromTextSAS (
1576 IN CHAR16
*TextDeviceNode
1583 CHAR16
*LocationStr
;
1585 CHAR16
*DriveBayStr
;
1586 CHAR16
*ReservedStr
;
1588 SAS_DEVICE_PATH
*Sas
;
1590 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1591 LunStr
= GetNextParamStr (&TextDeviceNode
);
1592 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1593 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1594 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1595 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1596 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1597 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1599 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1600 MESSAGING_DEVICE_PATH
,
1602 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1605 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1606 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1607 Strtoi64 (LunStr
, &Sas
->Lun
);
1608 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1609 if (StrCmp (SASSATAStr
, L
"NoTopology") != 0) {
1610 if (StrCmp (DriveBayStr
, L
"0") == 0) {
1614 Info
= (UINT16
) (Info
| (Strtoi (DriveBayStr
) << 8));
1617 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1621 if (StrCmp (LocationStr
, L
"External") == 0) {
1625 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1630 Sas
->DeviceTopology
= Info
;
1631 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1633 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1637 Converts a text device path node to Debug Port device path structure.
1639 @param TextDeviceNode The input Text device path node.
1641 @return A pointer to the newly-created Debug Port device path structure.
1644 EFI_DEVICE_PATH_PROTOCOL
*
1645 DevPathFromTextDebugPort (
1646 IN CHAR16
*TextDeviceNode
1649 VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*Vend
;
1651 Vend
= (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*) CreateDeviceNode (
1652 MESSAGING_DEVICE_PATH
,
1654 (UINT16
) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
)
1657 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1659 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1663 Converts a text device path node to MAC device path structure.
1665 @param TextDeviceNode The input Text device path node.
1667 @return A pointer to the newly-created MAC device path structure.
1670 EFI_DEVICE_PATH_PROTOCOL
*
1671 DevPathFromTextMAC (
1672 IN CHAR16
*TextDeviceNode
1678 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1680 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1681 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1682 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1683 MESSAGING_DEVICE_PATH
,
1685 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1688 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1690 Length
= sizeof (EFI_MAC_ADDRESS
);
1691 StrToBuf (&MACDevPath
->MacAddress
.Addr
[0], Length
, AddressStr
);
1693 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1698 Converts a text format to the network protocol ID.
1700 @param Text String of protocol field.
1702 @return Network protocol ID .
1706 NetworkProtocolFromText (
1710 if (StrCmp (Text
, L
"UDP") == 0) {
1711 return RFC_1700_UDP_PROTOCOL
;
1714 if (StrCmp (Text
, L
"TCP") == 0) {
1715 return RFC_1700_TCP_PROTOCOL
;
1718 return Strtoi (Text
);
1723 Converts a text device path node to IPV4 device path structure.
1725 @param TextDeviceNode The input Text device path node.
1727 @return A pointer to the newly-created IPV4 device path structure.
1730 EFI_DEVICE_PATH_PROTOCOL
*
1731 DevPathFromTextIPv4 (
1732 IN CHAR16
*TextDeviceNode
1735 CHAR16
*RemoteIPStr
;
1736 CHAR16
*ProtocolStr
;
1739 IPv4_DEVICE_PATH
*IPv4
;
1741 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1742 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1743 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1744 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1745 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1746 MESSAGING_DEVICE_PATH
,
1748 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
1751 StrToIPv4Addr (&RemoteIPStr
, &IPv4
->RemoteIpAddress
);
1752 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1753 if (StrCmp (TypeStr
, L
"Static") == 0) {
1754 IPv4
->StaticIpAddress
= TRUE
;
1756 IPv4
->StaticIpAddress
= FALSE
;
1759 StrToIPv4Addr (&LocalIPStr
, &IPv4
->LocalIpAddress
);
1761 IPv4
->LocalPort
= 0;
1762 IPv4
->RemotePort
= 0;
1764 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1768 Converts a text device path node to IPV6 device path structure.
1770 @param TextDeviceNode The input Text device path node.
1772 @return A pointer to the newly-created IPV6 device path structure.
1775 EFI_DEVICE_PATH_PROTOCOL
*
1776 DevPathFromTextIPv6 (
1777 IN CHAR16
*TextDeviceNode
1780 CHAR16
*RemoteIPStr
;
1781 CHAR16
*ProtocolStr
;
1784 IPv6_DEVICE_PATH
*IPv6
;
1786 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1787 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1788 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1789 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1790 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1791 MESSAGING_DEVICE_PATH
,
1793 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
1796 StrToIPv6Addr (&RemoteIPStr
, &IPv6
->RemoteIpAddress
);
1797 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1798 if (StrCmp (TypeStr
, L
"Static") == 0) {
1799 IPv6
->StaticIpAddress
= TRUE
;
1801 IPv6
->StaticIpAddress
= FALSE
;
1804 StrToIPv6Addr (&LocalIPStr
, &IPv6
->LocalIpAddress
);
1806 IPv6
->LocalPort
= 0;
1807 IPv6
->RemotePort
= 0;
1809 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
1813 Converts a text device path node to UART device path structure.
1815 @param TextDeviceNode The input Text device path node.
1817 @return A pointer to the newly-created UART device path structure.
1820 EFI_DEVICE_PATH_PROTOCOL
*
1821 DevPathFromTextUart (
1822 IN CHAR16
*TextDeviceNode
1826 CHAR16
*DataBitsStr
;
1828 CHAR16
*StopBitsStr
;
1829 UART_DEVICE_PATH
*Uart
;
1831 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1832 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1833 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1834 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1835 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
1836 MESSAGING_DEVICE_PATH
,
1838 (UINT16
) sizeof (UART_DEVICE_PATH
)
1841 Uart
->BaudRate
= (StrCmp (BaudStr
, L
"DEFAULT") == 0) ? 115200 : Dtoi (BaudStr
);
1842 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Dtoi (DataBitsStr
));
1843 switch (*ParityStr
) {
1868 Uart
->Parity
= 0xff;
1871 if (StrCmp (StopBitsStr
, L
"D") == 0) {
1872 Uart
->StopBits
= (UINT8
) 0;
1873 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
1874 Uart
->StopBits
= (UINT8
) 1;
1875 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
1876 Uart
->StopBits
= (UINT8
) 2;
1877 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
1878 Uart
->StopBits
= (UINT8
) 3;
1880 Uart
->StopBits
= 0xff;
1883 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
1887 Converts a text device path node to USB class device path structure.
1889 @param TextDeviceNode The input Text device path node.
1890 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
1892 @return A pointer to the newly-created USB class device path structure.
1895 EFI_DEVICE_PATH_PROTOCOL
*
1896 ConvertFromTextUsbClass (
1897 IN CHAR16
*TextDeviceNode
,
1898 IN USB_CLASS_TEXT
*UsbClassText
1904 CHAR16
*SubClassStr
;
1905 CHAR16
*ProtocolStr
;
1906 USB_CLASS_DEVICE_PATH
*UsbClass
;
1908 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
1909 MESSAGING_DEVICE_PATH
,
1911 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
1914 VIDStr
= GetNextParamStr (&TextDeviceNode
);
1915 PIDStr
= GetNextParamStr (&TextDeviceNode
);
1916 if (UsbClassText
->ClassExist
) {
1917 ClassStr
= GetNextParamStr (&TextDeviceNode
);
1918 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
1920 UsbClass
->DeviceClass
= UsbClassText
->Class
;
1922 if (UsbClassText
->SubClassExist
) {
1923 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
1924 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
1926 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
1929 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1931 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
1932 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
1933 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
1935 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
1940 Converts a text device path node to USB class device path structure.
1942 @param TextDeviceNode The input Text device path node.
1944 @return A pointer to the newly-created USB class device path structure.
1947 EFI_DEVICE_PATH_PROTOCOL
*
1948 DevPathFromTextUsbClass (
1949 IN CHAR16
*TextDeviceNode
1952 USB_CLASS_TEXT UsbClassText
;
1954 UsbClassText
.ClassExist
= TRUE
;
1955 UsbClassText
.SubClassExist
= TRUE
;
1957 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1961 Converts a text device path node to USB audio device path structure.
1963 @param TextDeviceNode The input Text device path node.
1965 @return A pointer to the newly-created USB audio device path structure.
1968 EFI_DEVICE_PATH_PROTOCOL
*
1969 DevPathFromTextUsbAudio (
1970 IN CHAR16
*TextDeviceNode
1973 USB_CLASS_TEXT UsbClassText
;
1975 UsbClassText
.ClassExist
= FALSE
;
1976 UsbClassText
.Class
= USB_CLASS_AUDIO
;
1977 UsbClassText
.SubClassExist
= TRUE
;
1979 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1983 Converts a text device path node to USB CDC Control device path structure.
1985 @param TextDeviceNode The input Text device path node.
1987 @return A pointer to the newly-created USB CDC Control device path structure.
1990 EFI_DEVICE_PATH_PROTOCOL
*
1991 DevPathFromTextUsbCDCControl (
1992 IN CHAR16
*TextDeviceNode
1995 USB_CLASS_TEXT UsbClassText
;
1997 UsbClassText
.ClassExist
= FALSE
;
1998 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
1999 UsbClassText
.SubClassExist
= TRUE
;
2001 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2005 Converts a text device path node to USB HID device path structure.
2007 @param TextDeviceNode The input Text device path node.
2009 @return A pointer to the newly-created USB HID device path structure.
2012 EFI_DEVICE_PATH_PROTOCOL
*
2013 DevPathFromTextUsbHID (
2014 IN CHAR16
*TextDeviceNode
2017 USB_CLASS_TEXT UsbClassText
;
2019 UsbClassText
.ClassExist
= FALSE
;
2020 UsbClassText
.Class
= USB_CLASS_HID
;
2021 UsbClassText
.SubClassExist
= TRUE
;
2023 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2027 Converts a text device path node to USB Image device path structure.
2029 @param TextDeviceNode The input Text device path node.
2031 @return A pointer to the newly-created USB Image device path structure.
2034 EFI_DEVICE_PATH_PROTOCOL
*
2035 DevPathFromTextUsbImage (
2036 IN CHAR16
*TextDeviceNode
2039 USB_CLASS_TEXT UsbClassText
;
2041 UsbClassText
.ClassExist
= FALSE
;
2042 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2043 UsbClassText
.SubClassExist
= TRUE
;
2045 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2049 Converts a text device path node to USB Print device path structure.
2051 @param TextDeviceNode The input Text device path node.
2053 @return A pointer to the newly-created USB Print device path structure.
2056 EFI_DEVICE_PATH_PROTOCOL
*
2057 DevPathFromTextUsbPrinter (
2058 IN CHAR16
*TextDeviceNode
2061 USB_CLASS_TEXT UsbClassText
;
2063 UsbClassText
.ClassExist
= FALSE
;
2064 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2065 UsbClassText
.SubClassExist
= TRUE
;
2067 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2071 Converts a text device path node to USB mass storage device path structure.
2073 @param TextDeviceNode The input Text device path node.
2075 @return A pointer to the newly-created USB mass storage device path structure.
2078 EFI_DEVICE_PATH_PROTOCOL
*
2079 DevPathFromTextUsbMassStorage (
2080 IN CHAR16
*TextDeviceNode
2083 USB_CLASS_TEXT UsbClassText
;
2085 UsbClassText
.ClassExist
= FALSE
;
2086 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2087 UsbClassText
.SubClassExist
= TRUE
;
2089 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2093 Converts a text device path node to USB HUB device path structure.
2095 @param TextDeviceNode The input Text device path node.
2097 @return A pointer to the newly-created USB HUB device path structure.
2100 EFI_DEVICE_PATH_PROTOCOL
*
2101 DevPathFromTextUsbHub (
2102 IN CHAR16
*TextDeviceNode
2105 USB_CLASS_TEXT UsbClassText
;
2107 UsbClassText
.ClassExist
= FALSE
;
2108 UsbClassText
.Class
= USB_CLASS_HUB
;
2109 UsbClassText
.SubClassExist
= TRUE
;
2111 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2115 Converts a text device path node to USB CDC data device path structure.
2117 @param TextDeviceNode The input Text device path node.
2119 @return A pointer to the newly-created USB CDC data device path structure.
2122 EFI_DEVICE_PATH_PROTOCOL
*
2123 DevPathFromTextUsbCDCData (
2124 IN CHAR16
*TextDeviceNode
2127 USB_CLASS_TEXT UsbClassText
;
2129 UsbClassText
.ClassExist
= FALSE
;
2130 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2131 UsbClassText
.SubClassExist
= TRUE
;
2133 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2137 Converts a text device path node to USB smart card device path structure.
2139 @param TextDeviceNode The input Text device path node.
2141 @return A pointer to the newly-created USB smart card device path structure.
2144 EFI_DEVICE_PATH_PROTOCOL
*
2145 DevPathFromTextUsbSmartCard (
2146 IN CHAR16
*TextDeviceNode
2149 USB_CLASS_TEXT UsbClassText
;
2151 UsbClassText
.ClassExist
= FALSE
;
2152 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2153 UsbClassText
.SubClassExist
= TRUE
;
2155 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2159 Converts a text device path node to USB video device path structure.
2161 @param TextDeviceNode The input Text device path node.
2163 @return A pointer to the newly-created USB video device path structure.
2166 EFI_DEVICE_PATH_PROTOCOL
*
2167 DevPathFromTextUsbVideo (
2168 IN CHAR16
*TextDeviceNode
2171 USB_CLASS_TEXT UsbClassText
;
2173 UsbClassText
.ClassExist
= FALSE
;
2174 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2175 UsbClassText
.SubClassExist
= TRUE
;
2177 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2181 Converts a text device path node to USB diagnostic device path structure.
2183 @param TextDeviceNode The input Text device path node.
2185 @return A pointer to the newly-created USB diagnostic device path structure.
2188 EFI_DEVICE_PATH_PROTOCOL
*
2189 DevPathFromTextUsbDiagnostic (
2190 IN CHAR16
*TextDeviceNode
2193 USB_CLASS_TEXT UsbClassText
;
2195 UsbClassText
.ClassExist
= FALSE
;
2196 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2197 UsbClassText
.SubClassExist
= TRUE
;
2199 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2203 Converts a text device path node to USB wireless device path structure.
2205 @param TextDeviceNode The input Text device path node.
2207 @return A pointer to the newly-created USB wireless device path structure.
2210 EFI_DEVICE_PATH_PROTOCOL
*
2211 DevPathFromTextUsbWireless (
2212 IN CHAR16
*TextDeviceNode
2215 USB_CLASS_TEXT UsbClassText
;
2217 UsbClassText
.ClassExist
= FALSE
;
2218 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2219 UsbClassText
.SubClassExist
= TRUE
;
2221 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2225 Converts a text device path node to USB device firmware update device path structure.
2227 @param TextDeviceNode The input Text device path node.
2229 @return A pointer to the newly-created USB device firmware update device path structure.
2232 EFI_DEVICE_PATH_PROTOCOL
*
2233 DevPathFromTextUsbDeviceFirmwareUpdate (
2234 IN CHAR16
*TextDeviceNode
2237 USB_CLASS_TEXT UsbClassText
;
2239 UsbClassText
.ClassExist
= FALSE
;
2240 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2241 UsbClassText
.SubClassExist
= FALSE
;
2242 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2244 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2248 Converts a text device path node to USB IRDA bridge device path structure.
2250 @param TextDeviceNode The input Text device path node.
2252 @return A pointer to the newly-created USB IRDA bridge device path structure.
2255 EFI_DEVICE_PATH_PROTOCOL
*
2256 DevPathFromTextUsbIrdaBridge (
2257 IN CHAR16
*TextDeviceNode
2260 USB_CLASS_TEXT UsbClassText
;
2262 UsbClassText
.ClassExist
= FALSE
;
2263 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2264 UsbClassText
.SubClassExist
= FALSE
;
2265 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2267 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2271 Converts a text device path node to USB text and measurement device path structure.
2273 @param TextDeviceNode The input Text device path node.
2275 @return A pointer to the newly-created USB text and measurement device path structure.
2278 EFI_DEVICE_PATH_PROTOCOL
*
2279 DevPathFromTextUsbTestAndMeasurement (
2280 IN CHAR16
*TextDeviceNode
2283 USB_CLASS_TEXT UsbClassText
;
2285 UsbClassText
.ClassExist
= FALSE
;
2286 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2287 UsbClassText
.SubClassExist
= FALSE
;
2288 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2290 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2294 Converts a text device path node to USB WWID device path structure.
2296 @param TextDeviceNode The input Text device path node.
2298 @return A pointer to the newly-created USB WWID device path structure.
2301 EFI_DEVICE_PATH_PROTOCOL
*
2302 DevPathFromTextUsbWwid (
2303 IN CHAR16
*TextDeviceNode
2308 CHAR16
*InterfaceNumStr
;
2309 CHAR16
*SerialNumberStr
;
2310 USB_WWID_DEVICE_PATH
*UsbWwid
;
2312 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2313 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2314 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2315 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2316 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2317 MESSAGING_DEVICE_PATH
,
2319 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + StrSize (SerialNumberStr
))
2322 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2323 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2324 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2325 StrCpy ((CHAR16
*) ((UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
)), SerialNumberStr
);
2327 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2331 Converts a text device path node to Logic Unit device path structure.
2333 @param TextDeviceNode The input Text device path node.
2335 @return A pointer to the newly-created Logic Unit device path structure.
2338 EFI_DEVICE_PATH_PROTOCOL
*
2339 DevPathFromTextUnit (
2340 IN CHAR16
*TextDeviceNode
2344 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2346 LunStr
= GetNextParamStr (&TextDeviceNode
);
2347 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2348 MESSAGING_DEVICE_PATH
,
2349 MSG_DEVICE_LOGICAL_UNIT_DP
,
2350 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2353 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2355 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2359 Converts a text device path node to iSCSI device path structure.
2361 @param TextDeviceNode The input Text device path node.
2363 @return A pointer to the newly-created iSCSI device path structure.
2366 EFI_DEVICE_PATH_PROTOCOL
*
2367 DevPathFromTextiSCSI (
2368 IN CHAR16
*TextDeviceNode
2373 CHAR16
*PortalGroupStr
;
2375 CHAR16
*HeaderDigestStr
;
2376 CHAR16
*DataDigestStr
;
2377 CHAR16
*AuthenticationStr
;
2378 CHAR16
*ProtocolStr
;
2380 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2382 NameStr
= GetNextParamStr (&TextDeviceNode
);
2383 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2384 LunStr
= GetNextParamStr (&TextDeviceNode
);
2385 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2386 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2387 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2388 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2389 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2390 MESSAGING_DEVICE_PATH
,
2392 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2395 AsciiStr
= ISCSIDevPath
->TargetName
;
2396 StrToAscii (NameStr
, &AsciiStr
);
2398 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2399 Strtoi64 (LunStr
, &ISCSIDevPath
->Lun
);
2402 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2406 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2410 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2414 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2418 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2420 ISCSIDevPath
->NetworkProtocol
= (UINT16
) StrCmp (ProtocolStr
, L
"TCP");
2422 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2426 Converts a text device path node to VLAN device path structure.
2428 @param TextDeviceNode The input Text device path node.
2430 @return A pointer to the newly-created VLAN device path structure.
2433 EFI_DEVICE_PATH_PROTOCOL
*
2434 DevPathFromTextVlan (
2435 IN CHAR16
*TextDeviceNode
2439 VLAN_DEVICE_PATH
*Vlan
;
2441 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2442 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2443 MESSAGING_DEVICE_PATH
,
2445 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2448 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2450 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2454 Converts a text device path node to HD device path structure.
2456 @param TextDeviceNode The input Text device path node.
2458 @return A pointer to the newly-created HD device path structure.
2461 EFI_DEVICE_PATH_PROTOCOL
*
2463 IN CHAR16
*TextDeviceNode
2466 CHAR16
*PartitionStr
;
2468 CHAR16
*SignatureStr
;
2472 EFI_GUID SignatureGuid
;
2473 HARDDRIVE_DEVICE_PATH
*Hd
;
2475 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2476 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2477 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2478 StartStr
= GetNextParamStr (&TextDeviceNode
);
2479 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2480 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2483 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2486 Hd
->PartitionNumber
= (UINT32
) Dtoi (PartitionStr
);
2488 ZeroMem (Hd
->Signature
, 16);
2489 Hd
->MBRType
= (UINT8
) 0;
2491 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2492 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2495 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2496 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2497 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2498 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2501 StrToGuid (SignatureStr
, &SignatureGuid
);
2502 CopyMem (Hd
->Signature
, &SignatureGuid
, sizeof (EFI_GUID
));
2504 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2507 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2508 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2510 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2514 Converts a text device path node to CDROM device path structure.
2516 @param TextDeviceNode The input Text device path node.
2518 @return A pointer to the newly-created CDROM device path structure.
2521 EFI_DEVICE_PATH_PROTOCOL
*
2522 DevPathFromTextCDROM (
2523 IN CHAR16
*TextDeviceNode
2529 CDROM_DEVICE_PATH
*CDROMDevPath
;
2531 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2532 StartStr
= GetNextParamStr (&TextDeviceNode
);
2533 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2534 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2537 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2540 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2541 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2542 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2544 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2548 Converts a text device path node to Vendor-defined media device path structure.
2550 @param TextDeviceNode The input Text device path node.
2552 @return A pointer to the newly-created Vendor-defined media device path structure.
2555 EFI_DEVICE_PATH_PROTOCOL
*
2556 DevPathFromTextVenMEDIA (
2557 IN CHAR16
*TextDeviceNode
2560 return ConvertFromTextVendor (
2568 Converts a text device path node to File device path structure.
2570 @param TextDeviceNode The input Text device path node.
2572 @return A pointer to the newly-created File device path structure.
2575 EFI_DEVICE_PATH_PROTOCOL
*
2576 DevPathFromTextFilePath (
2577 IN CHAR16
*TextDeviceNode
2580 FILEPATH_DEVICE_PATH
*File
;
2582 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2585 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
2588 StrCpy (File
->PathName
, TextDeviceNode
);
2590 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
2594 Converts a text device path node to Media protocol device path structure.
2596 @param TextDeviceNode The input Text device path node.
2598 @return A pointer to the newly-created Media protocol device path structure.
2601 EFI_DEVICE_PATH_PROTOCOL
*
2602 DevPathFromTextMedia (
2603 IN CHAR16
*TextDeviceNode
2607 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
2609 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2610 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
2613 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
2616 StrToGuid (GuidStr
, &Media
->Protocol
);
2618 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
2622 Converts a text device path node to firmware volume device path structure.
2624 @param TextDeviceNode The input Text device path node.
2626 @return A pointer to the newly-created firmware volume device path structure.
2629 EFI_DEVICE_PATH_PROTOCOL
*
2631 IN CHAR16
*TextDeviceNode
2635 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
2637 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2638 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
2640 MEDIA_PIWG_FW_VOL_DP
,
2641 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
2644 StrToGuid (GuidStr
, &Fv
->FvName
);
2646 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
2650 Converts a text device path node to firmware file device path structure.
2652 @param TextDeviceNode The input Text device path node.
2654 @return A pointer to the newly-created firmware file device path structure.
2657 EFI_DEVICE_PATH_PROTOCOL
*
2658 DevPathFromTextFvFile (
2659 IN CHAR16
*TextDeviceNode
2663 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
2665 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2666 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2668 MEDIA_PIWG_FW_FILE_DP
,
2669 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
2672 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
2674 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
2678 Converts a text device path node to text relative offset device path structure.
2680 @param TextDeviceNode The input Text device path node.
2682 @return A pointer to the newly-created Text device path structure.
2685 EFI_DEVICE_PATH_PROTOCOL
*
2686 DevPathFromTextRelativeOffsetRange (
2687 IN CHAR16
*TextDeviceNode
2690 CHAR16
*StartingOffsetStr
;
2691 CHAR16
*EndingOffsetStr
;
2692 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
2694 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2695 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2696 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
2698 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
2699 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
2702 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
2703 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
2705 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
2709 Converts a text device path node to BIOS Boot Specification device path structure.
2711 @param TextDeviceNode The input Text device path node.
2713 @return A pointer to the newly-created BIOS Boot Specification device path structure.
2716 EFI_DEVICE_PATH_PROTOCOL
*
2717 DevPathFromTextBBS (
2718 IN CHAR16
*TextDeviceNode
2725 BBS_BBS_DEVICE_PATH
*Bbs
;
2727 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2728 IdStr
= GetNextParamStr (&TextDeviceNode
);
2729 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
2730 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
2733 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
2736 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
2737 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
2738 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
2739 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
2740 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
2741 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
2742 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
2743 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
2744 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
2745 Bbs
->DeviceType
= BBS_TYPE_USB
;
2746 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
2747 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
2749 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
2752 AsciiStr
= Bbs
->String
;
2753 StrToAscii (IdStr
, &AsciiStr
);
2755 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
2757 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
2761 Converts a text device path node to SATA device path structure.
2763 @param TextDeviceNode The input Text device path node.
2765 @return A pointer to the newly-created SATA device path structure.
2768 EFI_DEVICE_PATH_PROTOCOL
*
2769 DevPathFromTextSata (
2770 IN CHAR16
*TextDeviceNode
2773 SATA_DEVICE_PATH
*Sata
;
2779 // The PMPN is optional.
2781 Param1
= GetNextParamStr (&TextDeviceNode
);
2782 Param2
= GetNextParamStr (&TextDeviceNode
);
2784 if (!IS_NULL (TextDeviceNode
)) {
2785 Param3
= GetNextParamStr (&TextDeviceNode
);
2788 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
2789 MESSAGING_DEVICE_PATH
,
2791 (UINT16
) sizeof (SATA_DEVICE_PATH
)
2793 Sata
->HBAPortNumber
= (UINT16
) Xtoi (Param1
);
2794 if (Param3
!= NULL
) {
2795 Sata
->PortMultiplierPortNumber
= (UINT16
) Xtoi (Param2
);
2798 Sata
->PortMultiplierPortNumber
= SATA_HBA_DIRECT_CONNECT_FLAG
;
2800 Sata
->Lun
= (UINT16
) Xtoi (Param2
);
2802 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
2805 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable
[] = {
2806 {L
"Pci", DevPathFromTextPci
},
2807 {L
"PcCard", DevPathFromTextPcCard
},
2808 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
2809 {L
"VenHw", DevPathFromTextVenHw
},
2810 {L
"Ctrl", DevPathFromTextCtrl
},
2811 {L
"Acpi", DevPathFromTextAcpi
},
2812 {L
"PciRoot", DevPathFromTextPciRoot
},
2813 {L
"Floppy", DevPathFromTextFloppy
},
2814 {L
"Keyboard", DevPathFromTextKeyboard
},
2815 {L
"Serial", DevPathFromTextSerial
},
2816 {L
"ParallelPort", DevPathFromTextParallelPort
},
2817 {L
"AcpiEx", DevPathFromTextAcpiEx
},
2818 {L
"AcpiExp", DevPathFromTextAcpiExp
},
2819 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
2820 {L
"Ata", DevPathFromTextAta
},
2821 {L
"Scsi", DevPathFromTextScsi
},
2822 {L
"Fibre", DevPathFromTextFibre
},
2823 {L
"I1394", DevPathFromText1394
},
2824 {L
"USB", DevPathFromTextUsb
},
2825 {L
"I2O", DevPathFromTextI2O
},
2826 {L
"Infiniband", DevPathFromTextInfiniband
},
2827 {L
"VenMsg", DevPathFromTextVenMsg
},
2828 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
2829 {L
"VenVt100", DevPathFromTextVenVt100
},
2830 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
2831 {L
"VenUtf8", DevPathFromTextVenUtf8
},
2832 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
2833 {L
"SAS", DevPathFromTextSAS
},
2834 {L
"DebugPort", DevPathFromTextDebugPort
},
2835 {L
"MAC", DevPathFromTextMAC
},
2836 {L
"IPv4", DevPathFromTextIPv4
},
2837 {L
"IPv6", DevPathFromTextIPv6
},
2838 {L
"Uart", DevPathFromTextUart
},
2839 {L
"UsbClass", DevPathFromTextUsbClass
},
2840 {L
"UsbAudio", DevPathFromTextUsbAudio
},
2841 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
2842 {L
"UsbHID", DevPathFromTextUsbHID
},
2843 {L
"UsbImage", DevPathFromTextUsbImage
},
2844 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
2845 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
2846 {L
"UsbHub", DevPathFromTextUsbHub
},
2847 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
2848 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
2849 {L
"UsbVideo", DevPathFromTextUsbVideo
},
2850 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
2851 {L
"UsbWireless", DevPathFromTextUsbWireless
},
2852 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
2853 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
2854 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
2855 {L
"UsbWwid", DevPathFromTextUsbWwid
},
2856 {L
"Unit", DevPathFromTextUnit
},
2857 {L
"iSCSI", DevPathFromTextiSCSI
},
2858 {L
"Vlan", DevPathFromTextVlan
},
2859 {L
"HD", DevPathFromTextHD
},
2860 {L
"CDROM", DevPathFromTextCDROM
},
2861 {L
"VenMEDIA", DevPathFromTextVenMEDIA
},
2862 {L
"Media", DevPathFromTextMedia
},
2863 {L
"Fv", DevPathFromTextFv
},
2864 {L
"FvFile", DevPathFromTextFvFile
},
2865 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
2866 {L
"BBS", DevPathFromTextBBS
},
2867 {L
"Sata", DevPathFromTextSata
},
2872 Convert text to the binary representation of a device node.
2874 @param TextDeviceNode TextDeviceNode points to the text representation of a device
2875 node. Conversion starts with the first character and continues
2876 until the first non-device node character.
2878 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
2879 insufficient memory or text unsupported.
2882 EFI_DEVICE_PATH_PROTOCOL
*
2884 ConvertTextToDeviceNode (
2885 IN CONST CHAR16
*TextDeviceNode
2890 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
2891 CHAR16
*DeviceNodeStr
;
2894 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
2900 DeviceNodeStr
= StrDuplicate (TextDeviceNode
);
2901 ASSERT (DeviceNodeStr
!= NULL
);
2903 for (Index
= 0; DevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
2904 ParamStr
= GetParamByNodeName (DeviceNodeStr
, DevPathFromTextTable
[Index
].DevicePathNodeText
);
2905 if (ParamStr
!= NULL
) {
2906 DumpNode
= DevPathFromTextTable
[Index
].Function
;
2911 if (DumpNode
== NULL
) {
2915 DumpNode
= DevPathFromTextFilePath
;
2916 DeviceNode
= DumpNode (DeviceNodeStr
);
2918 DeviceNode
= DumpNode (ParamStr
);
2919 FreePool (ParamStr
);
2922 FreePool (DeviceNodeStr
);
2928 Convert text to the binary representation of a device path.
2931 @param TextDevicePath TextDevicePath points to the text representation of a device
2932 path. Conversion starts with the first character and continues
2933 until the first non-device node character.
2935 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
2936 there was insufficient memory.
2939 EFI_DEVICE_PATH_PROTOCOL
*
2941 ConvertTextToDevicePath (
2942 IN CONST CHAR16
*TextDevicePath
2947 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
2949 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
2950 CHAR16
*DevicePathStr
;
2952 CHAR16
*DeviceNodeStr
;
2953 UINT8 IsInstanceEnd
;
2954 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
2956 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
2960 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
2961 ASSERT (DevicePath
!= NULL
);
2962 SetDevicePathEndNode (DevicePath
);
2965 DeviceNodeStr
= NULL
;
2966 DevicePathStr
= StrDuplicate (TextDevicePath
);
2968 Str
= DevicePathStr
;
2969 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
2971 for (Index
= 0; DevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
2972 ParamStr
= GetParamByNodeName (DeviceNodeStr
, DevPathFromTextTable
[Index
].DevicePathNodeText
);
2973 if (ParamStr
!= NULL
) {
2974 DumpNode
= DevPathFromTextTable
[Index
].Function
;
2979 if (DumpNode
== NULL
) {
2983 DumpNode
= DevPathFromTextFilePath
;
2984 DeviceNode
= DumpNode (DeviceNodeStr
);
2986 DeviceNode
= DumpNode (ParamStr
);
2987 FreePool (ParamStr
);
2990 NewDevicePath
= AppendDeviceNodeProtocolInterface (DevicePath
, DeviceNode
);
2991 FreePool (DevicePath
);
2992 FreePool (DeviceNode
);
2993 DevicePath
= NewDevicePath
;
2995 if (IsInstanceEnd
!= 0) {
2996 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
2997 ASSERT (DeviceNode
!= NULL
);
2998 SET_DEVICE_PATH_INSTANCE_END_NODE (DeviceNode
);
3000 NewDevicePath
= AppendDeviceNodeProtocolInterface (DevicePath
, DeviceNode
);
3001 FreePool (DevicePath
);
3002 FreePool (DeviceNode
);
3003 DevicePath
= NewDevicePath
;
3007 FreePool (DevicePathStr
);