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 Debug Port device path structure.
1908 @param TextDeviceNode The input Text device path node.
1910 @return A pointer to the newly-created Debug Port device path structure.
1913 EFI_DEVICE_PATH_PROTOCOL
*
1914 DevPathFromTextDebugPort (
1915 IN CHAR16
*TextDeviceNode
1918 VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*Vend
;
1920 Vend
= (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*) CreateDeviceNode (
1921 MESSAGING_DEVICE_PATH
,
1923 (UINT16
) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
)
1926 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1928 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1932 Converts a text device path node to MAC device path structure.
1934 @param TextDeviceNode The input Text device path node.
1936 @return A pointer to the newly-created MAC device path structure.
1939 EFI_DEVICE_PATH_PROTOCOL
*
1940 DevPathFromTextMAC (
1941 IN CHAR16
*TextDeviceNode
1947 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1949 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1950 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1951 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1952 MESSAGING_DEVICE_PATH
,
1954 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1957 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1959 Length
= sizeof (EFI_MAC_ADDRESS
);
1960 StrToBuf (&MACDevPath
->MacAddress
.Addr
[0], Length
, AddressStr
);
1962 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1967 Converts a text format to the network protocol ID.
1969 @param Text String of protocol field.
1971 @return Network protocol ID .
1975 NetworkProtocolFromText (
1979 if (StrCmp (Text
, L
"UDP") == 0) {
1980 return RFC_1700_UDP_PROTOCOL
;
1983 if (StrCmp (Text
, L
"TCP") == 0) {
1984 return RFC_1700_TCP_PROTOCOL
;
1987 return Strtoi (Text
);
1992 Converts a text device path node to IPV4 device path structure.
1994 @param TextDeviceNode The input Text device path node.
1996 @return A pointer to the newly-created IPV4 device path structure.
1999 EFI_DEVICE_PATH_PROTOCOL
*
2000 DevPathFromTextIPv4 (
2001 IN CHAR16
*TextDeviceNode
2004 CHAR16
*RemoteIPStr
;
2005 CHAR16
*ProtocolStr
;
2008 CHAR16
*GatewayIPStr
;
2009 CHAR16
*SubnetMaskStr
;
2010 IPv4_DEVICE_PATH
*IPv4
;
2012 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
2013 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2014 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2015 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
2016 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
2017 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
2018 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
2019 MESSAGING_DEVICE_PATH
,
2021 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
2024 StrToIPv4Addr (&RemoteIPStr
, &IPv4
->RemoteIpAddress
);
2025 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
2026 if (StrCmp (TypeStr
, L
"Static") == 0) {
2027 IPv4
->StaticIpAddress
= TRUE
;
2029 IPv4
->StaticIpAddress
= FALSE
;
2032 StrToIPv4Addr (&LocalIPStr
, &IPv4
->LocalIpAddress
);
2033 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
2034 StrToIPv4Addr (&GatewayIPStr
, &IPv4
->GatewayIpAddress
);
2035 StrToIPv4Addr (&SubnetMaskStr
, &IPv4
->SubnetMask
);
2037 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
2038 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
2041 IPv4
->LocalPort
= 0;
2042 IPv4
->RemotePort
= 0;
2044 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
2048 Converts a text device path node to IPV6 device path structure.
2050 @param TextDeviceNode The input Text device path node.
2052 @return A pointer to the newly-created IPV6 device path structure.
2055 EFI_DEVICE_PATH_PROTOCOL
*
2056 DevPathFromTextIPv6 (
2057 IN CHAR16
*TextDeviceNode
2060 CHAR16
*RemoteIPStr
;
2061 CHAR16
*ProtocolStr
;
2064 CHAR16
*GatewayIPStr
;
2065 CHAR16
*PrefixLengthStr
;
2066 IPv6_DEVICE_PATH
*IPv6
;
2068 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
2069 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2070 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2071 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
2072 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
2073 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
2074 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
2075 MESSAGING_DEVICE_PATH
,
2077 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
2080 StrToIPv6Addr (&RemoteIPStr
, &IPv6
->RemoteIpAddress
);
2081 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
2082 if (StrCmp (TypeStr
, L
"Static") == 0) {
2083 IPv6
->IpAddressOrigin
= 0;
2084 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
2085 IPv6
->IpAddressOrigin
= 1;
2087 IPv6
->IpAddressOrigin
= 2;
2090 StrToIPv6Addr (&LocalIPStr
, &IPv6
->LocalIpAddress
);
2091 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
2092 StrToIPv6Addr (&GatewayIPStr
, &IPv6
->GatewayIpAddress
);
2093 IPv6
->PrefixLength
= (UINT8
) Strtoi (PrefixLengthStr
);
2095 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
2096 IPv6
->PrefixLength
= 0;
2099 IPv6
->LocalPort
= 0;
2100 IPv6
->RemotePort
= 0;
2102 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
2106 Converts a text device path node to UART device path structure.
2108 @param TextDeviceNode The input Text device path node.
2110 @return A pointer to the newly-created UART device path structure.
2113 EFI_DEVICE_PATH_PROTOCOL
*
2114 DevPathFromTextUart (
2115 IN CHAR16
*TextDeviceNode
2119 CHAR16
*DataBitsStr
;
2121 CHAR16
*StopBitsStr
;
2122 UART_DEVICE_PATH
*Uart
;
2124 BaudStr
= GetNextParamStr (&TextDeviceNode
);
2125 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
2126 ParityStr
= GetNextParamStr (&TextDeviceNode
);
2127 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
2128 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
2129 MESSAGING_DEVICE_PATH
,
2131 (UINT16
) sizeof (UART_DEVICE_PATH
)
2134 if (StrCmp (BaudStr
, L
"DEFAULT") == 0) {
2135 Uart
->BaudRate
= 115200;
2137 Strtoi64 (BaudStr
, &Uart
->BaudRate
);
2139 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr
));
2140 switch (*ParityStr
) {
2166 Uart
->Parity
= (UINT8
) Strtoi (ParityStr
);
2170 if (StrCmp (StopBitsStr
, L
"D") == 0) {
2171 Uart
->StopBits
= (UINT8
) 0;
2172 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
2173 Uart
->StopBits
= (UINT8
) 1;
2174 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
2175 Uart
->StopBits
= (UINT8
) 2;
2176 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
2177 Uart
->StopBits
= (UINT8
) 3;
2179 Uart
->StopBits
= (UINT8
) Strtoi (StopBitsStr
);
2182 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
2186 Converts a text device path node to USB class device path structure.
2188 @param TextDeviceNode The input Text device path node.
2189 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
2191 @return A pointer to the newly-created USB class device path structure.
2194 EFI_DEVICE_PATH_PROTOCOL
*
2195 ConvertFromTextUsbClass (
2196 IN CHAR16
*TextDeviceNode
,
2197 IN USB_CLASS_TEXT
*UsbClassText
2203 CHAR16
*SubClassStr
;
2204 CHAR16
*ProtocolStr
;
2205 USB_CLASS_DEVICE_PATH
*UsbClass
;
2207 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
2208 MESSAGING_DEVICE_PATH
,
2210 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
2213 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2214 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2215 if (UsbClassText
->ClassExist
) {
2216 ClassStr
= GetNextParamStr (&TextDeviceNode
);
2217 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
2219 UsbClass
->DeviceClass
= UsbClassText
->Class
;
2221 if (UsbClassText
->SubClassExist
) {
2222 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
2223 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
2225 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
2228 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2230 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2231 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2232 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
2234 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
2239 Converts a text device path node to USB class device path structure.
2241 @param TextDeviceNode The input Text device path node.
2243 @return A pointer to the newly-created USB class device path structure.
2246 EFI_DEVICE_PATH_PROTOCOL
*
2247 DevPathFromTextUsbClass (
2248 IN CHAR16
*TextDeviceNode
2251 USB_CLASS_TEXT UsbClassText
;
2253 UsbClassText
.ClassExist
= TRUE
;
2254 UsbClassText
.SubClassExist
= TRUE
;
2256 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2260 Converts a text device path node to USB audio device path structure.
2262 @param TextDeviceNode The input Text device path node.
2264 @return A pointer to the newly-created USB audio device path structure.
2267 EFI_DEVICE_PATH_PROTOCOL
*
2268 DevPathFromTextUsbAudio (
2269 IN CHAR16
*TextDeviceNode
2272 USB_CLASS_TEXT UsbClassText
;
2274 UsbClassText
.ClassExist
= FALSE
;
2275 UsbClassText
.Class
= USB_CLASS_AUDIO
;
2276 UsbClassText
.SubClassExist
= TRUE
;
2278 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2282 Converts a text device path node to USB CDC Control device path structure.
2284 @param TextDeviceNode The input Text device path node.
2286 @return A pointer to the newly-created USB CDC Control device path structure.
2289 EFI_DEVICE_PATH_PROTOCOL
*
2290 DevPathFromTextUsbCDCControl (
2291 IN CHAR16
*TextDeviceNode
2294 USB_CLASS_TEXT UsbClassText
;
2296 UsbClassText
.ClassExist
= FALSE
;
2297 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
2298 UsbClassText
.SubClassExist
= TRUE
;
2300 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2304 Converts a text device path node to USB HID device path structure.
2306 @param TextDeviceNode The input Text device path node.
2308 @return A pointer to the newly-created USB HID device path structure.
2311 EFI_DEVICE_PATH_PROTOCOL
*
2312 DevPathFromTextUsbHID (
2313 IN CHAR16
*TextDeviceNode
2316 USB_CLASS_TEXT UsbClassText
;
2318 UsbClassText
.ClassExist
= FALSE
;
2319 UsbClassText
.Class
= USB_CLASS_HID
;
2320 UsbClassText
.SubClassExist
= TRUE
;
2322 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2326 Converts a text device path node to USB Image device path structure.
2328 @param TextDeviceNode The input Text device path node.
2330 @return A pointer to the newly-created USB Image device path structure.
2333 EFI_DEVICE_PATH_PROTOCOL
*
2334 DevPathFromTextUsbImage (
2335 IN CHAR16
*TextDeviceNode
2338 USB_CLASS_TEXT UsbClassText
;
2340 UsbClassText
.ClassExist
= FALSE
;
2341 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2342 UsbClassText
.SubClassExist
= TRUE
;
2344 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2348 Converts a text device path node to USB Print device path structure.
2350 @param TextDeviceNode The input Text device path node.
2352 @return A pointer to the newly-created USB Print device path structure.
2355 EFI_DEVICE_PATH_PROTOCOL
*
2356 DevPathFromTextUsbPrinter (
2357 IN CHAR16
*TextDeviceNode
2360 USB_CLASS_TEXT UsbClassText
;
2362 UsbClassText
.ClassExist
= FALSE
;
2363 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2364 UsbClassText
.SubClassExist
= TRUE
;
2366 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2370 Converts a text device path node to USB mass storage device path structure.
2372 @param TextDeviceNode The input Text device path node.
2374 @return A pointer to the newly-created USB mass storage device path structure.
2377 EFI_DEVICE_PATH_PROTOCOL
*
2378 DevPathFromTextUsbMassStorage (
2379 IN CHAR16
*TextDeviceNode
2382 USB_CLASS_TEXT UsbClassText
;
2384 UsbClassText
.ClassExist
= FALSE
;
2385 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2386 UsbClassText
.SubClassExist
= TRUE
;
2388 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2392 Converts a text device path node to USB HUB device path structure.
2394 @param TextDeviceNode The input Text device path node.
2396 @return A pointer to the newly-created USB HUB device path structure.
2399 EFI_DEVICE_PATH_PROTOCOL
*
2400 DevPathFromTextUsbHub (
2401 IN CHAR16
*TextDeviceNode
2404 USB_CLASS_TEXT UsbClassText
;
2406 UsbClassText
.ClassExist
= FALSE
;
2407 UsbClassText
.Class
= USB_CLASS_HUB
;
2408 UsbClassText
.SubClassExist
= TRUE
;
2410 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2414 Converts a text device path node to USB CDC data device path structure.
2416 @param TextDeviceNode The input Text device path node.
2418 @return A pointer to the newly-created USB CDC data device path structure.
2421 EFI_DEVICE_PATH_PROTOCOL
*
2422 DevPathFromTextUsbCDCData (
2423 IN CHAR16
*TextDeviceNode
2426 USB_CLASS_TEXT UsbClassText
;
2428 UsbClassText
.ClassExist
= FALSE
;
2429 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2430 UsbClassText
.SubClassExist
= TRUE
;
2432 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2436 Converts a text device path node to USB smart card device path structure.
2438 @param TextDeviceNode The input Text device path node.
2440 @return A pointer to the newly-created USB smart card device path structure.
2443 EFI_DEVICE_PATH_PROTOCOL
*
2444 DevPathFromTextUsbSmartCard (
2445 IN CHAR16
*TextDeviceNode
2448 USB_CLASS_TEXT UsbClassText
;
2450 UsbClassText
.ClassExist
= FALSE
;
2451 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2452 UsbClassText
.SubClassExist
= TRUE
;
2454 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2458 Converts a text device path node to USB video device path structure.
2460 @param TextDeviceNode The input Text device path node.
2462 @return A pointer to the newly-created USB video device path structure.
2465 EFI_DEVICE_PATH_PROTOCOL
*
2466 DevPathFromTextUsbVideo (
2467 IN CHAR16
*TextDeviceNode
2470 USB_CLASS_TEXT UsbClassText
;
2472 UsbClassText
.ClassExist
= FALSE
;
2473 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2474 UsbClassText
.SubClassExist
= TRUE
;
2476 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2480 Converts a text device path node to USB diagnostic device path structure.
2482 @param TextDeviceNode The input Text device path node.
2484 @return A pointer to the newly-created USB diagnostic device path structure.
2487 EFI_DEVICE_PATH_PROTOCOL
*
2488 DevPathFromTextUsbDiagnostic (
2489 IN CHAR16
*TextDeviceNode
2492 USB_CLASS_TEXT UsbClassText
;
2494 UsbClassText
.ClassExist
= FALSE
;
2495 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2496 UsbClassText
.SubClassExist
= TRUE
;
2498 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2502 Converts a text device path node to USB wireless device path structure.
2504 @param TextDeviceNode The input Text device path node.
2506 @return A pointer to the newly-created USB wireless device path structure.
2509 EFI_DEVICE_PATH_PROTOCOL
*
2510 DevPathFromTextUsbWireless (
2511 IN CHAR16
*TextDeviceNode
2514 USB_CLASS_TEXT UsbClassText
;
2516 UsbClassText
.ClassExist
= FALSE
;
2517 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2518 UsbClassText
.SubClassExist
= TRUE
;
2520 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2524 Converts a text device path node to USB device firmware update device path structure.
2526 @param TextDeviceNode The input Text device path node.
2528 @return A pointer to the newly-created USB device firmware update device path structure.
2531 EFI_DEVICE_PATH_PROTOCOL
*
2532 DevPathFromTextUsbDeviceFirmwareUpdate (
2533 IN CHAR16
*TextDeviceNode
2536 USB_CLASS_TEXT UsbClassText
;
2538 UsbClassText
.ClassExist
= FALSE
;
2539 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2540 UsbClassText
.SubClassExist
= FALSE
;
2541 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2543 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2547 Converts a text device path node to USB IRDA bridge device path structure.
2549 @param TextDeviceNode The input Text device path node.
2551 @return A pointer to the newly-created USB IRDA bridge device path structure.
2554 EFI_DEVICE_PATH_PROTOCOL
*
2555 DevPathFromTextUsbIrdaBridge (
2556 IN CHAR16
*TextDeviceNode
2559 USB_CLASS_TEXT UsbClassText
;
2561 UsbClassText
.ClassExist
= FALSE
;
2562 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2563 UsbClassText
.SubClassExist
= FALSE
;
2564 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2566 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2570 Converts a text device path node to USB text and measurement device path structure.
2572 @param TextDeviceNode The input Text device path node.
2574 @return A pointer to the newly-created USB text and measurement device path structure.
2577 EFI_DEVICE_PATH_PROTOCOL
*
2578 DevPathFromTextUsbTestAndMeasurement (
2579 IN CHAR16
*TextDeviceNode
2582 USB_CLASS_TEXT UsbClassText
;
2584 UsbClassText
.ClassExist
= FALSE
;
2585 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2586 UsbClassText
.SubClassExist
= FALSE
;
2587 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2589 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2593 Converts a text device path node to USB WWID device path structure.
2595 @param TextDeviceNode The input Text device path node.
2597 @return A pointer to the newly-created USB WWID device path structure.
2600 EFI_DEVICE_PATH_PROTOCOL
*
2601 DevPathFromTextUsbWwid (
2602 IN CHAR16
*TextDeviceNode
2607 CHAR16
*InterfaceNumStr
;
2608 CHAR16
*SerialNumberStr
;
2609 USB_WWID_DEVICE_PATH
*UsbWwid
;
2610 UINTN SerialNumberStrLen
;
2612 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2613 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2614 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2615 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2616 SerialNumberStrLen
= StrLen (SerialNumberStr
);
2617 if (SerialNumberStrLen
>= 2 &&
2618 SerialNumberStr
[0] == L
'\"' &&
2619 SerialNumberStr
[SerialNumberStrLen
- 1] == L
'\"'
2621 SerialNumberStr
[SerialNumberStrLen
- 1] = L
'\0';
2623 SerialNumberStrLen
-= 2;
2625 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2626 MESSAGING_DEVICE_PATH
,
2628 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + SerialNumberStrLen
* sizeof (CHAR16
))
2630 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2631 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2632 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2635 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
2636 // Therefore, the '\0' will not be copied.
2639 (UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
),
2641 SerialNumberStrLen
* sizeof (CHAR16
)
2644 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2648 Converts a text device path node to Logic Unit device path structure.
2650 @param TextDeviceNode The input Text device path node.
2652 @return A pointer to the newly-created Logic Unit device path structure.
2655 EFI_DEVICE_PATH_PROTOCOL
*
2656 DevPathFromTextUnit (
2657 IN CHAR16
*TextDeviceNode
2661 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2663 LunStr
= GetNextParamStr (&TextDeviceNode
);
2664 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2665 MESSAGING_DEVICE_PATH
,
2666 MSG_DEVICE_LOGICAL_UNIT_DP
,
2667 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2670 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2672 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2676 Converts a text device path node to iSCSI device path structure.
2678 @param TextDeviceNode The input Text device path node.
2680 @return A pointer to the newly-created iSCSI device path structure.
2683 EFI_DEVICE_PATH_PROTOCOL
*
2684 DevPathFromTextiSCSI (
2685 IN CHAR16
*TextDeviceNode
2690 CHAR16
*PortalGroupStr
;
2692 CHAR16
*HeaderDigestStr
;
2693 CHAR16
*DataDigestStr
;
2694 CHAR16
*AuthenticationStr
;
2695 CHAR16
*ProtocolStr
;
2697 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2699 NameStr
= GetNextParamStr (&TextDeviceNode
);
2700 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2701 LunStr
= GetNextParamStr (&TextDeviceNode
);
2702 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2703 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2704 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2705 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2706 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2707 MESSAGING_DEVICE_PATH
,
2709 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2712 AsciiStr
= ISCSIDevPath
->TargetName
;
2713 StrToAscii (NameStr
, &AsciiStr
);
2715 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2716 Strtoi64 (LunStr
, &ISCSIDevPath
->Lun
);
2719 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2723 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2727 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2731 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2735 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2737 ISCSIDevPath
->NetworkProtocol
= (UINT16
) StrCmp (ProtocolStr
, L
"TCP");
2739 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2743 Converts a text device path node to VLAN device path structure.
2745 @param TextDeviceNode The input Text device path node.
2747 @return A pointer to the newly-created VLAN device path structure.
2750 EFI_DEVICE_PATH_PROTOCOL
*
2751 DevPathFromTextVlan (
2752 IN CHAR16
*TextDeviceNode
2756 VLAN_DEVICE_PATH
*Vlan
;
2758 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2759 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2760 MESSAGING_DEVICE_PATH
,
2762 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2765 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2767 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2771 Converts a text device path node to Bluetooth device path structure.
2773 @param TextDeviceNode The input Text device path node.
2775 @return A pointer to the newly-created Bluetooth device path structure.
2778 EFI_DEVICE_PATH_PROTOCOL
*
2779 DevPathFromTextBluetooth (
2780 IN CHAR16
*TextDeviceNode
2783 CHAR16
*BluetoothStr
;
2785 CHAR16
*TempNumBuffer
;
2786 UINTN TempBufferSize
;
2788 BLUETOOTH_DEVICE_PATH
*BluetoothDp
;
2790 BluetoothStr
= GetNextParamStr (&TextDeviceNode
);
2791 BluetoothDp
= (BLUETOOTH_DEVICE_PATH
*) CreateDeviceNode (
2792 MESSAGING_DEVICE_PATH
,
2794 (UINT16
) sizeof (BLUETOOTH_DEVICE_PATH
)
2797 Index
= sizeof (BLUETOOTH_ADDRESS
) - 1;
2798 Walker
= BluetoothStr
;
2799 while (!IS_NULL(*Walker
) && Index
>= 0) {
2800 TempBufferSize
= 2 * sizeof(CHAR16
) + StrSize(L
"0x");
2801 TempNumBuffer
= AllocateZeroPool (TempBufferSize
);
2802 if (TempNumBuffer
== NULL
) {
2805 StrCpyS (TempNumBuffer
, TempBufferSize
/ sizeof (CHAR16
), L
"0x");
2806 StrnCatS (TempNumBuffer
, TempBufferSize
/ sizeof (CHAR16
), Walker
, 2);
2807 BluetoothDp
->BD_ADDR
.Address
[Index
] = (UINT8
)Strtoi (TempNumBuffer
);
2808 FreePool (TempNumBuffer
);
2813 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothDp
;
2817 Converts a text device path node to Wi-Fi device path structure.
2819 @param TextDeviceNode The input Text device path node.
2821 @return A pointer to the newly-created Wi-Fi device path structure.
2824 EFI_DEVICE_PATH_PROTOCOL
*
2825 DevPathFromTextWiFi (
2826 IN CHAR16
*TextDeviceNode
2831 WIFI_DEVICE_PATH
*WiFiDp
;
2833 SSIdStr
= GetNextParamStr (&TextDeviceNode
);
2834 WiFiDp
= (WIFI_DEVICE_PATH
*) CreateDeviceNode (
2835 MESSAGING_DEVICE_PATH
,
2837 (UINT16
) sizeof (WIFI_DEVICE_PATH
)
2840 AsciiStr
= (CHAR8
*) WiFiDp
->SSId
;
2841 StrToAscii (SSIdStr
, &AsciiStr
);
2843 return (EFI_DEVICE_PATH_PROTOCOL
*) WiFiDp
;
2847 Converts a text device path node to URI device path structure.
2849 @param TextDeviceNode The input Text device path node.
2851 @return A pointer to the newly-created URI device path structure.
2854 EFI_DEVICE_PATH_PROTOCOL
*
2855 DevPathFromTextUri (
2856 IN CHAR16
*TextDeviceNode
2861 URI_DEVICE_PATH
*Uri
;
2863 UriStr
= GetNextParamStr (&TextDeviceNode
);
2864 UriLength
= StrnLenS (UriStr
, MAX_UINT16
- sizeof (URI_DEVICE_PATH
));
2865 Uri
= (URI_DEVICE_PATH
*) CreateDeviceNode (
2866 MESSAGING_DEVICE_PATH
,
2868 (UINT16
) (sizeof (URI_DEVICE_PATH
) + UriLength
)
2871 while (UriLength
-- != 0) {
2872 Uri
->Uri
[UriLength
] = (CHAR8
) UriStr
[UriLength
];
2875 return (EFI_DEVICE_PATH_PROTOCOL
*) Uri
;
2879 Converts a media text device path node to media device path structure.
2881 @param TextDeviceNode The input Text device path node.
2883 @return A pointer to media device path structure.
2886 EFI_DEVICE_PATH_PROTOCOL
*
2887 DevPathFromTextMediaPath (
2888 IN CHAR16
*TextDeviceNode
2891 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH
, TextDeviceNode
);
2895 Converts a text device path node to HD device path structure.
2897 @param TextDeviceNode The input Text device path node.
2899 @return A pointer to the newly-created HD device path structure.
2902 EFI_DEVICE_PATH_PROTOCOL
*
2904 IN CHAR16
*TextDeviceNode
2907 CHAR16
*PartitionStr
;
2909 CHAR16
*SignatureStr
;
2913 EFI_GUID SignatureGuid
;
2914 HARDDRIVE_DEVICE_PATH
*Hd
;
2916 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2917 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2918 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2919 StartStr
= GetNextParamStr (&TextDeviceNode
);
2920 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2921 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2924 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2927 Hd
->PartitionNumber
= (UINT32
) Strtoi (PartitionStr
);
2929 ZeroMem (Hd
->Signature
, 16);
2930 Hd
->MBRType
= (UINT8
) 0;
2932 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2933 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2936 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2937 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2938 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2939 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2942 StrToGuid (SignatureStr
, &SignatureGuid
);
2943 CopyMem (Hd
->Signature
, &SignatureGuid
, sizeof (EFI_GUID
));
2945 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2948 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2949 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2951 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2955 Converts a text device path node to CDROM device path structure.
2957 @param TextDeviceNode The input Text device path node.
2959 @return A pointer to the newly-created CDROM device path structure.
2962 EFI_DEVICE_PATH_PROTOCOL
*
2963 DevPathFromTextCDROM (
2964 IN CHAR16
*TextDeviceNode
2970 CDROM_DEVICE_PATH
*CDROMDevPath
;
2972 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2973 StartStr
= GetNextParamStr (&TextDeviceNode
);
2974 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2975 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2978 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2981 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2982 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2983 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2985 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2989 Converts a text device path node to Vendor-defined media device path structure.
2991 @param TextDeviceNode The input Text device path node.
2993 @return A pointer to the newly-created Vendor-defined media device path structure.
2996 EFI_DEVICE_PATH_PROTOCOL
*
2997 DevPathFromTextVenMedia (
2998 IN CHAR16
*TextDeviceNode
3001 return ConvertFromTextVendor (
3009 Converts a text device path node to File device path structure.
3011 @param TextDeviceNode The input Text device path node.
3013 @return A pointer to the newly-created File device path structure.
3016 EFI_DEVICE_PATH_PROTOCOL
*
3017 DevPathFromTextFilePath (
3018 IN CHAR16
*TextDeviceNode
3021 FILEPATH_DEVICE_PATH
*File
;
3023 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
3026 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
3029 StrCpyS (File
->PathName
, StrLen (TextDeviceNode
) + 1, TextDeviceNode
);
3031 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
3035 Converts a text device path node to Media protocol device path structure.
3037 @param TextDeviceNode The input Text device path node.
3039 @return A pointer to the newly-created Media protocol device path structure.
3042 EFI_DEVICE_PATH_PROTOCOL
*
3043 DevPathFromTextMedia (
3044 IN CHAR16
*TextDeviceNode
3048 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
3050 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3051 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
3054 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
3057 StrToGuid (GuidStr
, &Media
->Protocol
);
3059 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
3063 Converts a text device path node to firmware volume device path structure.
3065 @param TextDeviceNode The input Text device path node.
3067 @return A pointer to the newly-created firmware volume device path structure.
3070 EFI_DEVICE_PATH_PROTOCOL
*
3072 IN CHAR16
*TextDeviceNode
3076 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
3078 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3079 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
3081 MEDIA_PIWG_FW_VOL_DP
,
3082 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
3085 StrToGuid (GuidStr
, &Fv
->FvName
);
3087 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
3091 Converts a text device path node to firmware file device path structure.
3093 @param TextDeviceNode The input Text device path node.
3095 @return A pointer to the newly-created firmware file device path structure.
3098 EFI_DEVICE_PATH_PROTOCOL
*
3099 DevPathFromTextFvFile (
3100 IN CHAR16
*TextDeviceNode
3104 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
3106 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3107 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
3109 MEDIA_PIWG_FW_FILE_DP
,
3110 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
3113 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
3115 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
3119 Converts a text device path node to text relative offset device path structure.
3121 @param TextDeviceNode The input Text device path node.
3123 @return A pointer to the newly-created Text device path structure.
3126 EFI_DEVICE_PATH_PROTOCOL
*
3127 DevPathFromTextRelativeOffsetRange (
3128 IN CHAR16
*TextDeviceNode
3131 CHAR16
*StartingOffsetStr
;
3132 CHAR16
*EndingOffsetStr
;
3133 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
3135 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
3136 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
3137 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
3139 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
3140 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
3143 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
3144 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
3146 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
3150 Converts a text device path node to text ram disk device path structure.
3152 @param TextDeviceNode The input Text device path node.
3154 @return A pointer to the newly-created Text device path structure.
3157 EFI_DEVICE_PATH_PROTOCOL
*
3158 DevPathFromTextRamDisk (
3159 IN CHAR16
*TextDeviceNode
3162 CHAR16
*StartingAddrStr
;
3163 CHAR16
*EndingAddrStr
;
3164 CHAR16
*TypeGuidStr
;
3165 CHAR16
*InstanceStr
;
3166 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3167 UINT64 StartingAddr
;
3170 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3171 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3172 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3173 TypeGuidStr
= GetNextParamStr (&TextDeviceNode
);
3174 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3177 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3180 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3181 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3182 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3183 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3184 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3185 StrToGuid (TypeGuidStr
, &RamDisk
->TypeGuid
);
3187 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3191 Converts a text device path node to text virtual disk device path structure.
3193 @param TextDeviceNode The input Text device path node.
3195 @return A pointer to the newly-created Text device path structure.
3198 EFI_DEVICE_PATH_PROTOCOL
*
3199 DevPathFromTextVirtualDisk (
3200 IN CHAR16
*TextDeviceNode
3203 CHAR16
*StartingAddrStr
;
3204 CHAR16
*EndingAddrStr
;
3205 CHAR16
*InstanceStr
;
3206 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3207 UINT64 StartingAddr
;
3210 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3211 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3212 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3214 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3217 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3220 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3221 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3222 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3223 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3224 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3225 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualDiskGuid
);
3227 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3231 Converts a text device path node to text virtual cd device path structure.
3233 @param TextDeviceNode The input Text device path node.
3235 @return A pointer to the newly-created Text device path structure.
3238 EFI_DEVICE_PATH_PROTOCOL
*
3239 DevPathFromTextVirtualCd (
3240 IN CHAR16
*TextDeviceNode
3243 CHAR16
*StartingAddrStr
;
3244 CHAR16
*EndingAddrStr
;
3245 CHAR16
*InstanceStr
;
3246 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3247 UINT64 StartingAddr
;
3250 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3251 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3252 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3254 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3257 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3260 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3261 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3262 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3263 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3264 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3265 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualCdGuid
);
3267 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3271 Converts a text device path node to text persistent virtual disk device path structure.
3273 @param TextDeviceNode The input Text device path node.
3275 @return A pointer to the newly-created Text device path structure.
3278 EFI_DEVICE_PATH_PROTOCOL
*
3279 DevPathFromTextPersistentVirtualDisk (
3280 IN CHAR16
*TextDeviceNode
3283 CHAR16
*StartingAddrStr
;
3284 CHAR16
*EndingAddrStr
;
3285 CHAR16
*InstanceStr
;
3286 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3287 UINT64 StartingAddr
;
3290 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3291 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3292 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3294 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3297 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3300 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3301 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3302 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3303 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3304 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3305 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualDiskGuid
);
3307 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3311 Converts a text device path node to text persistent virtual cd device path structure.
3313 @param TextDeviceNode The input Text device path node.
3315 @return A pointer to the newly-created Text device path structure.
3318 EFI_DEVICE_PATH_PROTOCOL
*
3319 DevPathFromTextPersistentVirtualCd (
3320 IN CHAR16
*TextDeviceNode
3323 CHAR16
*StartingAddrStr
;
3324 CHAR16
*EndingAddrStr
;
3325 CHAR16
*InstanceStr
;
3326 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3327 UINT64 StartingAddr
;
3330 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3331 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3332 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3334 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3337 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3340 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3341 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3342 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3343 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3344 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3345 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualCdGuid
);
3347 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3351 Converts a BBS text device path node to BBS device path structure.
3353 @param TextDeviceNode The input Text device path node.
3355 @return A pointer to BBS device path structure.
3358 EFI_DEVICE_PATH_PROTOCOL
*
3359 DevPathFromTextBbsPath (
3360 IN CHAR16
*TextDeviceNode
3363 return DevPathFromTextGenericPath (BBS_DEVICE_PATH
, TextDeviceNode
);
3367 Converts a text device path node to BIOS Boot Specification device path structure.
3369 @param TextDeviceNode The input Text device path node.
3371 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3374 EFI_DEVICE_PATH_PROTOCOL
*
3375 DevPathFromTextBBS (
3376 IN CHAR16
*TextDeviceNode
3383 BBS_BBS_DEVICE_PATH
*Bbs
;
3385 TypeStr
= GetNextParamStr (&TextDeviceNode
);
3386 IdStr
= GetNextParamStr (&TextDeviceNode
);
3387 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
3388 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
3391 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
3394 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
3395 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
3396 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
3397 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
3398 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
3399 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
3400 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
3401 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
3402 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
3403 Bbs
->DeviceType
= BBS_TYPE_USB
;
3404 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
3405 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
3407 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
3410 AsciiStr
= Bbs
->String
;
3411 StrToAscii (IdStr
, &AsciiStr
);
3413 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
3415 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
3419 Converts a text device path node to SATA device path structure.
3421 @param TextDeviceNode The input Text device path node.
3423 @return A pointer to the newly-created SATA device path structure.
3426 EFI_DEVICE_PATH_PROTOCOL
*
3427 DevPathFromTextSata (
3428 IN CHAR16
*TextDeviceNode
3431 SATA_DEVICE_PATH
*Sata
;
3436 Param1
= GetNextParamStr (&TextDeviceNode
);
3437 Param2
= GetNextParamStr (&TextDeviceNode
);
3438 Param3
= GetNextParamStr (&TextDeviceNode
);
3440 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
3441 MESSAGING_DEVICE_PATH
,
3443 (UINT16
) sizeof (SATA_DEVICE_PATH
)
3445 Sata
->HBAPortNumber
= (UINT16
) Strtoi (Param1
);
3446 Sata
->PortMultiplierPortNumber
= (UINT16
) Strtoi (Param2
);
3447 Sata
->Lun
= (UINT16
) Strtoi (Param3
);
3449 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
3452 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
3453 {L
"Path", DevPathFromTextPath
},
3455 {L
"HardwarePath", DevPathFromTextHardwarePath
},
3456 {L
"Pci", DevPathFromTextPci
},
3457 {L
"PcCard", DevPathFromTextPcCard
},
3458 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
3459 {L
"VenHw", DevPathFromTextVenHw
},
3460 {L
"Ctrl", DevPathFromTextCtrl
},
3461 {L
"Bmc", DevPathFromTextBmc
},
3463 {L
"AcpiPath", DevPathFromTextAcpiPath
},
3464 {L
"Acpi", DevPathFromTextAcpi
},
3465 {L
"PciRoot", DevPathFromTextPciRoot
},
3466 {L
"PcieRoot", DevPathFromTextPcieRoot
},
3467 {L
"Floppy", DevPathFromTextFloppy
},
3468 {L
"Keyboard", DevPathFromTextKeyboard
},
3469 {L
"Serial", DevPathFromTextSerial
},
3470 {L
"ParallelPort", DevPathFromTextParallelPort
},
3471 {L
"AcpiEx", DevPathFromTextAcpiEx
},
3472 {L
"AcpiExp", DevPathFromTextAcpiExp
},
3473 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
3475 {L
"Msg", DevPathFromTextMsg
},
3476 {L
"Ata", DevPathFromTextAta
},
3477 {L
"Scsi", DevPathFromTextScsi
},
3478 {L
"Fibre", DevPathFromTextFibre
},
3479 {L
"FibreEx", DevPathFromTextFibreEx
},
3480 {L
"I1394", DevPathFromText1394
},
3481 {L
"USB", DevPathFromTextUsb
},
3482 {L
"I2O", DevPathFromTextI2O
},
3483 {L
"Infiniband", DevPathFromTextInfiniband
},
3484 {L
"VenMsg", DevPathFromTextVenMsg
},
3485 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
3486 {L
"VenVt100", DevPathFromTextVenVt100
},
3487 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
3488 {L
"VenUtf8", DevPathFromTextVenUtf8
},
3489 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
3490 {L
"SAS", DevPathFromTextSAS
},
3491 {L
"SasEx", DevPathFromTextSasEx
},
3492 {L
"NVMe", DevPathFromTextNVMe
},
3493 {L
"UFS", DevPathFromTextUfs
},
3494 {L
"SD", DevPathFromTextSd
},
3495 {L
"DebugPort", DevPathFromTextDebugPort
},
3496 {L
"MAC", DevPathFromTextMAC
},
3497 {L
"IPv4", DevPathFromTextIPv4
},
3498 {L
"IPv6", DevPathFromTextIPv6
},
3499 {L
"Uart", DevPathFromTextUart
},
3500 {L
"UsbClass", DevPathFromTextUsbClass
},
3501 {L
"UsbAudio", DevPathFromTextUsbAudio
},
3502 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
3503 {L
"UsbHID", DevPathFromTextUsbHID
},
3504 {L
"UsbImage", DevPathFromTextUsbImage
},
3505 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
3506 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
3507 {L
"UsbHub", DevPathFromTextUsbHub
},
3508 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
3509 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
3510 {L
"UsbVideo", DevPathFromTextUsbVideo
},
3511 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
3512 {L
"UsbWireless", DevPathFromTextUsbWireless
},
3513 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
3514 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
3515 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
3516 {L
"UsbWwid", DevPathFromTextUsbWwid
},
3517 {L
"Unit", DevPathFromTextUnit
},
3518 {L
"iSCSI", DevPathFromTextiSCSI
},
3519 {L
"Vlan", DevPathFromTextVlan
},
3520 {L
"Uri", DevPathFromTextUri
},
3521 {L
"Bluetooth", DevPathFromTextBluetooth
},
3522 {L
"WiFi", DevPathFromTextWiFi
},
3523 {L
"MediaPath", DevPathFromTextMediaPath
},
3524 {L
"HD", DevPathFromTextHD
},
3525 {L
"CDROM", DevPathFromTextCDROM
},
3526 {L
"VenMedia", DevPathFromTextVenMedia
},
3527 {L
"Media", DevPathFromTextMedia
},
3528 {L
"Fv", DevPathFromTextFv
},
3529 {L
"FvFile", DevPathFromTextFvFile
},
3530 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
3531 {L
"RamDisk", DevPathFromTextRamDisk
},
3532 {L
"VirtualDisk", DevPathFromTextVirtualDisk
},
3533 {L
"VirtualCD", DevPathFromTextVirtualCd
},
3534 {L
"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk
},
3535 {L
"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd
},
3537 {L
"BbsPath", DevPathFromTextBbsPath
},
3538 {L
"BBS", DevPathFromTextBBS
},
3539 {L
"Sata", DevPathFromTextSata
},
3544 Convert text to the binary representation of a device node.
3546 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3547 node. Conversion starts with the first character and continues
3548 until the first non-device node character.
3550 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3551 insufficient memory or text unsupported.
3554 EFI_DEVICE_PATH_PROTOCOL
*
3556 UefiDevicePathLibConvertTextToDeviceNode (
3557 IN CONST CHAR16
*TextDeviceNode
3560 DEVICE_PATH_FROM_TEXT FromText
;
3562 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3563 CHAR16
*DeviceNodeStr
;
3566 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
3572 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
3573 ASSERT (DeviceNodeStr
!= NULL
);
3575 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3576 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
3577 if (ParamStr
!= NULL
) {
3578 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
3583 if (FromText
== NULL
) {
3587 FromText
= DevPathFromTextFilePath
;
3588 DeviceNode
= FromText (DeviceNodeStr
);
3590 DeviceNode
= FromText (ParamStr
);
3591 FreePool (ParamStr
);
3594 FreePool (DeviceNodeStr
);
3600 Convert text to the binary representation of a device path.
3603 @param TextDevicePath TextDevicePath points to the text representation of a device
3604 path. Conversion starts with the first character and continues
3605 until the first non-device node character.
3607 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3608 there was insufficient memory.
3611 EFI_DEVICE_PATH_PROTOCOL
*
3613 UefiDevicePathLibConvertTextToDevicePath (
3614 IN CONST CHAR16
*TextDevicePath
3617 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3618 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3619 CHAR16
*DevicePathStr
;
3621 CHAR16
*DeviceNodeStr
;
3622 BOOLEAN IsInstanceEnd
;
3623 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3625 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3629 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3630 ASSERT (DevicePath
!= NULL
);
3631 SetDevicePathEndNode (DevicePath
);
3633 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3635 Str
= DevicePathStr
;
3636 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3637 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3639 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3640 FreePool (DevicePath
);
3641 FreePool (DeviceNode
);
3642 DevicePath
= NewDevicePath
;
3644 if (IsInstanceEnd
) {
3645 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3646 ASSERT (DeviceNode
!= NULL
);
3647 SetDevicePathEndNode (DeviceNode
);
3649 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3650 FreePool (DevicePath
);
3651 FreePool (DeviceNode
);
3652 DevicePath
= NewDevicePath
;
3656 FreePool (DevicePathStr
);