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
) StrDecimalToUintn (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 Atapi
->PrimarySecondary
= (UINT8
) ((StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) ? 0 : 1);
1077 Atapi
->SlaveMaster
= (UINT8
) ((StrCmp (SlaveMasterStr
, L
"Master") == 0) ? 0 : 1);
1078 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
1080 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
1084 Converts a text device path node to SCSI device path structure.
1086 @param TextDeviceNode The input Text device path node.
1088 @return A pointer to the newly-created SCSI device path structure.
1091 EFI_DEVICE_PATH_PROTOCOL
*
1092 DevPathFromTextScsi (
1093 IN CHAR16
*TextDeviceNode
1098 SCSI_DEVICE_PATH
*Scsi
;
1100 PunStr
= GetNextParamStr (&TextDeviceNode
);
1101 LunStr
= GetNextParamStr (&TextDeviceNode
);
1102 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
1103 MESSAGING_DEVICE_PATH
,
1105 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
1108 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
1109 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
1111 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
1115 Converts a text device path node to Fibre device path structure.
1117 @param TextDeviceNode The input Text device path node.
1119 @return A pointer to the newly-created Fibre device path structure.
1122 EFI_DEVICE_PATH_PROTOCOL
*
1123 DevPathFromTextFibre (
1124 IN CHAR16
*TextDeviceNode
1129 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
1131 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1132 LunStr
= GetNextParamStr (&TextDeviceNode
);
1133 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
1134 MESSAGING_DEVICE_PATH
,
1135 MSG_FIBRECHANNEL_DP
,
1136 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
1139 Fibre
->Reserved
= 0;
1140 Strtoi64 (WWNStr
, &Fibre
->WWN
);
1141 Strtoi64 (LunStr
, &Fibre
->Lun
);
1143 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
1147 Converts a text device path node to FibreEx device path structure.
1149 @param TextDeviceNode The input Text device path node.
1151 @return A pointer to the newly-created FibreEx device path structure.
1154 EFI_DEVICE_PATH_PROTOCOL
*
1155 DevPathFromTextFibreEx (
1156 IN CHAR16
*TextDeviceNode
1161 FIBRECHANNELEX_DEVICE_PATH
*FibreEx
;
1163 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1164 LunStr
= GetNextParamStr (&TextDeviceNode
);
1165 FibreEx
= (FIBRECHANNELEX_DEVICE_PATH
*) CreateDeviceNode (
1166 MESSAGING_DEVICE_PATH
,
1167 MSG_FIBRECHANNELEX_DP
,
1168 (UINT16
) sizeof (FIBRECHANNELEX_DEVICE_PATH
)
1171 FibreEx
->Reserved
= 0;
1172 Strtoi64 (WWNStr
, (UINT64
*) (&FibreEx
->WWN
));
1173 Strtoi64 (LunStr
, (UINT64
*) (&FibreEx
->Lun
));
1175 *(UINT64
*) (&FibreEx
->WWN
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->WWN
));
1176 *(UINT64
*) (&FibreEx
->Lun
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->Lun
));
1178 return (EFI_DEVICE_PATH_PROTOCOL
*) FibreEx
;
1182 Converts a text device path node to 1394 device path structure.
1184 @param TextDeviceNode The input Text device path node.
1186 @return A pointer to the newly-created 1394 device path structure.
1189 EFI_DEVICE_PATH_PROTOCOL
*
1190 DevPathFromText1394 (
1191 IN CHAR16
*TextDeviceNode
1195 F1394_DEVICE_PATH
*F1394DevPath
;
1197 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1198 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1199 MESSAGING_DEVICE_PATH
,
1201 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1204 F1394DevPath
->Reserved
= 0;
1205 F1394DevPath
->Guid
= StrHexToUint64 (GuidStr
);
1207 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1211 Converts a text device path node to USB device path structure.
1213 @param TextDeviceNode The input Text device path node.
1215 @return A pointer to the newly-created USB device path structure.
1218 EFI_DEVICE_PATH_PROTOCOL
*
1219 DevPathFromTextUsb (
1220 IN CHAR16
*TextDeviceNode
1224 CHAR16
*InterfaceStr
;
1225 USB_DEVICE_PATH
*Usb
;
1227 PortStr
= GetNextParamStr (&TextDeviceNode
);
1228 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1229 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1230 MESSAGING_DEVICE_PATH
,
1232 (UINT16
) sizeof (USB_DEVICE_PATH
)
1235 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1236 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1238 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1242 Converts a text device path node to I20 device path structure.
1244 @param TextDeviceNode The input Text device path node.
1246 @return A pointer to the newly-created I20 device path structure.
1249 EFI_DEVICE_PATH_PROTOCOL
*
1250 DevPathFromTextI2O (
1251 IN CHAR16
*TextDeviceNode
1255 I2O_DEVICE_PATH
*I2ODevPath
;
1257 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1258 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1259 MESSAGING_DEVICE_PATH
,
1261 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1264 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1266 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1270 Converts a text device path node to Infini Band device path structure.
1272 @param TextDeviceNode The input Text device path node.
1274 @return A pointer to the newly-created Infini Band device path structure.
1277 EFI_DEVICE_PATH_PROTOCOL
*
1278 DevPathFromTextInfiniband (
1279 IN CHAR16
*TextDeviceNode
1288 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1290 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1291 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1292 SidStr
= GetNextParamStr (&TextDeviceNode
);
1293 TidStr
= GetNextParamStr (&TextDeviceNode
);
1294 DidStr
= GetNextParamStr (&TextDeviceNode
);
1295 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1296 MESSAGING_DEVICE_PATH
,
1298 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1301 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1302 StrToGuid (GuidStr
, &PortGid
);
1303 CopyMem (InfiniBand
->PortGid
, &PortGid
, sizeof (EFI_GUID
));
1304 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1305 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1306 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1308 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1312 Converts a text device path node to Vendor-Defined Messaging device path structure.
1314 @param TextDeviceNode The input Text device path node.
1316 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1319 EFI_DEVICE_PATH_PROTOCOL
*
1320 DevPathFromTextVenMsg (
1321 IN CHAR16
*TextDeviceNode
1324 return ConvertFromTextVendor (
1326 MESSAGING_DEVICE_PATH
,
1332 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1334 @param TextDeviceNode The input Text device path node.
1336 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1339 EFI_DEVICE_PATH_PROTOCOL
*
1340 DevPathFromTextVenPcAnsi (
1341 IN CHAR16
*TextDeviceNode
1344 VENDOR_DEVICE_PATH
*Vendor
;
1346 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1347 MESSAGING_DEVICE_PATH
,
1349 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1350 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1352 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1356 Converts a text device path node to Vendor defined VT100 device path structure.
1358 @param TextDeviceNode The input Text device path node.
1360 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1363 EFI_DEVICE_PATH_PROTOCOL
*
1364 DevPathFromTextVenVt100 (
1365 IN CHAR16
*TextDeviceNode
1368 VENDOR_DEVICE_PATH
*Vendor
;
1370 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1371 MESSAGING_DEVICE_PATH
,
1373 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1374 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1376 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1380 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1382 @param TextDeviceNode The input Text device path node.
1384 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1387 EFI_DEVICE_PATH_PROTOCOL
*
1388 DevPathFromTextVenVt100Plus (
1389 IN CHAR16
*TextDeviceNode
1392 VENDOR_DEVICE_PATH
*Vendor
;
1394 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1395 MESSAGING_DEVICE_PATH
,
1397 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1398 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1400 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1404 Converts a text device path node to Vendor defined UTF8 device path structure.
1406 @param TextDeviceNode The input Text device path node.
1408 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1411 EFI_DEVICE_PATH_PROTOCOL
*
1412 DevPathFromTextVenUtf8 (
1413 IN CHAR16
*TextDeviceNode
1416 VENDOR_DEVICE_PATH
*Vendor
;
1418 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1419 MESSAGING_DEVICE_PATH
,
1421 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1422 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1424 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1428 Converts a text device path node to UART Flow Control device path structure.
1430 @param TextDeviceNode The input Text device path node.
1432 @return A pointer to the newly-created UART Flow Control device path structure.
1435 EFI_DEVICE_PATH_PROTOCOL
*
1436 DevPathFromTextUartFlowCtrl (
1437 IN CHAR16
*TextDeviceNode
1441 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1443 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1444 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1445 MESSAGING_DEVICE_PATH
,
1447 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1450 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1451 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1452 UartFlowControl
->FlowControlMap
= 2;
1453 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1454 UartFlowControl
->FlowControlMap
= 1;
1456 UartFlowControl
->FlowControlMap
= 0;
1459 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1463 Converts a text device path node to Serial Attached SCSI device path structure.
1465 @param TextDeviceNode The input Text device path node.
1467 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1470 EFI_DEVICE_PATH_PROTOCOL
*
1471 DevPathFromTextSAS (
1472 IN CHAR16
*TextDeviceNode
1479 CHAR16
*LocationStr
;
1481 CHAR16
*DriveBayStr
;
1482 CHAR16
*ReservedStr
;
1485 SAS_DEVICE_PATH
*Sas
;
1487 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1488 LunStr
= GetNextParamStr (&TextDeviceNode
);
1489 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1490 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1491 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1492 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1493 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1494 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1495 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1496 MESSAGING_DEVICE_PATH
,
1498 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1501 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1502 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1503 Strtoi64 (LunStr
, &Sas
->Lun
);
1504 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1506 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1509 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1511 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1515 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1518 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1523 // Location is an integer between 0 and 1 or else
1524 // the keyword Internal (0) or External (1).
1526 if (StrCmp (LocationStr
, L
"External") == 0) {
1528 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1531 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1533 Info
|= (Uint16
<< 5);
1536 // Connect is an integer between 0 and 3 or else
1537 // the keyword Direct (0) or Expanded (1).
1539 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1541 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1544 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1546 Info
|= (Uint16
<< 6);
1549 Info
= (UINT16
) Strtoi (SASSATAStr
);
1552 Sas
->DeviceTopology
= Info
;
1553 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1555 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1559 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1561 @param TextDeviceNode The input Text device path node.
1563 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1566 EFI_DEVICE_PATH_PROTOCOL
*
1567 DevPathFromTextSasEx (
1568 IN CHAR16
*TextDeviceNode
1575 CHAR16
*LocationStr
;
1577 CHAR16
*DriveBayStr
;
1582 SASEX_DEVICE_PATH
*SasEx
;
1584 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1585 LunStr
= GetNextParamStr (&TextDeviceNode
);
1586 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1587 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1588 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1589 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1590 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1591 SasEx
= (SASEX_DEVICE_PATH
*) CreateDeviceNode (
1592 MESSAGING_DEVICE_PATH
,
1594 (UINT16
) sizeof (SASEX_DEVICE_PATH
)
1597 Strtoi64 (AddressStr
, &SasAddress
);
1598 Strtoi64 (LunStr
, &Lun
);
1599 WriteUnaligned64 ((UINT64
*) &SasEx
->SasAddress
, SwapBytes64 (SasAddress
));
1600 WriteUnaligned64 ((UINT64
*) &SasEx
->Lun
, SwapBytes64 (Lun
));
1601 SasEx
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1603 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1606 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1608 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1612 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1615 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1620 // Location is an integer between 0 and 1 or else
1621 // the keyword Internal (0) or External (1).
1623 if (StrCmp (LocationStr
, L
"External") == 0) {
1625 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1628 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1630 Info
|= (Uint16
<< 5);
1633 // Connect is an integer between 0 and 3 or else
1634 // the keyword Direct (0) or Expanded (1).
1636 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1638 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1641 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1643 Info
|= (Uint16
<< 6);
1646 Info
= (UINT16
) Strtoi (SASSATAStr
);
1649 SasEx
->DeviceTopology
= Info
;
1651 return (EFI_DEVICE_PATH_PROTOCOL
*) SasEx
;
1655 Converts a text device path node to Debug Port device path structure.
1657 @param TextDeviceNode The input Text device path node.
1659 @return A pointer to the newly-created Debug Port device path structure.
1662 EFI_DEVICE_PATH_PROTOCOL
*
1663 DevPathFromTextDebugPort (
1664 IN CHAR16
*TextDeviceNode
1667 VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*Vend
;
1669 Vend
= (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*) CreateDeviceNode (
1670 MESSAGING_DEVICE_PATH
,
1672 (UINT16
) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
)
1675 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1677 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1681 Converts a text device path node to MAC device path structure.
1683 @param TextDeviceNode The input Text device path node.
1685 @return A pointer to the newly-created MAC device path structure.
1688 EFI_DEVICE_PATH_PROTOCOL
*
1689 DevPathFromTextMAC (
1690 IN CHAR16
*TextDeviceNode
1696 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1698 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1699 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1700 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1701 MESSAGING_DEVICE_PATH
,
1703 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1706 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1708 Length
= sizeof (EFI_MAC_ADDRESS
);
1709 StrToBuf (&MACDevPath
->MacAddress
.Addr
[0], Length
, AddressStr
);
1711 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1716 Converts a text format to the network protocol ID.
1718 @param Text String of protocol field.
1720 @return Network protocol ID .
1724 NetworkProtocolFromText (
1728 if (StrCmp (Text
, L
"UDP") == 0) {
1729 return RFC_1700_UDP_PROTOCOL
;
1732 if (StrCmp (Text
, L
"TCP") == 0) {
1733 return RFC_1700_TCP_PROTOCOL
;
1736 return Strtoi (Text
);
1741 Converts a text device path node to IPV4 device path structure.
1743 @param TextDeviceNode The input Text device path node.
1745 @return A pointer to the newly-created IPV4 device path structure.
1748 EFI_DEVICE_PATH_PROTOCOL
*
1749 DevPathFromTextIPv4 (
1750 IN CHAR16
*TextDeviceNode
1753 CHAR16
*RemoteIPStr
;
1754 CHAR16
*ProtocolStr
;
1757 CHAR16
*GatewayIPStr
;
1758 CHAR16
*SubnetMaskStr
;
1759 IPv4_DEVICE_PATH
*IPv4
;
1761 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1762 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1763 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1764 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1765 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1766 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
1767 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1768 MESSAGING_DEVICE_PATH
,
1770 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
1773 StrToIPv4Addr (&RemoteIPStr
, &IPv4
->RemoteIpAddress
);
1774 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1775 if (StrCmp (TypeStr
, L
"Static") == 0) {
1776 IPv4
->StaticIpAddress
= TRUE
;
1778 IPv4
->StaticIpAddress
= FALSE
;
1781 StrToIPv4Addr (&LocalIPStr
, &IPv4
->LocalIpAddress
);
1782 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
1783 StrToIPv4Addr (&GatewayIPStr
, &IPv4
->GatewayIpAddress
);
1784 StrToIPv4Addr (&SubnetMaskStr
, &IPv4
->SubnetMask
);
1786 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
1787 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
1790 IPv4
->LocalPort
= 0;
1791 IPv4
->RemotePort
= 0;
1793 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1797 Converts a text device path node to IPV6 device path structure.
1799 @param TextDeviceNode The input Text device path node.
1801 @return A pointer to the newly-created IPV6 device path structure.
1804 EFI_DEVICE_PATH_PROTOCOL
*
1805 DevPathFromTextIPv6 (
1806 IN CHAR16
*TextDeviceNode
1809 CHAR16
*RemoteIPStr
;
1810 CHAR16
*ProtocolStr
;
1813 CHAR16
*GatewayIPStr
;
1814 CHAR16
*PrefixLengthStr
;
1815 IPv6_DEVICE_PATH
*IPv6
;
1817 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1818 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1819 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1820 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1821 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
1822 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1823 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1824 MESSAGING_DEVICE_PATH
,
1826 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
1829 StrToIPv6Addr (&RemoteIPStr
, &IPv6
->RemoteIpAddress
);
1830 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1831 if (StrCmp (TypeStr
, L
"Static") == 0) {
1832 IPv6
->IpAddressOrigin
= 0;
1833 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
1834 IPv6
->IpAddressOrigin
= 1;
1836 IPv6
->IpAddressOrigin
= 2;
1839 StrToIPv6Addr (&LocalIPStr
, &IPv6
->LocalIpAddress
);
1840 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
1841 StrToIPv6Addr (&GatewayIPStr
, &IPv6
->GatewayIpAddress
);
1842 IPv6
->PrefixLength
= (UINT8
) Strtoi (PrefixLengthStr
);
1844 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
1845 IPv6
->PrefixLength
= 0;
1848 IPv6
->LocalPort
= 0;
1849 IPv6
->RemotePort
= 0;
1851 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
1855 Converts a text device path node to UART device path structure.
1857 @param TextDeviceNode The input Text device path node.
1859 @return A pointer to the newly-created UART device path structure.
1862 EFI_DEVICE_PATH_PROTOCOL
*
1863 DevPathFromTextUart (
1864 IN CHAR16
*TextDeviceNode
1868 CHAR16
*DataBitsStr
;
1870 CHAR16
*StopBitsStr
;
1871 UART_DEVICE_PATH
*Uart
;
1873 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1874 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1875 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1876 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1877 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
1878 MESSAGING_DEVICE_PATH
,
1880 (UINT16
) sizeof (UART_DEVICE_PATH
)
1883 Uart
->BaudRate
= (StrCmp (BaudStr
, L
"DEFAULT") == 0) ? 115200 : StrDecimalToUintn (BaudStr
);
1884 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : StrDecimalToUintn (DataBitsStr
));
1885 switch (*ParityStr
) {
1911 Uart
->Parity
= 0xff;
1914 if (StrCmp (StopBitsStr
, L
"D") == 0) {
1915 Uart
->StopBits
= (UINT8
) 0;
1916 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
1917 Uart
->StopBits
= (UINT8
) 1;
1918 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
1919 Uart
->StopBits
= (UINT8
) 2;
1920 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
1921 Uart
->StopBits
= (UINT8
) 3;
1923 Uart
->StopBits
= 0xff;
1926 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
1930 Converts a text device path node to USB class device path structure.
1932 @param TextDeviceNode The input Text device path node.
1933 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
1935 @return A pointer to the newly-created USB class device path structure.
1938 EFI_DEVICE_PATH_PROTOCOL
*
1939 ConvertFromTextUsbClass (
1940 IN CHAR16
*TextDeviceNode
,
1941 IN USB_CLASS_TEXT
*UsbClassText
1947 CHAR16
*SubClassStr
;
1948 CHAR16
*ProtocolStr
;
1949 USB_CLASS_DEVICE_PATH
*UsbClass
;
1951 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
1952 MESSAGING_DEVICE_PATH
,
1954 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
1957 VIDStr
= GetNextParamStr (&TextDeviceNode
);
1958 PIDStr
= GetNextParamStr (&TextDeviceNode
);
1959 if (UsbClassText
->ClassExist
) {
1960 ClassStr
= GetNextParamStr (&TextDeviceNode
);
1961 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
1963 UsbClass
->DeviceClass
= UsbClassText
->Class
;
1965 if (UsbClassText
->SubClassExist
) {
1966 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
1967 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
1969 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
1972 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1974 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
1975 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
1976 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
1978 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
1983 Converts a text device path node to USB class device path structure.
1985 @param TextDeviceNode The input Text device path node.
1987 @return A pointer to the newly-created USB class device path structure.
1990 EFI_DEVICE_PATH_PROTOCOL
*
1991 DevPathFromTextUsbClass (
1992 IN CHAR16
*TextDeviceNode
1995 USB_CLASS_TEXT UsbClassText
;
1997 UsbClassText
.ClassExist
= TRUE
;
1998 UsbClassText
.SubClassExist
= TRUE
;
2000 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2004 Converts a text device path node to USB audio device path structure.
2006 @param TextDeviceNode The input Text device path node.
2008 @return A pointer to the newly-created USB audio device path structure.
2011 EFI_DEVICE_PATH_PROTOCOL
*
2012 DevPathFromTextUsbAudio (
2013 IN CHAR16
*TextDeviceNode
2016 USB_CLASS_TEXT UsbClassText
;
2018 UsbClassText
.ClassExist
= FALSE
;
2019 UsbClassText
.Class
= USB_CLASS_AUDIO
;
2020 UsbClassText
.SubClassExist
= TRUE
;
2022 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2026 Converts a text device path node to USB CDC Control device path structure.
2028 @param TextDeviceNode The input Text device path node.
2030 @return A pointer to the newly-created USB CDC Control device path structure.
2033 EFI_DEVICE_PATH_PROTOCOL
*
2034 DevPathFromTextUsbCDCControl (
2035 IN CHAR16
*TextDeviceNode
2038 USB_CLASS_TEXT UsbClassText
;
2040 UsbClassText
.ClassExist
= FALSE
;
2041 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
2042 UsbClassText
.SubClassExist
= TRUE
;
2044 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2048 Converts a text device path node to USB HID device path structure.
2050 @param TextDeviceNode The input Text device path node.
2052 @return A pointer to the newly-created USB HID device path structure.
2055 EFI_DEVICE_PATH_PROTOCOL
*
2056 DevPathFromTextUsbHID (
2057 IN CHAR16
*TextDeviceNode
2060 USB_CLASS_TEXT UsbClassText
;
2062 UsbClassText
.ClassExist
= FALSE
;
2063 UsbClassText
.Class
= USB_CLASS_HID
;
2064 UsbClassText
.SubClassExist
= TRUE
;
2066 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2070 Converts a text device path node to USB Image device path structure.
2072 @param TextDeviceNode The input Text device path node.
2074 @return A pointer to the newly-created USB Image device path structure.
2077 EFI_DEVICE_PATH_PROTOCOL
*
2078 DevPathFromTextUsbImage (
2079 IN CHAR16
*TextDeviceNode
2082 USB_CLASS_TEXT UsbClassText
;
2084 UsbClassText
.ClassExist
= FALSE
;
2085 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2086 UsbClassText
.SubClassExist
= TRUE
;
2088 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2092 Converts a text device path node to USB Print device path structure.
2094 @param TextDeviceNode The input Text device path node.
2096 @return A pointer to the newly-created USB Print device path structure.
2099 EFI_DEVICE_PATH_PROTOCOL
*
2100 DevPathFromTextUsbPrinter (
2101 IN CHAR16
*TextDeviceNode
2104 USB_CLASS_TEXT UsbClassText
;
2106 UsbClassText
.ClassExist
= FALSE
;
2107 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2108 UsbClassText
.SubClassExist
= TRUE
;
2110 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2114 Converts a text device path node to USB mass storage device path structure.
2116 @param TextDeviceNode The input Text device path node.
2118 @return A pointer to the newly-created USB mass storage device path structure.
2121 EFI_DEVICE_PATH_PROTOCOL
*
2122 DevPathFromTextUsbMassStorage (
2123 IN CHAR16
*TextDeviceNode
2126 USB_CLASS_TEXT UsbClassText
;
2128 UsbClassText
.ClassExist
= FALSE
;
2129 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2130 UsbClassText
.SubClassExist
= TRUE
;
2132 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2136 Converts a text device path node to USB HUB device path structure.
2138 @param TextDeviceNode The input Text device path node.
2140 @return A pointer to the newly-created USB HUB device path structure.
2143 EFI_DEVICE_PATH_PROTOCOL
*
2144 DevPathFromTextUsbHub (
2145 IN CHAR16
*TextDeviceNode
2148 USB_CLASS_TEXT UsbClassText
;
2150 UsbClassText
.ClassExist
= FALSE
;
2151 UsbClassText
.Class
= USB_CLASS_HUB
;
2152 UsbClassText
.SubClassExist
= TRUE
;
2154 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2158 Converts a text device path node to USB CDC data device path structure.
2160 @param TextDeviceNode The input Text device path node.
2162 @return A pointer to the newly-created USB CDC data device path structure.
2165 EFI_DEVICE_PATH_PROTOCOL
*
2166 DevPathFromTextUsbCDCData (
2167 IN CHAR16
*TextDeviceNode
2170 USB_CLASS_TEXT UsbClassText
;
2172 UsbClassText
.ClassExist
= FALSE
;
2173 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2174 UsbClassText
.SubClassExist
= TRUE
;
2176 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2180 Converts a text device path node to USB smart card device path structure.
2182 @param TextDeviceNode The input Text device path node.
2184 @return A pointer to the newly-created USB smart card device path structure.
2187 EFI_DEVICE_PATH_PROTOCOL
*
2188 DevPathFromTextUsbSmartCard (
2189 IN CHAR16
*TextDeviceNode
2192 USB_CLASS_TEXT UsbClassText
;
2194 UsbClassText
.ClassExist
= FALSE
;
2195 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2196 UsbClassText
.SubClassExist
= TRUE
;
2198 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2202 Converts a text device path node to USB video device path structure.
2204 @param TextDeviceNode The input Text device path node.
2206 @return A pointer to the newly-created USB video device path structure.
2209 EFI_DEVICE_PATH_PROTOCOL
*
2210 DevPathFromTextUsbVideo (
2211 IN CHAR16
*TextDeviceNode
2214 USB_CLASS_TEXT UsbClassText
;
2216 UsbClassText
.ClassExist
= FALSE
;
2217 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2218 UsbClassText
.SubClassExist
= TRUE
;
2220 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2224 Converts a text device path node to USB diagnostic device path structure.
2226 @param TextDeviceNode The input Text device path node.
2228 @return A pointer to the newly-created USB diagnostic device path structure.
2231 EFI_DEVICE_PATH_PROTOCOL
*
2232 DevPathFromTextUsbDiagnostic (
2233 IN CHAR16
*TextDeviceNode
2236 USB_CLASS_TEXT UsbClassText
;
2238 UsbClassText
.ClassExist
= FALSE
;
2239 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2240 UsbClassText
.SubClassExist
= TRUE
;
2242 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2246 Converts a text device path node to USB wireless device path structure.
2248 @param TextDeviceNode The input Text device path node.
2250 @return A pointer to the newly-created USB wireless device path structure.
2253 EFI_DEVICE_PATH_PROTOCOL
*
2254 DevPathFromTextUsbWireless (
2255 IN CHAR16
*TextDeviceNode
2258 USB_CLASS_TEXT UsbClassText
;
2260 UsbClassText
.ClassExist
= FALSE
;
2261 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2262 UsbClassText
.SubClassExist
= TRUE
;
2264 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2268 Converts a text device path node to USB device firmware update device path structure.
2270 @param TextDeviceNode The input Text device path node.
2272 @return A pointer to the newly-created USB device firmware update device path structure.
2275 EFI_DEVICE_PATH_PROTOCOL
*
2276 DevPathFromTextUsbDeviceFirmwareUpdate (
2277 IN CHAR16
*TextDeviceNode
2280 USB_CLASS_TEXT UsbClassText
;
2282 UsbClassText
.ClassExist
= FALSE
;
2283 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2284 UsbClassText
.SubClassExist
= FALSE
;
2285 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2287 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2291 Converts a text device path node to USB IRDA bridge device path structure.
2293 @param TextDeviceNode The input Text device path node.
2295 @return A pointer to the newly-created USB IRDA bridge device path structure.
2298 EFI_DEVICE_PATH_PROTOCOL
*
2299 DevPathFromTextUsbIrdaBridge (
2300 IN CHAR16
*TextDeviceNode
2303 USB_CLASS_TEXT UsbClassText
;
2305 UsbClassText
.ClassExist
= FALSE
;
2306 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2307 UsbClassText
.SubClassExist
= FALSE
;
2308 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2310 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2314 Converts a text device path node to USB text and measurement device path structure.
2316 @param TextDeviceNode The input Text device path node.
2318 @return A pointer to the newly-created USB text and measurement device path structure.
2321 EFI_DEVICE_PATH_PROTOCOL
*
2322 DevPathFromTextUsbTestAndMeasurement (
2323 IN CHAR16
*TextDeviceNode
2326 USB_CLASS_TEXT UsbClassText
;
2328 UsbClassText
.ClassExist
= FALSE
;
2329 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2330 UsbClassText
.SubClassExist
= FALSE
;
2331 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2333 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2337 Converts a text device path node to USB WWID device path structure.
2339 @param TextDeviceNode The input Text device path node.
2341 @return A pointer to the newly-created USB WWID device path structure.
2344 EFI_DEVICE_PATH_PROTOCOL
*
2345 DevPathFromTextUsbWwid (
2346 IN CHAR16
*TextDeviceNode
2351 CHAR16
*InterfaceNumStr
;
2352 CHAR16
*SerialNumberStr
;
2353 USB_WWID_DEVICE_PATH
*UsbWwid
;
2355 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2356 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2357 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2358 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2359 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2360 MESSAGING_DEVICE_PATH
,
2362 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + StrSize (SerialNumberStr
))
2365 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2366 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2367 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2368 StrCpy ((CHAR16
*) ((UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
)), SerialNumberStr
);
2370 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2374 Converts a text device path node to Logic Unit device path structure.
2376 @param TextDeviceNode The input Text device path node.
2378 @return A pointer to the newly-created Logic Unit device path structure.
2381 EFI_DEVICE_PATH_PROTOCOL
*
2382 DevPathFromTextUnit (
2383 IN CHAR16
*TextDeviceNode
2387 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2389 LunStr
= GetNextParamStr (&TextDeviceNode
);
2390 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2391 MESSAGING_DEVICE_PATH
,
2392 MSG_DEVICE_LOGICAL_UNIT_DP
,
2393 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2396 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2398 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2402 Converts a text device path node to iSCSI device path structure.
2404 @param TextDeviceNode The input Text device path node.
2406 @return A pointer to the newly-created iSCSI device path structure.
2409 EFI_DEVICE_PATH_PROTOCOL
*
2410 DevPathFromTextiSCSI (
2411 IN CHAR16
*TextDeviceNode
2416 CHAR16
*PortalGroupStr
;
2418 CHAR16
*HeaderDigestStr
;
2419 CHAR16
*DataDigestStr
;
2420 CHAR16
*AuthenticationStr
;
2421 CHAR16
*ProtocolStr
;
2423 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2425 NameStr
= GetNextParamStr (&TextDeviceNode
);
2426 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2427 LunStr
= GetNextParamStr (&TextDeviceNode
);
2428 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2429 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2430 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2431 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2432 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2433 MESSAGING_DEVICE_PATH
,
2435 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2438 AsciiStr
= ISCSIDevPath
->TargetName
;
2439 StrToAscii (NameStr
, &AsciiStr
);
2441 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2442 Strtoi64 (LunStr
, &ISCSIDevPath
->Lun
);
2445 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2449 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2453 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2457 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2461 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2463 ISCSIDevPath
->NetworkProtocol
= (UINT16
) StrCmp (ProtocolStr
, L
"TCP");
2465 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2469 Converts a text device path node to VLAN device path structure.
2471 @param TextDeviceNode The input Text device path node.
2473 @return A pointer to the newly-created VLAN device path structure.
2476 EFI_DEVICE_PATH_PROTOCOL
*
2477 DevPathFromTextVlan (
2478 IN CHAR16
*TextDeviceNode
2482 VLAN_DEVICE_PATH
*Vlan
;
2484 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2485 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2486 MESSAGING_DEVICE_PATH
,
2488 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2491 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2493 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2497 Converts a text device path node to HD device path structure.
2499 @param TextDeviceNode The input Text device path node.
2501 @return A pointer to the newly-created HD device path structure.
2504 EFI_DEVICE_PATH_PROTOCOL
*
2506 IN CHAR16
*TextDeviceNode
2509 CHAR16
*PartitionStr
;
2511 CHAR16
*SignatureStr
;
2515 EFI_GUID SignatureGuid
;
2516 HARDDRIVE_DEVICE_PATH
*Hd
;
2518 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2519 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2520 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2521 StartStr
= GetNextParamStr (&TextDeviceNode
);
2522 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2523 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2526 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2529 Hd
->PartitionNumber
= (UINT32
) StrDecimalToUintn (PartitionStr
);
2531 ZeroMem (Hd
->Signature
, 16);
2532 Hd
->MBRType
= (UINT8
) 0;
2534 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2535 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2538 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2539 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2540 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2541 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2544 StrToGuid (SignatureStr
, &SignatureGuid
);
2545 CopyMem (Hd
->Signature
, &SignatureGuid
, sizeof (EFI_GUID
));
2547 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2550 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2551 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2553 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2557 Converts a text device path node to CDROM device path structure.
2559 @param TextDeviceNode The input Text device path node.
2561 @return A pointer to the newly-created CDROM device path structure.
2564 EFI_DEVICE_PATH_PROTOCOL
*
2565 DevPathFromTextCDROM (
2566 IN CHAR16
*TextDeviceNode
2572 CDROM_DEVICE_PATH
*CDROMDevPath
;
2574 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2575 StartStr
= GetNextParamStr (&TextDeviceNode
);
2576 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2577 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2580 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2583 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2584 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2585 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2587 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2591 Converts a text device path node to Vendor-defined media device path structure.
2593 @param TextDeviceNode The input Text device path node.
2595 @return A pointer to the newly-created Vendor-defined media device path structure.
2598 EFI_DEVICE_PATH_PROTOCOL
*
2599 DevPathFromTextVenMEDIA (
2600 IN CHAR16
*TextDeviceNode
2603 return ConvertFromTextVendor (
2611 Converts a text device path node to File device path structure.
2613 @param TextDeviceNode The input Text device path node.
2615 @return A pointer to the newly-created File device path structure.
2618 EFI_DEVICE_PATH_PROTOCOL
*
2619 DevPathFromTextFilePath (
2620 IN CHAR16
*TextDeviceNode
2623 FILEPATH_DEVICE_PATH
*File
;
2625 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2628 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
2631 StrCpy (File
->PathName
, TextDeviceNode
);
2633 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
2637 Converts a text device path node to Media protocol device path structure.
2639 @param TextDeviceNode The input Text device path node.
2641 @return A pointer to the newly-created Media protocol device path structure.
2644 EFI_DEVICE_PATH_PROTOCOL
*
2645 DevPathFromTextMedia (
2646 IN CHAR16
*TextDeviceNode
2650 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
2652 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2653 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
2656 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
2659 StrToGuid (GuidStr
, &Media
->Protocol
);
2661 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
2665 Converts a text device path node to firmware volume device path structure.
2667 @param TextDeviceNode The input Text device path node.
2669 @return A pointer to the newly-created firmware volume device path structure.
2672 EFI_DEVICE_PATH_PROTOCOL
*
2674 IN CHAR16
*TextDeviceNode
2678 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
2680 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2681 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
2683 MEDIA_PIWG_FW_VOL_DP
,
2684 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
2687 StrToGuid (GuidStr
, &Fv
->FvName
);
2689 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
2693 Converts a text device path node to firmware file device path structure.
2695 @param TextDeviceNode The input Text device path node.
2697 @return A pointer to the newly-created firmware file device path structure.
2700 EFI_DEVICE_PATH_PROTOCOL
*
2701 DevPathFromTextFvFile (
2702 IN CHAR16
*TextDeviceNode
2706 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
2708 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2709 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2711 MEDIA_PIWG_FW_FILE_DP
,
2712 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
2715 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
2717 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
2721 Converts a text device path node to text relative offset device path structure.
2723 @param TextDeviceNode The input Text device path node.
2725 @return A pointer to the newly-created Text device path structure.
2728 EFI_DEVICE_PATH_PROTOCOL
*
2729 DevPathFromTextRelativeOffsetRange (
2730 IN CHAR16
*TextDeviceNode
2733 CHAR16
*StartingOffsetStr
;
2734 CHAR16
*EndingOffsetStr
;
2735 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
2737 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2738 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2739 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
2741 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
2742 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
2745 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
2746 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
2748 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
2752 Converts a text device path node to BIOS Boot Specification device path structure.
2754 @param TextDeviceNode The input Text device path node.
2756 @return A pointer to the newly-created BIOS Boot Specification device path structure.
2759 EFI_DEVICE_PATH_PROTOCOL
*
2760 DevPathFromTextBBS (
2761 IN CHAR16
*TextDeviceNode
2768 BBS_BBS_DEVICE_PATH
*Bbs
;
2770 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2771 IdStr
= GetNextParamStr (&TextDeviceNode
);
2772 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
2773 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
2776 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
2779 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
2780 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
2781 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
2782 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
2783 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
2784 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
2785 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
2786 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
2787 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
2788 Bbs
->DeviceType
= BBS_TYPE_USB
;
2789 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
2790 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
2792 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
2795 AsciiStr
= Bbs
->String
;
2796 StrToAscii (IdStr
, &AsciiStr
);
2798 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
2800 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
2804 Converts a text device path node to SATA device path structure.
2806 @param TextDeviceNode The input Text device path node.
2808 @return A pointer to the newly-created SATA device path structure.
2811 EFI_DEVICE_PATH_PROTOCOL
*
2812 DevPathFromTextSata (
2813 IN CHAR16
*TextDeviceNode
2816 SATA_DEVICE_PATH
*Sata
;
2822 // The PMPN is optional.
2824 Param1
= GetNextParamStr (&TextDeviceNode
);
2825 Param2
= GetNextParamStr (&TextDeviceNode
);
2827 if (!IS_NULL (TextDeviceNode
)) {
2828 Param3
= GetNextParamStr (&TextDeviceNode
);
2831 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
2832 MESSAGING_DEVICE_PATH
,
2834 (UINT16
) sizeof (SATA_DEVICE_PATH
)
2836 Sata
->HBAPortNumber
= (UINT16
) StrHexToUintn (Param1
);
2837 if (Param3
!= NULL
) {
2838 Sata
->PortMultiplierPortNumber
= (UINT16
) StrHexToUintn (Param2
);
2841 Sata
->PortMultiplierPortNumber
= SATA_HBA_DIRECT_CONNECT_FLAG
;
2843 Sata
->Lun
= (UINT16
) StrHexToUintn (Param2
);
2845 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
2848 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
2849 {L
"Pci", DevPathFromTextPci
},
2850 {L
"PcCard", DevPathFromTextPcCard
},
2851 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
2852 {L
"VenHw", DevPathFromTextVenHw
},
2853 {L
"Ctrl", DevPathFromTextCtrl
},
2854 {L
"Acpi", DevPathFromTextAcpi
},
2855 {L
"PciRoot", DevPathFromTextPciRoot
},
2856 {L
"PcieRoot", DevPathFromTextPcieRoot
},
2857 {L
"Floppy", DevPathFromTextFloppy
},
2858 {L
"Keyboard", DevPathFromTextKeyboard
},
2859 {L
"Serial", DevPathFromTextSerial
},
2860 {L
"ParallelPort", DevPathFromTextParallelPort
},
2861 {L
"AcpiEx", DevPathFromTextAcpiEx
},
2862 {L
"AcpiExp", DevPathFromTextAcpiExp
},
2863 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
2864 {L
"Ata", DevPathFromTextAta
},
2865 {L
"Scsi", DevPathFromTextScsi
},
2866 {L
"Fibre", DevPathFromTextFibre
},
2867 {L
"FibreEx", DevPathFromTextFibreEx
},
2868 {L
"I1394", DevPathFromText1394
},
2869 {L
"USB", DevPathFromTextUsb
},
2870 {L
"I2O", DevPathFromTextI2O
},
2871 {L
"Infiniband", DevPathFromTextInfiniband
},
2872 {L
"VenMsg", DevPathFromTextVenMsg
},
2873 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
2874 {L
"VenVt100", DevPathFromTextVenVt100
},
2875 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
2876 {L
"VenUtf8", DevPathFromTextVenUtf8
},
2877 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
2878 {L
"SAS", DevPathFromTextSAS
},
2879 {L
"SasEx", DevPathFromTextSasEx
},
2880 {L
"DebugPort", DevPathFromTextDebugPort
},
2881 {L
"MAC", DevPathFromTextMAC
},
2882 {L
"IPv4", DevPathFromTextIPv4
},
2883 {L
"IPv6", DevPathFromTextIPv6
},
2884 {L
"Uart", DevPathFromTextUart
},
2885 {L
"UsbClass", DevPathFromTextUsbClass
},
2886 {L
"UsbAudio", DevPathFromTextUsbAudio
},
2887 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
2888 {L
"UsbHID", DevPathFromTextUsbHID
},
2889 {L
"UsbImage", DevPathFromTextUsbImage
},
2890 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
2891 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
2892 {L
"UsbHub", DevPathFromTextUsbHub
},
2893 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
2894 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
2895 {L
"UsbVideo", DevPathFromTextUsbVideo
},
2896 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
2897 {L
"UsbWireless", DevPathFromTextUsbWireless
},
2898 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
2899 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
2900 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
2901 {L
"UsbWwid", DevPathFromTextUsbWwid
},
2902 {L
"Unit", DevPathFromTextUnit
},
2903 {L
"iSCSI", DevPathFromTextiSCSI
},
2904 {L
"Vlan", DevPathFromTextVlan
},
2905 {L
"HD", DevPathFromTextHD
},
2906 {L
"CDROM", DevPathFromTextCDROM
},
2907 {L
"VenMEDIA", DevPathFromTextVenMEDIA
},
2908 {L
"Media", DevPathFromTextMedia
},
2909 {L
"Fv", DevPathFromTextFv
},
2910 {L
"FvFile", DevPathFromTextFvFile
},
2911 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
2912 {L
"BBS", DevPathFromTextBBS
},
2913 {L
"Sata", DevPathFromTextSata
},
2918 Convert text to the binary representation of a device node.
2920 @param TextDeviceNode TextDeviceNode points to the text representation of a device
2921 node. Conversion starts with the first character and continues
2922 until the first non-device node character.
2924 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
2925 insufficient memory or text unsupported.
2928 EFI_DEVICE_PATH_PROTOCOL
*
2930 UefiDevicePathLibConvertTextToDeviceNode (
2931 IN CONST CHAR16
*TextDeviceNode
2934 DEVICE_PATH_FROM_TEXT FromText
;
2936 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
2937 CHAR16
*DeviceNodeStr
;
2940 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
2946 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
2947 ASSERT (DeviceNodeStr
!= NULL
);
2949 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
2950 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
2951 if (ParamStr
!= NULL
) {
2952 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
2957 if (FromText
== NULL
) {
2961 FromText
= DevPathFromTextFilePath
;
2962 DeviceNode
= FromText (DeviceNodeStr
);
2964 DeviceNode
= FromText (ParamStr
);
2965 FreePool (ParamStr
);
2968 FreePool (DeviceNodeStr
);
2974 Convert text to the binary representation of a device path.
2977 @param TextDevicePath TextDevicePath points to the text representation of a device
2978 path. Conversion starts with the first character and continues
2979 until the first non-device node character.
2981 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
2982 there was insufficient memory.
2985 EFI_DEVICE_PATH_PROTOCOL
*
2987 UefiDevicePathLibConvertTextToDevicePath (
2988 IN CONST CHAR16
*TextDevicePath
2991 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
2992 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
2993 CHAR16
*DevicePathStr
;
2995 CHAR16
*DeviceNodeStr
;
2996 BOOLEAN IsInstanceEnd
;
2997 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
2999 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3003 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3004 ASSERT (DevicePath
!= NULL
);
3005 SetDevicePathEndNode (DevicePath
);
3007 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3009 Str
= DevicePathStr
;
3010 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3011 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3013 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3014 FreePool (DevicePath
);
3015 FreePool (DeviceNode
);
3016 DevicePath
= NewDevicePath
;
3018 if (IsInstanceEnd
) {
3019 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3020 ASSERT (DeviceNode
!= NULL
);
3021 SetDevicePathEndNode (DeviceNode
);
3023 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3024 FreePool (DevicePath
);
3025 FreePool (DeviceNode
);
3026 DevicePath
= NewDevicePath
;
3030 FreePool (DevicePathStr
);