2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
4 Copyright (c) 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 "UefiDevicePathLib.h"
21 @param Src Source string.
23 @return The duplicated string.
27 UefiDevicePathLibStrDuplicate (
31 return AllocateCopyPool (StrSize (Src
), Src
);
36 Get parameter in a pair of parentheses follow the given node name.
37 For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".
39 @param Str Device Path Text.
40 @param NodeName Name of the node.
42 @return Parameter text for the node.
54 UINTN ParameterLength
;
57 // Check whether the node name matchs
59 NodeNameLength
= StrLen (NodeName
);
60 if (StrnCmp (Str
, NodeName
, NodeNameLength
) != 0) {
64 ParamStr
= Str
+ NodeNameLength
;
65 if (!IS_LEFT_PARENTH (*ParamStr
)) {
70 // Skip the found '(' and find first occurrence of ')'
74 StrPointer
= ParamStr
;
75 while (!IS_NULL (*StrPointer
)) {
76 if (IS_RIGHT_PARENTH (*StrPointer
)) {
82 if (IS_NULL (*StrPointer
)) {
89 ParamStr
= AllocateCopyPool ((ParameterLength
+ 1) * sizeof (CHAR16
), ParamStr
);
90 if (ParamStr
== NULL
) {
94 // Terminate the parameter string
96 ParamStr
[ParameterLength
] = L
'\0';
102 Gets current sub-string from a string list, before return
103 the list header is moved to next sub-string. The sub-string is separated
104 by the specified character. For example, the separator is ',', the string
105 list is "2,0,3", it returns "2", the remain list move to "0,3"
107 @param List A string list separated by the specified separator
108 @param Separator The separator character
110 @return A pointer to the current sub-string
115 IN OUT CHAR16
**List
,
125 if (IS_NULL (*Str
)) {
130 // Find first occurrence of the separator
132 while (!IS_NULL (*Str
)) {
133 if (*Str
== Separator
) {
139 if (*Str
== Separator
) {
141 // Find a sub-string, terminate it
148 // Move to next sub-string
156 Gets the next parameter string from the list.
158 @param List A string list separated by the specified separator
160 @return A pointer to the current sub-string
169 // The separator is comma
171 return SplitStr (List
, L
',');
175 Get one device node from entire device path text.
177 @param DevicePath On input, the current Device Path node; on output, the next device path node
178 @param IsInstanceEnd This node is the end of a device path instance
180 @return A device node text or NULL if no more device node available
184 GetNextDeviceNodeStr (
185 IN OUT CHAR16
**DevicePath
,
186 OUT BOOLEAN
*IsInstanceEnd
191 UINTN ParenthesesStack
;
194 if (IS_NULL (*Str
)) {
199 // Skip the leading '/', '(', ')' and ','
201 while (!IS_NULL (*Str
)) {
202 if (!IS_SLASH (*Str
) &&
204 !IS_LEFT_PARENTH (*Str
) &&
205 !IS_RIGHT_PARENTH (*Str
)) {
214 // Scan for the separator of this device node, '/' or ','
216 ParenthesesStack
= 0;
217 while (!IS_NULL (*Str
)) {
218 if ((IS_COMMA (*Str
) || IS_SLASH (*Str
)) && (ParenthesesStack
== 0)) {
222 if (IS_LEFT_PARENTH (*Str
)) {
224 } else if (IS_RIGHT_PARENTH (*Str
)) {
231 if (ParenthesesStack
!= 0) {
233 // The '(' doesn't pair with ')', invalid device path text
238 if (IS_COMMA (*Str
)) {
239 *IsInstanceEnd
= TRUE
;
243 *IsInstanceEnd
= FALSE
;
244 if (!IS_NULL (*Str
)) {
257 Return whether the integer string is a hex string.
259 @param Str The integer string
261 @retval TRUE Hex string
262 @retval FALSE Decimal string
271 // skip preceeding white space
273 while ((*Str
!= 0) && *Str
== L
' ') {
277 // skip preceeding zeros
279 while ((*Str
!= 0) && *Str
== L
'0') {
283 return (BOOLEAN
) (*Str
== L
'x' || *Str
== L
'X');
288 Convert integer string to uint.
290 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
292 @return A UINTN value represented by Str
300 if (IsHexStr (Str
)) {
301 return StrHexToUintn (Str
);
303 return StrDecimalToUintn (Str
);
309 Convert integer string to 64 bit data.
311 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
312 @param Data A pointer to the UINT64 value represented by Str
321 if (IsHexStr (Str
)) {
322 *Data
= StrHexToUint64 (Str
);
324 *Data
= StrDecimalToUint64 (Str
);
329 Converts a list of string to a specified buffer.
331 @param Buf The output buffer that contains the string.
332 @param BufferLength The length of the buffer
333 @param Str The input string that contains the hex number
335 @retval EFI_SUCCESS The string was successfully converted to the buffer.
341 IN UINTN BufferLength
,
353 // Two hex char make up one byte
355 StrLength
= BufferLength
* sizeof (CHAR16
);
357 for(Index
= 0; Index
< StrLength
; Index
++, Str
++) {
359 if ((*Str
>= L
'a') && (*Str
<= L
'f')) {
360 Digit
= (UINT8
) (*Str
- L
'a' + 0x0A);
361 } else if ((*Str
>= L
'A') && (*Str
<= L
'F')) {
362 Digit
= (UINT8
) (*Str
- L
'A' + 0x0A);
363 } else if ((*Str
>= L
'0') && (*Str
<= L
'9')) {
364 Digit
= (UINT8
) (*Str
- L
'0');
366 return EFI_INVALID_PARAMETER
;
370 // For odd characters, write the upper nibble for each buffer byte,
371 // and for even characters, the lower nibble.
373 if ((Index
& 1) == 0) {
374 Byte
= (UINT8
) (Digit
<< 4);
376 Byte
= Buf
[Index
/ 2];
378 Byte
= (UINT8
) (Byte
| Digit
);
381 Buf
[Index
/ 2] = Byte
;
388 Converts a string to GUID value.
389 Guid Format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
391 @param Str The registry format GUID string that contains the GUID value.
392 @param Guid A pointer to the converted GUID value.
394 @retval EFI_SUCCESS The GUID string was successfully converted to the GUID value.
395 @retval EFI_UNSUPPORTED The input string is not in registry format.
396 @return others Some error occurred when converting part of GUID value.
406 // Get the first UINT32 data
408 Guid
->Data1
= (UINT32
) StrHexToUint64 (Str
);
409 while (!IS_HYPHEN (*Str
) && !IS_NULL (*Str
)) {
413 if (IS_HYPHEN (*Str
)) {
416 return EFI_UNSUPPORTED
;
420 // Get the second UINT16 data
422 Guid
->Data2
= (UINT16
) StrHexToUint64 (Str
);
423 while (!IS_HYPHEN (*Str
) && !IS_NULL (*Str
)) {
427 if (IS_HYPHEN (*Str
)) {
430 return EFI_UNSUPPORTED
;
434 // Get the third UINT16 data
436 Guid
->Data3
= (UINT16
) StrHexToUint64 (Str
);
437 while (!IS_HYPHEN (*Str
) && !IS_NULL (*Str
)) {
441 if (IS_HYPHEN (*Str
)) {
444 return EFI_UNSUPPORTED
;
448 // Get the following 8 bytes data
450 StrToBuf (&Guid
->Data4
[0], 2, Str
);
452 // Skip 2 byte hex chars
456 if (IS_HYPHEN (*Str
)) {
459 return EFI_UNSUPPORTED
;
461 StrToBuf (&Guid
->Data4
[2], 6, Str
);
467 Converts a string to IPv4 address
469 @param Str A string representation of IPv4 address.
470 @param IPv4Addr A pointer to the converted IPv4 address.
476 OUT EFI_IPv4_ADDRESS
*IPv4Addr
481 for (Index
= 0; Index
< 4; Index
++) {
482 IPv4Addr
->Addr
[Index
] = (UINT8
) Strtoi (SplitStr (Str
, L
'.'));
487 Converts a string to IPv4 address
489 @param Str A string representation of IPv6 address.
490 @param IPv6Addr A pointer to the converted IPv6 address.
496 OUT EFI_IPv6_ADDRESS
*IPv6Addr
502 for (Index
= 0; Index
< 8; Index
++) {
503 Data
= (UINT16
) StrHexToUintn (SplitStr (Str
, L
':'));
504 IPv6Addr
->Addr
[Index
* 2] = (UINT8
) (Data
>> 8);
505 IPv6Addr
->Addr
[Index
* 2 + 1] = (UINT8
) (Data
& 0xff);
510 Converts a Unicode string to ASCII string.
512 @param Str The equivalent Unicode string
513 @param AsciiStr On input, it points to destination ASCII string buffer; on output, it points
514 to the next ASCII string next to it
520 IN OUT CHAR8
**AsciiStr
526 while (!IS_NULL (*Str
)) {
527 *(Dest
++) = (CHAR8
) *(Str
++);
532 // Return the string next to it
534 *AsciiStr
= Dest
+ 1;
538 Converts a text device path node to Hardware PCI device path structure.
540 @param TextDeviceNode The input Text device path node.
542 @return A pointer to Hardware PCI device path structure.
545 EFI_DEVICE_PATH_PROTOCOL
*
547 IN CHAR16
*TextDeviceNode
552 PCI_DEVICE_PATH
*Pci
;
554 DeviceStr
= GetNextParamStr (&TextDeviceNode
);
555 FunctionStr
= GetNextParamStr (&TextDeviceNode
);
556 Pci
= (PCI_DEVICE_PATH
*) CreateDeviceNode (
557 HARDWARE_DEVICE_PATH
,
559 (UINT16
) sizeof (PCI_DEVICE_PATH
)
562 Pci
->Function
= (UINT8
) Strtoi (FunctionStr
);
563 Pci
->Device
= (UINT8
) Strtoi (DeviceStr
);
565 return (EFI_DEVICE_PATH_PROTOCOL
*) Pci
;
569 Converts a text device path node to Hardware PC card device path structure.
571 @param TextDeviceNode The input Text device path node.
573 @return A pointer to Hardware PC card device path structure.
576 EFI_DEVICE_PATH_PROTOCOL
*
577 DevPathFromTextPcCard (
578 IN CHAR16
*TextDeviceNode
581 CHAR16
*FunctionNumberStr
;
582 PCCARD_DEVICE_PATH
*Pccard
;
584 FunctionNumberStr
= GetNextParamStr (&TextDeviceNode
);
585 Pccard
= (PCCARD_DEVICE_PATH
*) CreateDeviceNode (
586 HARDWARE_DEVICE_PATH
,
588 (UINT16
) sizeof (PCCARD_DEVICE_PATH
)
591 Pccard
->FunctionNumber
= (UINT8
) Strtoi (FunctionNumberStr
);
593 return (EFI_DEVICE_PATH_PROTOCOL
*) Pccard
;
597 Converts a text device path node to Hardware memory map device path structure.
599 @param TextDeviceNode The input Text device path node.
601 @return A pointer to Hardware memory map device path structure.
604 EFI_DEVICE_PATH_PROTOCOL
*
605 DevPathFromTextMemoryMapped (
606 IN CHAR16
*TextDeviceNode
609 CHAR16
*MemoryTypeStr
;
610 CHAR16
*StartingAddressStr
;
611 CHAR16
*EndingAddressStr
;
612 MEMMAP_DEVICE_PATH
*MemMap
;
614 MemoryTypeStr
= GetNextParamStr (&TextDeviceNode
);
615 StartingAddressStr
= GetNextParamStr (&TextDeviceNode
);
616 EndingAddressStr
= GetNextParamStr (&TextDeviceNode
);
617 MemMap
= (MEMMAP_DEVICE_PATH
*) CreateDeviceNode (
618 HARDWARE_DEVICE_PATH
,
620 (UINT16
) sizeof (MEMMAP_DEVICE_PATH
)
623 MemMap
->MemoryType
= (UINT32
) Strtoi (MemoryTypeStr
);
624 Strtoi64 (StartingAddressStr
, &MemMap
->StartingAddress
);
625 Strtoi64 (EndingAddressStr
, &MemMap
->EndingAddress
);
627 return (EFI_DEVICE_PATH_PROTOCOL
*) MemMap
;
631 Converts a text device path node to Vendor device path structure based on the input Type
634 @param TextDeviceNode The input Text device path node.
635 @param Type The type of device path node.
636 @param SubType The subtype of device path node.
638 @return A pointer to the newly-created Vendor device path structure.
641 EFI_DEVICE_PATH_PROTOCOL
*
642 ConvertFromTextVendor (
643 IN CHAR16
*TextDeviceNode
,
651 VENDOR_DEVICE_PATH
*Vendor
;
653 GuidStr
= GetNextParamStr (&TextDeviceNode
);
655 DataStr
= GetNextParamStr (&TextDeviceNode
);
656 Length
= StrLen (DataStr
);
658 // Two hex characters make up 1 buffer byte
660 Length
= (Length
+ 1) / 2;
662 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
665 (UINT16
) (sizeof (VENDOR_DEVICE_PATH
) + Length
)
668 StrToGuid (GuidStr
, &Vendor
->Guid
);
669 StrToBuf (((UINT8
*) Vendor
) + sizeof (VENDOR_DEVICE_PATH
), Length
, DataStr
);
671 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
675 Converts a text device path node to Vendor Hardware device path structure.
677 @param TextDeviceNode The input Text device path node.
679 @return A pointer to the newly-created Vendor Hardware device path structure.
682 EFI_DEVICE_PATH_PROTOCOL
*
683 DevPathFromTextVenHw (
684 IN CHAR16
*TextDeviceNode
687 return ConvertFromTextVendor (
689 HARDWARE_DEVICE_PATH
,
695 Converts a text device path node to Hardware Controller device path structure.
697 @param TextDeviceNode The input Text device path node.
699 @return A pointer to the newly-created Hardware Controller device path structure.
702 EFI_DEVICE_PATH_PROTOCOL
*
703 DevPathFromTextCtrl (
704 IN CHAR16
*TextDeviceNode
707 CHAR16
*ControllerStr
;
708 CONTROLLER_DEVICE_PATH
*Controller
;
710 ControllerStr
= GetNextParamStr (&TextDeviceNode
);
711 Controller
= (CONTROLLER_DEVICE_PATH
*) CreateDeviceNode (
712 HARDWARE_DEVICE_PATH
,
714 (UINT16
) sizeof (CONTROLLER_DEVICE_PATH
)
716 Controller
->ControllerNumber
= (UINT32
) Strtoi (ControllerStr
);
718 return (EFI_DEVICE_PATH_PROTOCOL
*) Controller
;
722 Converts a string to EisaId.
724 @param Text The input string.
726 @return UINT32 EISA ID.
733 return (((Text
[0] - 'A' + 1) & 0x1f) << 10)
734 + (((Text
[1] - 'A' + 1) & 0x1f) << 5)
735 + (((Text
[2] - 'A' + 1) & 0x1f) << 0)
736 + (UINT32
) (StrHexToUintn (&Text
[3]) << 16)
741 Converts a text device path node to ACPI HID device path structure.
743 @param TextDeviceNode The input Text device path node.
745 @return A pointer to the newly-created ACPI HID device path structure.
748 EFI_DEVICE_PATH_PROTOCOL
*
749 DevPathFromTextAcpi (
750 IN CHAR16
*TextDeviceNode
755 ACPI_HID_DEVICE_PATH
*Acpi
;
757 HIDStr
= GetNextParamStr (&TextDeviceNode
);
758 UIDStr
= GetNextParamStr (&TextDeviceNode
);
759 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
762 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
765 Acpi
->HID
= EisaIdFromText (HIDStr
);
766 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
768 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
772 Converts a text device path node to ACPI HID device path structure.
774 @param TextDeviceNode The input Text device path node.
775 @param PnPId The input plug and play identification.
777 @return A pointer to the newly-created ACPI HID device path structure.
780 EFI_DEVICE_PATH_PROTOCOL
*
781 ConvertFromTextAcpi (
782 IN CHAR16
*TextDeviceNode
,
787 ACPI_HID_DEVICE_PATH
*Acpi
;
789 UIDStr
= GetNextParamStr (&TextDeviceNode
);
790 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
793 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
796 Acpi
->HID
= EFI_PNP_ID (PnPId
);
797 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
799 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
803 Converts a text device path node to PCI root device path structure.
805 @param TextDeviceNode The input Text device path node.
807 @return A pointer to the newly-created PCI root device path structure.
810 EFI_DEVICE_PATH_PROTOCOL
*
811 DevPathFromTextPciRoot (
812 IN CHAR16
*TextDeviceNode
815 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a03);
819 Converts a text device path node to PCIE root device path structure.
821 @param TextDeviceNode The input Text device path node.
823 @return A pointer to the newly-created PCIE root device path structure.
826 EFI_DEVICE_PATH_PROTOCOL
*
827 DevPathFromTextPcieRoot (
828 IN CHAR16
*TextDeviceNode
831 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a08);
835 Converts a text device path node to Floppy device path structure.
837 @param TextDeviceNode The input Text device path node.
839 @return A pointer to the newly-created Floppy device path structure.
842 EFI_DEVICE_PATH_PROTOCOL
*
843 DevPathFromTextFloppy (
844 IN CHAR16
*TextDeviceNode
847 return ConvertFromTextAcpi (TextDeviceNode
, 0x0604);
851 Converts a text device path node to Keyboard device path structure.
853 @param TextDeviceNode The input Text device path node.
855 @return A pointer to the newly-created Keyboard device path structure.
858 EFI_DEVICE_PATH_PROTOCOL
*
859 DevPathFromTextKeyboard (
860 IN CHAR16
*TextDeviceNode
863 return ConvertFromTextAcpi (TextDeviceNode
, 0x0301);
867 Converts a text device path node to Serial device path structure.
869 @param TextDeviceNode The input Text device path node.
871 @return A pointer to the newly-created Serial device path structure.
874 EFI_DEVICE_PATH_PROTOCOL
*
875 DevPathFromTextSerial (
876 IN CHAR16
*TextDeviceNode
879 return ConvertFromTextAcpi (TextDeviceNode
, 0x0501);
883 Converts a text device path node to Parallel Port device path structure.
885 @param TextDeviceNode The input Text device path node.
887 @return A pointer to the newly-created Parallel Port device path structure.
890 EFI_DEVICE_PATH_PROTOCOL
*
891 DevPathFromTextParallelPort (
892 IN CHAR16
*TextDeviceNode
895 return ConvertFromTextAcpi (TextDeviceNode
, 0x0401);
899 Converts a text device path node to ACPI extension device path structure.
901 @param TextDeviceNode The input Text device path node.
903 @return A pointer to the newly-created ACPI extension device path structure.
906 EFI_DEVICE_PATH_PROTOCOL
*
907 DevPathFromTextAcpiEx (
908 IN CHAR16
*TextDeviceNode
919 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
921 HIDStr
= GetNextParamStr (&TextDeviceNode
);
922 CIDStr
= GetNextParamStr (&TextDeviceNode
);
923 UIDStr
= GetNextParamStr (&TextDeviceNode
);
924 HIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
925 CIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
926 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
928 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (HIDSTRStr
) + 1);
929 Length
= (UINT16
) (Length
+ StrLen (UIDSTRStr
) + 1);
930 Length
= (UINT16
) (Length
+ StrLen (CIDSTRStr
) + 1);
931 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
937 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
938 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
939 AcpiEx
->UID
= (UINT32
) Strtoi (UIDStr
);
941 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
942 StrToAscii (HIDSTRStr
, &AsciiStr
);
943 StrToAscii (UIDSTRStr
, &AsciiStr
);
944 StrToAscii (CIDSTRStr
, &AsciiStr
);
946 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
950 Converts a text device path node to ACPI extension device path structure.
952 @param TextDeviceNode The input Text device path node.
954 @return A pointer to the newly-created ACPI extension device path structure.
957 EFI_DEVICE_PATH_PROTOCOL
*
958 DevPathFromTextAcpiExp (
959 IN CHAR16
*TextDeviceNode
967 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
969 HIDStr
= GetNextParamStr (&TextDeviceNode
);
970 CIDStr
= GetNextParamStr (&TextDeviceNode
);
971 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
972 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (UIDSTRStr
) + 3);
973 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
979 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
980 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
983 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
985 // HID string is NULL
989 // Convert UID string
992 StrToAscii (UIDSTRStr
, &AsciiStr
);
994 // CID string is NULL
998 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
1002 Converts a text device path node to ACPI _ADR device path structure.
1004 @param TextDeviceNode The input Text device path node.
1006 @return A pointer to the newly-created ACPI _ADR device path structure.
1009 EFI_DEVICE_PATH_PROTOCOL
*
1010 DevPathFromTextAcpiAdr (
1011 IN CHAR16
*TextDeviceNode
1014 CHAR16
*DisplayDeviceStr
;
1015 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
1019 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*) CreateDeviceNode (
1022 (UINT16
) sizeof (ACPI_ADR_DEVICE_PATH
)
1024 ASSERT (AcpiAdr
!= NULL
);
1026 for (Index
= 0; ; Index
++) {
1027 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
1028 if (IS_NULL (*DisplayDeviceStr
)) {
1032 Length
= DevicePathNodeLength (AcpiAdr
);
1033 AcpiAdr
= ReallocatePool (
1035 Length
+ sizeof (UINT32
),
1038 ASSERT (AcpiAdr
!= NULL
);
1039 SetDevicePathNodeLength (AcpiAdr
, Length
+ sizeof (UINT32
));
1042 (&AcpiAdr
->ADR
)[Index
] = (UINT32
) Strtoi (DisplayDeviceStr
);
1045 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
;
1049 Converts a text device path node to Parallel Port device path structure.
1051 @param TextDeviceNode The input Text device path node.
1053 @return A pointer to the newly-created Parallel Port device path structure.
1056 EFI_DEVICE_PATH_PROTOCOL
*
1057 DevPathFromTextAta (
1058 IN CHAR16
*TextDeviceNode
1061 CHAR16
*PrimarySecondaryStr
;
1062 CHAR16
*SlaveMasterStr
;
1064 ATAPI_DEVICE_PATH
*Atapi
;
1066 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
1067 MESSAGING_DEVICE_PATH
,
1069 (UINT16
) sizeof (ATAPI_DEVICE_PATH
)
1072 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
1073 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
1074 LunStr
= GetNextParamStr (&TextDeviceNode
);
1076 if (StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) {
1077 Atapi
->PrimarySecondary
= 0;
1078 } else if (StrCmp (PrimarySecondaryStr
, L
"Secondary") == 0) {
1079 Atapi
->PrimarySecondary
= 1;
1081 Atapi
->PrimarySecondary
= (UINT8
) Strtoi (PrimarySecondaryStr
);
1083 if (StrCmp (SlaveMasterStr
, L
"Master") == 0) {
1084 Atapi
->SlaveMaster
= 0;
1085 } else if (StrCmp (SlaveMasterStr
, L
"Slave") == 0) {
1086 Atapi
->SlaveMaster
= 1;
1088 Atapi
->SlaveMaster
= (UINT8
) Strtoi (SlaveMasterStr
);
1091 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
1093 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
1097 Converts a text device path node to SCSI device path structure.
1099 @param TextDeviceNode The input Text device path node.
1101 @return A pointer to the newly-created SCSI device path structure.
1104 EFI_DEVICE_PATH_PROTOCOL
*
1105 DevPathFromTextScsi (
1106 IN CHAR16
*TextDeviceNode
1111 SCSI_DEVICE_PATH
*Scsi
;
1113 PunStr
= GetNextParamStr (&TextDeviceNode
);
1114 LunStr
= GetNextParamStr (&TextDeviceNode
);
1115 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
1116 MESSAGING_DEVICE_PATH
,
1118 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
1121 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
1122 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
1124 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
1128 Converts a text device path node to Fibre device path structure.
1130 @param TextDeviceNode The input Text device path node.
1132 @return A pointer to the newly-created Fibre device path structure.
1135 EFI_DEVICE_PATH_PROTOCOL
*
1136 DevPathFromTextFibre (
1137 IN CHAR16
*TextDeviceNode
1142 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
1144 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1145 LunStr
= GetNextParamStr (&TextDeviceNode
);
1146 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
1147 MESSAGING_DEVICE_PATH
,
1148 MSG_FIBRECHANNEL_DP
,
1149 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
1152 Fibre
->Reserved
= 0;
1153 Strtoi64 (WWNStr
, &Fibre
->WWN
);
1154 Strtoi64 (LunStr
, &Fibre
->Lun
);
1156 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
1160 Converts a text device path node to FibreEx device path structure.
1162 @param TextDeviceNode The input Text device path node.
1164 @return A pointer to the newly-created FibreEx device path structure.
1167 EFI_DEVICE_PATH_PROTOCOL
*
1168 DevPathFromTextFibreEx (
1169 IN CHAR16
*TextDeviceNode
1174 FIBRECHANNELEX_DEVICE_PATH
*FibreEx
;
1176 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1177 LunStr
= GetNextParamStr (&TextDeviceNode
);
1178 FibreEx
= (FIBRECHANNELEX_DEVICE_PATH
*) CreateDeviceNode (
1179 MESSAGING_DEVICE_PATH
,
1180 MSG_FIBRECHANNELEX_DP
,
1181 (UINT16
) sizeof (FIBRECHANNELEX_DEVICE_PATH
)
1184 FibreEx
->Reserved
= 0;
1185 Strtoi64 (WWNStr
, (UINT64
*) (&FibreEx
->WWN
));
1186 Strtoi64 (LunStr
, (UINT64
*) (&FibreEx
->Lun
));
1188 *(UINT64
*) (&FibreEx
->WWN
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->WWN
));
1189 *(UINT64
*) (&FibreEx
->Lun
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->Lun
));
1191 return (EFI_DEVICE_PATH_PROTOCOL
*) FibreEx
;
1195 Converts a text device path node to 1394 device path structure.
1197 @param TextDeviceNode The input Text device path node.
1199 @return A pointer to the newly-created 1394 device path structure.
1202 EFI_DEVICE_PATH_PROTOCOL
*
1203 DevPathFromText1394 (
1204 IN CHAR16
*TextDeviceNode
1208 F1394_DEVICE_PATH
*F1394DevPath
;
1210 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1211 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1212 MESSAGING_DEVICE_PATH
,
1214 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1217 F1394DevPath
->Reserved
= 0;
1218 F1394DevPath
->Guid
= StrHexToUint64 (GuidStr
);
1220 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1224 Converts a text device path node to USB device path structure.
1226 @param TextDeviceNode The input Text device path node.
1228 @return A pointer to the newly-created USB device path structure.
1231 EFI_DEVICE_PATH_PROTOCOL
*
1232 DevPathFromTextUsb (
1233 IN CHAR16
*TextDeviceNode
1237 CHAR16
*InterfaceStr
;
1238 USB_DEVICE_PATH
*Usb
;
1240 PortStr
= GetNextParamStr (&TextDeviceNode
);
1241 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1242 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1243 MESSAGING_DEVICE_PATH
,
1245 (UINT16
) sizeof (USB_DEVICE_PATH
)
1248 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1249 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1251 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1255 Converts a text device path node to I20 device path structure.
1257 @param TextDeviceNode The input Text device path node.
1259 @return A pointer to the newly-created I20 device path structure.
1262 EFI_DEVICE_PATH_PROTOCOL
*
1263 DevPathFromTextI2O (
1264 IN CHAR16
*TextDeviceNode
1268 I2O_DEVICE_PATH
*I2ODevPath
;
1270 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1271 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1272 MESSAGING_DEVICE_PATH
,
1274 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1277 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1279 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1283 Converts a text device path node to Infini Band device path structure.
1285 @param TextDeviceNode The input Text device path node.
1287 @return A pointer to the newly-created Infini Band device path structure.
1290 EFI_DEVICE_PATH_PROTOCOL
*
1291 DevPathFromTextInfiniband (
1292 IN CHAR16
*TextDeviceNode
1301 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1303 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1304 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1305 SidStr
= GetNextParamStr (&TextDeviceNode
);
1306 TidStr
= GetNextParamStr (&TextDeviceNode
);
1307 DidStr
= GetNextParamStr (&TextDeviceNode
);
1308 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1309 MESSAGING_DEVICE_PATH
,
1311 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1314 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1315 StrToGuid (GuidStr
, &PortGid
);
1316 CopyMem (InfiniBand
->PortGid
, &PortGid
, sizeof (EFI_GUID
));
1317 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1318 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1319 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1321 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1325 Converts a text device path node to Vendor-Defined Messaging device path structure.
1327 @param TextDeviceNode The input Text device path node.
1329 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1332 EFI_DEVICE_PATH_PROTOCOL
*
1333 DevPathFromTextVenMsg (
1334 IN CHAR16
*TextDeviceNode
1337 return ConvertFromTextVendor (
1339 MESSAGING_DEVICE_PATH
,
1345 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1347 @param TextDeviceNode The input Text device path node.
1349 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1352 EFI_DEVICE_PATH_PROTOCOL
*
1353 DevPathFromTextVenPcAnsi (
1354 IN CHAR16
*TextDeviceNode
1357 VENDOR_DEVICE_PATH
*Vendor
;
1359 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1360 MESSAGING_DEVICE_PATH
,
1362 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1363 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1365 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1369 Converts a text device path node to Vendor defined VT100 device path structure.
1371 @param TextDeviceNode The input Text device path node.
1373 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1376 EFI_DEVICE_PATH_PROTOCOL
*
1377 DevPathFromTextVenVt100 (
1378 IN CHAR16
*TextDeviceNode
1381 VENDOR_DEVICE_PATH
*Vendor
;
1383 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1384 MESSAGING_DEVICE_PATH
,
1386 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1387 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1389 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1393 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1395 @param TextDeviceNode The input Text device path node.
1397 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1400 EFI_DEVICE_PATH_PROTOCOL
*
1401 DevPathFromTextVenVt100Plus (
1402 IN CHAR16
*TextDeviceNode
1405 VENDOR_DEVICE_PATH
*Vendor
;
1407 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1408 MESSAGING_DEVICE_PATH
,
1410 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1411 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1413 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1417 Converts a text device path node to Vendor defined UTF8 device path structure.
1419 @param TextDeviceNode The input Text device path node.
1421 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1424 EFI_DEVICE_PATH_PROTOCOL
*
1425 DevPathFromTextVenUtf8 (
1426 IN CHAR16
*TextDeviceNode
1429 VENDOR_DEVICE_PATH
*Vendor
;
1431 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1432 MESSAGING_DEVICE_PATH
,
1434 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1435 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1437 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1441 Converts a text device path node to UART Flow Control device path structure.
1443 @param TextDeviceNode The input Text device path node.
1445 @return A pointer to the newly-created UART Flow Control device path structure.
1448 EFI_DEVICE_PATH_PROTOCOL
*
1449 DevPathFromTextUartFlowCtrl (
1450 IN CHAR16
*TextDeviceNode
1454 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1456 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1457 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1458 MESSAGING_DEVICE_PATH
,
1460 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1463 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1464 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1465 UartFlowControl
->FlowControlMap
= 2;
1466 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1467 UartFlowControl
->FlowControlMap
= 1;
1469 UartFlowControl
->FlowControlMap
= 0;
1472 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1476 Converts a text device path node to Serial Attached SCSI device path structure.
1478 @param TextDeviceNode The input Text device path node.
1480 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1483 EFI_DEVICE_PATH_PROTOCOL
*
1484 DevPathFromTextSAS (
1485 IN CHAR16
*TextDeviceNode
1492 CHAR16
*LocationStr
;
1494 CHAR16
*DriveBayStr
;
1495 CHAR16
*ReservedStr
;
1498 SAS_DEVICE_PATH
*Sas
;
1500 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1501 LunStr
= GetNextParamStr (&TextDeviceNode
);
1502 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1503 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1504 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1505 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1506 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1507 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1508 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1509 MESSAGING_DEVICE_PATH
,
1511 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1514 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1515 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1516 Strtoi64 (LunStr
, &Sas
->Lun
);
1517 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1519 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1522 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1524 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1528 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1531 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1536 // Location is an integer between 0 and 1 or else
1537 // the keyword Internal (0) or External (1).
1539 if (StrCmp (LocationStr
, L
"External") == 0) {
1541 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1544 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1546 Info
|= (Uint16
<< 5);
1549 // Connect is an integer between 0 and 3 or else
1550 // the keyword Direct (0) or Expanded (1).
1552 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1554 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1557 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1559 Info
|= (Uint16
<< 6);
1562 Info
= (UINT16
) Strtoi (SASSATAStr
);
1565 Sas
->DeviceTopology
= Info
;
1566 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1568 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1572 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1574 @param TextDeviceNode The input Text device path node.
1576 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1579 EFI_DEVICE_PATH_PROTOCOL
*
1580 DevPathFromTextSasEx (
1581 IN CHAR16
*TextDeviceNode
1588 CHAR16
*LocationStr
;
1590 CHAR16
*DriveBayStr
;
1595 SASEX_DEVICE_PATH
*SasEx
;
1597 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1598 LunStr
= GetNextParamStr (&TextDeviceNode
);
1599 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1600 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1601 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1602 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1603 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1604 SasEx
= (SASEX_DEVICE_PATH
*) CreateDeviceNode (
1605 MESSAGING_DEVICE_PATH
,
1607 (UINT16
) sizeof (SASEX_DEVICE_PATH
)
1610 Strtoi64 (AddressStr
, &SasAddress
);
1611 Strtoi64 (LunStr
, &Lun
);
1612 WriteUnaligned64 ((UINT64
*) &SasEx
->SasAddress
, SwapBytes64 (SasAddress
));
1613 WriteUnaligned64 ((UINT64
*) &SasEx
->Lun
, SwapBytes64 (Lun
));
1614 SasEx
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1616 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1619 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1621 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1625 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1628 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1633 // Location is an integer between 0 and 1 or else
1634 // the keyword Internal (0) or External (1).
1636 if (StrCmp (LocationStr
, L
"External") == 0) {
1638 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1641 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1643 Info
|= (Uint16
<< 5);
1646 // Connect is an integer between 0 and 3 or else
1647 // the keyword Direct (0) or Expanded (1).
1649 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1651 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1654 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1656 Info
|= (Uint16
<< 6);
1659 Info
= (UINT16
) Strtoi (SASSATAStr
);
1662 SasEx
->DeviceTopology
= Info
;
1664 return (EFI_DEVICE_PATH_PROTOCOL
*) SasEx
;
1668 Converts a text device path node to Debug Port device path structure.
1670 @param TextDeviceNode The input Text device path node.
1672 @return A pointer to the newly-created Debug Port device path structure.
1675 EFI_DEVICE_PATH_PROTOCOL
*
1676 DevPathFromTextDebugPort (
1677 IN CHAR16
*TextDeviceNode
1680 VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*Vend
;
1682 Vend
= (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*) CreateDeviceNode (
1683 MESSAGING_DEVICE_PATH
,
1685 (UINT16
) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
)
1688 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1690 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1694 Converts a text device path node to MAC device path structure.
1696 @param TextDeviceNode The input Text device path node.
1698 @return A pointer to the newly-created MAC device path structure.
1701 EFI_DEVICE_PATH_PROTOCOL
*
1702 DevPathFromTextMAC (
1703 IN CHAR16
*TextDeviceNode
1709 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1711 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1712 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1713 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1714 MESSAGING_DEVICE_PATH
,
1716 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1719 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1721 Length
= sizeof (EFI_MAC_ADDRESS
);
1722 StrToBuf (&MACDevPath
->MacAddress
.Addr
[0], Length
, AddressStr
);
1724 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1729 Converts a text format to the network protocol ID.
1731 @param Text String of protocol field.
1733 @return Network protocol ID .
1737 NetworkProtocolFromText (
1741 if (StrCmp (Text
, L
"UDP") == 0) {
1742 return RFC_1700_UDP_PROTOCOL
;
1745 if (StrCmp (Text
, L
"TCP") == 0) {
1746 return RFC_1700_TCP_PROTOCOL
;
1749 return Strtoi (Text
);
1754 Converts a text device path node to IPV4 device path structure.
1756 @param TextDeviceNode The input Text device path node.
1758 @return A pointer to the newly-created IPV4 device path structure.
1761 EFI_DEVICE_PATH_PROTOCOL
*
1762 DevPathFromTextIPv4 (
1763 IN CHAR16
*TextDeviceNode
1766 CHAR16
*RemoteIPStr
;
1767 CHAR16
*ProtocolStr
;
1770 CHAR16
*GatewayIPStr
;
1771 CHAR16
*SubnetMaskStr
;
1772 IPv4_DEVICE_PATH
*IPv4
;
1774 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1775 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1776 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1777 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1778 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1779 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
1780 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1781 MESSAGING_DEVICE_PATH
,
1783 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
1786 StrToIPv4Addr (&RemoteIPStr
, &IPv4
->RemoteIpAddress
);
1787 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1788 if (StrCmp (TypeStr
, L
"Static") == 0) {
1789 IPv4
->StaticIpAddress
= TRUE
;
1791 IPv4
->StaticIpAddress
= FALSE
;
1794 StrToIPv4Addr (&LocalIPStr
, &IPv4
->LocalIpAddress
);
1795 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
1796 StrToIPv4Addr (&GatewayIPStr
, &IPv4
->GatewayIpAddress
);
1797 StrToIPv4Addr (&SubnetMaskStr
, &IPv4
->SubnetMask
);
1799 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
1800 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
1803 IPv4
->LocalPort
= 0;
1804 IPv4
->RemotePort
= 0;
1806 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1810 Converts a text device path node to IPV6 device path structure.
1812 @param TextDeviceNode The input Text device path node.
1814 @return A pointer to the newly-created IPV6 device path structure.
1817 EFI_DEVICE_PATH_PROTOCOL
*
1818 DevPathFromTextIPv6 (
1819 IN CHAR16
*TextDeviceNode
1822 CHAR16
*RemoteIPStr
;
1823 CHAR16
*ProtocolStr
;
1826 CHAR16
*GatewayIPStr
;
1827 CHAR16
*PrefixLengthStr
;
1828 IPv6_DEVICE_PATH
*IPv6
;
1830 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1831 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1832 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1833 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1834 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
1835 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1836 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1837 MESSAGING_DEVICE_PATH
,
1839 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
1842 StrToIPv6Addr (&RemoteIPStr
, &IPv6
->RemoteIpAddress
);
1843 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1844 if (StrCmp (TypeStr
, L
"Static") == 0) {
1845 IPv6
->IpAddressOrigin
= 0;
1846 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
1847 IPv6
->IpAddressOrigin
= 1;
1849 IPv6
->IpAddressOrigin
= 2;
1852 StrToIPv6Addr (&LocalIPStr
, &IPv6
->LocalIpAddress
);
1853 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
1854 StrToIPv6Addr (&GatewayIPStr
, &IPv6
->GatewayIpAddress
);
1855 IPv6
->PrefixLength
= (UINT8
) Strtoi (PrefixLengthStr
);
1857 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
1858 IPv6
->PrefixLength
= 0;
1861 IPv6
->LocalPort
= 0;
1862 IPv6
->RemotePort
= 0;
1864 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
1868 Converts a text device path node to UART device path structure.
1870 @param TextDeviceNode The input Text device path node.
1872 @return A pointer to the newly-created UART device path structure.
1875 EFI_DEVICE_PATH_PROTOCOL
*
1876 DevPathFromTextUart (
1877 IN CHAR16
*TextDeviceNode
1881 CHAR16
*DataBitsStr
;
1883 CHAR16
*StopBitsStr
;
1884 UART_DEVICE_PATH
*Uart
;
1886 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1887 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1888 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1889 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1890 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
1891 MESSAGING_DEVICE_PATH
,
1893 (UINT16
) sizeof (UART_DEVICE_PATH
)
1896 if (StrCmp (BaudStr
, L
"DEFAULT") == 0) {
1897 Uart
->BaudRate
= 115200;
1899 Strtoi64 (BaudStr
, &Uart
->BaudRate
);
1901 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr
));
1902 switch (*ParityStr
) {
1928 Uart
->Parity
= (UINT8
) Strtoi (ParityStr
);
1932 if (StrCmp (StopBitsStr
, L
"D") == 0) {
1933 Uart
->StopBits
= (UINT8
) 0;
1934 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
1935 Uart
->StopBits
= (UINT8
) 1;
1936 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
1937 Uart
->StopBits
= (UINT8
) 2;
1938 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
1939 Uart
->StopBits
= (UINT8
) 3;
1941 Uart
->StopBits
= (UINT8
) Strtoi (StopBitsStr
);
1944 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
1948 Converts a text device path node to USB class device path structure.
1950 @param TextDeviceNode The input Text device path node.
1951 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
1953 @return A pointer to the newly-created USB class device path structure.
1956 EFI_DEVICE_PATH_PROTOCOL
*
1957 ConvertFromTextUsbClass (
1958 IN CHAR16
*TextDeviceNode
,
1959 IN USB_CLASS_TEXT
*UsbClassText
1965 CHAR16
*SubClassStr
;
1966 CHAR16
*ProtocolStr
;
1967 USB_CLASS_DEVICE_PATH
*UsbClass
;
1969 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
1970 MESSAGING_DEVICE_PATH
,
1972 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
1975 VIDStr
= GetNextParamStr (&TextDeviceNode
);
1976 PIDStr
= GetNextParamStr (&TextDeviceNode
);
1977 if (UsbClassText
->ClassExist
) {
1978 ClassStr
= GetNextParamStr (&TextDeviceNode
);
1979 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
1981 UsbClass
->DeviceClass
= UsbClassText
->Class
;
1983 if (UsbClassText
->SubClassExist
) {
1984 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
1985 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
1987 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
1990 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1992 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
1993 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
1994 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
1996 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
2001 Converts a text device path node to USB class device path structure.
2003 @param TextDeviceNode The input Text device path node.
2005 @return A pointer to the newly-created USB class device path structure.
2008 EFI_DEVICE_PATH_PROTOCOL
*
2009 DevPathFromTextUsbClass (
2010 IN CHAR16
*TextDeviceNode
2013 USB_CLASS_TEXT UsbClassText
;
2015 UsbClassText
.ClassExist
= TRUE
;
2016 UsbClassText
.SubClassExist
= TRUE
;
2018 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2022 Converts a text device path node to USB audio device path structure.
2024 @param TextDeviceNode The input Text device path node.
2026 @return A pointer to the newly-created USB audio device path structure.
2029 EFI_DEVICE_PATH_PROTOCOL
*
2030 DevPathFromTextUsbAudio (
2031 IN CHAR16
*TextDeviceNode
2034 USB_CLASS_TEXT UsbClassText
;
2036 UsbClassText
.ClassExist
= FALSE
;
2037 UsbClassText
.Class
= USB_CLASS_AUDIO
;
2038 UsbClassText
.SubClassExist
= TRUE
;
2040 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2044 Converts a text device path node to USB CDC Control device path structure.
2046 @param TextDeviceNode The input Text device path node.
2048 @return A pointer to the newly-created USB CDC Control device path structure.
2051 EFI_DEVICE_PATH_PROTOCOL
*
2052 DevPathFromTextUsbCDCControl (
2053 IN CHAR16
*TextDeviceNode
2056 USB_CLASS_TEXT UsbClassText
;
2058 UsbClassText
.ClassExist
= FALSE
;
2059 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
2060 UsbClassText
.SubClassExist
= TRUE
;
2062 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2066 Converts a text device path node to USB HID device path structure.
2068 @param TextDeviceNode The input Text device path node.
2070 @return A pointer to the newly-created USB HID device path structure.
2073 EFI_DEVICE_PATH_PROTOCOL
*
2074 DevPathFromTextUsbHID (
2075 IN CHAR16
*TextDeviceNode
2078 USB_CLASS_TEXT UsbClassText
;
2080 UsbClassText
.ClassExist
= FALSE
;
2081 UsbClassText
.Class
= USB_CLASS_HID
;
2082 UsbClassText
.SubClassExist
= TRUE
;
2084 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2088 Converts a text device path node to USB Image device path structure.
2090 @param TextDeviceNode The input Text device path node.
2092 @return A pointer to the newly-created USB Image device path structure.
2095 EFI_DEVICE_PATH_PROTOCOL
*
2096 DevPathFromTextUsbImage (
2097 IN CHAR16
*TextDeviceNode
2100 USB_CLASS_TEXT UsbClassText
;
2102 UsbClassText
.ClassExist
= FALSE
;
2103 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2104 UsbClassText
.SubClassExist
= TRUE
;
2106 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2110 Converts a text device path node to USB Print device path structure.
2112 @param TextDeviceNode The input Text device path node.
2114 @return A pointer to the newly-created USB Print device path structure.
2117 EFI_DEVICE_PATH_PROTOCOL
*
2118 DevPathFromTextUsbPrinter (
2119 IN CHAR16
*TextDeviceNode
2122 USB_CLASS_TEXT UsbClassText
;
2124 UsbClassText
.ClassExist
= FALSE
;
2125 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2126 UsbClassText
.SubClassExist
= TRUE
;
2128 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2132 Converts a text device path node to USB mass storage device path structure.
2134 @param TextDeviceNode The input Text device path node.
2136 @return A pointer to the newly-created USB mass storage device path structure.
2139 EFI_DEVICE_PATH_PROTOCOL
*
2140 DevPathFromTextUsbMassStorage (
2141 IN CHAR16
*TextDeviceNode
2144 USB_CLASS_TEXT UsbClassText
;
2146 UsbClassText
.ClassExist
= FALSE
;
2147 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2148 UsbClassText
.SubClassExist
= TRUE
;
2150 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2154 Converts a text device path node to USB HUB device path structure.
2156 @param TextDeviceNode The input Text device path node.
2158 @return A pointer to the newly-created USB HUB device path structure.
2161 EFI_DEVICE_PATH_PROTOCOL
*
2162 DevPathFromTextUsbHub (
2163 IN CHAR16
*TextDeviceNode
2166 USB_CLASS_TEXT UsbClassText
;
2168 UsbClassText
.ClassExist
= FALSE
;
2169 UsbClassText
.Class
= USB_CLASS_HUB
;
2170 UsbClassText
.SubClassExist
= TRUE
;
2172 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2176 Converts a text device path node to USB CDC data device path structure.
2178 @param TextDeviceNode The input Text device path node.
2180 @return A pointer to the newly-created USB CDC data device path structure.
2183 EFI_DEVICE_PATH_PROTOCOL
*
2184 DevPathFromTextUsbCDCData (
2185 IN CHAR16
*TextDeviceNode
2188 USB_CLASS_TEXT UsbClassText
;
2190 UsbClassText
.ClassExist
= FALSE
;
2191 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2192 UsbClassText
.SubClassExist
= TRUE
;
2194 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2198 Converts a text device path node to USB smart card device path structure.
2200 @param TextDeviceNode The input Text device path node.
2202 @return A pointer to the newly-created USB smart card device path structure.
2205 EFI_DEVICE_PATH_PROTOCOL
*
2206 DevPathFromTextUsbSmartCard (
2207 IN CHAR16
*TextDeviceNode
2210 USB_CLASS_TEXT UsbClassText
;
2212 UsbClassText
.ClassExist
= FALSE
;
2213 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2214 UsbClassText
.SubClassExist
= TRUE
;
2216 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2220 Converts a text device path node to USB video device path structure.
2222 @param TextDeviceNode The input Text device path node.
2224 @return A pointer to the newly-created USB video device path structure.
2227 EFI_DEVICE_PATH_PROTOCOL
*
2228 DevPathFromTextUsbVideo (
2229 IN CHAR16
*TextDeviceNode
2232 USB_CLASS_TEXT UsbClassText
;
2234 UsbClassText
.ClassExist
= FALSE
;
2235 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2236 UsbClassText
.SubClassExist
= TRUE
;
2238 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2242 Converts a text device path node to USB diagnostic device path structure.
2244 @param TextDeviceNode The input Text device path node.
2246 @return A pointer to the newly-created USB diagnostic device path structure.
2249 EFI_DEVICE_PATH_PROTOCOL
*
2250 DevPathFromTextUsbDiagnostic (
2251 IN CHAR16
*TextDeviceNode
2254 USB_CLASS_TEXT UsbClassText
;
2256 UsbClassText
.ClassExist
= FALSE
;
2257 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2258 UsbClassText
.SubClassExist
= TRUE
;
2260 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2264 Converts a text device path node to USB wireless device path structure.
2266 @param TextDeviceNode The input Text device path node.
2268 @return A pointer to the newly-created USB wireless device path structure.
2271 EFI_DEVICE_PATH_PROTOCOL
*
2272 DevPathFromTextUsbWireless (
2273 IN CHAR16
*TextDeviceNode
2276 USB_CLASS_TEXT UsbClassText
;
2278 UsbClassText
.ClassExist
= FALSE
;
2279 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2280 UsbClassText
.SubClassExist
= TRUE
;
2282 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2286 Converts a text device path node to USB device firmware update device path structure.
2288 @param TextDeviceNode The input Text device path node.
2290 @return A pointer to the newly-created USB device firmware update device path structure.
2293 EFI_DEVICE_PATH_PROTOCOL
*
2294 DevPathFromTextUsbDeviceFirmwareUpdate (
2295 IN CHAR16
*TextDeviceNode
2298 USB_CLASS_TEXT UsbClassText
;
2300 UsbClassText
.ClassExist
= FALSE
;
2301 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2302 UsbClassText
.SubClassExist
= FALSE
;
2303 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2305 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2309 Converts a text device path node to USB IRDA bridge device path structure.
2311 @param TextDeviceNode The input Text device path node.
2313 @return A pointer to the newly-created USB IRDA bridge device path structure.
2316 EFI_DEVICE_PATH_PROTOCOL
*
2317 DevPathFromTextUsbIrdaBridge (
2318 IN CHAR16
*TextDeviceNode
2321 USB_CLASS_TEXT UsbClassText
;
2323 UsbClassText
.ClassExist
= FALSE
;
2324 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2325 UsbClassText
.SubClassExist
= FALSE
;
2326 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2328 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2332 Converts a text device path node to USB text and measurement device path structure.
2334 @param TextDeviceNode The input Text device path node.
2336 @return A pointer to the newly-created USB text and measurement device path structure.
2339 EFI_DEVICE_PATH_PROTOCOL
*
2340 DevPathFromTextUsbTestAndMeasurement (
2341 IN CHAR16
*TextDeviceNode
2344 USB_CLASS_TEXT UsbClassText
;
2346 UsbClassText
.ClassExist
= FALSE
;
2347 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2348 UsbClassText
.SubClassExist
= FALSE
;
2349 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2351 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2355 Converts a text device path node to USB WWID device path structure.
2357 @param TextDeviceNode The input Text device path node.
2359 @return A pointer to the newly-created USB WWID device path structure.
2362 EFI_DEVICE_PATH_PROTOCOL
*
2363 DevPathFromTextUsbWwid (
2364 IN CHAR16
*TextDeviceNode
2369 CHAR16
*InterfaceNumStr
;
2370 CHAR16
*SerialNumberStr
;
2371 USB_WWID_DEVICE_PATH
*UsbWwid
;
2372 UINTN SerialNumberStrLen
;
2374 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2375 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2376 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2377 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2378 SerialNumberStrLen
= StrLen (SerialNumberStr
);
2379 if (SerialNumberStrLen
>= 2 &&
2380 SerialNumberStr
[0] == L
'\"' &&
2381 SerialNumberStr
[SerialNumberStrLen
- 1] == L
'\"'
2383 SerialNumberStr
[SerialNumberStrLen
- 1] = L
'\0';
2385 SerialNumberStrLen
-= 2;
2387 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2388 MESSAGING_DEVICE_PATH
,
2390 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + SerialNumberStrLen
* sizeof (CHAR16
))
2392 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2393 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2394 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2395 StrnCpy ((CHAR16
*) ((UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
)), SerialNumberStr
, SerialNumberStrLen
);
2397 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2401 Converts a text device path node to Logic Unit device path structure.
2403 @param TextDeviceNode The input Text device path node.
2405 @return A pointer to the newly-created Logic Unit device path structure.
2408 EFI_DEVICE_PATH_PROTOCOL
*
2409 DevPathFromTextUnit (
2410 IN CHAR16
*TextDeviceNode
2414 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2416 LunStr
= GetNextParamStr (&TextDeviceNode
);
2417 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2418 MESSAGING_DEVICE_PATH
,
2419 MSG_DEVICE_LOGICAL_UNIT_DP
,
2420 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2423 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2425 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2429 Converts a text device path node to iSCSI device path structure.
2431 @param TextDeviceNode The input Text device path node.
2433 @return A pointer to the newly-created iSCSI device path structure.
2436 EFI_DEVICE_PATH_PROTOCOL
*
2437 DevPathFromTextiSCSI (
2438 IN CHAR16
*TextDeviceNode
2443 CHAR16
*PortalGroupStr
;
2445 CHAR16
*HeaderDigestStr
;
2446 CHAR16
*DataDigestStr
;
2447 CHAR16
*AuthenticationStr
;
2448 CHAR16
*ProtocolStr
;
2450 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2452 NameStr
= GetNextParamStr (&TextDeviceNode
);
2453 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2454 LunStr
= GetNextParamStr (&TextDeviceNode
);
2455 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2456 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2457 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2458 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2459 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2460 MESSAGING_DEVICE_PATH
,
2462 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2465 AsciiStr
= ISCSIDevPath
->TargetName
;
2466 StrToAscii (NameStr
, &AsciiStr
);
2468 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2469 Strtoi64 (LunStr
, &ISCSIDevPath
->Lun
);
2472 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2476 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2480 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2484 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2488 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2490 ISCSIDevPath
->NetworkProtocol
= (UINT16
) StrCmp (ProtocolStr
, L
"TCP");
2492 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2496 Converts a text device path node to VLAN device path structure.
2498 @param TextDeviceNode The input Text device path node.
2500 @return A pointer to the newly-created VLAN device path structure.
2503 EFI_DEVICE_PATH_PROTOCOL
*
2504 DevPathFromTextVlan (
2505 IN CHAR16
*TextDeviceNode
2509 VLAN_DEVICE_PATH
*Vlan
;
2511 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2512 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2513 MESSAGING_DEVICE_PATH
,
2515 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2518 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2520 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2524 Converts a text device path node to HD device path structure.
2526 @param TextDeviceNode The input Text device path node.
2528 @return A pointer to the newly-created HD device path structure.
2531 EFI_DEVICE_PATH_PROTOCOL
*
2533 IN CHAR16
*TextDeviceNode
2536 CHAR16
*PartitionStr
;
2538 CHAR16
*SignatureStr
;
2542 EFI_GUID SignatureGuid
;
2543 HARDDRIVE_DEVICE_PATH
*Hd
;
2545 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2546 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2547 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2548 StartStr
= GetNextParamStr (&TextDeviceNode
);
2549 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2550 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2553 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2556 Hd
->PartitionNumber
= (UINT32
) Strtoi (PartitionStr
);
2558 ZeroMem (Hd
->Signature
, 16);
2559 Hd
->MBRType
= (UINT8
) 0;
2561 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2562 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2565 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2566 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2567 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2568 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2571 StrToGuid (SignatureStr
, &SignatureGuid
);
2572 CopyMem (Hd
->Signature
, &SignatureGuid
, sizeof (EFI_GUID
));
2574 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2577 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2578 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2580 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2584 Converts a text device path node to CDROM device path structure.
2586 @param TextDeviceNode The input Text device path node.
2588 @return A pointer to the newly-created CDROM device path structure.
2591 EFI_DEVICE_PATH_PROTOCOL
*
2592 DevPathFromTextCDROM (
2593 IN CHAR16
*TextDeviceNode
2599 CDROM_DEVICE_PATH
*CDROMDevPath
;
2601 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2602 StartStr
= GetNextParamStr (&TextDeviceNode
);
2603 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2604 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2607 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2610 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2611 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2612 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2614 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2618 Converts a text device path node to Vendor-defined media device path structure.
2620 @param TextDeviceNode The input Text device path node.
2622 @return A pointer to the newly-created Vendor-defined media device path structure.
2625 EFI_DEVICE_PATH_PROTOCOL
*
2626 DevPathFromTextVenMedia (
2627 IN CHAR16
*TextDeviceNode
2630 return ConvertFromTextVendor (
2638 Converts a text device path node to File device path structure.
2640 @param TextDeviceNode The input Text device path node.
2642 @return A pointer to the newly-created File device path structure.
2645 EFI_DEVICE_PATH_PROTOCOL
*
2646 DevPathFromTextFilePath (
2647 IN CHAR16
*TextDeviceNode
2650 FILEPATH_DEVICE_PATH
*File
;
2652 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2655 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
2658 StrCpy (File
->PathName
, TextDeviceNode
);
2660 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
2664 Converts a text device path node to Media protocol device path structure.
2666 @param TextDeviceNode The input Text device path node.
2668 @return A pointer to the newly-created Media protocol device path structure.
2671 EFI_DEVICE_PATH_PROTOCOL
*
2672 DevPathFromTextMedia (
2673 IN CHAR16
*TextDeviceNode
2677 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
2679 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2680 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
2683 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
2686 StrToGuid (GuidStr
, &Media
->Protocol
);
2688 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
2692 Converts a text device path node to firmware volume device path structure.
2694 @param TextDeviceNode The input Text device path node.
2696 @return A pointer to the newly-created firmware volume device path structure.
2699 EFI_DEVICE_PATH_PROTOCOL
*
2701 IN CHAR16
*TextDeviceNode
2705 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
2707 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2708 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
2710 MEDIA_PIWG_FW_VOL_DP
,
2711 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
2714 StrToGuid (GuidStr
, &Fv
->FvName
);
2716 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
2720 Converts a text device path node to firmware file device path structure.
2722 @param TextDeviceNode The input Text device path node.
2724 @return A pointer to the newly-created firmware file device path structure.
2727 EFI_DEVICE_PATH_PROTOCOL
*
2728 DevPathFromTextFvFile (
2729 IN CHAR16
*TextDeviceNode
2733 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
2735 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2736 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2738 MEDIA_PIWG_FW_FILE_DP
,
2739 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
2742 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
2744 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
2748 Converts a text device path node to text relative offset device path structure.
2750 @param TextDeviceNode The input Text device path node.
2752 @return A pointer to the newly-created Text device path structure.
2755 EFI_DEVICE_PATH_PROTOCOL
*
2756 DevPathFromTextRelativeOffsetRange (
2757 IN CHAR16
*TextDeviceNode
2760 CHAR16
*StartingOffsetStr
;
2761 CHAR16
*EndingOffsetStr
;
2762 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
2764 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2765 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2766 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
2768 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
2769 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
2772 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
2773 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
2775 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
2779 Converts a text device path node to BIOS Boot Specification device path structure.
2781 @param TextDeviceNode The input Text device path node.
2783 @return A pointer to the newly-created BIOS Boot Specification device path structure.
2786 EFI_DEVICE_PATH_PROTOCOL
*
2787 DevPathFromTextBBS (
2788 IN CHAR16
*TextDeviceNode
2795 BBS_BBS_DEVICE_PATH
*Bbs
;
2797 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2798 IdStr
= GetNextParamStr (&TextDeviceNode
);
2799 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
2800 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
2803 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
2806 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
2807 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
2808 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
2809 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
2810 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
2811 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
2812 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
2813 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
2814 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
2815 Bbs
->DeviceType
= BBS_TYPE_USB
;
2816 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
2817 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
2819 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
2822 AsciiStr
= Bbs
->String
;
2823 StrToAscii (IdStr
, &AsciiStr
);
2825 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
2827 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
2831 Converts a text device path node to SATA device path structure.
2833 @param TextDeviceNode The input Text device path node.
2835 @return A pointer to the newly-created SATA device path structure.
2838 EFI_DEVICE_PATH_PROTOCOL
*
2839 DevPathFromTextSata (
2840 IN CHAR16
*TextDeviceNode
2843 SATA_DEVICE_PATH
*Sata
;
2848 Param1
= GetNextParamStr (&TextDeviceNode
);
2849 Param2
= GetNextParamStr (&TextDeviceNode
);
2850 Param3
= GetNextParamStr (&TextDeviceNode
);
2852 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
2853 MESSAGING_DEVICE_PATH
,
2855 (UINT16
) sizeof (SATA_DEVICE_PATH
)
2857 Sata
->HBAPortNumber
= (UINT16
) Strtoi (Param1
);
2858 Sata
->PortMultiplierPortNumber
= (UINT16
) Strtoi (Param2
);
2859 Sata
->Lun
= (UINT16
) Strtoi (Param3
);
2861 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
2864 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
2865 {L
"Pci", DevPathFromTextPci
},
2866 {L
"PcCard", DevPathFromTextPcCard
},
2867 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
2868 {L
"VenHw", DevPathFromTextVenHw
},
2869 {L
"Ctrl", DevPathFromTextCtrl
},
2870 {L
"Acpi", DevPathFromTextAcpi
},
2871 {L
"PciRoot", DevPathFromTextPciRoot
},
2872 {L
"PcieRoot", DevPathFromTextPcieRoot
},
2873 {L
"Floppy", DevPathFromTextFloppy
},
2874 {L
"Keyboard", DevPathFromTextKeyboard
},
2875 {L
"Serial", DevPathFromTextSerial
},
2876 {L
"ParallelPort", DevPathFromTextParallelPort
},
2877 {L
"AcpiEx", DevPathFromTextAcpiEx
},
2878 {L
"AcpiExp", DevPathFromTextAcpiExp
},
2879 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
2880 {L
"Ata", DevPathFromTextAta
},
2881 {L
"Scsi", DevPathFromTextScsi
},
2882 {L
"Fibre", DevPathFromTextFibre
},
2883 {L
"FibreEx", DevPathFromTextFibreEx
},
2884 {L
"I1394", DevPathFromText1394
},
2885 {L
"USB", DevPathFromTextUsb
},
2886 {L
"I2O", DevPathFromTextI2O
},
2887 {L
"Infiniband", DevPathFromTextInfiniband
},
2888 {L
"VenMsg", DevPathFromTextVenMsg
},
2889 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
2890 {L
"VenVt100", DevPathFromTextVenVt100
},
2891 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
2892 {L
"VenUtf8", DevPathFromTextVenUtf8
},
2893 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
2894 {L
"SAS", DevPathFromTextSAS
},
2895 {L
"SasEx", DevPathFromTextSasEx
},
2896 {L
"DebugPort", DevPathFromTextDebugPort
},
2897 {L
"MAC", DevPathFromTextMAC
},
2898 {L
"IPv4", DevPathFromTextIPv4
},
2899 {L
"IPv6", DevPathFromTextIPv6
},
2900 {L
"Uart", DevPathFromTextUart
},
2901 {L
"UsbClass", DevPathFromTextUsbClass
},
2902 {L
"UsbAudio", DevPathFromTextUsbAudio
},
2903 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
2904 {L
"UsbHID", DevPathFromTextUsbHID
},
2905 {L
"UsbImage", DevPathFromTextUsbImage
},
2906 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
2907 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
2908 {L
"UsbHub", DevPathFromTextUsbHub
},
2909 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
2910 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
2911 {L
"UsbVideo", DevPathFromTextUsbVideo
},
2912 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
2913 {L
"UsbWireless", DevPathFromTextUsbWireless
},
2914 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
2915 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
2916 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
2917 {L
"UsbWwid", DevPathFromTextUsbWwid
},
2918 {L
"Unit", DevPathFromTextUnit
},
2919 {L
"iSCSI", DevPathFromTextiSCSI
},
2920 {L
"Vlan", DevPathFromTextVlan
},
2921 {L
"HD", DevPathFromTextHD
},
2922 {L
"CDROM", DevPathFromTextCDROM
},
2923 {L
"VenMedia", DevPathFromTextVenMedia
},
2924 {L
"Media", DevPathFromTextMedia
},
2925 {L
"Fv", DevPathFromTextFv
},
2926 {L
"FvFile", DevPathFromTextFvFile
},
2927 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
2928 {L
"BBS", DevPathFromTextBBS
},
2929 {L
"Sata", DevPathFromTextSata
},
2934 Convert text to the binary representation of a device node.
2936 @param TextDeviceNode TextDeviceNode points to the text representation of a device
2937 node. Conversion starts with the first character and continues
2938 until the first non-device node character.
2940 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
2941 insufficient memory or text unsupported.
2944 EFI_DEVICE_PATH_PROTOCOL
*
2946 UefiDevicePathLibConvertTextToDeviceNode (
2947 IN CONST CHAR16
*TextDeviceNode
2950 DEVICE_PATH_FROM_TEXT FromText
;
2952 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
2953 CHAR16
*DeviceNodeStr
;
2956 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
2962 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
2963 ASSERT (DeviceNodeStr
!= NULL
);
2965 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
2966 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
2967 if (ParamStr
!= NULL
) {
2968 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
2973 if (FromText
== NULL
) {
2977 FromText
= DevPathFromTextFilePath
;
2978 DeviceNode
= FromText (DeviceNodeStr
);
2980 DeviceNode
= FromText (ParamStr
);
2981 FreePool (ParamStr
);
2984 FreePool (DeviceNodeStr
);
2990 Convert text to the binary representation of a device path.
2993 @param TextDevicePath TextDevicePath points to the text representation of a device
2994 path. Conversion starts with the first character and continues
2995 until the first non-device node character.
2997 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
2998 there was insufficient memory.
3001 EFI_DEVICE_PATH_PROTOCOL
*
3003 UefiDevicePathLibConvertTextToDevicePath (
3004 IN CONST CHAR16
*TextDevicePath
3007 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3008 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3009 CHAR16
*DevicePathStr
;
3011 CHAR16
*DeviceNodeStr
;
3012 BOOLEAN IsInstanceEnd
;
3013 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3015 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3019 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3020 ASSERT (DevicePath
!= NULL
);
3021 SetDevicePathEndNode (DevicePath
);
3023 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3025 Str
= DevicePathStr
;
3026 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3027 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3029 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3030 FreePool (DevicePath
);
3031 FreePool (DeviceNode
);
3032 DevicePath
= NewDevicePath
;
3034 if (IsInstanceEnd
) {
3035 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3036 ASSERT (DeviceNode
!= NULL
);
3037 SetDevicePathEndNode (DeviceNode
);
3039 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3040 FreePool (DevicePath
);
3041 FreePool (DeviceNode
);
3042 DevicePath
= NewDevicePath
;
3046 FreePool (DevicePathStr
);