2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
4 Copyright (c) 2013 - 2015, 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 generic text device path node to device path structure.
540 @param Type The type of the device path node.
541 @param TextDeviceNode The input text device path node.
543 @return A pointer to device path structure.
545 EFI_DEVICE_PATH_PROTOCOL
*
546 DevPathFromTextGenericPath (
548 IN CHAR16
*TextDeviceNode
551 EFI_DEVICE_PATH_PROTOCOL
*Node
;
556 SubtypeStr
= GetNextParamStr (&TextDeviceNode
);
557 DataStr
= GetNextParamStr (&TextDeviceNode
);
559 if (DataStr
== NULL
) {
562 DataLength
= StrLen (DataStr
) / 2;
564 Node
= CreateDeviceNode (
566 (UINT8
) Strtoi (SubtypeStr
),
567 (UINT16
) (sizeof (EFI_DEVICE_PATH_PROTOCOL
) + DataLength
)
570 if (DataLength
!= 0) {
571 StrToBuf ((UINT8
*) (Node
+ 1), DataLength
, DataStr
);
577 Converts a generic text device path node to device path structure.
579 @param TextDeviceNode The input Text device path node.
581 @return A pointer to device path structure.
584 EFI_DEVICE_PATH_PROTOCOL
*
585 DevPathFromTextPath (
586 IN CHAR16
*TextDeviceNode
591 TypeStr
= GetNextParamStr (&TextDeviceNode
);
593 return DevPathFromTextGenericPath ((UINT8
) Strtoi (TypeStr
), TextDeviceNode
);
597 Converts a generic hardware text device path node to Hardware device path structure.
599 @param TextDeviceNode The input Text device path node.
601 @return A pointer to Hardware device path structure.
604 EFI_DEVICE_PATH_PROTOCOL
*
605 DevPathFromTextHardwarePath (
606 IN CHAR16
*TextDeviceNode
609 return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH
, TextDeviceNode
);
613 Converts a text device path node to Hardware PCI device path structure.
615 @param TextDeviceNode The input Text device path node.
617 @return A pointer to Hardware PCI device path structure.
620 EFI_DEVICE_PATH_PROTOCOL
*
622 IN CHAR16
*TextDeviceNode
627 PCI_DEVICE_PATH
*Pci
;
629 DeviceStr
= GetNextParamStr (&TextDeviceNode
);
630 FunctionStr
= GetNextParamStr (&TextDeviceNode
);
631 Pci
= (PCI_DEVICE_PATH
*) CreateDeviceNode (
632 HARDWARE_DEVICE_PATH
,
634 (UINT16
) sizeof (PCI_DEVICE_PATH
)
637 Pci
->Function
= (UINT8
) Strtoi (FunctionStr
);
638 Pci
->Device
= (UINT8
) Strtoi (DeviceStr
);
640 return (EFI_DEVICE_PATH_PROTOCOL
*) Pci
;
644 Converts a text device path node to Hardware PC card device path structure.
646 @param TextDeviceNode The input Text device path node.
648 @return A pointer to Hardware PC card device path structure.
651 EFI_DEVICE_PATH_PROTOCOL
*
652 DevPathFromTextPcCard (
653 IN CHAR16
*TextDeviceNode
656 CHAR16
*FunctionNumberStr
;
657 PCCARD_DEVICE_PATH
*Pccard
;
659 FunctionNumberStr
= GetNextParamStr (&TextDeviceNode
);
660 Pccard
= (PCCARD_DEVICE_PATH
*) CreateDeviceNode (
661 HARDWARE_DEVICE_PATH
,
663 (UINT16
) sizeof (PCCARD_DEVICE_PATH
)
666 Pccard
->FunctionNumber
= (UINT8
) Strtoi (FunctionNumberStr
);
668 return (EFI_DEVICE_PATH_PROTOCOL
*) Pccard
;
672 Converts a text device path node to Hardware memory map device path structure.
674 @param TextDeviceNode The input Text device path node.
676 @return A pointer to Hardware memory map device path structure.
679 EFI_DEVICE_PATH_PROTOCOL
*
680 DevPathFromTextMemoryMapped (
681 IN CHAR16
*TextDeviceNode
684 CHAR16
*MemoryTypeStr
;
685 CHAR16
*StartingAddressStr
;
686 CHAR16
*EndingAddressStr
;
687 MEMMAP_DEVICE_PATH
*MemMap
;
689 MemoryTypeStr
= GetNextParamStr (&TextDeviceNode
);
690 StartingAddressStr
= GetNextParamStr (&TextDeviceNode
);
691 EndingAddressStr
= GetNextParamStr (&TextDeviceNode
);
692 MemMap
= (MEMMAP_DEVICE_PATH
*) CreateDeviceNode (
693 HARDWARE_DEVICE_PATH
,
695 (UINT16
) sizeof (MEMMAP_DEVICE_PATH
)
698 MemMap
->MemoryType
= (UINT32
) Strtoi (MemoryTypeStr
);
699 Strtoi64 (StartingAddressStr
, &MemMap
->StartingAddress
);
700 Strtoi64 (EndingAddressStr
, &MemMap
->EndingAddress
);
702 return (EFI_DEVICE_PATH_PROTOCOL
*) MemMap
;
706 Converts a text device path node to Vendor device path structure based on the input Type
709 @param TextDeviceNode The input Text device path node.
710 @param Type The type of device path node.
711 @param SubType The subtype of device path node.
713 @return A pointer to the newly-created Vendor device path structure.
716 EFI_DEVICE_PATH_PROTOCOL
*
717 ConvertFromTextVendor (
718 IN CHAR16
*TextDeviceNode
,
726 VENDOR_DEVICE_PATH
*Vendor
;
728 GuidStr
= GetNextParamStr (&TextDeviceNode
);
730 DataStr
= GetNextParamStr (&TextDeviceNode
);
731 Length
= StrLen (DataStr
);
733 // Two hex characters make up 1 buffer byte
735 Length
= (Length
+ 1) / 2;
737 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
740 (UINT16
) (sizeof (VENDOR_DEVICE_PATH
) + Length
)
743 StrToGuid (GuidStr
, &Vendor
->Guid
);
744 StrToBuf (((UINT8
*) Vendor
) + sizeof (VENDOR_DEVICE_PATH
), Length
, DataStr
);
746 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
750 Converts a text device path node to Vendor Hardware device path structure.
752 @param TextDeviceNode The input Text device path node.
754 @return A pointer to the newly-created Vendor Hardware device path structure.
757 EFI_DEVICE_PATH_PROTOCOL
*
758 DevPathFromTextVenHw (
759 IN CHAR16
*TextDeviceNode
762 return ConvertFromTextVendor (
764 HARDWARE_DEVICE_PATH
,
770 Converts a text device path node to Hardware Controller device path structure.
772 @param TextDeviceNode The input Text device path node.
774 @return A pointer to the newly-created Hardware Controller device path structure.
777 EFI_DEVICE_PATH_PROTOCOL
*
778 DevPathFromTextCtrl (
779 IN CHAR16
*TextDeviceNode
782 CHAR16
*ControllerStr
;
783 CONTROLLER_DEVICE_PATH
*Controller
;
785 ControllerStr
= GetNextParamStr (&TextDeviceNode
);
786 Controller
= (CONTROLLER_DEVICE_PATH
*) CreateDeviceNode (
787 HARDWARE_DEVICE_PATH
,
789 (UINT16
) sizeof (CONTROLLER_DEVICE_PATH
)
791 Controller
->ControllerNumber
= (UINT32
) Strtoi (ControllerStr
);
793 return (EFI_DEVICE_PATH_PROTOCOL
*) Controller
;
797 Converts a text device path node to BMC device path structure.
799 @param TextDeviceNode The input Text device path node.
801 @return A pointer to the newly-created BMC device path structure.
804 EFI_DEVICE_PATH_PROTOCOL
*
806 IN CHAR16
*TextDeviceNode
809 CHAR16
*InterfaceTypeStr
;
810 CHAR16
*BaseAddressStr
;
811 BMC_DEVICE_PATH
*BmcDp
;
813 InterfaceTypeStr
= GetNextParamStr (&TextDeviceNode
);
814 BaseAddressStr
= GetNextParamStr (&TextDeviceNode
);
815 BmcDp
= (BMC_DEVICE_PATH
*) CreateDeviceNode (
816 HARDWARE_DEVICE_PATH
,
818 (UINT16
) sizeof (BMC_DEVICE_PATH
)
821 BmcDp
->InterfaceType
= (UINT8
) Strtoi (InterfaceTypeStr
);
823 (UINT64
*) (&BmcDp
->BaseAddress
),
824 StrHexToUint64 (BaseAddressStr
)
827 return (EFI_DEVICE_PATH_PROTOCOL
*) BmcDp
;
831 Converts a generic ACPI text device path node to ACPI device path structure.
833 @param TextDeviceNode The input Text device path node.
835 @return A pointer to ACPI device path structure.
838 EFI_DEVICE_PATH_PROTOCOL
*
839 DevPathFromTextAcpiPath (
840 IN CHAR16
*TextDeviceNode
843 return DevPathFromTextGenericPath (ACPI_DEVICE_PATH
, TextDeviceNode
);
847 Converts a string to EisaId.
849 @param Text The input string.
851 @return UINT32 EISA ID.
858 return (((Text
[0] - 'A' + 1) & 0x1f) << 10)
859 + (((Text
[1] - 'A' + 1) & 0x1f) << 5)
860 + (((Text
[2] - 'A' + 1) & 0x1f) << 0)
861 + (UINT32
) (StrHexToUintn (&Text
[3]) << 16)
866 Converts a text device path node to ACPI HID device path structure.
868 @param TextDeviceNode The input Text device path node.
870 @return A pointer to the newly-created ACPI HID device path structure.
873 EFI_DEVICE_PATH_PROTOCOL
*
874 DevPathFromTextAcpi (
875 IN CHAR16
*TextDeviceNode
880 ACPI_HID_DEVICE_PATH
*Acpi
;
882 HIDStr
= GetNextParamStr (&TextDeviceNode
);
883 UIDStr
= GetNextParamStr (&TextDeviceNode
);
884 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
887 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
890 Acpi
->HID
= EisaIdFromText (HIDStr
);
891 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
893 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
897 Converts a text device path node to ACPI HID device path structure.
899 @param TextDeviceNode The input Text device path node.
900 @param PnPId The input plug and play identification.
902 @return A pointer to the newly-created ACPI HID device path structure.
905 EFI_DEVICE_PATH_PROTOCOL
*
906 ConvertFromTextAcpi (
907 IN CHAR16
*TextDeviceNode
,
912 ACPI_HID_DEVICE_PATH
*Acpi
;
914 UIDStr
= GetNextParamStr (&TextDeviceNode
);
915 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
918 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
921 Acpi
->HID
= EFI_PNP_ID (PnPId
);
922 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
924 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
928 Converts a text device path node to PCI root device path structure.
930 @param TextDeviceNode The input Text device path node.
932 @return A pointer to the newly-created PCI root device path structure.
935 EFI_DEVICE_PATH_PROTOCOL
*
936 DevPathFromTextPciRoot (
937 IN CHAR16
*TextDeviceNode
940 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a03);
944 Converts a text device path node to PCIE root device path structure.
946 @param TextDeviceNode The input Text device path node.
948 @return A pointer to the newly-created PCIE root device path structure.
951 EFI_DEVICE_PATH_PROTOCOL
*
952 DevPathFromTextPcieRoot (
953 IN CHAR16
*TextDeviceNode
956 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a08);
960 Converts a text device path node to Floppy device path structure.
962 @param TextDeviceNode The input Text device path node.
964 @return A pointer to the newly-created Floppy device path structure.
967 EFI_DEVICE_PATH_PROTOCOL
*
968 DevPathFromTextFloppy (
969 IN CHAR16
*TextDeviceNode
972 return ConvertFromTextAcpi (TextDeviceNode
, 0x0604);
976 Converts a text device path node to Keyboard device path structure.
978 @param TextDeviceNode The input Text device path node.
980 @return A pointer to the newly-created Keyboard device path structure.
983 EFI_DEVICE_PATH_PROTOCOL
*
984 DevPathFromTextKeyboard (
985 IN CHAR16
*TextDeviceNode
988 return ConvertFromTextAcpi (TextDeviceNode
, 0x0301);
992 Converts a text device path node to Serial device path structure.
994 @param TextDeviceNode The input Text device path node.
996 @return A pointer to the newly-created Serial device path structure.
999 EFI_DEVICE_PATH_PROTOCOL
*
1000 DevPathFromTextSerial (
1001 IN CHAR16
*TextDeviceNode
1004 return ConvertFromTextAcpi (TextDeviceNode
, 0x0501);
1008 Converts a text device path node to Parallel Port device path structure.
1010 @param TextDeviceNode The input Text device path node.
1012 @return A pointer to the newly-created Parallel Port device path structure.
1015 EFI_DEVICE_PATH_PROTOCOL
*
1016 DevPathFromTextParallelPort (
1017 IN CHAR16
*TextDeviceNode
1020 return ConvertFromTextAcpi (TextDeviceNode
, 0x0401);
1024 Converts a text device path node to ACPI extension device path structure.
1026 @param TextDeviceNode The input Text device path node.
1028 @return A pointer to the newly-created ACPI extension device path structure.
1031 EFI_DEVICE_PATH_PROTOCOL
*
1032 DevPathFromTextAcpiEx (
1033 IN CHAR16
*TextDeviceNode
1044 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
1046 HIDStr
= GetNextParamStr (&TextDeviceNode
);
1047 CIDStr
= GetNextParamStr (&TextDeviceNode
);
1048 UIDStr
= GetNextParamStr (&TextDeviceNode
);
1049 HIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1050 CIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1051 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1053 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (HIDSTRStr
) + 1);
1054 Length
= (UINT16
) (Length
+ StrLen (UIDSTRStr
) + 1);
1055 Length
= (UINT16
) (Length
+ StrLen (CIDSTRStr
) + 1);
1056 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
1062 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
1063 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
1064 AcpiEx
->UID
= (UINT32
) Strtoi (UIDStr
);
1066 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
1067 StrToAscii (HIDSTRStr
, &AsciiStr
);
1068 StrToAscii (UIDSTRStr
, &AsciiStr
);
1069 StrToAscii (CIDSTRStr
, &AsciiStr
);
1071 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
1075 Converts a text device path node to ACPI extension device path structure.
1077 @param TextDeviceNode The input Text device path node.
1079 @return A pointer to the newly-created ACPI extension device path structure.
1082 EFI_DEVICE_PATH_PROTOCOL
*
1083 DevPathFromTextAcpiExp (
1084 IN CHAR16
*TextDeviceNode
1092 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
1094 HIDStr
= GetNextParamStr (&TextDeviceNode
);
1095 CIDStr
= GetNextParamStr (&TextDeviceNode
);
1096 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1097 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (UIDSTRStr
) + 3);
1098 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
1104 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
1105 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
1108 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
1110 // HID string is NULL
1114 // Convert UID string
1117 StrToAscii (UIDSTRStr
, &AsciiStr
);
1119 // CID string is NULL
1123 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
1127 Converts a text device path node to ACPI _ADR device path structure.
1129 @param TextDeviceNode The input Text device path node.
1131 @return A pointer to the newly-created ACPI _ADR device path structure.
1134 EFI_DEVICE_PATH_PROTOCOL
*
1135 DevPathFromTextAcpiAdr (
1136 IN CHAR16
*TextDeviceNode
1139 CHAR16
*DisplayDeviceStr
;
1140 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
1144 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*) CreateDeviceNode (
1147 (UINT16
) sizeof (ACPI_ADR_DEVICE_PATH
)
1149 ASSERT (AcpiAdr
!= NULL
);
1151 for (Index
= 0; ; Index
++) {
1152 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
1153 if (IS_NULL (*DisplayDeviceStr
)) {
1157 Length
= DevicePathNodeLength (AcpiAdr
);
1158 AcpiAdr
= ReallocatePool (
1160 Length
+ sizeof (UINT32
),
1163 ASSERT (AcpiAdr
!= NULL
);
1164 SetDevicePathNodeLength (AcpiAdr
, Length
+ sizeof (UINT32
));
1167 (&AcpiAdr
->ADR
)[Index
] = (UINT32
) Strtoi (DisplayDeviceStr
);
1170 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
;
1174 Converts a generic messaging text device path node to messaging device path structure.
1176 @param TextDeviceNode The input Text device path node.
1178 @return A pointer to messaging device path structure.
1181 EFI_DEVICE_PATH_PROTOCOL
*
1182 DevPathFromTextMsg (
1183 IN CHAR16
*TextDeviceNode
1186 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH
, TextDeviceNode
);
1190 Converts a text device path node to Parallel Port device path structure.
1192 @param TextDeviceNode The input Text device path node.
1194 @return A pointer to the newly-created Parallel Port device path structure.
1197 EFI_DEVICE_PATH_PROTOCOL
*
1198 DevPathFromTextAta (
1199 IN CHAR16
*TextDeviceNode
1202 CHAR16
*PrimarySecondaryStr
;
1203 CHAR16
*SlaveMasterStr
;
1205 ATAPI_DEVICE_PATH
*Atapi
;
1207 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
1208 MESSAGING_DEVICE_PATH
,
1210 (UINT16
) sizeof (ATAPI_DEVICE_PATH
)
1213 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
1214 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
1215 LunStr
= GetNextParamStr (&TextDeviceNode
);
1217 if (StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) {
1218 Atapi
->PrimarySecondary
= 0;
1219 } else if (StrCmp (PrimarySecondaryStr
, L
"Secondary") == 0) {
1220 Atapi
->PrimarySecondary
= 1;
1222 Atapi
->PrimarySecondary
= (UINT8
) Strtoi (PrimarySecondaryStr
);
1224 if (StrCmp (SlaveMasterStr
, L
"Master") == 0) {
1225 Atapi
->SlaveMaster
= 0;
1226 } else if (StrCmp (SlaveMasterStr
, L
"Slave") == 0) {
1227 Atapi
->SlaveMaster
= 1;
1229 Atapi
->SlaveMaster
= (UINT8
) Strtoi (SlaveMasterStr
);
1232 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
1234 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
1238 Converts a text device path node to SCSI device path structure.
1240 @param TextDeviceNode The input Text device path node.
1242 @return A pointer to the newly-created SCSI device path structure.
1245 EFI_DEVICE_PATH_PROTOCOL
*
1246 DevPathFromTextScsi (
1247 IN CHAR16
*TextDeviceNode
1252 SCSI_DEVICE_PATH
*Scsi
;
1254 PunStr
= GetNextParamStr (&TextDeviceNode
);
1255 LunStr
= GetNextParamStr (&TextDeviceNode
);
1256 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
1257 MESSAGING_DEVICE_PATH
,
1259 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
1262 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
1263 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
1265 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
1269 Converts a text device path node to Fibre device path structure.
1271 @param TextDeviceNode The input Text device path node.
1273 @return A pointer to the newly-created Fibre device path structure.
1276 EFI_DEVICE_PATH_PROTOCOL
*
1277 DevPathFromTextFibre (
1278 IN CHAR16
*TextDeviceNode
1283 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
1285 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1286 LunStr
= GetNextParamStr (&TextDeviceNode
);
1287 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
1288 MESSAGING_DEVICE_PATH
,
1289 MSG_FIBRECHANNEL_DP
,
1290 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
1293 Fibre
->Reserved
= 0;
1294 Strtoi64 (WWNStr
, &Fibre
->WWN
);
1295 Strtoi64 (LunStr
, &Fibre
->Lun
);
1297 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
1301 Converts a text device path node to FibreEx device path structure.
1303 @param TextDeviceNode The input Text device path node.
1305 @return A pointer to the newly-created FibreEx device path structure.
1308 EFI_DEVICE_PATH_PROTOCOL
*
1309 DevPathFromTextFibreEx (
1310 IN CHAR16
*TextDeviceNode
1315 FIBRECHANNELEX_DEVICE_PATH
*FibreEx
;
1317 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1318 LunStr
= GetNextParamStr (&TextDeviceNode
);
1319 FibreEx
= (FIBRECHANNELEX_DEVICE_PATH
*) CreateDeviceNode (
1320 MESSAGING_DEVICE_PATH
,
1321 MSG_FIBRECHANNELEX_DP
,
1322 (UINT16
) sizeof (FIBRECHANNELEX_DEVICE_PATH
)
1325 FibreEx
->Reserved
= 0;
1326 Strtoi64 (WWNStr
, (UINT64
*) (&FibreEx
->WWN
));
1327 Strtoi64 (LunStr
, (UINT64
*) (&FibreEx
->Lun
));
1329 *(UINT64
*) (&FibreEx
->WWN
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->WWN
));
1330 *(UINT64
*) (&FibreEx
->Lun
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->Lun
));
1332 return (EFI_DEVICE_PATH_PROTOCOL
*) FibreEx
;
1336 Converts a text device path node to 1394 device path structure.
1338 @param TextDeviceNode The input Text device path node.
1340 @return A pointer to the newly-created 1394 device path structure.
1343 EFI_DEVICE_PATH_PROTOCOL
*
1344 DevPathFromText1394 (
1345 IN CHAR16
*TextDeviceNode
1349 F1394_DEVICE_PATH
*F1394DevPath
;
1351 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1352 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1353 MESSAGING_DEVICE_PATH
,
1355 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1358 F1394DevPath
->Reserved
= 0;
1359 F1394DevPath
->Guid
= StrHexToUint64 (GuidStr
);
1361 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1365 Converts a text device path node to USB device path structure.
1367 @param TextDeviceNode The input Text device path node.
1369 @return A pointer to the newly-created USB device path structure.
1372 EFI_DEVICE_PATH_PROTOCOL
*
1373 DevPathFromTextUsb (
1374 IN CHAR16
*TextDeviceNode
1378 CHAR16
*InterfaceStr
;
1379 USB_DEVICE_PATH
*Usb
;
1381 PortStr
= GetNextParamStr (&TextDeviceNode
);
1382 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1383 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1384 MESSAGING_DEVICE_PATH
,
1386 (UINT16
) sizeof (USB_DEVICE_PATH
)
1389 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1390 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1392 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1396 Converts a text device path node to I20 device path structure.
1398 @param TextDeviceNode The input Text device path node.
1400 @return A pointer to the newly-created I20 device path structure.
1403 EFI_DEVICE_PATH_PROTOCOL
*
1404 DevPathFromTextI2O (
1405 IN CHAR16
*TextDeviceNode
1409 I2O_DEVICE_PATH
*I2ODevPath
;
1411 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1412 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1413 MESSAGING_DEVICE_PATH
,
1415 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1418 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1420 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1424 Converts a text device path node to Infini Band device path structure.
1426 @param TextDeviceNode The input Text device path node.
1428 @return A pointer to the newly-created Infini Band device path structure.
1431 EFI_DEVICE_PATH_PROTOCOL
*
1432 DevPathFromTextInfiniband (
1433 IN CHAR16
*TextDeviceNode
1442 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1444 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1445 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1446 SidStr
= GetNextParamStr (&TextDeviceNode
);
1447 TidStr
= GetNextParamStr (&TextDeviceNode
);
1448 DidStr
= GetNextParamStr (&TextDeviceNode
);
1449 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1450 MESSAGING_DEVICE_PATH
,
1452 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1455 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1456 StrToGuid (GuidStr
, &PortGid
);
1457 CopyMem (InfiniBand
->PortGid
, &PortGid
, sizeof (EFI_GUID
));
1458 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1459 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1460 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1462 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1466 Converts a text device path node to Vendor-Defined Messaging device path structure.
1468 @param TextDeviceNode The input Text device path node.
1470 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1473 EFI_DEVICE_PATH_PROTOCOL
*
1474 DevPathFromTextVenMsg (
1475 IN CHAR16
*TextDeviceNode
1478 return ConvertFromTextVendor (
1480 MESSAGING_DEVICE_PATH
,
1486 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1488 @param TextDeviceNode The input Text device path node.
1490 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1493 EFI_DEVICE_PATH_PROTOCOL
*
1494 DevPathFromTextVenPcAnsi (
1495 IN CHAR16
*TextDeviceNode
1498 VENDOR_DEVICE_PATH
*Vendor
;
1500 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1501 MESSAGING_DEVICE_PATH
,
1503 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1504 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1506 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1510 Converts a text device path node to Vendor defined VT100 device path structure.
1512 @param TextDeviceNode The input Text device path node.
1514 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1517 EFI_DEVICE_PATH_PROTOCOL
*
1518 DevPathFromTextVenVt100 (
1519 IN CHAR16
*TextDeviceNode
1522 VENDOR_DEVICE_PATH
*Vendor
;
1524 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1525 MESSAGING_DEVICE_PATH
,
1527 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1528 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1530 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1534 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1536 @param TextDeviceNode The input Text device path node.
1538 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1541 EFI_DEVICE_PATH_PROTOCOL
*
1542 DevPathFromTextVenVt100Plus (
1543 IN CHAR16
*TextDeviceNode
1546 VENDOR_DEVICE_PATH
*Vendor
;
1548 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1549 MESSAGING_DEVICE_PATH
,
1551 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1552 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1554 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1558 Converts a text device path node to Vendor defined UTF8 device path structure.
1560 @param TextDeviceNode The input Text device path node.
1562 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1565 EFI_DEVICE_PATH_PROTOCOL
*
1566 DevPathFromTextVenUtf8 (
1567 IN CHAR16
*TextDeviceNode
1570 VENDOR_DEVICE_PATH
*Vendor
;
1572 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1573 MESSAGING_DEVICE_PATH
,
1575 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1576 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1578 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1582 Converts a text device path node to UART Flow Control device path structure.
1584 @param TextDeviceNode The input Text device path node.
1586 @return A pointer to the newly-created UART Flow Control device path structure.
1589 EFI_DEVICE_PATH_PROTOCOL
*
1590 DevPathFromTextUartFlowCtrl (
1591 IN CHAR16
*TextDeviceNode
1595 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1597 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1598 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1599 MESSAGING_DEVICE_PATH
,
1601 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1604 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1605 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1606 UartFlowControl
->FlowControlMap
= 2;
1607 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1608 UartFlowControl
->FlowControlMap
= 1;
1610 UartFlowControl
->FlowControlMap
= 0;
1613 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1617 Converts a text device path node to Serial Attached SCSI device path structure.
1619 @param TextDeviceNode The input Text device path node.
1621 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1624 EFI_DEVICE_PATH_PROTOCOL
*
1625 DevPathFromTextSAS (
1626 IN CHAR16
*TextDeviceNode
1633 CHAR16
*LocationStr
;
1635 CHAR16
*DriveBayStr
;
1636 CHAR16
*ReservedStr
;
1639 SAS_DEVICE_PATH
*Sas
;
1641 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1642 LunStr
= GetNextParamStr (&TextDeviceNode
);
1643 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1644 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1645 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1646 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1647 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1648 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1649 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1650 MESSAGING_DEVICE_PATH
,
1652 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1655 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1656 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1657 Strtoi64 (LunStr
, &Sas
->Lun
);
1658 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1660 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1663 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1665 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1669 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1672 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1677 // Location is an integer between 0 and 1 or else
1678 // the keyword Internal (0) or External (1).
1680 if (StrCmp (LocationStr
, L
"External") == 0) {
1682 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1685 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1687 Info
|= (Uint16
<< 5);
1690 // Connect is an integer between 0 and 3 or else
1691 // the keyword Direct (0) or Expanded (1).
1693 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1695 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1698 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1700 Info
|= (Uint16
<< 6);
1703 Info
= (UINT16
) Strtoi (SASSATAStr
);
1706 Sas
->DeviceTopology
= Info
;
1707 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1709 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1713 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1715 @param TextDeviceNode The input Text device path node.
1717 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1720 EFI_DEVICE_PATH_PROTOCOL
*
1721 DevPathFromTextSasEx (
1722 IN CHAR16
*TextDeviceNode
1729 CHAR16
*LocationStr
;
1731 CHAR16
*DriveBayStr
;
1736 SASEX_DEVICE_PATH
*SasEx
;
1738 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1739 LunStr
= GetNextParamStr (&TextDeviceNode
);
1740 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1741 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1742 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1743 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1744 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1745 SasEx
= (SASEX_DEVICE_PATH
*) CreateDeviceNode (
1746 MESSAGING_DEVICE_PATH
,
1748 (UINT16
) sizeof (SASEX_DEVICE_PATH
)
1751 Strtoi64 (AddressStr
, &SasAddress
);
1752 Strtoi64 (LunStr
, &Lun
);
1753 WriteUnaligned64 ((UINT64
*) &SasEx
->SasAddress
, SwapBytes64 (SasAddress
));
1754 WriteUnaligned64 ((UINT64
*) &SasEx
->Lun
, SwapBytes64 (Lun
));
1755 SasEx
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1757 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1760 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1762 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1766 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1769 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1774 // Location is an integer between 0 and 1 or else
1775 // the keyword Internal (0) or External (1).
1777 if (StrCmp (LocationStr
, L
"External") == 0) {
1779 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1782 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1784 Info
|= (Uint16
<< 5);
1787 // Connect is an integer between 0 and 3 or else
1788 // the keyword Direct (0) or Expanded (1).
1790 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1792 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1795 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1797 Info
|= (Uint16
<< 6);
1800 Info
= (UINT16
) Strtoi (SASSATAStr
);
1803 SasEx
->DeviceTopology
= Info
;
1805 return (EFI_DEVICE_PATH_PROTOCOL
*) SasEx
;
1809 Converts a text device path node to NVM Express Namespace device path structure.
1811 @param TextDeviceNode The input Text device path node.
1813 @return A pointer to the newly-created NVM Express Namespace device path structure.
1816 EFI_DEVICE_PATH_PROTOCOL
*
1817 DevPathFromTextNVMe (
1818 IN CHAR16
*TextDeviceNode
1821 CHAR16
*NamespaceIdStr
;
1822 CHAR16
*NamespaceUuidStr
;
1823 NVME_NAMESPACE_DEVICE_PATH
*Nvme
;
1827 NamespaceIdStr
= GetNextParamStr (&TextDeviceNode
);
1828 NamespaceUuidStr
= GetNextParamStr (&TextDeviceNode
);
1829 Nvme
= (NVME_NAMESPACE_DEVICE_PATH
*) CreateDeviceNode (
1830 MESSAGING_DEVICE_PATH
,
1831 MSG_NVME_NAMESPACE_DP
,
1832 (UINT16
) sizeof (NVME_NAMESPACE_DEVICE_PATH
)
1835 Nvme
->NamespaceId
= (UINT32
) Strtoi (NamespaceIdStr
);
1836 Uuid
= (UINT8
*) &Nvme
->NamespaceUuid
;
1838 Index
= sizeof (Nvme
->NamespaceUuid
) / sizeof (UINT8
);
1839 while (Index
-- != 0) {
1840 Uuid
[Index
] = (UINT8
) StrHexToUintn (SplitStr (&NamespaceUuidStr
, L
'-'));
1843 return (EFI_DEVICE_PATH_PROTOCOL
*) Nvme
;
1847 Converts a text device path node to UFS device path structure.
1849 @param TextDeviceNode The input Text device path node.
1851 @return A pointer to the newly-created UFS device path structure.
1854 EFI_DEVICE_PATH_PROTOCOL
*
1855 DevPathFromTextUfs (
1856 IN CHAR16
*TextDeviceNode
1861 UFS_DEVICE_PATH
*Ufs
;
1863 PunStr
= GetNextParamStr (&TextDeviceNode
);
1864 LunStr
= GetNextParamStr (&TextDeviceNode
);
1865 Ufs
= (UFS_DEVICE_PATH
*) CreateDeviceNode (
1866 MESSAGING_DEVICE_PATH
,
1868 (UINT16
) sizeof (UFS_DEVICE_PATH
)
1871 Ufs
->Pun
= (UINT8
) Strtoi (PunStr
);
1872 Ufs
->Lun
= (UINT8
) Strtoi (LunStr
);
1874 return (EFI_DEVICE_PATH_PROTOCOL
*) Ufs
;
1878 Converts a text device path node to SD (Secure Digital) device path structure.
1880 @param TextDeviceNode The input Text device path node.
1882 @return A pointer to the newly-created SD device path structure.
1885 EFI_DEVICE_PATH_PROTOCOL
*
1887 IN CHAR16
*TextDeviceNode
1890 CHAR16
*SlotNumberStr
;
1893 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1894 Sd
= (SD_DEVICE_PATH
*) CreateDeviceNode (
1895 MESSAGING_DEVICE_PATH
,
1897 (UINT16
) sizeof (SD_DEVICE_PATH
)
1900 Sd
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1902 return (EFI_DEVICE_PATH_PROTOCOL
*) Sd
;
1906 Converts a text device path node to EMMC (Embedded MMC) device path structure.
1908 @param TextDeviceNode The input Text device path node.
1910 @return A pointer to the newly-created EMMC device path structure.
1913 EFI_DEVICE_PATH_PROTOCOL
*
1914 DevPathFromTextEmmc (
1915 IN CHAR16
*TextDeviceNode
1918 CHAR16
*SlotNumberStr
;
1919 EMMC_DEVICE_PATH
*Emmc
;
1921 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1922 Emmc
= (EMMC_DEVICE_PATH
*) CreateDeviceNode (
1923 MESSAGING_DEVICE_PATH
,
1925 (UINT16
) sizeof (EMMC_DEVICE_PATH
)
1928 Emmc
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1930 return (EFI_DEVICE_PATH_PROTOCOL
*) Emmc
;
1934 Converts a text device path node to Debug Port device path structure.
1936 @param TextDeviceNode The input Text device path node.
1938 @return A pointer to the newly-created Debug Port device path structure.
1941 EFI_DEVICE_PATH_PROTOCOL
*
1942 DevPathFromTextDebugPort (
1943 IN CHAR16
*TextDeviceNode
1946 VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*Vend
;
1948 Vend
= (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*) CreateDeviceNode (
1949 MESSAGING_DEVICE_PATH
,
1951 (UINT16
) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
)
1954 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1956 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1960 Converts a text device path node to MAC device path structure.
1962 @param TextDeviceNode The input Text device path node.
1964 @return A pointer to the newly-created MAC device path structure.
1967 EFI_DEVICE_PATH_PROTOCOL
*
1968 DevPathFromTextMAC (
1969 IN CHAR16
*TextDeviceNode
1975 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1977 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1978 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1979 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1980 MESSAGING_DEVICE_PATH
,
1982 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1985 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1987 Length
= sizeof (EFI_MAC_ADDRESS
);
1988 StrToBuf (&MACDevPath
->MacAddress
.Addr
[0], Length
, AddressStr
);
1990 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1995 Converts a text format to the network protocol ID.
1997 @param Text String of protocol field.
1999 @return Network protocol ID .
2003 NetworkProtocolFromText (
2007 if (StrCmp (Text
, L
"UDP") == 0) {
2008 return RFC_1700_UDP_PROTOCOL
;
2011 if (StrCmp (Text
, L
"TCP") == 0) {
2012 return RFC_1700_TCP_PROTOCOL
;
2015 return Strtoi (Text
);
2020 Converts a text device path node to IPV4 device path structure.
2022 @param TextDeviceNode The input Text device path node.
2024 @return A pointer to the newly-created IPV4 device path structure.
2027 EFI_DEVICE_PATH_PROTOCOL
*
2028 DevPathFromTextIPv4 (
2029 IN CHAR16
*TextDeviceNode
2032 CHAR16
*RemoteIPStr
;
2033 CHAR16
*ProtocolStr
;
2036 CHAR16
*GatewayIPStr
;
2037 CHAR16
*SubnetMaskStr
;
2038 IPv4_DEVICE_PATH
*IPv4
;
2040 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
2041 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2042 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2043 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
2044 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
2045 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
2046 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
2047 MESSAGING_DEVICE_PATH
,
2049 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
2052 StrToIPv4Addr (&RemoteIPStr
, &IPv4
->RemoteIpAddress
);
2053 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
2054 if (StrCmp (TypeStr
, L
"Static") == 0) {
2055 IPv4
->StaticIpAddress
= TRUE
;
2057 IPv4
->StaticIpAddress
= FALSE
;
2060 StrToIPv4Addr (&LocalIPStr
, &IPv4
->LocalIpAddress
);
2061 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
2062 StrToIPv4Addr (&GatewayIPStr
, &IPv4
->GatewayIpAddress
);
2063 StrToIPv4Addr (&SubnetMaskStr
, &IPv4
->SubnetMask
);
2065 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
2066 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
2069 IPv4
->LocalPort
= 0;
2070 IPv4
->RemotePort
= 0;
2072 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
2076 Converts a text device path node to IPV6 device path structure.
2078 @param TextDeviceNode The input Text device path node.
2080 @return A pointer to the newly-created IPV6 device path structure.
2083 EFI_DEVICE_PATH_PROTOCOL
*
2084 DevPathFromTextIPv6 (
2085 IN CHAR16
*TextDeviceNode
2088 CHAR16
*RemoteIPStr
;
2089 CHAR16
*ProtocolStr
;
2092 CHAR16
*GatewayIPStr
;
2093 CHAR16
*PrefixLengthStr
;
2094 IPv6_DEVICE_PATH
*IPv6
;
2096 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
2097 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2098 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2099 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
2100 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
2101 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
2102 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
2103 MESSAGING_DEVICE_PATH
,
2105 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
2108 StrToIPv6Addr (&RemoteIPStr
, &IPv6
->RemoteIpAddress
);
2109 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
2110 if (StrCmp (TypeStr
, L
"Static") == 0) {
2111 IPv6
->IpAddressOrigin
= 0;
2112 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
2113 IPv6
->IpAddressOrigin
= 1;
2115 IPv6
->IpAddressOrigin
= 2;
2118 StrToIPv6Addr (&LocalIPStr
, &IPv6
->LocalIpAddress
);
2119 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
2120 StrToIPv6Addr (&GatewayIPStr
, &IPv6
->GatewayIpAddress
);
2121 IPv6
->PrefixLength
= (UINT8
) Strtoi (PrefixLengthStr
);
2123 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
2124 IPv6
->PrefixLength
= 0;
2127 IPv6
->LocalPort
= 0;
2128 IPv6
->RemotePort
= 0;
2130 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
2134 Converts a text device path node to UART device path structure.
2136 @param TextDeviceNode The input Text device path node.
2138 @return A pointer to the newly-created UART device path structure.
2141 EFI_DEVICE_PATH_PROTOCOL
*
2142 DevPathFromTextUart (
2143 IN CHAR16
*TextDeviceNode
2147 CHAR16
*DataBitsStr
;
2149 CHAR16
*StopBitsStr
;
2150 UART_DEVICE_PATH
*Uart
;
2152 BaudStr
= GetNextParamStr (&TextDeviceNode
);
2153 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
2154 ParityStr
= GetNextParamStr (&TextDeviceNode
);
2155 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
2156 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
2157 MESSAGING_DEVICE_PATH
,
2159 (UINT16
) sizeof (UART_DEVICE_PATH
)
2162 if (StrCmp (BaudStr
, L
"DEFAULT") == 0) {
2163 Uart
->BaudRate
= 115200;
2165 Strtoi64 (BaudStr
, &Uart
->BaudRate
);
2167 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr
));
2168 switch (*ParityStr
) {
2194 Uart
->Parity
= (UINT8
) Strtoi (ParityStr
);
2198 if (StrCmp (StopBitsStr
, L
"D") == 0) {
2199 Uart
->StopBits
= (UINT8
) 0;
2200 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
2201 Uart
->StopBits
= (UINT8
) 1;
2202 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
2203 Uart
->StopBits
= (UINT8
) 2;
2204 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
2205 Uart
->StopBits
= (UINT8
) 3;
2207 Uart
->StopBits
= (UINT8
) Strtoi (StopBitsStr
);
2210 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
2214 Converts a text device path node to USB class device path structure.
2216 @param TextDeviceNode The input Text device path node.
2217 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
2219 @return A pointer to the newly-created USB class device path structure.
2222 EFI_DEVICE_PATH_PROTOCOL
*
2223 ConvertFromTextUsbClass (
2224 IN CHAR16
*TextDeviceNode
,
2225 IN USB_CLASS_TEXT
*UsbClassText
2231 CHAR16
*SubClassStr
;
2232 CHAR16
*ProtocolStr
;
2233 USB_CLASS_DEVICE_PATH
*UsbClass
;
2235 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
2236 MESSAGING_DEVICE_PATH
,
2238 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
2241 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2242 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2243 if (UsbClassText
->ClassExist
) {
2244 ClassStr
= GetNextParamStr (&TextDeviceNode
);
2245 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
2247 UsbClass
->DeviceClass
= UsbClassText
->Class
;
2249 if (UsbClassText
->SubClassExist
) {
2250 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
2251 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
2253 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
2256 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2258 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2259 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2260 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
2262 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
2267 Converts a text device path node to USB class device path structure.
2269 @param TextDeviceNode The input Text device path node.
2271 @return A pointer to the newly-created USB class device path structure.
2274 EFI_DEVICE_PATH_PROTOCOL
*
2275 DevPathFromTextUsbClass (
2276 IN CHAR16
*TextDeviceNode
2279 USB_CLASS_TEXT UsbClassText
;
2281 UsbClassText
.ClassExist
= TRUE
;
2282 UsbClassText
.SubClassExist
= TRUE
;
2284 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2288 Converts a text device path node to USB audio device path structure.
2290 @param TextDeviceNode The input Text device path node.
2292 @return A pointer to the newly-created USB audio device path structure.
2295 EFI_DEVICE_PATH_PROTOCOL
*
2296 DevPathFromTextUsbAudio (
2297 IN CHAR16
*TextDeviceNode
2300 USB_CLASS_TEXT UsbClassText
;
2302 UsbClassText
.ClassExist
= FALSE
;
2303 UsbClassText
.Class
= USB_CLASS_AUDIO
;
2304 UsbClassText
.SubClassExist
= TRUE
;
2306 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2310 Converts a text device path node to USB CDC Control device path structure.
2312 @param TextDeviceNode The input Text device path node.
2314 @return A pointer to the newly-created USB CDC Control device path structure.
2317 EFI_DEVICE_PATH_PROTOCOL
*
2318 DevPathFromTextUsbCDCControl (
2319 IN CHAR16
*TextDeviceNode
2322 USB_CLASS_TEXT UsbClassText
;
2324 UsbClassText
.ClassExist
= FALSE
;
2325 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
2326 UsbClassText
.SubClassExist
= TRUE
;
2328 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2332 Converts a text device path node to USB HID device path structure.
2334 @param TextDeviceNode The input Text device path node.
2336 @return A pointer to the newly-created USB HID device path structure.
2339 EFI_DEVICE_PATH_PROTOCOL
*
2340 DevPathFromTextUsbHID (
2341 IN CHAR16
*TextDeviceNode
2344 USB_CLASS_TEXT UsbClassText
;
2346 UsbClassText
.ClassExist
= FALSE
;
2347 UsbClassText
.Class
= USB_CLASS_HID
;
2348 UsbClassText
.SubClassExist
= TRUE
;
2350 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2354 Converts a text device path node to USB Image device path structure.
2356 @param TextDeviceNode The input Text device path node.
2358 @return A pointer to the newly-created USB Image device path structure.
2361 EFI_DEVICE_PATH_PROTOCOL
*
2362 DevPathFromTextUsbImage (
2363 IN CHAR16
*TextDeviceNode
2366 USB_CLASS_TEXT UsbClassText
;
2368 UsbClassText
.ClassExist
= FALSE
;
2369 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2370 UsbClassText
.SubClassExist
= TRUE
;
2372 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2376 Converts a text device path node to USB Print device path structure.
2378 @param TextDeviceNode The input Text device path node.
2380 @return A pointer to the newly-created USB Print device path structure.
2383 EFI_DEVICE_PATH_PROTOCOL
*
2384 DevPathFromTextUsbPrinter (
2385 IN CHAR16
*TextDeviceNode
2388 USB_CLASS_TEXT UsbClassText
;
2390 UsbClassText
.ClassExist
= FALSE
;
2391 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2392 UsbClassText
.SubClassExist
= TRUE
;
2394 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2398 Converts a text device path node to USB mass storage device path structure.
2400 @param TextDeviceNode The input Text device path node.
2402 @return A pointer to the newly-created USB mass storage device path structure.
2405 EFI_DEVICE_PATH_PROTOCOL
*
2406 DevPathFromTextUsbMassStorage (
2407 IN CHAR16
*TextDeviceNode
2410 USB_CLASS_TEXT UsbClassText
;
2412 UsbClassText
.ClassExist
= FALSE
;
2413 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2414 UsbClassText
.SubClassExist
= TRUE
;
2416 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2420 Converts a text device path node to USB HUB device path structure.
2422 @param TextDeviceNode The input Text device path node.
2424 @return A pointer to the newly-created USB HUB device path structure.
2427 EFI_DEVICE_PATH_PROTOCOL
*
2428 DevPathFromTextUsbHub (
2429 IN CHAR16
*TextDeviceNode
2432 USB_CLASS_TEXT UsbClassText
;
2434 UsbClassText
.ClassExist
= FALSE
;
2435 UsbClassText
.Class
= USB_CLASS_HUB
;
2436 UsbClassText
.SubClassExist
= TRUE
;
2438 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2442 Converts a text device path node to USB CDC data device path structure.
2444 @param TextDeviceNode The input Text device path node.
2446 @return A pointer to the newly-created USB CDC data device path structure.
2449 EFI_DEVICE_PATH_PROTOCOL
*
2450 DevPathFromTextUsbCDCData (
2451 IN CHAR16
*TextDeviceNode
2454 USB_CLASS_TEXT UsbClassText
;
2456 UsbClassText
.ClassExist
= FALSE
;
2457 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2458 UsbClassText
.SubClassExist
= TRUE
;
2460 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2464 Converts a text device path node to USB smart card device path structure.
2466 @param TextDeviceNode The input Text device path node.
2468 @return A pointer to the newly-created USB smart card device path structure.
2471 EFI_DEVICE_PATH_PROTOCOL
*
2472 DevPathFromTextUsbSmartCard (
2473 IN CHAR16
*TextDeviceNode
2476 USB_CLASS_TEXT UsbClassText
;
2478 UsbClassText
.ClassExist
= FALSE
;
2479 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2480 UsbClassText
.SubClassExist
= TRUE
;
2482 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2486 Converts a text device path node to USB video device path structure.
2488 @param TextDeviceNode The input Text device path node.
2490 @return A pointer to the newly-created USB video device path structure.
2493 EFI_DEVICE_PATH_PROTOCOL
*
2494 DevPathFromTextUsbVideo (
2495 IN CHAR16
*TextDeviceNode
2498 USB_CLASS_TEXT UsbClassText
;
2500 UsbClassText
.ClassExist
= FALSE
;
2501 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2502 UsbClassText
.SubClassExist
= TRUE
;
2504 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2508 Converts a text device path node to USB diagnostic device path structure.
2510 @param TextDeviceNode The input Text device path node.
2512 @return A pointer to the newly-created USB diagnostic device path structure.
2515 EFI_DEVICE_PATH_PROTOCOL
*
2516 DevPathFromTextUsbDiagnostic (
2517 IN CHAR16
*TextDeviceNode
2520 USB_CLASS_TEXT UsbClassText
;
2522 UsbClassText
.ClassExist
= FALSE
;
2523 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2524 UsbClassText
.SubClassExist
= TRUE
;
2526 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2530 Converts a text device path node to USB wireless device path structure.
2532 @param TextDeviceNode The input Text device path node.
2534 @return A pointer to the newly-created USB wireless device path structure.
2537 EFI_DEVICE_PATH_PROTOCOL
*
2538 DevPathFromTextUsbWireless (
2539 IN CHAR16
*TextDeviceNode
2542 USB_CLASS_TEXT UsbClassText
;
2544 UsbClassText
.ClassExist
= FALSE
;
2545 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2546 UsbClassText
.SubClassExist
= TRUE
;
2548 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2552 Converts a text device path node to USB device firmware update device path structure.
2554 @param TextDeviceNode The input Text device path node.
2556 @return A pointer to the newly-created USB device firmware update device path structure.
2559 EFI_DEVICE_PATH_PROTOCOL
*
2560 DevPathFromTextUsbDeviceFirmwareUpdate (
2561 IN CHAR16
*TextDeviceNode
2564 USB_CLASS_TEXT UsbClassText
;
2566 UsbClassText
.ClassExist
= FALSE
;
2567 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2568 UsbClassText
.SubClassExist
= FALSE
;
2569 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2571 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2575 Converts a text device path node to USB IRDA bridge device path structure.
2577 @param TextDeviceNode The input Text device path node.
2579 @return A pointer to the newly-created USB IRDA bridge device path structure.
2582 EFI_DEVICE_PATH_PROTOCOL
*
2583 DevPathFromTextUsbIrdaBridge (
2584 IN CHAR16
*TextDeviceNode
2587 USB_CLASS_TEXT UsbClassText
;
2589 UsbClassText
.ClassExist
= FALSE
;
2590 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2591 UsbClassText
.SubClassExist
= FALSE
;
2592 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2594 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2598 Converts a text device path node to USB text and measurement device path structure.
2600 @param TextDeviceNode The input Text device path node.
2602 @return A pointer to the newly-created USB text and measurement device path structure.
2605 EFI_DEVICE_PATH_PROTOCOL
*
2606 DevPathFromTextUsbTestAndMeasurement (
2607 IN CHAR16
*TextDeviceNode
2610 USB_CLASS_TEXT UsbClassText
;
2612 UsbClassText
.ClassExist
= FALSE
;
2613 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2614 UsbClassText
.SubClassExist
= FALSE
;
2615 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2617 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2621 Converts a text device path node to USB WWID device path structure.
2623 @param TextDeviceNode The input Text device path node.
2625 @return A pointer to the newly-created USB WWID device path structure.
2628 EFI_DEVICE_PATH_PROTOCOL
*
2629 DevPathFromTextUsbWwid (
2630 IN CHAR16
*TextDeviceNode
2635 CHAR16
*InterfaceNumStr
;
2636 CHAR16
*SerialNumberStr
;
2637 USB_WWID_DEVICE_PATH
*UsbWwid
;
2638 UINTN SerialNumberStrLen
;
2640 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2641 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2642 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2643 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2644 SerialNumberStrLen
= StrLen (SerialNumberStr
);
2645 if (SerialNumberStrLen
>= 2 &&
2646 SerialNumberStr
[0] == L
'\"' &&
2647 SerialNumberStr
[SerialNumberStrLen
- 1] == L
'\"'
2649 SerialNumberStr
[SerialNumberStrLen
- 1] = L
'\0';
2651 SerialNumberStrLen
-= 2;
2653 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2654 MESSAGING_DEVICE_PATH
,
2656 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + SerialNumberStrLen
* sizeof (CHAR16
))
2658 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2659 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2660 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2663 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
2664 // Therefore, the '\0' will not be copied.
2667 (UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
),
2669 SerialNumberStrLen
* sizeof (CHAR16
)
2672 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2676 Converts a text device path node to Logic Unit device path structure.
2678 @param TextDeviceNode The input Text device path node.
2680 @return A pointer to the newly-created Logic Unit device path structure.
2683 EFI_DEVICE_PATH_PROTOCOL
*
2684 DevPathFromTextUnit (
2685 IN CHAR16
*TextDeviceNode
2689 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2691 LunStr
= GetNextParamStr (&TextDeviceNode
);
2692 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2693 MESSAGING_DEVICE_PATH
,
2694 MSG_DEVICE_LOGICAL_UNIT_DP
,
2695 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2698 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2700 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2704 Converts a text device path node to iSCSI device path structure.
2706 @param TextDeviceNode The input Text device path node.
2708 @return A pointer to the newly-created iSCSI device path structure.
2711 EFI_DEVICE_PATH_PROTOCOL
*
2712 DevPathFromTextiSCSI (
2713 IN CHAR16
*TextDeviceNode
2718 CHAR16
*PortalGroupStr
;
2720 CHAR16
*HeaderDigestStr
;
2721 CHAR16
*DataDigestStr
;
2722 CHAR16
*AuthenticationStr
;
2723 CHAR16
*ProtocolStr
;
2725 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2727 NameStr
= GetNextParamStr (&TextDeviceNode
);
2728 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2729 LunStr
= GetNextParamStr (&TextDeviceNode
);
2730 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2731 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2732 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2733 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2734 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2735 MESSAGING_DEVICE_PATH
,
2737 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2740 AsciiStr
= ISCSIDevPath
->TargetName
;
2741 StrToAscii (NameStr
, &AsciiStr
);
2743 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2744 Strtoi64 (LunStr
, &ISCSIDevPath
->Lun
);
2747 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2751 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2755 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2759 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2763 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2765 ISCSIDevPath
->NetworkProtocol
= (UINT16
) StrCmp (ProtocolStr
, L
"TCP");
2767 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2771 Converts a text device path node to VLAN device path structure.
2773 @param TextDeviceNode The input Text device path node.
2775 @return A pointer to the newly-created VLAN device path structure.
2778 EFI_DEVICE_PATH_PROTOCOL
*
2779 DevPathFromTextVlan (
2780 IN CHAR16
*TextDeviceNode
2784 VLAN_DEVICE_PATH
*Vlan
;
2786 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2787 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2788 MESSAGING_DEVICE_PATH
,
2790 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2793 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2795 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2799 Converts a text device path node to Bluetooth device path structure.
2801 @param TextDeviceNode The input Text device path node.
2803 @return A pointer to the newly-created Bluetooth device path structure.
2806 EFI_DEVICE_PATH_PROTOCOL
*
2807 DevPathFromTextBluetooth (
2808 IN CHAR16
*TextDeviceNode
2811 CHAR16
*BluetoothStr
;
2813 CHAR16
*TempNumBuffer
;
2814 UINTN TempBufferSize
;
2816 BLUETOOTH_DEVICE_PATH
*BluetoothDp
;
2818 BluetoothStr
= GetNextParamStr (&TextDeviceNode
);
2819 BluetoothDp
= (BLUETOOTH_DEVICE_PATH
*) CreateDeviceNode (
2820 MESSAGING_DEVICE_PATH
,
2822 (UINT16
) sizeof (BLUETOOTH_DEVICE_PATH
)
2825 Index
= sizeof (BLUETOOTH_ADDRESS
) - 1;
2826 Walker
= BluetoothStr
;
2827 while (!IS_NULL(*Walker
) && Index
>= 0) {
2828 TempBufferSize
= 2 * sizeof(CHAR16
) + StrSize(L
"0x");
2829 TempNumBuffer
= AllocateZeroPool (TempBufferSize
);
2830 if (TempNumBuffer
== NULL
) {
2833 StrCpyS (TempNumBuffer
, TempBufferSize
/ sizeof (CHAR16
), L
"0x");
2834 StrnCatS (TempNumBuffer
, TempBufferSize
/ sizeof (CHAR16
), Walker
, 2);
2835 BluetoothDp
->BD_ADDR
.Address
[Index
] = (UINT8
)Strtoi (TempNumBuffer
);
2836 FreePool (TempNumBuffer
);
2841 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothDp
;
2845 Converts a text device path node to Wi-Fi device path structure.
2847 @param TextDeviceNode The input Text device path node.
2849 @return A pointer to the newly-created Wi-Fi device path structure.
2852 EFI_DEVICE_PATH_PROTOCOL
*
2853 DevPathFromTextWiFi (
2854 IN CHAR16
*TextDeviceNode
2860 WIFI_DEVICE_PATH
*WiFiDp
;
2862 SSIdStr
= GetNextParamStr (&TextDeviceNode
);
2863 WiFiDp
= (WIFI_DEVICE_PATH
*) CreateDeviceNode (
2864 MESSAGING_DEVICE_PATH
,
2866 (UINT16
) sizeof (WIFI_DEVICE_PATH
)
2869 if (NULL
!= SSIdStr
) {
2870 DataLen
= StrLen (SSIdStr
);
2871 if (StrLen (SSIdStr
) > 32) {
2872 SSIdStr
[32] = L
'\0';
2876 UnicodeStrToAsciiStr (SSIdStr
, AsciiStr
);
2877 CopyMem (WiFiDp
->SSId
, AsciiStr
, DataLen
);
2880 return (EFI_DEVICE_PATH_PROTOCOL
*) WiFiDp
;
2884 Converts a text device path node to URI device path structure.
2886 @param TextDeviceNode The input Text device path node.
2888 @return A pointer to the newly-created URI device path structure.
2891 EFI_DEVICE_PATH_PROTOCOL
*
2892 DevPathFromTextUri (
2893 IN CHAR16
*TextDeviceNode
2898 URI_DEVICE_PATH
*Uri
;
2900 UriStr
= GetNextParamStr (&TextDeviceNode
);
2901 UriLength
= StrnLenS (UriStr
, MAX_UINT16
- sizeof (URI_DEVICE_PATH
));
2902 Uri
= (URI_DEVICE_PATH
*) CreateDeviceNode (
2903 MESSAGING_DEVICE_PATH
,
2905 (UINT16
) (sizeof (URI_DEVICE_PATH
) + UriLength
)
2908 while (UriLength
-- != 0) {
2909 Uri
->Uri
[UriLength
] = (CHAR8
) UriStr
[UriLength
];
2912 return (EFI_DEVICE_PATH_PROTOCOL
*) Uri
;
2916 Converts a media text device path node to media device path structure.
2918 @param TextDeviceNode The input Text device path node.
2920 @return A pointer to media device path structure.
2923 EFI_DEVICE_PATH_PROTOCOL
*
2924 DevPathFromTextMediaPath (
2925 IN CHAR16
*TextDeviceNode
2928 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH
, TextDeviceNode
);
2932 Converts a text device path node to HD device path structure.
2934 @param TextDeviceNode The input Text device path node.
2936 @return A pointer to the newly-created HD device path structure.
2939 EFI_DEVICE_PATH_PROTOCOL
*
2941 IN CHAR16
*TextDeviceNode
2944 CHAR16
*PartitionStr
;
2946 CHAR16
*SignatureStr
;
2950 EFI_GUID SignatureGuid
;
2951 HARDDRIVE_DEVICE_PATH
*Hd
;
2953 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2954 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2955 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2956 StartStr
= GetNextParamStr (&TextDeviceNode
);
2957 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2958 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2961 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2964 Hd
->PartitionNumber
= (UINT32
) Strtoi (PartitionStr
);
2966 ZeroMem (Hd
->Signature
, 16);
2967 Hd
->MBRType
= (UINT8
) 0;
2969 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2970 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2973 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2974 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2975 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2976 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2979 StrToGuid (SignatureStr
, &SignatureGuid
);
2980 CopyMem (Hd
->Signature
, &SignatureGuid
, sizeof (EFI_GUID
));
2982 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2985 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2986 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2988 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2992 Converts a text device path node to CDROM device path structure.
2994 @param TextDeviceNode The input Text device path node.
2996 @return A pointer to the newly-created CDROM device path structure.
2999 EFI_DEVICE_PATH_PROTOCOL
*
3000 DevPathFromTextCDROM (
3001 IN CHAR16
*TextDeviceNode
3007 CDROM_DEVICE_PATH
*CDROMDevPath
;
3009 EntryStr
= GetNextParamStr (&TextDeviceNode
);
3010 StartStr
= GetNextParamStr (&TextDeviceNode
);
3011 SizeStr
= GetNextParamStr (&TextDeviceNode
);
3012 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
3015 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
3018 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
3019 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
3020 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
3022 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
3026 Converts a text device path node to Vendor-defined media device path structure.
3028 @param TextDeviceNode The input Text device path node.
3030 @return A pointer to the newly-created Vendor-defined media device path structure.
3033 EFI_DEVICE_PATH_PROTOCOL
*
3034 DevPathFromTextVenMedia (
3035 IN CHAR16
*TextDeviceNode
3038 return ConvertFromTextVendor (
3046 Converts a text device path node to File device path structure.
3048 @param TextDeviceNode The input Text device path node.
3050 @return A pointer to the newly-created File device path structure.
3053 EFI_DEVICE_PATH_PROTOCOL
*
3054 DevPathFromTextFilePath (
3055 IN CHAR16
*TextDeviceNode
3058 FILEPATH_DEVICE_PATH
*File
;
3060 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
3063 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
3066 StrCpyS (File
->PathName
, StrLen (TextDeviceNode
) + 1, TextDeviceNode
);
3068 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
3072 Converts a text device path node to Media protocol device path structure.
3074 @param TextDeviceNode The input Text device path node.
3076 @return A pointer to the newly-created Media protocol device path structure.
3079 EFI_DEVICE_PATH_PROTOCOL
*
3080 DevPathFromTextMedia (
3081 IN CHAR16
*TextDeviceNode
3085 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
3087 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3088 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
3091 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
3094 StrToGuid (GuidStr
, &Media
->Protocol
);
3096 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
3100 Converts a text device path node to firmware volume device path structure.
3102 @param TextDeviceNode The input Text device path node.
3104 @return A pointer to the newly-created firmware volume device path structure.
3107 EFI_DEVICE_PATH_PROTOCOL
*
3109 IN CHAR16
*TextDeviceNode
3113 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
3115 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3116 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
3118 MEDIA_PIWG_FW_VOL_DP
,
3119 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
3122 StrToGuid (GuidStr
, &Fv
->FvName
);
3124 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
3128 Converts a text device path node to firmware file device path structure.
3130 @param TextDeviceNode The input Text device path node.
3132 @return A pointer to the newly-created firmware file device path structure.
3135 EFI_DEVICE_PATH_PROTOCOL
*
3136 DevPathFromTextFvFile (
3137 IN CHAR16
*TextDeviceNode
3141 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
3143 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3144 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
3146 MEDIA_PIWG_FW_FILE_DP
,
3147 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
3150 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
3152 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
3156 Converts a text device path node to text relative offset device path structure.
3158 @param TextDeviceNode The input Text device path node.
3160 @return A pointer to the newly-created Text device path structure.
3163 EFI_DEVICE_PATH_PROTOCOL
*
3164 DevPathFromTextRelativeOffsetRange (
3165 IN CHAR16
*TextDeviceNode
3168 CHAR16
*StartingOffsetStr
;
3169 CHAR16
*EndingOffsetStr
;
3170 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
3172 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
3173 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
3174 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
3176 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
3177 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
3180 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
3181 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
3183 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
3187 Converts a text device path node to text ram disk device path structure.
3189 @param TextDeviceNode The input Text device path node.
3191 @return A pointer to the newly-created Text device path structure.
3194 EFI_DEVICE_PATH_PROTOCOL
*
3195 DevPathFromTextRamDisk (
3196 IN CHAR16
*TextDeviceNode
3199 CHAR16
*StartingAddrStr
;
3200 CHAR16
*EndingAddrStr
;
3201 CHAR16
*TypeGuidStr
;
3202 CHAR16
*InstanceStr
;
3203 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3204 UINT64 StartingAddr
;
3207 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3208 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3209 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3210 TypeGuidStr
= GetNextParamStr (&TextDeviceNode
);
3211 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3214 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3217 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3218 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3219 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3220 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3221 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3222 StrToGuid (TypeGuidStr
, &RamDisk
->TypeGuid
);
3224 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3228 Converts a text device path node to text virtual disk device path structure.
3230 @param TextDeviceNode The input Text device path node.
3232 @return A pointer to the newly-created Text device path structure.
3235 EFI_DEVICE_PATH_PROTOCOL
*
3236 DevPathFromTextVirtualDisk (
3237 IN CHAR16
*TextDeviceNode
3240 CHAR16
*StartingAddrStr
;
3241 CHAR16
*EndingAddrStr
;
3242 CHAR16
*InstanceStr
;
3243 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3244 UINT64 StartingAddr
;
3247 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3248 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3249 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3251 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3254 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3257 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3258 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3259 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3260 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3261 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3262 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualDiskGuid
);
3264 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3268 Converts a text device path node to text virtual cd device path structure.
3270 @param TextDeviceNode The input Text device path node.
3272 @return A pointer to the newly-created Text device path structure.
3275 EFI_DEVICE_PATH_PROTOCOL
*
3276 DevPathFromTextVirtualCd (
3277 IN CHAR16
*TextDeviceNode
3280 CHAR16
*StartingAddrStr
;
3281 CHAR16
*EndingAddrStr
;
3282 CHAR16
*InstanceStr
;
3283 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3284 UINT64 StartingAddr
;
3287 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3288 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3289 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3291 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3294 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3297 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3298 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3299 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3300 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3301 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3302 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualCdGuid
);
3304 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3308 Converts a text device path node to text persistent virtual disk device path structure.
3310 @param TextDeviceNode The input Text device path node.
3312 @return A pointer to the newly-created Text device path structure.
3315 EFI_DEVICE_PATH_PROTOCOL
*
3316 DevPathFromTextPersistentVirtualDisk (
3317 IN CHAR16
*TextDeviceNode
3320 CHAR16
*StartingAddrStr
;
3321 CHAR16
*EndingAddrStr
;
3322 CHAR16
*InstanceStr
;
3323 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3324 UINT64 StartingAddr
;
3327 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3328 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3329 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3331 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3334 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3337 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3338 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3339 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3340 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3341 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3342 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualDiskGuid
);
3344 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3348 Converts a text device path node to text persistent virtual cd device path structure.
3350 @param TextDeviceNode The input Text device path node.
3352 @return A pointer to the newly-created Text device path structure.
3355 EFI_DEVICE_PATH_PROTOCOL
*
3356 DevPathFromTextPersistentVirtualCd (
3357 IN CHAR16
*TextDeviceNode
3360 CHAR16
*StartingAddrStr
;
3361 CHAR16
*EndingAddrStr
;
3362 CHAR16
*InstanceStr
;
3363 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3364 UINT64 StartingAddr
;
3367 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3368 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3369 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3371 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3374 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3377 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3378 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3379 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3380 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3381 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3382 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualCdGuid
);
3384 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3388 Converts a BBS text device path node to BBS device path structure.
3390 @param TextDeviceNode The input Text device path node.
3392 @return A pointer to BBS device path structure.
3395 EFI_DEVICE_PATH_PROTOCOL
*
3396 DevPathFromTextBbsPath (
3397 IN CHAR16
*TextDeviceNode
3400 return DevPathFromTextGenericPath (BBS_DEVICE_PATH
, TextDeviceNode
);
3404 Converts a text device path node to BIOS Boot Specification device path structure.
3406 @param TextDeviceNode The input Text device path node.
3408 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3411 EFI_DEVICE_PATH_PROTOCOL
*
3412 DevPathFromTextBBS (
3413 IN CHAR16
*TextDeviceNode
3420 BBS_BBS_DEVICE_PATH
*Bbs
;
3422 TypeStr
= GetNextParamStr (&TextDeviceNode
);
3423 IdStr
= GetNextParamStr (&TextDeviceNode
);
3424 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
3425 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
3428 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
3431 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
3432 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
3433 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
3434 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
3435 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
3436 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
3437 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
3438 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
3439 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
3440 Bbs
->DeviceType
= BBS_TYPE_USB
;
3441 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
3442 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
3444 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
3447 AsciiStr
= Bbs
->String
;
3448 StrToAscii (IdStr
, &AsciiStr
);
3450 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
3452 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
3456 Converts a text device path node to SATA device path structure.
3458 @param TextDeviceNode The input Text device path node.
3460 @return A pointer to the newly-created SATA device path structure.
3463 EFI_DEVICE_PATH_PROTOCOL
*
3464 DevPathFromTextSata (
3465 IN CHAR16
*TextDeviceNode
3468 SATA_DEVICE_PATH
*Sata
;
3473 Param1
= GetNextParamStr (&TextDeviceNode
);
3474 Param2
= GetNextParamStr (&TextDeviceNode
);
3475 Param3
= GetNextParamStr (&TextDeviceNode
);
3477 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
3478 MESSAGING_DEVICE_PATH
,
3480 (UINT16
) sizeof (SATA_DEVICE_PATH
)
3482 Sata
->HBAPortNumber
= (UINT16
) Strtoi (Param1
);
3483 Sata
->PortMultiplierPortNumber
= (UINT16
) Strtoi (Param2
);
3484 Sata
->Lun
= (UINT16
) Strtoi (Param3
);
3486 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
3489 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
3490 {L
"Path", DevPathFromTextPath
},
3492 {L
"HardwarePath", DevPathFromTextHardwarePath
},
3493 {L
"Pci", DevPathFromTextPci
},
3494 {L
"PcCard", DevPathFromTextPcCard
},
3495 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
3496 {L
"VenHw", DevPathFromTextVenHw
},
3497 {L
"Ctrl", DevPathFromTextCtrl
},
3498 {L
"BMC", DevPathFromTextBmc
},
3500 {L
"AcpiPath", DevPathFromTextAcpiPath
},
3501 {L
"Acpi", DevPathFromTextAcpi
},
3502 {L
"PciRoot", DevPathFromTextPciRoot
},
3503 {L
"PcieRoot", DevPathFromTextPcieRoot
},
3504 {L
"Floppy", DevPathFromTextFloppy
},
3505 {L
"Keyboard", DevPathFromTextKeyboard
},
3506 {L
"Serial", DevPathFromTextSerial
},
3507 {L
"ParallelPort", DevPathFromTextParallelPort
},
3508 {L
"AcpiEx", DevPathFromTextAcpiEx
},
3509 {L
"AcpiExp", DevPathFromTextAcpiExp
},
3510 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
3512 {L
"Msg", DevPathFromTextMsg
},
3513 {L
"Ata", DevPathFromTextAta
},
3514 {L
"Scsi", DevPathFromTextScsi
},
3515 {L
"Fibre", DevPathFromTextFibre
},
3516 {L
"FibreEx", DevPathFromTextFibreEx
},
3517 {L
"I1394", DevPathFromText1394
},
3518 {L
"USB", DevPathFromTextUsb
},
3519 {L
"I2O", DevPathFromTextI2O
},
3520 {L
"Infiniband", DevPathFromTextInfiniband
},
3521 {L
"VenMsg", DevPathFromTextVenMsg
},
3522 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
3523 {L
"VenVt100", DevPathFromTextVenVt100
},
3524 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
3525 {L
"VenUtf8", DevPathFromTextVenUtf8
},
3526 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
3527 {L
"SAS", DevPathFromTextSAS
},
3528 {L
"SasEx", DevPathFromTextSasEx
},
3529 {L
"NVMe", DevPathFromTextNVMe
},
3530 {L
"UFS", DevPathFromTextUfs
},
3531 {L
"SD", DevPathFromTextSd
},
3532 {L
"Emmc", DevPathFromTextEmmc
},
3533 {L
"DebugPort", DevPathFromTextDebugPort
},
3534 {L
"MAC", DevPathFromTextMAC
},
3535 {L
"IPv4", DevPathFromTextIPv4
},
3536 {L
"IPv6", DevPathFromTextIPv6
},
3537 {L
"Uart", DevPathFromTextUart
},
3538 {L
"UsbClass", DevPathFromTextUsbClass
},
3539 {L
"UsbAudio", DevPathFromTextUsbAudio
},
3540 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
3541 {L
"UsbHID", DevPathFromTextUsbHID
},
3542 {L
"UsbImage", DevPathFromTextUsbImage
},
3543 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
3544 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
3545 {L
"UsbHub", DevPathFromTextUsbHub
},
3546 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
3547 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
3548 {L
"UsbVideo", DevPathFromTextUsbVideo
},
3549 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
3550 {L
"UsbWireless", DevPathFromTextUsbWireless
},
3551 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
3552 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
3553 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
3554 {L
"UsbWwid", DevPathFromTextUsbWwid
},
3555 {L
"Unit", DevPathFromTextUnit
},
3556 {L
"iSCSI", DevPathFromTextiSCSI
},
3557 {L
"Vlan", DevPathFromTextVlan
},
3558 {L
"Uri", DevPathFromTextUri
},
3559 {L
"Bluetooth", DevPathFromTextBluetooth
},
3560 {L
"Wi-Fi", DevPathFromTextWiFi
},
3561 {L
"MediaPath", DevPathFromTextMediaPath
},
3562 {L
"HD", DevPathFromTextHD
},
3563 {L
"CDROM", DevPathFromTextCDROM
},
3564 {L
"VenMedia", DevPathFromTextVenMedia
},
3565 {L
"Media", DevPathFromTextMedia
},
3566 {L
"Fv", DevPathFromTextFv
},
3567 {L
"FvFile", DevPathFromTextFvFile
},
3568 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
3569 {L
"RamDisk", DevPathFromTextRamDisk
},
3570 {L
"VirtualDisk", DevPathFromTextVirtualDisk
},
3571 {L
"VirtualCD", DevPathFromTextVirtualCd
},
3572 {L
"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk
},
3573 {L
"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd
},
3575 {L
"BbsPath", DevPathFromTextBbsPath
},
3576 {L
"BBS", DevPathFromTextBBS
},
3577 {L
"Sata", DevPathFromTextSata
},
3582 Convert text to the binary representation of a device node.
3584 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3585 node. Conversion starts with the first character and continues
3586 until the first non-device node character.
3588 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3589 insufficient memory or text unsupported.
3592 EFI_DEVICE_PATH_PROTOCOL
*
3594 UefiDevicePathLibConvertTextToDeviceNode (
3595 IN CONST CHAR16
*TextDeviceNode
3598 DEVICE_PATH_FROM_TEXT FromText
;
3600 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3601 CHAR16
*DeviceNodeStr
;
3604 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
3610 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
3611 ASSERT (DeviceNodeStr
!= NULL
);
3613 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3614 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
3615 if (ParamStr
!= NULL
) {
3616 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
3621 if (FromText
== NULL
) {
3625 FromText
= DevPathFromTextFilePath
;
3626 DeviceNode
= FromText (DeviceNodeStr
);
3628 DeviceNode
= FromText (ParamStr
);
3629 FreePool (ParamStr
);
3632 FreePool (DeviceNodeStr
);
3638 Convert text to the binary representation of a device path.
3641 @param TextDevicePath TextDevicePath points to the text representation of a device
3642 path. Conversion starts with the first character and continues
3643 until the first non-device node character.
3645 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3646 there was insufficient memory.
3649 EFI_DEVICE_PATH_PROTOCOL
*
3651 UefiDevicePathLibConvertTextToDevicePath (
3652 IN CONST CHAR16
*TextDevicePath
3655 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3656 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3657 CHAR16
*DevicePathStr
;
3659 CHAR16
*DeviceNodeStr
;
3660 BOOLEAN IsInstanceEnd
;
3661 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3663 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3667 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3668 ASSERT (DevicePath
!= NULL
);
3669 SetDevicePathEndNode (DevicePath
);
3671 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3673 Str
= DevicePathStr
;
3674 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3675 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3677 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3678 FreePool (DevicePath
);
3679 FreePool (DeviceNode
);
3680 DevicePath
= NewDevicePath
;
3682 if (IsInstanceEnd
) {
3683 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3684 ASSERT (DeviceNode
!= NULL
);
3685 SetDevicePathEndNode (DeviceNode
);
3687 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3688 FreePool (DevicePath
);
3689 FreePool (DeviceNode
);
3690 DevicePath
= NewDevicePath
;
3694 FreePool (DevicePathStr
);