2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
4 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiDevicePathLib.h"
21 @param Src Source string.
23 @return The duplicated string.
27 UefiDevicePathLibStrDuplicate (
31 return AllocateCopyPool (StrSize (Src
), Src
);
36 Get parameter in a pair of parentheses follow the given node name.
37 For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".
39 @param Str Device Path Text.
40 @param NodeName Name of the node.
42 @return Parameter text for the node.
54 UINTN ParameterLength
;
57 // Check whether the node name matchs
59 NodeNameLength
= StrLen (NodeName
);
60 if (StrnCmp (Str
, NodeName
, NodeNameLength
) != 0) {
64 ParamStr
= Str
+ NodeNameLength
;
65 if (!IS_LEFT_PARENTH (*ParamStr
)) {
70 // Skip the found '(' and find first occurrence of ')'
74 StrPointer
= ParamStr
;
75 while (!IS_NULL (*StrPointer
)) {
76 if (IS_RIGHT_PARENTH (*StrPointer
)) {
82 if (IS_NULL (*StrPointer
)) {
89 ParamStr
= AllocateCopyPool ((ParameterLength
+ 1) * sizeof (CHAR16
), ParamStr
);
90 if (ParamStr
== NULL
) {
94 // Terminate the parameter string
96 ParamStr
[ParameterLength
] = L
'\0';
102 Gets current sub-string from a string list, before return
103 the list header is moved to next sub-string. The sub-string is separated
104 by the specified character. For example, the separator is ',', the string
105 list is "2,0,3", it returns "2", the remain list move to "0,3"
107 @param List A string list separated by the specified separator
108 @param Separator The separator character
110 @return A pointer to the current sub-string
115 IN OUT CHAR16
**List
,
125 if (IS_NULL (*Str
)) {
130 // Find first occurrence of the separator
132 while (!IS_NULL (*Str
)) {
133 if (*Str
== Separator
) {
139 if (*Str
== Separator
) {
141 // Find a sub-string, terminate it
148 // Move to next sub-string
156 Gets the next parameter string from the list.
158 @param List A string list separated by the specified separator
160 @return A pointer to the current sub-string
169 // The separator is comma
171 return SplitStr (List
, L
',');
175 Get one device node from entire device path text.
177 @param DevicePath On input, the current Device Path node; on output, the next device path node
178 @param IsInstanceEnd This node is the end of a device path instance
180 @return A device node text or NULL if no more device node available
184 GetNextDeviceNodeStr (
185 IN OUT CHAR16
**DevicePath
,
186 OUT BOOLEAN
*IsInstanceEnd
191 UINTN ParenthesesStack
;
194 if (IS_NULL (*Str
)) {
199 // Skip the leading '/', '(', ')' and ','
201 while (!IS_NULL (*Str
)) {
202 if (!IS_SLASH (*Str
) &&
204 !IS_LEFT_PARENTH (*Str
) &&
205 !IS_RIGHT_PARENTH (*Str
)) {
214 // Scan for the separator of this device node, '/' or ','
216 ParenthesesStack
= 0;
217 while (!IS_NULL (*Str
)) {
218 if ((IS_COMMA (*Str
) || IS_SLASH (*Str
)) && (ParenthesesStack
== 0)) {
222 if (IS_LEFT_PARENTH (*Str
)) {
224 } else if (IS_RIGHT_PARENTH (*Str
)) {
231 if (ParenthesesStack
!= 0) {
233 // The '(' doesn't pair with ')', invalid device path text
238 if (IS_COMMA (*Str
)) {
239 *IsInstanceEnd
= TRUE
;
243 *IsInstanceEnd
= FALSE
;
244 if (!IS_NULL (*Str
)) {
257 Return whether the integer string is a hex string.
259 @param Str The integer string
261 @retval TRUE Hex string
262 @retval FALSE Decimal string
271 // skip preceeding white space
273 while ((*Str
!= 0) && *Str
== L
' ') {
277 // skip preceeding zeros
279 while ((*Str
!= 0) && *Str
== L
'0') {
283 return (BOOLEAN
) (*Str
== L
'x' || *Str
== L
'X');
288 Convert integer string to uint.
290 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
292 @return A UINTN value represented by Str
300 if (IsHexStr (Str
)) {
301 return StrHexToUintn (Str
);
303 return StrDecimalToUintn (Str
);
309 Convert integer string to 64 bit data.
311 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
312 @param Data A pointer to the UINT64 value represented by Str
321 if (IsHexStr (Str
)) {
322 *Data
= StrHexToUint64 (Str
);
324 *Data
= StrDecimalToUint64 (Str
);
329 Converts a 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
++);
351 // Return the string next to it
353 *AsciiStr
= Dest
+ 1;
357 Converts a generic text device path node to device path structure.
359 @param Type The type of the device path node.
360 @param TextDeviceNode The input text device path node.
362 @return A pointer to device path structure.
364 EFI_DEVICE_PATH_PROTOCOL
*
365 DevPathFromTextGenericPath (
367 IN CHAR16
*TextDeviceNode
370 EFI_DEVICE_PATH_PROTOCOL
*Node
;
375 SubtypeStr
= GetNextParamStr (&TextDeviceNode
);
376 DataStr
= GetNextParamStr (&TextDeviceNode
);
378 if (DataStr
== NULL
) {
381 DataLength
= StrLen (DataStr
) / 2;
383 Node
= CreateDeviceNode (
385 (UINT8
) Strtoi (SubtypeStr
),
386 (UINT16
) (sizeof (EFI_DEVICE_PATH_PROTOCOL
) + DataLength
)
389 StrHexToBytes (DataStr
, DataLength
* 2, (UINT8
*) (Node
+ 1), DataLength
);
394 Converts a generic text device path node to device path structure.
396 @param TextDeviceNode The input Text device path node.
398 @return A pointer to device path structure.
401 EFI_DEVICE_PATH_PROTOCOL
*
402 DevPathFromTextPath (
403 IN CHAR16
*TextDeviceNode
408 TypeStr
= GetNextParamStr (&TextDeviceNode
);
410 return DevPathFromTextGenericPath ((UINT8
) Strtoi (TypeStr
), TextDeviceNode
);
414 Converts a generic hardware text device path node to Hardware device path structure.
416 @param TextDeviceNode The input Text device path node.
418 @return A pointer to Hardware device path structure.
421 EFI_DEVICE_PATH_PROTOCOL
*
422 DevPathFromTextHardwarePath (
423 IN CHAR16
*TextDeviceNode
426 return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH
, TextDeviceNode
);
430 Converts a text device path node to Hardware PCI device path structure.
432 @param TextDeviceNode The input Text device path node.
434 @return A pointer to Hardware PCI device path structure.
437 EFI_DEVICE_PATH_PROTOCOL
*
439 IN CHAR16
*TextDeviceNode
444 PCI_DEVICE_PATH
*Pci
;
446 DeviceStr
= GetNextParamStr (&TextDeviceNode
);
447 FunctionStr
= GetNextParamStr (&TextDeviceNode
);
448 Pci
= (PCI_DEVICE_PATH
*) CreateDeviceNode (
449 HARDWARE_DEVICE_PATH
,
451 (UINT16
) sizeof (PCI_DEVICE_PATH
)
454 Pci
->Function
= (UINT8
) Strtoi (FunctionStr
);
455 Pci
->Device
= (UINT8
) Strtoi (DeviceStr
);
457 return (EFI_DEVICE_PATH_PROTOCOL
*) Pci
;
461 Converts a text device path node to Hardware PC card device path structure.
463 @param TextDeviceNode The input Text device path node.
465 @return A pointer to Hardware PC card device path structure.
468 EFI_DEVICE_PATH_PROTOCOL
*
469 DevPathFromTextPcCard (
470 IN CHAR16
*TextDeviceNode
473 CHAR16
*FunctionNumberStr
;
474 PCCARD_DEVICE_PATH
*Pccard
;
476 FunctionNumberStr
= GetNextParamStr (&TextDeviceNode
);
477 Pccard
= (PCCARD_DEVICE_PATH
*) CreateDeviceNode (
478 HARDWARE_DEVICE_PATH
,
480 (UINT16
) sizeof (PCCARD_DEVICE_PATH
)
483 Pccard
->FunctionNumber
= (UINT8
) Strtoi (FunctionNumberStr
);
485 return (EFI_DEVICE_PATH_PROTOCOL
*) Pccard
;
489 Converts a text device path node to Hardware memory map device path structure.
491 @param TextDeviceNode The input Text device path node.
493 @return A pointer to Hardware memory map device path structure.
496 EFI_DEVICE_PATH_PROTOCOL
*
497 DevPathFromTextMemoryMapped (
498 IN CHAR16
*TextDeviceNode
501 CHAR16
*MemoryTypeStr
;
502 CHAR16
*StartingAddressStr
;
503 CHAR16
*EndingAddressStr
;
504 MEMMAP_DEVICE_PATH
*MemMap
;
506 MemoryTypeStr
= GetNextParamStr (&TextDeviceNode
);
507 StartingAddressStr
= GetNextParamStr (&TextDeviceNode
);
508 EndingAddressStr
= GetNextParamStr (&TextDeviceNode
);
509 MemMap
= (MEMMAP_DEVICE_PATH
*) CreateDeviceNode (
510 HARDWARE_DEVICE_PATH
,
512 (UINT16
) sizeof (MEMMAP_DEVICE_PATH
)
515 MemMap
->MemoryType
= (UINT32
) Strtoi (MemoryTypeStr
);
516 Strtoi64 (StartingAddressStr
, &MemMap
->StartingAddress
);
517 Strtoi64 (EndingAddressStr
, &MemMap
->EndingAddress
);
519 return (EFI_DEVICE_PATH_PROTOCOL
*) MemMap
;
523 Converts a text device path node to Vendor device path structure based on the input Type
526 @param TextDeviceNode The input Text device path node.
527 @param Type The type of device path node.
528 @param SubType The subtype of device path node.
530 @return A pointer to the newly-created Vendor device path structure.
533 EFI_DEVICE_PATH_PROTOCOL
*
534 ConvertFromTextVendor (
535 IN CHAR16
*TextDeviceNode
,
543 VENDOR_DEVICE_PATH
*Vendor
;
545 GuidStr
= GetNextParamStr (&TextDeviceNode
);
547 DataStr
= GetNextParamStr (&TextDeviceNode
);
548 Length
= StrLen (DataStr
);
550 // Two hex characters make up 1 buffer byte
552 Length
= (Length
+ 1) / 2;
554 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
557 (UINT16
) (sizeof (VENDOR_DEVICE_PATH
) + Length
)
560 StrToGuid (GuidStr
, &Vendor
->Guid
);
561 StrHexToBytes (DataStr
, Length
* 2, (UINT8
*) (Vendor
+ 1), Length
);
563 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
567 Converts a text device path node to Vendor Hardware device path structure.
569 @param TextDeviceNode The input Text device path node.
571 @return A pointer to the newly-created Vendor Hardware device path structure.
574 EFI_DEVICE_PATH_PROTOCOL
*
575 DevPathFromTextVenHw (
576 IN CHAR16
*TextDeviceNode
579 return ConvertFromTextVendor (
581 HARDWARE_DEVICE_PATH
,
587 Converts a text device path node to Hardware Controller device path structure.
589 @param TextDeviceNode The input Text device path node.
591 @return A pointer to the newly-created Hardware Controller device path structure.
594 EFI_DEVICE_PATH_PROTOCOL
*
595 DevPathFromTextCtrl (
596 IN CHAR16
*TextDeviceNode
599 CHAR16
*ControllerStr
;
600 CONTROLLER_DEVICE_PATH
*Controller
;
602 ControllerStr
= GetNextParamStr (&TextDeviceNode
);
603 Controller
= (CONTROLLER_DEVICE_PATH
*) CreateDeviceNode (
604 HARDWARE_DEVICE_PATH
,
606 (UINT16
) sizeof (CONTROLLER_DEVICE_PATH
)
608 Controller
->ControllerNumber
= (UINT32
) Strtoi (ControllerStr
);
610 return (EFI_DEVICE_PATH_PROTOCOL
*) Controller
;
614 Converts a text device path node to BMC device path structure.
616 @param TextDeviceNode The input Text device path node.
618 @return A pointer to the newly-created BMC device path structure.
621 EFI_DEVICE_PATH_PROTOCOL
*
623 IN CHAR16
*TextDeviceNode
626 CHAR16
*InterfaceTypeStr
;
627 CHAR16
*BaseAddressStr
;
628 BMC_DEVICE_PATH
*BmcDp
;
630 InterfaceTypeStr
= GetNextParamStr (&TextDeviceNode
);
631 BaseAddressStr
= GetNextParamStr (&TextDeviceNode
);
632 BmcDp
= (BMC_DEVICE_PATH
*) CreateDeviceNode (
633 HARDWARE_DEVICE_PATH
,
635 (UINT16
) sizeof (BMC_DEVICE_PATH
)
638 BmcDp
->InterfaceType
= (UINT8
) Strtoi (InterfaceTypeStr
);
640 (UINT64
*) (&BmcDp
->BaseAddress
),
641 StrHexToUint64 (BaseAddressStr
)
644 return (EFI_DEVICE_PATH_PROTOCOL
*) BmcDp
;
648 Converts a generic ACPI text device path node to ACPI device path structure.
650 @param TextDeviceNode The input Text device path node.
652 @return A pointer to ACPI device path structure.
655 EFI_DEVICE_PATH_PROTOCOL
*
656 DevPathFromTextAcpiPath (
657 IN CHAR16
*TextDeviceNode
660 return DevPathFromTextGenericPath (ACPI_DEVICE_PATH
, TextDeviceNode
);
664 Converts a string to EisaId.
666 @param Text The input string.
668 @return UINT32 EISA ID.
675 return (((Text
[0] - 'A' + 1) & 0x1f) << 10)
676 + (((Text
[1] - 'A' + 1) & 0x1f) << 5)
677 + (((Text
[2] - 'A' + 1) & 0x1f) << 0)
678 + (UINT32
) (StrHexToUintn (&Text
[3]) << 16)
683 Converts a text device path node to ACPI HID device path structure.
685 @param TextDeviceNode The input Text device path node.
687 @return A pointer to the newly-created ACPI HID device path structure.
690 EFI_DEVICE_PATH_PROTOCOL
*
691 DevPathFromTextAcpi (
692 IN CHAR16
*TextDeviceNode
697 ACPI_HID_DEVICE_PATH
*Acpi
;
699 HIDStr
= GetNextParamStr (&TextDeviceNode
);
700 UIDStr
= GetNextParamStr (&TextDeviceNode
);
701 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
704 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
707 Acpi
->HID
= EisaIdFromText (HIDStr
);
708 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
710 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
714 Converts a text device path node to ACPI HID device path structure.
716 @param TextDeviceNode The input Text device path node.
717 @param PnPId The input plug and play identification.
719 @return A pointer to the newly-created ACPI HID device path structure.
722 EFI_DEVICE_PATH_PROTOCOL
*
723 ConvertFromTextAcpi (
724 IN CHAR16
*TextDeviceNode
,
729 ACPI_HID_DEVICE_PATH
*Acpi
;
731 UIDStr
= GetNextParamStr (&TextDeviceNode
);
732 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
735 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
738 Acpi
->HID
= EFI_PNP_ID (PnPId
);
739 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
741 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
745 Converts a text device path node to PCI root device path structure.
747 @param TextDeviceNode The input Text device path node.
749 @return A pointer to the newly-created PCI root device path structure.
752 EFI_DEVICE_PATH_PROTOCOL
*
753 DevPathFromTextPciRoot (
754 IN CHAR16
*TextDeviceNode
757 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a03);
761 Converts a text device path node to PCIE root device path structure.
763 @param TextDeviceNode The input Text device path node.
765 @return A pointer to the newly-created PCIE root device path structure.
768 EFI_DEVICE_PATH_PROTOCOL
*
769 DevPathFromTextPcieRoot (
770 IN CHAR16
*TextDeviceNode
773 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a08);
777 Converts a text device path node to Floppy device path structure.
779 @param TextDeviceNode The input Text device path node.
781 @return A pointer to the newly-created Floppy device path structure.
784 EFI_DEVICE_PATH_PROTOCOL
*
785 DevPathFromTextFloppy (
786 IN CHAR16
*TextDeviceNode
789 return ConvertFromTextAcpi (TextDeviceNode
, 0x0604);
793 Converts a text device path node to Keyboard device path structure.
795 @param TextDeviceNode The input Text device path node.
797 @return A pointer to the newly-created Keyboard device path structure.
800 EFI_DEVICE_PATH_PROTOCOL
*
801 DevPathFromTextKeyboard (
802 IN CHAR16
*TextDeviceNode
805 return ConvertFromTextAcpi (TextDeviceNode
, 0x0301);
809 Converts a text device path node to Serial device path structure.
811 @param TextDeviceNode The input Text device path node.
813 @return A pointer to the newly-created Serial device path structure.
816 EFI_DEVICE_PATH_PROTOCOL
*
817 DevPathFromTextSerial (
818 IN CHAR16
*TextDeviceNode
821 return ConvertFromTextAcpi (TextDeviceNode
, 0x0501);
825 Converts a text device path node to Parallel Port device path structure.
827 @param TextDeviceNode The input Text device path node.
829 @return A pointer to the newly-created Parallel Port device path structure.
832 EFI_DEVICE_PATH_PROTOCOL
*
833 DevPathFromTextParallelPort (
834 IN CHAR16
*TextDeviceNode
837 return ConvertFromTextAcpi (TextDeviceNode
, 0x0401);
841 Converts a text device path node to ACPI extension device path structure.
843 @param TextDeviceNode The input Text device path node.
845 @return A pointer to the newly-created ACPI extension device path structure.
848 EFI_DEVICE_PATH_PROTOCOL
*
849 DevPathFromTextAcpiEx (
850 IN CHAR16
*TextDeviceNode
861 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
863 HIDStr
= GetNextParamStr (&TextDeviceNode
);
864 CIDStr
= GetNextParamStr (&TextDeviceNode
);
865 UIDStr
= GetNextParamStr (&TextDeviceNode
);
866 HIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
867 CIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
868 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
870 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (HIDSTRStr
) + 1);
871 Length
= (UINT16
) (Length
+ StrLen (UIDSTRStr
) + 1);
872 Length
= (UINT16
) (Length
+ StrLen (CIDSTRStr
) + 1);
873 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
879 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
880 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
881 AcpiEx
->UID
= (UINT32
) Strtoi (UIDStr
);
883 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
884 StrToAscii (HIDSTRStr
, &AsciiStr
);
885 StrToAscii (UIDSTRStr
, &AsciiStr
);
886 StrToAscii (CIDSTRStr
, &AsciiStr
);
888 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
892 Converts a text device path node to ACPI extension device path structure.
894 @param TextDeviceNode The input Text device path node.
896 @return A pointer to the newly-created ACPI extension device path structure.
899 EFI_DEVICE_PATH_PROTOCOL
*
900 DevPathFromTextAcpiExp (
901 IN CHAR16
*TextDeviceNode
909 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
911 HIDStr
= GetNextParamStr (&TextDeviceNode
);
912 CIDStr
= GetNextParamStr (&TextDeviceNode
);
913 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
914 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (UIDSTRStr
) + 3);
915 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
921 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
923 // According to UEFI spec, the CID parametr is optional and has a default value of 0.
924 // So when the CID parametr is not specified or specified as 0 in the text device node.
925 // Set the CID to 0 in the ACPI extension device path structure.
927 if (*CIDStr
== L
'\0' || *CIDStr
== L
'0') {
930 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
934 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
936 // HID string is NULL
940 // Convert UID string
943 StrToAscii (UIDSTRStr
, &AsciiStr
);
945 // CID string is NULL
949 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
953 Converts a text device path node to ACPI _ADR device path structure.
955 @param TextDeviceNode The input Text device path node.
957 @return A pointer to the newly-created ACPI _ADR device path structure.
960 EFI_DEVICE_PATH_PROTOCOL
*
961 DevPathFromTextAcpiAdr (
962 IN CHAR16
*TextDeviceNode
965 CHAR16
*DisplayDeviceStr
;
966 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
970 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*) CreateDeviceNode (
973 (UINT16
) sizeof (ACPI_ADR_DEVICE_PATH
)
975 ASSERT (AcpiAdr
!= NULL
);
977 for (Index
= 0; ; Index
++) {
978 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
979 if (IS_NULL (*DisplayDeviceStr
)) {
983 Length
= DevicePathNodeLength (AcpiAdr
);
984 AcpiAdr
= ReallocatePool (
986 Length
+ sizeof (UINT32
),
989 ASSERT (AcpiAdr
!= NULL
);
990 SetDevicePathNodeLength (AcpiAdr
, Length
+ sizeof (UINT32
));
993 (&AcpiAdr
->ADR
)[Index
] = (UINT32
) Strtoi (DisplayDeviceStr
);
996 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
;
1000 Converts a generic messaging text device path node to messaging device path structure.
1002 @param TextDeviceNode The input Text device path node.
1004 @return A pointer to messaging device path structure.
1007 EFI_DEVICE_PATH_PROTOCOL
*
1008 DevPathFromTextMsg (
1009 IN CHAR16
*TextDeviceNode
1012 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH
, TextDeviceNode
);
1016 Converts a text device path node to Parallel Port device path structure.
1018 @param TextDeviceNode The input Text device path node.
1020 @return A pointer to the newly-created Parallel Port device path structure.
1023 EFI_DEVICE_PATH_PROTOCOL
*
1024 DevPathFromTextAta (
1025 IN CHAR16
*TextDeviceNode
1028 CHAR16
*PrimarySecondaryStr
;
1029 CHAR16
*SlaveMasterStr
;
1031 ATAPI_DEVICE_PATH
*Atapi
;
1033 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
1034 MESSAGING_DEVICE_PATH
,
1036 (UINT16
) sizeof (ATAPI_DEVICE_PATH
)
1039 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
1040 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
1041 LunStr
= GetNextParamStr (&TextDeviceNode
);
1043 if (StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) {
1044 Atapi
->PrimarySecondary
= 0;
1045 } else if (StrCmp (PrimarySecondaryStr
, L
"Secondary") == 0) {
1046 Atapi
->PrimarySecondary
= 1;
1048 Atapi
->PrimarySecondary
= (UINT8
) Strtoi (PrimarySecondaryStr
);
1050 if (StrCmp (SlaveMasterStr
, L
"Master") == 0) {
1051 Atapi
->SlaveMaster
= 0;
1052 } else if (StrCmp (SlaveMasterStr
, L
"Slave") == 0) {
1053 Atapi
->SlaveMaster
= 1;
1055 Atapi
->SlaveMaster
= (UINT8
) Strtoi (SlaveMasterStr
);
1058 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
1060 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
1064 Converts a text device path node to SCSI device path structure.
1066 @param TextDeviceNode The input Text device path node.
1068 @return A pointer to the newly-created SCSI device path structure.
1071 EFI_DEVICE_PATH_PROTOCOL
*
1072 DevPathFromTextScsi (
1073 IN CHAR16
*TextDeviceNode
1078 SCSI_DEVICE_PATH
*Scsi
;
1080 PunStr
= GetNextParamStr (&TextDeviceNode
);
1081 LunStr
= GetNextParamStr (&TextDeviceNode
);
1082 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
1083 MESSAGING_DEVICE_PATH
,
1085 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
1088 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
1089 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
1091 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
1095 Converts a text device path node to Fibre device path structure.
1097 @param TextDeviceNode The input Text device path node.
1099 @return A pointer to the newly-created Fibre device path structure.
1102 EFI_DEVICE_PATH_PROTOCOL
*
1103 DevPathFromTextFibre (
1104 IN CHAR16
*TextDeviceNode
1109 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
1111 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1112 LunStr
= GetNextParamStr (&TextDeviceNode
);
1113 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
1114 MESSAGING_DEVICE_PATH
,
1115 MSG_FIBRECHANNEL_DP
,
1116 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
1119 Fibre
->Reserved
= 0;
1120 Strtoi64 (WWNStr
, &Fibre
->WWN
);
1121 Strtoi64 (LunStr
, &Fibre
->Lun
);
1123 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
1127 Converts a text device path node to FibreEx device path structure.
1129 @param TextDeviceNode The input Text device path node.
1131 @return A pointer to the newly-created FibreEx device path structure.
1134 EFI_DEVICE_PATH_PROTOCOL
*
1135 DevPathFromTextFibreEx (
1136 IN CHAR16
*TextDeviceNode
1141 FIBRECHANNELEX_DEVICE_PATH
*FibreEx
;
1143 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1144 LunStr
= GetNextParamStr (&TextDeviceNode
);
1145 FibreEx
= (FIBRECHANNELEX_DEVICE_PATH
*) CreateDeviceNode (
1146 MESSAGING_DEVICE_PATH
,
1147 MSG_FIBRECHANNELEX_DP
,
1148 (UINT16
) sizeof (FIBRECHANNELEX_DEVICE_PATH
)
1151 FibreEx
->Reserved
= 0;
1152 Strtoi64 (WWNStr
, (UINT64
*) (&FibreEx
->WWN
));
1153 Strtoi64 (LunStr
, (UINT64
*) (&FibreEx
->Lun
));
1155 *(UINT64
*) (&FibreEx
->WWN
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->WWN
));
1156 *(UINT64
*) (&FibreEx
->Lun
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->Lun
));
1158 return (EFI_DEVICE_PATH_PROTOCOL
*) FibreEx
;
1162 Converts a text device path node to 1394 device path structure.
1164 @param TextDeviceNode The input Text device path node.
1166 @return A pointer to the newly-created 1394 device path structure.
1169 EFI_DEVICE_PATH_PROTOCOL
*
1170 DevPathFromText1394 (
1171 IN CHAR16
*TextDeviceNode
1175 F1394_DEVICE_PATH
*F1394DevPath
;
1177 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1178 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1179 MESSAGING_DEVICE_PATH
,
1181 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1184 F1394DevPath
->Reserved
= 0;
1185 F1394DevPath
->Guid
= StrHexToUint64 (GuidStr
);
1187 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1191 Converts a text device path node to USB device path structure.
1193 @param TextDeviceNode The input Text device path node.
1195 @return A pointer to the newly-created USB device path structure.
1198 EFI_DEVICE_PATH_PROTOCOL
*
1199 DevPathFromTextUsb (
1200 IN CHAR16
*TextDeviceNode
1204 CHAR16
*InterfaceStr
;
1205 USB_DEVICE_PATH
*Usb
;
1207 PortStr
= GetNextParamStr (&TextDeviceNode
);
1208 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1209 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1210 MESSAGING_DEVICE_PATH
,
1212 (UINT16
) sizeof (USB_DEVICE_PATH
)
1215 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1216 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1218 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1222 Converts a text device path node to I20 device path structure.
1224 @param TextDeviceNode The input Text device path node.
1226 @return A pointer to the newly-created I20 device path structure.
1229 EFI_DEVICE_PATH_PROTOCOL
*
1230 DevPathFromTextI2O (
1231 IN CHAR16
*TextDeviceNode
1235 I2O_DEVICE_PATH
*I2ODevPath
;
1237 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1238 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1239 MESSAGING_DEVICE_PATH
,
1241 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1244 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1246 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1250 Converts a text device path node to Infini Band device path structure.
1252 @param TextDeviceNode The input Text device path node.
1254 @return A pointer to the newly-created Infini Band device path structure.
1257 EFI_DEVICE_PATH_PROTOCOL
*
1258 DevPathFromTextInfiniband (
1259 IN CHAR16
*TextDeviceNode
1267 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1269 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1270 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1271 SidStr
= GetNextParamStr (&TextDeviceNode
);
1272 TidStr
= GetNextParamStr (&TextDeviceNode
);
1273 DidStr
= GetNextParamStr (&TextDeviceNode
);
1274 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1275 MESSAGING_DEVICE_PATH
,
1277 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1280 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1281 StrToGuid (GuidStr
, (EFI_GUID
*) InfiniBand
->PortGid
);
1282 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1283 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1284 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1286 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1290 Converts a text device path node to Vendor-Defined Messaging device path structure.
1292 @param TextDeviceNode The input Text device path node.
1294 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1297 EFI_DEVICE_PATH_PROTOCOL
*
1298 DevPathFromTextVenMsg (
1299 IN CHAR16
*TextDeviceNode
1302 return ConvertFromTextVendor (
1304 MESSAGING_DEVICE_PATH
,
1310 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1312 @param TextDeviceNode The input Text device path node.
1314 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1317 EFI_DEVICE_PATH_PROTOCOL
*
1318 DevPathFromTextVenPcAnsi (
1319 IN CHAR16
*TextDeviceNode
1322 VENDOR_DEVICE_PATH
*Vendor
;
1324 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1325 MESSAGING_DEVICE_PATH
,
1327 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1328 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1330 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1334 Converts a text device path node to Vendor defined VT100 device path structure.
1336 @param TextDeviceNode The input Text device path node.
1338 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1341 EFI_DEVICE_PATH_PROTOCOL
*
1342 DevPathFromTextVenVt100 (
1343 IN CHAR16
*TextDeviceNode
1346 VENDOR_DEVICE_PATH
*Vendor
;
1348 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1349 MESSAGING_DEVICE_PATH
,
1351 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1352 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1354 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1358 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1360 @param TextDeviceNode The input Text device path node.
1362 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1365 EFI_DEVICE_PATH_PROTOCOL
*
1366 DevPathFromTextVenVt100Plus (
1367 IN CHAR16
*TextDeviceNode
1370 VENDOR_DEVICE_PATH
*Vendor
;
1372 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1373 MESSAGING_DEVICE_PATH
,
1375 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1376 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1378 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1382 Converts a text device path node to Vendor defined UTF8 device path structure.
1384 @param TextDeviceNode The input Text device path node.
1386 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1389 EFI_DEVICE_PATH_PROTOCOL
*
1390 DevPathFromTextVenUtf8 (
1391 IN CHAR16
*TextDeviceNode
1394 VENDOR_DEVICE_PATH
*Vendor
;
1396 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1397 MESSAGING_DEVICE_PATH
,
1399 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1400 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1402 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1406 Converts a text device path node to UART Flow Control device path structure.
1408 @param TextDeviceNode The input Text device path node.
1410 @return A pointer to the newly-created UART Flow Control device path structure.
1413 EFI_DEVICE_PATH_PROTOCOL
*
1414 DevPathFromTextUartFlowCtrl (
1415 IN CHAR16
*TextDeviceNode
1419 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1421 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1422 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1423 MESSAGING_DEVICE_PATH
,
1425 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1428 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1429 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1430 UartFlowControl
->FlowControlMap
= 2;
1431 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1432 UartFlowControl
->FlowControlMap
= 1;
1434 UartFlowControl
->FlowControlMap
= 0;
1437 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1441 Converts a text device path node to Serial Attached SCSI device path structure.
1443 @param TextDeviceNode The input Text device path node.
1445 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1448 EFI_DEVICE_PATH_PROTOCOL
*
1449 DevPathFromTextSAS (
1450 IN CHAR16
*TextDeviceNode
1457 CHAR16
*LocationStr
;
1459 CHAR16
*DriveBayStr
;
1460 CHAR16
*ReservedStr
;
1463 SAS_DEVICE_PATH
*Sas
;
1465 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1466 LunStr
= GetNextParamStr (&TextDeviceNode
);
1467 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1468 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1469 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1470 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1471 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1472 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1473 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1474 MESSAGING_DEVICE_PATH
,
1476 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1479 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1480 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1481 Strtoi64 (LunStr
, &Sas
->Lun
);
1482 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1484 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1487 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1489 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1493 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1496 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1501 // Location is an integer between 0 and 1 or else
1502 // the keyword Internal (0) or External (1).
1504 if (StrCmp (LocationStr
, L
"External") == 0) {
1506 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1509 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1511 Info
|= (Uint16
<< 5);
1514 // Connect is an integer between 0 and 3 or else
1515 // the keyword Direct (0) or Expanded (1).
1517 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1519 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1522 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1524 Info
|= (Uint16
<< 6);
1527 Info
= (UINT16
) Strtoi (SASSATAStr
);
1530 Sas
->DeviceTopology
= Info
;
1531 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1533 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1537 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1539 @param TextDeviceNode The input Text device path node.
1541 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1544 EFI_DEVICE_PATH_PROTOCOL
*
1545 DevPathFromTextSasEx (
1546 IN CHAR16
*TextDeviceNode
1553 CHAR16
*LocationStr
;
1555 CHAR16
*DriveBayStr
;
1560 SASEX_DEVICE_PATH
*SasEx
;
1562 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1563 LunStr
= GetNextParamStr (&TextDeviceNode
);
1564 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1565 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1566 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1567 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1568 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1569 SasEx
= (SASEX_DEVICE_PATH
*) CreateDeviceNode (
1570 MESSAGING_DEVICE_PATH
,
1572 (UINT16
) sizeof (SASEX_DEVICE_PATH
)
1575 Strtoi64 (AddressStr
, &SasAddress
);
1576 Strtoi64 (LunStr
, &Lun
);
1577 WriteUnaligned64 ((UINT64
*) &SasEx
->SasAddress
, SwapBytes64 (SasAddress
));
1578 WriteUnaligned64 ((UINT64
*) &SasEx
->Lun
, SwapBytes64 (Lun
));
1579 SasEx
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1581 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1584 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1586 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1590 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1593 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1598 // Location is an integer between 0 and 1 or else
1599 // the keyword Internal (0) or External (1).
1601 if (StrCmp (LocationStr
, L
"External") == 0) {
1603 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1606 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1608 Info
|= (Uint16
<< 5);
1611 // Connect is an integer between 0 and 3 or else
1612 // the keyword Direct (0) or Expanded (1).
1614 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1616 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1619 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1621 Info
|= (Uint16
<< 6);
1624 Info
= (UINT16
) Strtoi (SASSATAStr
);
1627 SasEx
->DeviceTopology
= Info
;
1629 return (EFI_DEVICE_PATH_PROTOCOL
*) SasEx
;
1633 Converts a text device path node to NVM Express Namespace device path structure.
1635 @param TextDeviceNode The input Text device path node.
1637 @return A pointer to the newly-created NVM Express Namespace device path structure.
1640 EFI_DEVICE_PATH_PROTOCOL
*
1641 DevPathFromTextNVMe (
1642 IN CHAR16
*TextDeviceNode
1645 CHAR16
*NamespaceIdStr
;
1646 CHAR16
*NamespaceUuidStr
;
1647 NVME_NAMESPACE_DEVICE_PATH
*Nvme
;
1651 NamespaceIdStr
= GetNextParamStr (&TextDeviceNode
);
1652 NamespaceUuidStr
= GetNextParamStr (&TextDeviceNode
);
1653 Nvme
= (NVME_NAMESPACE_DEVICE_PATH
*) CreateDeviceNode (
1654 MESSAGING_DEVICE_PATH
,
1655 MSG_NVME_NAMESPACE_DP
,
1656 (UINT16
) sizeof (NVME_NAMESPACE_DEVICE_PATH
)
1659 Nvme
->NamespaceId
= (UINT32
) Strtoi (NamespaceIdStr
);
1660 Uuid
= (UINT8
*) &Nvme
->NamespaceUuid
;
1662 Index
= sizeof (Nvme
->NamespaceUuid
) / sizeof (UINT8
);
1663 while (Index
-- != 0) {
1664 Uuid
[Index
] = (UINT8
) StrHexToUintn (SplitStr (&NamespaceUuidStr
, L
'-'));
1667 return (EFI_DEVICE_PATH_PROTOCOL
*) Nvme
;
1671 Converts a text device path node to UFS device path structure.
1673 @param TextDeviceNode The input Text device path node.
1675 @return A pointer to the newly-created UFS device path structure.
1678 EFI_DEVICE_PATH_PROTOCOL
*
1679 DevPathFromTextUfs (
1680 IN CHAR16
*TextDeviceNode
1685 UFS_DEVICE_PATH
*Ufs
;
1687 PunStr
= GetNextParamStr (&TextDeviceNode
);
1688 LunStr
= GetNextParamStr (&TextDeviceNode
);
1689 Ufs
= (UFS_DEVICE_PATH
*) CreateDeviceNode (
1690 MESSAGING_DEVICE_PATH
,
1692 (UINT16
) sizeof (UFS_DEVICE_PATH
)
1695 Ufs
->Pun
= (UINT8
) Strtoi (PunStr
);
1696 Ufs
->Lun
= (UINT8
) Strtoi (LunStr
);
1698 return (EFI_DEVICE_PATH_PROTOCOL
*) Ufs
;
1702 Converts a text device path node to SD (Secure Digital) device path structure.
1704 @param TextDeviceNode The input Text device path node.
1706 @return A pointer to the newly-created SD device path structure.
1709 EFI_DEVICE_PATH_PROTOCOL
*
1711 IN CHAR16
*TextDeviceNode
1714 CHAR16
*SlotNumberStr
;
1717 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1718 Sd
= (SD_DEVICE_PATH
*) CreateDeviceNode (
1719 MESSAGING_DEVICE_PATH
,
1721 (UINT16
) sizeof (SD_DEVICE_PATH
)
1724 Sd
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1726 return (EFI_DEVICE_PATH_PROTOCOL
*) Sd
;
1730 Converts a text device path node to EMMC (Embedded MMC) device path structure.
1732 @param TextDeviceNode The input Text device path node.
1734 @return A pointer to the newly-created EMMC device path structure.
1737 EFI_DEVICE_PATH_PROTOCOL
*
1738 DevPathFromTextEmmc (
1739 IN CHAR16
*TextDeviceNode
1742 CHAR16
*SlotNumberStr
;
1743 EMMC_DEVICE_PATH
*Emmc
;
1745 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1746 Emmc
= (EMMC_DEVICE_PATH
*) CreateDeviceNode (
1747 MESSAGING_DEVICE_PATH
,
1749 (UINT16
) sizeof (EMMC_DEVICE_PATH
)
1752 Emmc
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1754 return (EFI_DEVICE_PATH_PROTOCOL
*) Emmc
;
1758 Converts a text device path node to Debug Port device path structure.
1760 @param TextDeviceNode The input Text device path node.
1762 @return A pointer to the newly-created Debug Port device path structure.
1765 EFI_DEVICE_PATH_PROTOCOL
*
1766 DevPathFromTextDebugPort (
1767 IN CHAR16
*TextDeviceNode
1770 VENDOR_DEVICE_PATH
*Vend
;
1772 Vend
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1773 MESSAGING_DEVICE_PATH
,
1775 (UINT16
) sizeof (VENDOR_DEVICE_PATH
)
1778 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1780 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1784 Converts a text device path node to MAC device path structure.
1786 @param TextDeviceNode The input Text device path node.
1788 @return A pointer to the newly-created MAC device path structure.
1791 EFI_DEVICE_PATH_PROTOCOL
*
1792 DevPathFromTextMAC (
1793 IN CHAR16
*TextDeviceNode
1799 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1801 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1802 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1803 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1804 MESSAGING_DEVICE_PATH
,
1806 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1809 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1811 Length
= sizeof (EFI_MAC_ADDRESS
);
1812 if (MACDevPath
->IfType
== 0x01 || MACDevPath
->IfType
== 0x00) {
1816 StrHexToBytes (AddressStr
, Length
* 2, MACDevPath
->MacAddress
.Addr
, Length
);
1818 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1823 Converts a text format to the network protocol ID.
1825 @param Text String of protocol field.
1827 @return Network protocol ID .
1831 NetworkProtocolFromText (
1835 if (StrCmp (Text
, L
"UDP") == 0) {
1836 return RFC_1700_UDP_PROTOCOL
;
1839 if (StrCmp (Text
, L
"TCP") == 0) {
1840 return RFC_1700_TCP_PROTOCOL
;
1843 return Strtoi (Text
);
1848 Converts a text device path node to IPV4 device path structure.
1850 @param TextDeviceNode The input Text device path node.
1852 @return A pointer to the newly-created IPV4 device path structure.
1855 EFI_DEVICE_PATH_PROTOCOL
*
1856 DevPathFromTextIPv4 (
1857 IN CHAR16
*TextDeviceNode
1860 CHAR16
*RemoteIPStr
;
1861 CHAR16
*ProtocolStr
;
1864 CHAR16
*GatewayIPStr
;
1865 CHAR16
*SubnetMaskStr
;
1866 IPv4_DEVICE_PATH
*IPv4
;
1868 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1869 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1870 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1871 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1872 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1873 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
1874 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1875 MESSAGING_DEVICE_PATH
,
1877 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
1880 StrToIpv4Address (RemoteIPStr
, NULL
, &IPv4
->RemoteIpAddress
, NULL
);
1881 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1882 if (StrCmp (TypeStr
, L
"Static") == 0) {
1883 IPv4
->StaticIpAddress
= TRUE
;
1885 IPv4
->StaticIpAddress
= FALSE
;
1888 StrToIpv4Address (LocalIPStr
, NULL
, &IPv4
->LocalIpAddress
, NULL
);
1889 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
1890 StrToIpv4Address (GatewayIPStr
, NULL
, &IPv4
->GatewayIpAddress
, NULL
);
1891 StrToIpv4Address (SubnetMaskStr
, NULL
, &IPv4
->SubnetMask
, NULL
);
1893 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
1894 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
1897 IPv4
->LocalPort
= 0;
1898 IPv4
->RemotePort
= 0;
1900 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1904 Converts a text device path node to IPV6 device path structure.
1906 @param TextDeviceNode The input Text device path node.
1908 @return A pointer to the newly-created IPV6 device path structure.
1911 EFI_DEVICE_PATH_PROTOCOL
*
1912 DevPathFromTextIPv6 (
1913 IN CHAR16
*TextDeviceNode
1916 CHAR16
*RemoteIPStr
;
1917 CHAR16
*ProtocolStr
;
1920 CHAR16
*GatewayIPStr
;
1921 CHAR16
*PrefixLengthStr
;
1922 IPv6_DEVICE_PATH
*IPv6
;
1924 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1925 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1926 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1927 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1928 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
1929 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1930 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1931 MESSAGING_DEVICE_PATH
,
1933 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
1936 StrToIpv6Address (RemoteIPStr
, NULL
, &IPv6
->RemoteIpAddress
, NULL
);
1937 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1938 if (StrCmp (TypeStr
, L
"Static") == 0) {
1939 IPv6
->IpAddressOrigin
= 0;
1940 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
1941 IPv6
->IpAddressOrigin
= 1;
1943 IPv6
->IpAddressOrigin
= 2;
1946 StrToIpv6Address (LocalIPStr
, NULL
, &IPv6
->LocalIpAddress
, NULL
);
1947 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
1948 StrToIpv6Address (GatewayIPStr
, NULL
, &IPv6
->GatewayIpAddress
, NULL
);
1949 IPv6
->PrefixLength
= (UINT8
) Strtoi (PrefixLengthStr
);
1951 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
1952 IPv6
->PrefixLength
= 0;
1955 IPv6
->LocalPort
= 0;
1956 IPv6
->RemotePort
= 0;
1958 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
1962 Converts a text device path node to UART device path structure.
1964 @param TextDeviceNode The input Text device path node.
1966 @return A pointer to the newly-created UART device path structure.
1969 EFI_DEVICE_PATH_PROTOCOL
*
1970 DevPathFromTextUart (
1971 IN CHAR16
*TextDeviceNode
1975 CHAR16
*DataBitsStr
;
1977 CHAR16
*StopBitsStr
;
1978 UART_DEVICE_PATH
*Uart
;
1980 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1981 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1982 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1983 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1984 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
1985 MESSAGING_DEVICE_PATH
,
1987 (UINT16
) sizeof (UART_DEVICE_PATH
)
1990 if (StrCmp (BaudStr
, L
"DEFAULT") == 0) {
1991 Uart
->BaudRate
= 115200;
1993 Strtoi64 (BaudStr
, &Uart
->BaudRate
);
1995 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr
));
1996 switch (*ParityStr
) {
2022 Uart
->Parity
= (UINT8
) Strtoi (ParityStr
);
2026 if (StrCmp (StopBitsStr
, L
"D") == 0) {
2027 Uart
->StopBits
= (UINT8
) 0;
2028 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
2029 Uart
->StopBits
= (UINT8
) 1;
2030 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
2031 Uart
->StopBits
= (UINT8
) 2;
2032 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
2033 Uart
->StopBits
= (UINT8
) 3;
2035 Uart
->StopBits
= (UINT8
) Strtoi (StopBitsStr
);
2038 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
2042 Converts a text device path node to USB class device path structure.
2044 @param TextDeviceNode The input Text device path node.
2045 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
2047 @return A pointer to the newly-created USB class device path structure.
2050 EFI_DEVICE_PATH_PROTOCOL
*
2051 ConvertFromTextUsbClass (
2052 IN CHAR16
*TextDeviceNode
,
2053 IN USB_CLASS_TEXT
*UsbClassText
2059 CHAR16
*SubClassStr
;
2060 CHAR16
*ProtocolStr
;
2061 USB_CLASS_DEVICE_PATH
*UsbClass
;
2063 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
2064 MESSAGING_DEVICE_PATH
,
2066 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
2069 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2070 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2071 if (UsbClassText
->ClassExist
) {
2072 ClassStr
= GetNextParamStr (&TextDeviceNode
);
2073 if (*ClassStr
== L
'\0') {
2074 UsbClass
->DeviceClass
= 0xFF;
2076 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
2079 UsbClass
->DeviceClass
= UsbClassText
->Class
;
2081 if (UsbClassText
->SubClassExist
) {
2082 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
2083 if (*SubClassStr
== L
'\0') {
2084 UsbClass
->DeviceSubClass
= 0xFF;
2086 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
2089 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
2092 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2094 if (*VIDStr
== L
'\0') {
2095 UsbClass
->VendorId
= 0xFFFF;
2097 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2099 if (*PIDStr
== L
'\0') {
2100 UsbClass
->ProductId
= 0xFFFF;
2102 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2104 if (*ProtocolStr
== L
'\0') {
2105 UsbClass
->DeviceProtocol
= 0xFF;
2107 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
2110 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
2115 Converts a text device path node to USB class device path structure.
2117 @param TextDeviceNode The input Text device path node.
2119 @return A pointer to the newly-created USB class device path structure.
2122 EFI_DEVICE_PATH_PROTOCOL
*
2123 DevPathFromTextUsbClass (
2124 IN CHAR16
*TextDeviceNode
2127 USB_CLASS_TEXT UsbClassText
;
2129 UsbClassText
.ClassExist
= TRUE
;
2130 UsbClassText
.SubClassExist
= TRUE
;
2132 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2136 Converts a text device path node to USB audio device path structure.
2138 @param TextDeviceNode The input Text device path node.
2140 @return A pointer to the newly-created USB audio device path structure.
2143 EFI_DEVICE_PATH_PROTOCOL
*
2144 DevPathFromTextUsbAudio (
2145 IN CHAR16
*TextDeviceNode
2148 USB_CLASS_TEXT UsbClassText
;
2150 UsbClassText
.ClassExist
= FALSE
;
2151 UsbClassText
.Class
= USB_CLASS_AUDIO
;
2152 UsbClassText
.SubClassExist
= TRUE
;
2154 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2158 Converts a text device path node to USB CDC Control device path structure.
2160 @param TextDeviceNode The input Text device path node.
2162 @return A pointer to the newly-created USB CDC Control device path structure.
2165 EFI_DEVICE_PATH_PROTOCOL
*
2166 DevPathFromTextUsbCDCControl (
2167 IN CHAR16
*TextDeviceNode
2170 USB_CLASS_TEXT UsbClassText
;
2172 UsbClassText
.ClassExist
= FALSE
;
2173 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
2174 UsbClassText
.SubClassExist
= TRUE
;
2176 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2180 Converts a text device path node to USB HID device path structure.
2182 @param TextDeviceNode The input Text device path node.
2184 @return A pointer to the newly-created USB HID device path structure.
2187 EFI_DEVICE_PATH_PROTOCOL
*
2188 DevPathFromTextUsbHID (
2189 IN CHAR16
*TextDeviceNode
2192 USB_CLASS_TEXT UsbClassText
;
2194 UsbClassText
.ClassExist
= FALSE
;
2195 UsbClassText
.Class
= USB_CLASS_HID
;
2196 UsbClassText
.SubClassExist
= TRUE
;
2198 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2202 Converts a text device path node to USB Image device path structure.
2204 @param TextDeviceNode The input Text device path node.
2206 @return A pointer to the newly-created USB Image device path structure.
2209 EFI_DEVICE_PATH_PROTOCOL
*
2210 DevPathFromTextUsbImage (
2211 IN CHAR16
*TextDeviceNode
2214 USB_CLASS_TEXT UsbClassText
;
2216 UsbClassText
.ClassExist
= FALSE
;
2217 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2218 UsbClassText
.SubClassExist
= TRUE
;
2220 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2224 Converts a text device path node to USB Print device path structure.
2226 @param TextDeviceNode The input Text device path node.
2228 @return A pointer to the newly-created USB Print device path structure.
2231 EFI_DEVICE_PATH_PROTOCOL
*
2232 DevPathFromTextUsbPrinter (
2233 IN CHAR16
*TextDeviceNode
2236 USB_CLASS_TEXT UsbClassText
;
2238 UsbClassText
.ClassExist
= FALSE
;
2239 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2240 UsbClassText
.SubClassExist
= TRUE
;
2242 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2246 Converts a text device path node to USB mass storage device path structure.
2248 @param TextDeviceNode The input Text device path node.
2250 @return A pointer to the newly-created USB mass storage device path structure.
2253 EFI_DEVICE_PATH_PROTOCOL
*
2254 DevPathFromTextUsbMassStorage (
2255 IN CHAR16
*TextDeviceNode
2258 USB_CLASS_TEXT UsbClassText
;
2260 UsbClassText
.ClassExist
= FALSE
;
2261 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2262 UsbClassText
.SubClassExist
= TRUE
;
2264 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2268 Converts a text device path node to USB HUB device path structure.
2270 @param TextDeviceNode The input Text device path node.
2272 @return A pointer to the newly-created USB HUB device path structure.
2275 EFI_DEVICE_PATH_PROTOCOL
*
2276 DevPathFromTextUsbHub (
2277 IN CHAR16
*TextDeviceNode
2280 USB_CLASS_TEXT UsbClassText
;
2282 UsbClassText
.ClassExist
= FALSE
;
2283 UsbClassText
.Class
= USB_CLASS_HUB
;
2284 UsbClassText
.SubClassExist
= TRUE
;
2286 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2290 Converts a text device path node to USB CDC data device path structure.
2292 @param TextDeviceNode The input Text device path node.
2294 @return A pointer to the newly-created USB CDC data device path structure.
2297 EFI_DEVICE_PATH_PROTOCOL
*
2298 DevPathFromTextUsbCDCData (
2299 IN CHAR16
*TextDeviceNode
2302 USB_CLASS_TEXT UsbClassText
;
2304 UsbClassText
.ClassExist
= FALSE
;
2305 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2306 UsbClassText
.SubClassExist
= TRUE
;
2308 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2312 Converts a text device path node to USB smart card device path structure.
2314 @param TextDeviceNode The input Text device path node.
2316 @return A pointer to the newly-created USB smart card device path structure.
2319 EFI_DEVICE_PATH_PROTOCOL
*
2320 DevPathFromTextUsbSmartCard (
2321 IN CHAR16
*TextDeviceNode
2324 USB_CLASS_TEXT UsbClassText
;
2326 UsbClassText
.ClassExist
= FALSE
;
2327 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2328 UsbClassText
.SubClassExist
= TRUE
;
2330 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2334 Converts a text device path node to USB video device path structure.
2336 @param TextDeviceNode The input Text device path node.
2338 @return A pointer to the newly-created USB video device path structure.
2341 EFI_DEVICE_PATH_PROTOCOL
*
2342 DevPathFromTextUsbVideo (
2343 IN CHAR16
*TextDeviceNode
2346 USB_CLASS_TEXT UsbClassText
;
2348 UsbClassText
.ClassExist
= FALSE
;
2349 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2350 UsbClassText
.SubClassExist
= TRUE
;
2352 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2356 Converts a text device path node to USB diagnostic device path structure.
2358 @param TextDeviceNode The input Text device path node.
2360 @return A pointer to the newly-created USB diagnostic device path structure.
2363 EFI_DEVICE_PATH_PROTOCOL
*
2364 DevPathFromTextUsbDiagnostic (
2365 IN CHAR16
*TextDeviceNode
2368 USB_CLASS_TEXT UsbClassText
;
2370 UsbClassText
.ClassExist
= FALSE
;
2371 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2372 UsbClassText
.SubClassExist
= TRUE
;
2374 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2378 Converts a text device path node to USB wireless device path structure.
2380 @param TextDeviceNode The input Text device path node.
2382 @return A pointer to the newly-created USB wireless device path structure.
2385 EFI_DEVICE_PATH_PROTOCOL
*
2386 DevPathFromTextUsbWireless (
2387 IN CHAR16
*TextDeviceNode
2390 USB_CLASS_TEXT UsbClassText
;
2392 UsbClassText
.ClassExist
= FALSE
;
2393 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2394 UsbClassText
.SubClassExist
= TRUE
;
2396 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2400 Converts a text device path node to USB device firmware update device path structure.
2402 @param TextDeviceNode The input Text device path node.
2404 @return A pointer to the newly-created USB device firmware update device path structure.
2407 EFI_DEVICE_PATH_PROTOCOL
*
2408 DevPathFromTextUsbDeviceFirmwareUpdate (
2409 IN CHAR16
*TextDeviceNode
2412 USB_CLASS_TEXT UsbClassText
;
2414 UsbClassText
.ClassExist
= FALSE
;
2415 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2416 UsbClassText
.SubClassExist
= FALSE
;
2417 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2419 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2423 Converts a text device path node to USB IRDA bridge device path structure.
2425 @param TextDeviceNode The input Text device path node.
2427 @return A pointer to the newly-created USB IRDA bridge device path structure.
2430 EFI_DEVICE_PATH_PROTOCOL
*
2431 DevPathFromTextUsbIrdaBridge (
2432 IN CHAR16
*TextDeviceNode
2435 USB_CLASS_TEXT UsbClassText
;
2437 UsbClassText
.ClassExist
= FALSE
;
2438 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2439 UsbClassText
.SubClassExist
= FALSE
;
2440 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2442 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2446 Converts a text device path node to USB text and measurement device path structure.
2448 @param TextDeviceNode The input Text device path node.
2450 @return A pointer to the newly-created USB text and measurement device path structure.
2453 EFI_DEVICE_PATH_PROTOCOL
*
2454 DevPathFromTextUsbTestAndMeasurement (
2455 IN CHAR16
*TextDeviceNode
2458 USB_CLASS_TEXT UsbClassText
;
2460 UsbClassText
.ClassExist
= FALSE
;
2461 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2462 UsbClassText
.SubClassExist
= FALSE
;
2463 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2465 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2469 Converts a text device path node to USB WWID device path structure.
2471 @param TextDeviceNode The input Text device path node.
2473 @return A pointer to the newly-created USB WWID device path structure.
2476 EFI_DEVICE_PATH_PROTOCOL
*
2477 DevPathFromTextUsbWwid (
2478 IN CHAR16
*TextDeviceNode
2483 CHAR16
*InterfaceNumStr
;
2484 CHAR16
*SerialNumberStr
;
2485 USB_WWID_DEVICE_PATH
*UsbWwid
;
2486 UINTN SerialNumberStrLen
;
2488 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2489 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2490 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2491 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2492 SerialNumberStrLen
= StrLen (SerialNumberStr
);
2493 if (SerialNumberStrLen
>= 2 &&
2494 SerialNumberStr
[0] == L
'\"' &&
2495 SerialNumberStr
[SerialNumberStrLen
- 1] == L
'\"'
2497 SerialNumberStr
[SerialNumberStrLen
- 1] = L
'\0';
2499 SerialNumberStrLen
-= 2;
2501 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2502 MESSAGING_DEVICE_PATH
,
2504 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + SerialNumberStrLen
* sizeof (CHAR16
))
2506 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2507 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2508 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2511 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
2512 // Therefore, the '\0' will not be copied.
2515 (UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
),
2517 SerialNumberStrLen
* sizeof (CHAR16
)
2520 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2524 Converts a text device path node to Logic Unit device path structure.
2526 @param TextDeviceNode The input Text device path node.
2528 @return A pointer to the newly-created Logic Unit device path structure.
2531 EFI_DEVICE_PATH_PROTOCOL
*
2532 DevPathFromTextUnit (
2533 IN CHAR16
*TextDeviceNode
2537 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2539 LunStr
= GetNextParamStr (&TextDeviceNode
);
2540 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2541 MESSAGING_DEVICE_PATH
,
2542 MSG_DEVICE_LOGICAL_UNIT_DP
,
2543 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2546 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2548 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2552 Converts a text device path node to iSCSI device path structure.
2554 @param TextDeviceNode The input Text device path node.
2556 @return A pointer to the newly-created iSCSI device path structure.
2559 EFI_DEVICE_PATH_PROTOCOL
*
2560 DevPathFromTextiSCSI (
2561 IN CHAR16
*TextDeviceNode
2566 CHAR16
*PortalGroupStr
;
2568 CHAR16
*HeaderDigestStr
;
2569 CHAR16
*DataDigestStr
;
2570 CHAR16
*AuthenticationStr
;
2571 CHAR16
*ProtocolStr
;
2573 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2576 NameStr
= GetNextParamStr (&TextDeviceNode
);
2577 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2578 LunStr
= GetNextParamStr (&TextDeviceNode
);
2579 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2580 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2581 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2582 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2583 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2584 MESSAGING_DEVICE_PATH
,
2586 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2589 AsciiStr
= ISCSIDevPath
->TargetName
;
2590 StrToAscii (NameStr
, &AsciiStr
);
2592 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2593 Strtoi64 (LunStr
, &Lun
);
2594 WriteUnaligned64 ((UINT64
*) &ISCSIDevPath
->Lun
, SwapBytes64 (Lun
));
2597 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2601 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2605 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2609 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2613 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2615 if (IS_NULL (*ProtocolStr
) || (StrCmp (ProtocolStr
, L
"TCP") == 0)) {
2616 ISCSIDevPath
->NetworkProtocol
= 0;
2619 // Undefined and reserved.
2621 ISCSIDevPath
->NetworkProtocol
= 1;
2624 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2628 Converts a text device path node to VLAN device path structure.
2630 @param TextDeviceNode The input Text device path node.
2632 @return A pointer to the newly-created VLAN device path structure.
2635 EFI_DEVICE_PATH_PROTOCOL
*
2636 DevPathFromTextVlan (
2637 IN CHAR16
*TextDeviceNode
2641 VLAN_DEVICE_PATH
*Vlan
;
2643 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2644 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2645 MESSAGING_DEVICE_PATH
,
2647 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2650 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2652 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2656 Converts a text device path node to Bluetooth device path structure.
2658 @param TextDeviceNode The input Text device path node.
2660 @return A pointer to the newly-created Bluetooth device path structure.
2663 EFI_DEVICE_PATH_PROTOCOL
*
2664 DevPathFromTextBluetooth (
2665 IN CHAR16
*TextDeviceNode
2668 CHAR16
*BluetoothStr
;
2669 BLUETOOTH_DEVICE_PATH
*BluetoothDp
;
2671 BluetoothStr
= GetNextParamStr (&TextDeviceNode
);
2672 BluetoothDp
= (BLUETOOTH_DEVICE_PATH
*) CreateDeviceNode (
2673 MESSAGING_DEVICE_PATH
,
2675 (UINT16
) sizeof (BLUETOOTH_DEVICE_PATH
)
2679 sizeof (BLUETOOTH_ADDRESS
) * 2,
2680 BluetoothDp
->BD_ADDR
.Address
,
2681 sizeof (BLUETOOTH_ADDRESS
)
2683 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothDp
;
2687 Converts a text device path node to Wi-Fi device path structure.
2689 @param TextDeviceNode The input Text device path node.
2691 @return A pointer to the newly-created Wi-Fi device path structure.
2694 EFI_DEVICE_PATH_PROTOCOL
*
2695 DevPathFromTextWiFi (
2696 IN CHAR16
*TextDeviceNode
2702 WIFI_DEVICE_PATH
*WiFiDp
;
2704 SSIdStr
= GetNextParamStr (&TextDeviceNode
);
2705 WiFiDp
= (WIFI_DEVICE_PATH
*) CreateDeviceNode (
2706 MESSAGING_DEVICE_PATH
,
2708 (UINT16
) sizeof (WIFI_DEVICE_PATH
)
2711 if (NULL
!= SSIdStr
) {
2712 DataLen
= StrLen (SSIdStr
);
2713 if (StrLen (SSIdStr
) > 32) {
2714 SSIdStr
[32] = L
'\0';
2718 UnicodeStrToAsciiStrS (SSIdStr
, AsciiStr
, sizeof (AsciiStr
));
2719 CopyMem (WiFiDp
->SSId
, AsciiStr
, DataLen
);
2722 return (EFI_DEVICE_PATH_PROTOCOL
*) WiFiDp
;
2726 Converts a text device path node to Bluetooth LE device path structure.
2728 @param TextDeviceNode The input Text device path node.
2730 @return A pointer to the newly-created Bluetooth LE device path structure.
2733 EFI_DEVICE_PATH_PROTOCOL
*
2734 DevPathFromTextBluetoothLE (
2735 IN CHAR16
*TextDeviceNode
2738 CHAR16
*BluetoothLeAddrStr
;
2739 CHAR16
*BluetoothLeAddrTypeStr
;
2740 BLUETOOTH_LE_DEVICE_PATH
*BluetoothLeDp
;
2742 BluetoothLeAddrStr
= GetNextParamStr (&TextDeviceNode
);
2743 BluetoothLeAddrTypeStr
= GetNextParamStr (&TextDeviceNode
);
2744 BluetoothLeDp
= (BLUETOOTH_LE_DEVICE_PATH
*) CreateDeviceNode (
2745 MESSAGING_DEVICE_PATH
,
2746 MSG_BLUETOOTH_LE_DP
,
2747 (UINT16
) sizeof (BLUETOOTH_LE_DEVICE_PATH
)
2750 BluetoothLeDp
->Address
.Type
= (UINT8
) Strtoi (BluetoothLeAddrTypeStr
);
2752 BluetoothLeAddrStr
, sizeof (BluetoothLeDp
->Address
.Address
) * 2,
2753 BluetoothLeDp
->Address
.Address
, sizeof (BluetoothLeDp
->Address
.Address
)
2755 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothLeDp
;
2759 Converts a text device path node to DNS device path structure.
2761 @param TextDeviceNode The input Text device path node.
2763 @return A pointer to the newly-created DNS device path structure.
2766 EFI_DEVICE_PATH_PROTOCOL
*
2767 DevPathFromTextDns (
2768 IN CHAR16
*TextDeviceNode
2771 CHAR16
*DeviceNodeStr
;
2772 CHAR16
*DeviceNodeStrPtr
;
2773 UINT32 DnsServerIpCount
;
2774 UINT16 DnsDeviceNodeLength
;
2775 DNS_DEVICE_PATH
*DnsDeviceNode
;
2776 UINT32 DnsServerIpIndex
;
2777 CHAR16
*DnsServerIp
;
2781 // Count the DNS server address number.
2783 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
2784 if (DeviceNodeStr
== NULL
) {
2788 DeviceNodeStrPtr
= DeviceNodeStr
;
2790 DnsServerIpCount
= 0;
2791 while (DeviceNodeStrPtr
!= NULL
&& *DeviceNodeStrPtr
!= L
'\0') {
2792 GetNextParamStr (&DeviceNodeStrPtr
);
2793 DnsServerIpCount
++;
2796 FreePool (DeviceNodeStr
);
2797 DeviceNodeStr
= NULL
;
2800 // One or more instances of the DNS server address in EFI_IP_ADDRESS,
2801 // otherwise, NULL will be returned.
2803 if (DnsServerIpCount
== 0) {
2808 // Create the DNS DeviceNode.
2810 DnsDeviceNodeLength
= (UINT16
) (sizeof (EFI_DEVICE_PATH_PROTOCOL
) + sizeof (UINT8
) + DnsServerIpCount
* sizeof (EFI_IP_ADDRESS
));
2811 DnsDeviceNode
= (DNS_DEVICE_PATH
*) CreateDeviceNode (
2812 MESSAGING_DEVICE_PATH
,
2816 if (DnsDeviceNode
== NULL
) {
2821 // Confirm the DNS server address is IPv4 or IPv6 type.
2823 DeviceNodeStrPtr
= TextDeviceNode
;
2824 while (!IS_NULL (*DeviceNodeStrPtr
)) {
2825 if (*DeviceNodeStrPtr
== L
'.') {
2826 DnsDeviceNode
->IsIPv6
= 0x00;
2830 if (*DeviceNodeStrPtr
== L
':') {
2831 DnsDeviceNode
->IsIPv6
= 0x01;
2838 for (DnsServerIpIndex
= 0; DnsServerIpIndex
< DnsServerIpCount
; DnsServerIpIndex
++) {
2839 DnsServerIp
= GetNextParamStr (&TextDeviceNode
);
2840 if (DnsDeviceNode
->IsIPv6
== 0x00) {
2841 StrToIpv4Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v4
), NULL
);
2843 StrToIpv6Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v6
), NULL
);
2847 return (EFI_DEVICE_PATH_PROTOCOL
*) DnsDeviceNode
;
2851 Converts a text device path node to URI device path structure.
2853 @param TextDeviceNode The input Text device path node.
2855 @return A pointer to the newly-created URI device path structure.
2858 EFI_DEVICE_PATH_PROTOCOL
*
2859 DevPathFromTextUri (
2860 IN CHAR16
*TextDeviceNode
2865 URI_DEVICE_PATH
*Uri
;
2867 UriStr
= GetNextParamStr (&TextDeviceNode
);
2868 UriLength
= StrnLenS (UriStr
, MAX_UINT16
- sizeof (URI_DEVICE_PATH
));
2869 Uri
= (URI_DEVICE_PATH
*) CreateDeviceNode (
2870 MESSAGING_DEVICE_PATH
,
2872 (UINT16
) (sizeof (URI_DEVICE_PATH
) + UriLength
)
2875 while (UriLength
-- != 0) {
2876 Uri
->Uri
[UriLength
] = (CHAR8
) UriStr
[UriLength
];
2879 return (EFI_DEVICE_PATH_PROTOCOL
*) Uri
;
2883 Converts a media text device path node to media device path structure.
2885 @param TextDeviceNode The input Text device path node.
2887 @return A pointer to media device path structure.
2890 EFI_DEVICE_PATH_PROTOCOL
*
2891 DevPathFromTextMediaPath (
2892 IN CHAR16
*TextDeviceNode
2895 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH
, TextDeviceNode
);
2899 Converts a text device path node to HD device path structure.
2901 @param TextDeviceNode The input Text device path node.
2903 @return A pointer to the newly-created HD device path structure.
2906 EFI_DEVICE_PATH_PROTOCOL
*
2908 IN CHAR16
*TextDeviceNode
2911 CHAR16
*PartitionStr
;
2913 CHAR16
*SignatureStr
;
2917 HARDDRIVE_DEVICE_PATH
*Hd
;
2919 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2920 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2921 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2922 StartStr
= GetNextParamStr (&TextDeviceNode
);
2923 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2924 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2927 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2930 Hd
->PartitionNumber
= (UINT32
) Strtoi (PartitionStr
);
2932 ZeroMem (Hd
->Signature
, 16);
2933 Hd
->MBRType
= (UINT8
) 0;
2935 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2936 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2939 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2940 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2941 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2942 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2945 StrToGuid (SignatureStr
, (EFI_GUID
*) Hd
->Signature
);
2947 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2950 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2951 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2953 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2957 Converts a text device path node to CDROM device path structure.
2959 @param TextDeviceNode The input Text device path node.
2961 @return A pointer to the newly-created CDROM device path structure.
2964 EFI_DEVICE_PATH_PROTOCOL
*
2965 DevPathFromTextCDROM (
2966 IN CHAR16
*TextDeviceNode
2972 CDROM_DEVICE_PATH
*CDROMDevPath
;
2974 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2975 StartStr
= GetNextParamStr (&TextDeviceNode
);
2976 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2977 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2980 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2983 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2984 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2985 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2987 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2991 Converts a text device path node to Vendor-defined media device path structure.
2993 @param TextDeviceNode The input Text device path node.
2995 @return A pointer to the newly-created Vendor-defined media device path structure.
2998 EFI_DEVICE_PATH_PROTOCOL
*
2999 DevPathFromTextVenMedia (
3000 IN CHAR16
*TextDeviceNode
3003 return ConvertFromTextVendor (
3011 Converts a text device path node to File device path structure.
3013 @param TextDeviceNode The input Text device path node.
3015 @return A pointer to the newly-created File device path structure.
3018 EFI_DEVICE_PATH_PROTOCOL
*
3019 DevPathFromTextFilePath (
3020 IN CHAR16
*TextDeviceNode
3023 FILEPATH_DEVICE_PATH
*File
;
3025 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
3028 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
3031 StrCpyS (File
->PathName
, StrLen (TextDeviceNode
) + 1, TextDeviceNode
);
3033 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
3037 Converts a text device path node to Media protocol device path structure.
3039 @param TextDeviceNode The input Text device path node.
3041 @return A pointer to the newly-created Media protocol device path structure.
3044 EFI_DEVICE_PATH_PROTOCOL
*
3045 DevPathFromTextMedia (
3046 IN CHAR16
*TextDeviceNode
3050 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
3052 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3053 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
3056 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
3059 StrToGuid (GuidStr
, &Media
->Protocol
);
3061 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
3065 Converts a text device path node to firmware volume device path structure.
3067 @param TextDeviceNode The input Text device path node.
3069 @return A pointer to the newly-created firmware volume device path structure.
3072 EFI_DEVICE_PATH_PROTOCOL
*
3074 IN CHAR16
*TextDeviceNode
3078 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
3080 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3081 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
3083 MEDIA_PIWG_FW_VOL_DP
,
3084 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
3087 StrToGuid (GuidStr
, &Fv
->FvName
);
3089 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
3093 Converts a text device path node to firmware file device path structure.
3095 @param TextDeviceNode The input Text device path node.
3097 @return A pointer to the newly-created firmware file device path structure.
3100 EFI_DEVICE_PATH_PROTOCOL
*
3101 DevPathFromTextFvFile (
3102 IN CHAR16
*TextDeviceNode
3106 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
3108 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3109 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
3111 MEDIA_PIWG_FW_FILE_DP
,
3112 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
3115 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
3117 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
3121 Converts a text device path node to text relative offset device path structure.
3123 @param TextDeviceNode The input Text device path node.
3125 @return A pointer to the newly-created Text device path structure.
3128 EFI_DEVICE_PATH_PROTOCOL
*
3129 DevPathFromTextRelativeOffsetRange (
3130 IN CHAR16
*TextDeviceNode
3133 CHAR16
*StartingOffsetStr
;
3134 CHAR16
*EndingOffsetStr
;
3135 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
3137 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
3138 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
3139 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
3141 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
3142 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
3145 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
3146 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
3148 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
3152 Converts a text device path node to text ram disk device path structure.
3154 @param TextDeviceNode The input Text device path node.
3156 @return A pointer to the newly-created Text device path structure.
3159 EFI_DEVICE_PATH_PROTOCOL
*
3160 DevPathFromTextRamDisk (
3161 IN CHAR16
*TextDeviceNode
3164 CHAR16
*StartingAddrStr
;
3165 CHAR16
*EndingAddrStr
;
3166 CHAR16
*TypeGuidStr
;
3167 CHAR16
*InstanceStr
;
3168 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3169 UINT64 StartingAddr
;
3172 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3173 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3174 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3175 TypeGuidStr
= GetNextParamStr (&TextDeviceNode
);
3176 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3179 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3182 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3183 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3184 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3185 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3186 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3187 StrToGuid (TypeGuidStr
, &RamDisk
->TypeGuid
);
3189 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3193 Converts a text device path node to text virtual disk device path structure.
3195 @param TextDeviceNode The input Text device path node.
3197 @return A pointer to the newly-created Text device path structure.
3200 EFI_DEVICE_PATH_PROTOCOL
*
3201 DevPathFromTextVirtualDisk (
3202 IN CHAR16
*TextDeviceNode
3205 CHAR16
*StartingAddrStr
;
3206 CHAR16
*EndingAddrStr
;
3207 CHAR16
*InstanceStr
;
3208 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3209 UINT64 StartingAddr
;
3212 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3213 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3214 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3216 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3219 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3222 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3223 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3224 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3225 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3226 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3227 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualDiskGuid
);
3229 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3233 Converts a text device path node to text virtual cd device path structure.
3235 @param TextDeviceNode The input Text device path node.
3237 @return A pointer to the newly-created Text device path structure.
3240 EFI_DEVICE_PATH_PROTOCOL
*
3241 DevPathFromTextVirtualCd (
3242 IN CHAR16
*TextDeviceNode
3245 CHAR16
*StartingAddrStr
;
3246 CHAR16
*EndingAddrStr
;
3247 CHAR16
*InstanceStr
;
3248 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3249 UINT64 StartingAddr
;
3252 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3253 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3254 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3256 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3259 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3262 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3263 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3264 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3265 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3266 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3267 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualCdGuid
);
3269 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3273 Converts a text device path node to text persistent virtual disk device path structure.
3275 @param TextDeviceNode The input Text device path node.
3277 @return A pointer to the newly-created Text device path structure.
3280 EFI_DEVICE_PATH_PROTOCOL
*
3281 DevPathFromTextPersistentVirtualDisk (
3282 IN CHAR16
*TextDeviceNode
3285 CHAR16
*StartingAddrStr
;
3286 CHAR16
*EndingAddrStr
;
3287 CHAR16
*InstanceStr
;
3288 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3289 UINT64 StartingAddr
;
3292 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3293 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3294 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3296 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3299 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3302 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3303 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3304 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3305 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3306 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3307 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualDiskGuid
);
3309 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3313 Converts a text device path node to text persistent virtual cd device path structure.
3315 @param TextDeviceNode The input Text device path node.
3317 @return A pointer to the newly-created Text device path structure.
3320 EFI_DEVICE_PATH_PROTOCOL
*
3321 DevPathFromTextPersistentVirtualCd (
3322 IN CHAR16
*TextDeviceNode
3325 CHAR16
*StartingAddrStr
;
3326 CHAR16
*EndingAddrStr
;
3327 CHAR16
*InstanceStr
;
3328 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3329 UINT64 StartingAddr
;
3332 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3333 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3334 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3336 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3339 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3342 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3343 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3344 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3345 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3346 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3347 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualCdGuid
);
3349 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3353 Converts a BBS text device path node to BBS device path structure.
3355 @param TextDeviceNode The input Text device path node.
3357 @return A pointer to BBS device path structure.
3360 EFI_DEVICE_PATH_PROTOCOL
*
3361 DevPathFromTextBbsPath (
3362 IN CHAR16
*TextDeviceNode
3365 return DevPathFromTextGenericPath (BBS_DEVICE_PATH
, TextDeviceNode
);
3369 Converts a text device path node to BIOS Boot Specification device path structure.
3371 @param TextDeviceNode The input Text device path node.
3373 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3376 EFI_DEVICE_PATH_PROTOCOL
*
3377 DevPathFromTextBBS (
3378 IN CHAR16
*TextDeviceNode
3385 BBS_BBS_DEVICE_PATH
*Bbs
;
3387 TypeStr
= GetNextParamStr (&TextDeviceNode
);
3388 IdStr
= GetNextParamStr (&TextDeviceNode
);
3389 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
3390 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
3393 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
3396 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
3397 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
3398 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
3399 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
3400 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
3401 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
3402 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
3403 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
3404 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
3405 Bbs
->DeviceType
= BBS_TYPE_USB
;
3406 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
3407 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
3409 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
3412 AsciiStr
= Bbs
->String
;
3413 StrToAscii (IdStr
, &AsciiStr
);
3415 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
3417 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
3421 Converts a text device path node to SATA device path structure.
3423 @param TextDeviceNode The input Text device path node.
3425 @return A pointer to the newly-created SATA device path structure.
3428 EFI_DEVICE_PATH_PROTOCOL
*
3429 DevPathFromTextSata (
3430 IN CHAR16
*TextDeviceNode
3433 SATA_DEVICE_PATH
*Sata
;
3438 Param1
= GetNextParamStr (&TextDeviceNode
);
3439 Param2
= GetNextParamStr (&TextDeviceNode
);
3440 Param3
= GetNextParamStr (&TextDeviceNode
);
3442 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
3443 MESSAGING_DEVICE_PATH
,
3445 (UINT16
) sizeof (SATA_DEVICE_PATH
)
3447 Sata
->HBAPortNumber
= (UINT16
) Strtoi (Param1
);
3450 // According to UEFI spec, if PMPN is not provided, the default is 0xFFFF
3452 if (*Param2
== L
'\0' ) {
3453 Sata
->PortMultiplierPortNumber
= 0xFFFF;
3455 Sata
->PortMultiplierPortNumber
= (UINT16
) Strtoi (Param2
);
3457 Sata
->Lun
= (UINT16
) Strtoi (Param3
);
3459 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
3462 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
3463 {L
"Path", DevPathFromTextPath
},
3465 {L
"HardwarePath", DevPathFromTextHardwarePath
},
3466 {L
"Pci", DevPathFromTextPci
},
3467 {L
"PcCard", DevPathFromTextPcCard
},
3468 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
3469 {L
"VenHw", DevPathFromTextVenHw
},
3470 {L
"Ctrl", DevPathFromTextCtrl
},
3471 {L
"BMC", DevPathFromTextBmc
},
3473 {L
"AcpiPath", DevPathFromTextAcpiPath
},
3474 {L
"Acpi", DevPathFromTextAcpi
},
3475 {L
"PciRoot", DevPathFromTextPciRoot
},
3476 {L
"PcieRoot", DevPathFromTextPcieRoot
},
3477 {L
"Floppy", DevPathFromTextFloppy
},
3478 {L
"Keyboard", DevPathFromTextKeyboard
},
3479 {L
"Serial", DevPathFromTextSerial
},
3480 {L
"ParallelPort", DevPathFromTextParallelPort
},
3481 {L
"AcpiEx", DevPathFromTextAcpiEx
},
3482 {L
"AcpiExp", DevPathFromTextAcpiExp
},
3483 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
3485 {L
"Msg", DevPathFromTextMsg
},
3486 {L
"Ata", DevPathFromTextAta
},
3487 {L
"Scsi", DevPathFromTextScsi
},
3488 {L
"Fibre", DevPathFromTextFibre
},
3489 {L
"FibreEx", DevPathFromTextFibreEx
},
3490 {L
"I1394", DevPathFromText1394
},
3491 {L
"USB", DevPathFromTextUsb
},
3492 {L
"I2O", DevPathFromTextI2O
},
3493 {L
"Infiniband", DevPathFromTextInfiniband
},
3494 {L
"VenMsg", DevPathFromTextVenMsg
},
3495 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
3496 {L
"VenVt100", DevPathFromTextVenVt100
},
3497 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
3498 {L
"VenUtf8", DevPathFromTextVenUtf8
},
3499 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
3500 {L
"SAS", DevPathFromTextSAS
},
3501 {L
"SasEx", DevPathFromTextSasEx
},
3502 {L
"NVMe", DevPathFromTextNVMe
},
3503 {L
"UFS", DevPathFromTextUfs
},
3504 {L
"SD", DevPathFromTextSd
},
3505 {L
"eMMC", DevPathFromTextEmmc
},
3506 {L
"DebugPort", DevPathFromTextDebugPort
},
3507 {L
"MAC", DevPathFromTextMAC
},
3508 {L
"IPv4", DevPathFromTextIPv4
},
3509 {L
"IPv6", DevPathFromTextIPv6
},
3510 {L
"Uart", DevPathFromTextUart
},
3511 {L
"UsbClass", DevPathFromTextUsbClass
},
3512 {L
"UsbAudio", DevPathFromTextUsbAudio
},
3513 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
3514 {L
"UsbHID", DevPathFromTextUsbHID
},
3515 {L
"UsbImage", DevPathFromTextUsbImage
},
3516 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
3517 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
3518 {L
"UsbHub", DevPathFromTextUsbHub
},
3519 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
3520 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
3521 {L
"UsbVideo", DevPathFromTextUsbVideo
},
3522 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
3523 {L
"UsbWireless", DevPathFromTextUsbWireless
},
3524 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
3525 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
3526 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
3527 {L
"UsbWwid", DevPathFromTextUsbWwid
},
3528 {L
"Unit", DevPathFromTextUnit
},
3529 {L
"iSCSI", DevPathFromTextiSCSI
},
3530 {L
"Vlan", DevPathFromTextVlan
},
3531 {L
"Dns", DevPathFromTextDns
},
3532 {L
"Uri", DevPathFromTextUri
},
3533 {L
"Bluetooth", DevPathFromTextBluetooth
},
3534 {L
"Wi-Fi", DevPathFromTextWiFi
},
3535 {L
"BluetoothLE", DevPathFromTextBluetoothLE
},
3536 {L
"MediaPath", DevPathFromTextMediaPath
},
3537 {L
"HD", DevPathFromTextHD
},
3538 {L
"CDROM", DevPathFromTextCDROM
},
3539 {L
"VenMedia", DevPathFromTextVenMedia
},
3540 {L
"Media", DevPathFromTextMedia
},
3541 {L
"Fv", DevPathFromTextFv
},
3542 {L
"FvFile", DevPathFromTextFvFile
},
3543 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
3544 {L
"RamDisk", DevPathFromTextRamDisk
},
3545 {L
"VirtualDisk", DevPathFromTextVirtualDisk
},
3546 {L
"VirtualCD", DevPathFromTextVirtualCd
},
3547 {L
"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk
},
3548 {L
"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd
},
3550 {L
"BbsPath", DevPathFromTextBbsPath
},
3551 {L
"BBS", DevPathFromTextBBS
},
3552 {L
"Sata", DevPathFromTextSata
},
3557 Convert text to the binary representation of a device node.
3559 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3560 node. Conversion starts with the first character and continues
3561 until the first non-device node character.
3563 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3564 insufficient memory or text unsupported.
3567 EFI_DEVICE_PATH_PROTOCOL
*
3569 UefiDevicePathLibConvertTextToDeviceNode (
3570 IN CONST CHAR16
*TextDeviceNode
3573 DEVICE_PATH_FROM_TEXT FromText
;
3575 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3576 CHAR16
*DeviceNodeStr
;
3579 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
3585 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
3586 ASSERT (DeviceNodeStr
!= NULL
);
3588 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3589 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
3590 if (ParamStr
!= NULL
) {
3591 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
3596 if (FromText
== NULL
) {
3600 FromText
= DevPathFromTextFilePath
;
3601 DeviceNode
= FromText (DeviceNodeStr
);
3603 DeviceNode
= FromText (ParamStr
);
3604 FreePool (ParamStr
);
3607 FreePool (DeviceNodeStr
);
3613 Convert text to the binary representation of a device path.
3616 @param TextDevicePath TextDevicePath points to the text representation of a device
3617 path. Conversion starts with the first character and continues
3618 until the first non-device node character.
3620 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3621 there was insufficient memory.
3624 EFI_DEVICE_PATH_PROTOCOL
*
3626 UefiDevicePathLibConvertTextToDevicePath (
3627 IN CONST CHAR16
*TextDevicePath
3630 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3631 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3632 CHAR16
*DevicePathStr
;
3634 CHAR16
*DeviceNodeStr
;
3635 BOOLEAN IsInstanceEnd
;
3636 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3638 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3642 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3643 ASSERT (DevicePath
!= NULL
);
3644 SetDevicePathEndNode (DevicePath
);
3646 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3648 Str
= DevicePathStr
;
3649 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3650 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3652 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3653 FreePool (DevicePath
);
3654 FreePool (DeviceNode
);
3655 DevicePath
= NewDevicePath
;
3657 if (IsInstanceEnd
) {
3658 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3659 ASSERT (DeviceNode
!= NULL
);
3660 SetDevicePathEndNode (DeviceNode
);
3661 DeviceNode
->SubType
= END_INSTANCE_DEVICE_PATH_SUBTYPE
;
3663 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3664 FreePool (DevicePath
);
3665 FreePool (DeviceNode
);
3666 DevicePath
= NewDevicePath
;
3670 FreePool (DevicePathStr
);