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
);
922 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
925 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
927 // HID string is NULL
931 // Convert UID string
934 StrToAscii (UIDSTRStr
, &AsciiStr
);
936 // CID string is NULL
940 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
944 Converts a text device path node to ACPI _ADR device path structure.
946 @param TextDeviceNode The input Text device path node.
948 @return A pointer to the newly-created ACPI _ADR device path structure.
951 EFI_DEVICE_PATH_PROTOCOL
*
952 DevPathFromTextAcpiAdr (
953 IN CHAR16
*TextDeviceNode
956 CHAR16
*DisplayDeviceStr
;
957 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
961 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*) CreateDeviceNode (
964 (UINT16
) sizeof (ACPI_ADR_DEVICE_PATH
)
966 ASSERT (AcpiAdr
!= NULL
);
968 for (Index
= 0; ; Index
++) {
969 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
970 if (IS_NULL (*DisplayDeviceStr
)) {
974 Length
= DevicePathNodeLength (AcpiAdr
);
975 AcpiAdr
= ReallocatePool (
977 Length
+ sizeof (UINT32
),
980 ASSERT (AcpiAdr
!= NULL
);
981 SetDevicePathNodeLength (AcpiAdr
, Length
+ sizeof (UINT32
));
984 (&AcpiAdr
->ADR
)[Index
] = (UINT32
) Strtoi (DisplayDeviceStr
);
987 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
;
991 Converts a generic messaging text device path node to messaging device path structure.
993 @param TextDeviceNode The input Text device path node.
995 @return A pointer to messaging device path structure.
998 EFI_DEVICE_PATH_PROTOCOL
*
1000 IN CHAR16
*TextDeviceNode
1003 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH
, TextDeviceNode
);
1007 Converts a text device path node to Parallel Port device path structure.
1009 @param TextDeviceNode The input Text device path node.
1011 @return A pointer to the newly-created Parallel Port device path structure.
1014 EFI_DEVICE_PATH_PROTOCOL
*
1015 DevPathFromTextAta (
1016 IN CHAR16
*TextDeviceNode
1019 CHAR16
*PrimarySecondaryStr
;
1020 CHAR16
*SlaveMasterStr
;
1022 ATAPI_DEVICE_PATH
*Atapi
;
1024 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
1025 MESSAGING_DEVICE_PATH
,
1027 (UINT16
) sizeof (ATAPI_DEVICE_PATH
)
1030 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
1031 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
1032 LunStr
= GetNextParamStr (&TextDeviceNode
);
1034 if (StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) {
1035 Atapi
->PrimarySecondary
= 0;
1036 } else if (StrCmp (PrimarySecondaryStr
, L
"Secondary") == 0) {
1037 Atapi
->PrimarySecondary
= 1;
1039 Atapi
->PrimarySecondary
= (UINT8
) Strtoi (PrimarySecondaryStr
);
1041 if (StrCmp (SlaveMasterStr
, L
"Master") == 0) {
1042 Atapi
->SlaveMaster
= 0;
1043 } else if (StrCmp (SlaveMasterStr
, L
"Slave") == 0) {
1044 Atapi
->SlaveMaster
= 1;
1046 Atapi
->SlaveMaster
= (UINT8
) Strtoi (SlaveMasterStr
);
1049 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
1051 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
1055 Converts a text device path node to SCSI device path structure.
1057 @param TextDeviceNode The input Text device path node.
1059 @return A pointer to the newly-created SCSI device path structure.
1062 EFI_DEVICE_PATH_PROTOCOL
*
1063 DevPathFromTextScsi (
1064 IN CHAR16
*TextDeviceNode
1069 SCSI_DEVICE_PATH
*Scsi
;
1071 PunStr
= GetNextParamStr (&TextDeviceNode
);
1072 LunStr
= GetNextParamStr (&TextDeviceNode
);
1073 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
1074 MESSAGING_DEVICE_PATH
,
1076 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
1079 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
1080 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
1082 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
1086 Converts a text device path node to Fibre device path structure.
1088 @param TextDeviceNode The input Text device path node.
1090 @return A pointer to the newly-created Fibre device path structure.
1093 EFI_DEVICE_PATH_PROTOCOL
*
1094 DevPathFromTextFibre (
1095 IN CHAR16
*TextDeviceNode
1100 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
1102 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1103 LunStr
= GetNextParamStr (&TextDeviceNode
);
1104 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
1105 MESSAGING_DEVICE_PATH
,
1106 MSG_FIBRECHANNEL_DP
,
1107 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
1110 Fibre
->Reserved
= 0;
1111 Strtoi64 (WWNStr
, &Fibre
->WWN
);
1112 Strtoi64 (LunStr
, &Fibre
->Lun
);
1114 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
1118 Converts a text device path node to FibreEx device path structure.
1120 @param TextDeviceNode The input Text device path node.
1122 @return A pointer to the newly-created FibreEx device path structure.
1125 EFI_DEVICE_PATH_PROTOCOL
*
1126 DevPathFromTextFibreEx (
1127 IN CHAR16
*TextDeviceNode
1132 FIBRECHANNELEX_DEVICE_PATH
*FibreEx
;
1134 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1135 LunStr
= GetNextParamStr (&TextDeviceNode
);
1136 FibreEx
= (FIBRECHANNELEX_DEVICE_PATH
*) CreateDeviceNode (
1137 MESSAGING_DEVICE_PATH
,
1138 MSG_FIBRECHANNELEX_DP
,
1139 (UINT16
) sizeof (FIBRECHANNELEX_DEVICE_PATH
)
1142 FibreEx
->Reserved
= 0;
1143 Strtoi64 (WWNStr
, (UINT64
*) (&FibreEx
->WWN
));
1144 Strtoi64 (LunStr
, (UINT64
*) (&FibreEx
->Lun
));
1146 *(UINT64
*) (&FibreEx
->WWN
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->WWN
));
1147 *(UINT64
*) (&FibreEx
->Lun
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->Lun
));
1149 return (EFI_DEVICE_PATH_PROTOCOL
*) FibreEx
;
1153 Converts a text device path node to 1394 device path structure.
1155 @param TextDeviceNode The input Text device path node.
1157 @return A pointer to the newly-created 1394 device path structure.
1160 EFI_DEVICE_PATH_PROTOCOL
*
1161 DevPathFromText1394 (
1162 IN CHAR16
*TextDeviceNode
1166 F1394_DEVICE_PATH
*F1394DevPath
;
1168 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1169 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1170 MESSAGING_DEVICE_PATH
,
1172 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1175 F1394DevPath
->Reserved
= 0;
1176 F1394DevPath
->Guid
= StrHexToUint64 (GuidStr
);
1178 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1182 Converts a text device path node to USB device path structure.
1184 @param TextDeviceNode The input Text device path node.
1186 @return A pointer to the newly-created USB device path structure.
1189 EFI_DEVICE_PATH_PROTOCOL
*
1190 DevPathFromTextUsb (
1191 IN CHAR16
*TextDeviceNode
1195 CHAR16
*InterfaceStr
;
1196 USB_DEVICE_PATH
*Usb
;
1198 PortStr
= GetNextParamStr (&TextDeviceNode
);
1199 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1200 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1201 MESSAGING_DEVICE_PATH
,
1203 (UINT16
) sizeof (USB_DEVICE_PATH
)
1206 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1207 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1209 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1213 Converts a text device path node to I20 device path structure.
1215 @param TextDeviceNode The input Text device path node.
1217 @return A pointer to the newly-created I20 device path structure.
1220 EFI_DEVICE_PATH_PROTOCOL
*
1221 DevPathFromTextI2O (
1222 IN CHAR16
*TextDeviceNode
1226 I2O_DEVICE_PATH
*I2ODevPath
;
1228 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1229 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1230 MESSAGING_DEVICE_PATH
,
1232 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1235 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1237 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1241 Converts a text device path node to Infini Band device path structure.
1243 @param TextDeviceNode The input Text device path node.
1245 @return A pointer to the newly-created Infini Band device path structure.
1248 EFI_DEVICE_PATH_PROTOCOL
*
1249 DevPathFromTextInfiniband (
1250 IN CHAR16
*TextDeviceNode
1258 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1260 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1261 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1262 SidStr
= GetNextParamStr (&TextDeviceNode
);
1263 TidStr
= GetNextParamStr (&TextDeviceNode
);
1264 DidStr
= GetNextParamStr (&TextDeviceNode
);
1265 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1266 MESSAGING_DEVICE_PATH
,
1268 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1271 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1272 StrToGuid (GuidStr
, (EFI_GUID
*) InfiniBand
->PortGid
);
1273 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1274 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1275 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1277 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1281 Converts a text device path node to Vendor-Defined Messaging device path structure.
1283 @param TextDeviceNode The input Text device path node.
1285 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1288 EFI_DEVICE_PATH_PROTOCOL
*
1289 DevPathFromTextVenMsg (
1290 IN CHAR16
*TextDeviceNode
1293 return ConvertFromTextVendor (
1295 MESSAGING_DEVICE_PATH
,
1301 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1303 @param TextDeviceNode The input Text device path node.
1305 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1308 EFI_DEVICE_PATH_PROTOCOL
*
1309 DevPathFromTextVenPcAnsi (
1310 IN CHAR16
*TextDeviceNode
1313 VENDOR_DEVICE_PATH
*Vendor
;
1315 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1316 MESSAGING_DEVICE_PATH
,
1318 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1319 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1321 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1325 Converts a text device path node to Vendor defined VT100 device path structure.
1327 @param TextDeviceNode The input Text device path node.
1329 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1332 EFI_DEVICE_PATH_PROTOCOL
*
1333 DevPathFromTextVenVt100 (
1334 IN CHAR16
*TextDeviceNode
1337 VENDOR_DEVICE_PATH
*Vendor
;
1339 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1340 MESSAGING_DEVICE_PATH
,
1342 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1343 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1345 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1349 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1351 @param TextDeviceNode The input Text device path node.
1353 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1356 EFI_DEVICE_PATH_PROTOCOL
*
1357 DevPathFromTextVenVt100Plus (
1358 IN CHAR16
*TextDeviceNode
1361 VENDOR_DEVICE_PATH
*Vendor
;
1363 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1364 MESSAGING_DEVICE_PATH
,
1366 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1367 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1369 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1373 Converts a text device path node to Vendor defined UTF8 device path structure.
1375 @param TextDeviceNode The input Text device path node.
1377 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1380 EFI_DEVICE_PATH_PROTOCOL
*
1381 DevPathFromTextVenUtf8 (
1382 IN CHAR16
*TextDeviceNode
1385 VENDOR_DEVICE_PATH
*Vendor
;
1387 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1388 MESSAGING_DEVICE_PATH
,
1390 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1391 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1393 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1397 Converts a text device path node to UART Flow Control device path structure.
1399 @param TextDeviceNode The input Text device path node.
1401 @return A pointer to the newly-created UART Flow Control device path structure.
1404 EFI_DEVICE_PATH_PROTOCOL
*
1405 DevPathFromTextUartFlowCtrl (
1406 IN CHAR16
*TextDeviceNode
1410 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1412 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1413 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1414 MESSAGING_DEVICE_PATH
,
1416 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1419 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1420 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1421 UartFlowControl
->FlowControlMap
= 2;
1422 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1423 UartFlowControl
->FlowControlMap
= 1;
1425 UartFlowControl
->FlowControlMap
= 0;
1428 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1432 Converts a text device path node to Serial Attached SCSI device path structure.
1434 @param TextDeviceNode The input Text device path node.
1436 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1439 EFI_DEVICE_PATH_PROTOCOL
*
1440 DevPathFromTextSAS (
1441 IN CHAR16
*TextDeviceNode
1448 CHAR16
*LocationStr
;
1450 CHAR16
*DriveBayStr
;
1451 CHAR16
*ReservedStr
;
1454 SAS_DEVICE_PATH
*Sas
;
1456 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1457 LunStr
= GetNextParamStr (&TextDeviceNode
);
1458 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1459 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1460 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1461 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1462 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1463 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1464 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1465 MESSAGING_DEVICE_PATH
,
1467 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1470 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1471 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1472 Strtoi64 (LunStr
, &Sas
->Lun
);
1473 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1475 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1478 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1480 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1484 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1487 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1492 // Location is an integer between 0 and 1 or else
1493 // the keyword Internal (0) or External (1).
1495 if (StrCmp (LocationStr
, L
"External") == 0) {
1497 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1500 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1502 Info
|= (Uint16
<< 5);
1505 // Connect is an integer between 0 and 3 or else
1506 // the keyword Direct (0) or Expanded (1).
1508 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1510 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1513 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1515 Info
|= (Uint16
<< 6);
1518 Info
= (UINT16
) Strtoi (SASSATAStr
);
1521 Sas
->DeviceTopology
= Info
;
1522 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1524 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1528 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1530 @param TextDeviceNode The input Text device path node.
1532 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1535 EFI_DEVICE_PATH_PROTOCOL
*
1536 DevPathFromTextSasEx (
1537 IN CHAR16
*TextDeviceNode
1544 CHAR16
*LocationStr
;
1546 CHAR16
*DriveBayStr
;
1551 SASEX_DEVICE_PATH
*SasEx
;
1553 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1554 LunStr
= GetNextParamStr (&TextDeviceNode
);
1555 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1556 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1557 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1558 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1559 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1560 SasEx
= (SASEX_DEVICE_PATH
*) CreateDeviceNode (
1561 MESSAGING_DEVICE_PATH
,
1563 (UINT16
) sizeof (SASEX_DEVICE_PATH
)
1566 Strtoi64 (AddressStr
, &SasAddress
);
1567 Strtoi64 (LunStr
, &Lun
);
1568 WriteUnaligned64 ((UINT64
*) &SasEx
->SasAddress
, SwapBytes64 (SasAddress
));
1569 WriteUnaligned64 ((UINT64
*) &SasEx
->Lun
, SwapBytes64 (Lun
));
1570 SasEx
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1572 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1575 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1577 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1581 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1584 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1589 // Location is an integer between 0 and 1 or else
1590 // the keyword Internal (0) or External (1).
1592 if (StrCmp (LocationStr
, L
"External") == 0) {
1594 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1597 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1599 Info
|= (Uint16
<< 5);
1602 // Connect is an integer between 0 and 3 or else
1603 // the keyword Direct (0) or Expanded (1).
1605 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1607 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1610 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1612 Info
|= (Uint16
<< 6);
1615 Info
= (UINT16
) Strtoi (SASSATAStr
);
1618 SasEx
->DeviceTopology
= Info
;
1620 return (EFI_DEVICE_PATH_PROTOCOL
*) SasEx
;
1624 Converts a text device path node to NVM Express Namespace device path structure.
1626 @param TextDeviceNode The input Text device path node.
1628 @return A pointer to the newly-created NVM Express Namespace device path structure.
1631 EFI_DEVICE_PATH_PROTOCOL
*
1632 DevPathFromTextNVMe (
1633 IN CHAR16
*TextDeviceNode
1636 CHAR16
*NamespaceIdStr
;
1637 CHAR16
*NamespaceUuidStr
;
1638 NVME_NAMESPACE_DEVICE_PATH
*Nvme
;
1642 NamespaceIdStr
= GetNextParamStr (&TextDeviceNode
);
1643 NamespaceUuidStr
= GetNextParamStr (&TextDeviceNode
);
1644 Nvme
= (NVME_NAMESPACE_DEVICE_PATH
*) CreateDeviceNode (
1645 MESSAGING_DEVICE_PATH
,
1646 MSG_NVME_NAMESPACE_DP
,
1647 (UINT16
) sizeof (NVME_NAMESPACE_DEVICE_PATH
)
1650 Nvme
->NamespaceId
= (UINT32
) Strtoi (NamespaceIdStr
);
1651 Uuid
= (UINT8
*) &Nvme
->NamespaceUuid
;
1653 Index
= sizeof (Nvme
->NamespaceUuid
) / sizeof (UINT8
);
1654 while (Index
-- != 0) {
1655 Uuid
[Index
] = (UINT8
) StrHexToUintn (SplitStr (&NamespaceUuidStr
, L
'-'));
1658 return (EFI_DEVICE_PATH_PROTOCOL
*) Nvme
;
1662 Converts a text device path node to UFS device path structure.
1664 @param TextDeviceNode The input Text device path node.
1666 @return A pointer to the newly-created UFS device path structure.
1669 EFI_DEVICE_PATH_PROTOCOL
*
1670 DevPathFromTextUfs (
1671 IN CHAR16
*TextDeviceNode
1676 UFS_DEVICE_PATH
*Ufs
;
1678 PunStr
= GetNextParamStr (&TextDeviceNode
);
1679 LunStr
= GetNextParamStr (&TextDeviceNode
);
1680 Ufs
= (UFS_DEVICE_PATH
*) CreateDeviceNode (
1681 MESSAGING_DEVICE_PATH
,
1683 (UINT16
) sizeof (UFS_DEVICE_PATH
)
1686 Ufs
->Pun
= (UINT8
) Strtoi (PunStr
);
1687 Ufs
->Lun
= (UINT8
) Strtoi (LunStr
);
1689 return (EFI_DEVICE_PATH_PROTOCOL
*) Ufs
;
1693 Converts a text device path node to SD (Secure Digital) device path structure.
1695 @param TextDeviceNode The input Text device path node.
1697 @return A pointer to the newly-created SD device path structure.
1700 EFI_DEVICE_PATH_PROTOCOL
*
1702 IN CHAR16
*TextDeviceNode
1705 CHAR16
*SlotNumberStr
;
1708 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1709 Sd
= (SD_DEVICE_PATH
*) CreateDeviceNode (
1710 MESSAGING_DEVICE_PATH
,
1712 (UINT16
) sizeof (SD_DEVICE_PATH
)
1715 Sd
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1717 return (EFI_DEVICE_PATH_PROTOCOL
*) Sd
;
1721 Converts a text device path node to EMMC (Embedded MMC) device path structure.
1723 @param TextDeviceNode The input Text device path node.
1725 @return A pointer to the newly-created EMMC device path structure.
1728 EFI_DEVICE_PATH_PROTOCOL
*
1729 DevPathFromTextEmmc (
1730 IN CHAR16
*TextDeviceNode
1733 CHAR16
*SlotNumberStr
;
1734 EMMC_DEVICE_PATH
*Emmc
;
1736 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1737 Emmc
= (EMMC_DEVICE_PATH
*) CreateDeviceNode (
1738 MESSAGING_DEVICE_PATH
,
1740 (UINT16
) sizeof (EMMC_DEVICE_PATH
)
1743 Emmc
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1745 return (EFI_DEVICE_PATH_PROTOCOL
*) Emmc
;
1749 Converts a text device path node to Debug Port device path structure.
1751 @param TextDeviceNode The input Text device path node.
1753 @return A pointer to the newly-created Debug Port device path structure.
1756 EFI_DEVICE_PATH_PROTOCOL
*
1757 DevPathFromTextDebugPort (
1758 IN CHAR16
*TextDeviceNode
1761 VENDOR_DEVICE_PATH
*Vend
;
1763 Vend
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1764 MESSAGING_DEVICE_PATH
,
1766 (UINT16
) sizeof (VENDOR_DEVICE_PATH
)
1769 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1771 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1775 Converts a text device path node to MAC device path structure.
1777 @param TextDeviceNode The input Text device path node.
1779 @return A pointer to the newly-created MAC device path structure.
1782 EFI_DEVICE_PATH_PROTOCOL
*
1783 DevPathFromTextMAC (
1784 IN CHAR16
*TextDeviceNode
1790 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1792 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1793 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1794 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1795 MESSAGING_DEVICE_PATH
,
1797 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1800 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1802 Length
= sizeof (EFI_MAC_ADDRESS
);
1803 if (MACDevPath
->IfType
== 0x01 || MACDevPath
->IfType
== 0x00) {
1807 StrHexToBytes (AddressStr
, Length
* 2, MACDevPath
->MacAddress
.Addr
, Length
);
1809 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1814 Converts a text format to the network protocol ID.
1816 @param Text String of protocol field.
1818 @return Network protocol ID .
1822 NetworkProtocolFromText (
1826 if (StrCmp (Text
, L
"UDP") == 0) {
1827 return RFC_1700_UDP_PROTOCOL
;
1830 if (StrCmp (Text
, L
"TCP") == 0) {
1831 return RFC_1700_TCP_PROTOCOL
;
1834 return Strtoi (Text
);
1839 Converts a text device path node to IPV4 device path structure.
1841 @param TextDeviceNode The input Text device path node.
1843 @return A pointer to the newly-created IPV4 device path structure.
1846 EFI_DEVICE_PATH_PROTOCOL
*
1847 DevPathFromTextIPv4 (
1848 IN CHAR16
*TextDeviceNode
1851 CHAR16
*RemoteIPStr
;
1852 CHAR16
*ProtocolStr
;
1855 CHAR16
*GatewayIPStr
;
1856 CHAR16
*SubnetMaskStr
;
1857 IPv4_DEVICE_PATH
*IPv4
;
1859 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1860 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1861 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1862 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1863 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1864 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
1865 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1866 MESSAGING_DEVICE_PATH
,
1868 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
1871 StrToIpv4Address (RemoteIPStr
, NULL
, &IPv4
->RemoteIpAddress
, NULL
);
1872 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1873 if (StrCmp (TypeStr
, L
"Static") == 0) {
1874 IPv4
->StaticIpAddress
= TRUE
;
1876 IPv4
->StaticIpAddress
= FALSE
;
1879 StrToIpv4Address (LocalIPStr
, NULL
, &IPv4
->LocalIpAddress
, NULL
);
1880 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
1881 StrToIpv4Address (GatewayIPStr
, NULL
, &IPv4
->GatewayIpAddress
, NULL
);
1882 StrToIpv4Address (SubnetMaskStr
, NULL
, &IPv4
->SubnetMask
, NULL
);
1884 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
1885 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
1888 IPv4
->LocalPort
= 0;
1889 IPv4
->RemotePort
= 0;
1891 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1895 Converts a text device path node to IPV6 device path structure.
1897 @param TextDeviceNode The input Text device path node.
1899 @return A pointer to the newly-created IPV6 device path structure.
1902 EFI_DEVICE_PATH_PROTOCOL
*
1903 DevPathFromTextIPv6 (
1904 IN CHAR16
*TextDeviceNode
1907 CHAR16
*RemoteIPStr
;
1908 CHAR16
*ProtocolStr
;
1911 CHAR16
*GatewayIPStr
;
1912 CHAR16
*PrefixLengthStr
;
1913 IPv6_DEVICE_PATH
*IPv6
;
1915 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1916 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1917 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1918 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1919 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
1920 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1921 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1922 MESSAGING_DEVICE_PATH
,
1924 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
1927 StrToIpv6Address (RemoteIPStr
, NULL
, &IPv6
->RemoteIpAddress
, NULL
);
1928 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1929 if (StrCmp (TypeStr
, L
"Static") == 0) {
1930 IPv6
->IpAddressOrigin
= 0;
1931 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
1932 IPv6
->IpAddressOrigin
= 1;
1934 IPv6
->IpAddressOrigin
= 2;
1937 StrToIpv6Address (LocalIPStr
, NULL
, &IPv6
->LocalIpAddress
, NULL
);
1938 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
1939 StrToIpv6Address (GatewayIPStr
, NULL
, &IPv6
->GatewayIpAddress
, NULL
);
1940 IPv6
->PrefixLength
= (UINT8
) Strtoi (PrefixLengthStr
);
1942 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
1943 IPv6
->PrefixLength
= 0;
1946 IPv6
->LocalPort
= 0;
1947 IPv6
->RemotePort
= 0;
1949 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
1953 Converts a text device path node to UART device path structure.
1955 @param TextDeviceNode The input Text device path node.
1957 @return A pointer to the newly-created UART device path structure.
1960 EFI_DEVICE_PATH_PROTOCOL
*
1961 DevPathFromTextUart (
1962 IN CHAR16
*TextDeviceNode
1966 CHAR16
*DataBitsStr
;
1968 CHAR16
*StopBitsStr
;
1969 UART_DEVICE_PATH
*Uart
;
1971 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1972 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1973 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1974 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1975 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
1976 MESSAGING_DEVICE_PATH
,
1978 (UINT16
) sizeof (UART_DEVICE_PATH
)
1981 if (StrCmp (BaudStr
, L
"DEFAULT") == 0) {
1982 Uart
->BaudRate
= 115200;
1984 Strtoi64 (BaudStr
, &Uart
->BaudRate
);
1986 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr
));
1987 switch (*ParityStr
) {
2013 Uart
->Parity
= (UINT8
) Strtoi (ParityStr
);
2017 if (StrCmp (StopBitsStr
, L
"D") == 0) {
2018 Uart
->StopBits
= (UINT8
) 0;
2019 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
2020 Uart
->StopBits
= (UINT8
) 1;
2021 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
2022 Uart
->StopBits
= (UINT8
) 2;
2023 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
2024 Uart
->StopBits
= (UINT8
) 3;
2026 Uart
->StopBits
= (UINT8
) Strtoi (StopBitsStr
);
2029 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
2033 Converts a text device path node to USB class device path structure.
2035 @param TextDeviceNode The input Text device path node.
2036 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
2038 @return A pointer to the newly-created USB class device path structure.
2041 EFI_DEVICE_PATH_PROTOCOL
*
2042 ConvertFromTextUsbClass (
2043 IN CHAR16
*TextDeviceNode
,
2044 IN USB_CLASS_TEXT
*UsbClassText
2050 CHAR16
*SubClassStr
;
2051 CHAR16
*ProtocolStr
;
2052 USB_CLASS_DEVICE_PATH
*UsbClass
;
2054 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
2055 MESSAGING_DEVICE_PATH
,
2057 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
2060 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2061 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2062 if (UsbClassText
->ClassExist
) {
2063 ClassStr
= GetNextParamStr (&TextDeviceNode
);
2064 if (*ClassStr
== L
'\0') {
2065 UsbClass
->DeviceClass
= 0xFF;
2067 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
2070 UsbClass
->DeviceClass
= UsbClassText
->Class
;
2072 if (UsbClassText
->SubClassExist
) {
2073 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
2074 if (*SubClassStr
== L
'\0') {
2075 UsbClass
->DeviceSubClass
= 0xFF;
2077 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
2080 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
2083 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2085 if (*VIDStr
== L
'\0') {
2086 UsbClass
->VendorId
= 0xFFFF;
2088 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2090 if (*PIDStr
== L
'\0') {
2091 UsbClass
->ProductId
= 0xFFFF;
2093 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2095 if (*ProtocolStr
== L
'\0') {
2096 UsbClass
->DeviceProtocol
= 0xFF;
2098 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
2101 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
2106 Converts a text device path node to USB class device path structure.
2108 @param TextDeviceNode The input Text device path node.
2110 @return A pointer to the newly-created USB class device path structure.
2113 EFI_DEVICE_PATH_PROTOCOL
*
2114 DevPathFromTextUsbClass (
2115 IN CHAR16
*TextDeviceNode
2118 USB_CLASS_TEXT UsbClassText
;
2120 UsbClassText
.ClassExist
= TRUE
;
2121 UsbClassText
.SubClassExist
= TRUE
;
2123 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2127 Converts a text device path node to USB audio device path structure.
2129 @param TextDeviceNode The input Text device path node.
2131 @return A pointer to the newly-created USB audio device path structure.
2134 EFI_DEVICE_PATH_PROTOCOL
*
2135 DevPathFromTextUsbAudio (
2136 IN CHAR16
*TextDeviceNode
2139 USB_CLASS_TEXT UsbClassText
;
2141 UsbClassText
.ClassExist
= FALSE
;
2142 UsbClassText
.Class
= USB_CLASS_AUDIO
;
2143 UsbClassText
.SubClassExist
= TRUE
;
2145 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2149 Converts a text device path node to USB CDC Control device path structure.
2151 @param TextDeviceNode The input Text device path node.
2153 @return A pointer to the newly-created USB CDC Control device path structure.
2156 EFI_DEVICE_PATH_PROTOCOL
*
2157 DevPathFromTextUsbCDCControl (
2158 IN CHAR16
*TextDeviceNode
2161 USB_CLASS_TEXT UsbClassText
;
2163 UsbClassText
.ClassExist
= FALSE
;
2164 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
2165 UsbClassText
.SubClassExist
= TRUE
;
2167 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2171 Converts a text device path node to USB HID device path structure.
2173 @param TextDeviceNode The input Text device path node.
2175 @return A pointer to the newly-created USB HID device path structure.
2178 EFI_DEVICE_PATH_PROTOCOL
*
2179 DevPathFromTextUsbHID (
2180 IN CHAR16
*TextDeviceNode
2183 USB_CLASS_TEXT UsbClassText
;
2185 UsbClassText
.ClassExist
= FALSE
;
2186 UsbClassText
.Class
= USB_CLASS_HID
;
2187 UsbClassText
.SubClassExist
= TRUE
;
2189 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2193 Converts a text device path node to USB Image device path structure.
2195 @param TextDeviceNode The input Text device path node.
2197 @return A pointer to the newly-created USB Image device path structure.
2200 EFI_DEVICE_PATH_PROTOCOL
*
2201 DevPathFromTextUsbImage (
2202 IN CHAR16
*TextDeviceNode
2205 USB_CLASS_TEXT UsbClassText
;
2207 UsbClassText
.ClassExist
= FALSE
;
2208 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2209 UsbClassText
.SubClassExist
= TRUE
;
2211 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2215 Converts a text device path node to USB Print device path structure.
2217 @param TextDeviceNode The input Text device path node.
2219 @return A pointer to the newly-created USB Print device path structure.
2222 EFI_DEVICE_PATH_PROTOCOL
*
2223 DevPathFromTextUsbPrinter (
2224 IN CHAR16
*TextDeviceNode
2227 USB_CLASS_TEXT UsbClassText
;
2229 UsbClassText
.ClassExist
= FALSE
;
2230 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2231 UsbClassText
.SubClassExist
= TRUE
;
2233 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2237 Converts a text device path node to USB mass storage device path structure.
2239 @param TextDeviceNode The input Text device path node.
2241 @return A pointer to the newly-created USB mass storage device path structure.
2244 EFI_DEVICE_PATH_PROTOCOL
*
2245 DevPathFromTextUsbMassStorage (
2246 IN CHAR16
*TextDeviceNode
2249 USB_CLASS_TEXT UsbClassText
;
2251 UsbClassText
.ClassExist
= FALSE
;
2252 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2253 UsbClassText
.SubClassExist
= TRUE
;
2255 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2259 Converts a text device path node to USB HUB device path structure.
2261 @param TextDeviceNode The input Text device path node.
2263 @return A pointer to the newly-created USB HUB device path structure.
2266 EFI_DEVICE_PATH_PROTOCOL
*
2267 DevPathFromTextUsbHub (
2268 IN CHAR16
*TextDeviceNode
2271 USB_CLASS_TEXT UsbClassText
;
2273 UsbClassText
.ClassExist
= FALSE
;
2274 UsbClassText
.Class
= USB_CLASS_HUB
;
2275 UsbClassText
.SubClassExist
= TRUE
;
2277 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2281 Converts a text device path node to USB CDC data device path structure.
2283 @param TextDeviceNode The input Text device path node.
2285 @return A pointer to the newly-created USB CDC data device path structure.
2288 EFI_DEVICE_PATH_PROTOCOL
*
2289 DevPathFromTextUsbCDCData (
2290 IN CHAR16
*TextDeviceNode
2293 USB_CLASS_TEXT UsbClassText
;
2295 UsbClassText
.ClassExist
= FALSE
;
2296 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2297 UsbClassText
.SubClassExist
= TRUE
;
2299 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2303 Converts a text device path node to USB smart card device path structure.
2305 @param TextDeviceNode The input Text device path node.
2307 @return A pointer to the newly-created USB smart card device path structure.
2310 EFI_DEVICE_PATH_PROTOCOL
*
2311 DevPathFromTextUsbSmartCard (
2312 IN CHAR16
*TextDeviceNode
2315 USB_CLASS_TEXT UsbClassText
;
2317 UsbClassText
.ClassExist
= FALSE
;
2318 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2319 UsbClassText
.SubClassExist
= TRUE
;
2321 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2325 Converts a text device path node to USB video device path structure.
2327 @param TextDeviceNode The input Text device path node.
2329 @return A pointer to the newly-created USB video device path structure.
2332 EFI_DEVICE_PATH_PROTOCOL
*
2333 DevPathFromTextUsbVideo (
2334 IN CHAR16
*TextDeviceNode
2337 USB_CLASS_TEXT UsbClassText
;
2339 UsbClassText
.ClassExist
= FALSE
;
2340 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2341 UsbClassText
.SubClassExist
= TRUE
;
2343 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2347 Converts a text device path node to USB diagnostic device path structure.
2349 @param TextDeviceNode The input Text device path node.
2351 @return A pointer to the newly-created USB diagnostic device path structure.
2354 EFI_DEVICE_PATH_PROTOCOL
*
2355 DevPathFromTextUsbDiagnostic (
2356 IN CHAR16
*TextDeviceNode
2359 USB_CLASS_TEXT UsbClassText
;
2361 UsbClassText
.ClassExist
= FALSE
;
2362 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2363 UsbClassText
.SubClassExist
= TRUE
;
2365 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2369 Converts a text device path node to USB wireless device path structure.
2371 @param TextDeviceNode The input Text device path node.
2373 @return A pointer to the newly-created USB wireless device path structure.
2376 EFI_DEVICE_PATH_PROTOCOL
*
2377 DevPathFromTextUsbWireless (
2378 IN CHAR16
*TextDeviceNode
2381 USB_CLASS_TEXT UsbClassText
;
2383 UsbClassText
.ClassExist
= FALSE
;
2384 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2385 UsbClassText
.SubClassExist
= TRUE
;
2387 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2391 Converts a text device path node to USB device firmware update device path structure.
2393 @param TextDeviceNode The input Text device path node.
2395 @return A pointer to the newly-created USB device firmware update device path structure.
2398 EFI_DEVICE_PATH_PROTOCOL
*
2399 DevPathFromTextUsbDeviceFirmwareUpdate (
2400 IN CHAR16
*TextDeviceNode
2403 USB_CLASS_TEXT UsbClassText
;
2405 UsbClassText
.ClassExist
= FALSE
;
2406 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2407 UsbClassText
.SubClassExist
= FALSE
;
2408 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2410 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2414 Converts a text device path node to USB IRDA bridge device path structure.
2416 @param TextDeviceNode The input Text device path node.
2418 @return A pointer to the newly-created USB IRDA bridge device path structure.
2421 EFI_DEVICE_PATH_PROTOCOL
*
2422 DevPathFromTextUsbIrdaBridge (
2423 IN CHAR16
*TextDeviceNode
2426 USB_CLASS_TEXT UsbClassText
;
2428 UsbClassText
.ClassExist
= FALSE
;
2429 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2430 UsbClassText
.SubClassExist
= FALSE
;
2431 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2433 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2437 Converts a text device path node to USB text and measurement device path structure.
2439 @param TextDeviceNode The input Text device path node.
2441 @return A pointer to the newly-created USB text and measurement device path structure.
2444 EFI_DEVICE_PATH_PROTOCOL
*
2445 DevPathFromTextUsbTestAndMeasurement (
2446 IN CHAR16
*TextDeviceNode
2449 USB_CLASS_TEXT UsbClassText
;
2451 UsbClassText
.ClassExist
= FALSE
;
2452 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2453 UsbClassText
.SubClassExist
= FALSE
;
2454 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2456 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2460 Converts a text device path node to USB WWID device path structure.
2462 @param TextDeviceNode The input Text device path node.
2464 @return A pointer to the newly-created USB WWID device path structure.
2467 EFI_DEVICE_PATH_PROTOCOL
*
2468 DevPathFromTextUsbWwid (
2469 IN CHAR16
*TextDeviceNode
2474 CHAR16
*InterfaceNumStr
;
2475 CHAR16
*SerialNumberStr
;
2476 USB_WWID_DEVICE_PATH
*UsbWwid
;
2477 UINTN SerialNumberStrLen
;
2479 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2480 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2481 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2482 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2483 SerialNumberStrLen
= StrLen (SerialNumberStr
);
2484 if (SerialNumberStrLen
>= 2 &&
2485 SerialNumberStr
[0] == L
'\"' &&
2486 SerialNumberStr
[SerialNumberStrLen
- 1] == L
'\"'
2488 SerialNumberStr
[SerialNumberStrLen
- 1] = L
'\0';
2490 SerialNumberStrLen
-= 2;
2492 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2493 MESSAGING_DEVICE_PATH
,
2495 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + SerialNumberStrLen
* sizeof (CHAR16
))
2497 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2498 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2499 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2502 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
2503 // Therefore, the '\0' will not be copied.
2506 (UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
),
2508 SerialNumberStrLen
* sizeof (CHAR16
)
2511 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2515 Converts a text device path node to Logic Unit device path structure.
2517 @param TextDeviceNode The input Text device path node.
2519 @return A pointer to the newly-created Logic Unit device path structure.
2522 EFI_DEVICE_PATH_PROTOCOL
*
2523 DevPathFromTextUnit (
2524 IN CHAR16
*TextDeviceNode
2528 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2530 LunStr
= GetNextParamStr (&TextDeviceNode
);
2531 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2532 MESSAGING_DEVICE_PATH
,
2533 MSG_DEVICE_LOGICAL_UNIT_DP
,
2534 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2537 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2539 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2543 Converts a text device path node to iSCSI device path structure.
2545 @param TextDeviceNode The input Text device path node.
2547 @return A pointer to the newly-created iSCSI device path structure.
2550 EFI_DEVICE_PATH_PROTOCOL
*
2551 DevPathFromTextiSCSI (
2552 IN CHAR16
*TextDeviceNode
2557 CHAR16
*PortalGroupStr
;
2559 CHAR16
*HeaderDigestStr
;
2560 CHAR16
*DataDigestStr
;
2561 CHAR16
*AuthenticationStr
;
2562 CHAR16
*ProtocolStr
;
2564 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2567 NameStr
= GetNextParamStr (&TextDeviceNode
);
2568 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2569 LunStr
= GetNextParamStr (&TextDeviceNode
);
2570 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2571 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2572 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2573 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2574 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2575 MESSAGING_DEVICE_PATH
,
2577 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2580 AsciiStr
= ISCSIDevPath
->TargetName
;
2581 StrToAscii (NameStr
, &AsciiStr
);
2583 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2584 Strtoi64 (LunStr
, &Lun
);
2585 WriteUnaligned64 ((UINT64
*) &ISCSIDevPath
->Lun
, SwapBytes64 (Lun
));
2588 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2592 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2596 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2600 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2604 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2606 if (IS_NULL (*ProtocolStr
) || (StrCmp (ProtocolStr
, L
"TCP") == 0)) {
2607 ISCSIDevPath
->NetworkProtocol
= 0;
2610 // Undefined and reserved.
2612 ISCSIDevPath
->NetworkProtocol
= 1;
2615 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2619 Converts a text device path node to VLAN device path structure.
2621 @param TextDeviceNode The input Text device path node.
2623 @return A pointer to the newly-created VLAN device path structure.
2626 EFI_DEVICE_PATH_PROTOCOL
*
2627 DevPathFromTextVlan (
2628 IN CHAR16
*TextDeviceNode
2632 VLAN_DEVICE_PATH
*Vlan
;
2634 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2635 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2636 MESSAGING_DEVICE_PATH
,
2638 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2641 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2643 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2647 Converts a text device path node to Bluetooth device path structure.
2649 @param TextDeviceNode The input Text device path node.
2651 @return A pointer to the newly-created Bluetooth device path structure.
2654 EFI_DEVICE_PATH_PROTOCOL
*
2655 DevPathFromTextBluetooth (
2656 IN CHAR16
*TextDeviceNode
2659 CHAR16
*BluetoothStr
;
2660 BLUETOOTH_DEVICE_PATH
*BluetoothDp
;
2662 BluetoothStr
= GetNextParamStr (&TextDeviceNode
);
2663 BluetoothDp
= (BLUETOOTH_DEVICE_PATH
*) CreateDeviceNode (
2664 MESSAGING_DEVICE_PATH
,
2666 (UINT16
) sizeof (BLUETOOTH_DEVICE_PATH
)
2670 sizeof (BLUETOOTH_ADDRESS
) * 2,
2671 BluetoothDp
->BD_ADDR
.Address
,
2672 sizeof (BLUETOOTH_ADDRESS
)
2674 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothDp
;
2678 Converts a text device path node to Wi-Fi device path structure.
2680 @param TextDeviceNode The input Text device path node.
2682 @return A pointer to the newly-created Wi-Fi device path structure.
2685 EFI_DEVICE_PATH_PROTOCOL
*
2686 DevPathFromTextWiFi (
2687 IN CHAR16
*TextDeviceNode
2693 WIFI_DEVICE_PATH
*WiFiDp
;
2695 SSIdStr
= GetNextParamStr (&TextDeviceNode
);
2696 WiFiDp
= (WIFI_DEVICE_PATH
*) CreateDeviceNode (
2697 MESSAGING_DEVICE_PATH
,
2699 (UINT16
) sizeof (WIFI_DEVICE_PATH
)
2702 if (NULL
!= SSIdStr
) {
2703 DataLen
= StrLen (SSIdStr
);
2704 if (StrLen (SSIdStr
) > 32) {
2705 SSIdStr
[32] = L
'\0';
2709 UnicodeStrToAsciiStrS (SSIdStr
, AsciiStr
, sizeof (AsciiStr
));
2710 CopyMem (WiFiDp
->SSId
, AsciiStr
, DataLen
);
2713 return (EFI_DEVICE_PATH_PROTOCOL
*) WiFiDp
;
2717 Converts a text device path node to Bluetooth LE device path structure.
2719 @param TextDeviceNode The input Text device path node.
2721 @return A pointer to the newly-created Bluetooth LE device path structure.
2724 EFI_DEVICE_PATH_PROTOCOL
*
2725 DevPathFromTextBluetoothLE (
2726 IN CHAR16
*TextDeviceNode
2729 CHAR16
*BluetoothLeAddrStr
;
2730 CHAR16
*BluetoothLeAddrTypeStr
;
2731 BLUETOOTH_LE_DEVICE_PATH
*BluetoothLeDp
;
2733 BluetoothLeAddrStr
= GetNextParamStr (&TextDeviceNode
);
2734 BluetoothLeAddrTypeStr
= GetNextParamStr (&TextDeviceNode
);
2735 BluetoothLeDp
= (BLUETOOTH_LE_DEVICE_PATH
*) CreateDeviceNode (
2736 MESSAGING_DEVICE_PATH
,
2737 MSG_BLUETOOTH_LE_DP
,
2738 (UINT16
) sizeof (BLUETOOTH_LE_DEVICE_PATH
)
2741 BluetoothLeDp
->Address
.Type
= (UINT8
) Strtoi (BluetoothLeAddrTypeStr
);
2743 BluetoothLeAddrStr
, sizeof (BluetoothLeDp
->Address
.Address
) * 2,
2744 BluetoothLeDp
->Address
.Address
, sizeof (BluetoothLeDp
->Address
.Address
)
2746 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothLeDp
;
2750 Converts a text device path node to DNS device path structure.
2752 @param TextDeviceNode The input Text device path node.
2754 @return A pointer to the newly-created DNS device path structure.
2757 EFI_DEVICE_PATH_PROTOCOL
*
2758 DevPathFromTextDns (
2759 IN CHAR16
*TextDeviceNode
2762 CHAR16
*DeviceNodeStr
;
2763 CHAR16
*DeviceNodeStrPtr
;
2764 UINT32 DnsServerIpCount
;
2765 UINT16 DnsDeviceNodeLength
;
2766 DNS_DEVICE_PATH
*DnsDeviceNode
;
2767 UINT32 DnsServerIpIndex
;
2768 CHAR16
*DnsServerIp
;
2772 // Count the DNS server address number.
2774 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
2775 if (DeviceNodeStr
== NULL
) {
2779 DeviceNodeStrPtr
= DeviceNodeStr
;
2781 DnsServerIpCount
= 0;
2782 while (DeviceNodeStrPtr
!= NULL
&& *DeviceNodeStrPtr
!= L
'\0') {
2783 GetNextParamStr (&DeviceNodeStrPtr
);
2784 DnsServerIpCount
++;
2787 FreePool (DeviceNodeStr
);
2788 DeviceNodeStr
= NULL
;
2791 // One or more instances of the DNS server address in EFI_IP_ADDRESS,
2792 // otherwise, NULL will be returned.
2794 if (DnsServerIpCount
== 0) {
2799 // Create the DNS DeviceNode.
2801 DnsDeviceNodeLength
= (UINT16
) (sizeof (EFI_DEVICE_PATH_PROTOCOL
) + sizeof (UINT8
) + DnsServerIpCount
* sizeof (EFI_IP_ADDRESS
));
2802 DnsDeviceNode
= (DNS_DEVICE_PATH
*) CreateDeviceNode (
2803 MESSAGING_DEVICE_PATH
,
2807 if (DnsDeviceNode
== NULL
) {
2812 // Confirm the DNS server address is IPv4 or IPv6 type.
2814 DeviceNodeStrPtr
= TextDeviceNode
;
2815 while (!IS_NULL (*DeviceNodeStrPtr
)) {
2816 if (*DeviceNodeStrPtr
== L
'.') {
2817 DnsDeviceNode
->IsIPv6
= 0x00;
2821 if (*DeviceNodeStrPtr
== L
':') {
2822 DnsDeviceNode
->IsIPv6
= 0x01;
2829 for (DnsServerIpIndex
= 0; DnsServerIpIndex
< DnsServerIpCount
; DnsServerIpIndex
++) {
2830 DnsServerIp
= GetNextParamStr (&TextDeviceNode
);
2831 if (DnsDeviceNode
->IsIPv6
== 0x00) {
2832 StrToIpv4Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v4
), NULL
);
2834 StrToIpv6Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v6
), NULL
);
2838 return (EFI_DEVICE_PATH_PROTOCOL
*) DnsDeviceNode
;
2842 Converts a text device path node to URI device path structure.
2844 @param TextDeviceNode The input Text device path node.
2846 @return A pointer to the newly-created URI device path structure.
2849 EFI_DEVICE_PATH_PROTOCOL
*
2850 DevPathFromTextUri (
2851 IN CHAR16
*TextDeviceNode
2856 URI_DEVICE_PATH
*Uri
;
2858 UriStr
= GetNextParamStr (&TextDeviceNode
);
2859 UriLength
= StrnLenS (UriStr
, MAX_UINT16
- sizeof (URI_DEVICE_PATH
));
2860 Uri
= (URI_DEVICE_PATH
*) CreateDeviceNode (
2861 MESSAGING_DEVICE_PATH
,
2863 (UINT16
) (sizeof (URI_DEVICE_PATH
) + UriLength
)
2866 while (UriLength
-- != 0) {
2867 Uri
->Uri
[UriLength
] = (CHAR8
) UriStr
[UriLength
];
2870 return (EFI_DEVICE_PATH_PROTOCOL
*) Uri
;
2874 Converts a media text device path node to media device path structure.
2876 @param TextDeviceNode The input Text device path node.
2878 @return A pointer to media device path structure.
2881 EFI_DEVICE_PATH_PROTOCOL
*
2882 DevPathFromTextMediaPath (
2883 IN CHAR16
*TextDeviceNode
2886 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH
, TextDeviceNode
);
2890 Converts a text device path node to HD device path structure.
2892 @param TextDeviceNode The input Text device path node.
2894 @return A pointer to the newly-created HD device path structure.
2897 EFI_DEVICE_PATH_PROTOCOL
*
2899 IN CHAR16
*TextDeviceNode
2902 CHAR16
*PartitionStr
;
2904 CHAR16
*SignatureStr
;
2908 HARDDRIVE_DEVICE_PATH
*Hd
;
2910 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2911 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2912 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2913 StartStr
= GetNextParamStr (&TextDeviceNode
);
2914 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2915 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2918 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2921 Hd
->PartitionNumber
= (UINT32
) Strtoi (PartitionStr
);
2923 ZeroMem (Hd
->Signature
, 16);
2924 Hd
->MBRType
= (UINT8
) 0;
2926 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2927 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2930 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2931 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2932 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2933 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2936 StrToGuid (SignatureStr
, (EFI_GUID
*) Hd
->Signature
);
2938 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2941 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2942 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2944 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2948 Converts a text device path node to CDROM device path structure.
2950 @param TextDeviceNode The input Text device path node.
2952 @return A pointer to the newly-created CDROM device path structure.
2955 EFI_DEVICE_PATH_PROTOCOL
*
2956 DevPathFromTextCDROM (
2957 IN CHAR16
*TextDeviceNode
2963 CDROM_DEVICE_PATH
*CDROMDevPath
;
2965 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2966 StartStr
= GetNextParamStr (&TextDeviceNode
);
2967 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2968 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2971 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2974 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2975 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2976 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2978 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2982 Converts a text device path node to Vendor-defined media device path structure.
2984 @param TextDeviceNode The input Text device path node.
2986 @return A pointer to the newly-created Vendor-defined media device path structure.
2989 EFI_DEVICE_PATH_PROTOCOL
*
2990 DevPathFromTextVenMedia (
2991 IN CHAR16
*TextDeviceNode
2994 return ConvertFromTextVendor (
3002 Converts a text device path node to File device path structure.
3004 @param TextDeviceNode The input Text device path node.
3006 @return A pointer to the newly-created File device path structure.
3009 EFI_DEVICE_PATH_PROTOCOL
*
3010 DevPathFromTextFilePath (
3011 IN CHAR16
*TextDeviceNode
3014 FILEPATH_DEVICE_PATH
*File
;
3016 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
3019 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
3022 StrCpyS (File
->PathName
, StrLen (TextDeviceNode
) + 1, TextDeviceNode
);
3024 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
3028 Converts a text device path node to Media protocol device path structure.
3030 @param TextDeviceNode The input Text device path node.
3032 @return A pointer to the newly-created Media protocol device path structure.
3035 EFI_DEVICE_PATH_PROTOCOL
*
3036 DevPathFromTextMedia (
3037 IN CHAR16
*TextDeviceNode
3041 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
3043 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3044 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
3047 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
3050 StrToGuid (GuidStr
, &Media
->Protocol
);
3052 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
3056 Converts a text device path node to firmware volume device path structure.
3058 @param TextDeviceNode The input Text device path node.
3060 @return A pointer to the newly-created firmware volume device path structure.
3063 EFI_DEVICE_PATH_PROTOCOL
*
3065 IN CHAR16
*TextDeviceNode
3069 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
3071 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3072 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
3074 MEDIA_PIWG_FW_VOL_DP
,
3075 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
3078 StrToGuid (GuidStr
, &Fv
->FvName
);
3080 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
3084 Converts a text device path node to firmware file device path structure.
3086 @param TextDeviceNode The input Text device path node.
3088 @return A pointer to the newly-created firmware file device path structure.
3091 EFI_DEVICE_PATH_PROTOCOL
*
3092 DevPathFromTextFvFile (
3093 IN CHAR16
*TextDeviceNode
3097 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
3099 GuidStr
= GetNextParamStr (&TextDeviceNode
);
3100 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
3102 MEDIA_PIWG_FW_FILE_DP
,
3103 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
3106 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
3108 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
3112 Converts a text device path node to text relative offset device path structure.
3114 @param TextDeviceNode The input Text device path node.
3116 @return A pointer to the newly-created Text device path structure.
3119 EFI_DEVICE_PATH_PROTOCOL
*
3120 DevPathFromTextRelativeOffsetRange (
3121 IN CHAR16
*TextDeviceNode
3124 CHAR16
*StartingOffsetStr
;
3125 CHAR16
*EndingOffsetStr
;
3126 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
3128 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
3129 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
3130 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
3132 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
3133 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
3136 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
3137 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
3139 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
3143 Converts a text device path node to text ram disk device path structure.
3145 @param TextDeviceNode The input Text device path node.
3147 @return A pointer to the newly-created Text device path structure.
3150 EFI_DEVICE_PATH_PROTOCOL
*
3151 DevPathFromTextRamDisk (
3152 IN CHAR16
*TextDeviceNode
3155 CHAR16
*StartingAddrStr
;
3156 CHAR16
*EndingAddrStr
;
3157 CHAR16
*TypeGuidStr
;
3158 CHAR16
*InstanceStr
;
3159 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3160 UINT64 StartingAddr
;
3163 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3164 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3165 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3166 TypeGuidStr
= GetNextParamStr (&TextDeviceNode
);
3167 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3170 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3173 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3174 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3175 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3176 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3177 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3178 StrToGuid (TypeGuidStr
, &RamDisk
->TypeGuid
);
3180 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3184 Converts a text device path node to text virtual disk device path structure.
3186 @param TextDeviceNode The input Text device path node.
3188 @return A pointer to the newly-created Text device path structure.
3191 EFI_DEVICE_PATH_PROTOCOL
*
3192 DevPathFromTextVirtualDisk (
3193 IN CHAR16
*TextDeviceNode
3196 CHAR16
*StartingAddrStr
;
3197 CHAR16
*EndingAddrStr
;
3198 CHAR16
*InstanceStr
;
3199 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3200 UINT64 StartingAddr
;
3203 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3204 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3205 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3207 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3210 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3213 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3214 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3215 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3216 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3217 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3218 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualDiskGuid
);
3220 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3224 Converts a text device path node to text virtual cd device path structure.
3226 @param TextDeviceNode The input Text device path node.
3228 @return A pointer to the newly-created Text device path structure.
3231 EFI_DEVICE_PATH_PROTOCOL
*
3232 DevPathFromTextVirtualCd (
3233 IN CHAR16
*TextDeviceNode
3236 CHAR16
*StartingAddrStr
;
3237 CHAR16
*EndingAddrStr
;
3238 CHAR16
*InstanceStr
;
3239 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3240 UINT64 StartingAddr
;
3243 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3244 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3245 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3247 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3250 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3253 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3254 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3255 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3256 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3257 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3258 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualCdGuid
);
3260 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3264 Converts a text device path node to text persistent virtual disk device path structure.
3266 @param TextDeviceNode The input Text device path node.
3268 @return A pointer to the newly-created Text device path structure.
3271 EFI_DEVICE_PATH_PROTOCOL
*
3272 DevPathFromTextPersistentVirtualDisk (
3273 IN CHAR16
*TextDeviceNode
3276 CHAR16
*StartingAddrStr
;
3277 CHAR16
*EndingAddrStr
;
3278 CHAR16
*InstanceStr
;
3279 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3280 UINT64 StartingAddr
;
3283 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3284 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3285 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3287 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3290 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3293 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3294 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3295 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3296 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3297 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3298 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualDiskGuid
);
3300 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3304 Converts a text device path node to text persistent virtual cd device path structure.
3306 @param TextDeviceNode The input Text device path node.
3308 @return A pointer to the newly-created Text device path structure.
3311 EFI_DEVICE_PATH_PROTOCOL
*
3312 DevPathFromTextPersistentVirtualCd (
3313 IN CHAR16
*TextDeviceNode
3316 CHAR16
*StartingAddrStr
;
3317 CHAR16
*EndingAddrStr
;
3318 CHAR16
*InstanceStr
;
3319 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3320 UINT64 StartingAddr
;
3323 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3324 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3325 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3327 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3330 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3333 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3334 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3335 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3336 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3337 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3338 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualCdGuid
);
3340 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3344 Converts a BBS text device path node to BBS device path structure.
3346 @param TextDeviceNode The input Text device path node.
3348 @return A pointer to BBS device path structure.
3351 EFI_DEVICE_PATH_PROTOCOL
*
3352 DevPathFromTextBbsPath (
3353 IN CHAR16
*TextDeviceNode
3356 return DevPathFromTextGenericPath (BBS_DEVICE_PATH
, TextDeviceNode
);
3360 Converts a text device path node to BIOS Boot Specification device path structure.
3362 @param TextDeviceNode The input Text device path node.
3364 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3367 EFI_DEVICE_PATH_PROTOCOL
*
3368 DevPathFromTextBBS (
3369 IN CHAR16
*TextDeviceNode
3376 BBS_BBS_DEVICE_PATH
*Bbs
;
3378 TypeStr
= GetNextParamStr (&TextDeviceNode
);
3379 IdStr
= GetNextParamStr (&TextDeviceNode
);
3380 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
3381 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
3384 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
3387 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
3388 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
3389 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
3390 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
3391 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
3392 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
3393 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
3394 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
3395 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
3396 Bbs
->DeviceType
= BBS_TYPE_USB
;
3397 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
3398 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
3400 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
3403 AsciiStr
= Bbs
->String
;
3404 StrToAscii (IdStr
, &AsciiStr
);
3406 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
3408 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
3412 Converts a text device path node to SATA device path structure.
3414 @param TextDeviceNode The input Text device path node.
3416 @return A pointer to the newly-created SATA device path structure.
3419 EFI_DEVICE_PATH_PROTOCOL
*
3420 DevPathFromTextSata (
3421 IN CHAR16
*TextDeviceNode
3424 SATA_DEVICE_PATH
*Sata
;
3429 Param1
= GetNextParamStr (&TextDeviceNode
);
3430 Param2
= GetNextParamStr (&TextDeviceNode
);
3431 Param3
= GetNextParamStr (&TextDeviceNode
);
3433 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
3434 MESSAGING_DEVICE_PATH
,
3436 (UINT16
) sizeof (SATA_DEVICE_PATH
)
3438 Sata
->HBAPortNumber
= (UINT16
) Strtoi (Param1
);
3441 // According to UEFI spec, if PMPN is not provided, the default is 0xFFFF
3443 if (*Param2
== L
'\0' ) {
3444 Sata
->PortMultiplierPortNumber
= 0xFFFF;
3446 Sata
->PortMultiplierPortNumber
= (UINT16
) Strtoi (Param2
);
3448 Sata
->Lun
= (UINT16
) Strtoi (Param3
);
3450 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
3453 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
3454 {L
"Path", DevPathFromTextPath
},
3456 {L
"HardwarePath", DevPathFromTextHardwarePath
},
3457 {L
"Pci", DevPathFromTextPci
},
3458 {L
"PcCard", DevPathFromTextPcCard
},
3459 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
3460 {L
"VenHw", DevPathFromTextVenHw
},
3461 {L
"Ctrl", DevPathFromTextCtrl
},
3462 {L
"BMC", DevPathFromTextBmc
},
3464 {L
"AcpiPath", DevPathFromTextAcpiPath
},
3465 {L
"Acpi", DevPathFromTextAcpi
},
3466 {L
"PciRoot", DevPathFromTextPciRoot
},
3467 {L
"PcieRoot", DevPathFromTextPcieRoot
},
3468 {L
"Floppy", DevPathFromTextFloppy
},
3469 {L
"Keyboard", DevPathFromTextKeyboard
},
3470 {L
"Serial", DevPathFromTextSerial
},
3471 {L
"ParallelPort", DevPathFromTextParallelPort
},
3472 {L
"AcpiEx", DevPathFromTextAcpiEx
},
3473 {L
"AcpiExp", DevPathFromTextAcpiExp
},
3474 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
3476 {L
"Msg", DevPathFromTextMsg
},
3477 {L
"Ata", DevPathFromTextAta
},
3478 {L
"Scsi", DevPathFromTextScsi
},
3479 {L
"Fibre", DevPathFromTextFibre
},
3480 {L
"FibreEx", DevPathFromTextFibreEx
},
3481 {L
"I1394", DevPathFromText1394
},
3482 {L
"USB", DevPathFromTextUsb
},
3483 {L
"I2O", DevPathFromTextI2O
},
3484 {L
"Infiniband", DevPathFromTextInfiniband
},
3485 {L
"VenMsg", DevPathFromTextVenMsg
},
3486 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
3487 {L
"VenVt100", DevPathFromTextVenVt100
},
3488 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
3489 {L
"VenUtf8", DevPathFromTextVenUtf8
},
3490 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
3491 {L
"SAS", DevPathFromTextSAS
},
3492 {L
"SasEx", DevPathFromTextSasEx
},
3493 {L
"NVMe", DevPathFromTextNVMe
},
3494 {L
"UFS", DevPathFromTextUfs
},
3495 {L
"SD", DevPathFromTextSd
},
3496 {L
"eMMC", DevPathFromTextEmmc
},
3497 {L
"DebugPort", DevPathFromTextDebugPort
},
3498 {L
"MAC", DevPathFromTextMAC
},
3499 {L
"IPv4", DevPathFromTextIPv4
},
3500 {L
"IPv6", DevPathFromTextIPv6
},
3501 {L
"Uart", DevPathFromTextUart
},
3502 {L
"UsbClass", DevPathFromTextUsbClass
},
3503 {L
"UsbAudio", DevPathFromTextUsbAudio
},
3504 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
3505 {L
"UsbHID", DevPathFromTextUsbHID
},
3506 {L
"UsbImage", DevPathFromTextUsbImage
},
3507 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
3508 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
3509 {L
"UsbHub", DevPathFromTextUsbHub
},
3510 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
3511 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
3512 {L
"UsbVideo", DevPathFromTextUsbVideo
},
3513 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
3514 {L
"UsbWireless", DevPathFromTextUsbWireless
},
3515 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
3516 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
3517 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
3518 {L
"UsbWwid", DevPathFromTextUsbWwid
},
3519 {L
"Unit", DevPathFromTextUnit
},
3520 {L
"iSCSI", DevPathFromTextiSCSI
},
3521 {L
"Vlan", DevPathFromTextVlan
},
3522 {L
"Dns", DevPathFromTextDns
},
3523 {L
"Uri", DevPathFromTextUri
},
3524 {L
"Bluetooth", DevPathFromTextBluetooth
},
3525 {L
"Wi-Fi", DevPathFromTextWiFi
},
3526 {L
"BluetoothLE", DevPathFromTextBluetoothLE
},
3527 {L
"MediaPath", DevPathFromTextMediaPath
},
3528 {L
"HD", DevPathFromTextHD
},
3529 {L
"CDROM", DevPathFromTextCDROM
},
3530 {L
"VenMedia", DevPathFromTextVenMedia
},
3531 {L
"Media", DevPathFromTextMedia
},
3532 {L
"Fv", DevPathFromTextFv
},
3533 {L
"FvFile", DevPathFromTextFvFile
},
3534 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
3535 {L
"RamDisk", DevPathFromTextRamDisk
},
3536 {L
"VirtualDisk", DevPathFromTextVirtualDisk
},
3537 {L
"VirtualCD", DevPathFromTextVirtualCd
},
3538 {L
"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk
},
3539 {L
"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd
},
3541 {L
"BbsPath", DevPathFromTextBbsPath
},
3542 {L
"BBS", DevPathFromTextBBS
},
3543 {L
"Sata", DevPathFromTextSata
},
3548 Convert text to the binary representation of a device node.
3550 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3551 node. Conversion starts with the first character and continues
3552 until the first non-device node character.
3554 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3555 insufficient memory or text unsupported.
3558 EFI_DEVICE_PATH_PROTOCOL
*
3560 UefiDevicePathLibConvertTextToDeviceNode (
3561 IN CONST CHAR16
*TextDeviceNode
3564 DEVICE_PATH_FROM_TEXT FromText
;
3566 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3567 CHAR16
*DeviceNodeStr
;
3570 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
3576 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
3577 ASSERT (DeviceNodeStr
!= NULL
);
3579 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3580 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
3581 if (ParamStr
!= NULL
) {
3582 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
3587 if (FromText
== NULL
) {
3591 FromText
= DevPathFromTextFilePath
;
3592 DeviceNode
= FromText (DeviceNodeStr
);
3594 DeviceNode
= FromText (ParamStr
);
3595 FreePool (ParamStr
);
3598 FreePool (DeviceNodeStr
);
3604 Convert text to the binary representation of a device path.
3607 @param TextDevicePath TextDevicePath points to the text representation of a device
3608 path. Conversion starts with the first character and continues
3609 until the first non-device node character.
3611 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3612 there was insufficient memory.
3615 EFI_DEVICE_PATH_PROTOCOL
*
3617 UefiDevicePathLibConvertTextToDevicePath (
3618 IN CONST CHAR16
*TextDevicePath
3621 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3622 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3623 CHAR16
*DevicePathStr
;
3625 CHAR16
*DeviceNodeStr
;
3626 BOOLEAN IsInstanceEnd
;
3627 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3629 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3633 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3634 ASSERT (DevicePath
!= NULL
);
3635 SetDevicePathEndNode (DevicePath
);
3637 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3639 Str
= DevicePathStr
;
3640 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3641 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3643 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3644 FreePool (DevicePath
);
3645 FreePool (DeviceNode
);
3646 DevicePath
= NewDevicePath
;
3648 if (IsInstanceEnd
) {
3649 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3650 ASSERT (DeviceNode
!= NULL
);
3651 SetDevicePathEndNode (DeviceNode
);
3652 DeviceNode
->SubType
= END_INSTANCE_DEVICE_PATH_SUBTYPE
;
3654 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3655 FreePool (DevicePath
);
3656 FreePool (DeviceNode
);
3657 DevicePath
= NewDevicePath
;
3661 FreePool (DevicePathStr
);