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
;
1157 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*) CreateDeviceNode (
1160 sizeof (ACPI_ADR_DEVICE_PATH
)
1162 ASSERT (AcpiAdr
!= NULL
);
1164 for (Index
= 0; ; Index
++) {
1165 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
1166 if (IS_NULL (*DisplayDeviceStr
)) {
1170 AcpiAdr
= ReallocatePool (
1171 DevicePathNodeLength (AcpiAdr
),
1172 DevicePathNodeLength (AcpiAdr
) + sizeof (UINT32
),
1175 ASSERT (AcpiAdr
!= NULL
);
1176 SetDevicePathNodeLength (AcpiAdr
, DevicePathNodeLength (AcpiAdr
) + sizeof (UINT32
));
1179 (&AcpiAdr
->ADR
)[Index
] = (UINT32
) Strtoi (DisplayDeviceStr
);
1182 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
;
1186 Converts a text device path node to Parallel Port device path structure.
1188 @param TextDeviceNode The input Text device path node.
1190 @return A pointer to the newly-created Parallel Port device path structure.
1193 EFI_DEVICE_PATH_PROTOCOL
*
1194 DevPathFromTextAta (
1195 IN CHAR16
*TextDeviceNode
1198 CHAR16
*PrimarySecondaryStr
;
1199 CHAR16
*SlaveMasterStr
;
1201 ATAPI_DEVICE_PATH
*Atapi
;
1203 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
1204 MESSAGING_DEVICE_PATH
,
1206 (UINT16
) sizeof (ATAPI_DEVICE_PATH
)
1209 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
1210 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
1211 LunStr
= GetNextParamStr (&TextDeviceNode
);
1213 Atapi
->PrimarySecondary
= (UINT8
) ((StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) ? 0 : 1);
1214 Atapi
->SlaveMaster
= (UINT8
) ((StrCmp (SlaveMasterStr
, L
"Master") == 0) ? 0 : 1);
1215 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
1217 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
1221 Converts a text device path node to SCSI device path structure.
1223 @param TextDeviceNode The input Text device path node.
1225 @return A pointer to the newly-created SCSI device path structure.
1228 EFI_DEVICE_PATH_PROTOCOL
*
1229 DevPathFromTextScsi (
1230 IN CHAR16
*TextDeviceNode
1235 SCSI_DEVICE_PATH
*Scsi
;
1237 PunStr
= GetNextParamStr (&TextDeviceNode
);
1238 LunStr
= GetNextParamStr (&TextDeviceNode
);
1239 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
1240 MESSAGING_DEVICE_PATH
,
1242 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
1245 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
1246 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
1248 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
1252 Converts a text device path node to Fibre device path structure.
1254 @param TextDeviceNode The input Text device path node.
1256 @return A pointer to the newly-created Fibre device path structure.
1259 EFI_DEVICE_PATH_PROTOCOL
*
1260 DevPathFromTextFibre (
1261 IN CHAR16
*TextDeviceNode
1266 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
1268 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1269 LunStr
= GetNextParamStr (&TextDeviceNode
);
1270 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
1271 MESSAGING_DEVICE_PATH
,
1272 MSG_FIBRECHANNEL_DP
,
1273 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
1276 Fibre
->Reserved
= 0;
1277 Strtoi64 (WWNStr
, &Fibre
->WWN
);
1278 Strtoi64 (LunStr
, &Fibre
->Lun
);
1280 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
1284 Converts a text device path node to 1394 device path structure.
1286 @param TextDeviceNode The input Text device path node.
1288 @return A pointer to the newly-created 1394 device path structure.
1291 EFI_DEVICE_PATH_PROTOCOL
*
1292 DevPathFromText1394 (
1293 IN CHAR16
*TextDeviceNode
1297 F1394_DEVICE_PATH
*F1394DevPath
;
1299 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1300 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1301 MESSAGING_DEVICE_PATH
,
1303 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1306 F1394DevPath
->Reserved
= 0;
1307 Xtoi64 (GuidStr
, &F1394DevPath
->Guid
);
1309 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1313 Converts a text device path node to USB device path structure.
1315 @param TextDeviceNode The input Text device path node.
1317 @return A pointer to the newly-created USB device path structure.
1320 EFI_DEVICE_PATH_PROTOCOL
*
1321 DevPathFromTextUsb (
1322 IN CHAR16
*TextDeviceNode
1326 CHAR16
*InterfaceStr
;
1327 USB_DEVICE_PATH
*Usb
;
1329 PortStr
= GetNextParamStr (&TextDeviceNode
);
1330 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1331 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1332 MESSAGING_DEVICE_PATH
,
1334 (UINT16
) sizeof (USB_DEVICE_PATH
)
1337 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1338 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1340 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1344 Converts a text device path node to I20 device path structure.
1346 @param TextDeviceNode The input Text device path node.
1348 @return A pointer to the newly-created I20 device path structure.
1351 EFI_DEVICE_PATH_PROTOCOL
*
1352 DevPathFromTextI2O (
1353 IN CHAR16
*TextDeviceNode
1357 I2O_DEVICE_PATH
*I2ODevPath
;
1359 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1360 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1361 MESSAGING_DEVICE_PATH
,
1363 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1366 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1368 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1372 Converts a text device path node to Infini Band device path structure.
1374 @param TextDeviceNode The input Text device path node.
1376 @return A pointer to the newly-created Infini Band device path structure.
1379 EFI_DEVICE_PATH_PROTOCOL
*
1380 DevPathFromTextInfiniband (
1381 IN CHAR16
*TextDeviceNode
1390 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1392 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1393 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1394 SidStr
= GetNextParamStr (&TextDeviceNode
);
1395 TidStr
= GetNextParamStr (&TextDeviceNode
);
1396 DidStr
= GetNextParamStr (&TextDeviceNode
);
1397 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1398 MESSAGING_DEVICE_PATH
,
1400 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1403 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1404 StrToGuid (GuidStr
, &PortGid
);
1405 CopyMem (InfiniBand
->PortGid
, &PortGid
, sizeof (EFI_GUID
));
1406 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1407 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1408 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1410 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1414 Converts a text device path node to Vendor-Defined Messaging device path structure.
1416 @param TextDeviceNode The input Text device path node.
1418 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1421 EFI_DEVICE_PATH_PROTOCOL
*
1422 DevPathFromTextVenMsg (
1423 IN CHAR16
*TextDeviceNode
1426 return ConvertFromTextVendor (
1428 MESSAGING_DEVICE_PATH
,
1434 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1436 @param TextDeviceNode The input Text device path node.
1438 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1441 EFI_DEVICE_PATH_PROTOCOL
*
1442 DevPathFromTextVenPcAnsi (
1443 IN CHAR16
*TextDeviceNode
1446 VENDOR_DEVICE_PATH
*Vendor
;
1448 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1449 MESSAGING_DEVICE_PATH
,
1451 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1452 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1454 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1458 Converts a text device path node to Vendor defined VT100 device path structure.
1460 @param TextDeviceNode The input Text device path node.
1462 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1465 EFI_DEVICE_PATH_PROTOCOL
*
1466 DevPathFromTextVenVt100 (
1467 IN CHAR16
*TextDeviceNode
1470 VENDOR_DEVICE_PATH
*Vendor
;
1472 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1473 MESSAGING_DEVICE_PATH
,
1475 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1476 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1478 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1482 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1484 @param TextDeviceNode The input Text device path node.
1486 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1489 EFI_DEVICE_PATH_PROTOCOL
*
1490 DevPathFromTextVenVt100Plus (
1491 IN CHAR16
*TextDeviceNode
1494 VENDOR_DEVICE_PATH
*Vendor
;
1496 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1497 MESSAGING_DEVICE_PATH
,
1499 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1500 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1502 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1506 Converts a text device path node to Vendor defined UTF8 device path structure.
1508 @param TextDeviceNode The input Text device path node.
1510 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1513 EFI_DEVICE_PATH_PROTOCOL
*
1514 DevPathFromTextVenUtf8 (
1515 IN CHAR16
*TextDeviceNode
1518 VENDOR_DEVICE_PATH
*Vendor
;
1520 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1521 MESSAGING_DEVICE_PATH
,
1523 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1524 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1526 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1530 Converts a text device path node to UART Flow Control device path structure.
1532 @param TextDeviceNode The input Text device path node.
1534 @return A pointer to the newly-created UART Flow Control device path structure.
1537 EFI_DEVICE_PATH_PROTOCOL
*
1538 DevPathFromTextUartFlowCtrl (
1539 IN CHAR16
*TextDeviceNode
1543 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1545 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1546 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1547 MESSAGING_DEVICE_PATH
,
1549 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1552 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1553 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1554 UartFlowControl
->FlowControlMap
= 2;
1555 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1556 UartFlowControl
->FlowControlMap
= 1;
1558 UartFlowControl
->FlowControlMap
= 0;
1561 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1565 Converts a text device path node to Serial Attached SCSI device path structure.
1567 @param TextDeviceNode The input Text device path node.
1569 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1572 EFI_DEVICE_PATH_PROTOCOL
*
1573 DevPathFromTextSAS (
1574 IN CHAR16
*TextDeviceNode
1581 CHAR16
*LocationStr
;
1583 CHAR16
*DriveBayStr
;
1584 CHAR16
*ReservedStr
;
1586 SAS_DEVICE_PATH
*Sas
;
1588 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1589 LunStr
= GetNextParamStr (&TextDeviceNode
);
1590 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1591 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1592 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1593 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1594 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1595 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1597 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1598 MESSAGING_DEVICE_PATH
,
1600 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1603 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1604 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1605 Strtoi64 (LunStr
, &Sas
->Lun
);
1606 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1607 if (StrCmp (SASSATAStr
, L
"NoTopology") != 0) {
1608 if (StrCmp (DriveBayStr
, L
"0") == 0) {
1612 Info
= (UINT16
) (Info
| (Strtoi (DriveBayStr
) << 8));
1615 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1619 if (StrCmp (LocationStr
, L
"External") == 0) {
1623 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1628 Sas
->DeviceTopology
= Info
;
1629 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1631 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1635 Converts a text device path node to Debug Port device path structure.
1637 @param TextDeviceNode The input Text device path node.
1639 @return A pointer to the newly-created Debug Port device path structure.
1642 EFI_DEVICE_PATH_PROTOCOL
*
1643 DevPathFromTextDebugPort (
1644 IN CHAR16
*TextDeviceNode
1647 VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*Vend
;
1649 Vend
= (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*) CreateDeviceNode (
1650 MESSAGING_DEVICE_PATH
,
1652 (UINT16
) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
)
1655 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1657 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1661 Converts a text device path node to MAC device path structure.
1663 @param TextDeviceNode The input Text device path node.
1665 @return A pointer to the newly-created MAC device path structure.
1668 EFI_DEVICE_PATH_PROTOCOL
*
1669 DevPathFromTextMAC (
1670 IN CHAR16
*TextDeviceNode
1676 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1678 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1679 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1680 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1681 MESSAGING_DEVICE_PATH
,
1683 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1686 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1688 Length
= sizeof (EFI_MAC_ADDRESS
);
1689 StrToBuf (&MACDevPath
->MacAddress
.Addr
[0], Length
, AddressStr
);
1691 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1696 Converts a text format to the network protocol ID.
1698 @param Text String of protocol field.
1700 @return Network protocol ID .
1704 NetworkProtocolFromText (
1708 if (StrCmp (Text
, L
"UDP") == 0) {
1709 return RFC_1700_UDP_PROTOCOL
;
1712 if (StrCmp (Text
, L
"TCP") == 0) {
1713 return RFC_1700_TCP_PROTOCOL
;
1716 return Strtoi (Text
);
1721 Converts a text device path node to IPV4 device path structure.
1723 @param TextDeviceNode The input Text device path node.
1725 @return A pointer to the newly-created IPV4 device path structure.
1728 EFI_DEVICE_PATH_PROTOCOL
*
1729 DevPathFromTextIPv4 (
1730 IN CHAR16
*TextDeviceNode
1733 CHAR16
*RemoteIPStr
;
1734 CHAR16
*ProtocolStr
;
1737 IPv4_DEVICE_PATH
*IPv4
;
1739 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1740 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1741 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1742 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1743 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1744 MESSAGING_DEVICE_PATH
,
1746 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
1749 StrToIPv4Addr (&RemoteIPStr
, &IPv4
->RemoteIpAddress
);
1750 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1751 if (StrCmp (TypeStr
, L
"Static") == 0) {
1752 IPv4
->StaticIpAddress
= TRUE
;
1754 IPv4
->StaticIpAddress
= FALSE
;
1757 StrToIPv4Addr (&LocalIPStr
, &IPv4
->LocalIpAddress
);
1759 IPv4
->LocalPort
= 0;
1760 IPv4
->RemotePort
= 0;
1762 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1766 Converts a text device path node to IPV6 device path structure.
1768 @param TextDeviceNode The input Text device path node.
1770 @return A pointer to the newly-created IPV6 device path structure.
1773 EFI_DEVICE_PATH_PROTOCOL
*
1774 DevPathFromTextIPv6 (
1775 IN CHAR16
*TextDeviceNode
1778 CHAR16
*RemoteIPStr
;
1779 CHAR16
*ProtocolStr
;
1782 IPv6_DEVICE_PATH
*IPv6
;
1784 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1785 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1786 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1787 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1788 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1789 MESSAGING_DEVICE_PATH
,
1791 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
1794 StrToIPv6Addr (&RemoteIPStr
, &IPv6
->RemoteIpAddress
);
1795 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1796 if (StrCmp (TypeStr
, L
"Static") == 0) {
1797 IPv6
->StaticIpAddress
= TRUE
;
1799 IPv6
->StaticIpAddress
= FALSE
;
1802 StrToIPv6Addr (&LocalIPStr
, &IPv6
->LocalIpAddress
);
1804 IPv6
->LocalPort
= 0;
1805 IPv6
->RemotePort
= 0;
1807 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
1811 Converts a text device path node to UART device path structure.
1813 @param TextDeviceNode The input Text device path node.
1815 @return A pointer to the newly-created UART device path structure.
1818 EFI_DEVICE_PATH_PROTOCOL
*
1819 DevPathFromTextUart (
1820 IN CHAR16
*TextDeviceNode
1824 CHAR16
*DataBitsStr
;
1826 CHAR16
*StopBitsStr
;
1827 UART_DEVICE_PATH
*Uart
;
1829 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1830 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1831 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1832 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1833 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
1834 MESSAGING_DEVICE_PATH
,
1836 (UINT16
) sizeof (UART_DEVICE_PATH
)
1839 Uart
->BaudRate
= (StrCmp (BaudStr
, L
"DEFAULT") == 0) ? 115200 : Dtoi (BaudStr
);
1840 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Dtoi (DataBitsStr
));
1841 switch (*ParityStr
) {
1866 Uart
->Parity
= 0xff;
1869 if (StrCmp (StopBitsStr
, L
"D") == 0) {
1870 Uart
->StopBits
= (UINT8
) 0;
1871 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
1872 Uart
->StopBits
= (UINT8
) 1;
1873 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
1874 Uart
->StopBits
= (UINT8
) 2;
1875 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
1876 Uart
->StopBits
= (UINT8
) 3;
1878 Uart
->StopBits
= 0xff;
1881 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
1885 Converts a text device path node to USB class device path structure.
1887 @param TextDeviceNode The input Text device path node.
1888 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
1890 @return A pointer to the newly-created USB class device path structure.
1893 EFI_DEVICE_PATH_PROTOCOL
*
1894 ConvertFromTextUsbClass (
1895 IN CHAR16
*TextDeviceNode
,
1896 IN USB_CLASS_TEXT
*UsbClassText
1902 CHAR16
*SubClassStr
;
1903 CHAR16
*ProtocolStr
;
1904 USB_CLASS_DEVICE_PATH
*UsbClass
;
1906 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
1907 MESSAGING_DEVICE_PATH
,
1909 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
1912 VIDStr
= GetNextParamStr (&TextDeviceNode
);
1913 PIDStr
= GetNextParamStr (&TextDeviceNode
);
1914 if (UsbClassText
->ClassExist
) {
1915 ClassStr
= GetNextParamStr (&TextDeviceNode
);
1916 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
1918 UsbClass
->DeviceClass
= UsbClassText
->Class
;
1920 if (UsbClassText
->SubClassExist
) {
1921 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
1922 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
1924 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
1927 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1929 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
1930 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
1931 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
1933 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
1938 Converts a text device path node to USB class device path structure.
1940 @param TextDeviceNode The input Text device path node.
1942 @return A pointer to the newly-created USB class device path structure.
1945 EFI_DEVICE_PATH_PROTOCOL
*
1946 DevPathFromTextUsbClass (
1947 IN CHAR16
*TextDeviceNode
1950 USB_CLASS_TEXT UsbClassText
;
1952 UsbClassText
.ClassExist
= TRUE
;
1953 UsbClassText
.SubClassExist
= TRUE
;
1955 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1959 Converts a text device path node to USB audio device path structure.
1961 @param TextDeviceNode The input Text device path node.
1963 @return A pointer to the newly-created USB audio device path structure.
1966 EFI_DEVICE_PATH_PROTOCOL
*
1967 DevPathFromTextUsbAudio (
1968 IN CHAR16
*TextDeviceNode
1971 USB_CLASS_TEXT UsbClassText
;
1973 UsbClassText
.ClassExist
= FALSE
;
1974 UsbClassText
.Class
= USB_CLASS_AUDIO
;
1975 UsbClassText
.SubClassExist
= TRUE
;
1977 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1981 Converts a text device path node to USB CDC Control device path structure.
1983 @param TextDeviceNode The input Text device path node.
1985 @return A pointer to the newly-created USB CDC Control device path structure.
1988 EFI_DEVICE_PATH_PROTOCOL
*
1989 DevPathFromTextUsbCDCControl (
1990 IN CHAR16
*TextDeviceNode
1993 USB_CLASS_TEXT UsbClassText
;
1995 UsbClassText
.ClassExist
= FALSE
;
1996 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
1997 UsbClassText
.SubClassExist
= TRUE
;
1999 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2003 Converts a text device path node to USB HID device path structure.
2005 @param TextDeviceNode The input Text device path node.
2007 @return A pointer to the newly-created USB HID device path structure.
2010 EFI_DEVICE_PATH_PROTOCOL
*
2011 DevPathFromTextUsbHID (
2012 IN CHAR16
*TextDeviceNode
2015 USB_CLASS_TEXT UsbClassText
;
2017 UsbClassText
.ClassExist
= FALSE
;
2018 UsbClassText
.Class
= USB_CLASS_HID
;
2019 UsbClassText
.SubClassExist
= TRUE
;
2021 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2025 Converts a text device path node to USB Image device path structure.
2027 @param TextDeviceNode The input Text device path node.
2029 @return A pointer to the newly-created USB Image device path structure.
2032 EFI_DEVICE_PATH_PROTOCOL
*
2033 DevPathFromTextUsbImage (
2034 IN CHAR16
*TextDeviceNode
2037 USB_CLASS_TEXT UsbClassText
;
2039 UsbClassText
.ClassExist
= FALSE
;
2040 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2041 UsbClassText
.SubClassExist
= TRUE
;
2043 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2047 Converts a text device path node to USB Print device path structure.
2049 @param TextDeviceNode The input Text device path node.
2051 @return A pointer to the newly-created USB Print device path structure.
2054 EFI_DEVICE_PATH_PROTOCOL
*
2055 DevPathFromTextUsbPrinter (
2056 IN CHAR16
*TextDeviceNode
2059 USB_CLASS_TEXT UsbClassText
;
2061 UsbClassText
.ClassExist
= FALSE
;
2062 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2063 UsbClassText
.SubClassExist
= TRUE
;
2065 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2069 Converts a text device path node to USB mass storage device path structure.
2071 @param TextDeviceNode The input Text device path node.
2073 @return A pointer to the newly-created USB mass storage device path structure.
2076 EFI_DEVICE_PATH_PROTOCOL
*
2077 DevPathFromTextUsbMassStorage (
2078 IN CHAR16
*TextDeviceNode
2081 USB_CLASS_TEXT UsbClassText
;
2083 UsbClassText
.ClassExist
= FALSE
;
2084 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2085 UsbClassText
.SubClassExist
= TRUE
;
2087 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2091 Converts a text device path node to USB HUB device path structure.
2093 @param TextDeviceNode The input Text device path node.
2095 @return A pointer to the newly-created USB HUB device path structure.
2098 EFI_DEVICE_PATH_PROTOCOL
*
2099 DevPathFromTextUsbHub (
2100 IN CHAR16
*TextDeviceNode
2103 USB_CLASS_TEXT UsbClassText
;
2105 UsbClassText
.ClassExist
= FALSE
;
2106 UsbClassText
.Class
= USB_CLASS_HUB
;
2107 UsbClassText
.SubClassExist
= TRUE
;
2109 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2113 Converts a text device path node to USB CDC data device path structure.
2115 @param TextDeviceNode The input Text device path node.
2117 @return A pointer to the newly-created USB CDC data device path structure.
2120 EFI_DEVICE_PATH_PROTOCOL
*
2121 DevPathFromTextUsbCDCData (
2122 IN CHAR16
*TextDeviceNode
2125 USB_CLASS_TEXT UsbClassText
;
2127 UsbClassText
.ClassExist
= FALSE
;
2128 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2129 UsbClassText
.SubClassExist
= TRUE
;
2131 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2135 Converts a text device path node to USB smart card device path structure.
2137 @param TextDeviceNode The input Text device path node.
2139 @return A pointer to the newly-created USB smart card device path structure.
2142 EFI_DEVICE_PATH_PROTOCOL
*
2143 DevPathFromTextUsbSmartCard (
2144 IN CHAR16
*TextDeviceNode
2147 USB_CLASS_TEXT UsbClassText
;
2149 UsbClassText
.ClassExist
= FALSE
;
2150 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2151 UsbClassText
.SubClassExist
= TRUE
;
2153 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2157 Converts a text device path node to USB video device path structure.
2159 @param TextDeviceNode The input Text device path node.
2161 @return A pointer to the newly-created USB video device path structure.
2164 EFI_DEVICE_PATH_PROTOCOL
*
2165 DevPathFromTextUsbVideo (
2166 IN CHAR16
*TextDeviceNode
2169 USB_CLASS_TEXT UsbClassText
;
2171 UsbClassText
.ClassExist
= FALSE
;
2172 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2173 UsbClassText
.SubClassExist
= TRUE
;
2175 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2179 Converts a text device path node to USB diagnostic device path structure.
2181 @param TextDeviceNode The input Text device path node.
2183 @return A pointer to the newly-created USB diagnostic device path structure.
2186 EFI_DEVICE_PATH_PROTOCOL
*
2187 DevPathFromTextUsbDiagnostic (
2188 IN CHAR16
*TextDeviceNode
2191 USB_CLASS_TEXT UsbClassText
;
2193 UsbClassText
.ClassExist
= FALSE
;
2194 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2195 UsbClassText
.SubClassExist
= TRUE
;
2197 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2201 Converts a text device path node to USB wireless device path structure.
2203 @param TextDeviceNode The input Text device path node.
2205 @return A pointer to the newly-created USB wireless device path structure.
2208 EFI_DEVICE_PATH_PROTOCOL
*
2209 DevPathFromTextUsbWireless (
2210 IN CHAR16
*TextDeviceNode
2213 USB_CLASS_TEXT UsbClassText
;
2215 UsbClassText
.ClassExist
= FALSE
;
2216 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2217 UsbClassText
.SubClassExist
= TRUE
;
2219 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2223 Converts a text device path node to USB device firmware update device path structure.
2225 @param TextDeviceNode The input Text device path node.
2227 @return A pointer to the newly-created USB device firmware update device path structure.
2230 EFI_DEVICE_PATH_PROTOCOL
*
2231 DevPathFromTextUsbDeviceFirmwareUpdate (
2232 IN CHAR16
*TextDeviceNode
2235 USB_CLASS_TEXT UsbClassText
;
2237 UsbClassText
.ClassExist
= FALSE
;
2238 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2239 UsbClassText
.SubClassExist
= FALSE
;
2240 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2242 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2246 Converts a text device path node to USB IRDA bridge device path structure.
2248 @param TextDeviceNode The input Text device path node.
2250 @return A pointer to the newly-created USB IRDA bridge device path structure.
2253 EFI_DEVICE_PATH_PROTOCOL
*
2254 DevPathFromTextUsbIrdaBridge (
2255 IN CHAR16
*TextDeviceNode
2258 USB_CLASS_TEXT UsbClassText
;
2260 UsbClassText
.ClassExist
= FALSE
;
2261 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2262 UsbClassText
.SubClassExist
= FALSE
;
2263 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2265 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2269 Converts a text device path node to USB text and measurement device path structure.
2271 @param TextDeviceNode The input Text device path node.
2273 @return A pointer to the newly-created USB text and measurement device path structure.
2276 EFI_DEVICE_PATH_PROTOCOL
*
2277 DevPathFromTextUsbTestAndMeasurement (
2278 IN CHAR16
*TextDeviceNode
2281 USB_CLASS_TEXT UsbClassText
;
2283 UsbClassText
.ClassExist
= FALSE
;
2284 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2285 UsbClassText
.SubClassExist
= FALSE
;
2286 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2288 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2292 Converts a text device path node to USB WWID device path structure.
2294 @param TextDeviceNode The input Text device path node.
2296 @return A pointer to the newly-created USB WWID device path structure.
2299 EFI_DEVICE_PATH_PROTOCOL
*
2300 DevPathFromTextUsbWwid (
2301 IN CHAR16
*TextDeviceNode
2306 CHAR16
*InterfaceNumStr
;
2307 CHAR16
*SerialNumberStr
;
2308 USB_WWID_DEVICE_PATH
*UsbWwid
;
2310 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2311 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2312 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2313 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2314 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2315 MESSAGING_DEVICE_PATH
,
2317 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + StrSize (SerialNumberStr
))
2320 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2321 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2322 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2323 StrCpy ((CHAR16
*) ((UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
)), SerialNumberStr
);
2325 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2329 Converts a text device path node to Logic Unit device path structure.
2331 @param TextDeviceNode The input Text device path node.
2333 @return A pointer to the newly-created Logic Unit device path structure.
2336 EFI_DEVICE_PATH_PROTOCOL
*
2337 DevPathFromTextUnit (
2338 IN CHAR16
*TextDeviceNode
2342 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2344 LunStr
= GetNextParamStr (&TextDeviceNode
);
2345 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2346 MESSAGING_DEVICE_PATH
,
2347 MSG_DEVICE_LOGICAL_UNIT_DP
,
2348 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2351 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2353 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2357 Converts a text device path node to iSCSI device path structure.
2359 @param TextDeviceNode The input Text device path node.
2361 @return A pointer to the newly-created iSCSI device path structure.
2364 EFI_DEVICE_PATH_PROTOCOL
*
2365 DevPathFromTextiSCSI (
2366 IN CHAR16
*TextDeviceNode
2371 CHAR16
*PortalGroupStr
;
2373 CHAR16
*HeaderDigestStr
;
2374 CHAR16
*DataDigestStr
;
2375 CHAR16
*AuthenticationStr
;
2376 CHAR16
*ProtocolStr
;
2378 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2380 NameStr
= GetNextParamStr (&TextDeviceNode
);
2381 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2382 LunStr
= GetNextParamStr (&TextDeviceNode
);
2383 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2384 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2385 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2386 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2387 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2388 MESSAGING_DEVICE_PATH
,
2390 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2393 AsciiStr
= ISCSIDevPath
->TargetName
;
2394 StrToAscii (NameStr
, &AsciiStr
);
2396 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2397 Strtoi64 (LunStr
, &ISCSIDevPath
->Lun
);
2400 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2404 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2408 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2412 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2416 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2418 ISCSIDevPath
->NetworkProtocol
= (UINT16
) StrCmp (ProtocolStr
, L
"TCP");
2420 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2424 Converts a text device path node to VLAN device path structure.
2426 @param TextDeviceNode The input Text device path node.
2428 @return A pointer to the newly-created VLAN device path structure.
2431 EFI_DEVICE_PATH_PROTOCOL
*
2432 DevPathFromTextVlan (
2433 IN CHAR16
*TextDeviceNode
2437 VLAN_DEVICE_PATH
*Vlan
;
2439 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2440 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2441 MESSAGING_DEVICE_PATH
,
2443 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2446 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2448 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2452 Converts a text device path node to HD device path structure.
2454 @param TextDeviceNode The input Text device path node.
2456 @return A pointer to the newly-created HD device path structure.
2459 EFI_DEVICE_PATH_PROTOCOL
*
2461 IN CHAR16
*TextDeviceNode
2464 CHAR16
*PartitionStr
;
2466 CHAR16
*SignatureStr
;
2470 EFI_GUID SignatureGuid
;
2471 HARDDRIVE_DEVICE_PATH
*Hd
;
2473 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2474 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2475 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2476 StartStr
= GetNextParamStr (&TextDeviceNode
);
2477 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2478 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2481 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2484 Hd
->PartitionNumber
= (UINT32
) Dtoi (PartitionStr
);
2486 ZeroMem (Hd
->Signature
, 16);
2487 Hd
->MBRType
= (UINT8
) 0;
2489 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2490 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2493 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2494 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2495 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2496 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2499 StrToGuid (SignatureStr
, &SignatureGuid
);
2500 CopyMem (Hd
->Signature
, &SignatureGuid
, sizeof (EFI_GUID
));
2502 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2505 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2506 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2508 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2512 Converts a text device path node to CDROM device path structure.
2514 @param TextDeviceNode The input Text device path node.
2516 @return A pointer to the newly-created CDROM device path structure.
2519 EFI_DEVICE_PATH_PROTOCOL
*
2520 DevPathFromTextCDROM (
2521 IN CHAR16
*TextDeviceNode
2527 CDROM_DEVICE_PATH
*CDROMDevPath
;
2529 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2530 StartStr
= GetNextParamStr (&TextDeviceNode
);
2531 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2532 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2535 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2538 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2539 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2540 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2542 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2546 Converts a text device path node to Vendor-defined media device path structure.
2548 @param TextDeviceNode The input Text device path node.
2550 @return A pointer to the newly-created Vendor-defined media device path structure.
2553 EFI_DEVICE_PATH_PROTOCOL
*
2554 DevPathFromTextVenMEDIA (
2555 IN CHAR16
*TextDeviceNode
2558 return ConvertFromTextVendor (
2566 Converts a text device path node to File device path structure.
2568 @param TextDeviceNode The input Text device path node.
2570 @return A pointer to the newly-created File device path structure.
2573 EFI_DEVICE_PATH_PROTOCOL
*
2574 DevPathFromTextFilePath (
2575 IN CHAR16
*TextDeviceNode
2578 FILEPATH_DEVICE_PATH
*File
;
2580 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2583 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
2586 StrCpy (File
->PathName
, TextDeviceNode
);
2588 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
2592 Converts a text device path node to Media protocol device path structure.
2594 @param TextDeviceNode The input Text device path node.
2596 @return A pointer to the newly-created Media protocol device path structure.
2599 EFI_DEVICE_PATH_PROTOCOL
*
2600 DevPathFromTextMedia (
2601 IN CHAR16
*TextDeviceNode
2605 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
2607 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2608 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
2611 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
2614 StrToGuid (GuidStr
, &Media
->Protocol
);
2616 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
2620 Converts a text device path node to firmware volume device path structure.
2622 @param TextDeviceNode The input Text device path node.
2624 @return A pointer to the newly-created firmware volume device path structure.
2627 EFI_DEVICE_PATH_PROTOCOL
*
2629 IN CHAR16
*TextDeviceNode
2633 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
2635 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2636 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
2638 MEDIA_PIWG_FW_VOL_DP
,
2639 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
2642 StrToGuid (GuidStr
, &Fv
->FvName
);
2644 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
2648 Converts a text device path node to firmware file device path structure.
2650 @param TextDeviceNode The input Text device path node.
2652 @return A pointer to the newly-created firmware file device path structure.
2655 EFI_DEVICE_PATH_PROTOCOL
*
2656 DevPathFromTextFvFile (
2657 IN CHAR16
*TextDeviceNode
2661 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
2663 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2664 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2666 MEDIA_PIWG_FW_FILE_DP
,
2667 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
2670 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
2672 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
2676 Converts a text device path node to text relative offset device path structure.
2678 @param TextDeviceNode The input Text device path node.
2680 @return A pointer to the newly-created Text device path structure.
2683 EFI_DEVICE_PATH_PROTOCOL
*
2684 DevPathFromTextRelativeOffsetRange (
2685 IN CHAR16
*TextDeviceNode
2688 CHAR16
*StartingOffsetStr
;
2689 CHAR16
*EndingOffsetStr
;
2690 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
2692 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2693 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2694 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
2696 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
2697 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
2700 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
2701 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
2703 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
2707 Converts a text device path node to BIOS Boot Specification device path structure.
2709 @param TextDeviceNode The input Text device path node.
2711 @return A pointer to the newly-created BIOS Boot Specification device path structure.
2714 EFI_DEVICE_PATH_PROTOCOL
*
2715 DevPathFromTextBBS (
2716 IN CHAR16
*TextDeviceNode
2723 BBS_BBS_DEVICE_PATH
*Bbs
;
2725 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2726 IdStr
= GetNextParamStr (&TextDeviceNode
);
2727 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
2728 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
2731 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
2734 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
2735 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
2736 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
2737 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
2738 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
2739 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
2740 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
2741 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
2742 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
2743 Bbs
->DeviceType
= BBS_TYPE_USB
;
2744 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
2745 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
2747 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
2750 AsciiStr
= Bbs
->String
;
2751 StrToAscii (IdStr
, &AsciiStr
);
2753 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
2755 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
2759 Converts a text device path node to SATA device path structure.
2761 @param TextDeviceNode The input Text device path node.
2763 @return A pointer to the newly-created SATA device path structure.
2766 EFI_DEVICE_PATH_PROTOCOL
*
2767 DevPathFromTextSata (
2768 IN CHAR16
*TextDeviceNode
2771 SATA_DEVICE_PATH
*Sata
;
2777 // The PMPN is optional.
2779 Param1
= GetNextParamStr (&TextDeviceNode
);
2780 Param2
= GetNextParamStr (&TextDeviceNode
);
2782 if (!IS_NULL (TextDeviceNode
)) {
2783 Param3
= GetNextParamStr (&TextDeviceNode
);
2786 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
2787 MESSAGING_DEVICE_PATH
,
2789 (UINT16
) sizeof (SATA_DEVICE_PATH
)
2791 Sata
->HBAPortNumber
= (UINT16
) Xtoi (Param1
);
2792 if (Param3
!= NULL
) {
2793 Sata
->PortMultiplierPortNumber
= (UINT16
) Xtoi (Param2
);
2796 Sata
->PortMultiplierPortNumber
= SATA_HBA_DIRECT_CONNECT_FLAG
;
2798 Sata
->Lun
= (UINT16
) Xtoi (Param2
);
2800 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
2803 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable
[] = {
2804 {L
"Pci", DevPathFromTextPci
},
2805 {L
"PcCard", DevPathFromTextPcCard
},
2806 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
2807 {L
"VenHw", DevPathFromTextVenHw
},
2808 {L
"Ctrl", DevPathFromTextCtrl
},
2809 {L
"Acpi", DevPathFromTextAcpi
},
2810 {L
"PciRoot", DevPathFromTextPciRoot
},
2811 {L
"Floppy", DevPathFromTextFloppy
},
2812 {L
"Keyboard", DevPathFromTextKeyboard
},
2813 {L
"Serial", DevPathFromTextSerial
},
2814 {L
"ParallelPort", DevPathFromTextParallelPort
},
2815 {L
"AcpiEx", DevPathFromTextAcpiEx
},
2816 {L
"AcpiExp", DevPathFromTextAcpiExp
},
2817 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
2818 {L
"Ata", DevPathFromTextAta
},
2819 {L
"Scsi", DevPathFromTextScsi
},
2820 {L
"Fibre", DevPathFromTextFibre
},
2821 {L
"I1394", DevPathFromText1394
},
2822 {L
"USB", DevPathFromTextUsb
},
2823 {L
"I2O", DevPathFromTextI2O
},
2824 {L
"Infiniband", DevPathFromTextInfiniband
},
2825 {L
"VenMsg", DevPathFromTextVenMsg
},
2826 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
2827 {L
"VenVt100", DevPathFromTextVenVt100
},
2828 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
2829 {L
"VenUtf8", DevPathFromTextVenUtf8
},
2830 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
2831 {L
"SAS", DevPathFromTextSAS
},
2832 {L
"DebugPort", DevPathFromTextDebugPort
},
2833 {L
"MAC", DevPathFromTextMAC
},
2834 {L
"IPv4", DevPathFromTextIPv4
},
2835 {L
"IPv6", DevPathFromTextIPv6
},
2836 {L
"Uart", DevPathFromTextUart
},
2837 {L
"UsbClass", DevPathFromTextUsbClass
},
2838 {L
"UsbAudio", DevPathFromTextUsbAudio
},
2839 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
2840 {L
"UsbHID", DevPathFromTextUsbHID
},
2841 {L
"UsbImage", DevPathFromTextUsbImage
},
2842 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
2843 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
2844 {L
"UsbHub", DevPathFromTextUsbHub
},
2845 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
2846 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
2847 {L
"UsbVideo", DevPathFromTextUsbVideo
},
2848 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
2849 {L
"UsbWireless", DevPathFromTextUsbWireless
},
2850 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
2851 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
2852 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
2853 {L
"UsbWwid", DevPathFromTextUsbWwid
},
2854 {L
"Unit", DevPathFromTextUnit
},
2855 {L
"iSCSI", DevPathFromTextiSCSI
},
2856 {L
"Vlan", DevPathFromTextVlan
},
2857 {L
"HD", DevPathFromTextHD
},
2858 {L
"CDROM", DevPathFromTextCDROM
},
2859 {L
"VenMEDIA", DevPathFromTextVenMEDIA
},
2860 {L
"Media", DevPathFromTextMedia
},
2861 {L
"Fv", DevPathFromTextFv
},
2862 {L
"FvFile", DevPathFromTextFvFile
},
2863 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
2864 {L
"BBS", DevPathFromTextBBS
},
2865 {L
"Sata", DevPathFromTextSata
},
2870 Convert text to the binary representation of a device node.
2872 @param TextDeviceNode TextDeviceNode points to the text representation of a device
2873 node. Conversion starts with the first character and continues
2874 until the first non-device node character.
2876 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
2877 insufficient memory or text unsupported.
2880 EFI_DEVICE_PATH_PROTOCOL
*
2882 ConvertTextToDeviceNode (
2883 IN CONST CHAR16
*TextDeviceNode
2888 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
2889 CHAR16
*DeviceNodeStr
;
2892 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
2898 DeviceNodeStr
= StrDuplicate (TextDeviceNode
);
2899 ASSERT (DeviceNodeStr
!= NULL
);
2901 for (Index
= 0; DevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
2902 ParamStr
= GetParamByNodeName (DeviceNodeStr
, DevPathFromTextTable
[Index
].DevicePathNodeText
);
2903 if (ParamStr
!= NULL
) {
2904 DumpNode
= DevPathFromTextTable
[Index
].Function
;
2909 if (DumpNode
== NULL
) {
2913 DumpNode
= DevPathFromTextFilePath
;
2914 DeviceNode
= DumpNode (DeviceNodeStr
);
2916 DeviceNode
= DumpNode (ParamStr
);
2917 FreePool (ParamStr
);
2920 FreePool (DeviceNodeStr
);
2926 Convert text to the binary representation of a device path.
2929 @param TextDevicePath TextDevicePath points to the text representation of a device
2930 path. Conversion starts with the first character and continues
2931 until the first non-device node character.
2933 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
2934 there was insufficient memory.
2937 EFI_DEVICE_PATH_PROTOCOL
*
2939 ConvertTextToDevicePath (
2940 IN CONST CHAR16
*TextDevicePath
2945 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
2947 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
2948 CHAR16
*DevicePathStr
;
2950 CHAR16
*DeviceNodeStr
;
2951 UINT8 IsInstanceEnd
;
2952 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
2954 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
2958 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
2959 ASSERT (DevicePath
!= NULL
);
2960 SetDevicePathEndNode (DevicePath
);
2963 DeviceNodeStr
= NULL
;
2964 DevicePathStr
= StrDuplicate (TextDevicePath
);
2966 Str
= DevicePathStr
;
2967 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
2969 for (Index
= 0; DevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
2970 ParamStr
= GetParamByNodeName (DeviceNodeStr
, DevPathFromTextTable
[Index
].DevicePathNodeText
);
2971 if (ParamStr
!= NULL
) {
2972 DumpNode
= DevPathFromTextTable
[Index
].Function
;
2977 if (DumpNode
== NULL
) {
2981 DumpNode
= DevPathFromTextFilePath
;
2982 DeviceNode
= DumpNode (DeviceNodeStr
);
2984 DeviceNode
= DumpNode (ParamStr
);
2985 FreePool (ParamStr
);
2988 NewDevicePath
= AppendDeviceNodeProtocolInterface (DevicePath
, DeviceNode
);
2989 FreePool (DevicePath
);
2990 FreePool (DeviceNode
);
2991 DevicePath
= NewDevicePath
;
2993 if (IsInstanceEnd
!= 0) {
2994 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
2995 ASSERT (DeviceNode
!= NULL
);
2996 SET_DEVICE_PATH_INSTANCE_END_NODE (DeviceNode
);
2998 NewDevicePath
= AppendDeviceNodeProtocolInterface (DevicePath
, DeviceNode
);
2999 FreePool (DevicePath
);
3000 FreePool (DeviceNode
);
3001 DevicePath
= NewDevicePath
;
3005 FreePool (DevicePathStr
);