2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
4 Copyright (c) 2006 - 2013, 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 PCIE root device path structure.
976 @param TextDeviceNode The input Text device path node.
978 @return A pointer to the newly-created PCIE root device path structure.
981 EFI_DEVICE_PATH_PROTOCOL
*
982 DevPathFromTextPcieRoot (
983 IN CHAR16
*TextDeviceNode
986 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a08);
990 Converts a text device path node to Floppy device path structure.
992 @param TextDeviceNode The input Text device path node.
994 @return A pointer to the newly-created Floppy device path structure.
997 EFI_DEVICE_PATH_PROTOCOL
*
998 DevPathFromTextFloppy (
999 IN CHAR16
*TextDeviceNode
1002 return ConvertFromTextAcpi (TextDeviceNode
, 0x0604);
1006 Converts a text device path node to Keyboard device path structure.
1008 @param TextDeviceNode The input Text device path node.
1010 @return A pointer to the newly-created Keyboard device path structure.
1013 EFI_DEVICE_PATH_PROTOCOL
*
1014 DevPathFromTextKeyboard (
1015 IN CHAR16
*TextDeviceNode
1018 return ConvertFromTextAcpi (TextDeviceNode
, 0x0301);
1022 Converts a text device path node to Serial device path structure.
1024 @param TextDeviceNode The input Text device path node.
1026 @return A pointer to the newly-created Serial device path structure.
1029 EFI_DEVICE_PATH_PROTOCOL
*
1030 DevPathFromTextSerial (
1031 IN CHAR16
*TextDeviceNode
1034 return ConvertFromTextAcpi (TextDeviceNode
, 0x0501);
1038 Converts a text device path node to Parallel Port device path structure.
1040 @param TextDeviceNode The input Text device path node.
1042 @return A pointer to the newly-created Parallel Port device path structure.
1045 EFI_DEVICE_PATH_PROTOCOL
*
1046 DevPathFromTextParallelPort (
1047 IN CHAR16
*TextDeviceNode
1050 return ConvertFromTextAcpi (TextDeviceNode
, 0x0401);
1054 Converts a text device path node to ACPI extension device path structure.
1056 @param TextDeviceNode The input Text device path node.
1058 @return A pointer to the newly-created ACPI extension device path structure.
1061 EFI_DEVICE_PATH_PROTOCOL
*
1062 DevPathFromTextAcpiEx (
1063 IN CHAR16
*TextDeviceNode
1074 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
1076 HIDStr
= GetNextParamStr (&TextDeviceNode
);
1077 CIDStr
= GetNextParamStr (&TextDeviceNode
);
1078 UIDStr
= GetNextParamStr (&TextDeviceNode
);
1079 HIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1080 CIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1081 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1083 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (HIDSTRStr
) + 1);
1084 Length
= (UINT16
) (Length
+ StrLen (UIDSTRStr
) + 1);
1085 Length
= (UINT16
) (Length
+ StrLen (CIDSTRStr
) + 1);
1086 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
1092 EisaIdFromText (HIDStr
, &AcpiEx
->HID
);
1093 EisaIdFromText (CIDStr
, &AcpiEx
->CID
);
1094 AcpiEx
->UID
= (UINT32
) Strtoi (UIDStr
);
1096 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
1097 StrToAscii (HIDSTRStr
, &AsciiStr
);
1098 StrToAscii (UIDSTRStr
, &AsciiStr
);
1099 StrToAscii (CIDSTRStr
, &AsciiStr
);
1101 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
1105 Converts a text device path node to ACPI extension device path structure.
1107 @param TextDeviceNode The input Text device path node.
1109 @return A pointer to the newly-created ACPI extension device path structure.
1112 EFI_DEVICE_PATH_PROTOCOL
*
1113 DevPathFromTextAcpiExp (
1114 IN CHAR16
*TextDeviceNode
1122 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
1124 HIDStr
= GetNextParamStr (&TextDeviceNode
);
1125 CIDStr
= GetNextParamStr (&TextDeviceNode
);
1126 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1127 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (UIDSTRStr
) + 3);
1128 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
1134 EisaIdFromText (HIDStr
, &AcpiEx
->HID
);
1135 EisaIdFromText (CIDStr
, &AcpiEx
->CID
);
1138 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
1140 // HID string is NULL
1144 // Convert UID string
1147 StrToAscii (UIDSTRStr
, &AsciiStr
);
1149 // CID string is NULL
1153 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
1157 Converts a text device path node to ACPI _ADR device path structure.
1159 @param TextDeviceNode The input Text device path node.
1161 @return A pointer to the newly-created ACPI _ADR device path structure.
1164 EFI_DEVICE_PATH_PROTOCOL
*
1165 DevPathFromTextAcpiAdr (
1166 IN CHAR16
*TextDeviceNode
1169 CHAR16
*DisplayDeviceStr
;
1170 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
1174 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*) CreateDeviceNode (
1177 (UINT16
) sizeof (ACPI_ADR_DEVICE_PATH
)
1179 ASSERT (AcpiAdr
!= NULL
);
1181 for (Index
= 0; ; Index
++) {
1182 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
1183 if (IS_NULL (*DisplayDeviceStr
)) {
1187 Length
= DevicePathNodeLength (AcpiAdr
);
1188 AcpiAdr
= ReallocatePool (
1190 Length
+ sizeof (UINT32
),
1193 ASSERT (AcpiAdr
!= NULL
);
1194 SetDevicePathNodeLength (AcpiAdr
, Length
+ sizeof (UINT32
));
1197 (&AcpiAdr
->ADR
)[Index
] = (UINT32
) Strtoi (DisplayDeviceStr
);
1200 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
;
1204 Converts a text device path node to Parallel Port device path structure.
1206 @param TextDeviceNode The input Text device path node.
1208 @return A pointer to the newly-created Parallel Port device path structure.
1211 EFI_DEVICE_PATH_PROTOCOL
*
1212 DevPathFromTextAta (
1213 IN CHAR16
*TextDeviceNode
1216 CHAR16
*PrimarySecondaryStr
;
1217 CHAR16
*SlaveMasterStr
;
1219 ATAPI_DEVICE_PATH
*Atapi
;
1221 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
1222 MESSAGING_DEVICE_PATH
,
1224 (UINT16
) sizeof (ATAPI_DEVICE_PATH
)
1227 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
1228 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
1229 LunStr
= GetNextParamStr (&TextDeviceNode
);
1231 Atapi
->PrimarySecondary
= (UINT8
) ((StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) ? 0 : 1);
1232 Atapi
->SlaveMaster
= (UINT8
) ((StrCmp (SlaveMasterStr
, L
"Master") == 0) ? 0 : 1);
1233 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
1235 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
1239 Converts a text device path node to SCSI device path structure.
1241 @param TextDeviceNode The input Text device path node.
1243 @return A pointer to the newly-created SCSI device path structure.
1246 EFI_DEVICE_PATH_PROTOCOL
*
1247 DevPathFromTextScsi (
1248 IN CHAR16
*TextDeviceNode
1253 SCSI_DEVICE_PATH
*Scsi
;
1255 PunStr
= GetNextParamStr (&TextDeviceNode
);
1256 LunStr
= GetNextParamStr (&TextDeviceNode
);
1257 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
1258 MESSAGING_DEVICE_PATH
,
1260 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
1263 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
1264 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
1266 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
1270 Converts a text device path node to Fibre device path structure.
1272 @param TextDeviceNode The input Text device path node.
1274 @return A pointer to the newly-created Fibre device path structure.
1277 EFI_DEVICE_PATH_PROTOCOL
*
1278 DevPathFromTextFibre (
1279 IN CHAR16
*TextDeviceNode
1284 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
1286 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1287 LunStr
= GetNextParamStr (&TextDeviceNode
);
1288 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
1289 MESSAGING_DEVICE_PATH
,
1290 MSG_FIBRECHANNEL_DP
,
1291 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
1294 Fibre
->Reserved
= 0;
1295 Strtoi64 (WWNStr
, &Fibre
->WWN
);
1296 Strtoi64 (LunStr
, &Fibre
->Lun
);
1298 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
1302 Converts a text device path node to FibreEx device path structure.
1304 @param TextDeviceNode The input Text device path node.
1306 @return A pointer to the newly-created FibreEx device path structure.
1309 EFI_DEVICE_PATH_PROTOCOL
*
1310 DevPathFromTextFibreEx (
1311 IN CHAR16
*TextDeviceNode
1316 FIBRECHANNELEX_DEVICE_PATH
*FibreEx
;
1318 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1319 LunStr
= GetNextParamStr (&TextDeviceNode
);
1320 FibreEx
= (FIBRECHANNELEX_DEVICE_PATH
*) CreateDeviceNode (
1321 MESSAGING_DEVICE_PATH
,
1322 MSG_FIBRECHANNELEX_DP
,
1323 (UINT16
) sizeof (FIBRECHANNELEX_DEVICE_PATH
)
1326 FibreEx
->Reserved
= 0;
1327 Strtoi64 (WWNStr
, (UINT64
*) (&FibreEx
->WWN
));
1328 Strtoi64 (LunStr
, (UINT64
*) (&FibreEx
->Lun
));
1330 *(UINT64
*) (&FibreEx
->WWN
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->WWN
));
1331 *(UINT64
*) (&FibreEx
->Lun
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->Lun
));
1333 return (EFI_DEVICE_PATH_PROTOCOL
*) FibreEx
;
1337 Converts a text device path node to 1394 device path structure.
1339 @param TextDeviceNode The input Text device path node.
1341 @return A pointer to the newly-created 1394 device path structure.
1344 EFI_DEVICE_PATH_PROTOCOL
*
1345 DevPathFromText1394 (
1346 IN CHAR16
*TextDeviceNode
1350 F1394_DEVICE_PATH
*F1394DevPath
;
1352 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1353 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1354 MESSAGING_DEVICE_PATH
,
1356 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1359 F1394DevPath
->Reserved
= 0;
1360 Xtoi64 (GuidStr
, &F1394DevPath
->Guid
);
1362 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1366 Converts a text device path node to USB device path structure.
1368 @param TextDeviceNode The input Text device path node.
1370 @return A pointer to the newly-created USB device path structure.
1373 EFI_DEVICE_PATH_PROTOCOL
*
1374 DevPathFromTextUsb (
1375 IN CHAR16
*TextDeviceNode
1379 CHAR16
*InterfaceStr
;
1380 USB_DEVICE_PATH
*Usb
;
1382 PortStr
= GetNextParamStr (&TextDeviceNode
);
1383 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1384 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1385 MESSAGING_DEVICE_PATH
,
1387 (UINT16
) sizeof (USB_DEVICE_PATH
)
1390 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1391 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1393 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1397 Converts a text device path node to I20 device path structure.
1399 @param TextDeviceNode The input Text device path node.
1401 @return A pointer to the newly-created I20 device path structure.
1404 EFI_DEVICE_PATH_PROTOCOL
*
1405 DevPathFromTextI2O (
1406 IN CHAR16
*TextDeviceNode
1410 I2O_DEVICE_PATH
*I2ODevPath
;
1412 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1413 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1414 MESSAGING_DEVICE_PATH
,
1416 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1419 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1421 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1425 Converts a text device path node to Infini Band device path structure.
1427 @param TextDeviceNode The input Text device path node.
1429 @return A pointer to the newly-created Infini Band device path structure.
1432 EFI_DEVICE_PATH_PROTOCOL
*
1433 DevPathFromTextInfiniband (
1434 IN CHAR16
*TextDeviceNode
1443 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1445 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1446 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1447 SidStr
= GetNextParamStr (&TextDeviceNode
);
1448 TidStr
= GetNextParamStr (&TextDeviceNode
);
1449 DidStr
= GetNextParamStr (&TextDeviceNode
);
1450 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1451 MESSAGING_DEVICE_PATH
,
1453 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1456 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1457 StrToGuid (GuidStr
, &PortGid
);
1458 CopyMem (InfiniBand
->PortGid
, &PortGid
, sizeof (EFI_GUID
));
1459 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1460 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1461 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1463 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1467 Converts a text device path node to Vendor-Defined Messaging device path structure.
1469 @param TextDeviceNode The input Text device path node.
1471 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1474 EFI_DEVICE_PATH_PROTOCOL
*
1475 DevPathFromTextVenMsg (
1476 IN CHAR16
*TextDeviceNode
1479 return ConvertFromTextVendor (
1481 MESSAGING_DEVICE_PATH
,
1487 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1489 @param TextDeviceNode The input Text device path node.
1491 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1494 EFI_DEVICE_PATH_PROTOCOL
*
1495 DevPathFromTextVenPcAnsi (
1496 IN CHAR16
*TextDeviceNode
1499 VENDOR_DEVICE_PATH
*Vendor
;
1501 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1502 MESSAGING_DEVICE_PATH
,
1504 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1505 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1507 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1511 Converts a text device path node to Vendor defined VT100 device path structure.
1513 @param TextDeviceNode The input Text device path node.
1515 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1518 EFI_DEVICE_PATH_PROTOCOL
*
1519 DevPathFromTextVenVt100 (
1520 IN CHAR16
*TextDeviceNode
1523 VENDOR_DEVICE_PATH
*Vendor
;
1525 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1526 MESSAGING_DEVICE_PATH
,
1528 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1529 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1531 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1535 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1537 @param TextDeviceNode The input Text device path node.
1539 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1542 EFI_DEVICE_PATH_PROTOCOL
*
1543 DevPathFromTextVenVt100Plus (
1544 IN CHAR16
*TextDeviceNode
1547 VENDOR_DEVICE_PATH
*Vendor
;
1549 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1550 MESSAGING_DEVICE_PATH
,
1552 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1553 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1555 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1559 Converts a text device path node to Vendor defined UTF8 device path structure.
1561 @param TextDeviceNode The input Text device path node.
1563 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1566 EFI_DEVICE_PATH_PROTOCOL
*
1567 DevPathFromTextVenUtf8 (
1568 IN CHAR16
*TextDeviceNode
1571 VENDOR_DEVICE_PATH
*Vendor
;
1573 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1574 MESSAGING_DEVICE_PATH
,
1576 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1577 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1579 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1583 Converts a text device path node to UART Flow Control device path structure.
1585 @param TextDeviceNode The input Text device path node.
1587 @return A pointer to the newly-created UART Flow Control device path structure.
1590 EFI_DEVICE_PATH_PROTOCOL
*
1591 DevPathFromTextUartFlowCtrl (
1592 IN CHAR16
*TextDeviceNode
1596 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1598 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1599 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1600 MESSAGING_DEVICE_PATH
,
1602 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1605 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1606 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1607 UartFlowControl
->FlowControlMap
= 2;
1608 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1609 UartFlowControl
->FlowControlMap
= 1;
1611 UartFlowControl
->FlowControlMap
= 0;
1614 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1618 Converts a text device path node to Serial Attached SCSI device path structure.
1620 @param TextDeviceNode The input Text device path node.
1622 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1625 EFI_DEVICE_PATH_PROTOCOL
*
1626 DevPathFromTextSAS (
1627 IN CHAR16
*TextDeviceNode
1634 CHAR16
*LocationStr
;
1636 CHAR16
*DriveBayStr
;
1637 CHAR16
*ReservedStr
;
1640 SAS_DEVICE_PATH
*Sas
;
1642 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1643 LunStr
= GetNextParamStr (&TextDeviceNode
);
1644 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1645 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1646 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1647 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1648 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1649 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1650 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1651 MESSAGING_DEVICE_PATH
,
1653 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1656 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1657 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1658 Strtoi64 (LunStr
, &Sas
->Lun
);
1659 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1661 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1664 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1666 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1670 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1673 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1678 // Location is an integer between 0 and 1 or else
1679 // the keyword Internal (0) or External (1).
1681 if (StrCmp (LocationStr
, L
"External") == 0) {
1683 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1686 Uint16
= (Strtoi (LocationStr
) & BIT0
);
1688 Info
|= (Uint16
<< 5);
1691 // Connect is an integer between 0 and 3 or else
1692 // the keyword Direct (0) or Expanded (1).
1694 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1696 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1699 Uint16
= (Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1701 Info
|= (Uint16
<< 6);
1704 Info
= (UINT16
) Strtoi (SASSATAStr
);
1707 Sas
->DeviceTopology
= Info
;
1708 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1710 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1714 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1716 @param TextDeviceNode The input Text device path node.
1718 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1721 EFI_DEVICE_PATH_PROTOCOL
*
1722 DevPathFromTextSasEx (
1723 IN CHAR16
*TextDeviceNode
1730 CHAR16
*LocationStr
;
1732 CHAR16
*DriveBayStr
;
1737 SASEX_DEVICE_PATH
*SasEx
;
1739 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1740 LunStr
= GetNextParamStr (&TextDeviceNode
);
1741 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1742 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1743 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1744 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1745 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1746 SasEx
= (SASEX_DEVICE_PATH
*) CreateDeviceNode (
1747 MESSAGING_DEVICE_PATH
,
1749 (UINT16
) sizeof (SASEX_DEVICE_PATH
)
1752 Strtoi64 (AddressStr
, &SasAddress
);
1753 Strtoi64 (LunStr
, &Lun
);
1754 WriteUnaligned64 ((UINT64
*) &SasEx
->SasAddress
, SwapBytes64 (SasAddress
));
1755 WriteUnaligned64 ((UINT64
*) &SasEx
->Lun
, SwapBytes64 (Lun
));
1756 SasEx
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1758 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1761 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1763 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1767 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1770 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1775 // Location is an integer between 0 and 1 or else
1776 // the keyword Internal (0) or External (1).
1778 if (StrCmp (LocationStr
, L
"External") == 0) {
1780 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1783 Uint16
= (Strtoi (LocationStr
) & BIT0
);
1785 Info
|= (Uint16
<< 5);
1788 // Connect is an integer between 0 and 3 or else
1789 // the keyword Direct (0) or Expanded (1).
1791 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1793 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1796 Uint16
= (Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1798 Info
|= (Uint16
<< 6);
1801 Info
= (UINT16
) Strtoi (SASSATAStr
);
1804 SasEx
->DeviceTopology
= Info
;
1806 return (EFI_DEVICE_PATH_PROTOCOL
*) SasEx
;
1810 Converts a text device path node to Debug Port device path structure.
1812 @param TextDeviceNode The input Text device path node.
1814 @return A pointer to the newly-created Debug Port device path structure.
1817 EFI_DEVICE_PATH_PROTOCOL
*
1818 DevPathFromTextDebugPort (
1819 IN CHAR16
*TextDeviceNode
1822 VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*Vend
;
1824 Vend
= (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*) CreateDeviceNode (
1825 MESSAGING_DEVICE_PATH
,
1827 (UINT16
) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
)
1830 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1832 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1836 Converts a text device path node to MAC device path structure.
1838 @param TextDeviceNode The input Text device path node.
1840 @return A pointer to the newly-created MAC device path structure.
1843 EFI_DEVICE_PATH_PROTOCOL
*
1844 DevPathFromTextMAC (
1845 IN CHAR16
*TextDeviceNode
1851 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1853 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1854 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1855 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1856 MESSAGING_DEVICE_PATH
,
1858 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1861 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1863 Length
= sizeof (EFI_MAC_ADDRESS
);
1864 StrToBuf (&MACDevPath
->MacAddress
.Addr
[0], Length
, AddressStr
);
1866 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1871 Converts a text format to the network protocol ID.
1873 @param Text String of protocol field.
1875 @return Network protocol ID .
1879 NetworkProtocolFromText (
1883 if (StrCmp (Text
, L
"UDP") == 0) {
1884 return RFC_1700_UDP_PROTOCOL
;
1887 if (StrCmp (Text
, L
"TCP") == 0) {
1888 return RFC_1700_TCP_PROTOCOL
;
1891 return Strtoi (Text
);
1896 Converts a text device path node to IPV4 device path structure.
1898 @param TextDeviceNode The input Text device path node.
1900 @return A pointer to the newly-created IPV4 device path structure.
1903 EFI_DEVICE_PATH_PROTOCOL
*
1904 DevPathFromTextIPv4 (
1905 IN CHAR16
*TextDeviceNode
1908 CHAR16
*RemoteIPStr
;
1909 CHAR16
*ProtocolStr
;
1912 CHAR16
*GatewayIPStr
;
1913 CHAR16
*SubnetMaskStr
;
1914 IPv4_DEVICE_PATH
*IPv4
;
1916 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1917 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1918 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1919 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1920 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1921 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
1922 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1923 MESSAGING_DEVICE_PATH
,
1925 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
1928 StrToIPv4Addr (&RemoteIPStr
, &IPv4
->RemoteIpAddress
);
1929 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1930 if (StrCmp (TypeStr
, L
"Static") == 0) {
1931 IPv4
->StaticIpAddress
= TRUE
;
1933 IPv4
->StaticIpAddress
= FALSE
;
1936 StrToIPv4Addr (&LocalIPStr
, &IPv4
->LocalIpAddress
);
1937 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
1938 StrToIPv4Addr (&GatewayIPStr
, &IPv4
->GatewayIpAddress
);
1939 StrToIPv4Addr (&SubnetMaskStr
, &IPv4
->SubnetMask
);
1941 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
1942 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
1945 IPv4
->LocalPort
= 0;
1946 IPv4
->RemotePort
= 0;
1948 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1952 Converts a text device path node to IPV6 device path structure.
1954 @param TextDeviceNode The input Text device path node.
1956 @return A pointer to the newly-created IPV6 device path structure.
1959 EFI_DEVICE_PATH_PROTOCOL
*
1960 DevPathFromTextIPv6 (
1961 IN CHAR16
*TextDeviceNode
1964 CHAR16
*RemoteIPStr
;
1965 CHAR16
*ProtocolStr
;
1968 CHAR16
*GatewayIPStr
;
1969 CHAR16
*PrefixLengthStr
;
1970 IPv6_DEVICE_PATH
*IPv6
;
1972 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1973 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1974 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1975 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1976 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
1977 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1978 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1979 MESSAGING_DEVICE_PATH
,
1981 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
1984 StrToIPv6Addr (&RemoteIPStr
, &IPv6
->RemoteIpAddress
);
1985 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1986 if (StrCmp (TypeStr
, L
"Static") == 0) {
1987 IPv6
->IpAddressOrigin
= 0;
1988 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
1989 IPv6
->IpAddressOrigin
= 1;
1991 IPv6
->IpAddressOrigin
= 2;
1994 StrToIPv6Addr (&LocalIPStr
, &IPv6
->LocalIpAddress
);
1995 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
1996 StrToIPv6Addr (&GatewayIPStr
, &IPv6
->GatewayIpAddress
);
1997 IPv6
->PrefixLength
= (UINT8
) Strtoi (PrefixLengthStr
);
1999 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
2000 IPv6
->PrefixLength
= 0;
2003 IPv6
->LocalPort
= 0;
2004 IPv6
->RemotePort
= 0;
2006 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
2010 Converts a text device path node to UART device path structure.
2012 @param TextDeviceNode The input Text device path node.
2014 @return A pointer to the newly-created UART device path structure.
2017 EFI_DEVICE_PATH_PROTOCOL
*
2018 DevPathFromTextUart (
2019 IN CHAR16
*TextDeviceNode
2023 CHAR16
*DataBitsStr
;
2025 CHAR16
*StopBitsStr
;
2026 UART_DEVICE_PATH
*Uart
;
2028 BaudStr
= GetNextParamStr (&TextDeviceNode
);
2029 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
2030 ParityStr
= GetNextParamStr (&TextDeviceNode
);
2031 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
2032 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
2033 MESSAGING_DEVICE_PATH
,
2035 (UINT16
) sizeof (UART_DEVICE_PATH
)
2038 Uart
->BaudRate
= (StrCmp (BaudStr
, L
"DEFAULT") == 0) ? 115200 : Dtoi (BaudStr
);
2039 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Dtoi (DataBitsStr
));
2040 switch (*ParityStr
) {
2066 Uart
->Parity
= 0xff;
2069 if (StrCmp (StopBitsStr
, L
"D") == 0) {
2070 Uart
->StopBits
= (UINT8
) 0;
2071 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
2072 Uart
->StopBits
= (UINT8
) 1;
2073 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
2074 Uart
->StopBits
= (UINT8
) 2;
2075 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
2076 Uart
->StopBits
= (UINT8
) 3;
2078 Uart
->StopBits
= 0xff;
2081 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
2085 Converts a text device path node to USB class device path structure.
2087 @param TextDeviceNode The input Text device path node.
2088 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
2090 @return A pointer to the newly-created USB class device path structure.
2093 EFI_DEVICE_PATH_PROTOCOL
*
2094 ConvertFromTextUsbClass (
2095 IN CHAR16
*TextDeviceNode
,
2096 IN USB_CLASS_TEXT
*UsbClassText
2102 CHAR16
*SubClassStr
;
2103 CHAR16
*ProtocolStr
;
2104 USB_CLASS_DEVICE_PATH
*UsbClass
;
2106 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
2107 MESSAGING_DEVICE_PATH
,
2109 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
2112 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2113 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2114 if (UsbClassText
->ClassExist
) {
2115 ClassStr
= GetNextParamStr (&TextDeviceNode
);
2116 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
2118 UsbClass
->DeviceClass
= UsbClassText
->Class
;
2120 if (UsbClassText
->SubClassExist
) {
2121 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
2122 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
2124 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
2127 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2129 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2130 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2131 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
2133 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
2138 Converts a text device path node to USB class device path structure.
2140 @param TextDeviceNode The input Text device path node.
2142 @return A pointer to the newly-created USB class device path structure.
2145 EFI_DEVICE_PATH_PROTOCOL
*
2146 DevPathFromTextUsbClass (
2147 IN CHAR16
*TextDeviceNode
2150 USB_CLASS_TEXT UsbClassText
;
2152 UsbClassText
.ClassExist
= TRUE
;
2153 UsbClassText
.SubClassExist
= TRUE
;
2155 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2159 Converts a text device path node to USB audio device path structure.
2161 @param TextDeviceNode The input Text device path node.
2163 @return A pointer to the newly-created USB audio device path structure.
2166 EFI_DEVICE_PATH_PROTOCOL
*
2167 DevPathFromTextUsbAudio (
2168 IN CHAR16
*TextDeviceNode
2171 USB_CLASS_TEXT UsbClassText
;
2173 UsbClassText
.ClassExist
= FALSE
;
2174 UsbClassText
.Class
= USB_CLASS_AUDIO
;
2175 UsbClassText
.SubClassExist
= TRUE
;
2177 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2181 Converts a text device path node to USB CDC Control device path structure.
2183 @param TextDeviceNode The input Text device path node.
2185 @return A pointer to the newly-created USB CDC Control device path structure.
2188 EFI_DEVICE_PATH_PROTOCOL
*
2189 DevPathFromTextUsbCDCControl (
2190 IN CHAR16
*TextDeviceNode
2193 USB_CLASS_TEXT UsbClassText
;
2195 UsbClassText
.ClassExist
= FALSE
;
2196 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
2197 UsbClassText
.SubClassExist
= TRUE
;
2199 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2203 Converts a text device path node to USB HID device path structure.
2205 @param TextDeviceNode The input Text device path node.
2207 @return A pointer to the newly-created USB HID device path structure.
2210 EFI_DEVICE_PATH_PROTOCOL
*
2211 DevPathFromTextUsbHID (
2212 IN CHAR16
*TextDeviceNode
2215 USB_CLASS_TEXT UsbClassText
;
2217 UsbClassText
.ClassExist
= FALSE
;
2218 UsbClassText
.Class
= USB_CLASS_HID
;
2219 UsbClassText
.SubClassExist
= TRUE
;
2221 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2225 Converts a text device path node to USB Image device path structure.
2227 @param TextDeviceNode The input Text device path node.
2229 @return A pointer to the newly-created USB Image device path structure.
2232 EFI_DEVICE_PATH_PROTOCOL
*
2233 DevPathFromTextUsbImage (
2234 IN CHAR16
*TextDeviceNode
2237 USB_CLASS_TEXT UsbClassText
;
2239 UsbClassText
.ClassExist
= FALSE
;
2240 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2241 UsbClassText
.SubClassExist
= TRUE
;
2243 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2247 Converts a text device path node to USB Print device path structure.
2249 @param TextDeviceNode The input Text device path node.
2251 @return A pointer to the newly-created USB Print device path structure.
2254 EFI_DEVICE_PATH_PROTOCOL
*
2255 DevPathFromTextUsbPrinter (
2256 IN CHAR16
*TextDeviceNode
2259 USB_CLASS_TEXT UsbClassText
;
2261 UsbClassText
.ClassExist
= FALSE
;
2262 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2263 UsbClassText
.SubClassExist
= TRUE
;
2265 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2269 Converts a text device path node to USB mass storage device path structure.
2271 @param TextDeviceNode The input Text device path node.
2273 @return A pointer to the newly-created USB mass storage device path structure.
2276 EFI_DEVICE_PATH_PROTOCOL
*
2277 DevPathFromTextUsbMassStorage (
2278 IN CHAR16
*TextDeviceNode
2281 USB_CLASS_TEXT UsbClassText
;
2283 UsbClassText
.ClassExist
= FALSE
;
2284 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2285 UsbClassText
.SubClassExist
= TRUE
;
2287 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2291 Converts a text device path node to USB HUB device path structure.
2293 @param TextDeviceNode The input Text device path node.
2295 @return A pointer to the newly-created USB HUB device path structure.
2298 EFI_DEVICE_PATH_PROTOCOL
*
2299 DevPathFromTextUsbHub (
2300 IN CHAR16
*TextDeviceNode
2303 USB_CLASS_TEXT UsbClassText
;
2305 UsbClassText
.ClassExist
= FALSE
;
2306 UsbClassText
.Class
= USB_CLASS_HUB
;
2307 UsbClassText
.SubClassExist
= TRUE
;
2309 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2313 Converts a text device path node to USB CDC data device path structure.
2315 @param TextDeviceNode The input Text device path node.
2317 @return A pointer to the newly-created USB CDC data device path structure.
2320 EFI_DEVICE_PATH_PROTOCOL
*
2321 DevPathFromTextUsbCDCData (
2322 IN CHAR16
*TextDeviceNode
2325 USB_CLASS_TEXT UsbClassText
;
2327 UsbClassText
.ClassExist
= FALSE
;
2328 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2329 UsbClassText
.SubClassExist
= TRUE
;
2331 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2335 Converts a text device path node to USB smart card device path structure.
2337 @param TextDeviceNode The input Text device path node.
2339 @return A pointer to the newly-created USB smart card device path structure.
2342 EFI_DEVICE_PATH_PROTOCOL
*
2343 DevPathFromTextUsbSmartCard (
2344 IN CHAR16
*TextDeviceNode
2347 USB_CLASS_TEXT UsbClassText
;
2349 UsbClassText
.ClassExist
= FALSE
;
2350 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2351 UsbClassText
.SubClassExist
= TRUE
;
2353 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2357 Converts a text device path node to USB video device path structure.
2359 @param TextDeviceNode The input Text device path node.
2361 @return A pointer to the newly-created USB video device path structure.
2364 EFI_DEVICE_PATH_PROTOCOL
*
2365 DevPathFromTextUsbVideo (
2366 IN CHAR16
*TextDeviceNode
2369 USB_CLASS_TEXT UsbClassText
;
2371 UsbClassText
.ClassExist
= FALSE
;
2372 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2373 UsbClassText
.SubClassExist
= TRUE
;
2375 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2379 Converts a text device path node to USB diagnostic device path structure.
2381 @param TextDeviceNode The input Text device path node.
2383 @return A pointer to the newly-created USB diagnostic device path structure.
2386 EFI_DEVICE_PATH_PROTOCOL
*
2387 DevPathFromTextUsbDiagnostic (
2388 IN CHAR16
*TextDeviceNode
2391 USB_CLASS_TEXT UsbClassText
;
2393 UsbClassText
.ClassExist
= FALSE
;
2394 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2395 UsbClassText
.SubClassExist
= TRUE
;
2397 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2401 Converts a text device path node to USB wireless device path structure.
2403 @param TextDeviceNode The input Text device path node.
2405 @return A pointer to the newly-created USB wireless device path structure.
2408 EFI_DEVICE_PATH_PROTOCOL
*
2409 DevPathFromTextUsbWireless (
2410 IN CHAR16
*TextDeviceNode
2413 USB_CLASS_TEXT UsbClassText
;
2415 UsbClassText
.ClassExist
= FALSE
;
2416 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2417 UsbClassText
.SubClassExist
= TRUE
;
2419 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2423 Converts a text device path node to USB device firmware update device path structure.
2425 @param TextDeviceNode The input Text device path node.
2427 @return A pointer to the newly-created USB device firmware update device path structure.
2430 EFI_DEVICE_PATH_PROTOCOL
*
2431 DevPathFromTextUsbDeviceFirmwareUpdate (
2432 IN CHAR16
*TextDeviceNode
2435 USB_CLASS_TEXT UsbClassText
;
2437 UsbClassText
.ClassExist
= FALSE
;
2438 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2439 UsbClassText
.SubClassExist
= FALSE
;
2440 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2442 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2446 Converts a text device path node to USB IRDA bridge device path structure.
2448 @param TextDeviceNode The input Text device path node.
2450 @return A pointer to the newly-created USB IRDA bridge device path structure.
2453 EFI_DEVICE_PATH_PROTOCOL
*
2454 DevPathFromTextUsbIrdaBridge (
2455 IN CHAR16
*TextDeviceNode
2458 USB_CLASS_TEXT UsbClassText
;
2460 UsbClassText
.ClassExist
= FALSE
;
2461 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2462 UsbClassText
.SubClassExist
= FALSE
;
2463 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2465 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2469 Converts a text device path node to USB text and measurement device path structure.
2471 @param TextDeviceNode The input Text device path node.
2473 @return A pointer to the newly-created USB text and measurement device path structure.
2476 EFI_DEVICE_PATH_PROTOCOL
*
2477 DevPathFromTextUsbTestAndMeasurement (
2478 IN CHAR16
*TextDeviceNode
2481 USB_CLASS_TEXT UsbClassText
;
2483 UsbClassText
.ClassExist
= FALSE
;
2484 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2485 UsbClassText
.SubClassExist
= FALSE
;
2486 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2488 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2492 Converts a text device path node to USB WWID device path structure.
2494 @param TextDeviceNode The input Text device path node.
2496 @return A pointer to the newly-created USB WWID device path structure.
2499 EFI_DEVICE_PATH_PROTOCOL
*
2500 DevPathFromTextUsbWwid (
2501 IN CHAR16
*TextDeviceNode
2506 CHAR16
*InterfaceNumStr
;
2507 CHAR16
*SerialNumberStr
;
2508 USB_WWID_DEVICE_PATH
*UsbWwid
;
2510 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2511 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2512 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2513 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2514 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2515 MESSAGING_DEVICE_PATH
,
2517 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + StrSize (SerialNumberStr
))
2520 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2521 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2522 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2523 StrCpy ((CHAR16
*) ((UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
)), SerialNumberStr
);
2525 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2529 Converts a text device path node to Logic Unit device path structure.
2531 @param TextDeviceNode The input Text device path node.
2533 @return A pointer to the newly-created Logic Unit device path structure.
2536 EFI_DEVICE_PATH_PROTOCOL
*
2537 DevPathFromTextUnit (
2538 IN CHAR16
*TextDeviceNode
2542 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2544 LunStr
= GetNextParamStr (&TextDeviceNode
);
2545 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2546 MESSAGING_DEVICE_PATH
,
2547 MSG_DEVICE_LOGICAL_UNIT_DP
,
2548 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2551 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2553 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2557 Converts a text device path node to iSCSI device path structure.
2559 @param TextDeviceNode The input Text device path node.
2561 @return A pointer to the newly-created iSCSI device path structure.
2564 EFI_DEVICE_PATH_PROTOCOL
*
2565 DevPathFromTextiSCSI (
2566 IN CHAR16
*TextDeviceNode
2571 CHAR16
*PortalGroupStr
;
2573 CHAR16
*HeaderDigestStr
;
2574 CHAR16
*DataDigestStr
;
2575 CHAR16
*AuthenticationStr
;
2576 CHAR16
*ProtocolStr
;
2578 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2580 NameStr
= GetNextParamStr (&TextDeviceNode
);
2581 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2582 LunStr
= GetNextParamStr (&TextDeviceNode
);
2583 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2584 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2585 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2586 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2587 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2588 MESSAGING_DEVICE_PATH
,
2590 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2593 AsciiStr
= ISCSIDevPath
->TargetName
;
2594 StrToAscii (NameStr
, &AsciiStr
);
2596 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2597 Strtoi64 (LunStr
, &ISCSIDevPath
->Lun
);
2600 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2604 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2608 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2612 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2616 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2618 ISCSIDevPath
->NetworkProtocol
= (UINT16
) StrCmp (ProtocolStr
, L
"TCP");
2620 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2624 Converts a text device path node to VLAN device path structure.
2626 @param TextDeviceNode The input Text device path node.
2628 @return A pointer to the newly-created VLAN device path structure.
2631 EFI_DEVICE_PATH_PROTOCOL
*
2632 DevPathFromTextVlan (
2633 IN CHAR16
*TextDeviceNode
2637 VLAN_DEVICE_PATH
*Vlan
;
2639 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2640 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2641 MESSAGING_DEVICE_PATH
,
2643 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2646 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2648 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2652 Converts a text device path node to HD device path structure.
2654 @param TextDeviceNode The input Text device path node.
2656 @return A pointer to the newly-created HD device path structure.
2659 EFI_DEVICE_PATH_PROTOCOL
*
2661 IN CHAR16
*TextDeviceNode
2664 CHAR16
*PartitionStr
;
2666 CHAR16
*SignatureStr
;
2670 EFI_GUID SignatureGuid
;
2671 HARDDRIVE_DEVICE_PATH
*Hd
;
2673 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2674 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2675 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2676 StartStr
= GetNextParamStr (&TextDeviceNode
);
2677 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2678 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2681 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2684 Hd
->PartitionNumber
= (UINT32
) Dtoi (PartitionStr
);
2686 ZeroMem (Hd
->Signature
, 16);
2687 Hd
->MBRType
= (UINT8
) 0;
2689 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2690 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2693 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2694 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2695 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2696 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2699 StrToGuid (SignatureStr
, &SignatureGuid
);
2700 CopyMem (Hd
->Signature
, &SignatureGuid
, sizeof (EFI_GUID
));
2702 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2705 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2706 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2708 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2712 Converts a text device path node to CDROM device path structure.
2714 @param TextDeviceNode The input Text device path node.
2716 @return A pointer to the newly-created CDROM device path structure.
2719 EFI_DEVICE_PATH_PROTOCOL
*
2720 DevPathFromTextCDROM (
2721 IN CHAR16
*TextDeviceNode
2727 CDROM_DEVICE_PATH
*CDROMDevPath
;
2729 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2730 StartStr
= GetNextParamStr (&TextDeviceNode
);
2731 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2732 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2735 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2738 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2739 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2740 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2742 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2746 Converts a text device path node to Vendor-defined media device path structure.
2748 @param TextDeviceNode The input Text device path node.
2750 @return A pointer to the newly-created Vendor-defined media device path structure.
2753 EFI_DEVICE_PATH_PROTOCOL
*
2754 DevPathFromTextVenMEDIA (
2755 IN CHAR16
*TextDeviceNode
2758 return ConvertFromTextVendor (
2766 Converts a text device path node to File device path structure.
2768 @param TextDeviceNode The input Text device path node.
2770 @return A pointer to the newly-created File device path structure.
2773 EFI_DEVICE_PATH_PROTOCOL
*
2774 DevPathFromTextFilePath (
2775 IN CHAR16
*TextDeviceNode
2778 FILEPATH_DEVICE_PATH
*File
;
2780 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2783 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
2786 StrCpy (File
->PathName
, TextDeviceNode
);
2788 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
2792 Converts a text device path node to Media protocol device path structure.
2794 @param TextDeviceNode The input Text device path node.
2796 @return A pointer to the newly-created Media protocol device path structure.
2799 EFI_DEVICE_PATH_PROTOCOL
*
2800 DevPathFromTextMedia (
2801 IN CHAR16
*TextDeviceNode
2805 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
2807 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2808 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
2811 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
2814 StrToGuid (GuidStr
, &Media
->Protocol
);
2816 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
2820 Converts a text device path node to firmware volume device path structure.
2822 @param TextDeviceNode The input Text device path node.
2824 @return A pointer to the newly-created firmware volume device path structure.
2827 EFI_DEVICE_PATH_PROTOCOL
*
2829 IN CHAR16
*TextDeviceNode
2833 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
2835 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2836 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
2838 MEDIA_PIWG_FW_VOL_DP
,
2839 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
2842 StrToGuid (GuidStr
, &Fv
->FvName
);
2844 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
2848 Converts a text device path node to firmware file device path structure.
2850 @param TextDeviceNode The input Text device path node.
2852 @return A pointer to the newly-created firmware file device path structure.
2855 EFI_DEVICE_PATH_PROTOCOL
*
2856 DevPathFromTextFvFile (
2857 IN CHAR16
*TextDeviceNode
2861 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
2863 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2864 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2866 MEDIA_PIWG_FW_FILE_DP
,
2867 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
2870 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
2872 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
2876 Converts a text device path node to text relative offset device path structure.
2878 @param TextDeviceNode The input Text device path node.
2880 @return A pointer to the newly-created Text device path structure.
2883 EFI_DEVICE_PATH_PROTOCOL
*
2884 DevPathFromTextRelativeOffsetRange (
2885 IN CHAR16
*TextDeviceNode
2888 CHAR16
*StartingOffsetStr
;
2889 CHAR16
*EndingOffsetStr
;
2890 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
2892 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2893 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2894 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
2896 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
2897 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
2900 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
2901 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
2903 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
2907 Converts a text device path node to BIOS Boot Specification device path structure.
2909 @param TextDeviceNode The input Text device path node.
2911 @return A pointer to the newly-created BIOS Boot Specification device path structure.
2914 EFI_DEVICE_PATH_PROTOCOL
*
2915 DevPathFromTextBBS (
2916 IN CHAR16
*TextDeviceNode
2923 BBS_BBS_DEVICE_PATH
*Bbs
;
2925 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2926 IdStr
= GetNextParamStr (&TextDeviceNode
);
2927 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
2928 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
2931 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
2934 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
2935 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
2936 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
2937 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
2938 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
2939 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
2940 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
2941 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
2942 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
2943 Bbs
->DeviceType
= BBS_TYPE_USB
;
2944 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
2945 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
2947 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
2950 AsciiStr
= Bbs
->String
;
2951 StrToAscii (IdStr
, &AsciiStr
);
2953 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
2955 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
2959 Converts a text device path node to SATA device path structure.
2961 @param TextDeviceNode The input Text device path node.
2963 @return A pointer to the newly-created SATA device path structure.
2966 EFI_DEVICE_PATH_PROTOCOL
*
2967 DevPathFromTextSata (
2968 IN CHAR16
*TextDeviceNode
2971 SATA_DEVICE_PATH
*Sata
;
2977 // The PMPN is optional.
2979 Param1
= GetNextParamStr (&TextDeviceNode
);
2980 Param2
= GetNextParamStr (&TextDeviceNode
);
2982 if (!IS_NULL (TextDeviceNode
)) {
2983 Param3
= GetNextParamStr (&TextDeviceNode
);
2986 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
2987 MESSAGING_DEVICE_PATH
,
2989 (UINT16
) sizeof (SATA_DEVICE_PATH
)
2991 Sata
->HBAPortNumber
= (UINT16
) Xtoi (Param1
);
2992 if (Param3
!= NULL
) {
2993 Sata
->PortMultiplierPortNumber
= (UINT16
) Xtoi (Param2
);
2996 Sata
->PortMultiplierPortNumber
= SATA_HBA_DIRECT_CONNECT_FLAG
;
2998 Sata
->Lun
= (UINT16
) Xtoi (Param2
);
3000 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
3003 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable
[] = {
3004 {L
"Pci", DevPathFromTextPci
},
3005 {L
"PcCard", DevPathFromTextPcCard
},
3006 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
3007 {L
"VenHw", DevPathFromTextVenHw
},
3008 {L
"Ctrl", DevPathFromTextCtrl
},
3009 {L
"Acpi", DevPathFromTextAcpi
},
3010 {L
"PciRoot", DevPathFromTextPciRoot
},
3011 {L
"PcieRoot", DevPathFromTextPcieRoot
},
3012 {L
"Floppy", DevPathFromTextFloppy
},
3013 {L
"Keyboard", DevPathFromTextKeyboard
},
3014 {L
"Serial", DevPathFromTextSerial
},
3015 {L
"ParallelPort", DevPathFromTextParallelPort
},
3016 {L
"AcpiEx", DevPathFromTextAcpiEx
},
3017 {L
"AcpiExp", DevPathFromTextAcpiExp
},
3018 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
3019 {L
"Ata", DevPathFromTextAta
},
3020 {L
"Scsi", DevPathFromTextScsi
},
3021 {L
"Fibre", DevPathFromTextFibre
},
3022 {L
"FibreEx", DevPathFromTextFibreEx
},
3023 {L
"I1394", DevPathFromText1394
},
3024 {L
"USB", DevPathFromTextUsb
},
3025 {L
"I2O", DevPathFromTextI2O
},
3026 {L
"Infiniband", DevPathFromTextInfiniband
},
3027 {L
"VenMsg", DevPathFromTextVenMsg
},
3028 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
3029 {L
"VenVt100", DevPathFromTextVenVt100
},
3030 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
3031 {L
"VenUtf8", DevPathFromTextVenUtf8
},
3032 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
3033 {L
"SAS", DevPathFromTextSAS
},
3034 {L
"SasEx", DevPathFromTextSasEx
},
3035 {L
"DebugPort", DevPathFromTextDebugPort
},
3036 {L
"MAC", DevPathFromTextMAC
},
3037 {L
"IPv4", DevPathFromTextIPv4
},
3038 {L
"IPv6", DevPathFromTextIPv6
},
3039 {L
"Uart", DevPathFromTextUart
},
3040 {L
"UsbClass", DevPathFromTextUsbClass
},
3041 {L
"UsbAudio", DevPathFromTextUsbAudio
},
3042 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
3043 {L
"UsbHID", DevPathFromTextUsbHID
},
3044 {L
"UsbImage", DevPathFromTextUsbImage
},
3045 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
3046 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
3047 {L
"UsbHub", DevPathFromTextUsbHub
},
3048 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
3049 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
3050 {L
"UsbVideo", DevPathFromTextUsbVideo
},
3051 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
3052 {L
"UsbWireless", DevPathFromTextUsbWireless
},
3053 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
3054 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
3055 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
3056 {L
"UsbWwid", DevPathFromTextUsbWwid
},
3057 {L
"Unit", DevPathFromTextUnit
},
3058 {L
"iSCSI", DevPathFromTextiSCSI
},
3059 {L
"Vlan", DevPathFromTextVlan
},
3060 {L
"HD", DevPathFromTextHD
},
3061 {L
"CDROM", DevPathFromTextCDROM
},
3062 {L
"VenMEDIA", DevPathFromTextVenMEDIA
},
3063 {L
"Media", DevPathFromTextMedia
},
3064 {L
"Fv", DevPathFromTextFv
},
3065 {L
"FvFile", DevPathFromTextFvFile
},
3066 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
3067 {L
"BBS", DevPathFromTextBBS
},
3068 {L
"Sata", DevPathFromTextSata
},
3073 Convert text to the binary representation of a device node.
3075 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3076 node. Conversion starts with the first character and continues
3077 until the first non-device node character.
3079 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3080 insufficient memory or text unsupported.
3083 EFI_DEVICE_PATH_PROTOCOL
*
3085 ConvertTextToDeviceNode (
3086 IN CONST CHAR16
*TextDeviceNode
3091 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3092 CHAR16
*DeviceNodeStr
;
3095 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
3101 DeviceNodeStr
= StrDuplicate (TextDeviceNode
);
3102 ASSERT (DeviceNodeStr
!= NULL
);
3104 for (Index
= 0; DevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3105 ParamStr
= GetParamByNodeName (DeviceNodeStr
, DevPathFromTextTable
[Index
].DevicePathNodeText
);
3106 if (ParamStr
!= NULL
) {
3107 DumpNode
= DevPathFromTextTable
[Index
].Function
;
3112 if (DumpNode
== NULL
) {
3116 DumpNode
= DevPathFromTextFilePath
;
3117 DeviceNode
= DumpNode (DeviceNodeStr
);
3119 DeviceNode
= DumpNode (ParamStr
);
3120 FreePool (ParamStr
);
3123 FreePool (DeviceNodeStr
);
3129 Convert text to the binary representation of a device path.
3132 @param TextDevicePath TextDevicePath points to the text representation of a device
3133 path. Conversion starts with the first character and continues
3134 until the first non-device node character.
3136 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3137 there was insufficient memory.
3140 EFI_DEVICE_PATH_PROTOCOL
*
3142 ConvertTextToDevicePath (
3143 IN CONST CHAR16
*TextDevicePath
3148 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3150 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3151 CHAR16
*DevicePathStr
;
3153 CHAR16
*DeviceNodeStr
;
3154 UINT8 IsInstanceEnd
;
3155 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3157 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3161 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3162 ASSERT (DevicePath
!= NULL
);
3163 SetDevicePathEndNode (DevicePath
);
3166 DeviceNodeStr
= NULL
;
3167 DevicePathStr
= StrDuplicate (TextDevicePath
);
3169 Str
= DevicePathStr
;
3170 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3172 for (Index
= 0; DevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3173 ParamStr
= GetParamByNodeName (DeviceNodeStr
, DevPathFromTextTable
[Index
].DevicePathNodeText
);
3174 if (ParamStr
!= NULL
) {
3175 DumpNode
= DevPathFromTextTable
[Index
].Function
;
3180 if (DumpNode
== NULL
) {
3184 DumpNode
= DevPathFromTextFilePath
;
3185 DeviceNode
= DumpNode (DeviceNodeStr
);
3187 DeviceNode
= DumpNode (ParamStr
);
3188 FreePool (ParamStr
);
3191 NewDevicePath
= AppendDeviceNodeProtocolInterface (DevicePath
, DeviceNode
);
3192 FreePool (DevicePath
);
3193 FreePool (DeviceNode
);
3194 DevicePath
= NewDevicePath
;
3196 if (IsInstanceEnd
!= 0) {
3197 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3198 ASSERT (DeviceNode
!= NULL
);
3199 SET_DEVICE_PATH_INSTANCE_END_NODE (DeviceNode
);
3201 NewDevicePath
= AppendDeviceNodeProtocolInterface (DevicePath
, DeviceNode
);
3202 FreePool (DevicePath
);
3203 FreePool (DeviceNode
);
3204 DevicePath
= NewDevicePath
;
3208 FreePool (DevicePathStr
);