2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
4 Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "UefiDevicePathLib.h"
15 @param Src Source string.
17 @return The duplicated string.
21 UefiDevicePathLibStrDuplicate (
25 return AllocateCopyPool (StrSize (Src
), Src
);
30 Get parameter in a pair of parentheses follow the given node name.
31 For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".
33 @param Str Device Path Text.
34 @param NodeName Name of the node.
36 @return Parameter text for the node.
48 UINTN ParameterLength
;
51 // Check whether the node name matchs
53 NodeNameLength
= StrLen (NodeName
);
54 if (StrnCmp (Str
, NodeName
, NodeNameLength
) != 0) {
58 ParamStr
= Str
+ NodeNameLength
;
59 if (!IS_LEFT_PARENTH (*ParamStr
)) {
64 // Skip the found '(' and find first occurrence of ')'
68 StrPointer
= ParamStr
;
69 while (!IS_NULL (*StrPointer
)) {
70 if (IS_RIGHT_PARENTH (*StrPointer
)) {
76 if (IS_NULL (*StrPointer
)) {
83 ParamStr
= AllocateCopyPool ((ParameterLength
+ 1) * sizeof (CHAR16
), ParamStr
);
84 if (ParamStr
== NULL
) {
88 // Terminate the parameter string
90 ParamStr
[ParameterLength
] = L
'\0';
96 Gets the next parameter string from the list.
98 @param List A string list separated by the specified separator
100 @return A pointer to the current sub-string
109 // The separator is comma
111 return SplitStr (List
, L
',');
115 Get one device node from entire device path text.
117 @param DevicePath On input, the current Device Path node; on output, the next device path node
118 @param IsInstanceEnd This node is the end of a device path instance
120 @return A device node text or NULL if no more device node available
124 GetNextDeviceNodeStr (
126 BOOLEAN
*IsInstanceEnd
131 UINTN ParenthesesStack
;
134 if (IS_NULL (*Str
)) {
139 // Skip the leading '/', '(', ')' and ','
141 while (!IS_NULL (*Str
)) {
142 if (!IS_SLASH (*Str
) &&
144 !IS_LEFT_PARENTH (*Str
) &&
145 !IS_RIGHT_PARENTH (*Str
)) {
154 // Scan for the separator of this device node, '/' or ','
156 ParenthesesStack
= 0;
157 while (!IS_NULL (*Str
)) {
158 if ((IS_COMMA (*Str
) || IS_SLASH (*Str
)) && (ParenthesesStack
== 0)) {
162 if (IS_LEFT_PARENTH (*Str
)) {
164 } else if (IS_RIGHT_PARENTH (*Str
)) {
171 if (ParenthesesStack
!= 0) {
173 // The '(' doesn't pair with ')', invalid device path text
178 if (IS_COMMA (*Str
)) {
179 *IsInstanceEnd
= TRUE
;
183 *IsInstanceEnd
= FALSE
;
184 if (!IS_NULL (*Str
)) {
196 Converts a generic text device path node to device path structure.
198 @param Type The type of the device path node.
199 @param TextDeviceNode The input text device path node.
201 @return A pointer to device path structure.
203 EFI_DEVICE_PATH_PROTOCOL
*
204 DevPathFromTextGenericPath (
206 CHAR16
*TextDeviceNode
209 EFI_DEVICE_PATH_PROTOCOL
*Node
;
214 SubtypeStr
= GetNextParamStr (&TextDeviceNode
);
215 DataStr
= GetNextParamStr (&TextDeviceNode
);
217 if (DataStr
== NULL
) {
220 DataLength
= StrLen (DataStr
) / 2;
222 Node
= CreateDeviceNode (
224 (UINT8
) Strtoi (SubtypeStr
),
225 (UINT16
) (sizeof (EFI_DEVICE_PATH_PROTOCOL
) + DataLength
)
228 StrHexToBytes (DataStr
, DataLength
* 2, (UINT8
*) (Node
+ 1), DataLength
);
233 Converts a generic text device path node to device path structure.
235 @param TextDeviceNode The input Text device path node.
237 @return A pointer to device path structure.
240 EFI_DEVICE_PATH_PROTOCOL
*
241 DevPathFromTextPath (
242 CHAR16
*TextDeviceNode
247 TypeStr
= GetNextParamStr (&TextDeviceNode
);
249 return DevPathFromTextGenericPath ((UINT8
) Strtoi (TypeStr
), TextDeviceNode
);
253 Converts a generic hardware text device path node to Hardware device path structure.
255 @param TextDeviceNode The input Text device path node.
257 @return A pointer to Hardware device path structure.
260 EFI_DEVICE_PATH_PROTOCOL
*
261 DevPathFromTextHardwarePath (
262 CHAR16
*TextDeviceNode
265 return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH
, TextDeviceNode
);
269 Converts a text device path node to Hardware PCI device path structure.
271 @param TextDeviceNode The input Text device path node.
273 @return A pointer to Hardware PCI device path structure.
276 EFI_DEVICE_PATH_PROTOCOL
*
278 CHAR16
*TextDeviceNode
283 PCI_DEVICE_PATH
*Pci
;
285 DeviceStr
= GetNextParamStr (&TextDeviceNode
);
286 FunctionStr
= GetNextParamStr (&TextDeviceNode
);
287 Pci
= (PCI_DEVICE_PATH
*) CreateDeviceNode (
288 HARDWARE_DEVICE_PATH
,
290 (UINT16
) sizeof (PCI_DEVICE_PATH
)
293 Pci
->Function
= (UINT8
) Strtoi (FunctionStr
);
294 Pci
->Device
= (UINT8
) Strtoi (DeviceStr
);
296 return (EFI_DEVICE_PATH_PROTOCOL
*) Pci
;
300 Converts a text device path node to Hardware PC card device path structure.
302 @param TextDeviceNode The input Text device path node.
304 @return A pointer to Hardware PC card device path structure.
307 EFI_DEVICE_PATH_PROTOCOL
*
308 DevPathFromTextPcCard (
309 CHAR16
*TextDeviceNode
312 CHAR16
*FunctionNumberStr
;
313 PCCARD_DEVICE_PATH
*Pccard
;
315 FunctionNumberStr
= GetNextParamStr (&TextDeviceNode
);
316 Pccard
= (PCCARD_DEVICE_PATH
*) CreateDeviceNode (
317 HARDWARE_DEVICE_PATH
,
319 (UINT16
) sizeof (PCCARD_DEVICE_PATH
)
322 Pccard
->FunctionNumber
= (UINT8
) Strtoi (FunctionNumberStr
);
324 return (EFI_DEVICE_PATH_PROTOCOL
*) Pccard
;
328 Converts a text device path node to Hardware memory map device path structure.
330 @param TextDeviceNode The input Text device path node.
332 @return A pointer to Hardware memory map device path structure.
335 EFI_DEVICE_PATH_PROTOCOL
*
336 DevPathFromTextMemoryMapped (
337 CHAR16
*TextDeviceNode
340 CHAR16
*MemoryTypeStr
;
341 CHAR16
*StartingAddressStr
;
342 CHAR16
*EndingAddressStr
;
343 MEMMAP_DEVICE_PATH
*MemMap
;
345 MemoryTypeStr
= GetNextParamStr (&TextDeviceNode
);
346 StartingAddressStr
= GetNextParamStr (&TextDeviceNode
);
347 EndingAddressStr
= GetNextParamStr (&TextDeviceNode
);
348 MemMap
= (MEMMAP_DEVICE_PATH
*) CreateDeviceNode (
349 HARDWARE_DEVICE_PATH
,
351 (UINT16
) sizeof (MEMMAP_DEVICE_PATH
)
354 MemMap
->MemoryType
= (UINT32
) Strtoi (MemoryTypeStr
);
355 Strtoi64 (StartingAddressStr
, &MemMap
->StartingAddress
);
356 Strtoi64 (EndingAddressStr
, &MemMap
->EndingAddress
);
358 return (EFI_DEVICE_PATH_PROTOCOL
*) MemMap
;
362 Converts a text device path node to Vendor device path structure based on the input Type
365 @param TextDeviceNode The input Text device path node.
366 @param Type The type of device path node.
367 @param SubType The subtype of device path node.
369 @return A pointer to the newly-created Vendor device path structure.
372 EFI_DEVICE_PATH_PROTOCOL
*
373 ConvertFromTextVendor (
374 CHAR16
*TextDeviceNode
,
382 VENDOR_DEVICE_PATH
*Vendor
;
384 GuidStr
= GetNextParamStr (&TextDeviceNode
);
386 DataStr
= GetNextParamStr (&TextDeviceNode
);
387 Length
= StrLen (DataStr
);
389 // Two hex characters make up 1 buffer byte
391 Length
= (Length
+ 1) / 2;
393 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
396 (UINT16
) (sizeof (VENDOR_DEVICE_PATH
) + Length
)
399 StrToGuid (GuidStr
, &Vendor
->Guid
);
400 StrHexToBytes (DataStr
, Length
* 2, (UINT8
*) (Vendor
+ 1), Length
);
402 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
406 Converts a text device path node to Vendor Hardware device path structure.
408 @param TextDeviceNode The input Text device path node.
410 @return A pointer to the newly-created Vendor Hardware device path structure.
413 EFI_DEVICE_PATH_PROTOCOL
*
414 DevPathFromTextVenHw (
415 CHAR16
*TextDeviceNode
418 return ConvertFromTextVendor (
420 HARDWARE_DEVICE_PATH
,
426 Converts a text device path node to Hardware Controller device path structure.
428 @param TextDeviceNode The input Text device path node.
430 @return A pointer to the newly-created Hardware Controller device path structure.
433 EFI_DEVICE_PATH_PROTOCOL
*
434 DevPathFromTextCtrl (
435 CHAR16
*TextDeviceNode
438 CHAR16
*ControllerStr
;
439 CONTROLLER_DEVICE_PATH
*Controller
;
441 ControllerStr
= GetNextParamStr (&TextDeviceNode
);
442 Controller
= (CONTROLLER_DEVICE_PATH
*) CreateDeviceNode (
443 HARDWARE_DEVICE_PATH
,
445 (UINT16
) sizeof (CONTROLLER_DEVICE_PATH
)
447 Controller
->ControllerNumber
= (UINT32
) Strtoi (ControllerStr
);
449 return (EFI_DEVICE_PATH_PROTOCOL
*) Controller
;
453 Converts a text device path node to BMC device path structure.
455 @param TextDeviceNode The input Text device path node.
457 @return A pointer to the newly-created BMC device path structure.
460 EFI_DEVICE_PATH_PROTOCOL
*
462 CHAR16
*TextDeviceNode
465 CHAR16
*InterfaceTypeStr
;
466 CHAR16
*BaseAddressStr
;
467 BMC_DEVICE_PATH
*BmcDp
;
469 InterfaceTypeStr
= GetNextParamStr (&TextDeviceNode
);
470 BaseAddressStr
= GetNextParamStr (&TextDeviceNode
);
471 BmcDp
= (BMC_DEVICE_PATH
*) CreateDeviceNode (
472 HARDWARE_DEVICE_PATH
,
474 (UINT16
) sizeof (BMC_DEVICE_PATH
)
477 BmcDp
->InterfaceType
= (UINT8
) Strtoi (InterfaceTypeStr
);
479 (UINT64
*) (&BmcDp
->BaseAddress
),
480 StrHexToUint64 (BaseAddressStr
)
483 return (EFI_DEVICE_PATH_PROTOCOL
*) BmcDp
;
487 Converts a generic ACPI text device path node to ACPI device path structure.
489 @param TextDeviceNode The input Text device path node.
491 @return A pointer to ACPI device path structure.
494 EFI_DEVICE_PATH_PROTOCOL
*
495 DevPathFromTextAcpiPath (
496 CHAR16
*TextDeviceNode
499 return DevPathFromTextGenericPath (ACPI_DEVICE_PATH
, TextDeviceNode
);
503 Converts a string to EisaId.
505 @param Text The input string.
507 @return UINT32 EISA ID.
514 return (((Text
[0] - 'A' + 1) & 0x1f) << 10)
515 + (((Text
[1] - 'A' + 1) & 0x1f) << 5)
516 + (((Text
[2] - 'A' + 1) & 0x1f) << 0)
517 + (UINT32
) (StrHexToUint64 (&Text
[3]) << 16)
522 Converts a text device path node to ACPI HID device path structure.
524 @param TextDeviceNode The input Text device path node.
526 @return A pointer to the newly-created ACPI HID device path structure.
529 EFI_DEVICE_PATH_PROTOCOL
*
530 DevPathFromTextAcpi (
531 CHAR16
*TextDeviceNode
536 ACPI_HID_DEVICE_PATH
*Acpi
;
538 HIDStr
= GetNextParamStr (&TextDeviceNode
);
539 UIDStr
= GetNextParamStr (&TextDeviceNode
);
540 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
543 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
546 Acpi
->HID
= EisaIdFromText (HIDStr
);
547 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
549 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
553 Converts a text device path node to ACPI HID device path structure.
555 @param TextDeviceNode The input Text device path node.
556 @param PnPId The input plug and play identification.
558 @return A pointer to the newly-created ACPI HID device path structure.
561 EFI_DEVICE_PATH_PROTOCOL
*
562 ConvertFromTextAcpi (
563 CHAR16
*TextDeviceNode
,
568 ACPI_HID_DEVICE_PATH
*Acpi
;
570 UIDStr
= GetNextParamStr (&TextDeviceNode
);
571 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
574 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
577 Acpi
->HID
= EFI_PNP_ID (PnPId
);
578 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
580 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
584 Converts a text device path node to PCI root device path structure.
586 @param TextDeviceNode The input Text device path node.
588 @return A pointer to the newly-created PCI root device path structure.
591 EFI_DEVICE_PATH_PROTOCOL
*
592 DevPathFromTextPciRoot (
593 CHAR16
*TextDeviceNode
596 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a03);
600 Converts a text device path node to PCIE root device path structure.
602 @param TextDeviceNode The input Text device path node.
604 @return A pointer to the newly-created PCIE root device path structure.
607 EFI_DEVICE_PATH_PROTOCOL
*
608 DevPathFromTextPcieRoot (
609 CHAR16
*TextDeviceNode
612 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a08);
616 Converts a text device path node to Floppy device path structure.
618 @param TextDeviceNode The input Text device path node.
620 @return A pointer to the newly-created Floppy device path structure.
623 EFI_DEVICE_PATH_PROTOCOL
*
624 DevPathFromTextFloppy (
625 CHAR16
*TextDeviceNode
628 return ConvertFromTextAcpi (TextDeviceNode
, 0x0604);
632 Converts a text device path node to Keyboard device path structure.
634 @param TextDeviceNode The input Text device path node.
636 @return A pointer to the newly-created Keyboard device path structure.
639 EFI_DEVICE_PATH_PROTOCOL
*
640 DevPathFromTextKeyboard (
641 CHAR16
*TextDeviceNode
644 return ConvertFromTextAcpi (TextDeviceNode
, 0x0301);
648 Converts a text device path node to Serial device path structure.
650 @param TextDeviceNode The input Text device path node.
652 @return A pointer to the newly-created Serial device path structure.
655 EFI_DEVICE_PATH_PROTOCOL
*
656 DevPathFromTextSerial (
657 CHAR16
*TextDeviceNode
660 return ConvertFromTextAcpi (TextDeviceNode
, 0x0501);
664 Converts a text device path node to Parallel Port device path structure.
666 @param TextDeviceNode The input Text device path node.
668 @return A pointer to the newly-created Parallel Port device path structure.
671 EFI_DEVICE_PATH_PROTOCOL
*
672 DevPathFromTextParallelPort (
673 CHAR16
*TextDeviceNode
676 return ConvertFromTextAcpi (TextDeviceNode
, 0x0401);
680 Converts a text device path node to ACPI extension device path structure.
682 @param TextDeviceNode The input Text device path node.
684 @return A pointer to the newly-created ACPI extension device path structure.
687 EFI_DEVICE_PATH_PROTOCOL
*
688 DevPathFromTextAcpiEx (
689 CHAR16
*TextDeviceNode
700 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
702 HIDStr
= GetNextParamStr (&TextDeviceNode
);
703 CIDStr
= GetNextParamStr (&TextDeviceNode
);
704 UIDStr
= GetNextParamStr (&TextDeviceNode
);
705 HIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
706 CIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
707 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
709 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (HIDSTRStr
) + 1);
710 Length
= (UINT16
) (Length
+ StrLen (UIDSTRStr
) + 1);
711 Length
= (UINT16
) (Length
+ StrLen (CIDSTRStr
) + 1);
712 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
718 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
719 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
720 AcpiEx
->UID
= (UINT32
) Strtoi (UIDStr
);
722 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
723 StrToAscii (HIDSTRStr
, &AsciiStr
);
724 StrToAscii (UIDSTRStr
, &AsciiStr
);
725 StrToAscii (CIDSTRStr
, &AsciiStr
);
727 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
731 Converts a text device path node to ACPI extension device path structure.
733 @param TextDeviceNode The input Text device path node.
735 @return A pointer to the newly-created ACPI extension device path structure.
738 EFI_DEVICE_PATH_PROTOCOL
*
739 DevPathFromTextAcpiExp (
740 CHAR16
*TextDeviceNode
748 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
750 HIDStr
= GetNextParamStr (&TextDeviceNode
);
751 CIDStr
= GetNextParamStr (&TextDeviceNode
);
752 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
753 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (UIDSTRStr
) + 3);
754 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
760 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
762 // According to UEFI spec, the CID parametr is optional and has a default value of 0.
763 // So when the CID parametr is not specified or specified as 0 in the text device node.
764 // Set the CID to 0 in the ACPI extension device path structure.
766 if (*CIDStr
== L
'\0' || *CIDStr
== L
'0') {
769 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
773 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
775 // HID string is NULL
779 // Convert UID string
782 StrToAscii (UIDSTRStr
, &AsciiStr
);
784 // CID string is NULL
788 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
792 Converts a text device path node to ACPI _ADR device path structure.
794 @param TextDeviceNode The input Text device path node.
796 @return A pointer to the newly-created ACPI _ADR device path structure.
799 EFI_DEVICE_PATH_PROTOCOL
*
800 DevPathFromTextAcpiAdr (
801 CHAR16
*TextDeviceNode
804 CHAR16
*DisplayDeviceStr
;
805 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
809 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*) CreateDeviceNode (
812 (UINT16
) sizeof (ACPI_ADR_DEVICE_PATH
)
814 ASSERT (AcpiAdr
!= NULL
);
816 for (Index
= 0; ; Index
++) {
817 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
818 if (IS_NULL (*DisplayDeviceStr
)) {
822 Length
= DevicePathNodeLength (AcpiAdr
);
823 AcpiAdr
= ReallocatePool (
825 Length
+ sizeof (UINT32
),
828 ASSERT (AcpiAdr
!= NULL
);
829 SetDevicePathNodeLength (AcpiAdr
, Length
+ sizeof (UINT32
));
832 (&AcpiAdr
->ADR
)[Index
] = (UINT32
) Strtoi (DisplayDeviceStr
);
835 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
;
839 Converts a generic messaging text device path node to messaging device path structure.
841 @param TextDeviceNode The input Text device path node.
843 @return A pointer to messaging device path structure.
846 EFI_DEVICE_PATH_PROTOCOL
*
848 CHAR16
*TextDeviceNode
851 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH
, TextDeviceNode
);
855 Converts a text device path node to Parallel Port device path structure.
857 @param TextDeviceNode The input Text device path node.
859 @return A pointer to the newly-created Parallel Port device path structure.
862 EFI_DEVICE_PATH_PROTOCOL
*
864 CHAR16
*TextDeviceNode
867 CHAR16
*PrimarySecondaryStr
;
868 CHAR16
*SlaveMasterStr
;
870 ATAPI_DEVICE_PATH
*Atapi
;
872 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
873 MESSAGING_DEVICE_PATH
,
875 (UINT16
) sizeof (ATAPI_DEVICE_PATH
)
878 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
879 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
880 LunStr
= GetNextParamStr (&TextDeviceNode
);
882 if (StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) {
883 Atapi
->PrimarySecondary
= 0;
884 } else if (StrCmp (PrimarySecondaryStr
, L
"Secondary") == 0) {
885 Atapi
->PrimarySecondary
= 1;
887 Atapi
->PrimarySecondary
= (UINT8
) Strtoi (PrimarySecondaryStr
);
889 if (StrCmp (SlaveMasterStr
, L
"Master") == 0) {
890 Atapi
->SlaveMaster
= 0;
891 } else if (StrCmp (SlaveMasterStr
, L
"Slave") == 0) {
892 Atapi
->SlaveMaster
= 1;
894 Atapi
->SlaveMaster
= (UINT8
) Strtoi (SlaveMasterStr
);
897 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
899 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
903 Converts a text device path node to SCSI device path structure.
905 @param TextDeviceNode The input Text device path node.
907 @return A pointer to the newly-created SCSI device path structure.
910 EFI_DEVICE_PATH_PROTOCOL
*
911 DevPathFromTextScsi (
912 CHAR16
*TextDeviceNode
917 SCSI_DEVICE_PATH
*Scsi
;
919 PunStr
= GetNextParamStr (&TextDeviceNode
);
920 LunStr
= GetNextParamStr (&TextDeviceNode
);
921 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
922 MESSAGING_DEVICE_PATH
,
924 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
927 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
928 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
930 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
934 Converts a text device path node to Fibre device path structure.
936 @param TextDeviceNode The input Text device path node.
938 @return A pointer to the newly-created Fibre device path structure.
941 EFI_DEVICE_PATH_PROTOCOL
*
942 DevPathFromTextFibre (
943 CHAR16
*TextDeviceNode
948 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
950 WWNStr
= GetNextParamStr (&TextDeviceNode
);
951 LunStr
= GetNextParamStr (&TextDeviceNode
);
952 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
953 MESSAGING_DEVICE_PATH
,
955 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
959 Strtoi64 (WWNStr
, &Fibre
->WWN
);
960 Strtoi64 (LunStr
, &Fibre
->Lun
);
962 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
966 Converts a text device path node to FibreEx device path structure.
968 @param TextDeviceNode The input Text device path node.
970 @return A pointer to the newly-created FibreEx device path structure.
973 EFI_DEVICE_PATH_PROTOCOL
*
974 DevPathFromTextFibreEx (
975 CHAR16
*TextDeviceNode
980 FIBRECHANNELEX_DEVICE_PATH
*FibreEx
;
982 WWNStr
= GetNextParamStr (&TextDeviceNode
);
983 LunStr
= GetNextParamStr (&TextDeviceNode
);
984 FibreEx
= (FIBRECHANNELEX_DEVICE_PATH
*) CreateDeviceNode (
985 MESSAGING_DEVICE_PATH
,
986 MSG_FIBRECHANNELEX_DP
,
987 (UINT16
) sizeof (FIBRECHANNELEX_DEVICE_PATH
)
990 FibreEx
->Reserved
= 0;
991 Strtoi64 (WWNStr
, (UINT64
*) (&FibreEx
->WWN
));
992 Strtoi64 (LunStr
, (UINT64
*) (&FibreEx
->Lun
));
994 *(UINT64
*) (&FibreEx
->WWN
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->WWN
));
995 *(UINT64
*) (&FibreEx
->Lun
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->Lun
));
997 return (EFI_DEVICE_PATH_PROTOCOL
*) FibreEx
;
1001 Converts a text device path node to 1394 device path structure.
1003 @param TextDeviceNode The input Text device path node.
1005 @return A pointer to the newly-created 1394 device path structure.
1008 EFI_DEVICE_PATH_PROTOCOL
*
1009 DevPathFromText1394 (
1010 CHAR16
*TextDeviceNode
1014 F1394_DEVICE_PATH
*F1394DevPath
;
1016 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1017 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1018 MESSAGING_DEVICE_PATH
,
1020 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1023 F1394DevPath
->Reserved
= 0;
1024 F1394DevPath
->Guid
= StrHexToUint64 (GuidStr
);
1026 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1030 Converts a text device path node to USB device path structure.
1032 @param TextDeviceNode The input Text device path node.
1034 @return A pointer to the newly-created USB device path structure.
1037 EFI_DEVICE_PATH_PROTOCOL
*
1038 DevPathFromTextUsb (
1039 CHAR16
*TextDeviceNode
1043 CHAR16
*InterfaceStr
;
1044 USB_DEVICE_PATH
*Usb
;
1046 PortStr
= GetNextParamStr (&TextDeviceNode
);
1047 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1048 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1049 MESSAGING_DEVICE_PATH
,
1051 (UINT16
) sizeof (USB_DEVICE_PATH
)
1054 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1055 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1057 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1061 Converts a text device path node to I20 device path structure.
1063 @param TextDeviceNode The input Text device path node.
1065 @return A pointer to the newly-created I20 device path structure.
1068 EFI_DEVICE_PATH_PROTOCOL
*
1069 DevPathFromTextI2O (
1070 CHAR16
*TextDeviceNode
1074 I2O_DEVICE_PATH
*I2ODevPath
;
1076 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1077 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1078 MESSAGING_DEVICE_PATH
,
1080 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1083 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1085 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1089 Converts a text device path node to Infini Band device path structure.
1091 @param TextDeviceNode The input Text device path node.
1093 @return A pointer to the newly-created Infini Band device path structure.
1096 EFI_DEVICE_PATH_PROTOCOL
*
1097 DevPathFromTextInfiniband (
1098 CHAR16
*TextDeviceNode
1106 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1108 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1109 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1110 SidStr
= GetNextParamStr (&TextDeviceNode
);
1111 TidStr
= GetNextParamStr (&TextDeviceNode
);
1112 DidStr
= GetNextParamStr (&TextDeviceNode
);
1113 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1114 MESSAGING_DEVICE_PATH
,
1116 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1119 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1120 StrToGuid (GuidStr
, (EFI_GUID
*) InfiniBand
->PortGid
);
1121 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1122 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1123 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1125 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1129 Converts a text device path node to Vendor-Defined Messaging device path structure.
1131 @param TextDeviceNode The input Text device path node.
1133 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1136 EFI_DEVICE_PATH_PROTOCOL
*
1137 DevPathFromTextVenMsg (
1138 CHAR16
*TextDeviceNode
1141 return ConvertFromTextVendor (
1143 MESSAGING_DEVICE_PATH
,
1149 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1151 @param TextDeviceNode The input Text device path node.
1153 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1156 EFI_DEVICE_PATH_PROTOCOL
*
1157 DevPathFromTextVenPcAnsi (
1158 CHAR16
*TextDeviceNode
1161 VENDOR_DEVICE_PATH
*Vendor
;
1163 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1164 MESSAGING_DEVICE_PATH
,
1166 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1167 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1169 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1173 Converts a text device path node to Vendor defined VT100 device path structure.
1175 @param TextDeviceNode The input Text device path node.
1177 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1180 EFI_DEVICE_PATH_PROTOCOL
*
1181 DevPathFromTextVenVt100 (
1182 CHAR16
*TextDeviceNode
1185 VENDOR_DEVICE_PATH
*Vendor
;
1187 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1188 MESSAGING_DEVICE_PATH
,
1190 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1191 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1193 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1197 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1199 @param TextDeviceNode The input Text device path node.
1201 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1204 EFI_DEVICE_PATH_PROTOCOL
*
1205 DevPathFromTextVenVt100Plus (
1206 CHAR16
*TextDeviceNode
1209 VENDOR_DEVICE_PATH
*Vendor
;
1211 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1212 MESSAGING_DEVICE_PATH
,
1214 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1215 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1217 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1221 Converts a text device path node to Vendor defined UTF8 device path structure.
1223 @param TextDeviceNode The input Text device path node.
1225 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1228 EFI_DEVICE_PATH_PROTOCOL
*
1229 DevPathFromTextVenUtf8 (
1230 CHAR16
*TextDeviceNode
1233 VENDOR_DEVICE_PATH
*Vendor
;
1235 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1236 MESSAGING_DEVICE_PATH
,
1238 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1239 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1241 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1245 Converts a text device path node to UART Flow Control device path structure.
1247 @param TextDeviceNode The input Text device path node.
1249 @return A pointer to the newly-created UART Flow Control device path structure.
1252 EFI_DEVICE_PATH_PROTOCOL
*
1253 DevPathFromTextUartFlowCtrl (
1254 CHAR16
*TextDeviceNode
1258 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1260 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1261 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1262 MESSAGING_DEVICE_PATH
,
1264 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1267 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1268 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1269 UartFlowControl
->FlowControlMap
= 2;
1270 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1271 UartFlowControl
->FlowControlMap
= 1;
1273 UartFlowControl
->FlowControlMap
= 0;
1276 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1280 Converts a text device path node to Serial Attached SCSI device path structure.
1282 @param TextDeviceNode The input Text device path node.
1284 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1287 EFI_DEVICE_PATH_PROTOCOL
*
1288 DevPathFromTextSAS (
1289 CHAR16
*TextDeviceNode
1296 CHAR16
*LocationStr
;
1298 CHAR16
*DriveBayStr
;
1299 CHAR16
*ReservedStr
;
1302 SAS_DEVICE_PATH
*Sas
;
1304 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1305 LunStr
= GetNextParamStr (&TextDeviceNode
);
1306 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1307 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1308 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1309 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1310 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1311 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1312 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1313 MESSAGING_DEVICE_PATH
,
1315 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1318 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1319 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1320 Strtoi64 (LunStr
, &Sas
->Lun
);
1321 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1323 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1326 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1328 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1332 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1335 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1340 // Location is an integer between 0 and 1 or else
1341 // the keyword Internal (0) or External (1).
1343 if (StrCmp (LocationStr
, L
"External") == 0) {
1345 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1348 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1350 Info
|= (Uint16
<< 5);
1353 // Connect is an integer between 0 and 3 or else
1354 // the keyword Direct (0) or Expanded (1).
1356 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1358 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1361 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1363 Info
|= (Uint16
<< 6);
1366 Info
= (UINT16
) Strtoi (SASSATAStr
);
1369 Sas
->DeviceTopology
= Info
;
1370 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1372 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1376 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1378 @param TextDeviceNode The input Text device path node.
1380 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1383 EFI_DEVICE_PATH_PROTOCOL
*
1384 DevPathFromTextSasEx (
1385 CHAR16
*TextDeviceNode
1392 CHAR16
*LocationStr
;
1394 CHAR16
*DriveBayStr
;
1399 SASEX_DEVICE_PATH
*SasEx
;
1401 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1402 LunStr
= GetNextParamStr (&TextDeviceNode
);
1403 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1404 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1405 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1406 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1407 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1408 SasEx
= (SASEX_DEVICE_PATH
*) CreateDeviceNode (
1409 MESSAGING_DEVICE_PATH
,
1411 (UINT16
) sizeof (SASEX_DEVICE_PATH
)
1414 Strtoi64 (AddressStr
, &SasAddress
);
1415 Strtoi64 (LunStr
, &Lun
);
1416 WriteUnaligned64 ((UINT64
*) &SasEx
->SasAddress
, SwapBytes64 (SasAddress
));
1417 WriteUnaligned64 ((UINT64
*) &SasEx
->Lun
, SwapBytes64 (Lun
));
1418 SasEx
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1420 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1423 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1425 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1429 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1432 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1437 // Location is an integer between 0 and 1 or else
1438 // the keyword Internal (0) or External (1).
1440 if (StrCmp (LocationStr
, L
"External") == 0) {
1442 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1445 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1447 Info
|= (Uint16
<< 5);
1450 // Connect is an integer between 0 and 3 or else
1451 // the keyword Direct (0) or Expanded (1).
1453 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1455 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1458 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1460 Info
|= (Uint16
<< 6);
1463 Info
= (UINT16
) Strtoi (SASSATAStr
);
1466 SasEx
->DeviceTopology
= Info
;
1468 return (EFI_DEVICE_PATH_PROTOCOL
*) SasEx
;
1472 Converts a text device path node to NVM Express Namespace device path structure.
1474 @param TextDeviceNode The input Text device path node.
1476 @return A pointer to the newly-created NVM Express Namespace device path structure.
1479 EFI_DEVICE_PATH_PROTOCOL
*
1480 DevPathFromTextNVMe (
1481 CHAR16
*TextDeviceNode
1484 CHAR16
*NamespaceIdStr
;
1485 CHAR16
*NamespaceUuidStr
;
1486 NVME_NAMESPACE_DEVICE_PATH
*Nvme
;
1490 NamespaceIdStr
= GetNextParamStr (&TextDeviceNode
);
1491 NamespaceUuidStr
= GetNextParamStr (&TextDeviceNode
);
1492 Nvme
= (NVME_NAMESPACE_DEVICE_PATH
*) CreateDeviceNode (
1493 MESSAGING_DEVICE_PATH
,
1494 MSG_NVME_NAMESPACE_DP
,
1495 (UINT16
) sizeof (NVME_NAMESPACE_DEVICE_PATH
)
1498 Nvme
->NamespaceId
= (UINT32
) Strtoi (NamespaceIdStr
);
1499 Uuid
= (UINT8
*) &Nvme
->NamespaceUuid
;
1501 Index
= sizeof (Nvme
->NamespaceUuid
) / sizeof (UINT8
);
1502 while (Index
-- != 0) {
1503 Uuid
[Index
] = (UINT8
) StrHexToUint64 (SplitStr (&NamespaceUuidStr
, L
'-'));
1506 return (EFI_DEVICE_PATH_PROTOCOL
*) Nvme
;
1510 Converts a text device path node to UFS device path structure.
1512 @param TextDeviceNode The input Text device path node.
1514 @return A pointer to the newly-created UFS device path structure.
1517 EFI_DEVICE_PATH_PROTOCOL
*
1518 DevPathFromTextUfs (
1519 CHAR16
*TextDeviceNode
1524 UFS_DEVICE_PATH
*Ufs
;
1526 PunStr
= GetNextParamStr (&TextDeviceNode
);
1527 LunStr
= GetNextParamStr (&TextDeviceNode
);
1528 Ufs
= (UFS_DEVICE_PATH
*) CreateDeviceNode (
1529 MESSAGING_DEVICE_PATH
,
1531 (UINT16
) sizeof (UFS_DEVICE_PATH
)
1534 Ufs
->Pun
= (UINT8
) Strtoi (PunStr
);
1535 Ufs
->Lun
= (UINT8
) Strtoi (LunStr
);
1537 return (EFI_DEVICE_PATH_PROTOCOL
*) Ufs
;
1541 Converts a text device path node to SD (Secure Digital) device path structure.
1543 @param TextDeviceNode The input Text device path node.
1545 @return A pointer to the newly-created SD device path structure.
1548 EFI_DEVICE_PATH_PROTOCOL
*
1550 CHAR16
*TextDeviceNode
1553 CHAR16
*SlotNumberStr
;
1556 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1557 Sd
= (SD_DEVICE_PATH
*) CreateDeviceNode (
1558 MESSAGING_DEVICE_PATH
,
1560 (UINT16
) sizeof (SD_DEVICE_PATH
)
1563 Sd
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1565 return (EFI_DEVICE_PATH_PROTOCOL
*) Sd
;
1569 Converts a text device path node to EMMC (Embedded MMC) device path structure.
1571 @param TextDeviceNode The input Text device path node.
1573 @return A pointer to the newly-created EMMC device path structure.
1576 EFI_DEVICE_PATH_PROTOCOL
*
1577 DevPathFromTextEmmc (
1578 CHAR16
*TextDeviceNode
1581 CHAR16
*SlotNumberStr
;
1582 EMMC_DEVICE_PATH
*Emmc
;
1584 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1585 Emmc
= (EMMC_DEVICE_PATH
*) CreateDeviceNode (
1586 MESSAGING_DEVICE_PATH
,
1588 (UINT16
) sizeof (EMMC_DEVICE_PATH
)
1591 Emmc
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1593 return (EFI_DEVICE_PATH_PROTOCOL
*) Emmc
;
1597 Converts a text device path node to Debug Port device path structure.
1599 @param TextDeviceNode The input Text device path node.
1601 @return A pointer to the newly-created Debug Port device path structure.
1604 EFI_DEVICE_PATH_PROTOCOL
*
1605 DevPathFromTextDebugPort (
1606 CHAR16
*TextDeviceNode
1609 VENDOR_DEVICE_PATH
*Vend
;
1611 Vend
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1612 MESSAGING_DEVICE_PATH
,
1614 (UINT16
) sizeof (VENDOR_DEVICE_PATH
)
1617 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1619 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1623 Converts a text device path node to MAC device path structure.
1625 @param TextDeviceNode The input Text device path node.
1627 @return A pointer to the newly-created MAC device path structure.
1630 EFI_DEVICE_PATH_PROTOCOL
*
1631 DevPathFromTextMAC (
1632 CHAR16
*TextDeviceNode
1638 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1640 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1641 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1642 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1643 MESSAGING_DEVICE_PATH
,
1645 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1648 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1650 Length
= sizeof (EFI_MAC_ADDRESS
);
1651 if (MACDevPath
->IfType
== 0x01 || MACDevPath
->IfType
== 0x00) {
1655 StrHexToBytes (AddressStr
, Length
* 2, MACDevPath
->MacAddress
.Addr
, Length
);
1657 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1662 Converts a text format to the network protocol ID.
1664 @param Text String of protocol field.
1666 @return Network protocol ID .
1670 NetworkProtocolFromText (
1674 if (StrCmp (Text
, L
"UDP") == 0) {
1675 return RFC_1700_UDP_PROTOCOL
;
1678 if (StrCmp (Text
, L
"TCP") == 0) {
1679 return RFC_1700_TCP_PROTOCOL
;
1682 return Strtoi (Text
);
1687 Converts a text device path node to IPV4 device path structure.
1689 @param TextDeviceNode The input Text device path node.
1691 @return A pointer to the newly-created IPV4 device path structure.
1694 EFI_DEVICE_PATH_PROTOCOL
*
1695 DevPathFromTextIPv4 (
1696 CHAR16
*TextDeviceNode
1699 CHAR16
*RemoteIPStr
;
1700 CHAR16
*ProtocolStr
;
1703 CHAR16
*GatewayIPStr
;
1704 CHAR16
*SubnetMaskStr
;
1705 IPv4_DEVICE_PATH
*IPv4
;
1707 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1708 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1709 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1710 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1711 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1712 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
1713 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1714 MESSAGING_DEVICE_PATH
,
1716 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
1719 StrToIpv4Address (RemoteIPStr
, NULL
, &IPv4
->RemoteIpAddress
, NULL
);
1720 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1721 if (StrCmp (TypeStr
, L
"Static") == 0) {
1722 IPv4
->StaticIpAddress
= TRUE
;
1724 IPv4
->StaticIpAddress
= FALSE
;
1727 StrToIpv4Address (LocalIPStr
, NULL
, &IPv4
->LocalIpAddress
, NULL
);
1728 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
1729 StrToIpv4Address (GatewayIPStr
, NULL
, &IPv4
->GatewayIpAddress
, NULL
);
1730 StrToIpv4Address (SubnetMaskStr
, NULL
, &IPv4
->SubnetMask
, NULL
);
1732 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
1733 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
1736 IPv4
->LocalPort
= 0;
1737 IPv4
->RemotePort
= 0;
1739 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1743 Converts a text device path node to IPV6 device path structure.
1745 @param TextDeviceNode The input Text device path node.
1747 @return A pointer to the newly-created IPV6 device path structure.
1750 EFI_DEVICE_PATH_PROTOCOL
*
1751 DevPathFromTextIPv6 (
1752 CHAR16
*TextDeviceNode
1755 CHAR16
*RemoteIPStr
;
1756 CHAR16
*ProtocolStr
;
1759 CHAR16
*GatewayIPStr
;
1760 CHAR16
*PrefixLengthStr
;
1761 IPv6_DEVICE_PATH
*IPv6
;
1763 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1764 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1765 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1766 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1767 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
1768 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1769 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1770 MESSAGING_DEVICE_PATH
,
1772 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
1775 StrToIpv6Address (RemoteIPStr
, NULL
, &IPv6
->RemoteIpAddress
, NULL
);
1776 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1777 if (StrCmp (TypeStr
, L
"Static") == 0) {
1778 IPv6
->IpAddressOrigin
= 0;
1779 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
1780 IPv6
->IpAddressOrigin
= 1;
1782 IPv6
->IpAddressOrigin
= 2;
1785 StrToIpv6Address (LocalIPStr
, NULL
, &IPv6
->LocalIpAddress
, NULL
);
1786 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
1787 StrToIpv6Address (GatewayIPStr
, NULL
, &IPv6
->GatewayIpAddress
, NULL
);
1788 IPv6
->PrefixLength
= (UINT8
) Strtoi (PrefixLengthStr
);
1790 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
1791 IPv6
->PrefixLength
= 0;
1794 IPv6
->LocalPort
= 0;
1795 IPv6
->RemotePort
= 0;
1797 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
1801 Converts a text device path node to UART device path structure.
1803 @param TextDeviceNode The input Text device path node.
1805 @return A pointer to the newly-created UART device path structure.
1808 EFI_DEVICE_PATH_PROTOCOL
*
1809 DevPathFromTextUart (
1810 CHAR16
*TextDeviceNode
1814 CHAR16
*DataBitsStr
;
1816 CHAR16
*StopBitsStr
;
1817 UART_DEVICE_PATH
*Uart
;
1819 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1820 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1821 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1822 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1823 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
1824 MESSAGING_DEVICE_PATH
,
1826 (UINT16
) sizeof (UART_DEVICE_PATH
)
1829 if (StrCmp (BaudStr
, L
"DEFAULT") == 0) {
1830 Uart
->BaudRate
= 115200;
1832 Strtoi64 (BaudStr
, &Uart
->BaudRate
);
1834 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr
));
1835 switch (*ParityStr
) {
1861 Uart
->Parity
= (UINT8
) Strtoi (ParityStr
);
1865 if (StrCmp (StopBitsStr
, L
"D") == 0) {
1866 Uart
->StopBits
= (UINT8
) 0;
1867 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
1868 Uart
->StopBits
= (UINT8
) 1;
1869 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
1870 Uart
->StopBits
= (UINT8
) 2;
1871 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
1872 Uart
->StopBits
= (UINT8
) 3;
1874 Uart
->StopBits
= (UINT8
) Strtoi (StopBitsStr
);
1877 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
1881 Converts a text device path node to USB class device path structure.
1883 @param TextDeviceNode The input Text device path node.
1884 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
1886 @return A pointer to the newly-created USB class device path structure.
1889 EFI_DEVICE_PATH_PROTOCOL
*
1890 ConvertFromTextUsbClass (
1891 CHAR16
*TextDeviceNode
,
1892 USB_CLASS_TEXT
*UsbClassText
1898 CHAR16
*SubClassStr
;
1899 CHAR16
*ProtocolStr
;
1900 USB_CLASS_DEVICE_PATH
*UsbClass
;
1902 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
1903 MESSAGING_DEVICE_PATH
,
1905 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
1908 VIDStr
= GetNextParamStr (&TextDeviceNode
);
1909 PIDStr
= GetNextParamStr (&TextDeviceNode
);
1910 if (UsbClassText
->ClassExist
) {
1911 ClassStr
= GetNextParamStr (&TextDeviceNode
);
1912 if (*ClassStr
== L
'\0') {
1913 UsbClass
->DeviceClass
= 0xFF;
1915 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
1918 UsbClass
->DeviceClass
= UsbClassText
->Class
;
1920 if (UsbClassText
->SubClassExist
) {
1921 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
1922 if (*SubClassStr
== L
'\0') {
1923 UsbClass
->DeviceSubClass
= 0xFF;
1925 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
1928 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
1931 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1933 if (*VIDStr
== L
'\0') {
1934 UsbClass
->VendorId
= 0xFFFF;
1936 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
1938 if (*PIDStr
== L
'\0') {
1939 UsbClass
->ProductId
= 0xFFFF;
1941 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
1943 if (*ProtocolStr
== L
'\0') {
1944 UsbClass
->DeviceProtocol
= 0xFF;
1946 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
1949 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
1954 Converts a text device path node to USB class device path structure.
1956 @param TextDeviceNode The input Text device path node.
1958 @return A pointer to the newly-created USB class device path structure.
1961 EFI_DEVICE_PATH_PROTOCOL
*
1962 DevPathFromTextUsbClass (
1963 CHAR16
*TextDeviceNode
1966 USB_CLASS_TEXT UsbClassText
;
1968 UsbClassText
.ClassExist
= TRUE
;
1969 UsbClassText
.SubClassExist
= TRUE
;
1971 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1975 Converts a text device path node to USB audio device path structure.
1977 @param TextDeviceNode The input Text device path node.
1979 @return A pointer to the newly-created USB audio device path structure.
1982 EFI_DEVICE_PATH_PROTOCOL
*
1983 DevPathFromTextUsbAudio (
1984 CHAR16
*TextDeviceNode
1987 USB_CLASS_TEXT UsbClassText
;
1989 UsbClassText
.ClassExist
= FALSE
;
1990 UsbClassText
.Class
= USB_CLASS_AUDIO
;
1991 UsbClassText
.SubClassExist
= TRUE
;
1993 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1997 Converts a text device path node to USB CDC Control device path structure.
1999 @param TextDeviceNode The input Text device path node.
2001 @return A pointer to the newly-created USB CDC Control device path structure.
2004 EFI_DEVICE_PATH_PROTOCOL
*
2005 DevPathFromTextUsbCDCControl (
2006 CHAR16
*TextDeviceNode
2009 USB_CLASS_TEXT UsbClassText
;
2011 UsbClassText
.ClassExist
= FALSE
;
2012 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
2013 UsbClassText
.SubClassExist
= TRUE
;
2015 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2019 Converts a text device path node to USB HID device path structure.
2021 @param TextDeviceNode The input Text device path node.
2023 @return A pointer to the newly-created USB HID device path structure.
2026 EFI_DEVICE_PATH_PROTOCOL
*
2027 DevPathFromTextUsbHID (
2028 CHAR16
*TextDeviceNode
2031 USB_CLASS_TEXT UsbClassText
;
2033 UsbClassText
.ClassExist
= FALSE
;
2034 UsbClassText
.Class
= USB_CLASS_HID
;
2035 UsbClassText
.SubClassExist
= TRUE
;
2037 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2041 Converts a text device path node to USB Image device path structure.
2043 @param TextDeviceNode The input Text device path node.
2045 @return A pointer to the newly-created USB Image device path structure.
2048 EFI_DEVICE_PATH_PROTOCOL
*
2049 DevPathFromTextUsbImage (
2050 CHAR16
*TextDeviceNode
2053 USB_CLASS_TEXT UsbClassText
;
2055 UsbClassText
.ClassExist
= FALSE
;
2056 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2057 UsbClassText
.SubClassExist
= TRUE
;
2059 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2063 Converts a text device path node to USB Print device path structure.
2065 @param TextDeviceNode The input Text device path node.
2067 @return A pointer to the newly-created USB Print device path structure.
2070 EFI_DEVICE_PATH_PROTOCOL
*
2071 DevPathFromTextUsbPrinter (
2072 CHAR16
*TextDeviceNode
2075 USB_CLASS_TEXT UsbClassText
;
2077 UsbClassText
.ClassExist
= FALSE
;
2078 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2079 UsbClassText
.SubClassExist
= TRUE
;
2081 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2085 Converts a text device path node to USB mass storage device path structure.
2087 @param TextDeviceNode The input Text device path node.
2089 @return A pointer to the newly-created USB mass storage device path structure.
2092 EFI_DEVICE_PATH_PROTOCOL
*
2093 DevPathFromTextUsbMassStorage (
2094 CHAR16
*TextDeviceNode
2097 USB_CLASS_TEXT UsbClassText
;
2099 UsbClassText
.ClassExist
= FALSE
;
2100 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2101 UsbClassText
.SubClassExist
= TRUE
;
2103 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2107 Converts a text device path node to USB HUB device path structure.
2109 @param TextDeviceNode The input Text device path node.
2111 @return A pointer to the newly-created USB HUB device path structure.
2114 EFI_DEVICE_PATH_PROTOCOL
*
2115 DevPathFromTextUsbHub (
2116 CHAR16
*TextDeviceNode
2119 USB_CLASS_TEXT UsbClassText
;
2121 UsbClassText
.ClassExist
= FALSE
;
2122 UsbClassText
.Class
= USB_CLASS_HUB
;
2123 UsbClassText
.SubClassExist
= TRUE
;
2125 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2129 Converts a text device path node to USB CDC data device path structure.
2131 @param TextDeviceNode The input Text device path node.
2133 @return A pointer to the newly-created USB CDC data device path structure.
2136 EFI_DEVICE_PATH_PROTOCOL
*
2137 DevPathFromTextUsbCDCData (
2138 CHAR16
*TextDeviceNode
2141 USB_CLASS_TEXT UsbClassText
;
2143 UsbClassText
.ClassExist
= FALSE
;
2144 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2145 UsbClassText
.SubClassExist
= TRUE
;
2147 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2151 Converts a text device path node to USB smart card device path structure.
2153 @param TextDeviceNode The input Text device path node.
2155 @return A pointer to the newly-created USB smart card device path structure.
2158 EFI_DEVICE_PATH_PROTOCOL
*
2159 DevPathFromTextUsbSmartCard (
2160 CHAR16
*TextDeviceNode
2163 USB_CLASS_TEXT UsbClassText
;
2165 UsbClassText
.ClassExist
= FALSE
;
2166 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2167 UsbClassText
.SubClassExist
= TRUE
;
2169 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2173 Converts a text device path node to USB video device path structure.
2175 @param TextDeviceNode The input Text device path node.
2177 @return A pointer to the newly-created USB video device path structure.
2180 EFI_DEVICE_PATH_PROTOCOL
*
2181 DevPathFromTextUsbVideo (
2182 CHAR16
*TextDeviceNode
2185 USB_CLASS_TEXT UsbClassText
;
2187 UsbClassText
.ClassExist
= FALSE
;
2188 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2189 UsbClassText
.SubClassExist
= TRUE
;
2191 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2195 Converts a text device path node to USB diagnostic device path structure.
2197 @param TextDeviceNode The input Text device path node.
2199 @return A pointer to the newly-created USB diagnostic device path structure.
2202 EFI_DEVICE_PATH_PROTOCOL
*
2203 DevPathFromTextUsbDiagnostic (
2204 CHAR16
*TextDeviceNode
2207 USB_CLASS_TEXT UsbClassText
;
2209 UsbClassText
.ClassExist
= FALSE
;
2210 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2211 UsbClassText
.SubClassExist
= TRUE
;
2213 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2217 Converts a text device path node to USB wireless device path structure.
2219 @param TextDeviceNode The input Text device path node.
2221 @return A pointer to the newly-created USB wireless device path structure.
2224 EFI_DEVICE_PATH_PROTOCOL
*
2225 DevPathFromTextUsbWireless (
2226 CHAR16
*TextDeviceNode
2229 USB_CLASS_TEXT UsbClassText
;
2231 UsbClassText
.ClassExist
= FALSE
;
2232 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2233 UsbClassText
.SubClassExist
= TRUE
;
2235 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2239 Converts a text device path node to USB device firmware update device path structure.
2241 @param TextDeviceNode The input Text device path node.
2243 @return A pointer to the newly-created USB device firmware update device path structure.
2246 EFI_DEVICE_PATH_PROTOCOL
*
2247 DevPathFromTextUsbDeviceFirmwareUpdate (
2248 CHAR16
*TextDeviceNode
2251 USB_CLASS_TEXT UsbClassText
;
2253 UsbClassText
.ClassExist
= FALSE
;
2254 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2255 UsbClassText
.SubClassExist
= FALSE
;
2256 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2258 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2262 Converts a text device path node to USB IRDA bridge device path structure.
2264 @param TextDeviceNode The input Text device path node.
2266 @return A pointer to the newly-created USB IRDA bridge device path structure.
2269 EFI_DEVICE_PATH_PROTOCOL
*
2270 DevPathFromTextUsbIrdaBridge (
2271 CHAR16
*TextDeviceNode
2274 USB_CLASS_TEXT UsbClassText
;
2276 UsbClassText
.ClassExist
= FALSE
;
2277 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2278 UsbClassText
.SubClassExist
= FALSE
;
2279 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2281 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2285 Converts a text device path node to USB text and measurement device path structure.
2287 @param TextDeviceNode The input Text device path node.
2289 @return A pointer to the newly-created USB text and measurement device path structure.
2292 EFI_DEVICE_PATH_PROTOCOL
*
2293 DevPathFromTextUsbTestAndMeasurement (
2294 CHAR16
*TextDeviceNode
2297 USB_CLASS_TEXT UsbClassText
;
2299 UsbClassText
.ClassExist
= FALSE
;
2300 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2301 UsbClassText
.SubClassExist
= FALSE
;
2302 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2304 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2308 Converts a text device path node to USB WWID device path structure.
2310 @param TextDeviceNode The input Text device path node.
2312 @return A pointer to the newly-created USB WWID device path structure.
2315 EFI_DEVICE_PATH_PROTOCOL
*
2316 DevPathFromTextUsbWwid (
2317 CHAR16
*TextDeviceNode
2322 CHAR16
*InterfaceNumStr
;
2323 CHAR16
*SerialNumberStr
;
2324 USB_WWID_DEVICE_PATH
*UsbWwid
;
2325 UINTN SerialNumberStrLen
;
2327 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2328 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2329 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2330 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2331 SerialNumberStrLen
= StrLen (SerialNumberStr
);
2332 if (SerialNumberStrLen
>= 2 &&
2333 SerialNumberStr
[0] == L
'\"' &&
2334 SerialNumberStr
[SerialNumberStrLen
- 1] == L
'\"'
2336 SerialNumberStr
[SerialNumberStrLen
- 1] = L
'\0';
2338 SerialNumberStrLen
-= 2;
2340 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2341 MESSAGING_DEVICE_PATH
,
2343 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + SerialNumberStrLen
* sizeof (CHAR16
))
2345 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2346 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2347 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2350 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
2351 // Therefore, the '\0' will not be copied.
2354 (UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
),
2356 SerialNumberStrLen
* sizeof (CHAR16
)
2359 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2363 Converts a text device path node to Logic Unit device path structure.
2365 @param TextDeviceNode The input Text device path node.
2367 @return A pointer to the newly-created Logic Unit device path structure.
2370 EFI_DEVICE_PATH_PROTOCOL
*
2371 DevPathFromTextUnit (
2372 CHAR16
*TextDeviceNode
2376 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2378 LunStr
= GetNextParamStr (&TextDeviceNode
);
2379 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2380 MESSAGING_DEVICE_PATH
,
2381 MSG_DEVICE_LOGICAL_UNIT_DP
,
2382 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2385 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2387 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2391 Converts a text device path node to iSCSI device path structure.
2393 @param TextDeviceNode The input Text device path node.
2395 @return A pointer to the newly-created iSCSI device path structure.
2398 EFI_DEVICE_PATH_PROTOCOL
*
2399 DevPathFromTextiSCSI (
2400 CHAR16
*TextDeviceNode
2405 CHAR16
*PortalGroupStr
;
2407 CHAR16
*HeaderDigestStr
;
2408 CHAR16
*DataDigestStr
;
2409 CHAR16
*AuthenticationStr
;
2410 CHAR16
*ProtocolStr
;
2412 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2415 NameStr
= GetNextParamStr (&TextDeviceNode
);
2416 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2417 LunStr
= GetNextParamStr (&TextDeviceNode
);
2418 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2419 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2420 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2421 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2422 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2423 MESSAGING_DEVICE_PATH
,
2425 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2428 AsciiStr
= ISCSIDevPath
->TargetName
;
2429 StrToAscii (NameStr
, &AsciiStr
);
2431 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2432 Strtoi64 (LunStr
, &Lun
);
2433 WriteUnaligned64 ((UINT64
*) &ISCSIDevPath
->Lun
, SwapBytes64 (Lun
));
2436 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2440 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2444 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2448 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2452 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2454 if (IS_NULL (*ProtocolStr
) || (StrCmp (ProtocolStr
, L
"TCP") == 0)) {
2455 ISCSIDevPath
->NetworkProtocol
= 0;
2458 // Undefined and reserved.
2460 ISCSIDevPath
->NetworkProtocol
= 1;
2463 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2467 Converts a text device path node to VLAN device path structure.
2469 @param TextDeviceNode The input Text device path node.
2471 @return A pointer to the newly-created VLAN device path structure.
2474 EFI_DEVICE_PATH_PROTOCOL
*
2475 DevPathFromTextVlan (
2476 CHAR16
*TextDeviceNode
2480 VLAN_DEVICE_PATH
*Vlan
;
2482 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2483 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2484 MESSAGING_DEVICE_PATH
,
2486 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2489 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2491 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2495 Converts a text device path node to Bluetooth device path structure.
2497 @param TextDeviceNode The input Text device path node.
2499 @return A pointer to the newly-created Bluetooth device path structure.
2502 EFI_DEVICE_PATH_PROTOCOL
*
2503 DevPathFromTextBluetooth (
2504 CHAR16
*TextDeviceNode
2507 CHAR16
*BluetoothStr
;
2508 BLUETOOTH_DEVICE_PATH
*BluetoothDp
;
2510 BluetoothStr
= GetNextParamStr (&TextDeviceNode
);
2511 BluetoothDp
= (BLUETOOTH_DEVICE_PATH
*) CreateDeviceNode (
2512 MESSAGING_DEVICE_PATH
,
2514 (UINT16
) sizeof (BLUETOOTH_DEVICE_PATH
)
2518 sizeof (BLUETOOTH_ADDRESS
) * 2,
2519 BluetoothDp
->BD_ADDR
.Address
,
2520 sizeof (BLUETOOTH_ADDRESS
)
2522 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothDp
;
2526 Converts a text device path node to Wi-Fi device path structure.
2528 @param TextDeviceNode The input Text device path node.
2530 @return A pointer to the newly-created Wi-Fi device path structure.
2533 EFI_DEVICE_PATH_PROTOCOL
*
2534 DevPathFromTextWiFi (
2535 CHAR16
*TextDeviceNode
2541 WIFI_DEVICE_PATH
*WiFiDp
;
2543 SSIdStr
= GetNextParamStr (&TextDeviceNode
);
2544 WiFiDp
= (WIFI_DEVICE_PATH
*) CreateDeviceNode (
2545 MESSAGING_DEVICE_PATH
,
2547 (UINT16
) sizeof (WIFI_DEVICE_PATH
)
2550 if (NULL
!= SSIdStr
) {
2551 DataLen
= StrLen (SSIdStr
);
2552 if (StrLen (SSIdStr
) > 32) {
2553 SSIdStr
[32] = L
'\0';
2557 UnicodeStrToAsciiStrS (SSIdStr
, AsciiStr
, sizeof (AsciiStr
));
2558 memcpy (WiFiDp
->SSId
, AsciiStr
, DataLen
);
2561 return (EFI_DEVICE_PATH_PROTOCOL
*) WiFiDp
;
2565 Converts a text device path node to Bluetooth LE device path structure.
2567 @param TextDeviceNode The input Text device path node.
2569 @return A pointer to the newly-created Bluetooth LE device path structure.
2572 EFI_DEVICE_PATH_PROTOCOL
*
2573 DevPathFromTextBluetoothLE (
2574 IN CHAR16
*TextDeviceNode
2577 CHAR16
*BluetoothLeAddrStr
;
2578 CHAR16
*BluetoothLeAddrTypeStr
;
2579 BLUETOOTH_LE_DEVICE_PATH
*BluetoothLeDp
;
2581 BluetoothLeAddrStr
= GetNextParamStr (&TextDeviceNode
);
2582 BluetoothLeAddrTypeStr
= GetNextParamStr (&TextDeviceNode
);
2583 BluetoothLeDp
= (BLUETOOTH_LE_DEVICE_PATH
*) CreateDeviceNode (
2584 MESSAGING_DEVICE_PATH
,
2585 MSG_BLUETOOTH_LE_DP
,
2586 (UINT16
) sizeof (BLUETOOTH_LE_DEVICE_PATH
)
2589 BluetoothLeDp
->Address
.Type
= (UINT8
) Strtoi (BluetoothLeAddrTypeStr
);
2591 BluetoothLeAddrStr
, sizeof (BluetoothLeDp
->Address
.Address
) * 2,
2592 BluetoothLeDp
->Address
.Address
, sizeof (BluetoothLeDp
->Address
.Address
)
2594 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothLeDp
;
2598 Converts a text device path node to DNS device path structure.
2600 @param TextDeviceNode The input Text device path node.
2602 @return A pointer to the newly-created DNS device path structure.
2605 EFI_DEVICE_PATH_PROTOCOL
*
2606 DevPathFromTextDns (
2607 IN CHAR16
*TextDeviceNode
2610 CHAR16
*DeviceNodeStr
;
2611 CHAR16
*DeviceNodeStrPtr
;
2612 UINT32 DnsServerIpCount
;
2613 UINT16 DnsDeviceNodeLength
;
2614 DNS_DEVICE_PATH
*DnsDeviceNode
;
2615 UINT32 DnsServerIpIndex
;
2616 CHAR16
*DnsServerIp
;
2620 // Count the DNS server address number.
2622 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
2623 if (DeviceNodeStr
== NULL
) {
2627 DeviceNodeStrPtr
= DeviceNodeStr
;
2629 DnsServerIpCount
= 0;
2630 while (DeviceNodeStrPtr
!= NULL
&& *DeviceNodeStrPtr
!= L
'\0') {
2631 GetNextParamStr (&DeviceNodeStrPtr
);
2632 DnsServerIpCount
++;
2635 free (DeviceNodeStr
);
2636 DeviceNodeStr
= NULL
;
2639 // One or more instances of the DNS server address in EFI_IP_ADDRESS,
2640 // otherwise, NULL will be returned.
2642 if (DnsServerIpCount
== 0) {
2647 // Create the DNS DeviceNode.
2649 DnsDeviceNodeLength
= (UINT16
) (sizeof (EFI_DEVICE_PATH_PROTOCOL
) + sizeof (UINT8
) + DnsServerIpCount
* sizeof (EFI_IP_ADDRESS
));
2650 DnsDeviceNode
= (DNS_DEVICE_PATH
*) CreateDeviceNode (
2651 MESSAGING_DEVICE_PATH
,
2655 if (DnsDeviceNode
== NULL
) {
2660 // Confirm the DNS server address is IPv4 or IPv6 type.
2662 DeviceNodeStrPtr
= TextDeviceNode
;
2663 while (!IS_NULL (*DeviceNodeStrPtr
)) {
2664 if (*DeviceNodeStrPtr
== L
'.') {
2665 DnsDeviceNode
->IsIPv6
= 0x00;
2669 if (*DeviceNodeStrPtr
== L
':') {
2670 DnsDeviceNode
->IsIPv6
= 0x01;
2677 for (DnsServerIpIndex
= 0; DnsServerIpIndex
< DnsServerIpCount
; DnsServerIpIndex
++) {
2678 DnsServerIp
= GetNextParamStr (&TextDeviceNode
);
2679 if (DnsDeviceNode
->IsIPv6
== 0x00) {
2680 StrToIpv4Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v4
), NULL
);
2682 StrToIpv6Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v6
), NULL
);
2686 return (EFI_DEVICE_PATH_PROTOCOL
*) DnsDeviceNode
;
2690 Converts a text device path node to URI device path structure.
2692 @param TextDeviceNode The input Text device path node.
2694 @return A pointer to the newly-created URI device path structure.
2697 EFI_DEVICE_PATH_PROTOCOL
*
2698 DevPathFromTextUri (
2699 CHAR16
*TextDeviceNode
2704 URI_DEVICE_PATH
*Uri
;
2706 UriStr
= GetNextParamStr (&TextDeviceNode
);
2707 UriLength
= StrnLenS (UriStr
, MAX_UINT16
- sizeof (URI_DEVICE_PATH
));
2708 Uri
= (URI_DEVICE_PATH
*) CreateDeviceNode (
2709 MESSAGING_DEVICE_PATH
,
2711 (UINT16
) (sizeof (URI_DEVICE_PATH
) + UriLength
)
2714 while (UriLength
-- != 0) {
2715 Uri
->Uri
[UriLength
] = (CHAR8
) UriStr
[UriLength
];
2718 return (EFI_DEVICE_PATH_PROTOCOL
*) Uri
;
2722 Converts a media text device path node to media device path structure.
2724 @param TextDeviceNode The input Text device path node.
2726 @return A pointer to media device path structure.
2729 EFI_DEVICE_PATH_PROTOCOL
*
2730 DevPathFromTextMediaPath (
2731 CHAR16
*TextDeviceNode
2734 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH
, TextDeviceNode
);
2738 Converts a text device path node to HD device path structure.
2740 @param TextDeviceNode The input Text device path node.
2742 @return A pointer to the newly-created HD device path structure.
2745 EFI_DEVICE_PATH_PROTOCOL
*
2747 CHAR16
*TextDeviceNode
2750 CHAR16
*PartitionStr
;
2752 CHAR16
*SignatureStr
;
2756 HARDDRIVE_DEVICE_PATH
*Hd
;
2758 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2759 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2760 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2761 StartStr
= GetNextParamStr (&TextDeviceNode
);
2762 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2763 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2766 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2769 Hd
->PartitionNumber
= (UINT32
) Strtoi (PartitionStr
);
2771 ZeroMem (Hd
->Signature
, 16);
2772 Hd
->MBRType
= (UINT8
) 0;
2774 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2775 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2778 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2779 memcpy (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2780 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2781 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2784 StrToGuid (SignatureStr
, (EFI_GUID
*) Hd
->Signature
);
2786 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2789 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2790 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2792 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2796 Converts a text device path node to CDROM device path structure.
2798 @param TextDeviceNode The input Text device path node.
2800 @return A pointer to the newly-created CDROM device path structure.
2803 EFI_DEVICE_PATH_PROTOCOL
*
2804 DevPathFromTextCDROM (
2805 CHAR16
*TextDeviceNode
2811 CDROM_DEVICE_PATH
*CDROMDevPath
;
2813 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2814 StartStr
= GetNextParamStr (&TextDeviceNode
);
2815 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2816 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2819 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2822 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2823 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2824 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2826 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2830 Converts a text device path node to Vendor-defined media device path structure.
2832 @param TextDeviceNode The input Text device path node.
2834 @return A pointer to the newly-created Vendor-defined media device path structure.
2837 EFI_DEVICE_PATH_PROTOCOL
*
2838 DevPathFromTextVenMedia (
2839 CHAR16
*TextDeviceNode
2842 return ConvertFromTextVendor (
2850 Converts a text device path node to File device path structure.
2852 @param TextDeviceNode The input Text device path node.
2854 @return A pointer to the newly-created File device path structure.
2857 EFI_DEVICE_PATH_PROTOCOL
*
2858 DevPathFromTextFilePath (
2859 CHAR16
*TextDeviceNode
2862 FILEPATH_DEVICE_PATH
*File
;
2864 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2867 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
2870 StrCpyS (File
->PathName
, StrLen (TextDeviceNode
) + 1, TextDeviceNode
);
2872 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
2876 Converts a text device path node to Media protocol device path structure.
2878 @param TextDeviceNode The input Text device path node.
2880 @return A pointer to the newly-created Media protocol device path structure.
2883 EFI_DEVICE_PATH_PROTOCOL
*
2884 DevPathFromTextMedia (
2885 CHAR16
*TextDeviceNode
2889 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
2891 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2892 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
2895 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
2898 StrToGuid (GuidStr
, &Media
->Protocol
);
2900 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
2904 Converts a text device path node to firmware volume device path structure.
2906 @param TextDeviceNode The input Text device path node.
2908 @return A pointer to the newly-created firmware volume device path structure.
2911 EFI_DEVICE_PATH_PROTOCOL
*
2913 CHAR16
*TextDeviceNode
2917 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
2919 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2920 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
2922 MEDIA_PIWG_FW_VOL_DP
,
2923 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
2926 StrToGuid (GuidStr
, &Fv
->FvName
);
2928 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
2932 Converts a text device path node to firmware file device path structure.
2934 @param TextDeviceNode The input Text device path node.
2936 @return A pointer to the newly-created firmware file device path structure.
2939 EFI_DEVICE_PATH_PROTOCOL
*
2940 DevPathFromTextFvFile (
2941 CHAR16
*TextDeviceNode
2945 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
2947 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2948 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2950 MEDIA_PIWG_FW_FILE_DP
,
2951 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
2954 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
2956 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
2960 Converts a text device path node to text relative offset device path structure.
2962 @param TextDeviceNode The input Text device path node.
2964 @return A pointer to the newly-created Text device path structure.
2967 EFI_DEVICE_PATH_PROTOCOL
*
2968 DevPathFromTextRelativeOffsetRange (
2969 CHAR16
*TextDeviceNode
2972 CHAR16
*StartingOffsetStr
;
2973 CHAR16
*EndingOffsetStr
;
2974 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
2976 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2977 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2978 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
2980 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
2981 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
2984 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
2985 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
2987 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
2991 Converts a text device path node to text ram disk device path structure.
2993 @param TextDeviceNode The input Text device path node.
2995 @return A pointer to the newly-created Text device path structure.
2998 EFI_DEVICE_PATH_PROTOCOL
*
2999 DevPathFromTextRamDisk (
3000 CHAR16
*TextDeviceNode
3003 CHAR16
*StartingAddrStr
;
3004 CHAR16
*EndingAddrStr
;
3005 CHAR16
*TypeGuidStr
;
3006 CHAR16
*InstanceStr
;
3007 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3008 UINT64 StartingAddr
;
3011 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3012 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3013 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3014 TypeGuidStr
= GetNextParamStr (&TextDeviceNode
);
3015 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3018 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3021 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3022 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3023 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3024 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3025 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3026 StrToGuid (TypeGuidStr
, &RamDisk
->TypeGuid
);
3028 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3032 Converts a text device path node to text virtual disk device path structure.
3034 @param TextDeviceNode The input Text device path node.
3036 @return A pointer to the newly-created Text device path structure.
3039 EFI_DEVICE_PATH_PROTOCOL
*
3040 DevPathFromTextVirtualDisk (
3041 CHAR16
*TextDeviceNode
3044 CHAR16
*StartingAddrStr
;
3045 CHAR16
*EndingAddrStr
;
3046 CHAR16
*InstanceStr
;
3047 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3048 UINT64 StartingAddr
;
3051 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3052 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3053 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3055 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3058 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3061 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3062 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3063 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3064 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3065 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3066 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualDiskGuid
);
3068 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3072 Converts a text device path node to text virtual cd device path structure.
3074 @param TextDeviceNode The input Text device path node.
3076 @return A pointer to the newly-created Text device path structure.
3079 EFI_DEVICE_PATH_PROTOCOL
*
3080 DevPathFromTextVirtualCd (
3081 CHAR16
*TextDeviceNode
3084 CHAR16
*StartingAddrStr
;
3085 CHAR16
*EndingAddrStr
;
3086 CHAR16
*InstanceStr
;
3087 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3088 UINT64 StartingAddr
;
3091 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3092 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3093 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3095 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3098 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3101 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3102 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3103 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3104 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3105 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3106 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualCdGuid
);
3108 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3112 Converts a text device path node to text persistent virtual disk 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 DevPathFromTextPersistentVirtualDisk (
3121 CHAR16
*TextDeviceNode
3124 CHAR16
*StartingAddrStr
;
3125 CHAR16
*EndingAddrStr
;
3126 CHAR16
*InstanceStr
;
3127 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3128 UINT64 StartingAddr
;
3131 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3132 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3133 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3135 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3138 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3141 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3142 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3143 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3144 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3145 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3146 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualDiskGuid
);
3148 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3152 Converts a text device path node to text persistent virtual cd 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 DevPathFromTextPersistentVirtualCd (
3161 CHAR16
*TextDeviceNode
3164 CHAR16
*StartingAddrStr
;
3165 CHAR16
*EndingAddrStr
;
3166 CHAR16
*InstanceStr
;
3167 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3168 UINT64 StartingAddr
;
3171 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3172 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3173 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3175 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3178 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3181 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3182 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3183 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3184 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3185 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3186 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualCdGuid
);
3188 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3192 Converts a BBS text device path node to BBS device path structure.
3194 @param TextDeviceNode The input Text device path node.
3196 @return A pointer to BBS device path structure.
3199 EFI_DEVICE_PATH_PROTOCOL
*
3200 DevPathFromTextBbsPath (
3201 CHAR16
*TextDeviceNode
3204 return DevPathFromTextGenericPath (BBS_DEVICE_PATH
, TextDeviceNode
);
3208 Converts a text device path node to BIOS Boot Specification device path structure.
3210 @param TextDeviceNode The input Text device path node.
3212 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3215 EFI_DEVICE_PATH_PROTOCOL
*
3216 DevPathFromTextBBS (
3217 CHAR16
*TextDeviceNode
3224 BBS_BBS_DEVICE_PATH
*Bbs
;
3226 TypeStr
= GetNextParamStr (&TextDeviceNode
);
3227 IdStr
= GetNextParamStr (&TextDeviceNode
);
3228 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
3229 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
3232 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
3235 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
3236 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
3237 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
3238 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
3239 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
3240 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
3241 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
3242 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
3243 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
3244 Bbs
->DeviceType
= BBS_TYPE_USB
;
3245 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
3246 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
3248 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
3251 AsciiStr
= Bbs
->String
;
3252 StrToAscii (IdStr
, &AsciiStr
);
3254 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
3256 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
3260 Converts a text device path node to SATA device path structure.
3262 @param TextDeviceNode The input Text device path node.
3264 @return A pointer to the newly-created SATA device path structure.
3267 EFI_DEVICE_PATH_PROTOCOL
*
3268 DevPathFromTextSata (
3269 CHAR16
*TextDeviceNode
3272 SATA_DEVICE_PATH
*Sata
;
3277 Param1
= GetNextParamStr (&TextDeviceNode
);
3278 Param2
= GetNextParamStr (&TextDeviceNode
);
3279 Param3
= GetNextParamStr (&TextDeviceNode
);
3281 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
3282 MESSAGING_DEVICE_PATH
,
3284 (UINT16
) sizeof (SATA_DEVICE_PATH
)
3286 Sata
->HBAPortNumber
= (UINT16
) Strtoi (Param1
);
3289 // According to UEFI spec, if PMPN is not provided, the default is 0xFFFF
3291 if (*Param2
== L
'\0' ) {
3292 Sata
->PortMultiplierPortNumber
= 0xFFFF;
3294 Sata
->PortMultiplierPortNumber
= (UINT16
) Strtoi (Param2
);
3296 Sata
->Lun
= (UINT16
) Strtoi (Param3
);
3298 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
3301 DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
3302 {L
"Path", DevPathFromTextPath
},
3304 {L
"HardwarePath", DevPathFromTextHardwarePath
},
3305 {L
"Pci", DevPathFromTextPci
},
3306 {L
"PcCard", DevPathFromTextPcCard
},
3307 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
3308 {L
"VenHw", DevPathFromTextVenHw
},
3309 {L
"Ctrl", DevPathFromTextCtrl
},
3310 {L
"BMC", DevPathFromTextBmc
},
3312 {L
"AcpiPath", DevPathFromTextAcpiPath
},
3313 {L
"Acpi", DevPathFromTextAcpi
},
3314 {L
"PciRoot", DevPathFromTextPciRoot
},
3315 {L
"PcieRoot", DevPathFromTextPcieRoot
},
3316 {L
"Floppy", DevPathFromTextFloppy
},
3317 {L
"Keyboard", DevPathFromTextKeyboard
},
3318 {L
"Serial", DevPathFromTextSerial
},
3319 {L
"ParallelPort", DevPathFromTextParallelPort
},
3320 {L
"AcpiEx", DevPathFromTextAcpiEx
},
3321 {L
"AcpiExp", DevPathFromTextAcpiExp
},
3322 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
3324 {L
"Msg", DevPathFromTextMsg
},
3325 {L
"Ata", DevPathFromTextAta
},
3326 {L
"Scsi", DevPathFromTextScsi
},
3327 {L
"Fibre", DevPathFromTextFibre
},
3328 {L
"FibreEx", DevPathFromTextFibreEx
},
3329 {L
"I1394", DevPathFromText1394
},
3330 {L
"USB", DevPathFromTextUsb
},
3331 {L
"I2O", DevPathFromTextI2O
},
3332 {L
"Infiniband", DevPathFromTextInfiniband
},
3333 {L
"VenMsg", DevPathFromTextVenMsg
},
3334 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
3335 {L
"VenVt100", DevPathFromTextVenVt100
},
3336 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
3337 {L
"VenUtf8", DevPathFromTextVenUtf8
},
3338 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
3339 {L
"SAS", DevPathFromTextSAS
},
3340 {L
"SasEx", DevPathFromTextSasEx
},
3341 {L
"NVMe", DevPathFromTextNVMe
},
3342 {L
"UFS", DevPathFromTextUfs
},
3343 {L
"SD", DevPathFromTextSd
},
3344 {L
"eMMC", DevPathFromTextEmmc
},
3345 {L
"DebugPort", DevPathFromTextDebugPort
},
3346 {L
"MAC", DevPathFromTextMAC
},
3347 {L
"IPv4", DevPathFromTextIPv4
},
3348 {L
"IPv6", DevPathFromTextIPv6
},
3349 {L
"Uart", DevPathFromTextUart
},
3350 {L
"UsbClass", DevPathFromTextUsbClass
},
3351 {L
"UsbAudio", DevPathFromTextUsbAudio
},
3352 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
3353 {L
"UsbHID", DevPathFromTextUsbHID
},
3354 {L
"UsbImage", DevPathFromTextUsbImage
},
3355 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
3356 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
3357 {L
"UsbHub", DevPathFromTextUsbHub
},
3358 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
3359 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
3360 {L
"UsbVideo", DevPathFromTextUsbVideo
},
3361 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
3362 {L
"UsbWireless", DevPathFromTextUsbWireless
},
3363 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
3364 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
3365 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
3366 {L
"UsbWwid", DevPathFromTextUsbWwid
},
3367 {L
"Unit", DevPathFromTextUnit
},
3368 {L
"iSCSI", DevPathFromTextiSCSI
},
3369 {L
"Vlan", DevPathFromTextVlan
},
3370 {L
"Dns", DevPathFromTextDns
},
3371 {L
"Uri", DevPathFromTextUri
},
3372 {L
"Bluetooth", DevPathFromTextBluetooth
},
3373 {L
"Wi-Fi", DevPathFromTextWiFi
},
3374 {L
"BluetoothLE", DevPathFromTextBluetoothLE
},
3375 {L
"MediaPath", DevPathFromTextMediaPath
},
3376 {L
"HD", DevPathFromTextHD
},
3377 {L
"CDROM", DevPathFromTextCDROM
},
3378 {L
"VenMedia", DevPathFromTextVenMedia
},
3379 {L
"Media", DevPathFromTextMedia
},
3380 {L
"Fv", DevPathFromTextFv
},
3381 {L
"FvFile", DevPathFromTextFvFile
},
3382 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
3383 {L
"RamDisk", DevPathFromTextRamDisk
},
3384 {L
"VirtualDisk", DevPathFromTextVirtualDisk
},
3385 {L
"VirtualCD", DevPathFromTextVirtualCd
},
3386 {L
"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk
},
3387 {L
"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd
},
3389 {L
"BbsPath", DevPathFromTextBbsPath
},
3390 {L
"BBS", DevPathFromTextBBS
},
3391 {L
"Sata", DevPathFromTextSata
},
3396 Convert text to the binary representation of a device node.
3398 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3399 node. Conversion starts with the first character and continues
3400 until the first non-device node character.
3402 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3403 insufficient memory or text unsupported.
3406 EFI_DEVICE_PATH_PROTOCOL
*
3407 UefiDevicePathLibConvertTextToDeviceNode (
3408 CONST CHAR16
*TextDeviceNode
3411 DEVICE_PATH_FROM_TEXT FromText
;
3413 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3414 CHAR16
*DeviceNodeStr
;
3417 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
3423 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
3424 ASSERT (DeviceNodeStr
!= NULL
);
3426 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3427 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
3428 if (ParamStr
!= NULL
) {
3429 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
3434 if (FromText
== NULL
) {
3438 FromText
= DevPathFromTextFilePath
;
3439 DeviceNode
= FromText (DeviceNodeStr
);
3441 // According to above logic, if 'FromText' is NULL in the 'if' statement,
3442 // then 'ParamStr' must be NULL as well. No memory allocation has been made
3445 // The below check is for addressing a false positive potential memory leak
3446 // issue raised from static analysis.
3448 if (ParamStr
!= NULL
) {
3452 DeviceNode
= FromText (ParamStr
);
3456 free (DeviceNodeStr
);
3462 Convert text to the binary representation of a device path.
3465 @param TextDevicePath TextDevicePath points to the text representation of a device
3466 path. Conversion starts with the first character and continues
3467 until the first non-device node character.
3469 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3470 there was insufficient memory.
3473 EFI_DEVICE_PATH_PROTOCOL
*
3474 UefiDevicePathLibConvertTextToDevicePath (
3475 CONST CHAR16
*TextDevicePath
3478 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3479 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3480 CHAR16
*DevicePathStr
;
3482 CHAR16
*DeviceNodeStr
;
3483 BOOLEAN IsInstanceEnd
;
3484 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3486 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3490 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3491 ASSERT (DevicePath
!= NULL
);
3492 SetDevicePathEndNode (DevicePath
);
3494 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3496 Str
= DevicePathStr
;
3497 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3498 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3500 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3503 DevicePath
= NewDevicePath
;
3505 if (IsInstanceEnd
) {
3506 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3507 ASSERT (DeviceNode
!= NULL
);
3508 SetDevicePathEndNode (DeviceNode
);
3509 DeviceNode
->SubType
= END_INSTANCE_DEVICE_PATH_SUBTYPE
;
3511 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3514 DevicePath
= NewDevicePath
;
3518 free (DevicePathStr
);