2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
4 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "UefiDevicePathLib.h"
15 @param Src Source string.
17 @return The duplicated string.
21 UefiDevicePathLibStrDuplicate (
25 return AllocateCopyPool (StrSize (Src
), Src
);
30 Get parameter in a pair of parentheses follow the given node name.
31 For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".
33 @param Str Device Path Text.
34 @param NodeName Name of the node.
36 @return Parameter text for the node.
48 UINTN ParameterLength
;
51 // Check whether the node name matchs
53 NodeNameLength
= StrLen (NodeName
);
54 if (StrnCmp (Str
, NodeName
, NodeNameLength
) != 0) {
58 ParamStr
= Str
+ NodeNameLength
;
59 if (!IS_LEFT_PARENTH (*ParamStr
)) {
64 // Skip the found '(' and find first occurrence of ')'
68 StrPointer
= ParamStr
;
69 while (!IS_NULL (*StrPointer
)) {
70 if (IS_RIGHT_PARENTH (*StrPointer
)) {
78 if (IS_NULL (*StrPointer
)) {
85 ParamStr
= AllocateCopyPool ((ParameterLength
+ 1) * sizeof (CHAR16
), ParamStr
);
86 if (ParamStr
== NULL
) {
91 // Terminate the parameter string
93 ParamStr
[ParameterLength
] = L
'\0';
99 Gets current sub-string from a string list, before return
100 the list header is moved to next sub-string. The sub-string is separated
101 by the specified character. For example, the separator is ',', the string
102 list is "2,0,3", it returns "2", the remain list move to "0,3"
104 @param List A string list separated by the specified separator
105 @param Separator The separator character
107 @return A pointer to the current sub-string
112 IN OUT CHAR16
**List
,
122 if (IS_NULL (*Str
)) {
127 // Find first occurrence of the separator
129 while (!IS_NULL (*Str
)) {
130 if (*Str
== Separator
) {
137 if (*Str
== Separator
) {
139 // Find a sub-string, terminate it
146 // Move to next sub-string
154 Gets the next parameter string from the list.
156 @param List A string list separated by the specified separator
158 @return A pointer to the current sub-string
167 // The separator is comma
169 return SplitStr (List
, L
',');
173 Get one device node from entire device path text.
175 @param DevicePath On input, the current Device Path node; on output, the next device path node
176 @param IsInstanceEnd This node is the end of a device path instance
178 @return A device node text or NULL if no more device node available
182 GetNextDeviceNodeStr (
183 IN OUT CHAR16
**DevicePath
,
184 OUT BOOLEAN
*IsInstanceEnd
189 UINTN ParenthesesStack
;
192 if (IS_NULL (*Str
)) {
197 // Skip the leading '/', '(', ')' and ','
199 while (!IS_NULL (*Str
)) {
200 if (!IS_SLASH (*Str
) &&
202 !IS_LEFT_PARENTH (*Str
) &&
203 !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
)) {
256 Return whether the integer string is a hex string.
258 @param Str The integer string
260 @retval TRUE Hex string
261 @retval FALSE Decimal string
270 // skip preceeding white space
272 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 Unicode string to ASCII string.
331 @param Str The equivalent Unicode string
332 @param AsciiStr On input, it points to destination ASCII string buffer; on output, it points
333 to the next ASCII string next to it
339 IN OUT CHAR8
**AsciiStr
345 while (!IS_NULL (*Str
)) {
346 *(Dest
++) = (CHAR8
)*(Str
++);
352 // Return the string next to it
354 *AsciiStr
= Dest
+ 1;
358 Converts a generic text device path node to device path structure.
360 @param Type The type of the device path node.
361 @param TextDeviceNode The input text device path node.
363 @return A pointer to device path structure.
365 EFI_DEVICE_PATH_PROTOCOL
*
366 DevPathFromTextGenericPath (
368 IN CHAR16
*TextDeviceNode
371 EFI_DEVICE_PATH_PROTOCOL
*Node
;
376 SubtypeStr
= GetNextParamStr (&TextDeviceNode
);
377 DataStr
= GetNextParamStr (&TextDeviceNode
);
379 if (DataStr
== NULL
) {
382 DataLength
= StrLen (DataStr
) / 2;
385 Node
= CreateDeviceNode (
387 (UINT8
)Strtoi (SubtypeStr
),
388 (UINT16
)(sizeof (EFI_DEVICE_PATH_PROTOCOL
) + DataLength
)
391 StrHexToBytes (DataStr
, DataLength
* 2, (UINT8
*)(Node
+ 1), DataLength
);
396 Converts a generic text device path node to device path structure.
398 @param TextDeviceNode The input Text device path node.
400 @return A pointer to device path structure.
403 EFI_DEVICE_PATH_PROTOCOL
*
404 DevPathFromTextPath (
405 IN CHAR16
*TextDeviceNode
410 TypeStr
= GetNextParamStr (&TextDeviceNode
);
412 return DevPathFromTextGenericPath ((UINT8
)Strtoi (TypeStr
), TextDeviceNode
);
416 Converts a generic hardware text device path node to Hardware device path structure.
418 @param TextDeviceNode The input Text device path node.
420 @return A pointer to Hardware device path structure.
423 EFI_DEVICE_PATH_PROTOCOL
*
424 DevPathFromTextHardwarePath (
425 IN CHAR16
*TextDeviceNode
428 return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH
, TextDeviceNode
);
432 Converts a text device path node to Hardware PCI device path structure.
434 @param TextDeviceNode The input Text device path node.
436 @return A pointer to Hardware PCI device path structure.
439 EFI_DEVICE_PATH_PROTOCOL
*
441 IN CHAR16
*TextDeviceNode
446 PCI_DEVICE_PATH
*Pci
;
448 DeviceStr
= GetNextParamStr (&TextDeviceNode
);
449 FunctionStr
= GetNextParamStr (&TextDeviceNode
);
450 Pci
= (PCI_DEVICE_PATH
*)CreateDeviceNode (
451 HARDWARE_DEVICE_PATH
,
453 (UINT16
)sizeof (PCI_DEVICE_PATH
)
456 Pci
->Function
= (UINT8
)Strtoi (FunctionStr
);
457 Pci
->Device
= (UINT8
)Strtoi (DeviceStr
);
459 return (EFI_DEVICE_PATH_PROTOCOL
*)Pci
;
463 Converts a text device path node to Hardware PC card device path structure.
465 @param TextDeviceNode The input Text device path node.
467 @return A pointer to Hardware PC card device path structure.
470 EFI_DEVICE_PATH_PROTOCOL
*
471 DevPathFromTextPcCard (
472 IN CHAR16
*TextDeviceNode
475 CHAR16
*FunctionNumberStr
;
476 PCCARD_DEVICE_PATH
*Pccard
;
478 FunctionNumberStr
= GetNextParamStr (&TextDeviceNode
);
479 Pccard
= (PCCARD_DEVICE_PATH
*)CreateDeviceNode (
480 HARDWARE_DEVICE_PATH
,
482 (UINT16
)sizeof (PCCARD_DEVICE_PATH
)
485 Pccard
->FunctionNumber
= (UINT8
)Strtoi (FunctionNumberStr
);
487 return (EFI_DEVICE_PATH_PROTOCOL
*)Pccard
;
491 Converts a text device path node to Hardware memory map device path structure.
493 @param TextDeviceNode The input Text device path node.
495 @return A pointer to Hardware memory map device path structure.
498 EFI_DEVICE_PATH_PROTOCOL
*
499 DevPathFromTextMemoryMapped (
500 IN CHAR16
*TextDeviceNode
503 CHAR16
*MemoryTypeStr
;
504 CHAR16
*StartingAddressStr
;
505 CHAR16
*EndingAddressStr
;
506 MEMMAP_DEVICE_PATH
*MemMap
;
508 MemoryTypeStr
= GetNextParamStr (&TextDeviceNode
);
509 StartingAddressStr
= GetNextParamStr (&TextDeviceNode
);
510 EndingAddressStr
= GetNextParamStr (&TextDeviceNode
);
511 MemMap
= (MEMMAP_DEVICE_PATH
*)CreateDeviceNode (
512 HARDWARE_DEVICE_PATH
,
514 (UINT16
)sizeof (MEMMAP_DEVICE_PATH
)
517 MemMap
->MemoryType
= (UINT32
)Strtoi (MemoryTypeStr
);
518 Strtoi64 (StartingAddressStr
, &MemMap
->StartingAddress
);
519 Strtoi64 (EndingAddressStr
, &MemMap
->EndingAddress
);
521 return (EFI_DEVICE_PATH_PROTOCOL
*)MemMap
;
525 Converts a text device path node to Vendor device path structure based on the input Type
528 @param TextDeviceNode The input Text device path node.
529 @param Type The type of device path node.
530 @param SubType The subtype of device path node.
532 @return A pointer to the newly-created Vendor device path structure.
535 EFI_DEVICE_PATH_PROTOCOL
*
536 ConvertFromTextVendor (
537 IN CHAR16
*TextDeviceNode
,
545 VENDOR_DEVICE_PATH
*Vendor
;
547 GuidStr
= GetNextParamStr (&TextDeviceNode
);
549 DataStr
= GetNextParamStr (&TextDeviceNode
);
550 Length
= StrLen (DataStr
);
552 // Two hex characters make up 1 buffer byte
554 Length
= (Length
+ 1) / 2;
556 Vendor
= (VENDOR_DEVICE_PATH
*)CreateDeviceNode (
559 (UINT16
)(sizeof (VENDOR_DEVICE_PATH
) + Length
)
562 StrToGuid (GuidStr
, &Vendor
->Guid
);
563 StrHexToBytes (DataStr
, Length
* 2, (UINT8
*)(Vendor
+ 1), Length
);
565 return (EFI_DEVICE_PATH_PROTOCOL
*)Vendor
;
569 Converts a text device path node to Vendor Hardware device path structure.
571 @param TextDeviceNode The input Text device path node.
573 @return A pointer to the newly-created Vendor Hardware device path structure.
576 EFI_DEVICE_PATH_PROTOCOL
*
577 DevPathFromTextVenHw (
578 IN CHAR16
*TextDeviceNode
581 return ConvertFromTextVendor (
583 HARDWARE_DEVICE_PATH
,
589 Converts a text device path node to Hardware Controller device path structure.
591 @param TextDeviceNode The input Text device path node.
593 @return A pointer to the newly-created Hardware Controller device path structure.
596 EFI_DEVICE_PATH_PROTOCOL
*
597 DevPathFromTextCtrl (
598 IN CHAR16
*TextDeviceNode
601 CHAR16
*ControllerStr
;
602 CONTROLLER_DEVICE_PATH
*Controller
;
604 ControllerStr
= GetNextParamStr (&TextDeviceNode
);
605 Controller
= (CONTROLLER_DEVICE_PATH
*)CreateDeviceNode (
606 HARDWARE_DEVICE_PATH
,
608 (UINT16
)sizeof (CONTROLLER_DEVICE_PATH
)
610 Controller
->ControllerNumber
= (UINT32
)Strtoi (ControllerStr
);
612 return (EFI_DEVICE_PATH_PROTOCOL
*)Controller
;
616 Converts a text device path node to BMC device path structure.
618 @param TextDeviceNode The input Text device path node.
620 @return A pointer to the newly-created BMC device path structure.
623 EFI_DEVICE_PATH_PROTOCOL
*
625 IN CHAR16
*TextDeviceNode
628 CHAR16
*InterfaceTypeStr
;
629 CHAR16
*BaseAddressStr
;
630 BMC_DEVICE_PATH
*BmcDp
;
632 InterfaceTypeStr
= GetNextParamStr (&TextDeviceNode
);
633 BaseAddressStr
= GetNextParamStr (&TextDeviceNode
);
634 BmcDp
= (BMC_DEVICE_PATH
*)CreateDeviceNode (
635 HARDWARE_DEVICE_PATH
,
637 (UINT16
)sizeof (BMC_DEVICE_PATH
)
640 BmcDp
->InterfaceType
= (UINT8
)Strtoi (InterfaceTypeStr
);
642 (UINT64
*)(&BmcDp
->BaseAddress
),
643 StrHexToUint64 (BaseAddressStr
)
646 return (EFI_DEVICE_PATH_PROTOCOL
*)BmcDp
;
650 Converts a generic ACPI text device path node to ACPI device path structure.
652 @param TextDeviceNode The input Text device path node.
654 @return A pointer to ACPI device path structure.
657 EFI_DEVICE_PATH_PROTOCOL
*
658 DevPathFromTextAcpiPath (
659 IN CHAR16
*TextDeviceNode
662 return DevPathFromTextGenericPath (ACPI_DEVICE_PATH
, TextDeviceNode
);
666 Converts a string to EisaId.
668 @param Text The input string.
670 @return UINT32 EISA ID.
677 return (((Text
[0] - 'A' + 1) & 0x1f) << 10)
678 + (((Text
[1] - 'A' + 1) & 0x1f) << 5)
679 + (((Text
[2] - 'A' + 1) & 0x1f) << 0)
680 + (UINT32
)(StrHexToUintn (&Text
[3]) << 16)
685 Converts a text device path node to ACPI HID device path structure.
687 @param TextDeviceNode The input Text device path node.
689 @return A pointer to the newly-created ACPI HID device path structure.
692 EFI_DEVICE_PATH_PROTOCOL
*
693 DevPathFromTextAcpi (
694 IN CHAR16
*TextDeviceNode
699 ACPI_HID_DEVICE_PATH
*Acpi
;
701 HIDStr
= GetNextParamStr (&TextDeviceNode
);
702 UIDStr
= GetNextParamStr (&TextDeviceNode
);
703 Acpi
= (ACPI_HID_DEVICE_PATH
*)CreateDeviceNode (
706 (UINT16
)sizeof (ACPI_HID_DEVICE_PATH
)
709 Acpi
->HID
= EisaIdFromText (HIDStr
);
710 Acpi
->UID
= (UINT32
)Strtoi (UIDStr
);
712 return (EFI_DEVICE_PATH_PROTOCOL
*)Acpi
;
716 Converts a text device path node to ACPI HID device path structure.
718 @param TextDeviceNode The input Text device path node.
719 @param PnPId The input plug and play identification.
721 @return A pointer to the newly-created ACPI HID device path structure.
724 EFI_DEVICE_PATH_PROTOCOL
*
725 ConvertFromTextAcpi (
726 IN CHAR16
*TextDeviceNode
,
731 ACPI_HID_DEVICE_PATH
*Acpi
;
733 UIDStr
= GetNextParamStr (&TextDeviceNode
);
734 Acpi
= (ACPI_HID_DEVICE_PATH
*)CreateDeviceNode (
737 (UINT16
)sizeof (ACPI_HID_DEVICE_PATH
)
740 Acpi
->HID
= EFI_PNP_ID (PnPId
);
741 Acpi
->UID
= (UINT32
)Strtoi (UIDStr
);
743 return (EFI_DEVICE_PATH_PROTOCOL
*)Acpi
;
747 Converts a text device path node to PCI root device path structure.
749 @param TextDeviceNode The input Text device path node.
751 @return A pointer to the newly-created PCI root device path structure.
754 EFI_DEVICE_PATH_PROTOCOL
*
755 DevPathFromTextPciRoot (
756 IN CHAR16
*TextDeviceNode
759 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a03);
763 Converts a text device path node to PCIE root device path structure.
765 @param TextDeviceNode The input Text device path node.
767 @return A pointer to the newly-created PCIE root device path structure.
770 EFI_DEVICE_PATH_PROTOCOL
*
771 DevPathFromTextPcieRoot (
772 IN CHAR16
*TextDeviceNode
775 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a08);
779 Converts a text device path node to Floppy device path structure.
781 @param TextDeviceNode The input Text device path node.
783 @return A pointer to the newly-created Floppy device path structure.
786 EFI_DEVICE_PATH_PROTOCOL
*
787 DevPathFromTextFloppy (
788 IN CHAR16
*TextDeviceNode
791 return ConvertFromTextAcpi (TextDeviceNode
, 0x0604);
795 Converts a text device path node to Keyboard device path structure.
797 @param TextDeviceNode The input Text device path node.
799 @return A pointer to the newly-created Keyboard device path structure.
802 EFI_DEVICE_PATH_PROTOCOL
*
803 DevPathFromTextKeyboard (
804 IN CHAR16
*TextDeviceNode
807 return ConvertFromTextAcpi (TextDeviceNode
, 0x0301);
811 Converts a text device path node to Serial device path structure.
813 @param TextDeviceNode The input Text device path node.
815 @return A pointer to the newly-created Serial device path structure.
818 EFI_DEVICE_PATH_PROTOCOL
*
819 DevPathFromTextSerial (
820 IN CHAR16
*TextDeviceNode
823 return ConvertFromTextAcpi (TextDeviceNode
, 0x0501);
827 Converts a text device path node to Parallel Port device path structure.
829 @param TextDeviceNode The input Text device path node.
831 @return A pointer to the newly-created Parallel Port device path structure.
834 EFI_DEVICE_PATH_PROTOCOL
*
835 DevPathFromTextParallelPort (
836 IN CHAR16
*TextDeviceNode
839 return ConvertFromTextAcpi (TextDeviceNode
, 0x0401);
843 Converts a text device path node to ACPI extension device path structure.
845 @param TextDeviceNode The input Text device path node.
847 @return A pointer to the newly-created ACPI extension device path structure.
850 EFI_DEVICE_PATH_PROTOCOL
*
851 DevPathFromTextAcpiEx (
852 IN CHAR16
*TextDeviceNode
863 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
865 HIDStr
= GetNextParamStr (&TextDeviceNode
);
866 CIDStr
= GetNextParamStr (&TextDeviceNode
);
867 UIDStr
= GetNextParamStr (&TextDeviceNode
);
868 HIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
869 CIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
870 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
872 Length
= (UINT16
)(sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (HIDSTRStr
) + 1);
873 Length
= (UINT16
)(Length
+ StrLen (UIDSTRStr
) + 1);
874 Length
= (UINT16
)(Length
+ StrLen (CIDSTRStr
) + 1);
875 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*)CreateDeviceNode (
881 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
882 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
883 AcpiEx
->UID
= (UINT32
)Strtoi (UIDStr
);
885 AsciiStr
= (CHAR8
*)((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
886 StrToAscii (HIDSTRStr
, &AsciiStr
);
887 StrToAscii (UIDSTRStr
, &AsciiStr
);
888 StrToAscii (CIDSTRStr
, &AsciiStr
);
890 return (EFI_DEVICE_PATH_PROTOCOL
*)AcpiEx
;
894 Converts a text device path node to ACPI extension device path structure.
896 @param TextDeviceNode The input Text device path node.
898 @return A pointer to the newly-created ACPI extension device path structure.
901 EFI_DEVICE_PATH_PROTOCOL
*
902 DevPathFromTextAcpiExp (
903 IN CHAR16
*TextDeviceNode
911 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
913 HIDStr
= GetNextParamStr (&TextDeviceNode
);
914 CIDStr
= GetNextParamStr (&TextDeviceNode
);
915 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
916 Length
= (UINT16
)(sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (UIDSTRStr
) + 3);
917 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*)CreateDeviceNode (
923 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
925 // According to UEFI spec, the CID parametr is optional and has a default value of 0.
926 // So when the CID parametr is not specified or specified as 0 in the text device node.
927 // Set the CID to 0 in the ACPI extension device path structure.
929 if ((*CIDStr
== L
'\0') || (*CIDStr
== L
'0')) {
932 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
937 AsciiStr
= (CHAR8
*)((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
939 // HID string is NULL
943 // Convert UID string
946 StrToAscii (UIDSTRStr
, &AsciiStr
);
948 // CID string is NULL
952 return (EFI_DEVICE_PATH_PROTOCOL
*)AcpiEx
;
956 Converts a text device path node to ACPI _ADR device path structure.
958 @param TextDeviceNode The input Text device path node.
960 @return A pointer to the newly-created ACPI _ADR device path structure.
963 EFI_DEVICE_PATH_PROTOCOL
*
964 DevPathFromTextAcpiAdr (
965 IN CHAR16
*TextDeviceNode
968 CHAR16
*DisplayDeviceStr
;
969 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
973 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*)CreateDeviceNode (
976 (UINT16
)sizeof (ACPI_ADR_DEVICE_PATH
)
978 ASSERT (AcpiAdr
!= NULL
);
980 for (Index
= 0; ; Index
++) {
981 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
982 if (IS_NULL (*DisplayDeviceStr
)) {
987 Length
= DevicePathNodeLength (AcpiAdr
);
988 AcpiAdr
= ReallocatePool (
990 Length
+ sizeof (UINT32
),
993 ASSERT (AcpiAdr
!= NULL
);
994 SetDevicePathNodeLength (AcpiAdr
, Length
+ sizeof (UINT32
));
997 (&AcpiAdr
->ADR
)[Index
] = (UINT32
)Strtoi (DisplayDeviceStr
);
1000 return (EFI_DEVICE_PATH_PROTOCOL
*)AcpiAdr
;
1004 Converts a generic messaging text device path node to messaging device path structure.
1006 @param TextDeviceNode The input Text device path node.
1008 @return A pointer to messaging device path structure.
1011 EFI_DEVICE_PATH_PROTOCOL
*
1012 DevPathFromTextMsg (
1013 IN CHAR16
*TextDeviceNode
1016 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH
, TextDeviceNode
);
1020 Converts a text device path node to Parallel Port device path structure.
1022 @param TextDeviceNode The input Text device path node.
1024 @return A pointer to the newly-created Parallel Port device path structure.
1027 EFI_DEVICE_PATH_PROTOCOL
*
1028 DevPathFromTextAta (
1029 IN CHAR16
*TextDeviceNode
1032 CHAR16
*PrimarySecondaryStr
;
1033 CHAR16
*SlaveMasterStr
;
1035 ATAPI_DEVICE_PATH
*Atapi
;
1037 Atapi
= (ATAPI_DEVICE_PATH
*)CreateDeviceNode (
1038 MESSAGING_DEVICE_PATH
,
1040 (UINT16
)sizeof (ATAPI_DEVICE_PATH
)
1043 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
1044 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
1045 LunStr
= GetNextParamStr (&TextDeviceNode
);
1047 if (StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) {
1048 Atapi
->PrimarySecondary
= 0;
1049 } else if (StrCmp (PrimarySecondaryStr
, L
"Secondary") == 0) {
1050 Atapi
->PrimarySecondary
= 1;
1052 Atapi
->PrimarySecondary
= (UINT8
)Strtoi (PrimarySecondaryStr
);
1055 if (StrCmp (SlaveMasterStr
, L
"Master") == 0) {
1056 Atapi
->SlaveMaster
= 0;
1057 } else if (StrCmp (SlaveMasterStr
, L
"Slave") == 0) {
1058 Atapi
->SlaveMaster
= 1;
1060 Atapi
->SlaveMaster
= (UINT8
)Strtoi (SlaveMasterStr
);
1063 Atapi
->Lun
= (UINT16
)Strtoi (LunStr
);
1065 return (EFI_DEVICE_PATH_PROTOCOL
*)Atapi
;
1069 Converts a text device path node to SCSI device path structure.
1071 @param TextDeviceNode The input Text device path node.
1073 @return A pointer to the newly-created SCSI device path structure.
1076 EFI_DEVICE_PATH_PROTOCOL
*
1077 DevPathFromTextScsi (
1078 IN CHAR16
*TextDeviceNode
1083 SCSI_DEVICE_PATH
*Scsi
;
1085 PunStr
= GetNextParamStr (&TextDeviceNode
);
1086 LunStr
= GetNextParamStr (&TextDeviceNode
);
1087 Scsi
= (SCSI_DEVICE_PATH
*)CreateDeviceNode (
1088 MESSAGING_DEVICE_PATH
,
1090 (UINT16
)sizeof (SCSI_DEVICE_PATH
)
1093 Scsi
->Pun
= (UINT16
)Strtoi (PunStr
);
1094 Scsi
->Lun
= (UINT16
)Strtoi (LunStr
);
1096 return (EFI_DEVICE_PATH_PROTOCOL
*)Scsi
;
1100 Converts a text device path node to Fibre device path structure.
1102 @param TextDeviceNode The input Text device path node.
1104 @return A pointer to the newly-created Fibre device path structure.
1107 EFI_DEVICE_PATH_PROTOCOL
*
1108 DevPathFromTextFibre (
1109 IN CHAR16
*TextDeviceNode
1114 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
1116 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1117 LunStr
= GetNextParamStr (&TextDeviceNode
);
1118 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*)CreateDeviceNode (
1119 MESSAGING_DEVICE_PATH
,
1120 MSG_FIBRECHANNEL_DP
,
1121 (UINT16
)sizeof (FIBRECHANNEL_DEVICE_PATH
)
1124 Fibre
->Reserved
= 0;
1125 Strtoi64 (WWNStr
, &Fibre
->WWN
);
1126 Strtoi64 (LunStr
, &Fibre
->Lun
);
1128 return (EFI_DEVICE_PATH_PROTOCOL
*)Fibre
;
1132 Converts a text device path node to FibreEx device path structure.
1134 @param TextDeviceNode The input Text device path node.
1136 @return A pointer to the newly-created FibreEx device path structure.
1139 EFI_DEVICE_PATH_PROTOCOL
*
1140 DevPathFromTextFibreEx (
1141 IN CHAR16
*TextDeviceNode
1146 FIBRECHANNELEX_DEVICE_PATH
*FibreEx
;
1148 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1149 LunStr
= GetNextParamStr (&TextDeviceNode
);
1150 FibreEx
= (FIBRECHANNELEX_DEVICE_PATH
*)CreateDeviceNode (
1151 MESSAGING_DEVICE_PATH
,
1152 MSG_FIBRECHANNELEX_DP
,
1153 (UINT16
)sizeof (FIBRECHANNELEX_DEVICE_PATH
)
1156 FibreEx
->Reserved
= 0;
1157 Strtoi64 (WWNStr
, (UINT64
*)(&FibreEx
->WWN
));
1158 Strtoi64 (LunStr
, (UINT64
*)(&FibreEx
->Lun
));
1160 *(UINT64
*)(&FibreEx
->WWN
) = SwapBytes64 (*(UINT64
*)(&FibreEx
->WWN
));
1161 *(UINT64
*)(&FibreEx
->Lun
) = SwapBytes64 (*(UINT64
*)(&FibreEx
->Lun
));
1163 return (EFI_DEVICE_PATH_PROTOCOL
*)FibreEx
;
1167 Converts a text device path node to 1394 device path structure.
1169 @param TextDeviceNode The input Text device path node.
1171 @return A pointer to the newly-created 1394 device path structure.
1174 EFI_DEVICE_PATH_PROTOCOL
*
1175 DevPathFromText1394 (
1176 IN CHAR16
*TextDeviceNode
1180 F1394_DEVICE_PATH
*F1394DevPath
;
1182 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1183 F1394DevPath
= (F1394_DEVICE_PATH
*)CreateDeviceNode (
1184 MESSAGING_DEVICE_PATH
,
1186 (UINT16
)sizeof (F1394_DEVICE_PATH
)
1189 F1394DevPath
->Reserved
= 0;
1190 F1394DevPath
->Guid
= StrHexToUint64 (GuidStr
);
1192 return (EFI_DEVICE_PATH_PROTOCOL
*)F1394DevPath
;
1196 Converts a text device path node to USB device path structure.
1198 @param TextDeviceNode The input Text device path node.
1200 @return A pointer to the newly-created USB device path structure.
1203 EFI_DEVICE_PATH_PROTOCOL
*
1204 DevPathFromTextUsb (
1205 IN CHAR16
*TextDeviceNode
1209 CHAR16
*InterfaceStr
;
1210 USB_DEVICE_PATH
*Usb
;
1212 PortStr
= GetNextParamStr (&TextDeviceNode
);
1213 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1214 Usb
= (USB_DEVICE_PATH
*)CreateDeviceNode (
1215 MESSAGING_DEVICE_PATH
,
1217 (UINT16
)sizeof (USB_DEVICE_PATH
)
1220 Usb
->ParentPortNumber
= (UINT8
)Strtoi (PortStr
);
1221 Usb
->InterfaceNumber
= (UINT8
)Strtoi (InterfaceStr
);
1223 return (EFI_DEVICE_PATH_PROTOCOL
*)Usb
;
1227 Converts a text device path node to I20 device path structure.
1229 @param TextDeviceNode The input Text device path node.
1231 @return A pointer to the newly-created I20 device path structure.
1234 EFI_DEVICE_PATH_PROTOCOL
*
1235 DevPathFromTextI2O (
1236 IN CHAR16
*TextDeviceNode
1240 I2O_DEVICE_PATH
*I2ODevPath
;
1242 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1243 I2ODevPath
= (I2O_DEVICE_PATH
*)CreateDeviceNode (
1244 MESSAGING_DEVICE_PATH
,
1246 (UINT16
)sizeof (I2O_DEVICE_PATH
)
1249 I2ODevPath
->Tid
= (UINT32
)Strtoi (TIDStr
);
1251 return (EFI_DEVICE_PATH_PROTOCOL
*)I2ODevPath
;
1255 Converts a text device path node to Infini Band device path structure.
1257 @param TextDeviceNode The input Text device path node.
1259 @return A pointer to the newly-created Infini Band device path structure.
1262 EFI_DEVICE_PATH_PROTOCOL
*
1263 DevPathFromTextInfiniband (
1264 IN CHAR16
*TextDeviceNode
1272 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1274 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1275 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1276 SidStr
= GetNextParamStr (&TextDeviceNode
);
1277 TidStr
= GetNextParamStr (&TextDeviceNode
);
1278 DidStr
= GetNextParamStr (&TextDeviceNode
);
1279 InfiniBand
= (INFINIBAND_DEVICE_PATH
*)CreateDeviceNode (
1280 MESSAGING_DEVICE_PATH
,
1282 (UINT16
)sizeof (INFINIBAND_DEVICE_PATH
)
1285 InfiniBand
->ResourceFlags
= (UINT32
)Strtoi (FlagsStr
);
1286 StrToGuid (GuidStr
, (EFI_GUID
*)InfiniBand
->PortGid
);
1287 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1288 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1289 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1291 return (EFI_DEVICE_PATH_PROTOCOL
*)InfiniBand
;
1295 Converts a text device path node to Vendor-Defined Messaging device path structure.
1297 @param TextDeviceNode The input Text device path node.
1299 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1302 EFI_DEVICE_PATH_PROTOCOL
*
1303 DevPathFromTextVenMsg (
1304 IN CHAR16
*TextDeviceNode
1307 return ConvertFromTextVendor (
1309 MESSAGING_DEVICE_PATH
,
1315 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1317 @param TextDeviceNode The input Text device path node.
1319 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1322 EFI_DEVICE_PATH_PROTOCOL
*
1323 DevPathFromTextVenPcAnsi (
1324 IN CHAR16
*TextDeviceNode
1327 VENDOR_DEVICE_PATH
*Vendor
;
1329 Vendor
= (VENDOR_DEVICE_PATH
*)CreateDeviceNode (
1330 MESSAGING_DEVICE_PATH
,
1332 (UINT16
)sizeof (VENDOR_DEVICE_PATH
)
1334 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1336 return (EFI_DEVICE_PATH_PROTOCOL
*)Vendor
;
1340 Converts a text device path node to Vendor defined VT100 device path structure.
1342 @param TextDeviceNode The input Text device path node.
1344 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1347 EFI_DEVICE_PATH_PROTOCOL
*
1348 DevPathFromTextVenVt100 (
1349 IN CHAR16
*TextDeviceNode
1352 VENDOR_DEVICE_PATH
*Vendor
;
1354 Vendor
= (VENDOR_DEVICE_PATH
*)CreateDeviceNode (
1355 MESSAGING_DEVICE_PATH
,
1357 (UINT16
)sizeof (VENDOR_DEVICE_PATH
)
1359 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1361 return (EFI_DEVICE_PATH_PROTOCOL
*)Vendor
;
1365 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1367 @param TextDeviceNode The input Text device path node.
1369 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1372 EFI_DEVICE_PATH_PROTOCOL
*
1373 DevPathFromTextVenVt100Plus (
1374 IN CHAR16
*TextDeviceNode
1377 VENDOR_DEVICE_PATH
*Vendor
;
1379 Vendor
= (VENDOR_DEVICE_PATH
*)CreateDeviceNode (
1380 MESSAGING_DEVICE_PATH
,
1382 (UINT16
)sizeof (VENDOR_DEVICE_PATH
)
1384 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1386 return (EFI_DEVICE_PATH_PROTOCOL
*)Vendor
;
1390 Converts a text device path node to Vendor defined UTF8 device path structure.
1392 @param TextDeviceNode The input Text device path node.
1394 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1397 EFI_DEVICE_PATH_PROTOCOL
*
1398 DevPathFromTextVenUtf8 (
1399 IN CHAR16
*TextDeviceNode
1402 VENDOR_DEVICE_PATH
*Vendor
;
1404 Vendor
= (VENDOR_DEVICE_PATH
*)CreateDeviceNode (
1405 MESSAGING_DEVICE_PATH
,
1407 (UINT16
)sizeof (VENDOR_DEVICE_PATH
)
1409 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1411 return (EFI_DEVICE_PATH_PROTOCOL
*)Vendor
;
1415 Converts a text device path node to UART Flow Control device path structure.
1417 @param TextDeviceNode The input Text device path node.
1419 @return A pointer to the newly-created UART Flow Control device path structure.
1422 EFI_DEVICE_PATH_PROTOCOL
*
1423 DevPathFromTextUartFlowCtrl (
1424 IN CHAR16
*TextDeviceNode
1428 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1430 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1431 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*)CreateDeviceNode (
1432 MESSAGING_DEVICE_PATH
,
1434 (UINT16
)sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1437 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1438 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1439 UartFlowControl
->FlowControlMap
= 2;
1440 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1441 UartFlowControl
->FlowControlMap
= 1;
1443 UartFlowControl
->FlowControlMap
= 0;
1446 return (EFI_DEVICE_PATH_PROTOCOL
*)UartFlowControl
;
1450 Converts a text device path node to Serial Attached SCSI device path structure.
1452 @param TextDeviceNode The input Text device path node.
1454 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1457 EFI_DEVICE_PATH_PROTOCOL
*
1458 DevPathFromTextSAS (
1459 IN CHAR16
*TextDeviceNode
1466 CHAR16
*LocationStr
;
1468 CHAR16
*DriveBayStr
;
1469 CHAR16
*ReservedStr
;
1472 SAS_DEVICE_PATH
*Sas
;
1474 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1475 LunStr
= GetNextParamStr (&TextDeviceNode
);
1476 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1477 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1478 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1479 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1480 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1481 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1482 Sas
= (SAS_DEVICE_PATH
*)CreateDeviceNode (
1483 MESSAGING_DEVICE_PATH
,
1485 (UINT16
)sizeof (SAS_DEVICE_PATH
)
1488 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1489 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1490 Strtoi64 (LunStr
, &Sas
->Lun
);
1491 Sas
->RelativeTargetPort
= (UINT16
)Strtoi (RTPStr
);
1493 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1495 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1496 Uint16
= (UINT16
)Strtoi (DriveBayStr
);
1500 Info
= (UINT16
)(0x2 | ((Uint16
- 1) << 8));
1503 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1508 // Location is an integer between 0 and 1 or else
1509 // the keyword Internal (0) or External (1).
1511 if (StrCmp (LocationStr
, L
"External") == 0) {
1513 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1516 Uint16
= ((UINT16
)Strtoi (LocationStr
) & BIT0
);
1519 Info
|= (Uint16
<< 5);
1522 // Connect is an integer between 0 and 3 or else
1523 // the keyword Direct (0) or Expanded (1).
1525 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1527 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1530 Uint16
= ((UINT16
)Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1533 Info
|= (Uint16
<< 6);
1535 Info
= (UINT16
)Strtoi (SASSATAStr
);
1538 Sas
->DeviceTopology
= Info
;
1539 Sas
->Reserved
= (UINT32
)Strtoi (ReservedStr
);
1541 return (EFI_DEVICE_PATH_PROTOCOL
*)Sas
;
1545 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1547 @param TextDeviceNode The input Text device path node.
1549 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1552 EFI_DEVICE_PATH_PROTOCOL
*
1553 DevPathFromTextSasEx (
1554 IN CHAR16
*TextDeviceNode
1561 CHAR16
*LocationStr
;
1563 CHAR16
*DriveBayStr
;
1568 SASEX_DEVICE_PATH
*SasEx
;
1570 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1571 LunStr
= GetNextParamStr (&TextDeviceNode
);
1572 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1573 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1574 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1575 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1576 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1577 SasEx
= (SASEX_DEVICE_PATH
*)CreateDeviceNode (
1578 MESSAGING_DEVICE_PATH
,
1580 (UINT16
)sizeof (SASEX_DEVICE_PATH
)
1583 Strtoi64 (AddressStr
, &SasAddress
);
1584 Strtoi64 (LunStr
, &Lun
);
1585 WriteUnaligned64 ((UINT64
*)&SasEx
->SasAddress
, SwapBytes64 (SasAddress
));
1586 WriteUnaligned64 ((UINT64
*)&SasEx
->Lun
, SwapBytes64 (Lun
));
1587 SasEx
->RelativeTargetPort
= (UINT16
)Strtoi (RTPStr
);
1589 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1591 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1592 Uint16
= (UINT16
)Strtoi (DriveBayStr
);
1596 Info
= (UINT16
)(0x2 | ((Uint16
- 1) << 8));
1599 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1604 // Location is an integer between 0 and 1 or else
1605 // the keyword Internal (0) or External (1).
1607 if (StrCmp (LocationStr
, L
"External") == 0) {
1609 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1612 Uint16
= ((UINT16
)Strtoi (LocationStr
) & BIT0
);
1615 Info
|= (Uint16
<< 5);
1618 // Connect is an integer between 0 and 3 or else
1619 // the keyword Direct (0) or Expanded (1).
1621 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1623 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1626 Uint16
= ((UINT16
)Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1629 Info
|= (Uint16
<< 6);
1631 Info
= (UINT16
)Strtoi (SASSATAStr
);
1634 SasEx
->DeviceTopology
= Info
;
1636 return (EFI_DEVICE_PATH_PROTOCOL
*)SasEx
;
1640 Converts a text device path node to NVM Express Namespace device path structure.
1642 @param TextDeviceNode The input Text device path node.
1644 @return A pointer to the newly-created NVM Express Namespace device path structure.
1647 EFI_DEVICE_PATH_PROTOCOL
*
1648 DevPathFromTextNVMe (
1649 IN CHAR16
*TextDeviceNode
1652 CHAR16
*NamespaceIdStr
;
1653 CHAR16
*NamespaceUuidStr
;
1654 NVME_NAMESPACE_DEVICE_PATH
*Nvme
;
1658 NamespaceIdStr
= GetNextParamStr (&TextDeviceNode
);
1659 NamespaceUuidStr
= GetNextParamStr (&TextDeviceNode
);
1660 Nvme
= (NVME_NAMESPACE_DEVICE_PATH
*)CreateDeviceNode (
1661 MESSAGING_DEVICE_PATH
,
1662 MSG_NVME_NAMESPACE_DP
,
1663 (UINT16
)sizeof (NVME_NAMESPACE_DEVICE_PATH
)
1666 Nvme
->NamespaceId
= (UINT32
)Strtoi (NamespaceIdStr
);
1667 Uuid
= (UINT8
*)&Nvme
->NamespaceUuid
;
1669 Index
= sizeof (Nvme
->NamespaceUuid
) / sizeof (UINT8
);
1670 while (Index
-- != 0) {
1671 Uuid
[Index
] = (UINT8
)StrHexToUintn (SplitStr (&NamespaceUuidStr
, L
'-'));
1674 return (EFI_DEVICE_PATH_PROTOCOL
*)Nvme
;
1678 Converts a text device path node to UFS device path structure.
1680 @param TextDeviceNode The input Text device path node.
1682 @return A pointer to the newly-created UFS device path structure.
1685 EFI_DEVICE_PATH_PROTOCOL
*
1686 DevPathFromTextUfs (
1687 IN CHAR16
*TextDeviceNode
1692 UFS_DEVICE_PATH
*Ufs
;
1694 PunStr
= GetNextParamStr (&TextDeviceNode
);
1695 LunStr
= GetNextParamStr (&TextDeviceNode
);
1696 Ufs
= (UFS_DEVICE_PATH
*)CreateDeviceNode (
1697 MESSAGING_DEVICE_PATH
,
1699 (UINT16
)sizeof (UFS_DEVICE_PATH
)
1702 Ufs
->Pun
= (UINT8
)Strtoi (PunStr
);
1703 Ufs
->Lun
= (UINT8
)Strtoi (LunStr
);
1705 return (EFI_DEVICE_PATH_PROTOCOL
*)Ufs
;
1709 Converts a text device path node to SD (Secure Digital) device path structure.
1711 @param TextDeviceNode The input Text device path node.
1713 @return A pointer to the newly-created SD device path structure.
1716 EFI_DEVICE_PATH_PROTOCOL
*
1718 IN CHAR16
*TextDeviceNode
1721 CHAR16
*SlotNumberStr
;
1724 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1725 Sd
= (SD_DEVICE_PATH
*)CreateDeviceNode (
1726 MESSAGING_DEVICE_PATH
,
1728 (UINT16
)sizeof (SD_DEVICE_PATH
)
1731 Sd
->SlotNumber
= (UINT8
)Strtoi (SlotNumberStr
);
1733 return (EFI_DEVICE_PATH_PROTOCOL
*)Sd
;
1737 Converts a text device path node to EMMC (Embedded MMC) device path structure.
1739 @param TextDeviceNode The input Text device path node.
1741 @return A pointer to the newly-created EMMC device path structure.
1744 EFI_DEVICE_PATH_PROTOCOL
*
1745 DevPathFromTextEmmc (
1746 IN CHAR16
*TextDeviceNode
1749 CHAR16
*SlotNumberStr
;
1750 EMMC_DEVICE_PATH
*Emmc
;
1752 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1753 Emmc
= (EMMC_DEVICE_PATH
*)CreateDeviceNode (
1754 MESSAGING_DEVICE_PATH
,
1756 (UINT16
)sizeof (EMMC_DEVICE_PATH
)
1759 Emmc
->SlotNumber
= (UINT8
)Strtoi (SlotNumberStr
);
1761 return (EFI_DEVICE_PATH_PROTOCOL
*)Emmc
;
1765 Converts a text device path node to Debug Port device path structure.
1767 @param TextDeviceNode The input Text device path node.
1769 @return A pointer to the newly-created Debug Port device path structure.
1772 EFI_DEVICE_PATH_PROTOCOL
*
1773 DevPathFromTextDebugPort (
1774 IN CHAR16
*TextDeviceNode
1777 VENDOR_DEVICE_PATH
*Vend
;
1779 Vend
= (VENDOR_DEVICE_PATH
*)CreateDeviceNode (
1780 MESSAGING_DEVICE_PATH
,
1782 (UINT16
)sizeof (VENDOR_DEVICE_PATH
)
1785 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1787 return (EFI_DEVICE_PATH_PROTOCOL
*)Vend
;
1791 Converts a text device path node to MAC device path structure.
1793 @param TextDeviceNode The input Text device path node.
1795 @return A pointer to the newly-created MAC device path structure.
1798 EFI_DEVICE_PATH_PROTOCOL
*
1799 DevPathFromTextMAC (
1800 IN CHAR16
*TextDeviceNode
1806 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1808 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1809 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1810 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*)CreateDeviceNode (
1811 MESSAGING_DEVICE_PATH
,
1813 (UINT16
)sizeof (MAC_ADDR_DEVICE_PATH
)
1816 MACDevPath
->IfType
= (UINT8
)Strtoi (IfTypeStr
);
1818 Length
= sizeof (EFI_MAC_ADDRESS
);
1819 if ((MACDevPath
->IfType
== 0x01) || (MACDevPath
->IfType
== 0x00)) {
1823 StrHexToBytes (AddressStr
, Length
* 2, MACDevPath
->MacAddress
.Addr
, Length
);
1825 return (EFI_DEVICE_PATH_PROTOCOL
*)MACDevPath
;
1829 Converts a text format to the network protocol ID.
1831 @param Text String of protocol field.
1833 @return Network protocol ID .
1837 NetworkProtocolFromText (
1841 if (StrCmp (Text
, L
"UDP") == 0) {
1842 return RFC_1700_UDP_PROTOCOL
;
1845 if (StrCmp (Text
, L
"TCP") == 0) {
1846 return RFC_1700_TCP_PROTOCOL
;
1849 return Strtoi (Text
);
1853 Converts a text device path node to IPV4 device path structure.
1855 @param TextDeviceNode The input Text device path node.
1857 @return A pointer to the newly-created IPV4 device path structure.
1860 EFI_DEVICE_PATH_PROTOCOL
*
1861 DevPathFromTextIPv4 (
1862 IN CHAR16
*TextDeviceNode
1865 CHAR16
*RemoteIPStr
;
1866 CHAR16
*ProtocolStr
;
1869 CHAR16
*GatewayIPStr
;
1870 CHAR16
*SubnetMaskStr
;
1871 IPv4_DEVICE_PATH
*IPv4
;
1873 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1874 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1875 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1876 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1877 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1878 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
1879 IPv4
= (IPv4_DEVICE_PATH
*)CreateDeviceNode (
1880 MESSAGING_DEVICE_PATH
,
1882 (UINT16
)sizeof (IPv4_DEVICE_PATH
)
1885 StrToIpv4Address (RemoteIPStr
, NULL
, &IPv4
->RemoteIpAddress
, NULL
);
1886 IPv4
->Protocol
= (UINT16
)NetworkProtocolFromText (ProtocolStr
);
1887 if (StrCmp (TypeStr
, L
"Static") == 0) {
1888 IPv4
->StaticIpAddress
= TRUE
;
1890 IPv4
->StaticIpAddress
= FALSE
;
1893 StrToIpv4Address (LocalIPStr
, NULL
, &IPv4
->LocalIpAddress
, NULL
);
1894 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
1895 StrToIpv4Address (GatewayIPStr
, NULL
, &IPv4
->GatewayIpAddress
, NULL
);
1896 StrToIpv4Address (SubnetMaskStr
, NULL
, &IPv4
->SubnetMask
, NULL
);
1898 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
1899 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
1902 IPv4
->LocalPort
= 0;
1903 IPv4
->RemotePort
= 0;
1905 return (EFI_DEVICE_PATH_PROTOCOL
*)IPv4
;
1909 Converts a text device path node to IPV6 device path structure.
1911 @param TextDeviceNode The input Text device path node.
1913 @return A pointer to the newly-created IPV6 device path structure.
1916 EFI_DEVICE_PATH_PROTOCOL
*
1917 DevPathFromTextIPv6 (
1918 IN CHAR16
*TextDeviceNode
1921 CHAR16
*RemoteIPStr
;
1922 CHAR16
*ProtocolStr
;
1925 CHAR16
*GatewayIPStr
;
1926 CHAR16
*PrefixLengthStr
;
1927 IPv6_DEVICE_PATH
*IPv6
;
1929 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1930 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1931 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1932 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1933 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
1934 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1935 IPv6
= (IPv6_DEVICE_PATH
*)CreateDeviceNode (
1936 MESSAGING_DEVICE_PATH
,
1938 (UINT16
)sizeof (IPv6_DEVICE_PATH
)
1941 StrToIpv6Address (RemoteIPStr
, NULL
, &IPv6
->RemoteIpAddress
, NULL
);
1942 IPv6
->Protocol
= (UINT16
)NetworkProtocolFromText (ProtocolStr
);
1943 if (StrCmp (TypeStr
, L
"Static") == 0) {
1944 IPv6
->IpAddressOrigin
= 0;
1945 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
1946 IPv6
->IpAddressOrigin
= 1;
1948 IPv6
->IpAddressOrigin
= 2;
1951 StrToIpv6Address (LocalIPStr
, NULL
, &IPv6
->LocalIpAddress
, NULL
);
1952 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
1953 StrToIpv6Address (GatewayIPStr
, NULL
, &IPv6
->GatewayIpAddress
, NULL
);
1954 IPv6
->PrefixLength
= (UINT8
)Strtoi (PrefixLengthStr
);
1956 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
1957 IPv6
->PrefixLength
= 0;
1960 IPv6
->LocalPort
= 0;
1961 IPv6
->RemotePort
= 0;
1963 return (EFI_DEVICE_PATH_PROTOCOL
*)IPv6
;
1967 Converts a text device path node to UART device path structure.
1969 @param TextDeviceNode The input Text device path node.
1971 @return A pointer to the newly-created UART device path structure.
1974 EFI_DEVICE_PATH_PROTOCOL
*
1975 DevPathFromTextUart (
1976 IN CHAR16
*TextDeviceNode
1980 CHAR16
*DataBitsStr
;
1982 CHAR16
*StopBitsStr
;
1983 UART_DEVICE_PATH
*Uart
;
1985 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1986 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1987 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1988 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1989 Uart
= (UART_DEVICE_PATH
*)CreateDeviceNode (
1990 MESSAGING_DEVICE_PATH
,
1992 (UINT16
)sizeof (UART_DEVICE_PATH
)
1995 if (StrCmp (BaudStr
, L
"DEFAULT") == 0) {
1996 Uart
->BaudRate
= 115200;
1998 Strtoi64 (BaudStr
, &Uart
->BaudRate
);
2001 Uart
->DataBits
= (UINT8
)((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr
));
2002 switch (*ParityStr
) {
2028 Uart
->Parity
= (UINT8
)Strtoi (ParityStr
);
2032 if (StrCmp (StopBitsStr
, L
"D") == 0) {
2033 Uart
->StopBits
= (UINT8
)0;
2034 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
2035 Uart
->StopBits
= (UINT8
)1;
2036 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
2037 Uart
->StopBits
= (UINT8
)2;
2038 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
2039 Uart
->StopBits
= (UINT8
)3;
2041 Uart
->StopBits
= (UINT8
)Strtoi (StopBitsStr
);
2044 return (EFI_DEVICE_PATH_PROTOCOL
*)Uart
;
2048 Converts a text device path node to USB class device path structure.
2050 @param TextDeviceNode The input Text device path node.
2051 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
2053 @return A pointer to the newly-created USB class device path structure.
2056 EFI_DEVICE_PATH_PROTOCOL
*
2057 ConvertFromTextUsbClass (
2058 IN CHAR16
*TextDeviceNode
,
2059 IN USB_CLASS_TEXT
*UsbClassText
2065 CHAR16
*SubClassStr
;
2066 CHAR16
*ProtocolStr
;
2067 USB_CLASS_DEVICE_PATH
*UsbClass
;
2069 UsbClass
= (USB_CLASS_DEVICE_PATH
*)CreateDeviceNode (
2070 MESSAGING_DEVICE_PATH
,
2072 (UINT16
)sizeof (USB_CLASS_DEVICE_PATH
)
2075 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2076 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2077 if (UsbClassText
->ClassExist
) {
2078 ClassStr
= GetNextParamStr (&TextDeviceNode
);
2079 if (*ClassStr
== L
'\0') {
2080 UsbClass
->DeviceClass
= 0xFF;
2082 UsbClass
->DeviceClass
= (UINT8
)Strtoi (ClassStr
);
2085 UsbClass
->DeviceClass
= UsbClassText
->Class
;
2088 if (UsbClassText
->SubClassExist
) {
2089 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
2090 if (*SubClassStr
== L
'\0') {
2091 UsbClass
->DeviceSubClass
= 0xFF;
2093 UsbClass
->DeviceSubClass
= (UINT8
)Strtoi (SubClassStr
);
2096 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
2099 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2101 if (*VIDStr
== L
'\0') {
2102 UsbClass
->VendorId
= 0xFFFF;
2104 UsbClass
->VendorId
= (UINT16
)Strtoi (VIDStr
);
2107 if (*PIDStr
== L
'\0') {
2108 UsbClass
->ProductId
= 0xFFFF;
2110 UsbClass
->ProductId
= (UINT16
)Strtoi (PIDStr
);
2113 if (*ProtocolStr
== L
'\0') {
2114 UsbClass
->DeviceProtocol
= 0xFF;
2116 UsbClass
->DeviceProtocol
= (UINT8
)Strtoi (ProtocolStr
);
2119 return (EFI_DEVICE_PATH_PROTOCOL
*)UsbClass
;
2123 Converts a text device path node to USB class device path structure.
2125 @param TextDeviceNode The input Text device path node.
2127 @return A pointer to the newly-created USB class device path structure.
2130 EFI_DEVICE_PATH_PROTOCOL
*
2131 DevPathFromTextUsbClass (
2132 IN CHAR16
*TextDeviceNode
2135 USB_CLASS_TEXT UsbClassText
;
2137 UsbClassText
.ClassExist
= TRUE
;
2138 UsbClassText
.SubClassExist
= TRUE
;
2140 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2144 Converts a text device path node to USB audio device path structure.
2146 @param TextDeviceNode The input Text device path node.
2148 @return A pointer to the newly-created USB audio device path structure.
2151 EFI_DEVICE_PATH_PROTOCOL
*
2152 DevPathFromTextUsbAudio (
2153 IN CHAR16
*TextDeviceNode
2156 USB_CLASS_TEXT UsbClassText
;
2158 UsbClassText
.ClassExist
= FALSE
;
2159 UsbClassText
.Class
= USB_CLASS_AUDIO
;
2160 UsbClassText
.SubClassExist
= TRUE
;
2162 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2166 Converts a text device path node to USB CDC Control device path structure.
2168 @param TextDeviceNode The input Text device path node.
2170 @return A pointer to the newly-created USB CDC Control device path structure.
2173 EFI_DEVICE_PATH_PROTOCOL
*
2174 DevPathFromTextUsbCDCControl (
2175 IN CHAR16
*TextDeviceNode
2178 USB_CLASS_TEXT UsbClassText
;
2180 UsbClassText
.ClassExist
= FALSE
;
2181 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
2182 UsbClassText
.SubClassExist
= TRUE
;
2184 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2188 Converts a text device path node to USB HID device path structure.
2190 @param TextDeviceNode The input Text device path node.
2192 @return A pointer to the newly-created USB HID device path structure.
2195 EFI_DEVICE_PATH_PROTOCOL
*
2196 DevPathFromTextUsbHID (
2197 IN CHAR16
*TextDeviceNode
2200 USB_CLASS_TEXT UsbClassText
;
2202 UsbClassText
.ClassExist
= FALSE
;
2203 UsbClassText
.Class
= USB_CLASS_HID
;
2204 UsbClassText
.SubClassExist
= TRUE
;
2206 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2210 Converts a text device path node to USB Image device path structure.
2212 @param TextDeviceNode The input Text device path node.
2214 @return A pointer to the newly-created USB Image device path structure.
2217 EFI_DEVICE_PATH_PROTOCOL
*
2218 DevPathFromTextUsbImage (
2219 IN CHAR16
*TextDeviceNode
2222 USB_CLASS_TEXT UsbClassText
;
2224 UsbClassText
.ClassExist
= FALSE
;
2225 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2226 UsbClassText
.SubClassExist
= TRUE
;
2228 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2232 Converts a text device path node to USB Print device path structure.
2234 @param TextDeviceNode The input Text device path node.
2236 @return A pointer to the newly-created USB Print device path structure.
2239 EFI_DEVICE_PATH_PROTOCOL
*
2240 DevPathFromTextUsbPrinter (
2241 IN CHAR16
*TextDeviceNode
2244 USB_CLASS_TEXT UsbClassText
;
2246 UsbClassText
.ClassExist
= FALSE
;
2247 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2248 UsbClassText
.SubClassExist
= TRUE
;
2250 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2254 Converts a text device path node to USB mass storage device path structure.
2256 @param TextDeviceNode The input Text device path node.
2258 @return A pointer to the newly-created USB mass storage device path structure.
2261 EFI_DEVICE_PATH_PROTOCOL
*
2262 DevPathFromTextUsbMassStorage (
2263 IN CHAR16
*TextDeviceNode
2266 USB_CLASS_TEXT UsbClassText
;
2268 UsbClassText
.ClassExist
= FALSE
;
2269 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2270 UsbClassText
.SubClassExist
= TRUE
;
2272 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2276 Converts a text device path node to USB HUB device path structure.
2278 @param TextDeviceNode The input Text device path node.
2280 @return A pointer to the newly-created USB HUB device path structure.
2283 EFI_DEVICE_PATH_PROTOCOL
*
2284 DevPathFromTextUsbHub (
2285 IN CHAR16
*TextDeviceNode
2288 USB_CLASS_TEXT UsbClassText
;
2290 UsbClassText
.ClassExist
= FALSE
;
2291 UsbClassText
.Class
= USB_CLASS_HUB
;
2292 UsbClassText
.SubClassExist
= TRUE
;
2294 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2298 Converts a text device path node to USB CDC data device path structure.
2300 @param TextDeviceNode The input Text device path node.
2302 @return A pointer to the newly-created USB CDC data device path structure.
2305 EFI_DEVICE_PATH_PROTOCOL
*
2306 DevPathFromTextUsbCDCData (
2307 IN CHAR16
*TextDeviceNode
2310 USB_CLASS_TEXT UsbClassText
;
2312 UsbClassText
.ClassExist
= FALSE
;
2313 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2314 UsbClassText
.SubClassExist
= TRUE
;
2316 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2320 Converts a text device path node to USB smart card device path structure.
2322 @param TextDeviceNode The input Text device path node.
2324 @return A pointer to the newly-created USB smart card device path structure.
2327 EFI_DEVICE_PATH_PROTOCOL
*
2328 DevPathFromTextUsbSmartCard (
2329 IN CHAR16
*TextDeviceNode
2332 USB_CLASS_TEXT UsbClassText
;
2334 UsbClassText
.ClassExist
= FALSE
;
2335 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2336 UsbClassText
.SubClassExist
= TRUE
;
2338 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2342 Converts a text device path node to USB video device path structure.
2344 @param TextDeviceNode The input Text device path node.
2346 @return A pointer to the newly-created USB video device path structure.
2349 EFI_DEVICE_PATH_PROTOCOL
*
2350 DevPathFromTextUsbVideo (
2351 IN CHAR16
*TextDeviceNode
2354 USB_CLASS_TEXT UsbClassText
;
2356 UsbClassText
.ClassExist
= FALSE
;
2357 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2358 UsbClassText
.SubClassExist
= TRUE
;
2360 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2364 Converts a text device path node to USB diagnostic device path structure.
2366 @param TextDeviceNode The input Text device path node.
2368 @return A pointer to the newly-created USB diagnostic device path structure.
2371 EFI_DEVICE_PATH_PROTOCOL
*
2372 DevPathFromTextUsbDiagnostic (
2373 IN CHAR16
*TextDeviceNode
2376 USB_CLASS_TEXT UsbClassText
;
2378 UsbClassText
.ClassExist
= FALSE
;
2379 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2380 UsbClassText
.SubClassExist
= TRUE
;
2382 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2386 Converts a text device path node to USB wireless device path structure.
2388 @param TextDeviceNode The input Text device path node.
2390 @return A pointer to the newly-created USB wireless device path structure.
2393 EFI_DEVICE_PATH_PROTOCOL
*
2394 DevPathFromTextUsbWireless (
2395 IN CHAR16
*TextDeviceNode
2398 USB_CLASS_TEXT UsbClassText
;
2400 UsbClassText
.ClassExist
= FALSE
;
2401 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2402 UsbClassText
.SubClassExist
= TRUE
;
2404 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2408 Converts a text device path node to USB device firmware update device path structure.
2410 @param TextDeviceNode The input Text device path node.
2412 @return A pointer to the newly-created USB device firmware update device path structure.
2415 EFI_DEVICE_PATH_PROTOCOL
*
2416 DevPathFromTextUsbDeviceFirmwareUpdate (
2417 IN CHAR16
*TextDeviceNode
2420 USB_CLASS_TEXT UsbClassText
;
2422 UsbClassText
.ClassExist
= FALSE
;
2423 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2424 UsbClassText
.SubClassExist
= FALSE
;
2425 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2427 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2431 Converts a text device path node to USB IRDA bridge device path structure.
2433 @param TextDeviceNode The input Text device path node.
2435 @return A pointer to the newly-created USB IRDA bridge device path structure.
2438 EFI_DEVICE_PATH_PROTOCOL
*
2439 DevPathFromTextUsbIrdaBridge (
2440 IN CHAR16
*TextDeviceNode
2443 USB_CLASS_TEXT UsbClassText
;
2445 UsbClassText
.ClassExist
= FALSE
;
2446 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2447 UsbClassText
.SubClassExist
= FALSE
;
2448 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2450 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2454 Converts a text device path node to USB text and measurement device path structure.
2456 @param TextDeviceNode The input Text device path node.
2458 @return A pointer to the newly-created USB text and measurement device path structure.
2461 EFI_DEVICE_PATH_PROTOCOL
*
2462 DevPathFromTextUsbTestAndMeasurement (
2463 IN CHAR16
*TextDeviceNode
2466 USB_CLASS_TEXT UsbClassText
;
2468 UsbClassText
.ClassExist
= FALSE
;
2469 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2470 UsbClassText
.SubClassExist
= FALSE
;
2471 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2473 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2477 Converts a text device path node to USB WWID device path structure.
2479 @param TextDeviceNode The input Text device path node.
2481 @return A pointer to the newly-created USB WWID device path structure.
2484 EFI_DEVICE_PATH_PROTOCOL
*
2485 DevPathFromTextUsbWwid (
2486 IN CHAR16
*TextDeviceNode
2491 CHAR16
*InterfaceNumStr
;
2492 CHAR16
*SerialNumberStr
;
2493 USB_WWID_DEVICE_PATH
*UsbWwid
;
2494 UINTN SerialNumberStrLen
;
2496 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2497 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2498 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2499 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2500 SerialNumberStrLen
= StrLen (SerialNumberStr
);
2501 if ((SerialNumberStrLen
>= 2) &&
2502 (SerialNumberStr
[0] == L
'\"') &&
2503 (SerialNumberStr
[SerialNumberStrLen
- 1] == L
'\"')
2506 SerialNumberStr
[SerialNumberStrLen
- 1] = L
'\0';
2508 SerialNumberStrLen
-= 2;
2511 UsbWwid
= (USB_WWID_DEVICE_PATH
*)CreateDeviceNode (
2512 MESSAGING_DEVICE_PATH
,
2514 (UINT16
)(sizeof (USB_WWID_DEVICE_PATH
) + SerialNumberStrLen
* sizeof (CHAR16
))
2516 UsbWwid
->VendorId
= (UINT16
)Strtoi (VIDStr
);
2517 UsbWwid
->ProductId
= (UINT16
)Strtoi (PIDStr
);
2518 UsbWwid
->InterfaceNumber
= (UINT16
)Strtoi (InterfaceNumStr
);
2521 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
2522 // Therefore, the '\0' will not be copied.
2525 (UINT8
*)UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
),
2527 SerialNumberStrLen
* sizeof (CHAR16
)
2530 return (EFI_DEVICE_PATH_PROTOCOL
*)UsbWwid
;
2534 Converts a text device path node to Logic Unit device path structure.
2536 @param TextDeviceNode The input Text device path node.
2538 @return A pointer to the newly-created Logic Unit device path structure.
2541 EFI_DEVICE_PATH_PROTOCOL
*
2542 DevPathFromTextUnit (
2543 IN CHAR16
*TextDeviceNode
2547 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2549 LunStr
= GetNextParamStr (&TextDeviceNode
);
2550 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*)CreateDeviceNode (
2551 MESSAGING_DEVICE_PATH
,
2552 MSG_DEVICE_LOGICAL_UNIT_DP
,
2553 (UINT16
)sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2556 LogicalUnit
->Lun
= (UINT8
)Strtoi (LunStr
);
2558 return (EFI_DEVICE_PATH_PROTOCOL
*)LogicalUnit
;
2562 Converts a text device path node to iSCSI device path structure.
2564 @param TextDeviceNode The input Text device path node.
2566 @return A pointer to the newly-created iSCSI device path structure.
2569 EFI_DEVICE_PATH_PROTOCOL
*
2570 DevPathFromTextiSCSI (
2571 IN CHAR16
*TextDeviceNode
2576 CHAR16
*PortalGroupStr
;
2578 CHAR16
*HeaderDigestStr
;
2579 CHAR16
*DataDigestStr
;
2580 CHAR16
*AuthenticationStr
;
2581 CHAR16
*ProtocolStr
;
2583 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2586 NameStr
= GetNextParamStr (&TextDeviceNode
);
2587 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2588 LunStr
= GetNextParamStr (&TextDeviceNode
);
2589 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2590 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2591 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2592 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2593 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*)CreateDeviceNode (
2594 MESSAGING_DEVICE_PATH
,
2596 (UINT16
)(sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2599 AsciiStr
= ISCSIDevPath
->TargetName
;
2600 StrToAscii (NameStr
, &AsciiStr
);
2602 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
)Strtoi (PortalGroupStr
);
2603 Strtoi64 (LunStr
, &Lun
);
2604 WriteUnaligned64 ((UINT64
*)&ISCSIDevPath
->Lun
, SwapBytes64 (Lun
));
2607 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2611 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2615 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2619 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2623 ISCSIDevPath
->LoginOption
= (UINT16
)Options
;
2625 if (IS_NULL (*ProtocolStr
) || (StrCmp (ProtocolStr
, L
"TCP") == 0)) {
2626 ISCSIDevPath
->NetworkProtocol
= 0;
2629 // Undefined and reserved.
2631 ISCSIDevPath
->NetworkProtocol
= 1;
2634 return (EFI_DEVICE_PATH_PROTOCOL
*)ISCSIDevPath
;
2638 Converts a text device path node to VLAN device path structure.
2640 @param TextDeviceNode The input Text device path node.
2642 @return A pointer to the newly-created VLAN device path structure.
2645 EFI_DEVICE_PATH_PROTOCOL
*
2646 DevPathFromTextVlan (
2647 IN CHAR16
*TextDeviceNode
2651 VLAN_DEVICE_PATH
*Vlan
;
2653 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2654 Vlan
= (VLAN_DEVICE_PATH
*)CreateDeviceNode (
2655 MESSAGING_DEVICE_PATH
,
2657 (UINT16
)sizeof (VLAN_DEVICE_PATH
)
2660 Vlan
->VlanId
= (UINT16
)Strtoi (VlanStr
);
2662 return (EFI_DEVICE_PATH_PROTOCOL
*)Vlan
;
2666 Converts a text device path node to Bluetooth device path structure.
2668 @param TextDeviceNode The input Text device path node.
2670 @return A pointer to the newly-created Bluetooth device path structure.
2673 EFI_DEVICE_PATH_PROTOCOL
*
2674 DevPathFromTextBluetooth (
2675 IN CHAR16
*TextDeviceNode
2678 CHAR16
*BluetoothStr
;
2679 BLUETOOTH_DEVICE_PATH
*BluetoothDp
;
2681 BluetoothStr
= GetNextParamStr (&TextDeviceNode
);
2682 BluetoothDp
= (BLUETOOTH_DEVICE_PATH
*)CreateDeviceNode (
2683 MESSAGING_DEVICE_PATH
,
2685 (UINT16
)sizeof (BLUETOOTH_DEVICE_PATH
)
2689 sizeof (BLUETOOTH_ADDRESS
) * 2,
2690 BluetoothDp
->BD_ADDR
.Address
,
2691 sizeof (BLUETOOTH_ADDRESS
)
2693 return (EFI_DEVICE_PATH_PROTOCOL
*)BluetoothDp
;
2697 Converts a text device path node to Wi-Fi device path structure.
2699 @param TextDeviceNode The input Text device path node.
2701 @return A pointer to the newly-created Wi-Fi device path structure.
2704 EFI_DEVICE_PATH_PROTOCOL
*
2705 DevPathFromTextWiFi (
2706 IN CHAR16
*TextDeviceNode
2712 WIFI_DEVICE_PATH
*WiFiDp
;
2714 SSIdStr
= GetNextParamStr (&TextDeviceNode
);
2715 WiFiDp
= (WIFI_DEVICE_PATH
*)CreateDeviceNode (
2716 MESSAGING_DEVICE_PATH
,
2718 (UINT16
)sizeof (WIFI_DEVICE_PATH
)
2721 if (NULL
!= SSIdStr
) {
2722 DataLen
= StrLen (SSIdStr
);
2723 if (StrLen (SSIdStr
) > 32) {
2724 SSIdStr
[32] = L
'\0';
2728 UnicodeStrToAsciiStrS (SSIdStr
, AsciiStr
, sizeof (AsciiStr
));
2729 CopyMem (WiFiDp
->SSId
, AsciiStr
, DataLen
);
2732 return (EFI_DEVICE_PATH_PROTOCOL
*)WiFiDp
;
2736 Converts a text device path node to Bluetooth LE device path structure.
2738 @param TextDeviceNode The input Text device path node.
2740 @return A pointer to the newly-created Bluetooth LE device path structure.
2743 EFI_DEVICE_PATH_PROTOCOL
*
2744 DevPathFromTextBluetoothLE (
2745 IN CHAR16
*TextDeviceNode
2748 CHAR16
*BluetoothLeAddrStr
;
2749 CHAR16
*BluetoothLeAddrTypeStr
;
2750 BLUETOOTH_LE_DEVICE_PATH
*BluetoothLeDp
;
2752 BluetoothLeAddrStr
= GetNextParamStr (&TextDeviceNode
);
2753 BluetoothLeAddrTypeStr
= GetNextParamStr (&TextDeviceNode
);
2754 BluetoothLeDp
= (BLUETOOTH_LE_DEVICE_PATH
*)CreateDeviceNode (
2755 MESSAGING_DEVICE_PATH
,
2756 MSG_BLUETOOTH_LE_DP
,
2757 (UINT16
)sizeof (BLUETOOTH_LE_DEVICE_PATH
)
2760 BluetoothLeDp
->Address
.Type
= (UINT8
)Strtoi (BluetoothLeAddrTypeStr
);
2763 sizeof (BluetoothLeDp
->Address
.Address
) * 2,
2764 BluetoothLeDp
->Address
.Address
,
2765 sizeof (BluetoothLeDp
->Address
.Address
)
2767 return (EFI_DEVICE_PATH_PROTOCOL
*)BluetoothLeDp
;
2771 Converts a text device path node to DNS device path structure.
2773 @param TextDeviceNode The input Text device path node.
2775 @return A pointer to the newly-created DNS device path structure.
2778 EFI_DEVICE_PATH_PROTOCOL
*
2779 DevPathFromTextDns (
2780 IN CHAR16
*TextDeviceNode
2783 CHAR16
*DeviceNodeStr
;
2784 CHAR16
*DeviceNodeStrPtr
;
2785 UINT32 DnsServerIpCount
;
2786 UINT16 DnsDeviceNodeLength
;
2787 DNS_DEVICE_PATH
*DnsDeviceNode
;
2788 UINT32 DnsServerIpIndex
;
2789 CHAR16
*DnsServerIp
;
2792 // Count the DNS server address number.
2794 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
2795 if (DeviceNodeStr
== NULL
) {
2799 DeviceNodeStrPtr
= DeviceNodeStr
;
2801 DnsServerIpCount
= 0;
2802 while (DeviceNodeStrPtr
!= NULL
&& *DeviceNodeStrPtr
!= L
'\0') {
2803 GetNextParamStr (&DeviceNodeStrPtr
);
2807 FreePool (DeviceNodeStr
);
2808 DeviceNodeStr
= NULL
;
2811 // One or more instances of the DNS server address in EFI_IP_ADDRESS,
2812 // otherwise, NULL will be returned.
2814 if (DnsServerIpCount
== 0) {
2819 // Create the DNS DeviceNode.
2821 DnsDeviceNodeLength
= (UINT16
)(sizeof (EFI_DEVICE_PATH_PROTOCOL
) + sizeof (UINT8
) + DnsServerIpCount
* sizeof (EFI_IP_ADDRESS
));
2822 DnsDeviceNode
= (DNS_DEVICE_PATH
*)CreateDeviceNode (
2823 MESSAGING_DEVICE_PATH
,
2827 if (DnsDeviceNode
== NULL
) {
2832 // Confirm the DNS server address is IPv4 or IPv6 type.
2834 DeviceNodeStrPtr
= TextDeviceNode
;
2835 while (!IS_NULL (*DeviceNodeStrPtr
)) {
2836 if (*DeviceNodeStrPtr
== L
'.') {
2837 DnsDeviceNode
->IsIPv6
= 0x00;
2841 if (*DeviceNodeStrPtr
== L
':') {
2842 DnsDeviceNode
->IsIPv6
= 0x01;
2849 for (DnsServerIpIndex
= 0; DnsServerIpIndex
< DnsServerIpCount
; DnsServerIpIndex
++) {
2850 DnsServerIp
= GetNextParamStr (&TextDeviceNode
);
2851 if (DnsDeviceNode
->IsIPv6
== 0x00) {
2852 StrToIpv4Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v4
), NULL
);
2854 StrToIpv6Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v6
), NULL
);
2858 return (EFI_DEVICE_PATH_PROTOCOL
*)DnsDeviceNode
;
2862 Converts a text device path node to URI device path structure.
2864 @param TextDeviceNode The input Text device path node.
2866 @return A pointer to the newly-created URI device path structure.
2869 EFI_DEVICE_PATH_PROTOCOL
*
2870 DevPathFromTextUri (
2871 IN CHAR16
*TextDeviceNode
2876 URI_DEVICE_PATH
*Uri
;
2878 UriStr
= GetNextParamStr (&TextDeviceNode
);
2879 UriLength
= StrnLenS (UriStr
, MAX_UINT16
- sizeof (URI_DEVICE_PATH
));
2880 Uri
= (URI_DEVICE_PATH
*)CreateDeviceNode (
2881 MESSAGING_DEVICE_PATH
,
2883 (UINT16
)(sizeof (URI_DEVICE_PATH
) + UriLength
)
2886 while (UriLength
-- != 0) {
2887 Uri
->Uri
[UriLength
] = (CHAR8
)UriStr
[UriLength
];
2890 return (EFI_DEVICE_PATH_PROTOCOL
*)Uri
;
2894 Converts a media text device path node to media device path structure.
2896 @param TextDeviceNode The input Text device path node.
2898 @return A pointer to media device path structure.
2901 EFI_DEVICE_PATH_PROTOCOL
*
2902 DevPathFromTextMediaPath (
2903 IN CHAR16
*TextDeviceNode
2906 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH
, TextDeviceNode
);
2910 Converts a text device path node to HD device path structure.
2912 @param TextDeviceNode The input Text device path node.
2914 @return A pointer to the newly-created HD device path structure.
2917 EFI_DEVICE_PATH_PROTOCOL
*
2919 IN CHAR16
*TextDeviceNode
2922 CHAR16
*PartitionStr
;
2924 CHAR16
*SignatureStr
;
2928 HARDDRIVE_DEVICE_PATH
*Hd
;
2930 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2931 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2932 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2933 StartStr
= GetNextParamStr (&TextDeviceNode
);
2934 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2935 Hd
= (HARDDRIVE_DEVICE_PATH
*)CreateDeviceNode (
2938 (UINT16
)sizeof (HARDDRIVE_DEVICE_PATH
)
2941 Hd
->PartitionNumber
= (UINT32
)Strtoi (PartitionStr
);
2943 ZeroMem (Hd
->Signature
, 16);
2944 Hd
->MBRType
= (UINT8
)0;
2946 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2947 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2950 Signature32
= (UINT32
)Strtoi (SignatureStr
);
2951 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2952 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2953 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2956 StrToGuid (SignatureStr
, (EFI_GUID
*)Hd
->Signature
);
2958 Hd
->SignatureType
= (UINT8
)Strtoi (TypeStr
);
2961 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2962 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2964 return (EFI_DEVICE_PATH_PROTOCOL
*)Hd
;
2968 Converts a text device path node to CDROM device path structure.
2970 @param TextDeviceNode The input Text device path node.
2972 @return A pointer to the newly-created CDROM device path structure.
2975 EFI_DEVICE_PATH_PROTOCOL
*
2976 DevPathFromTextCDROM (
2977 IN CHAR16
*TextDeviceNode
2983 CDROM_DEVICE_PATH
*CDROMDevPath
;
2985 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2986 StartStr
= GetNextParamStr (&TextDeviceNode
);
2987 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2988 CDROMDevPath
= (CDROM_DEVICE_PATH
*)CreateDeviceNode (
2991 (UINT16
)sizeof (CDROM_DEVICE_PATH
)
2994 CDROMDevPath
->BootEntry
= (UINT32
)Strtoi (EntryStr
);
2995 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2996 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2998 return (EFI_DEVICE_PATH_PROTOCOL
*)CDROMDevPath
;
3002 Converts a text device path node to Vendor-defined media device path structure.
3004 @param TextDeviceNode The input Text device path node.
3006 @return A pointer to the newly-created Vendor-defined media device path structure.
3009 EFI_DEVICE_PATH_PROTOCOL
*
3010 DevPathFromTextVenMedia (
3011 IN CHAR16
*TextDeviceNode
3014 return ConvertFromTextVendor (
3022 Converts a text device path node to File device path structure.
3024 @param TextDeviceNode The input Text device path node.
3026 @return A pointer to the newly-created File device path structure.
3029 EFI_DEVICE_PATH_PROTOCOL
*
3030 DevPathFromTextFilePath (
3031 IN CHAR16
*TextDeviceNode
3034 FILEPATH_DEVICE_PATH
*File
;
3036 File
= (FILEPATH_DEVICE_PATH
*)CreateDeviceNode (
3039 (UINT16
)(sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
3042 StrCpyS (File
->PathName
, StrLen (TextDeviceNode
) + 1, TextDeviceNode
);
3044 return (EFI_DEVICE_PATH_PROTOCOL
*)File
;
3048 Converts a text device path node to Media protocol device path structure.
3050 @param TextDeviceNode The input Text device path node.
3052 @return A pointer to the newly-created Media protocol device path structure.
3055 EFI_DEVICE_PATH_PROTOCOL
*
3056 DevPathFromTextMedia (
3057 IN CHAR16
*TextDeviceNode
3061 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
3063 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3064 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*)CreateDeviceNode (
3067 (UINT16
)sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
3070 StrToGuid (GuidStr
, &Media
->Protocol
);
3072 return (EFI_DEVICE_PATH_PROTOCOL
*)Media
;
3076 Converts a text device path node to firmware volume device path structure.
3078 @param TextDeviceNode The input Text device path node.
3080 @return A pointer to the newly-created firmware volume device path structure.
3083 EFI_DEVICE_PATH_PROTOCOL
*
3085 IN CHAR16
*TextDeviceNode
3089 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
3091 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3092 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*)CreateDeviceNode (
3094 MEDIA_PIWG_FW_VOL_DP
,
3095 (UINT16
)sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
3098 StrToGuid (GuidStr
, &Fv
->FvName
);
3100 return (EFI_DEVICE_PATH_PROTOCOL
*)Fv
;
3104 Converts a text device path node to firmware file device path structure.
3106 @param TextDeviceNode The input Text device path node.
3108 @return A pointer to the newly-created firmware file device path structure.
3111 EFI_DEVICE_PATH_PROTOCOL
*
3112 DevPathFromTextFvFile (
3113 IN CHAR16
*TextDeviceNode
3117 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
3119 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3120 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*)CreateDeviceNode (
3122 MEDIA_PIWG_FW_FILE_DP
,
3123 (UINT16
)sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
3126 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
3128 return (EFI_DEVICE_PATH_PROTOCOL
*)FvFile
;
3132 Converts a text device path node to text relative offset device path structure.
3134 @param TextDeviceNode The input Text device path node.
3136 @return A pointer to the newly-created Text device path structure.
3139 EFI_DEVICE_PATH_PROTOCOL
*
3140 DevPathFromTextRelativeOffsetRange (
3141 IN CHAR16
*TextDeviceNode
3144 CHAR16
*StartingOffsetStr
;
3145 CHAR16
*EndingOffsetStr
;
3146 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
3148 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
3149 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
3150 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*)CreateDeviceNode (
3152 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
3153 (UINT16
)sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
3156 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
3157 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
3159 return (EFI_DEVICE_PATH_PROTOCOL
*)Offset
;
3163 Converts a text device path node to text ram disk device path structure.
3165 @param TextDeviceNode The input Text device path node.
3167 @return A pointer to the newly-created Text device path structure.
3170 EFI_DEVICE_PATH_PROTOCOL
*
3171 DevPathFromTextRamDisk (
3172 IN CHAR16
*TextDeviceNode
3175 CHAR16
*StartingAddrStr
;
3176 CHAR16
*EndingAddrStr
;
3177 CHAR16
*TypeGuidStr
;
3178 CHAR16
*InstanceStr
;
3179 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3180 UINT64 StartingAddr
;
3183 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3184 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3185 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3186 TypeGuidStr
= GetNextParamStr (&TextDeviceNode
);
3187 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*)CreateDeviceNode (
3190 (UINT16
)sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3193 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3194 WriteUnaligned64 ((UINT64
*)&(RamDisk
->StartingAddr
[0]), StartingAddr
);
3195 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3196 WriteUnaligned64 ((UINT64
*)&(RamDisk
->EndingAddr
[0]), EndingAddr
);
3197 RamDisk
->Instance
= (UINT16
)Strtoi (InstanceStr
);
3198 StrToGuid (TypeGuidStr
, &RamDisk
->TypeGuid
);
3200 return (EFI_DEVICE_PATH_PROTOCOL
*)RamDisk
;
3204 Converts a text device path node to text virtual disk device path structure.
3206 @param TextDeviceNode The input Text device path node.
3208 @return A pointer to the newly-created Text device path structure.
3211 EFI_DEVICE_PATH_PROTOCOL
*
3212 DevPathFromTextVirtualDisk (
3213 IN CHAR16
*TextDeviceNode
3216 CHAR16
*StartingAddrStr
;
3217 CHAR16
*EndingAddrStr
;
3218 CHAR16
*InstanceStr
;
3219 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3220 UINT64 StartingAddr
;
3223 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3224 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3225 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3227 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*)CreateDeviceNode (
3230 (UINT16
)sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3233 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3234 WriteUnaligned64 ((UINT64
*)&(RamDisk
->StartingAddr
[0]), StartingAddr
);
3235 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3236 WriteUnaligned64 ((UINT64
*)&(RamDisk
->EndingAddr
[0]), EndingAddr
);
3237 RamDisk
->Instance
= (UINT16
)Strtoi (InstanceStr
);
3238 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualDiskGuid
);
3240 return (EFI_DEVICE_PATH_PROTOCOL
*)RamDisk
;
3244 Converts a text device path node to text virtual cd device path structure.
3246 @param TextDeviceNode The input Text device path node.
3248 @return A pointer to the newly-created Text device path structure.
3251 EFI_DEVICE_PATH_PROTOCOL
*
3252 DevPathFromTextVirtualCd (
3253 IN CHAR16
*TextDeviceNode
3256 CHAR16
*StartingAddrStr
;
3257 CHAR16
*EndingAddrStr
;
3258 CHAR16
*InstanceStr
;
3259 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3260 UINT64 StartingAddr
;
3263 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3264 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3265 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3267 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*)CreateDeviceNode (
3270 (UINT16
)sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3273 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3274 WriteUnaligned64 ((UINT64
*)&(RamDisk
->StartingAddr
[0]), StartingAddr
);
3275 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3276 WriteUnaligned64 ((UINT64
*)&(RamDisk
->EndingAddr
[0]), EndingAddr
);
3277 RamDisk
->Instance
= (UINT16
)Strtoi (InstanceStr
);
3278 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualCdGuid
);
3280 return (EFI_DEVICE_PATH_PROTOCOL
*)RamDisk
;
3284 Converts a text device path node to text persistent virtual disk device path structure.
3286 @param TextDeviceNode The input Text device path node.
3288 @return A pointer to the newly-created Text device path structure.
3291 EFI_DEVICE_PATH_PROTOCOL
*
3292 DevPathFromTextPersistentVirtualDisk (
3293 IN CHAR16
*TextDeviceNode
3296 CHAR16
*StartingAddrStr
;
3297 CHAR16
*EndingAddrStr
;
3298 CHAR16
*InstanceStr
;
3299 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3300 UINT64 StartingAddr
;
3303 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3304 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3305 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3307 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*)CreateDeviceNode (
3310 (UINT16
)sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3313 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3314 WriteUnaligned64 ((UINT64
*)&(RamDisk
->StartingAddr
[0]), StartingAddr
);
3315 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3316 WriteUnaligned64 ((UINT64
*)&(RamDisk
->EndingAddr
[0]), EndingAddr
);
3317 RamDisk
->Instance
= (UINT16
)Strtoi (InstanceStr
);
3318 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualDiskGuid
);
3320 return (EFI_DEVICE_PATH_PROTOCOL
*)RamDisk
;
3324 Converts a text device path node to text persistent virtual cd device path structure.
3326 @param TextDeviceNode The input Text device path node.
3328 @return A pointer to the newly-created Text device path structure.
3331 EFI_DEVICE_PATH_PROTOCOL
*
3332 DevPathFromTextPersistentVirtualCd (
3333 IN CHAR16
*TextDeviceNode
3336 CHAR16
*StartingAddrStr
;
3337 CHAR16
*EndingAddrStr
;
3338 CHAR16
*InstanceStr
;
3339 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3340 UINT64 StartingAddr
;
3343 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3344 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3345 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3347 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*)CreateDeviceNode (
3350 (UINT16
)sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3353 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3354 WriteUnaligned64 ((UINT64
*)&(RamDisk
->StartingAddr
[0]), StartingAddr
);
3355 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3356 WriteUnaligned64 ((UINT64
*)&(RamDisk
->EndingAddr
[0]), EndingAddr
);
3357 RamDisk
->Instance
= (UINT16
)Strtoi (InstanceStr
);
3358 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualCdGuid
);
3360 return (EFI_DEVICE_PATH_PROTOCOL
*)RamDisk
;
3364 Converts a BBS text device path node to BBS device path structure.
3366 @param TextDeviceNode The input Text device path node.
3368 @return A pointer to BBS device path structure.
3371 EFI_DEVICE_PATH_PROTOCOL
*
3372 DevPathFromTextBbsPath (
3373 IN CHAR16
*TextDeviceNode
3376 return DevPathFromTextGenericPath (BBS_DEVICE_PATH
, TextDeviceNode
);
3380 Converts a text device path node to BIOS Boot Specification device path structure.
3382 @param TextDeviceNode The input Text device path node.
3384 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3387 EFI_DEVICE_PATH_PROTOCOL
*
3388 DevPathFromTextBBS (
3389 IN CHAR16
*TextDeviceNode
3396 BBS_BBS_DEVICE_PATH
*Bbs
;
3398 TypeStr
= GetNextParamStr (&TextDeviceNode
);
3399 IdStr
= GetNextParamStr (&TextDeviceNode
);
3400 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
3401 Bbs
= (BBS_BBS_DEVICE_PATH
*)CreateDeviceNode (
3404 (UINT16
)(sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
3407 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
3408 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
3409 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
3410 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
3411 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
3412 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
3413 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
3414 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
3415 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
3416 Bbs
->DeviceType
= BBS_TYPE_USB
;
3417 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
3418 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
3420 Bbs
->DeviceType
= (UINT16
)Strtoi (TypeStr
);
3423 AsciiStr
= Bbs
->String
;
3424 StrToAscii (IdStr
, &AsciiStr
);
3426 Bbs
->StatusFlag
= (UINT16
)Strtoi (FlagsStr
);
3428 return (EFI_DEVICE_PATH_PROTOCOL
*)Bbs
;
3432 Converts a text device path node to SATA device path structure.
3434 @param TextDeviceNode The input Text device path node.
3436 @return A pointer to the newly-created SATA device path structure.
3439 EFI_DEVICE_PATH_PROTOCOL
*
3440 DevPathFromTextSata (
3441 IN CHAR16
*TextDeviceNode
3444 SATA_DEVICE_PATH
*Sata
;
3449 Param1
= GetNextParamStr (&TextDeviceNode
);
3450 Param2
= GetNextParamStr (&TextDeviceNode
);
3451 Param3
= GetNextParamStr (&TextDeviceNode
);
3453 Sata
= (SATA_DEVICE_PATH
*)CreateDeviceNode (
3454 MESSAGING_DEVICE_PATH
,
3456 (UINT16
)sizeof (SATA_DEVICE_PATH
)
3458 Sata
->HBAPortNumber
= (UINT16
)Strtoi (Param1
);
3461 // According to UEFI spec, if PMPN is not provided, the default is 0xFFFF
3463 if (*Param2
== L
'\0' ) {
3464 Sata
->PortMultiplierPortNumber
= 0xFFFF;
3466 Sata
->PortMultiplierPortNumber
= (UINT16
)Strtoi (Param2
);
3469 Sata
->Lun
= (UINT16
)Strtoi (Param3
);
3471 return (EFI_DEVICE_PATH_PROTOCOL
*)Sata
;
3474 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
3475 { L
"Path", DevPathFromTextPath
},
3477 { L
"HardwarePath", DevPathFromTextHardwarePath
},
3478 { L
"Pci", DevPathFromTextPci
},
3479 { L
"PcCard", DevPathFromTextPcCard
},
3480 { L
"MemoryMapped", DevPathFromTextMemoryMapped
},
3481 { L
"VenHw", DevPathFromTextVenHw
},
3482 { L
"Ctrl", DevPathFromTextCtrl
},
3483 { L
"BMC", DevPathFromTextBmc
},
3485 { L
"AcpiPath", DevPathFromTextAcpiPath
},
3486 { L
"Acpi", DevPathFromTextAcpi
},
3487 { L
"PciRoot", DevPathFromTextPciRoot
},
3488 { L
"PcieRoot", DevPathFromTextPcieRoot
},
3489 { L
"Floppy", DevPathFromTextFloppy
},
3490 { L
"Keyboard", DevPathFromTextKeyboard
},
3491 { L
"Serial", DevPathFromTextSerial
},
3492 { L
"ParallelPort", DevPathFromTextParallelPort
},
3493 { L
"AcpiEx", DevPathFromTextAcpiEx
},
3494 { L
"AcpiExp", DevPathFromTextAcpiExp
},
3495 { L
"AcpiAdr", DevPathFromTextAcpiAdr
},
3497 { L
"Msg", DevPathFromTextMsg
},
3498 { L
"Ata", DevPathFromTextAta
},
3499 { L
"Scsi", DevPathFromTextScsi
},
3500 { L
"Fibre", DevPathFromTextFibre
},
3501 { L
"FibreEx", DevPathFromTextFibreEx
},
3502 { L
"I1394", DevPathFromText1394
},
3503 { L
"USB", DevPathFromTextUsb
},
3504 { L
"I2O", DevPathFromTextI2O
},
3505 { L
"Infiniband", DevPathFromTextInfiniband
},
3506 { L
"VenMsg", DevPathFromTextVenMsg
},
3507 { L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
3508 { L
"VenVt100", DevPathFromTextVenVt100
},
3509 { L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
3510 { L
"VenUtf8", DevPathFromTextVenUtf8
},
3511 { L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
3512 { L
"SAS", DevPathFromTextSAS
},
3513 { L
"SasEx", DevPathFromTextSasEx
},
3514 { L
"NVMe", DevPathFromTextNVMe
},
3515 { L
"UFS", DevPathFromTextUfs
},
3516 { L
"SD", DevPathFromTextSd
},
3517 { L
"eMMC", DevPathFromTextEmmc
},
3518 { L
"DebugPort", DevPathFromTextDebugPort
},
3519 { L
"MAC", DevPathFromTextMAC
},
3520 { L
"IPv4", DevPathFromTextIPv4
},
3521 { L
"IPv6", DevPathFromTextIPv6
},
3522 { L
"Uart", DevPathFromTextUart
},
3523 { L
"UsbClass", DevPathFromTextUsbClass
},
3524 { L
"UsbAudio", DevPathFromTextUsbAudio
},
3525 { L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
3526 { L
"UsbHID", DevPathFromTextUsbHID
},
3527 { L
"UsbImage", DevPathFromTextUsbImage
},
3528 { L
"UsbPrinter", DevPathFromTextUsbPrinter
},
3529 { L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
3530 { L
"UsbHub", DevPathFromTextUsbHub
},
3531 { L
"UsbCDCData", DevPathFromTextUsbCDCData
},
3532 { L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
3533 { L
"UsbVideo", DevPathFromTextUsbVideo
},
3534 { L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
3535 { L
"UsbWireless", DevPathFromTextUsbWireless
},
3536 { L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
3537 { L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
3538 { L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
3539 { L
"UsbWwid", DevPathFromTextUsbWwid
},
3540 { L
"Unit", DevPathFromTextUnit
},
3541 { L
"iSCSI", DevPathFromTextiSCSI
},
3542 { L
"Vlan", DevPathFromTextVlan
},
3543 { L
"Dns", DevPathFromTextDns
},
3544 { L
"Uri", DevPathFromTextUri
},
3545 { L
"Bluetooth", DevPathFromTextBluetooth
},
3546 { L
"Wi-Fi", DevPathFromTextWiFi
},
3547 { L
"BluetoothLE", DevPathFromTextBluetoothLE
},
3548 { L
"MediaPath", DevPathFromTextMediaPath
},
3549 { L
"HD", DevPathFromTextHD
},
3550 { L
"CDROM", DevPathFromTextCDROM
},
3551 { L
"VenMedia", DevPathFromTextVenMedia
},
3552 { L
"Media", DevPathFromTextMedia
},
3553 { L
"Fv", DevPathFromTextFv
},
3554 { L
"FvFile", DevPathFromTextFvFile
},
3555 { L
"Offset", DevPathFromTextRelativeOffsetRange
},
3556 { L
"RamDisk", DevPathFromTextRamDisk
},
3557 { L
"VirtualDisk", DevPathFromTextVirtualDisk
},
3558 { L
"VirtualCD", DevPathFromTextVirtualCd
},
3559 { L
"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk
},
3560 { L
"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd
},
3562 { L
"BbsPath", DevPathFromTextBbsPath
},
3563 { L
"BBS", DevPathFromTextBBS
},
3564 { L
"Sata", DevPathFromTextSata
},
3569 Convert text to the binary representation of a device node.
3571 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3572 node. Conversion starts with the first character and continues
3573 until the first non-device node character.
3575 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3576 insufficient memory or text unsupported.
3579 EFI_DEVICE_PATH_PROTOCOL
*
3581 UefiDevicePathLibConvertTextToDeviceNode (
3582 IN CONST CHAR16
*TextDeviceNode
3585 DEVICE_PATH_FROM_TEXT FromText
;
3587 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3588 CHAR16
*DeviceNodeStr
;
3591 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
3597 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
3598 ASSERT (DeviceNodeStr
!= NULL
);
3600 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3601 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
3602 if (ParamStr
!= NULL
) {
3603 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
3608 if (FromText
== NULL
) {
3612 FromText
= DevPathFromTextFilePath
;
3613 DeviceNode
= FromText (DeviceNodeStr
);
3615 DeviceNode
= FromText (ParamStr
);
3616 FreePool (ParamStr
);
3619 FreePool (DeviceNodeStr
);
3625 Convert text to the binary representation of a device path.
3628 @param TextDevicePath TextDevicePath points to the text representation of a device
3629 path. Conversion starts with the first character and continues
3630 until the first non-device node character.
3632 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3633 there was insufficient memory.
3636 EFI_DEVICE_PATH_PROTOCOL
*
3638 UefiDevicePathLibConvertTextToDevicePath (
3639 IN CONST CHAR16
*TextDevicePath
3642 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3643 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3644 CHAR16
*DevicePathStr
;
3646 CHAR16
*DeviceNodeStr
;
3647 BOOLEAN IsInstanceEnd
;
3648 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3650 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3654 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*)AllocatePool (END_DEVICE_PATH_LENGTH
);
3655 ASSERT (DevicePath
!= NULL
);
3656 SetDevicePathEndNode (DevicePath
);
3658 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3660 Str
= DevicePathStr
;
3661 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3662 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3664 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3665 FreePool (DevicePath
);
3666 FreePool (DeviceNode
);
3667 DevicePath
= NewDevicePath
;
3669 if (IsInstanceEnd
) {
3670 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*)AllocatePool (END_DEVICE_PATH_LENGTH
);
3671 ASSERT (DeviceNode
!= NULL
);
3672 SetDevicePathEndNode (DeviceNode
);
3673 DeviceNode
->SubType
= END_INSTANCE_DEVICE_PATH_SUBTYPE
;
3675 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3676 FreePool (DevicePath
);
3677 FreePool (DeviceNode
);
3678 DevicePath
= NewDevicePath
;
3682 FreePool (DevicePathStr
);