2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
4 Copyright (c) 2006 - 2010, 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 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 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 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 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 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 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 Parallel Port device path structure.
1143 @param TextDeviceNode The input Text device path node.
1145 @return A pointer to the newly-created Parallel Port device path structure.
1148 EFI_DEVICE_PATH_PROTOCOL
*
1149 DevPathFromTextAta (
1150 IN CHAR16
*TextDeviceNode
1153 CHAR16
*PrimarySecondaryStr
;
1154 CHAR16
*SlaveMasterStr
;
1156 ATAPI_DEVICE_PATH
*Atapi
;
1158 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
1159 MESSAGING_DEVICE_PATH
,
1161 sizeof (ATAPI_DEVICE_PATH
)
1164 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
1165 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
1166 LunStr
= GetNextParamStr (&TextDeviceNode
);
1168 Atapi
->PrimarySecondary
= (UINT8
) ((StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) ? 0 : 1);
1169 Atapi
->SlaveMaster
= (UINT8
) ((StrCmp (SlaveMasterStr
, L
"Master") == 0) ? 0 : 1);
1170 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
1172 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
1176 Converts a text device path node to SCSI device path structure.
1178 @param TextDeviceNode The input Text device path node.
1180 @return A pointer to the newly-created SCSI device path structure.
1183 EFI_DEVICE_PATH_PROTOCOL
*
1184 DevPathFromTextScsi (
1185 IN CHAR16
*TextDeviceNode
1190 SCSI_DEVICE_PATH
*Scsi
;
1192 PunStr
= GetNextParamStr (&TextDeviceNode
);
1193 LunStr
= GetNextParamStr (&TextDeviceNode
);
1194 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
1195 MESSAGING_DEVICE_PATH
,
1197 sizeof (SCSI_DEVICE_PATH
)
1200 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
1201 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
1203 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
1207 Converts a text device path node to Fibre device path structure.
1209 @param TextDeviceNode The input Text device path node.
1211 @return A pointer to the newly-created Fibre device path structure.
1214 EFI_DEVICE_PATH_PROTOCOL
*
1215 DevPathFromTextFibre (
1216 IN CHAR16
*TextDeviceNode
1221 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
1223 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1224 LunStr
= GetNextParamStr (&TextDeviceNode
);
1225 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
1226 MESSAGING_DEVICE_PATH
,
1227 MSG_FIBRECHANNEL_DP
,
1228 sizeof (FIBRECHANNEL_DEVICE_PATH
)
1231 Fibre
->Reserved
= 0;
1232 Strtoi64 (WWNStr
, &Fibre
->WWN
);
1233 Strtoi64 (LunStr
, &Fibre
->Lun
);
1235 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
1239 Converts a text device path node to 1394 device path structure.
1241 @param TextDeviceNode The input Text device path node.
1243 @return A pointer to the newly-created 1394 device path structure.
1246 EFI_DEVICE_PATH_PROTOCOL
*
1247 DevPathFromText1394 (
1248 IN CHAR16
*TextDeviceNode
1252 F1394_DEVICE_PATH
*F1394DevPath
;
1254 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1255 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1256 MESSAGING_DEVICE_PATH
,
1258 sizeof (F1394_DEVICE_PATH
)
1261 F1394DevPath
->Reserved
= 0;
1262 Xtoi64 (GuidStr
, &F1394DevPath
->Guid
);
1264 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1268 Converts a text device path node to USB device path structure.
1270 @param TextDeviceNode The input Text device path node.
1272 @return A pointer to the newly-created USB device path structure.
1275 EFI_DEVICE_PATH_PROTOCOL
*
1276 DevPathFromTextUsb (
1277 IN CHAR16
*TextDeviceNode
1281 CHAR16
*InterfaceStr
;
1282 USB_DEVICE_PATH
*Usb
;
1284 PortStr
= GetNextParamStr (&TextDeviceNode
);
1285 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1286 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1287 MESSAGING_DEVICE_PATH
,
1289 sizeof (USB_DEVICE_PATH
)
1292 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1293 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1295 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1299 Converts a text device path node to I20 device path structure.
1301 @param TextDeviceNode The input Text device path node.
1303 @return A pointer to the newly-created I20 device path structure.
1306 EFI_DEVICE_PATH_PROTOCOL
*
1307 DevPathFromTextI2O (
1308 IN CHAR16
*TextDeviceNode
1312 I2O_DEVICE_PATH
*I2ODevPath
;
1314 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1315 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1316 MESSAGING_DEVICE_PATH
,
1318 sizeof (I2O_DEVICE_PATH
)
1321 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1323 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1327 Converts a text device path node to Infini Band device path structure.
1329 @param TextDeviceNode The input Text device path node.
1331 @return A pointer to the newly-created Infini Band device path structure.
1334 EFI_DEVICE_PATH_PROTOCOL
*
1335 DevPathFromTextInfiniband (
1336 IN CHAR16
*TextDeviceNode
1345 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1347 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1348 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1349 SidStr
= GetNextParamStr (&TextDeviceNode
);
1350 TidStr
= GetNextParamStr (&TextDeviceNode
);
1351 DidStr
= GetNextParamStr (&TextDeviceNode
);
1352 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1353 MESSAGING_DEVICE_PATH
,
1355 sizeof (INFINIBAND_DEVICE_PATH
)
1358 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1359 StrToGuid (GuidStr
, &PortGid
);
1360 CopyMem (InfiniBand
->PortGid
, &PortGid
, sizeof (EFI_GUID
));
1361 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1362 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1363 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1365 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1369 Converts a text device path node to Vendor-Defined Messaging device path structure.
1371 @param TextDeviceNode The input Text device path node.
1373 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1376 EFI_DEVICE_PATH_PROTOCOL
*
1377 DevPathFromTextVenMsg (
1378 IN CHAR16
*TextDeviceNode
1381 return ConvertFromTextVendor (
1383 MESSAGING_DEVICE_PATH
,
1389 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1391 @param TextDeviceNode The input Text device path node.
1393 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1396 EFI_DEVICE_PATH_PROTOCOL
*
1397 DevPathFromTextVenPcAnsi (
1398 IN CHAR16
*TextDeviceNode
1401 VENDOR_DEVICE_PATH
*Vendor
;
1403 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1404 MESSAGING_DEVICE_PATH
,
1406 sizeof (VENDOR_DEVICE_PATH
));
1407 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1409 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1413 Converts a text device path node to Vendor defined VT100 device path structure.
1415 @param TextDeviceNode The input Text device path node.
1417 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1420 EFI_DEVICE_PATH_PROTOCOL
*
1421 DevPathFromTextVenVt100 (
1422 IN CHAR16
*TextDeviceNode
1425 VENDOR_DEVICE_PATH
*Vendor
;
1427 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1428 MESSAGING_DEVICE_PATH
,
1430 sizeof (VENDOR_DEVICE_PATH
));
1431 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1433 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1437 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1439 @param TextDeviceNode The input Text device path node.
1441 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1444 EFI_DEVICE_PATH_PROTOCOL
*
1445 DevPathFromTextVenVt100Plus (
1446 IN CHAR16
*TextDeviceNode
1449 VENDOR_DEVICE_PATH
*Vendor
;
1451 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1452 MESSAGING_DEVICE_PATH
,
1454 sizeof (VENDOR_DEVICE_PATH
));
1455 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1457 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1461 Converts a text device path node to Vendor defined UTF8 device path structure.
1463 @param TextDeviceNode The input Text device path node.
1465 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1468 EFI_DEVICE_PATH_PROTOCOL
*
1469 DevPathFromTextVenUtf8 (
1470 IN CHAR16
*TextDeviceNode
1473 VENDOR_DEVICE_PATH
*Vendor
;
1475 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1476 MESSAGING_DEVICE_PATH
,
1478 sizeof (VENDOR_DEVICE_PATH
));
1479 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1481 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1485 Converts a text device path node to UART Flow Control device path structure.
1487 @param TextDeviceNode The input Text device path node.
1489 @return A pointer to the newly-created UART Flow Control device path structure.
1492 EFI_DEVICE_PATH_PROTOCOL
*
1493 DevPathFromTextUartFlowCtrl (
1494 IN CHAR16
*TextDeviceNode
1498 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1500 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1501 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1502 MESSAGING_DEVICE_PATH
,
1504 sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1507 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1508 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1509 UartFlowControl
->FlowControlMap
= 2;
1510 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1511 UartFlowControl
->FlowControlMap
= 1;
1513 UartFlowControl
->FlowControlMap
= 0;
1516 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1520 Converts a text device path node to Serial Attached SCSI device path structure.
1522 @param TextDeviceNode The input Text device path node.
1524 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1527 EFI_DEVICE_PATH_PROTOCOL
*
1528 DevPathFromTextSAS (
1529 IN CHAR16
*TextDeviceNode
1536 CHAR16
*LocationStr
;
1538 CHAR16
*DriveBayStr
;
1539 CHAR16
*ReservedStr
;
1541 SAS_DEVICE_PATH
*Sas
;
1543 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1544 LunStr
= GetNextParamStr (&TextDeviceNode
);
1545 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1546 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1547 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1548 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1549 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1550 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1552 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1553 MESSAGING_DEVICE_PATH
,
1555 sizeof (SAS_DEVICE_PATH
)
1558 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1559 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1560 Strtoi64 (LunStr
, &Sas
->Lun
);
1561 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1562 if (StrCmp (SASSATAStr
, L
"NoTopology") != 0) {
1563 if (StrCmp (DriveBayStr
, L
"0") == 0) {
1567 Info
= (UINT16
) (Info
| (Strtoi (DriveBayStr
) << 8));
1570 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1574 if (StrCmp (LocationStr
, L
"External") == 0) {
1578 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1583 Sas
->DeviceTopology
= Info
;
1584 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1586 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1590 Converts a text device path node to Debug Port device path structure.
1592 @param TextDeviceNode The input Text device path node.
1594 @return A pointer to the newly-created Debug Port device path structure.
1597 EFI_DEVICE_PATH_PROTOCOL
*
1598 DevPathFromTextDebugPort (
1599 IN CHAR16
*TextDeviceNode
1602 VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*Vend
;
1604 Vend
= (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*) CreateDeviceNode (
1605 MESSAGING_DEVICE_PATH
,
1607 sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
)
1610 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1612 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1616 Converts a text device path node to MAC device path structure.
1618 @param TextDeviceNode The input Text device path node.
1620 @return A pointer to the newly-created MAC device path structure.
1623 EFI_DEVICE_PATH_PROTOCOL
*
1624 DevPathFromTextMAC (
1625 IN CHAR16
*TextDeviceNode
1631 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1633 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1634 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1635 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1636 MESSAGING_DEVICE_PATH
,
1638 sizeof (MAC_ADDR_DEVICE_PATH
)
1641 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1643 Length
= sizeof (EFI_MAC_ADDRESS
);
1644 StrToBuf (&MACDevPath
->MacAddress
.Addr
[0], Length
, AddressStr
);
1646 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1651 Converts a text format to the network protocol ID.
1653 @param Text String of protocol field.
1655 @return Network protocol ID .
1659 NetworkProtocolFromText (
1663 if (StrCmp (Text
, L
"UDP") == 0) {
1664 return RFC_1700_UDP_PROTOCOL
;
1667 if (StrCmp (Text
, L
"TCP") == 0) {
1668 return RFC_1700_TCP_PROTOCOL
;
1671 return Strtoi (Text
);
1676 Converts a text device path node to IPV4 device path structure.
1678 @param TextDeviceNode The input Text device path node.
1680 @return A pointer to the newly-created IPV4 device path structure.
1683 EFI_DEVICE_PATH_PROTOCOL
*
1684 DevPathFromTextIPv4 (
1685 IN CHAR16
*TextDeviceNode
1688 CHAR16
*RemoteIPStr
;
1689 CHAR16
*ProtocolStr
;
1692 IPv4_DEVICE_PATH
*IPv4
;
1694 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1695 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1696 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1697 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1698 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1699 MESSAGING_DEVICE_PATH
,
1701 sizeof (IPv4_DEVICE_PATH
)
1704 StrToIPv4Addr (&RemoteIPStr
, &IPv4
->RemoteIpAddress
);
1705 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1706 if (StrCmp (TypeStr
, L
"Static") == 0) {
1707 IPv4
->StaticIpAddress
= TRUE
;
1709 IPv4
->StaticIpAddress
= FALSE
;
1712 StrToIPv4Addr (&LocalIPStr
, &IPv4
->LocalIpAddress
);
1714 IPv4
->LocalPort
= 0;
1715 IPv4
->RemotePort
= 0;
1717 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1721 Converts a text device path node to IPV6 device path structure.
1723 @param TextDeviceNode The input Text device path node.
1725 @return A pointer to the newly-created IPV6 device path structure.
1728 EFI_DEVICE_PATH_PROTOCOL
*
1729 DevPathFromTextIPv6 (
1730 IN CHAR16
*TextDeviceNode
1733 CHAR16
*RemoteIPStr
;
1734 CHAR16
*ProtocolStr
;
1737 IPv6_DEVICE_PATH
*IPv6
;
1739 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1740 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1741 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1742 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1743 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1744 MESSAGING_DEVICE_PATH
,
1746 sizeof (IPv6_DEVICE_PATH
)
1749 StrToIPv6Addr (&RemoteIPStr
, &IPv6
->RemoteIpAddress
);
1750 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1751 if (StrCmp (TypeStr
, L
"Static") == 0) {
1752 IPv6
->StaticIpAddress
= TRUE
;
1754 IPv6
->StaticIpAddress
= FALSE
;
1757 StrToIPv6Addr (&LocalIPStr
, &IPv6
->LocalIpAddress
);
1759 IPv6
->LocalPort
= 0;
1760 IPv6
->RemotePort
= 0;
1762 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
1766 Converts a text device path node to UART device path structure.
1768 @param TextDeviceNode The input Text device path node.
1770 @return A pointer to the newly-created UART device path structure.
1773 EFI_DEVICE_PATH_PROTOCOL
*
1774 DevPathFromTextUart (
1775 IN CHAR16
*TextDeviceNode
1779 CHAR16
*DataBitsStr
;
1781 CHAR16
*StopBitsStr
;
1782 UART_DEVICE_PATH
*Uart
;
1784 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1785 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1786 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1787 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1788 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
1789 MESSAGING_DEVICE_PATH
,
1791 sizeof (UART_DEVICE_PATH
)
1794 Uart
->BaudRate
= (StrCmp (BaudStr
, L
"DEFAULT") == 0) ? 115200 : Dtoi (BaudStr
);
1795 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Dtoi (DataBitsStr
));
1796 switch (*ParityStr
) {
1821 Uart
->Parity
= 0xff;
1824 if (StrCmp (StopBitsStr
, L
"D") == 0) {
1825 Uart
->StopBits
= (UINT8
) 0;
1826 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
1827 Uart
->StopBits
= (UINT8
) 1;
1828 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
1829 Uart
->StopBits
= (UINT8
) 2;
1830 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
1831 Uart
->StopBits
= (UINT8
) 3;
1833 Uart
->StopBits
= 0xff;
1836 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
1840 Converts a text device path node to USB class device path structure.
1842 @param TextDeviceNode The input Text device path node.
1843 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
1845 @return A pointer to the newly-created USB class device path structure.
1848 EFI_DEVICE_PATH_PROTOCOL
*
1849 ConvertFromTextUsbClass (
1850 IN CHAR16
*TextDeviceNode
,
1851 IN USB_CLASS_TEXT
*UsbClassText
1857 CHAR16
*SubClassStr
;
1858 CHAR16
*ProtocolStr
;
1859 USB_CLASS_DEVICE_PATH
*UsbClass
;
1861 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
1862 MESSAGING_DEVICE_PATH
,
1864 sizeof (USB_CLASS_DEVICE_PATH
)
1867 VIDStr
= GetNextParamStr (&TextDeviceNode
);
1868 PIDStr
= GetNextParamStr (&TextDeviceNode
);
1869 if (UsbClassText
->ClassExist
) {
1870 ClassStr
= GetNextParamStr (&TextDeviceNode
);
1871 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
1873 UsbClass
->DeviceClass
= UsbClassText
->Class
;
1875 if (UsbClassText
->SubClassExist
) {
1876 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
1877 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
1879 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
1882 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1884 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
1885 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
1886 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
1888 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
1893 Converts a text device path node to USB class device path structure.
1895 @param TextDeviceNode The input Text device path node.
1897 @return A pointer to the newly-created USB class device path structure.
1900 EFI_DEVICE_PATH_PROTOCOL
*
1901 DevPathFromTextUsbClass (
1902 IN CHAR16
*TextDeviceNode
1905 USB_CLASS_TEXT UsbClassText
;
1907 UsbClassText
.ClassExist
= TRUE
;
1908 UsbClassText
.SubClassExist
= TRUE
;
1910 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1914 Converts a text device path node to USB audio device path structure.
1916 @param TextDeviceNode The input Text device path node.
1918 @return A pointer to the newly-created USB audio device path structure.
1921 EFI_DEVICE_PATH_PROTOCOL
*
1922 DevPathFromTextUsbAudio (
1923 IN CHAR16
*TextDeviceNode
1926 USB_CLASS_TEXT UsbClassText
;
1928 UsbClassText
.ClassExist
= FALSE
;
1929 UsbClassText
.Class
= USB_CLASS_AUDIO
;
1930 UsbClassText
.SubClassExist
= TRUE
;
1932 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1936 Converts a text device path node to USB CDC Control device path structure.
1938 @param TextDeviceNode The input Text device path node.
1940 @return A pointer to the newly-created USB CDC Control device path structure.
1943 EFI_DEVICE_PATH_PROTOCOL
*
1944 DevPathFromTextUsbCDCControl (
1945 IN CHAR16
*TextDeviceNode
1948 USB_CLASS_TEXT UsbClassText
;
1950 UsbClassText
.ClassExist
= FALSE
;
1951 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
1952 UsbClassText
.SubClassExist
= TRUE
;
1954 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1958 Converts a text device path node to USB HID device path structure.
1960 @param TextDeviceNode The input Text device path node.
1962 @return A pointer to the newly-created USB HID device path structure.
1965 EFI_DEVICE_PATH_PROTOCOL
*
1966 DevPathFromTextUsbHID (
1967 IN CHAR16
*TextDeviceNode
1970 USB_CLASS_TEXT UsbClassText
;
1972 UsbClassText
.ClassExist
= FALSE
;
1973 UsbClassText
.Class
= USB_CLASS_HID
;
1974 UsbClassText
.SubClassExist
= TRUE
;
1976 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1980 Converts a text device path node to USB Image device path structure.
1982 @param TextDeviceNode The input Text device path node.
1984 @return A pointer to the newly-created USB Image device path structure.
1987 EFI_DEVICE_PATH_PROTOCOL
*
1988 DevPathFromTextUsbImage (
1989 IN CHAR16
*TextDeviceNode
1992 USB_CLASS_TEXT UsbClassText
;
1994 UsbClassText
.ClassExist
= FALSE
;
1995 UsbClassText
.Class
= USB_CLASS_IMAGE
;
1996 UsbClassText
.SubClassExist
= TRUE
;
1998 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2002 Converts a text device path node to USB Print device path structure.
2004 @param TextDeviceNode The input Text device path node.
2006 @return A pointer to the newly-created USB Print device path structure.
2009 EFI_DEVICE_PATH_PROTOCOL
*
2010 DevPathFromTextUsbPrinter (
2011 IN CHAR16
*TextDeviceNode
2014 USB_CLASS_TEXT UsbClassText
;
2016 UsbClassText
.ClassExist
= FALSE
;
2017 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2018 UsbClassText
.SubClassExist
= TRUE
;
2020 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2024 Converts a text device path node to USB mass storage device path structure.
2026 @param TextDeviceNode The input Text device path node.
2028 @return A pointer to the newly-created USB mass storage device path structure.
2031 EFI_DEVICE_PATH_PROTOCOL
*
2032 DevPathFromTextUsbMassStorage (
2033 IN CHAR16
*TextDeviceNode
2036 USB_CLASS_TEXT UsbClassText
;
2038 UsbClassText
.ClassExist
= FALSE
;
2039 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2040 UsbClassText
.SubClassExist
= TRUE
;
2042 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2046 Converts a text device path node to USB HUB device path structure.
2048 @param TextDeviceNode The input Text device path node.
2050 @return A pointer to the newly-created USB HUB device path structure.
2053 EFI_DEVICE_PATH_PROTOCOL
*
2054 DevPathFromTextUsbHub (
2055 IN CHAR16
*TextDeviceNode
2058 USB_CLASS_TEXT UsbClassText
;
2060 UsbClassText
.ClassExist
= FALSE
;
2061 UsbClassText
.Class
= USB_CLASS_HUB
;
2062 UsbClassText
.SubClassExist
= TRUE
;
2064 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2068 Converts a text device path node to USB CDC data device path structure.
2070 @param TextDeviceNode The input Text device path node.
2072 @return A pointer to the newly-created USB CDC data device path structure.
2075 EFI_DEVICE_PATH_PROTOCOL
*
2076 DevPathFromTextUsbCDCData (
2077 IN CHAR16
*TextDeviceNode
2080 USB_CLASS_TEXT UsbClassText
;
2082 UsbClassText
.ClassExist
= FALSE
;
2083 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2084 UsbClassText
.SubClassExist
= TRUE
;
2086 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2090 Converts a text device path node to USB smart card device path structure.
2092 @param TextDeviceNode The input Text device path node.
2094 @return A pointer to the newly-created USB smart card device path structure.
2097 EFI_DEVICE_PATH_PROTOCOL
*
2098 DevPathFromTextUsbSmartCard (
2099 IN CHAR16
*TextDeviceNode
2102 USB_CLASS_TEXT UsbClassText
;
2104 UsbClassText
.ClassExist
= FALSE
;
2105 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2106 UsbClassText
.SubClassExist
= TRUE
;
2108 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2112 Converts a text device path node to USB video device path structure.
2114 @param TextDeviceNode The input Text device path node.
2116 @return A pointer to the newly-created USB video device path structure.
2119 EFI_DEVICE_PATH_PROTOCOL
*
2120 DevPathFromTextUsbVideo (
2121 IN CHAR16
*TextDeviceNode
2124 USB_CLASS_TEXT UsbClassText
;
2126 UsbClassText
.ClassExist
= FALSE
;
2127 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2128 UsbClassText
.SubClassExist
= TRUE
;
2130 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2134 Converts a text device path node to USB diagnostic device path structure.
2136 @param TextDeviceNode The input Text device path node.
2138 @return A pointer to the newly-created USB diagnostic device path structure.
2141 EFI_DEVICE_PATH_PROTOCOL
*
2142 DevPathFromTextUsbDiagnostic (
2143 IN CHAR16
*TextDeviceNode
2146 USB_CLASS_TEXT UsbClassText
;
2148 UsbClassText
.ClassExist
= FALSE
;
2149 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2150 UsbClassText
.SubClassExist
= TRUE
;
2152 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2156 Converts a text device path node to USB wireless device path structure.
2158 @param TextDeviceNode The input Text device path node.
2160 @return A pointer to the newly-created USB wireless device path structure.
2163 EFI_DEVICE_PATH_PROTOCOL
*
2164 DevPathFromTextUsbWireless (
2165 IN CHAR16
*TextDeviceNode
2168 USB_CLASS_TEXT UsbClassText
;
2170 UsbClassText
.ClassExist
= FALSE
;
2171 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2172 UsbClassText
.SubClassExist
= TRUE
;
2174 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2178 Converts a text device path node to USB device firmware update device path structure.
2180 @param TextDeviceNode The input Text device path node.
2182 @return A pointer to the newly-created USB device firmware update device path structure.
2185 EFI_DEVICE_PATH_PROTOCOL
*
2186 DevPathFromTextUsbDeviceFirmwareUpdate (
2187 IN CHAR16
*TextDeviceNode
2190 USB_CLASS_TEXT UsbClassText
;
2192 UsbClassText
.ClassExist
= FALSE
;
2193 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2194 UsbClassText
.SubClassExist
= FALSE
;
2195 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2197 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2201 Converts a text device path node to USB IRDA bridge device path structure.
2203 @param TextDeviceNode The input Text device path node.
2205 @return A pointer to the newly-created USB IRDA bridge device path structure.
2208 EFI_DEVICE_PATH_PROTOCOL
*
2209 DevPathFromTextUsbIrdaBridge (
2210 IN CHAR16
*TextDeviceNode
2213 USB_CLASS_TEXT UsbClassText
;
2215 UsbClassText
.ClassExist
= FALSE
;
2216 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2217 UsbClassText
.SubClassExist
= FALSE
;
2218 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2220 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2224 Converts a text device path node to USB text and measurement device path structure.
2226 @param TextDeviceNode The input Text device path node.
2228 @return A pointer to the newly-created USB text and measurement device path structure.
2231 EFI_DEVICE_PATH_PROTOCOL
*
2232 DevPathFromTextUsbTestAndMeasurement (
2233 IN CHAR16
*TextDeviceNode
2236 USB_CLASS_TEXT UsbClassText
;
2238 UsbClassText
.ClassExist
= FALSE
;
2239 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2240 UsbClassText
.SubClassExist
= FALSE
;
2241 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2243 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2247 Converts a text device path node to USB WWID device path structure.
2249 @param TextDeviceNode The input Text device path node.
2251 @return A pointer to the newly-created USB WWID device path structure.
2254 EFI_DEVICE_PATH_PROTOCOL
*
2255 DevPathFromTextUsbWwid (
2256 IN CHAR16
*TextDeviceNode
2261 CHAR16
*InterfaceNumStr
;
2262 CHAR16
*SerialNumberStr
;
2263 USB_WWID_DEVICE_PATH
*UsbWwid
;
2265 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2266 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2267 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2268 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2269 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2270 MESSAGING_DEVICE_PATH
,
2272 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + StrSize (SerialNumberStr
))
2275 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2276 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2277 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2278 StrCpy ((CHAR16
*) ((UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
)), SerialNumberStr
);
2280 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2284 Converts a text device path node to Logic Unit device path structure.
2286 @param TextDeviceNode The input Text device path node.
2288 @return A pointer to the newly-created Logic Unit device path structure.
2291 EFI_DEVICE_PATH_PROTOCOL
*
2292 DevPathFromTextUnit (
2293 IN CHAR16
*TextDeviceNode
2297 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2299 LunStr
= GetNextParamStr (&TextDeviceNode
);
2300 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2301 MESSAGING_DEVICE_PATH
,
2302 MSG_DEVICE_LOGICAL_UNIT_DP
,
2303 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2306 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2308 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2312 Converts a text device path node to iSCSI device path structure.
2314 @param TextDeviceNode The input Text device path node.
2316 @return A pointer to the newly-created iSCSI device path structure.
2319 EFI_DEVICE_PATH_PROTOCOL
*
2320 DevPathFromTextiSCSI (
2321 IN CHAR16
*TextDeviceNode
2326 CHAR16
*PortalGroupStr
;
2328 CHAR16
*HeaderDigestStr
;
2329 CHAR16
*DataDigestStr
;
2330 CHAR16
*AuthenticationStr
;
2331 CHAR16
*ProtocolStr
;
2333 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2335 NameStr
= GetNextParamStr (&TextDeviceNode
);
2336 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2337 LunStr
= GetNextParamStr (&TextDeviceNode
);
2338 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2339 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2340 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2341 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2342 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2343 MESSAGING_DEVICE_PATH
,
2345 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2348 AsciiStr
= ISCSIDevPath
->TargetName
;
2349 StrToAscii (NameStr
, &AsciiStr
);
2351 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2352 Strtoi64 (LunStr
, &ISCSIDevPath
->Lun
);
2355 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2359 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2363 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2367 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2371 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2373 ISCSIDevPath
->NetworkProtocol
= (UINT16
) StrCmp (ProtocolStr
, L
"TCP");
2375 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2379 Converts a text device path node to VLAN device path structure.
2381 @param TextDeviceNode The input Text device path node.
2383 @return A pointer to the newly-created VLAN device path structure.
2386 EFI_DEVICE_PATH_PROTOCOL
*
2387 DevPathFromTextVlan (
2388 IN CHAR16
*TextDeviceNode
2392 VLAN_DEVICE_PATH
*Vlan
;
2394 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2395 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2396 MESSAGING_DEVICE_PATH
,
2398 sizeof (VLAN_DEVICE_PATH
)
2401 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2403 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2407 Converts a text device path node to HD device path structure.
2409 @param TextDeviceNode The input Text device path node.
2411 @return A pointer to the newly-created HD device path structure.
2414 EFI_DEVICE_PATH_PROTOCOL
*
2416 IN CHAR16
*TextDeviceNode
2419 CHAR16
*PartitionStr
;
2421 CHAR16
*SignatureStr
;
2425 EFI_GUID SignatureGuid
;
2426 HARDDRIVE_DEVICE_PATH
*Hd
;
2428 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2429 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2430 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2431 StartStr
= GetNextParamStr (&TextDeviceNode
);
2432 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2433 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2436 sizeof (HARDDRIVE_DEVICE_PATH
)
2439 Hd
->PartitionNumber
= (UINT32
) Dtoi (PartitionStr
);
2441 ZeroMem (Hd
->Signature
, 16);
2442 Hd
->MBRType
= (UINT8
) 0;
2444 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2445 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2448 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2449 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2450 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2451 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2454 StrToGuid (SignatureStr
, &SignatureGuid
);
2455 CopyMem (Hd
->Signature
, &SignatureGuid
, sizeof (EFI_GUID
));
2457 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2460 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2461 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2463 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2467 Converts a text device path node to CDROM device path structure.
2469 @param TextDeviceNode The input Text device path node.
2471 @return A pointer to the newly-created CDROM device path structure.
2474 EFI_DEVICE_PATH_PROTOCOL
*
2475 DevPathFromTextCDROM (
2476 IN CHAR16
*TextDeviceNode
2482 CDROM_DEVICE_PATH
*CDROMDevPath
;
2484 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2485 StartStr
= GetNextParamStr (&TextDeviceNode
);
2486 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2487 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2490 sizeof (CDROM_DEVICE_PATH
)
2493 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2494 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2495 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2497 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2501 Converts a text device path node to Vendor-defined media device path structure.
2503 @param TextDeviceNode The input Text device path node.
2505 @return A pointer to the newly-created Vendor-defined media device path structure.
2508 EFI_DEVICE_PATH_PROTOCOL
*
2509 DevPathFromTextVenMEDIA (
2510 IN CHAR16
*TextDeviceNode
2513 return ConvertFromTextVendor (
2521 Converts a text device path node to File device path structure.
2523 @param TextDeviceNode The input Text device path node.
2525 @return A pointer to the newly-created File device path structure.
2528 EFI_DEVICE_PATH_PROTOCOL
*
2529 DevPathFromTextFilePath (
2530 IN CHAR16
*TextDeviceNode
2533 FILEPATH_DEVICE_PATH
*File
;
2535 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2538 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
2541 StrCpy (File
->PathName
, TextDeviceNode
);
2543 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
2547 Converts a text device path node to Media protocol device path structure.
2549 @param TextDeviceNode The input Text device path node.
2551 @return A pointer to the newly-created Media protocol device path structure.
2554 EFI_DEVICE_PATH_PROTOCOL
*
2555 DevPathFromTextMedia (
2556 IN CHAR16
*TextDeviceNode
2560 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
2562 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2563 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
2566 sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
2569 StrToGuid (GuidStr
, &Media
->Protocol
);
2571 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
2575 Converts a text device path node to firmware volume device path structure.
2577 @param TextDeviceNode The input Text device path node.
2579 @return A pointer to the newly-created firmware volume device path structure.
2582 EFI_DEVICE_PATH_PROTOCOL
*
2584 IN CHAR16
*TextDeviceNode
2588 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
2590 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2591 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
2593 MEDIA_PIWG_FW_VOL_DP
,
2594 sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
2597 StrToGuid (GuidStr
, &Fv
->FvName
);
2599 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
2603 Converts a text device path node to firmware file device path structure.
2605 @param TextDeviceNode The input Text device path node.
2607 @return A pointer to the newly-created firmware file device path structure.
2610 EFI_DEVICE_PATH_PROTOCOL
*
2611 DevPathFromTextFvFile (
2612 IN CHAR16
*TextDeviceNode
2616 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
2618 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2619 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2621 MEDIA_PIWG_FW_FILE_DP
,
2622 sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
2625 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
2627 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
2631 Converts a text device path node to text relative offset device path structure.
2633 @param TextDeviceNode The input Text device path node.
2635 @return A pointer to the newly-created Text device path structure.
2638 EFI_DEVICE_PATH_PROTOCOL
*
2639 DevPathFromTextRelativeOffsetRange (
2640 IN CHAR16
*TextDeviceNode
2643 CHAR16
*StartingOffsetStr
;
2644 CHAR16
*EndingOffsetStr
;
2645 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
2647 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2648 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2649 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
2651 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
2652 sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
2655 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
2656 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
2658 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
2662 Converts a text device path node to BIOS Boot Specification device path structure.
2664 @param TextDeviceNode The input Text device path node.
2666 @return A pointer to the newly-created BIOS Boot Specification device path structure.
2669 EFI_DEVICE_PATH_PROTOCOL
*
2670 DevPathFromTextBBS (
2671 IN CHAR16
*TextDeviceNode
2678 BBS_BBS_DEVICE_PATH
*Bbs
;
2680 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2681 IdStr
= GetNextParamStr (&TextDeviceNode
);
2682 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
2683 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
2686 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
2689 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
2690 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
2691 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
2692 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
2693 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
2694 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
2695 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
2696 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
2697 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
2698 Bbs
->DeviceType
= BBS_TYPE_USB
;
2699 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
2700 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
2702 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
2705 AsciiStr
= Bbs
->String
;
2706 StrToAscii (IdStr
, &AsciiStr
);
2708 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
2710 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
2714 Converts a text device path node to SATA device path structure.
2716 @param TextDeviceNode The input Text device path node.
2718 @return A pointer to the newly-created SATA device path structure.
2721 EFI_DEVICE_PATH_PROTOCOL
*
2722 DevPathFromTextSata (
2723 IN CHAR16
*TextDeviceNode
2726 SATA_DEVICE_PATH
*Sata
;
2732 // The PMPN is optional.
2734 Param1
= GetNextParamStr (&TextDeviceNode
);
2735 Param2
= GetNextParamStr (&TextDeviceNode
);
2737 if (!IS_NULL (TextDeviceNode
)) {
2738 Param3
= GetNextParamStr (&TextDeviceNode
);
2741 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
2742 MESSAGING_DEVICE_PATH
,
2744 sizeof (SATA_DEVICE_PATH
)
2746 Sata
->HBAPortNumber
= (UINT16
) Xtoi (Param1
);
2747 if (Param3
!= NULL
) {
2748 Sata
->PortMultiplierPortNumber
= (UINT16
) Xtoi (Param2
);
2751 Sata
->PortMultiplierPortNumber
= SATA_HBA_DIRECT_CONNECT_FLAG
;
2753 Sata
->Lun
= (UINT16
) Xtoi (Param2
);
2755 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
2758 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable
[] = {
2759 {L
"Pci", DevPathFromTextPci
},
2760 {L
"PcCard", DevPathFromTextPcCard
},
2761 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
2762 {L
"VenHw", DevPathFromTextVenHw
},
2763 {L
"Ctrl", DevPathFromTextCtrl
},
2764 {L
"Acpi", DevPathFromTextAcpi
},
2765 {L
"PciRoot", DevPathFromTextPciRoot
},
2766 {L
"Floppy", DevPathFromTextFloppy
},
2767 {L
"Keyboard", DevPathFromTextKeyboard
},
2768 {L
"Serial", DevPathFromTextSerial
},
2769 {L
"ParallelPort", DevPathFromTextParallelPort
},
2770 {L
"AcpiEx", DevPathFromTextAcpiEx
},
2771 {L
"AcpiExp", DevPathFromTextAcpiExp
},
2772 {L
"Ata", DevPathFromTextAta
},
2773 {L
"Scsi", DevPathFromTextScsi
},
2774 {L
"Fibre", DevPathFromTextFibre
},
2775 {L
"I1394", DevPathFromText1394
},
2776 {L
"USB", DevPathFromTextUsb
},
2777 {L
"I2O", DevPathFromTextI2O
},
2778 {L
"Infiniband", DevPathFromTextInfiniband
},
2779 {L
"VenMsg", DevPathFromTextVenMsg
},
2780 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
2781 {L
"VenVt100", DevPathFromTextVenVt100
},
2782 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
2783 {L
"VenUtf8", DevPathFromTextVenUtf8
},
2784 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
2785 {L
"SAS", DevPathFromTextSAS
},
2786 {L
"DebugPort", DevPathFromTextDebugPort
},
2787 {L
"MAC", DevPathFromTextMAC
},
2788 {L
"IPv4", DevPathFromTextIPv4
},
2789 {L
"IPv6", DevPathFromTextIPv6
},
2790 {L
"Uart", DevPathFromTextUart
},
2791 {L
"UsbClass", DevPathFromTextUsbClass
},
2792 {L
"UsbAudio", DevPathFromTextUsbAudio
},
2793 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
2794 {L
"UsbHID", DevPathFromTextUsbHID
},
2795 {L
"UsbImage", DevPathFromTextUsbImage
},
2796 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
2797 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
2798 {L
"UsbHub", DevPathFromTextUsbHub
},
2799 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
2800 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
2801 {L
"UsbVideo", DevPathFromTextUsbVideo
},
2802 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
2803 {L
"UsbWireless", DevPathFromTextUsbWireless
},
2804 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
2805 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
2806 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
2807 {L
"UsbWwid", DevPathFromTextUsbWwid
},
2808 {L
"Unit", DevPathFromTextUnit
},
2809 {L
"iSCSI", DevPathFromTextiSCSI
},
2810 {L
"Vlan", DevPathFromTextVlan
},
2811 {L
"HD", DevPathFromTextHD
},
2812 {L
"CDROM", DevPathFromTextCDROM
},
2813 {L
"VenMEDIA", DevPathFromTextVenMEDIA
},
2814 {L
"Media", DevPathFromTextMedia
},
2815 {L
"Fv", DevPathFromTextFv
},
2816 {L
"FvFile", DevPathFromTextFvFile
},
2817 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
2818 {L
"BBS", DevPathFromTextBBS
},
2819 {L
"Sata", DevPathFromTextSata
},
2824 Convert text to the binary representation of a device node.
2826 @param TextDeviceNode TextDeviceNode points to the text representation of a device
2827 node. Conversion starts with the first character and continues
2828 until the first non-device node character.
2830 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
2831 insufficient memory or text unsupported.
2834 EFI_DEVICE_PATH_PROTOCOL
*
2836 ConvertTextToDeviceNode (
2837 IN CONST CHAR16
*TextDeviceNode
2842 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
2843 CHAR16
*DeviceNodeStr
;
2846 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
2852 DeviceNodeStr
= StrDuplicate (TextDeviceNode
);
2853 ASSERT (DeviceNodeStr
!= NULL
);
2855 for (Index
= 0; DevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
2856 ParamStr
= GetParamByNodeName (DeviceNodeStr
, DevPathFromTextTable
[Index
].DevicePathNodeText
);
2857 if (ParamStr
!= NULL
) {
2858 DumpNode
= DevPathFromTextTable
[Index
].Function
;
2863 if (DumpNode
== NULL
) {
2867 DumpNode
= DevPathFromTextFilePath
;
2868 DeviceNode
= DumpNode (DeviceNodeStr
);
2870 DeviceNode
= DumpNode (ParamStr
);
2871 FreePool (ParamStr
);
2874 FreePool (DeviceNodeStr
);
2880 Convert text to the binary representation of a device path.
2883 @param TextDevicePath TextDevicePath points to the text representation of a device
2884 path. Conversion starts with the first character and continues
2885 until the first non-device node character.
2887 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
2888 there was insufficient memory.
2891 EFI_DEVICE_PATH_PROTOCOL
*
2893 ConvertTextToDevicePath (
2894 IN CONST CHAR16
*TextDevicePath
2899 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
2901 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
2902 CHAR16
*DevicePathStr
;
2904 CHAR16
*DeviceNodeStr
;
2905 UINT8 IsInstanceEnd
;
2906 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
2908 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
2912 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
2913 ASSERT (DevicePath
!= NULL
);
2914 SetDevicePathEndNode (DevicePath
);
2917 DeviceNodeStr
= NULL
;
2918 DevicePathStr
= StrDuplicate (TextDevicePath
);
2920 Str
= DevicePathStr
;
2921 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
2923 for (Index
= 0; DevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
2924 ParamStr
= GetParamByNodeName (DeviceNodeStr
, DevPathFromTextTable
[Index
].DevicePathNodeText
);
2925 if (ParamStr
!= NULL
) {
2926 DumpNode
= DevPathFromTextTable
[Index
].Function
;
2931 if (DumpNode
== NULL
) {
2935 DumpNode
= DevPathFromTextFilePath
;
2936 DeviceNode
= DumpNode (DeviceNodeStr
);
2938 DeviceNode
= DumpNode (ParamStr
);
2939 FreePool (ParamStr
);
2942 NewDevicePath
= AppendDeviceNodeProtocolInterface (DevicePath
, DeviceNode
);
2943 FreePool (DevicePath
);
2944 FreePool (DeviceNode
);
2945 DevicePath
= NewDevicePath
;
2947 if (IsInstanceEnd
!= 0) {
2948 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
2949 ASSERT (DeviceNode
!= NULL
);
2950 SET_DEVICE_PATH_INSTANCE_END_NODE (DeviceNode
);
2952 NewDevicePath
= AppendDeviceNodeProtocolInterface (DevicePath
, DeviceNode
);
2953 FreePool (DevicePath
);
2954 FreePool (DeviceNode
);
2955 DevicePath
= NewDevicePath
;
2959 FreePool (DevicePathStr
);