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
)) {
76 if (IS_NULL (*StrPointer
)) {
83 ParamStr
= AllocateCopyPool ((ParameterLength
+ 1) * sizeof (CHAR16
), ParamStr
);
84 if (ParamStr
== NULL
) {
88 // Terminate the parameter string
90 ParamStr
[ParameterLength
] = L
'\0';
96 Gets current sub-string from a string list, before return
97 the list header is moved to next sub-string. The sub-string is separated
98 by the specified character. For example, the separator is ',', the string
99 list is "2,0,3", it returns "2", the remain list move to "0,3"
101 @param List A string list separated by the specified separator
102 @param Separator The separator character
104 @return A pointer to the current sub-string
109 IN OUT CHAR16
**List
,
119 if (IS_NULL (*Str
)) {
124 // Find first occurrence of the separator
126 while (!IS_NULL (*Str
)) {
127 if (*Str
== Separator
) {
133 if (*Str
== Separator
) {
135 // Find a sub-string, terminate it
142 // Move to next sub-string
150 Gets the next parameter string from the list.
152 @param List A string list separated by the specified separator
154 @return A pointer to the current sub-string
163 // The separator is comma
165 return SplitStr (List
, L
',');
169 Get one device node from entire device path text.
171 @param DevicePath On input, the current Device Path node; on output, the next device path node
172 @param IsInstanceEnd This node is the end of a device path instance
174 @return A device node text or NULL if no more device node available
178 GetNextDeviceNodeStr (
179 IN OUT CHAR16
**DevicePath
,
180 OUT BOOLEAN
*IsInstanceEnd
185 UINTN ParenthesesStack
;
188 if (IS_NULL (*Str
)) {
193 // Skip the leading '/', '(', ')' and ','
195 while (!IS_NULL (*Str
)) {
196 if (!IS_SLASH (*Str
) &&
198 !IS_LEFT_PARENTH (*Str
) &&
199 !IS_RIGHT_PARENTH (*Str
)) {
208 // Scan for the separator of this device node, '/' or ','
210 ParenthesesStack
= 0;
211 while (!IS_NULL (*Str
)) {
212 if ((IS_COMMA (*Str
) || IS_SLASH (*Str
)) && (ParenthesesStack
== 0)) {
216 if (IS_LEFT_PARENTH (*Str
)) {
218 } else if (IS_RIGHT_PARENTH (*Str
)) {
225 if (ParenthesesStack
!= 0) {
227 // The '(' doesn't pair with ')', invalid device path text
232 if (IS_COMMA (*Str
)) {
233 *IsInstanceEnd
= TRUE
;
237 *IsInstanceEnd
= FALSE
;
238 if (!IS_NULL (*Str
)) {
251 Return whether the integer string is a hex string.
253 @param Str The integer string
255 @retval TRUE Hex string
256 @retval FALSE Decimal string
265 // skip preceeding white space
267 while ((*Str
!= 0) && *Str
== L
' ') {
271 // skip preceeding zeros
273 while ((*Str
!= 0) && *Str
== L
'0') {
277 return (BOOLEAN
) (*Str
== L
'x' || *Str
== L
'X');
282 Convert integer string to uint.
284 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
286 @return A UINTN value represented by Str
294 if (IsHexStr (Str
)) {
295 return StrHexToUintn (Str
);
297 return StrDecimalToUintn (Str
);
303 Convert integer string to 64 bit data.
305 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
306 @param Data A pointer to the UINT64 value represented by Str
315 if (IsHexStr (Str
)) {
316 *Data
= StrHexToUint64 (Str
);
318 *Data
= StrDecimalToUint64 (Str
);
323 Converts a Unicode string to ASCII string.
325 @param Str The equivalent Unicode string
326 @param AsciiStr On input, it points to destination ASCII string buffer; on output, it points
327 to the next ASCII string next to it
333 IN OUT CHAR8
**AsciiStr
339 while (!IS_NULL (*Str
)) {
340 *(Dest
++) = (CHAR8
) *(Str
++);
345 // Return the string next to it
347 *AsciiStr
= Dest
+ 1;
351 Converts a generic text device path node to device path structure.
353 @param Type The type of the device path node.
354 @param TextDeviceNode The input text device path node.
356 @return A pointer to device path structure.
358 EFI_DEVICE_PATH_PROTOCOL
*
359 DevPathFromTextGenericPath (
361 IN CHAR16
*TextDeviceNode
364 EFI_DEVICE_PATH_PROTOCOL
*Node
;
369 SubtypeStr
= GetNextParamStr (&TextDeviceNode
);
370 DataStr
= GetNextParamStr (&TextDeviceNode
);
372 if (DataStr
== NULL
) {
375 DataLength
= StrLen (DataStr
) / 2;
377 Node
= CreateDeviceNode (
379 (UINT8
) Strtoi (SubtypeStr
),
380 (UINT16
) (sizeof (EFI_DEVICE_PATH_PROTOCOL
) + DataLength
)
383 StrHexToBytes (DataStr
, DataLength
* 2, (UINT8
*) (Node
+ 1), DataLength
);
388 Converts a generic text device path node to device path structure.
390 @param TextDeviceNode The input Text device path node.
392 @return A pointer to device path structure.
395 EFI_DEVICE_PATH_PROTOCOL
*
396 DevPathFromTextPath (
397 IN CHAR16
*TextDeviceNode
402 TypeStr
= GetNextParamStr (&TextDeviceNode
);
404 return DevPathFromTextGenericPath ((UINT8
) Strtoi (TypeStr
), TextDeviceNode
);
408 Converts a generic hardware text device path node to Hardware device path structure.
410 @param TextDeviceNode The input Text device path node.
412 @return A pointer to Hardware device path structure.
415 EFI_DEVICE_PATH_PROTOCOL
*
416 DevPathFromTextHardwarePath (
417 IN CHAR16
*TextDeviceNode
420 return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH
, TextDeviceNode
);
424 Converts a text device path node to Hardware PCI device path structure.
426 @param TextDeviceNode The input Text device path node.
428 @return A pointer to Hardware PCI device path structure.
431 EFI_DEVICE_PATH_PROTOCOL
*
433 IN CHAR16
*TextDeviceNode
438 PCI_DEVICE_PATH
*Pci
;
440 DeviceStr
= GetNextParamStr (&TextDeviceNode
);
441 FunctionStr
= GetNextParamStr (&TextDeviceNode
);
442 Pci
= (PCI_DEVICE_PATH
*) CreateDeviceNode (
443 HARDWARE_DEVICE_PATH
,
445 (UINT16
) sizeof (PCI_DEVICE_PATH
)
448 Pci
->Function
= (UINT8
) Strtoi (FunctionStr
);
449 Pci
->Device
= (UINT8
) Strtoi (DeviceStr
);
451 return (EFI_DEVICE_PATH_PROTOCOL
*) Pci
;
455 Converts a text device path node to Hardware PC card device path structure.
457 @param TextDeviceNode The input Text device path node.
459 @return A pointer to Hardware PC card device path structure.
462 EFI_DEVICE_PATH_PROTOCOL
*
463 DevPathFromTextPcCard (
464 IN CHAR16
*TextDeviceNode
467 CHAR16
*FunctionNumberStr
;
468 PCCARD_DEVICE_PATH
*Pccard
;
470 FunctionNumberStr
= GetNextParamStr (&TextDeviceNode
);
471 Pccard
= (PCCARD_DEVICE_PATH
*) CreateDeviceNode (
472 HARDWARE_DEVICE_PATH
,
474 (UINT16
) sizeof (PCCARD_DEVICE_PATH
)
477 Pccard
->FunctionNumber
= (UINT8
) Strtoi (FunctionNumberStr
);
479 return (EFI_DEVICE_PATH_PROTOCOL
*) Pccard
;
483 Converts a text device path node to Hardware memory map device path structure.
485 @param TextDeviceNode The input Text device path node.
487 @return A pointer to Hardware memory map device path structure.
490 EFI_DEVICE_PATH_PROTOCOL
*
491 DevPathFromTextMemoryMapped (
492 IN CHAR16
*TextDeviceNode
495 CHAR16
*MemoryTypeStr
;
496 CHAR16
*StartingAddressStr
;
497 CHAR16
*EndingAddressStr
;
498 MEMMAP_DEVICE_PATH
*MemMap
;
500 MemoryTypeStr
= GetNextParamStr (&TextDeviceNode
);
501 StartingAddressStr
= GetNextParamStr (&TextDeviceNode
);
502 EndingAddressStr
= GetNextParamStr (&TextDeviceNode
);
503 MemMap
= (MEMMAP_DEVICE_PATH
*) CreateDeviceNode (
504 HARDWARE_DEVICE_PATH
,
506 (UINT16
) sizeof (MEMMAP_DEVICE_PATH
)
509 MemMap
->MemoryType
= (UINT32
) Strtoi (MemoryTypeStr
);
510 Strtoi64 (StartingAddressStr
, &MemMap
->StartingAddress
);
511 Strtoi64 (EndingAddressStr
, &MemMap
->EndingAddress
);
513 return (EFI_DEVICE_PATH_PROTOCOL
*) MemMap
;
517 Converts a text device path node to Vendor device path structure based on the input Type
520 @param TextDeviceNode The input Text device path node.
521 @param Type The type of device path node.
522 @param SubType The subtype of device path node.
524 @return A pointer to the newly-created Vendor device path structure.
527 EFI_DEVICE_PATH_PROTOCOL
*
528 ConvertFromTextVendor (
529 IN CHAR16
*TextDeviceNode
,
537 VENDOR_DEVICE_PATH
*Vendor
;
539 GuidStr
= GetNextParamStr (&TextDeviceNode
);
541 DataStr
= GetNextParamStr (&TextDeviceNode
);
542 Length
= StrLen (DataStr
);
544 // Two hex characters make up 1 buffer byte
546 Length
= (Length
+ 1) / 2;
548 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
551 (UINT16
) (sizeof (VENDOR_DEVICE_PATH
) + Length
)
554 StrToGuid (GuidStr
, &Vendor
->Guid
);
555 StrHexToBytes (DataStr
, Length
* 2, (UINT8
*) (Vendor
+ 1), Length
);
557 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
561 Converts a text device path node to Vendor Hardware device path structure.
563 @param TextDeviceNode The input Text device path node.
565 @return A pointer to the newly-created Vendor Hardware device path structure.
568 EFI_DEVICE_PATH_PROTOCOL
*
569 DevPathFromTextVenHw (
570 IN CHAR16
*TextDeviceNode
573 return ConvertFromTextVendor (
575 HARDWARE_DEVICE_PATH
,
581 Converts a text device path node to Hardware Controller device path structure.
583 @param TextDeviceNode The input Text device path node.
585 @return A pointer to the newly-created Hardware Controller device path structure.
588 EFI_DEVICE_PATH_PROTOCOL
*
589 DevPathFromTextCtrl (
590 IN CHAR16
*TextDeviceNode
593 CHAR16
*ControllerStr
;
594 CONTROLLER_DEVICE_PATH
*Controller
;
596 ControllerStr
= GetNextParamStr (&TextDeviceNode
);
597 Controller
= (CONTROLLER_DEVICE_PATH
*) CreateDeviceNode (
598 HARDWARE_DEVICE_PATH
,
600 (UINT16
) sizeof (CONTROLLER_DEVICE_PATH
)
602 Controller
->ControllerNumber
= (UINT32
) Strtoi (ControllerStr
);
604 return (EFI_DEVICE_PATH_PROTOCOL
*) Controller
;
608 Converts a text device path node to BMC device path structure.
610 @param TextDeviceNode The input Text device path node.
612 @return A pointer to the newly-created BMC device path structure.
615 EFI_DEVICE_PATH_PROTOCOL
*
617 IN CHAR16
*TextDeviceNode
620 CHAR16
*InterfaceTypeStr
;
621 CHAR16
*BaseAddressStr
;
622 BMC_DEVICE_PATH
*BmcDp
;
624 InterfaceTypeStr
= GetNextParamStr (&TextDeviceNode
);
625 BaseAddressStr
= GetNextParamStr (&TextDeviceNode
);
626 BmcDp
= (BMC_DEVICE_PATH
*) CreateDeviceNode (
627 HARDWARE_DEVICE_PATH
,
629 (UINT16
) sizeof (BMC_DEVICE_PATH
)
632 BmcDp
->InterfaceType
= (UINT8
) Strtoi (InterfaceTypeStr
);
634 (UINT64
*) (&BmcDp
->BaseAddress
),
635 StrHexToUint64 (BaseAddressStr
)
638 return (EFI_DEVICE_PATH_PROTOCOL
*) BmcDp
;
642 Converts a generic ACPI text device path node to ACPI device path structure.
644 @param TextDeviceNode The input Text device path node.
646 @return A pointer to ACPI device path structure.
649 EFI_DEVICE_PATH_PROTOCOL
*
650 DevPathFromTextAcpiPath (
651 IN CHAR16
*TextDeviceNode
654 return DevPathFromTextGenericPath (ACPI_DEVICE_PATH
, TextDeviceNode
);
658 Converts a string to EisaId.
660 @param Text The input string.
662 @return UINT32 EISA ID.
669 return (((Text
[0] - 'A' + 1) & 0x1f) << 10)
670 + (((Text
[1] - 'A' + 1) & 0x1f) << 5)
671 + (((Text
[2] - 'A' + 1) & 0x1f) << 0)
672 + (UINT32
) (StrHexToUintn (&Text
[3]) << 16)
677 Converts a text device path node to ACPI HID device path structure.
679 @param TextDeviceNode The input Text device path node.
681 @return A pointer to the newly-created ACPI HID device path structure.
684 EFI_DEVICE_PATH_PROTOCOL
*
685 DevPathFromTextAcpi (
686 IN CHAR16
*TextDeviceNode
691 ACPI_HID_DEVICE_PATH
*Acpi
;
693 HIDStr
= GetNextParamStr (&TextDeviceNode
);
694 UIDStr
= GetNextParamStr (&TextDeviceNode
);
695 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
698 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
701 Acpi
->HID
= EisaIdFromText (HIDStr
);
702 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
704 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
708 Converts a text device path node to ACPI HID device path structure.
710 @param TextDeviceNode The input Text device path node.
711 @param PnPId The input plug and play identification.
713 @return A pointer to the newly-created ACPI HID device path structure.
716 EFI_DEVICE_PATH_PROTOCOL
*
717 ConvertFromTextAcpi (
718 IN CHAR16
*TextDeviceNode
,
723 ACPI_HID_DEVICE_PATH
*Acpi
;
725 UIDStr
= GetNextParamStr (&TextDeviceNode
);
726 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
729 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
732 Acpi
->HID
= EFI_PNP_ID (PnPId
);
733 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
735 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
739 Converts a text device path node to PCI root device path structure.
741 @param TextDeviceNode The input Text device path node.
743 @return A pointer to the newly-created PCI root device path structure.
746 EFI_DEVICE_PATH_PROTOCOL
*
747 DevPathFromTextPciRoot (
748 IN CHAR16
*TextDeviceNode
751 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a03);
755 Converts a text device path node to PCIE root device path structure.
757 @param TextDeviceNode The input Text device path node.
759 @return A pointer to the newly-created PCIE root device path structure.
762 EFI_DEVICE_PATH_PROTOCOL
*
763 DevPathFromTextPcieRoot (
764 IN CHAR16
*TextDeviceNode
767 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a08);
771 Converts a text device path node to Floppy device path structure.
773 @param TextDeviceNode The input Text device path node.
775 @return A pointer to the newly-created Floppy device path structure.
778 EFI_DEVICE_PATH_PROTOCOL
*
779 DevPathFromTextFloppy (
780 IN CHAR16
*TextDeviceNode
783 return ConvertFromTextAcpi (TextDeviceNode
, 0x0604);
787 Converts a text device path node to Keyboard device path structure.
789 @param TextDeviceNode The input Text device path node.
791 @return A pointer to the newly-created Keyboard device path structure.
794 EFI_DEVICE_PATH_PROTOCOL
*
795 DevPathFromTextKeyboard (
796 IN CHAR16
*TextDeviceNode
799 return ConvertFromTextAcpi (TextDeviceNode
, 0x0301);
803 Converts a text device path node to Serial device path structure.
805 @param TextDeviceNode The input Text device path node.
807 @return A pointer to the newly-created Serial device path structure.
810 EFI_DEVICE_PATH_PROTOCOL
*
811 DevPathFromTextSerial (
812 IN CHAR16
*TextDeviceNode
815 return ConvertFromTextAcpi (TextDeviceNode
, 0x0501);
819 Converts a text device path node to Parallel Port device path structure.
821 @param TextDeviceNode The input Text device path node.
823 @return A pointer to the newly-created Parallel Port device path structure.
826 EFI_DEVICE_PATH_PROTOCOL
*
827 DevPathFromTextParallelPort (
828 IN CHAR16
*TextDeviceNode
831 return ConvertFromTextAcpi (TextDeviceNode
, 0x0401);
835 Converts a text device path node to ACPI extension device path structure.
837 @param TextDeviceNode The input Text device path node.
839 @return A pointer to the newly-created ACPI extension device path structure.
842 EFI_DEVICE_PATH_PROTOCOL
*
843 DevPathFromTextAcpiEx (
844 IN CHAR16
*TextDeviceNode
855 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
857 HIDStr
= GetNextParamStr (&TextDeviceNode
);
858 CIDStr
= GetNextParamStr (&TextDeviceNode
);
859 UIDStr
= GetNextParamStr (&TextDeviceNode
);
860 HIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
861 CIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
862 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
864 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (HIDSTRStr
) + 1);
865 Length
= (UINT16
) (Length
+ StrLen (UIDSTRStr
) + 1);
866 Length
= (UINT16
) (Length
+ StrLen (CIDSTRStr
) + 1);
867 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
873 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
874 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
875 AcpiEx
->UID
= (UINT32
) Strtoi (UIDStr
);
877 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
878 StrToAscii (HIDSTRStr
, &AsciiStr
);
879 StrToAscii (UIDSTRStr
, &AsciiStr
);
880 StrToAscii (CIDSTRStr
, &AsciiStr
);
882 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
886 Converts a text device path node to ACPI extension device path structure.
888 @param TextDeviceNode The input Text device path node.
890 @return A pointer to the newly-created ACPI extension device path structure.
893 EFI_DEVICE_PATH_PROTOCOL
*
894 DevPathFromTextAcpiExp (
895 IN CHAR16
*TextDeviceNode
903 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
905 HIDStr
= GetNextParamStr (&TextDeviceNode
);
906 CIDStr
= GetNextParamStr (&TextDeviceNode
);
907 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
908 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (UIDSTRStr
) + 3);
909 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
915 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
917 // According to UEFI spec, the CID parametr is optional and has a default value of 0.
918 // So when the CID parametr is not specified or specified as 0 in the text device node.
919 // Set the CID to 0 in the ACPI extension device path structure.
921 if (*CIDStr
== L
'\0' || *CIDStr
== L
'0') {
924 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
928 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
930 // HID string is NULL
934 // Convert UID string
937 StrToAscii (UIDSTRStr
, &AsciiStr
);
939 // CID string is NULL
943 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
947 Converts a text device path node to ACPI _ADR device path structure.
949 @param TextDeviceNode The input Text device path node.
951 @return A pointer to the newly-created ACPI _ADR device path structure.
954 EFI_DEVICE_PATH_PROTOCOL
*
955 DevPathFromTextAcpiAdr (
956 IN CHAR16
*TextDeviceNode
959 CHAR16
*DisplayDeviceStr
;
960 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
964 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*) CreateDeviceNode (
967 (UINT16
) sizeof (ACPI_ADR_DEVICE_PATH
)
969 ASSERT (AcpiAdr
!= NULL
);
971 for (Index
= 0; ; Index
++) {
972 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
973 if (IS_NULL (*DisplayDeviceStr
)) {
977 Length
= DevicePathNodeLength (AcpiAdr
);
978 AcpiAdr
= ReallocatePool (
980 Length
+ sizeof (UINT32
),
983 ASSERT (AcpiAdr
!= NULL
);
984 SetDevicePathNodeLength (AcpiAdr
, Length
+ sizeof (UINT32
));
987 (&AcpiAdr
->ADR
)[Index
] = (UINT32
) Strtoi (DisplayDeviceStr
);
990 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
;
994 Converts a generic messaging text device path node to messaging device path structure.
996 @param TextDeviceNode The input Text device path node.
998 @return A pointer to messaging device path structure.
1001 EFI_DEVICE_PATH_PROTOCOL
*
1002 DevPathFromTextMsg (
1003 IN CHAR16
*TextDeviceNode
1006 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH
, TextDeviceNode
);
1010 Converts a text device path node to Parallel Port device path structure.
1012 @param TextDeviceNode The input Text device path node.
1014 @return A pointer to the newly-created Parallel Port device path structure.
1017 EFI_DEVICE_PATH_PROTOCOL
*
1018 DevPathFromTextAta (
1019 IN CHAR16
*TextDeviceNode
1022 CHAR16
*PrimarySecondaryStr
;
1023 CHAR16
*SlaveMasterStr
;
1025 ATAPI_DEVICE_PATH
*Atapi
;
1027 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
1028 MESSAGING_DEVICE_PATH
,
1030 (UINT16
) sizeof (ATAPI_DEVICE_PATH
)
1033 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
1034 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
1035 LunStr
= GetNextParamStr (&TextDeviceNode
);
1037 if (StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) {
1038 Atapi
->PrimarySecondary
= 0;
1039 } else if (StrCmp (PrimarySecondaryStr
, L
"Secondary") == 0) {
1040 Atapi
->PrimarySecondary
= 1;
1042 Atapi
->PrimarySecondary
= (UINT8
) Strtoi (PrimarySecondaryStr
);
1044 if (StrCmp (SlaveMasterStr
, L
"Master") == 0) {
1045 Atapi
->SlaveMaster
= 0;
1046 } else if (StrCmp (SlaveMasterStr
, L
"Slave") == 0) {
1047 Atapi
->SlaveMaster
= 1;
1049 Atapi
->SlaveMaster
= (UINT8
) Strtoi (SlaveMasterStr
);
1052 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
1054 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
1058 Converts a text device path node to SCSI device path structure.
1060 @param TextDeviceNode The input Text device path node.
1062 @return A pointer to the newly-created SCSI device path structure.
1065 EFI_DEVICE_PATH_PROTOCOL
*
1066 DevPathFromTextScsi (
1067 IN CHAR16
*TextDeviceNode
1072 SCSI_DEVICE_PATH
*Scsi
;
1074 PunStr
= GetNextParamStr (&TextDeviceNode
);
1075 LunStr
= GetNextParamStr (&TextDeviceNode
);
1076 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
1077 MESSAGING_DEVICE_PATH
,
1079 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
1082 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
1083 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
1085 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
1089 Converts a text device path node to Fibre device path structure.
1091 @param TextDeviceNode The input Text device path node.
1093 @return A pointer to the newly-created Fibre device path structure.
1096 EFI_DEVICE_PATH_PROTOCOL
*
1097 DevPathFromTextFibre (
1098 IN CHAR16
*TextDeviceNode
1103 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
1105 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1106 LunStr
= GetNextParamStr (&TextDeviceNode
);
1107 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
1108 MESSAGING_DEVICE_PATH
,
1109 MSG_FIBRECHANNEL_DP
,
1110 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
1113 Fibre
->Reserved
= 0;
1114 Strtoi64 (WWNStr
, &Fibre
->WWN
);
1115 Strtoi64 (LunStr
, &Fibre
->Lun
);
1117 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
1121 Converts a text device path node to FibreEx device path structure.
1123 @param TextDeviceNode The input Text device path node.
1125 @return A pointer to the newly-created FibreEx device path structure.
1128 EFI_DEVICE_PATH_PROTOCOL
*
1129 DevPathFromTextFibreEx (
1130 IN CHAR16
*TextDeviceNode
1135 FIBRECHANNELEX_DEVICE_PATH
*FibreEx
;
1137 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1138 LunStr
= GetNextParamStr (&TextDeviceNode
);
1139 FibreEx
= (FIBRECHANNELEX_DEVICE_PATH
*) CreateDeviceNode (
1140 MESSAGING_DEVICE_PATH
,
1141 MSG_FIBRECHANNELEX_DP
,
1142 (UINT16
) sizeof (FIBRECHANNELEX_DEVICE_PATH
)
1145 FibreEx
->Reserved
= 0;
1146 Strtoi64 (WWNStr
, (UINT64
*) (&FibreEx
->WWN
));
1147 Strtoi64 (LunStr
, (UINT64
*) (&FibreEx
->Lun
));
1149 *(UINT64
*) (&FibreEx
->WWN
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->WWN
));
1150 *(UINT64
*) (&FibreEx
->Lun
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->Lun
));
1152 return (EFI_DEVICE_PATH_PROTOCOL
*) FibreEx
;
1156 Converts a text device path node to 1394 device path structure.
1158 @param TextDeviceNode The input Text device path node.
1160 @return A pointer to the newly-created 1394 device path structure.
1163 EFI_DEVICE_PATH_PROTOCOL
*
1164 DevPathFromText1394 (
1165 IN CHAR16
*TextDeviceNode
1169 F1394_DEVICE_PATH
*F1394DevPath
;
1171 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1172 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1173 MESSAGING_DEVICE_PATH
,
1175 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1178 F1394DevPath
->Reserved
= 0;
1179 F1394DevPath
->Guid
= StrHexToUint64 (GuidStr
);
1181 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1185 Converts a text device path node to USB device path structure.
1187 @param TextDeviceNode The input Text device path node.
1189 @return A pointer to the newly-created USB device path structure.
1192 EFI_DEVICE_PATH_PROTOCOL
*
1193 DevPathFromTextUsb (
1194 IN CHAR16
*TextDeviceNode
1198 CHAR16
*InterfaceStr
;
1199 USB_DEVICE_PATH
*Usb
;
1201 PortStr
= GetNextParamStr (&TextDeviceNode
);
1202 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1203 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1204 MESSAGING_DEVICE_PATH
,
1206 (UINT16
) sizeof (USB_DEVICE_PATH
)
1209 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1210 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1212 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1216 Converts a text device path node to I20 device path structure.
1218 @param TextDeviceNode The input Text device path node.
1220 @return A pointer to the newly-created I20 device path structure.
1223 EFI_DEVICE_PATH_PROTOCOL
*
1224 DevPathFromTextI2O (
1225 IN CHAR16
*TextDeviceNode
1229 I2O_DEVICE_PATH
*I2ODevPath
;
1231 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1232 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1233 MESSAGING_DEVICE_PATH
,
1235 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1238 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1240 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1244 Converts a text device path node to Infini Band device path structure.
1246 @param TextDeviceNode The input Text device path node.
1248 @return A pointer to the newly-created Infini Band device path structure.
1251 EFI_DEVICE_PATH_PROTOCOL
*
1252 DevPathFromTextInfiniband (
1253 IN CHAR16
*TextDeviceNode
1261 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1263 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1264 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1265 SidStr
= GetNextParamStr (&TextDeviceNode
);
1266 TidStr
= GetNextParamStr (&TextDeviceNode
);
1267 DidStr
= GetNextParamStr (&TextDeviceNode
);
1268 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1269 MESSAGING_DEVICE_PATH
,
1271 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1274 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1275 StrToGuid (GuidStr
, (EFI_GUID
*) InfiniBand
->PortGid
);
1276 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1277 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1278 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1280 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1284 Converts a text device path node to Vendor-Defined Messaging device path structure.
1286 @param TextDeviceNode The input Text device path node.
1288 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1291 EFI_DEVICE_PATH_PROTOCOL
*
1292 DevPathFromTextVenMsg (
1293 IN CHAR16
*TextDeviceNode
1296 return ConvertFromTextVendor (
1298 MESSAGING_DEVICE_PATH
,
1304 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1306 @param TextDeviceNode The input Text device path node.
1308 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1311 EFI_DEVICE_PATH_PROTOCOL
*
1312 DevPathFromTextVenPcAnsi (
1313 IN CHAR16
*TextDeviceNode
1316 VENDOR_DEVICE_PATH
*Vendor
;
1318 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1319 MESSAGING_DEVICE_PATH
,
1321 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1322 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1324 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1328 Converts a text device path node to Vendor defined VT100 device path structure.
1330 @param TextDeviceNode The input Text device path node.
1332 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1335 EFI_DEVICE_PATH_PROTOCOL
*
1336 DevPathFromTextVenVt100 (
1337 IN CHAR16
*TextDeviceNode
1340 VENDOR_DEVICE_PATH
*Vendor
;
1342 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1343 MESSAGING_DEVICE_PATH
,
1345 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1346 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1348 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1352 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1354 @param TextDeviceNode The input Text device path node.
1356 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1359 EFI_DEVICE_PATH_PROTOCOL
*
1360 DevPathFromTextVenVt100Plus (
1361 IN CHAR16
*TextDeviceNode
1364 VENDOR_DEVICE_PATH
*Vendor
;
1366 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1367 MESSAGING_DEVICE_PATH
,
1369 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1370 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1372 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1376 Converts a text device path node to Vendor defined UTF8 device path structure.
1378 @param TextDeviceNode The input Text device path node.
1380 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1383 EFI_DEVICE_PATH_PROTOCOL
*
1384 DevPathFromTextVenUtf8 (
1385 IN CHAR16
*TextDeviceNode
1388 VENDOR_DEVICE_PATH
*Vendor
;
1390 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1391 MESSAGING_DEVICE_PATH
,
1393 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1394 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1396 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1400 Converts a text device path node to UART Flow Control device path structure.
1402 @param TextDeviceNode The input Text device path node.
1404 @return A pointer to the newly-created UART Flow Control device path structure.
1407 EFI_DEVICE_PATH_PROTOCOL
*
1408 DevPathFromTextUartFlowCtrl (
1409 IN CHAR16
*TextDeviceNode
1413 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1415 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1416 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1417 MESSAGING_DEVICE_PATH
,
1419 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1422 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1423 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1424 UartFlowControl
->FlowControlMap
= 2;
1425 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1426 UartFlowControl
->FlowControlMap
= 1;
1428 UartFlowControl
->FlowControlMap
= 0;
1431 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1435 Converts a text device path node to Serial Attached SCSI device path structure.
1437 @param TextDeviceNode The input Text device path node.
1439 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1442 EFI_DEVICE_PATH_PROTOCOL
*
1443 DevPathFromTextSAS (
1444 IN CHAR16
*TextDeviceNode
1451 CHAR16
*LocationStr
;
1453 CHAR16
*DriveBayStr
;
1454 CHAR16
*ReservedStr
;
1457 SAS_DEVICE_PATH
*Sas
;
1459 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1460 LunStr
= GetNextParamStr (&TextDeviceNode
);
1461 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1462 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1463 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1464 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1465 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1466 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1467 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1468 MESSAGING_DEVICE_PATH
,
1470 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1473 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1474 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1475 Strtoi64 (LunStr
, &Sas
->Lun
);
1476 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1478 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1481 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1483 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1487 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1490 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1495 // Location is an integer between 0 and 1 or else
1496 // the keyword Internal (0) or External (1).
1498 if (StrCmp (LocationStr
, L
"External") == 0) {
1500 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1503 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1505 Info
|= (Uint16
<< 5);
1508 // Connect is an integer between 0 and 3 or else
1509 // the keyword Direct (0) or Expanded (1).
1511 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1513 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1516 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1518 Info
|= (Uint16
<< 6);
1521 Info
= (UINT16
) Strtoi (SASSATAStr
);
1524 Sas
->DeviceTopology
= Info
;
1525 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1527 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1531 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1533 @param TextDeviceNode The input Text device path node.
1535 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1538 EFI_DEVICE_PATH_PROTOCOL
*
1539 DevPathFromTextSasEx (
1540 IN CHAR16
*TextDeviceNode
1547 CHAR16
*LocationStr
;
1549 CHAR16
*DriveBayStr
;
1554 SASEX_DEVICE_PATH
*SasEx
;
1556 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1557 LunStr
= GetNextParamStr (&TextDeviceNode
);
1558 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1559 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1560 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1561 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1562 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1563 SasEx
= (SASEX_DEVICE_PATH
*) CreateDeviceNode (
1564 MESSAGING_DEVICE_PATH
,
1566 (UINT16
) sizeof (SASEX_DEVICE_PATH
)
1569 Strtoi64 (AddressStr
, &SasAddress
);
1570 Strtoi64 (LunStr
, &Lun
);
1571 WriteUnaligned64 ((UINT64
*) &SasEx
->SasAddress
, SwapBytes64 (SasAddress
));
1572 WriteUnaligned64 ((UINT64
*) &SasEx
->Lun
, SwapBytes64 (Lun
));
1573 SasEx
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1575 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1578 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1580 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1584 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1587 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1592 // Location is an integer between 0 and 1 or else
1593 // the keyword Internal (0) or External (1).
1595 if (StrCmp (LocationStr
, L
"External") == 0) {
1597 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1600 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1602 Info
|= (Uint16
<< 5);
1605 // Connect is an integer between 0 and 3 or else
1606 // the keyword Direct (0) or Expanded (1).
1608 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1610 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1613 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1615 Info
|= (Uint16
<< 6);
1618 Info
= (UINT16
) Strtoi (SASSATAStr
);
1621 SasEx
->DeviceTopology
= Info
;
1623 return (EFI_DEVICE_PATH_PROTOCOL
*) SasEx
;
1627 Converts a text device path node to NVM Express Namespace device path structure.
1629 @param TextDeviceNode The input Text device path node.
1631 @return A pointer to the newly-created NVM Express Namespace device path structure.
1634 EFI_DEVICE_PATH_PROTOCOL
*
1635 DevPathFromTextNVMe (
1636 IN CHAR16
*TextDeviceNode
1639 CHAR16
*NamespaceIdStr
;
1640 CHAR16
*NamespaceUuidStr
;
1641 NVME_NAMESPACE_DEVICE_PATH
*Nvme
;
1645 NamespaceIdStr
= GetNextParamStr (&TextDeviceNode
);
1646 NamespaceUuidStr
= GetNextParamStr (&TextDeviceNode
);
1647 Nvme
= (NVME_NAMESPACE_DEVICE_PATH
*) CreateDeviceNode (
1648 MESSAGING_DEVICE_PATH
,
1649 MSG_NVME_NAMESPACE_DP
,
1650 (UINT16
) sizeof (NVME_NAMESPACE_DEVICE_PATH
)
1653 Nvme
->NamespaceId
= (UINT32
) Strtoi (NamespaceIdStr
);
1654 Uuid
= (UINT8
*) &Nvme
->NamespaceUuid
;
1656 Index
= sizeof (Nvme
->NamespaceUuid
) / sizeof (UINT8
);
1657 while (Index
-- != 0) {
1658 Uuid
[Index
] = (UINT8
) StrHexToUintn (SplitStr (&NamespaceUuidStr
, L
'-'));
1661 return (EFI_DEVICE_PATH_PROTOCOL
*) Nvme
;
1665 Converts a text device path node to UFS device path structure.
1667 @param TextDeviceNode The input Text device path node.
1669 @return A pointer to the newly-created UFS device path structure.
1672 EFI_DEVICE_PATH_PROTOCOL
*
1673 DevPathFromTextUfs (
1674 IN CHAR16
*TextDeviceNode
1679 UFS_DEVICE_PATH
*Ufs
;
1681 PunStr
= GetNextParamStr (&TextDeviceNode
);
1682 LunStr
= GetNextParamStr (&TextDeviceNode
);
1683 Ufs
= (UFS_DEVICE_PATH
*) CreateDeviceNode (
1684 MESSAGING_DEVICE_PATH
,
1686 (UINT16
) sizeof (UFS_DEVICE_PATH
)
1689 Ufs
->Pun
= (UINT8
) Strtoi (PunStr
);
1690 Ufs
->Lun
= (UINT8
) Strtoi (LunStr
);
1692 return (EFI_DEVICE_PATH_PROTOCOL
*) Ufs
;
1696 Converts a text device path node to SD (Secure Digital) device path structure.
1698 @param TextDeviceNode The input Text device path node.
1700 @return A pointer to the newly-created SD device path structure.
1703 EFI_DEVICE_PATH_PROTOCOL
*
1705 IN CHAR16
*TextDeviceNode
1708 CHAR16
*SlotNumberStr
;
1711 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1712 Sd
= (SD_DEVICE_PATH
*) CreateDeviceNode (
1713 MESSAGING_DEVICE_PATH
,
1715 (UINT16
) sizeof (SD_DEVICE_PATH
)
1718 Sd
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1720 return (EFI_DEVICE_PATH_PROTOCOL
*) Sd
;
1724 Converts a text device path node to EMMC (Embedded MMC) device path structure.
1726 @param TextDeviceNode The input Text device path node.
1728 @return A pointer to the newly-created EMMC device path structure.
1731 EFI_DEVICE_PATH_PROTOCOL
*
1732 DevPathFromTextEmmc (
1733 IN CHAR16
*TextDeviceNode
1736 CHAR16
*SlotNumberStr
;
1737 EMMC_DEVICE_PATH
*Emmc
;
1739 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1740 Emmc
= (EMMC_DEVICE_PATH
*) CreateDeviceNode (
1741 MESSAGING_DEVICE_PATH
,
1743 (UINT16
) sizeof (EMMC_DEVICE_PATH
)
1746 Emmc
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1748 return (EFI_DEVICE_PATH_PROTOCOL
*) Emmc
;
1752 Converts a text device path node to Debug Port device path structure.
1754 @param TextDeviceNode The input Text device path node.
1756 @return A pointer to the newly-created Debug Port device path structure.
1759 EFI_DEVICE_PATH_PROTOCOL
*
1760 DevPathFromTextDebugPort (
1761 IN CHAR16
*TextDeviceNode
1764 VENDOR_DEVICE_PATH
*Vend
;
1766 Vend
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1767 MESSAGING_DEVICE_PATH
,
1769 (UINT16
) sizeof (VENDOR_DEVICE_PATH
)
1772 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1774 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1778 Converts a text device path node to MAC device path structure.
1780 @param TextDeviceNode The input Text device path node.
1782 @return A pointer to the newly-created MAC device path structure.
1785 EFI_DEVICE_PATH_PROTOCOL
*
1786 DevPathFromTextMAC (
1787 IN CHAR16
*TextDeviceNode
1793 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1795 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1796 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1797 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1798 MESSAGING_DEVICE_PATH
,
1800 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1803 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1805 Length
= sizeof (EFI_MAC_ADDRESS
);
1806 if (MACDevPath
->IfType
== 0x01 || MACDevPath
->IfType
== 0x00) {
1810 StrHexToBytes (AddressStr
, Length
* 2, MACDevPath
->MacAddress
.Addr
, Length
);
1812 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1817 Converts a text format to the network protocol ID.
1819 @param Text String of protocol field.
1821 @return Network protocol ID .
1825 NetworkProtocolFromText (
1829 if (StrCmp (Text
, L
"UDP") == 0) {
1830 return RFC_1700_UDP_PROTOCOL
;
1833 if (StrCmp (Text
, L
"TCP") == 0) {
1834 return RFC_1700_TCP_PROTOCOL
;
1837 return Strtoi (Text
);
1842 Converts a text device path node to IPV4 device path structure.
1844 @param TextDeviceNode The input Text device path node.
1846 @return A pointer to the newly-created IPV4 device path structure.
1849 EFI_DEVICE_PATH_PROTOCOL
*
1850 DevPathFromTextIPv4 (
1851 IN CHAR16
*TextDeviceNode
1854 CHAR16
*RemoteIPStr
;
1855 CHAR16
*ProtocolStr
;
1858 CHAR16
*GatewayIPStr
;
1859 CHAR16
*SubnetMaskStr
;
1860 IPv4_DEVICE_PATH
*IPv4
;
1862 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1863 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1864 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1865 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1866 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1867 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
1868 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1869 MESSAGING_DEVICE_PATH
,
1871 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
1874 StrToIpv4Address (RemoteIPStr
, NULL
, &IPv4
->RemoteIpAddress
, NULL
);
1875 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1876 if (StrCmp (TypeStr
, L
"Static") == 0) {
1877 IPv4
->StaticIpAddress
= TRUE
;
1879 IPv4
->StaticIpAddress
= FALSE
;
1882 StrToIpv4Address (LocalIPStr
, NULL
, &IPv4
->LocalIpAddress
, NULL
);
1883 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
1884 StrToIpv4Address (GatewayIPStr
, NULL
, &IPv4
->GatewayIpAddress
, NULL
);
1885 StrToIpv4Address (SubnetMaskStr
, NULL
, &IPv4
->SubnetMask
, NULL
);
1887 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
1888 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
1891 IPv4
->LocalPort
= 0;
1892 IPv4
->RemotePort
= 0;
1894 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1898 Converts a text device path node to IPV6 device path structure.
1900 @param TextDeviceNode The input Text device path node.
1902 @return A pointer to the newly-created IPV6 device path structure.
1905 EFI_DEVICE_PATH_PROTOCOL
*
1906 DevPathFromTextIPv6 (
1907 IN CHAR16
*TextDeviceNode
1910 CHAR16
*RemoteIPStr
;
1911 CHAR16
*ProtocolStr
;
1914 CHAR16
*GatewayIPStr
;
1915 CHAR16
*PrefixLengthStr
;
1916 IPv6_DEVICE_PATH
*IPv6
;
1918 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1919 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1920 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1921 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1922 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
1923 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1924 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1925 MESSAGING_DEVICE_PATH
,
1927 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
1930 StrToIpv6Address (RemoteIPStr
, NULL
, &IPv6
->RemoteIpAddress
, NULL
);
1931 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1932 if (StrCmp (TypeStr
, L
"Static") == 0) {
1933 IPv6
->IpAddressOrigin
= 0;
1934 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
1935 IPv6
->IpAddressOrigin
= 1;
1937 IPv6
->IpAddressOrigin
= 2;
1940 StrToIpv6Address (LocalIPStr
, NULL
, &IPv6
->LocalIpAddress
, NULL
);
1941 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
1942 StrToIpv6Address (GatewayIPStr
, NULL
, &IPv6
->GatewayIpAddress
, NULL
);
1943 IPv6
->PrefixLength
= (UINT8
) Strtoi (PrefixLengthStr
);
1945 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
1946 IPv6
->PrefixLength
= 0;
1949 IPv6
->LocalPort
= 0;
1950 IPv6
->RemotePort
= 0;
1952 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
1956 Converts a text device path node to UART device path structure.
1958 @param TextDeviceNode The input Text device path node.
1960 @return A pointer to the newly-created UART device path structure.
1963 EFI_DEVICE_PATH_PROTOCOL
*
1964 DevPathFromTextUart (
1965 IN CHAR16
*TextDeviceNode
1969 CHAR16
*DataBitsStr
;
1971 CHAR16
*StopBitsStr
;
1972 UART_DEVICE_PATH
*Uart
;
1974 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1975 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1976 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1977 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1978 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
1979 MESSAGING_DEVICE_PATH
,
1981 (UINT16
) sizeof (UART_DEVICE_PATH
)
1984 if (StrCmp (BaudStr
, L
"DEFAULT") == 0) {
1985 Uart
->BaudRate
= 115200;
1987 Strtoi64 (BaudStr
, &Uart
->BaudRate
);
1989 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr
));
1990 switch (*ParityStr
) {
2016 Uart
->Parity
= (UINT8
) Strtoi (ParityStr
);
2020 if (StrCmp (StopBitsStr
, L
"D") == 0) {
2021 Uart
->StopBits
= (UINT8
) 0;
2022 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
2023 Uart
->StopBits
= (UINT8
) 1;
2024 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
2025 Uart
->StopBits
= (UINT8
) 2;
2026 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
2027 Uart
->StopBits
= (UINT8
) 3;
2029 Uart
->StopBits
= (UINT8
) Strtoi (StopBitsStr
);
2032 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
2036 Converts a text device path node to USB class device path structure.
2038 @param TextDeviceNode The input Text device path node.
2039 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
2041 @return A pointer to the newly-created USB class device path structure.
2044 EFI_DEVICE_PATH_PROTOCOL
*
2045 ConvertFromTextUsbClass (
2046 IN CHAR16
*TextDeviceNode
,
2047 IN USB_CLASS_TEXT
*UsbClassText
2053 CHAR16
*SubClassStr
;
2054 CHAR16
*ProtocolStr
;
2055 USB_CLASS_DEVICE_PATH
*UsbClass
;
2057 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
2058 MESSAGING_DEVICE_PATH
,
2060 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
2063 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2064 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2065 if (UsbClassText
->ClassExist
) {
2066 ClassStr
= GetNextParamStr (&TextDeviceNode
);
2067 if (*ClassStr
== L
'\0') {
2068 UsbClass
->DeviceClass
= 0xFF;
2070 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
2073 UsbClass
->DeviceClass
= UsbClassText
->Class
;
2075 if (UsbClassText
->SubClassExist
) {
2076 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
2077 if (*SubClassStr
== L
'\0') {
2078 UsbClass
->DeviceSubClass
= 0xFF;
2080 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
2083 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
2086 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2088 if (*VIDStr
== L
'\0') {
2089 UsbClass
->VendorId
= 0xFFFF;
2091 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2093 if (*PIDStr
== L
'\0') {
2094 UsbClass
->ProductId
= 0xFFFF;
2096 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2098 if (*ProtocolStr
== L
'\0') {
2099 UsbClass
->DeviceProtocol
= 0xFF;
2101 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
2104 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
2109 Converts a text device path node to USB class device path structure.
2111 @param TextDeviceNode The input Text device path node.
2113 @return A pointer to the newly-created USB class device path structure.
2116 EFI_DEVICE_PATH_PROTOCOL
*
2117 DevPathFromTextUsbClass (
2118 IN CHAR16
*TextDeviceNode
2121 USB_CLASS_TEXT UsbClassText
;
2123 UsbClassText
.ClassExist
= TRUE
;
2124 UsbClassText
.SubClassExist
= TRUE
;
2126 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2130 Converts a text device path node to USB audio device path structure.
2132 @param TextDeviceNode The input Text device path node.
2134 @return A pointer to the newly-created USB audio device path structure.
2137 EFI_DEVICE_PATH_PROTOCOL
*
2138 DevPathFromTextUsbAudio (
2139 IN CHAR16
*TextDeviceNode
2142 USB_CLASS_TEXT UsbClassText
;
2144 UsbClassText
.ClassExist
= FALSE
;
2145 UsbClassText
.Class
= USB_CLASS_AUDIO
;
2146 UsbClassText
.SubClassExist
= TRUE
;
2148 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2152 Converts a text device path node to USB CDC Control device path structure.
2154 @param TextDeviceNode The input Text device path node.
2156 @return A pointer to the newly-created USB CDC Control device path structure.
2159 EFI_DEVICE_PATH_PROTOCOL
*
2160 DevPathFromTextUsbCDCControl (
2161 IN CHAR16
*TextDeviceNode
2164 USB_CLASS_TEXT UsbClassText
;
2166 UsbClassText
.ClassExist
= FALSE
;
2167 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
2168 UsbClassText
.SubClassExist
= TRUE
;
2170 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2174 Converts a text device path node to USB HID device path structure.
2176 @param TextDeviceNode The input Text device path node.
2178 @return A pointer to the newly-created USB HID device path structure.
2181 EFI_DEVICE_PATH_PROTOCOL
*
2182 DevPathFromTextUsbHID (
2183 IN CHAR16
*TextDeviceNode
2186 USB_CLASS_TEXT UsbClassText
;
2188 UsbClassText
.ClassExist
= FALSE
;
2189 UsbClassText
.Class
= USB_CLASS_HID
;
2190 UsbClassText
.SubClassExist
= TRUE
;
2192 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2196 Converts a text device path node to USB Image device path structure.
2198 @param TextDeviceNode The input Text device path node.
2200 @return A pointer to the newly-created USB Image device path structure.
2203 EFI_DEVICE_PATH_PROTOCOL
*
2204 DevPathFromTextUsbImage (
2205 IN CHAR16
*TextDeviceNode
2208 USB_CLASS_TEXT UsbClassText
;
2210 UsbClassText
.ClassExist
= FALSE
;
2211 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2212 UsbClassText
.SubClassExist
= TRUE
;
2214 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2218 Converts a text device path node to USB Print device path structure.
2220 @param TextDeviceNode The input Text device path node.
2222 @return A pointer to the newly-created USB Print device path structure.
2225 EFI_DEVICE_PATH_PROTOCOL
*
2226 DevPathFromTextUsbPrinter (
2227 IN CHAR16
*TextDeviceNode
2230 USB_CLASS_TEXT UsbClassText
;
2232 UsbClassText
.ClassExist
= FALSE
;
2233 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2234 UsbClassText
.SubClassExist
= TRUE
;
2236 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2240 Converts a text device path node to USB mass storage device path structure.
2242 @param TextDeviceNode The input Text device path node.
2244 @return A pointer to the newly-created USB mass storage device path structure.
2247 EFI_DEVICE_PATH_PROTOCOL
*
2248 DevPathFromTextUsbMassStorage (
2249 IN CHAR16
*TextDeviceNode
2252 USB_CLASS_TEXT UsbClassText
;
2254 UsbClassText
.ClassExist
= FALSE
;
2255 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2256 UsbClassText
.SubClassExist
= TRUE
;
2258 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2262 Converts a text device path node to USB HUB device path structure.
2264 @param TextDeviceNode The input Text device path node.
2266 @return A pointer to the newly-created USB HUB device path structure.
2269 EFI_DEVICE_PATH_PROTOCOL
*
2270 DevPathFromTextUsbHub (
2271 IN CHAR16
*TextDeviceNode
2274 USB_CLASS_TEXT UsbClassText
;
2276 UsbClassText
.ClassExist
= FALSE
;
2277 UsbClassText
.Class
= USB_CLASS_HUB
;
2278 UsbClassText
.SubClassExist
= TRUE
;
2280 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2284 Converts a text device path node to USB CDC data device path structure.
2286 @param TextDeviceNode The input Text device path node.
2288 @return A pointer to the newly-created USB CDC data device path structure.
2291 EFI_DEVICE_PATH_PROTOCOL
*
2292 DevPathFromTextUsbCDCData (
2293 IN CHAR16
*TextDeviceNode
2296 USB_CLASS_TEXT UsbClassText
;
2298 UsbClassText
.ClassExist
= FALSE
;
2299 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2300 UsbClassText
.SubClassExist
= TRUE
;
2302 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2306 Converts a text device path node to USB smart card device path structure.
2308 @param TextDeviceNode The input Text device path node.
2310 @return A pointer to the newly-created USB smart card device path structure.
2313 EFI_DEVICE_PATH_PROTOCOL
*
2314 DevPathFromTextUsbSmartCard (
2315 IN CHAR16
*TextDeviceNode
2318 USB_CLASS_TEXT UsbClassText
;
2320 UsbClassText
.ClassExist
= FALSE
;
2321 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2322 UsbClassText
.SubClassExist
= TRUE
;
2324 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2328 Converts a text device path node to USB video device path structure.
2330 @param TextDeviceNode The input Text device path node.
2332 @return A pointer to the newly-created USB video device path structure.
2335 EFI_DEVICE_PATH_PROTOCOL
*
2336 DevPathFromTextUsbVideo (
2337 IN CHAR16
*TextDeviceNode
2340 USB_CLASS_TEXT UsbClassText
;
2342 UsbClassText
.ClassExist
= FALSE
;
2343 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2344 UsbClassText
.SubClassExist
= TRUE
;
2346 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2350 Converts a text device path node to USB diagnostic device path structure.
2352 @param TextDeviceNode The input Text device path node.
2354 @return A pointer to the newly-created USB diagnostic device path structure.
2357 EFI_DEVICE_PATH_PROTOCOL
*
2358 DevPathFromTextUsbDiagnostic (
2359 IN CHAR16
*TextDeviceNode
2362 USB_CLASS_TEXT UsbClassText
;
2364 UsbClassText
.ClassExist
= FALSE
;
2365 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2366 UsbClassText
.SubClassExist
= TRUE
;
2368 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2372 Converts a text device path node to USB wireless device path structure.
2374 @param TextDeviceNode The input Text device path node.
2376 @return A pointer to the newly-created USB wireless device path structure.
2379 EFI_DEVICE_PATH_PROTOCOL
*
2380 DevPathFromTextUsbWireless (
2381 IN CHAR16
*TextDeviceNode
2384 USB_CLASS_TEXT UsbClassText
;
2386 UsbClassText
.ClassExist
= FALSE
;
2387 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2388 UsbClassText
.SubClassExist
= TRUE
;
2390 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2394 Converts a text device path node to USB device firmware update device path structure.
2396 @param TextDeviceNode The input Text device path node.
2398 @return A pointer to the newly-created USB device firmware update device path structure.
2401 EFI_DEVICE_PATH_PROTOCOL
*
2402 DevPathFromTextUsbDeviceFirmwareUpdate (
2403 IN CHAR16
*TextDeviceNode
2406 USB_CLASS_TEXT UsbClassText
;
2408 UsbClassText
.ClassExist
= FALSE
;
2409 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2410 UsbClassText
.SubClassExist
= FALSE
;
2411 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2413 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2417 Converts a text device path node to USB IRDA bridge device path structure.
2419 @param TextDeviceNode The input Text device path node.
2421 @return A pointer to the newly-created USB IRDA bridge device path structure.
2424 EFI_DEVICE_PATH_PROTOCOL
*
2425 DevPathFromTextUsbIrdaBridge (
2426 IN CHAR16
*TextDeviceNode
2429 USB_CLASS_TEXT UsbClassText
;
2431 UsbClassText
.ClassExist
= FALSE
;
2432 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2433 UsbClassText
.SubClassExist
= FALSE
;
2434 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2436 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2440 Converts a text device path node to USB text and measurement device path structure.
2442 @param TextDeviceNode The input Text device path node.
2444 @return A pointer to the newly-created USB text and measurement device path structure.
2447 EFI_DEVICE_PATH_PROTOCOL
*
2448 DevPathFromTextUsbTestAndMeasurement (
2449 IN CHAR16
*TextDeviceNode
2452 USB_CLASS_TEXT UsbClassText
;
2454 UsbClassText
.ClassExist
= FALSE
;
2455 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2456 UsbClassText
.SubClassExist
= FALSE
;
2457 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2459 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2463 Converts a text device path node to USB WWID device path structure.
2465 @param TextDeviceNode The input Text device path node.
2467 @return A pointer to the newly-created USB WWID device path structure.
2470 EFI_DEVICE_PATH_PROTOCOL
*
2471 DevPathFromTextUsbWwid (
2472 IN CHAR16
*TextDeviceNode
2477 CHAR16
*InterfaceNumStr
;
2478 CHAR16
*SerialNumberStr
;
2479 USB_WWID_DEVICE_PATH
*UsbWwid
;
2480 UINTN SerialNumberStrLen
;
2482 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2483 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2484 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2485 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2486 SerialNumberStrLen
= StrLen (SerialNumberStr
);
2487 if (SerialNumberStrLen
>= 2 &&
2488 SerialNumberStr
[0] == L
'\"' &&
2489 SerialNumberStr
[SerialNumberStrLen
- 1] == L
'\"'
2491 SerialNumberStr
[SerialNumberStrLen
- 1] = L
'\0';
2493 SerialNumberStrLen
-= 2;
2495 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2496 MESSAGING_DEVICE_PATH
,
2498 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + SerialNumberStrLen
* sizeof (CHAR16
))
2500 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2501 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2502 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2505 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
2506 // Therefore, the '\0' will not be copied.
2509 (UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
),
2511 SerialNumberStrLen
* sizeof (CHAR16
)
2514 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2518 Converts a text device path node to Logic Unit device path structure.
2520 @param TextDeviceNode The input Text device path node.
2522 @return A pointer to the newly-created Logic Unit device path structure.
2525 EFI_DEVICE_PATH_PROTOCOL
*
2526 DevPathFromTextUnit (
2527 IN CHAR16
*TextDeviceNode
2531 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2533 LunStr
= GetNextParamStr (&TextDeviceNode
);
2534 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2535 MESSAGING_DEVICE_PATH
,
2536 MSG_DEVICE_LOGICAL_UNIT_DP
,
2537 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2540 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2542 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2546 Converts a text device path node to iSCSI device path structure.
2548 @param TextDeviceNode The input Text device path node.
2550 @return A pointer to the newly-created iSCSI device path structure.
2553 EFI_DEVICE_PATH_PROTOCOL
*
2554 DevPathFromTextiSCSI (
2555 IN CHAR16
*TextDeviceNode
2560 CHAR16
*PortalGroupStr
;
2562 CHAR16
*HeaderDigestStr
;
2563 CHAR16
*DataDigestStr
;
2564 CHAR16
*AuthenticationStr
;
2565 CHAR16
*ProtocolStr
;
2567 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2570 NameStr
= GetNextParamStr (&TextDeviceNode
);
2571 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2572 LunStr
= GetNextParamStr (&TextDeviceNode
);
2573 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2574 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2575 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2576 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2577 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2578 MESSAGING_DEVICE_PATH
,
2580 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2583 AsciiStr
= ISCSIDevPath
->TargetName
;
2584 StrToAscii (NameStr
, &AsciiStr
);
2586 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2587 Strtoi64 (LunStr
, &Lun
);
2588 WriteUnaligned64 ((UINT64
*) &ISCSIDevPath
->Lun
, SwapBytes64 (Lun
));
2591 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2595 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2599 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2603 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2607 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2609 if (IS_NULL (*ProtocolStr
) || (StrCmp (ProtocolStr
, L
"TCP") == 0)) {
2610 ISCSIDevPath
->NetworkProtocol
= 0;
2613 // Undefined and reserved.
2615 ISCSIDevPath
->NetworkProtocol
= 1;
2618 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2622 Converts a text device path node to VLAN device path structure.
2624 @param TextDeviceNode The input Text device path node.
2626 @return A pointer to the newly-created VLAN device path structure.
2629 EFI_DEVICE_PATH_PROTOCOL
*
2630 DevPathFromTextVlan (
2631 IN CHAR16
*TextDeviceNode
2635 VLAN_DEVICE_PATH
*Vlan
;
2637 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2638 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2639 MESSAGING_DEVICE_PATH
,
2641 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2644 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2646 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2650 Converts a text device path node to Bluetooth device path structure.
2652 @param TextDeviceNode The input Text device path node.
2654 @return A pointer to the newly-created Bluetooth device path structure.
2657 EFI_DEVICE_PATH_PROTOCOL
*
2658 DevPathFromTextBluetooth (
2659 IN CHAR16
*TextDeviceNode
2662 CHAR16
*BluetoothStr
;
2663 BLUETOOTH_DEVICE_PATH
*BluetoothDp
;
2665 BluetoothStr
= GetNextParamStr (&TextDeviceNode
);
2666 BluetoothDp
= (BLUETOOTH_DEVICE_PATH
*) CreateDeviceNode (
2667 MESSAGING_DEVICE_PATH
,
2669 (UINT16
) sizeof (BLUETOOTH_DEVICE_PATH
)
2673 sizeof (BLUETOOTH_ADDRESS
) * 2,
2674 BluetoothDp
->BD_ADDR
.Address
,
2675 sizeof (BLUETOOTH_ADDRESS
)
2677 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothDp
;
2681 Converts a text device path node to Wi-Fi device path structure.
2683 @param TextDeviceNode The input Text device path node.
2685 @return A pointer to the newly-created Wi-Fi device path structure.
2688 EFI_DEVICE_PATH_PROTOCOL
*
2689 DevPathFromTextWiFi (
2690 IN CHAR16
*TextDeviceNode
2696 WIFI_DEVICE_PATH
*WiFiDp
;
2698 SSIdStr
= GetNextParamStr (&TextDeviceNode
);
2699 WiFiDp
= (WIFI_DEVICE_PATH
*) CreateDeviceNode (
2700 MESSAGING_DEVICE_PATH
,
2702 (UINT16
) sizeof (WIFI_DEVICE_PATH
)
2705 if (NULL
!= SSIdStr
) {
2706 DataLen
= StrLen (SSIdStr
);
2707 if (StrLen (SSIdStr
) > 32) {
2708 SSIdStr
[32] = L
'\0';
2712 UnicodeStrToAsciiStrS (SSIdStr
, AsciiStr
, sizeof (AsciiStr
));
2713 CopyMem (WiFiDp
->SSId
, AsciiStr
, DataLen
);
2716 return (EFI_DEVICE_PATH_PROTOCOL
*) WiFiDp
;
2720 Converts a text device path node to Bluetooth LE device path structure.
2722 @param TextDeviceNode The input Text device path node.
2724 @return A pointer to the newly-created Bluetooth LE device path structure.
2727 EFI_DEVICE_PATH_PROTOCOL
*
2728 DevPathFromTextBluetoothLE (
2729 IN CHAR16
*TextDeviceNode
2732 CHAR16
*BluetoothLeAddrStr
;
2733 CHAR16
*BluetoothLeAddrTypeStr
;
2734 BLUETOOTH_LE_DEVICE_PATH
*BluetoothLeDp
;
2736 BluetoothLeAddrStr
= GetNextParamStr (&TextDeviceNode
);
2737 BluetoothLeAddrTypeStr
= GetNextParamStr (&TextDeviceNode
);
2738 BluetoothLeDp
= (BLUETOOTH_LE_DEVICE_PATH
*) CreateDeviceNode (
2739 MESSAGING_DEVICE_PATH
,
2740 MSG_BLUETOOTH_LE_DP
,
2741 (UINT16
) sizeof (BLUETOOTH_LE_DEVICE_PATH
)
2744 BluetoothLeDp
->Address
.Type
= (UINT8
) Strtoi (BluetoothLeAddrTypeStr
);
2746 BluetoothLeAddrStr
, sizeof (BluetoothLeDp
->Address
.Address
) * 2,
2747 BluetoothLeDp
->Address
.Address
, sizeof (BluetoothLeDp
->Address
.Address
)
2749 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothLeDp
;
2753 Converts a text device path node to DNS device path structure.
2755 @param TextDeviceNode The input Text device path node.
2757 @return A pointer to the newly-created DNS device path structure.
2760 EFI_DEVICE_PATH_PROTOCOL
*
2761 DevPathFromTextDns (
2762 IN CHAR16
*TextDeviceNode
2765 CHAR16
*DeviceNodeStr
;
2766 CHAR16
*DeviceNodeStrPtr
;
2767 UINT32 DnsServerIpCount
;
2768 UINT16 DnsDeviceNodeLength
;
2769 DNS_DEVICE_PATH
*DnsDeviceNode
;
2770 UINT32 DnsServerIpIndex
;
2771 CHAR16
*DnsServerIp
;
2775 // Count the DNS server address number.
2777 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
2778 if (DeviceNodeStr
== NULL
) {
2782 DeviceNodeStrPtr
= DeviceNodeStr
;
2784 DnsServerIpCount
= 0;
2785 while (DeviceNodeStrPtr
!= NULL
&& *DeviceNodeStrPtr
!= L
'\0') {
2786 GetNextParamStr (&DeviceNodeStrPtr
);
2787 DnsServerIpCount
++;
2790 FreePool (DeviceNodeStr
);
2791 DeviceNodeStr
= NULL
;
2794 // One or more instances of the DNS server address in EFI_IP_ADDRESS,
2795 // otherwise, NULL will be returned.
2797 if (DnsServerIpCount
== 0) {
2802 // Create the DNS DeviceNode.
2804 DnsDeviceNodeLength
= (UINT16
) (sizeof (EFI_DEVICE_PATH_PROTOCOL
) + sizeof (UINT8
) + DnsServerIpCount
* sizeof (EFI_IP_ADDRESS
));
2805 DnsDeviceNode
= (DNS_DEVICE_PATH
*) CreateDeviceNode (
2806 MESSAGING_DEVICE_PATH
,
2810 if (DnsDeviceNode
== NULL
) {
2815 // Confirm the DNS server address is IPv4 or IPv6 type.
2817 DeviceNodeStrPtr
= TextDeviceNode
;
2818 while (!IS_NULL (*DeviceNodeStrPtr
)) {
2819 if (*DeviceNodeStrPtr
== L
'.') {
2820 DnsDeviceNode
->IsIPv6
= 0x00;
2824 if (*DeviceNodeStrPtr
== L
':') {
2825 DnsDeviceNode
->IsIPv6
= 0x01;
2832 for (DnsServerIpIndex
= 0; DnsServerIpIndex
< DnsServerIpCount
; DnsServerIpIndex
++) {
2833 DnsServerIp
= GetNextParamStr (&TextDeviceNode
);
2834 if (DnsDeviceNode
->IsIPv6
== 0x00) {
2835 StrToIpv4Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v4
), NULL
);
2837 StrToIpv6Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v6
), NULL
);
2841 return (EFI_DEVICE_PATH_PROTOCOL
*) DnsDeviceNode
;
2845 Converts a text device path node to URI device path structure.
2847 @param TextDeviceNode The input Text device path node.
2849 @return A pointer to the newly-created URI device path structure.
2852 EFI_DEVICE_PATH_PROTOCOL
*
2853 DevPathFromTextUri (
2854 IN CHAR16
*TextDeviceNode
2859 URI_DEVICE_PATH
*Uri
;
2861 UriStr
= GetNextParamStr (&TextDeviceNode
);
2862 UriLength
= StrnLenS (UriStr
, MAX_UINT16
- sizeof (URI_DEVICE_PATH
));
2863 Uri
= (URI_DEVICE_PATH
*) CreateDeviceNode (
2864 MESSAGING_DEVICE_PATH
,
2866 (UINT16
) (sizeof (URI_DEVICE_PATH
) + UriLength
)
2869 while (UriLength
-- != 0) {
2870 Uri
->Uri
[UriLength
] = (CHAR8
) UriStr
[UriLength
];
2873 return (EFI_DEVICE_PATH_PROTOCOL
*) Uri
;
2877 Converts a media text device path node to media device path structure.
2879 @param TextDeviceNode The input Text device path node.
2881 @return A pointer to media device path structure.
2884 EFI_DEVICE_PATH_PROTOCOL
*
2885 DevPathFromTextMediaPath (
2886 IN CHAR16
*TextDeviceNode
2889 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH
, TextDeviceNode
);
2893 Converts a text device path node to HD device path structure.
2895 @param TextDeviceNode The input Text device path node.
2897 @return A pointer to the newly-created HD device path structure.
2900 EFI_DEVICE_PATH_PROTOCOL
*
2902 IN CHAR16
*TextDeviceNode
2905 CHAR16
*PartitionStr
;
2907 CHAR16
*SignatureStr
;
2911 HARDDRIVE_DEVICE_PATH
*Hd
;
2913 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2914 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2915 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2916 StartStr
= GetNextParamStr (&TextDeviceNode
);
2917 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2918 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2921 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2924 Hd
->PartitionNumber
= (UINT32
) Strtoi (PartitionStr
);
2926 ZeroMem (Hd
->Signature
, 16);
2927 Hd
->MBRType
= (UINT8
) 0;
2929 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2930 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2933 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2934 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2935 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2936 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2939 StrToGuid (SignatureStr
, (EFI_GUID
*) Hd
->Signature
);
2941 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2944 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2945 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2947 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2951 Converts a text device path node to CDROM device path structure.
2953 @param TextDeviceNode The input Text device path node.
2955 @return A pointer to the newly-created CDROM device path structure.
2958 EFI_DEVICE_PATH_PROTOCOL
*
2959 DevPathFromTextCDROM (
2960 IN CHAR16
*TextDeviceNode
2966 CDROM_DEVICE_PATH
*CDROMDevPath
;
2968 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2969 StartStr
= GetNextParamStr (&TextDeviceNode
);
2970 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2971 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2974 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2977 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2978 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2979 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2981 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2985 Converts a text device path node to Vendor-defined media device path structure.
2987 @param TextDeviceNode The input Text device path node.
2989 @return A pointer to the newly-created Vendor-defined media device path structure.
2992 EFI_DEVICE_PATH_PROTOCOL
*
2993 DevPathFromTextVenMedia (
2994 IN CHAR16
*TextDeviceNode
2997 return ConvertFromTextVendor (
3005 Converts a text device path node to File device path structure.
3007 @param TextDeviceNode The input Text device path node.
3009 @return A pointer to the newly-created File device path structure.
3012 EFI_DEVICE_PATH_PROTOCOL
*
3013 DevPathFromTextFilePath (
3014 IN CHAR16
*TextDeviceNode
3017 FILEPATH_DEVICE_PATH
*File
;
3019 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
3022 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
3025 StrCpyS (File
->PathName
, StrLen (TextDeviceNode
) + 1, TextDeviceNode
);
3027 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
3031 Converts a text device path node to Media protocol device path structure.
3033 @param TextDeviceNode The input Text device path node.
3035 @return A pointer to the newly-created Media protocol device path structure.
3038 EFI_DEVICE_PATH_PROTOCOL
*
3039 DevPathFromTextMedia (
3040 IN CHAR16
*TextDeviceNode
3044 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
3046 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3047 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
3050 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
3053 StrToGuid (GuidStr
, &Media
->Protocol
);
3055 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
3059 Converts a text device path node to firmware volume device path structure.
3061 @param TextDeviceNode The input Text device path node.
3063 @return A pointer to the newly-created firmware volume device path structure.
3066 EFI_DEVICE_PATH_PROTOCOL
*
3068 IN CHAR16
*TextDeviceNode
3072 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
3074 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3075 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
3077 MEDIA_PIWG_FW_VOL_DP
,
3078 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
3081 StrToGuid (GuidStr
, &Fv
->FvName
);
3083 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
3087 Converts a text device path node to firmware file device path structure.
3089 @param TextDeviceNode The input Text device path node.
3091 @return A pointer to the newly-created firmware file device path structure.
3094 EFI_DEVICE_PATH_PROTOCOL
*
3095 DevPathFromTextFvFile (
3096 IN CHAR16
*TextDeviceNode
3100 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
3102 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3103 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
3105 MEDIA_PIWG_FW_FILE_DP
,
3106 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
3109 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
3111 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
3115 Converts a text device path node to text relative offset device path structure.
3117 @param TextDeviceNode The input Text device path node.
3119 @return A pointer to the newly-created Text device path structure.
3122 EFI_DEVICE_PATH_PROTOCOL
*
3123 DevPathFromTextRelativeOffsetRange (
3124 IN CHAR16
*TextDeviceNode
3127 CHAR16
*StartingOffsetStr
;
3128 CHAR16
*EndingOffsetStr
;
3129 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
3131 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
3132 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
3133 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
3135 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
3136 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
3139 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
3140 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
3142 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
3146 Converts a text device path node to text ram disk device path structure.
3148 @param TextDeviceNode The input Text device path node.
3150 @return A pointer to the newly-created Text device path structure.
3153 EFI_DEVICE_PATH_PROTOCOL
*
3154 DevPathFromTextRamDisk (
3155 IN CHAR16
*TextDeviceNode
3158 CHAR16
*StartingAddrStr
;
3159 CHAR16
*EndingAddrStr
;
3160 CHAR16
*TypeGuidStr
;
3161 CHAR16
*InstanceStr
;
3162 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3163 UINT64 StartingAddr
;
3166 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3167 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3168 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3169 TypeGuidStr
= GetNextParamStr (&TextDeviceNode
);
3170 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3173 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3176 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3177 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3178 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3179 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3180 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3181 StrToGuid (TypeGuidStr
, &RamDisk
->TypeGuid
);
3183 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3187 Converts a text device path node to text virtual disk device path structure.
3189 @param TextDeviceNode The input Text device path node.
3191 @return A pointer to the newly-created Text device path structure.
3194 EFI_DEVICE_PATH_PROTOCOL
*
3195 DevPathFromTextVirtualDisk (
3196 IN CHAR16
*TextDeviceNode
3199 CHAR16
*StartingAddrStr
;
3200 CHAR16
*EndingAddrStr
;
3201 CHAR16
*InstanceStr
;
3202 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3203 UINT64 StartingAddr
;
3206 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3207 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3208 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3210 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3213 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3216 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3217 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3218 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3219 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3220 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3221 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualDiskGuid
);
3223 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3227 Converts a text device path node to text virtual cd device path structure.
3229 @param TextDeviceNode The input Text device path node.
3231 @return A pointer to the newly-created Text device path structure.
3234 EFI_DEVICE_PATH_PROTOCOL
*
3235 DevPathFromTextVirtualCd (
3236 IN CHAR16
*TextDeviceNode
3239 CHAR16
*StartingAddrStr
;
3240 CHAR16
*EndingAddrStr
;
3241 CHAR16
*InstanceStr
;
3242 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3243 UINT64 StartingAddr
;
3246 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3247 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3248 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3250 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3253 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3256 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3257 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3258 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3259 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3260 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3261 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualCdGuid
);
3263 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3267 Converts a text device path node to text persistent virtual disk device path structure.
3269 @param TextDeviceNode The input Text device path node.
3271 @return A pointer to the newly-created Text device path structure.
3274 EFI_DEVICE_PATH_PROTOCOL
*
3275 DevPathFromTextPersistentVirtualDisk (
3276 IN CHAR16
*TextDeviceNode
3279 CHAR16
*StartingAddrStr
;
3280 CHAR16
*EndingAddrStr
;
3281 CHAR16
*InstanceStr
;
3282 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3283 UINT64 StartingAddr
;
3286 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3287 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3288 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3290 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3293 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3296 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3297 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3298 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3299 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3300 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3301 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualDiskGuid
);
3303 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3307 Converts a text device path node to text persistent virtual cd device path structure.
3309 @param TextDeviceNode The input Text device path node.
3311 @return A pointer to the newly-created Text device path structure.
3314 EFI_DEVICE_PATH_PROTOCOL
*
3315 DevPathFromTextPersistentVirtualCd (
3316 IN CHAR16
*TextDeviceNode
3319 CHAR16
*StartingAddrStr
;
3320 CHAR16
*EndingAddrStr
;
3321 CHAR16
*InstanceStr
;
3322 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3323 UINT64 StartingAddr
;
3326 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3327 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3328 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3330 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3333 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3336 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3337 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3338 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3339 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3340 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3341 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualCdGuid
);
3343 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3347 Converts a BBS text device path node to BBS device path structure.
3349 @param TextDeviceNode The input Text device path node.
3351 @return A pointer to BBS device path structure.
3354 EFI_DEVICE_PATH_PROTOCOL
*
3355 DevPathFromTextBbsPath (
3356 IN CHAR16
*TextDeviceNode
3359 return DevPathFromTextGenericPath (BBS_DEVICE_PATH
, TextDeviceNode
);
3363 Converts a text device path node to BIOS Boot Specification device path structure.
3365 @param TextDeviceNode The input Text device path node.
3367 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3370 EFI_DEVICE_PATH_PROTOCOL
*
3371 DevPathFromTextBBS (
3372 IN CHAR16
*TextDeviceNode
3379 BBS_BBS_DEVICE_PATH
*Bbs
;
3381 TypeStr
= GetNextParamStr (&TextDeviceNode
);
3382 IdStr
= GetNextParamStr (&TextDeviceNode
);
3383 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
3384 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
3387 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
3390 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
3391 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
3392 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
3393 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
3394 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
3395 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
3396 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
3397 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
3398 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
3399 Bbs
->DeviceType
= BBS_TYPE_USB
;
3400 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
3401 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
3403 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
3406 AsciiStr
= Bbs
->String
;
3407 StrToAscii (IdStr
, &AsciiStr
);
3409 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
3411 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
3415 Converts a text device path node to SATA device path structure.
3417 @param TextDeviceNode The input Text device path node.
3419 @return A pointer to the newly-created SATA device path structure.
3422 EFI_DEVICE_PATH_PROTOCOL
*
3423 DevPathFromTextSata (
3424 IN CHAR16
*TextDeviceNode
3427 SATA_DEVICE_PATH
*Sata
;
3432 Param1
= GetNextParamStr (&TextDeviceNode
);
3433 Param2
= GetNextParamStr (&TextDeviceNode
);
3434 Param3
= GetNextParamStr (&TextDeviceNode
);
3436 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
3437 MESSAGING_DEVICE_PATH
,
3439 (UINT16
) sizeof (SATA_DEVICE_PATH
)
3441 Sata
->HBAPortNumber
= (UINT16
) Strtoi (Param1
);
3444 // According to UEFI spec, if PMPN is not provided, the default is 0xFFFF
3446 if (*Param2
== L
'\0' ) {
3447 Sata
->PortMultiplierPortNumber
= 0xFFFF;
3449 Sata
->PortMultiplierPortNumber
= (UINT16
) Strtoi (Param2
);
3451 Sata
->Lun
= (UINT16
) Strtoi (Param3
);
3453 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
3456 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
3457 {L
"Path", DevPathFromTextPath
},
3459 {L
"HardwarePath", DevPathFromTextHardwarePath
},
3460 {L
"Pci", DevPathFromTextPci
},
3461 {L
"PcCard", DevPathFromTextPcCard
},
3462 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
3463 {L
"VenHw", DevPathFromTextVenHw
},
3464 {L
"Ctrl", DevPathFromTextCtrl
},
3465 {L
"BMC", DevPathFromTextBmc
},
3467 {L
"AcpiPath", DevPathFromTextAcpiPath
},
3468 {L
"Acpi", DevPathFromTextAcpi
},
3469 {L
"PciRoot", DevPathFromTextPciRoot
},
3470 {L
"PcieRoot", DevPathFromTextPcieRoot
},
3471 {L
"Floppy", DevPathFromTextFloppy
},
3472 {L
"Keyboard", DevPathFromTextKeyboard
},
3473 {L
"Serial", DevPathFromTextSerial
},
3474 {L
"ParallelPort", DevPathFromTextParallelPort
},
3475 {L
"AcpiEx", DevPathFromTextAcpiEx
},
3476 {L
"AcpiExp", DevPathFromTextAcpiExp
},
3477 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
3479 {L
"Msg", DevPathFromTextMsg
},
3480 {L
"Ata", DevPathFromTextAta
},
3481 {L
"Scsi", DevPathFromTextScsi
},
3482 {L
"Fibre", DevPathFromTextFibre
},
3483 {L
"FibreEx", DevPathFromTextFibreEx
},
3484 {L
"I1394", DevPathFromText1394
},
3485 {L
"USB", DevPathFromTextUsb
},
3486 {L
"I2O", DevPathFromTextI2O
},
3487 {L
"Infiniband", DevPathFromTextInfiniband
},
3488 {L
"VenMsg", DevPathFromTextVenMsg
},
3489 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
3490 {L
"VenVt100", DevPathFromTextVenVt100
},
3491 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
3492 {L
"VenUtf8", DevPathFromTextVenUtf8
},
3493 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
3494 {L
"SAS", DevPathFromTextSAS
},
3495 {L
"SasEx", DevPathFromTextSasEx
},
3496 {L
"NVMe", DevPathFromTextNVMe
},
3497 {L
"UFS", DevPathFromTextUfs
},
3498 {L
"SD", DevPathFromTextSd
},
3499 {L
"eMMC", DevPathFromTextEmmc
},
3500 {L
"DebugPort", DevPathFromTextDebugPort
},
3501 {L
"MAC", DevPathFromTextMAC
},
3502 {L
"IPv4", DevPathFromTextIPv4
},
3503 {L
"IPv6", DevPathFromTextIPv6
},
3504 {L
"Uart", DevPathFromTextUart
},
3505 {L
"UsbClass", DevPathFromTextUsbClass
},
3506 {L
"UsbAudio", DevPathFromTextUsbAudio
},
3507 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
3508 {L
"UsbHID", DevPathFromTextUsbHID
},
3509 {L
"UsbImage", DevPathFromTextUsbImage
},
3510 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
3511 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
3512 {L
"UsbHub", DevPathFromTextUsbHub
},
3513 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
3514 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
3515 {L
"UsbVideo", DevPathFromTextUsbVideo
},
3516 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
3517 {L
"UsbWireless", DevPathFromTextUsbWireless
},
3518 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
3519 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
3520 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
3521 {L
"UsbWwid", DevPathFromTextUsbWwid
},
3522 {L
"Unit", DevPathFromTextUnit
},
3523 {L
"iSCSI", DevPathFromTextiSCSI
},
3524 {L
"Vlan", DevPathFromTextVlan
},
3525 {L
"Dns", DevPathFromTextDns
},
3526 {L
"Uri", DevPathFromTextUri
},
3527 {L
"Bluetooth", DevPathFromTextBluetooth
},
3528 {L
"Wi-Fi", DevPathFromTextWiFi
},
3529 {L
"BluetoothLE", DevPathFromTextBluetoothLE
},
3530 {L
"MediaPath", DevPathFromTextMediaPath
},
3531 {L
"HD", DevPathFromTextHD
},
3532 {L
"CDROM", DevPathFromTextCDROM
},
3533 {L
"VenMedia", DevPathFromTextVenMedia
},
3534 {L
"Media", DevPathFromTextMedia
},
3535 {L
"Fv", DevPathFromTextFv
},
3536 {L
"FvFile", DevPathFromTextFvFile
},
3537 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
3538 {L
"RamDisk", DevPathFromTextRamDisk
},
3539 {L
"VirtualDisk", DevPathFromTextVirtualDisk
},
3540 {L
"VirtualCD", DevPathFromTextVirtualCd
},
3541 {L
"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk
},
3542 {L
"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd
},
3544 {L
"BbsPath", DevPathFromTextBbsPath
},
3545 {L
"BBS", DevPathFromTextBBS
},
3546 {L
"Sata", DevPathFromTextSata
},
3551 Convert text to the binary representation of a device node.
3553 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3554 node. Conversion starts with the first character and continues
3555 until the first non-device node character.
3557 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3558 insufficient memory or text unsupported.
3561 EFI_DEVICE_PATH_PROTOCOL
*
3563 UefiDevicePathLibConvertTextToDeviceNode (
3564 IN CONST CHAR16
*TextDeviceNode
3567 DEVICE_PATH_FROM_TEXT FromText
;
3569 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3570 CHAR16
*DeviceNodeStr
;
3573 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
3579 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
3580 ASSERT (DeviceNodeStr
!= NULL
);
3582 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3583 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
3584 if (ParamStr
!= NULL
) {
3585 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
3590 if (FromText
== NULL
) {
3594 FromText
= DevPathFromTextFilePath
;
3595 DeviceNode
= FromText (DeviceNodeStr
);
3597 DeviceNode
= FromText (ParamStr
);
3598 FreePool (ParamStr
);
3601 FreePool (DeviceNodeStr
);
3607 Convert text to the binary representation of a device path.
3610 @param TextDevicePath TextDevicePath points to the text representation of a device
3611 path. Conversion starts with the first character and continues
3612 until the first non-device node character.
3614 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3615 there was insufficient memory.
3618 EFI_DEVICE_PATH_PROTOCOL
*
3620 UefiDevicePathLibConvertTextToDevicePath (
3621 IN CONST CHAR16
*TextDevicePath
3624 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3625 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3626 CHAR16
*DevicePathStr
;
3628 CHAR16
*DeviceNodeStr
;
3629 BOOLEAN IsInstanceEnd
;
3630 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3632 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3636 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3637 ASSERT (DevicePath
!= NULL
);
3638 SetDevicePathEndNode (DevicePath
);
3640 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3642 Str
= DevicePathStr
;
3643 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3644 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3646 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3647 FreePool (DevicePath
);
3648 FreePool (DeviceNode
);
3649 DevicePath
= NewDevicePath
;
3651 if (IsInstanceEnd
) {
3652 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3653 ASSERT (DeviceNode
!= NULL
);
3654 SetDevicePathEndNode (DeviceNode
);
3655 DeviceNode
->SubType
= END_INSTANCE_DEVICE_PATH_SUBTYPE
;
3657 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3658 FreePool (DevicePath
);
3659 FreePool (DeviceNode
);
3660 DevicePath
= NewDevicePath
;
3664 FreePool (DevicePathStr
);