2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
4 Copyright (c) 2017 - 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 the next parameter string from the list.
104 @param List A string list separated by the specified separator
106 @return A pointer to the current sub-string
115 // The separator is comma
117 return SplitStr (List
, L
',');
121 Get one device node from entire device path text.
123 @param DevicePath On input, the current Device Path node; on output, the next device path node
124 @param IsInstanceEnd This node is the end of a device path instance
126 @return A device node text or NULL if no more device node available
130 GetNextDeviceNodeStr (
132 BOOLEAN
*IsInstanceEnd
137 UINTN ParenthesesStack
;
140 if (IS_NULL (*Str
)) {
145 // Skip the leading '/', '(', ')' and ','
147 while (!IS_NULL (*Str
)) {
148 if (!IS_SLASH (*Str
) &&
150 !IS_LEFT_PARENTH (*Str
) &&
151 !IS_RIGHT_PARENTH (*Str
)) {
160 // Scan for the separator of this device node, '/' or ','
162 ParenthesesStack
= 0;
163 while (!IS_NULL (*Str
)) {
164 if ((IS_COMMA (*Str
) || IS_SLASH (*Str
)) && (ParenthesesStack
== 0)) {
168 if (IS_LEFT_PARENTH (*Str
)) {
170 } else if (IS_RIGHT_PARENTH (*Str
)) {
177 if (ParenthesesStack
!= 0) {
179 // The '(' doesn't pair with ')', invalid device path text
184 if (IS_COMMA (*Str
)) {
185 *IsInstanceEnd
= TRUE
;
189 *IsInstanceEnd
= FALSE
;
190 if (!IS_NULL (*Str
)) {
202 Converts a generic text device path node to device path structure.
204 @param Type The type of the device path node.
205 @param TextDeviceNode The input text device path node.
207 @return A pointer to device path structure.
209 EFI_DEVICE_PATH_PROTOCOL
*
210 DevPathFromTextGenericPath (
212 CHAR16
*TextDeviceNode
215 EFI_DEVICE_PATH_PROTOCOL
*Node
;
220 SubtypeStr
= GetNextParamStr (&TextDeviceNode
);
221 DataStr
= GetNextParamStr (&TextDeviceNode
);
223 if (DataStr
== NULL
) {
226 DataLength
= StrLen (DataStr
) / 2;
228 Node
= CreateDeviceNode (
230 (UINT8
) Strtoi (SubtypeStr
),
231 (UINT16
) (sizeof (EFI_DEVICE_PATH_PROTOCOL
) + DataLength
)
234 StrHexToBytes (DataStr
, DataLength
* 2, (UINT8
*) (Node
+ 1), DataLength
);
239 Converts a generic text device path node to device path structure.
241 @param TextDeviceNode The input Text device path node.
243 @return A pointer to device path structure.
246 EFI_DEVICE_PATH_PROTOCOL
*
247 DevPathFromTextPath (
248 CHAR16
*TextDeviceNode
253 TypeStr
= GetNextParamStr (&TextDeviceNode
);
255 return DevPathFromTextGenericPath ((UINT8
) Strtoi (TypeStr
), TextDeviceNode
);
259 Converts a generic hardware text device path node to Hardware device path structure.
261 @param TextDeviceNode The input Text device path node.
263 @return A pointer to Hardware device path structure.
266 EFI_DEVICE_PATH_PROTOCOL
*
267 DevPathFromTextHardwarePath (
268 CHAR16
*TextDeviceNode
271 return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH
, TextDeviceNode
);
275 Converts a text device path node to Hardware PCI device path structure.
277 @param TextDeviceNode The input Text device path node.
279 @return A pointer to Hardware PCI device path structure.
282 EFI_DEVICE_PATH_PROTOCOL
*
284 CHAR16
*TextDeviceNode
289 PCI_DEVICE_PATH
*Pci
;
291 DeviceStr
= GetNextParamStr (&TextDeviceNode
);
292 FunctionStr
= GetNextParamStr (&TextDeviceNode
);
293 Pci
= (PCI_DEVICE_PATH
*) CreateDeviceNode (
294 HARDWARE_DEVICE_PATH
,
296 (UINT16
) sizeof (PCI_DEVICE_PATH
)
299 Pci
->Function
= (UINT8
) Strtoi (FunctionStr
);
300 Pci
->Device
= (UINT8
) Strtoi (DeviceStr
);
302 return (EFI_DEVICE_PATH_PROTOCOL
*) Pci
;
306 Converts a text device path node to Hardware PC card device path structure.
308 @param TextDeviceNode The input Text device path node.
310 @return A pointer to Hardware PC card device path structure.
313 EFI_DEVICE_PATH_PROTOCOL
*
314 DevPathFromTextPcCard (
315 CHAR16
*TextDeviceNode
318 CHAR16
*FunctionNumberStr
;
319 PCCARD_DEVICE_PATH
*Pccard
;
321 FunctionNumberStr
= GetNextParamStr (&TextDeviceNode
);
322 Pccard
= (PCCARD_DEVICE_PATH
*) CreateDeviceNode (
323 HARDWARE_DEVICE_PATH
,
325 (UINT16
) sizeof (PCCARD_DEVICE_PATH
)
328 Pccard
->FunctionNumber
= (UINT8
) Strtoi (FunctionNumberStr
);
330 return (EFI_DEVICE_PATH_PROTOCOL
*) Pccard
;
334 Converts a text device path node to Hardware memory map device path structure.
336 @param TextDeviceNode The input Text device path node.
338 @return A pointer to Hardware memory map device path structure.
341 EFI_DEVICE_PATH_PROTOCOL
*
342 DevPathFromTextMemoryMapped (
343 CHAR16
*TextDeviceNode
346 CHAR16
*MemoryTypeStr
;
347 CHAR16
*StartingAddressStr
;
348 CHAR16
*EndingAddressStr
;
349 MEMMAP_DEVICE_PATH
*MemMap
;
351 MemoryTypeStr
= GetNextParamStr (&TextDeviceNode
);
352 StartingAddressStr
= GetNextParamStr (&TextDeviceNode
);
353 EndingAddressStr
= GetNextParamStr (&TextDeviceNode
);
354 MemMap
= (MEMMAP_DEVICE_PATH
*) CreateDeviceNode (
355 HARDWARE_DEVICE_PATH
,
357 (UINT16
) sizeof (MEMMAP_DEVICE_PATH
)
360 MemMap
->MemoryType
= (UINT32
) Strtoi (MemoryTypeStr
);
361 Strtoi64 (StartingAddressStr
, &MemMap
->StartingAddress
);
362 Strtoi64 (EndingAddressStr
, &MemMap
->EndingAddress
);
364 return (EFI_DEVICE_PATH_PROTOCOL
*) MemMap
;
368 Converts a text device path node to Vendor device path structure based on the input Type
371 @param TextDeviceNode The input Text device path node.
372 @param Type The type of device path node.
373 @param SubType The subtype of device path node.
375 @return A pointer to the newly-created Vendor device path structure.
378 EFI_DEVICE_PATH_PROTOCOL
*
379 ConvertFromTextVendor (
380 CHAR16
*TextDeviceNode
,
388 VENDOR_DEVICE_PATH
*Vendor
;
390 GuidStr
= GetNextParamStr (&TextDeviceNode
);
392 DataStr
= GetNextParamStr (&TextDeviceNode
);
393 Length
= StrLen (DataStr
);
395 // Two hex characters make up 1 buffer byte
397 Length
= (Length
+ 1) / 2;
399 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
402 (UINT16
) (sizeof (VENDOR_DEVICE_PATH
) + Length
)
405 StrToGuid (GuidStr
, &Vendor
->Guid
);
406 StrHexToBytes (DataStr
, Length
* 2, (UINT8
*) (Vendor
+ 1), Length
);
408 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
412 Converts a text device path node to Vendor Hardware device path structure.
414 @param TextDeviceNode The input Text device path node.
416 @return A pointer to the newly-created Vendor Hardware device path structure.
419 EFI_DEVICE_PATH_PROTOCOL
*
420 DevPathFromTextVenHw (
421 CHAR16
*TextDeviceNode
424 return ConvertFromTextVendor (
426 HARDWARE_DEVICE_PATH
,
432 Converts a text device path node to Hardware Controller device path structure.
434 @param TextDeviceNode The input Text device path node.
436 @return A pointer to the newly-created Hardware Controller device path structure.
439 EFI_DEVICE_PATH_PROTOCOL
*
440 DevPathFromTextCtrl (
441 CHAR16
*TextDeviceNode
444 CHAR16
*ControllerStr
;
445 CONTROLLER_DEVICE_PATH
*Controller
;
447 ControllerStr
= GetNextParamStr (&TextDeviceNode
);
448 Controller
= (CONTROLLER_DEVICE_PATH
*) CreateDeviceNode (
449 HARDWARE_DEVICE_PATH
,
451 (UINT16
) sizeof (CONTROLLER_DEVICE_PATH
)
453 Controller
->ControllerNumber
= (UINT32
) Strtoi (ControllerStr
);
455 return (EFI_DEVICE_PATH_PROTOCOL
*) Controller
;
459 Converts a text device path node to BMC device path structure.
461 @param TextDeviceNode The input Text device path node.
463 @return A pointer to the newly-created BMC device path structure.
466 EFI_DEVICE_PATH_PROTOCOL
*
468 CHAR16
*TextDeviceNode
471 CHAR16
*InterfaceTypeStr
;
472 CHAR16
*BaseAddressStr
;
473 BMC_DEVICE_PATH
*BmcDp
;
475 InterfaceTypeStr
= GetNextParamStr (&TextDeviceNode
);
476 BaseAddressStr
= GetNextParamStr (&TextDeviceNode
);
477 BmcDp
= (BMC_DEVICE_PATH
*) CreateDeviceNode (
478 HARDWARE_DEVICE_PATH
,
480 (UINT16
) sizeof (BMC_DEVICE_PATH
)
483 BmcDp
->InterfaceType
= (UINT8
) Strtoi (InterfaceTypeStr
);
485 (UINT64
*) (&BmcDp
->BaseAddress
),
486 StrHexToUint64 (BaseAddressStr
)
489 return (EFI_DEVICE_PATH_PROTOCOL
*) BmcDp
;
493 Converts a generic ACPI text device path node to ACPI device path structure.
495 @param TextDeviceNode The input Text device path node.
497 @return A pointer to ACPI device path structure.
500 EFI_DEVICE_PATH_PROTOCOL
*
501 DevPathFromTextAcpiPath (
502 CHAR16
*TextDeviceNode
505 return DevPathFromTextGenericPath (ACPI_DEVICE_PATH
, TextDeviceNode
);
509 Converts a string to EisaId.
511 @param Text The input string.
513 @return UINT32 EISA ID.
520 return (((Text
[0] - 'A' + 1) & 0x1f) << 10)
521 + (((Text
[1] - 'A' + 1) & 0x1f) << 5)
522 + (((Text
[2] - 'A' + 1) & 0x1f) << 0)
523 + (UINT32
) (StrHexToUintn (&Text
[3]) << 16)
528 Converts a text device path node to ACPI HID device path structure.
530 @param TextDeviceNode The input Text device path node.
532 @return A pointer to the newly-created ACPI HID device path structure.
535 EFI_DEVICE_PATH_PROTOCOL
*
536 DevPathFromTextAcpi (
537 CHAR16
*TextDeviceNode
542 ACPI_HID_DEVICE_PATH
*Acpi
;
544 HIDStr
= GetNextParamStr (&TextDeviceNode
);
545 UIDStr
= GetNextParamStr (&TextDeviceNode
);
546 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
549 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
552 Acpi
->HID
= EisaIdFromText (HIDStr
);
553 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
555 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
559 Converts a text device path node to ACPI HID device path structure.
561 @param TextDeviceNode The input Text device path node.
562 @param PnPId The input plug and play identification.
564 @return A pointer to the newly-created ACPI HID device path structure.
567 EFI_DEVICE_PATH_PROTOCOL
*
568 ConvertFromTextAcpi (
569 CHAR16
*TextDeviceNode
,
574 ACPI_HID_DEVICE_PATH
*Acpi
;
576 UIDStr
= GetNextParamStr (&TextDeviceNode
);
577 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
580 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
583 Acpi
->HID
= EFI_PNP_ID (PnPId
);
584 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
586 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
590 Converts a text device path node to PCI root device path structure.
592 @param TextDeviceNode The input Text device path node.
594 @return A pointer to the newly-created PCI root device path structure.
597 EFI_DEVICE_PATH_PROTOCOL
*
598 DevPathFromTextPciRoot (
599 CHAR16
*TextDeviceNode
602 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a03);
606 Converts a text device path node to PCIE root device path structure.
608 @param TextDeviceNode The input Text device path node.
610 @return A pointer to the newly-created PCIE root device path structure.
613 EFI_DEVICE_PATH_PROTOCOL
*
614 DevPathFromTextPcieRoot (
615 CHAR16
*TextDeviceNode
618 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a08);
622 Converts a text device path node to Floppy device path structure.
624 @param TextDeviceNode The input Text device path node.
626 @return A pointer to the newly-created Floppy device path structure.
629 EFI_DEVICE_PATH_PROTOCOL
*
630 DevPathFromTextFloppy (
631 CHAR16
*TextDeviceNode
634 return ConvertFromTextAcpi (TextDeviceNode
, 0x0604);
638 Converts a text device path node to Keyboard device path structure.
640 @param TextDeviceNode The input Text device path node.
642 @return A pointer to the newly-created Keyboard device path structure.
645 EFI_DEVICE_PATH_PROTOCOL
*
646 DevPathFromTextKeyboard (
647 CHAR16
*TextDeviceNode
650 return ConvertFromTextAcpi (TextDeviceNode
, 0x0301);
654 Converts a text device path node to Serial device path structure.
656 @param TextDeviceNode The input Text device path node.
658 @return A pointer to the newly-created Serial device path structure.
661 EFI_DEVICE_PATH_PROTOCOL
*
662 DevPathFromTextSerial (
663 CHAR16
*TextDeviceNode
666 return ConvertFromTextAcpi (TextDeviceNode
, 0x0501);
670 Converts a text device path node to Parallel Port device path structure.
672 @param TextDeviceNode The input Text device path node.
674 @return A pointer to the newly-created Parallel Port device path structure.
677 EFI_DEVICE_PATH_PROTOCOL
*
678 DevPathFromTextParallelPort (
679 CHAR16
*TextDeviceNode
682 return ConvertFromTextAcpi (TextDeviceNode
, 0x0401);
686 Converts a text device path node to ACPI extension device path structure.
688 @param TextDeviceNode The input Text device path node.
690 @return A pointer to the newly-created ACPI extension device path structure.
693 EFI_DEVICE_PATH_PROTOCOL
*
694 DevPathFromTextAcpiEx (
695 CHAR16
*TextDeviceNode
706 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
708 HIDStr
= GetNextParamStr (&TextDeviceNode
);
709 CIDStr
= GetNextParamStr (&TextDeviceNode
);
710 UIDStr
= GetNextParamStr (&TextDeviceNode
);
711 HIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
712 CIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
713 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
715 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (HIDSTRStr
) + 1);
716 Length
= (UINT16
) (Length
+ StrLen (UIDSTRStr
) + 1);
717 Length
= (UINT16
) (Length
+ StrLen (CIDSTRStr
) + 1);
718 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
724 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
725 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
726 AcpiEx
->UID
= (UINT32
) Strtoi (UIDStr
);
728 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
729 StrToAscii (HIDSTRStr
, &AsciiStr
);
730 StrToAscii (UIDSTRStr
, &AsciiStr
);
731 StrToAscii (CIDSTRStr
, &AsciiStr
);
733 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
737 Converts a text device path node to ACPI extension device path structure.
739 @param TextDeviceNode The input Text device path node.
741 @return A pointer to the newly-created ACPI extension device path structure.
744 EFI_DEVICE_PATH_PROTOCOL
*
745 DevPathFromTextAcpiExp (
746 CHAR16
*TextDeviceNode
754 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
756 HIDStr
= GetNextParamStr (&TextDeviceNode
);
757 CIDStr
= GetNextParamStr (&TextDeviceNode
);
758 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
759 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (UIDSTRStr
) + 3);
760 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
766 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
767 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
770 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
772 // HID string is NULL
776 // Convert UID string
779 StrToAscii (UIDSTRStr
, &AsciiStr
);
781 // CID string is NULL
785 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
789 Converts a text device path node to ACPI _ADR device path structure.
791 @param TextDeviceNode The input Text device path node.
793 @return A pointer to the newly-created ACPI _ADR device path structure.
796 EFI_DEVICE_PATH_PROTOCOL
*
797 DevPathFromTextAcpiAdr (
798 CHAR16
*TextDeviceNode
801 CHAR16
*DisplayDeviceStr
;
802 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
806 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*) CreateDeviceNode (
809 (UINT16
) sizeof (ACPI_ADR_DEVICE_PATH
)
811 ASSERT (AcpiAdr
!= NULL
);
813 for (Index
= 0; ; Index
++) {
814 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
815 if (IS_NULL (*DisplayDeviceStr
)) {
819 Length
= DevicePathNodeLength (AcpiAdr
);
820 AcpiAdr
= ReallocatePool (
822 Length
+ sizeof (UINT32
),
825 ASSERT (AcpiAdr
!= NULL
);
826 SetDevicePathNodeLength (AcpiAdr
, Length
+ sizeof (UINT32
));
829 (&AcpiAdr
->ADR
)[Index
] = (UINT32
) Strtoi (DisplayDeviceStr
);
832 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
;
836 Converts a generic messaging text device path node to messaging device path structure.
838 @param TextDeviceNode The input Text device path node.
840 @return A pointer to messaging device path structure.
843 EFI_DEVICE_PATH_PROTOCOL
*
845 CHAR16
*TextDeviceNode
848 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH
, TextDeviceNode
);
852 Converts a text device path node to Parallel Port device path structure.
854 @param TextDeviceNode The input Text device path node.
856 @return A pointer to the newly-created Parallel Port device path structure.
859 EFI_DEVICE_PATH_PROTOCOL
*
861 CHAR16
*TextDeviceNode
864 CHAR16
*PrimarySecondaryStr
;
865 CHAR16
*SlaveMasterStr
;
867 ATAPI_DEVICE_PATH
*Atapi
;
869 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
870 MESSAGING_DEVICE_PATH
,
872 (UINT16
) sizeof (ATAPI_DEVICE_PATH
)
875 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
876 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
877 LunStr
= GetNextParamStr (&TextDeviceNode
);
879 if (StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) {
880 Atapi
->PrimarySecondary
= 0;
881 } else if (StrCmp (PrimarySecondaryStr
, L
"Secondary") == 0) {
882 Atapi
->PrimarySecondary
= 1;
884 Atapi
->PrimarySecondary
= (UINT8
) Strtoi (PrimarySecondaryStr
);
886 if (StrCmp (SlaveMasterStr
, L
"Master") == 0) {
887 Atapi
->SlaveMaster
= 0;
888 } else if (StrCmp (SlaveMasterStr
, L
"Slave") == 0) {
889 Atapi
->SlaveMaster
= 1;
891 Atapi
->SlaveMaster
= (UINT8
) Strtoi (SlaveMasterStr
);
894 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
896 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
900 Converts a text device path node to SCSI device path structure.
902 @param TextDeviceNode The input Text device path node.
904 @return A pointer to the newly-created SCSI device path structure.
907 EFI_DEVICE_PATH_PROTOCOL
*
908 DevPathFromTextScsi (
909 CHAR16
*TextDeviceNode
914 SCSI_DEVICE_PATH
*Scsi
;
916 PunStr
= GetNextParamStr (&TextDeviceNode
);
917 LunStr
= GetNextParamStr (&TextDeviceNode
);
918 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
919 MESSAGING_DEVICE_PATH
,
921 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
924 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
925 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
927 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
931 Converts a text device path node to Fibre device path structure.
933 @param TextDeviceNode The input Text device path node.
935 @return A pointer to the newly-created Fibre device path structure.
938 EFI_DEVICE_PATH_PROTOCOL
*
939 DevPathFromTextFibre (
940 CHAR16
*TextDeviceNode
945 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
947 WWNStr
= GetNextParamStr (&TextDeviceNode
);
948 LunStr
= GetNextParamStr (&TextDeviceNode
);
949 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
950 MESSAGING_DEVICE_PATH
,
952 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
956 Strtoi64 (WWNStr
, &Fibre
->WWN
);
957 Strtoi64 (LunStr
, &Fibre
->Lun
);
959 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
963 Converts a text device path node to FibreEx device path structure.
965 @param TextDeviceNode The input Text device path node.
967 @return A pointer to the newly-created FibreEx device path structure.
970 EFI_DEVICE_PATH_PROTOCOL
*
971 DevPathFromTextFibreEx (
972 CHAR16
*TextDeviceNode
977 FIBRECHANNELEX_DEVICE_PATH
*FibreEx
;
979 WWNStr
= GetNextParamStr (&TextDeviceNode
);
980 LunStr
= GetNextParamStr (&TextDeviceNode
);
981 FibreEx
= (FIBRECHANNELEX_DEVICE_PATH
*) CreateDeviceNode (
982 MESSAGING_DEVICE_PATH
,
983 MSG_FIBRECHANNELEX_DP
,
984 (UINT16
) sizeof (FIBRECHANNELEX_DEVICE_PATH
)
987 FibreEx
->Reserved
= 0;
988 Strtoi64 (WWNStr
, (UINT64
*) (&FibreEx
->WWN
));
989 Strtoi64 (LunStr
, (UINT64
*) (&FibreEx
->Lun
));
991 *(UINT64
*) (&FibreEx
->WWN
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->WWN
));
992 *(UINT64
*) (&FibreEx
->Lun
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->Lun
));
994 return (EFI_DEVICE_PATH_PROTOCOL
*) FibreEx
;
998 Converts a text device path node to 1394 device path structure.
1000 @param TextDeviceNode The input Text device path node.
1002 @return A pointer to the newly-created 1394 device path structure.
1005 EFI_DEVICE_PATH_PROTOCOL
*
1006 DevPathFromText1394 (
1007 CHAR16
*TextDeviceNode
1011 F1394_DEVICE_PATH
*F1394DevPath
;
1013 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1014 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1015 MESSAGING_DEVICE_PATH
,
1017 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1020 F1394DevPath
->Reserved
= 0;
1021 F1394DevPath
->Guid
= StrHexToUint64 (GuidStr
);
1023 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1027 Converts a text device path node to USB device path structure.
1029 @param TextDeviceNode The input Text device path node.
1031 @return A pointer to the newly-created USB device path structure.
1034 EFI_DEVICE_PATH_PROTOCOL
*
1035 DevPathFromTextUsb (
1036 CHAR16
*TextDeviceNode
1040 CHAR16
*InterfaceStr
;
1041 USB_DEVICE_PATH
*Usb
;
1043 PortStr
= GetNextParamStr (&TextDeviceNode
);
1044 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1045 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1046 MESSAGING_DEVICE_PATH
,
1048 (UINT16
) sizeof (USB_DEVICE_PATH
)
1051 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1052 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1054 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1058 Converts a text device path node to I20 device path structure.
1060 @param TextDeviceNode The input Text device path node.
1062 @return A pointer to the newly-created I20 device path structure.
1065 EFI_DEVICE_PATH_PROTOCOL
*
1066 DevPathFromTextI2O (
1067 CHAR16
*TextDeviceNode
1071 I2O_DEVICE_PATH
*I2ODevPath
;
1073 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1074 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1075 MESSAGING_DEVICE_PATH
,
1077 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1080 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1082 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1086 Converts a text device path node to Infini Band device path structure.
1088 @param TextDeviceNode The input Text device path node.
1090 @return A pointer to the newly-created Infini Band device path structure.
1093 EFI_DEVICE_PATH_PROTOCOL
*
1094 DevPathFromTextInfiniband (
1095 CHAR16
*TextDeviceNode
1103 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1105 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1106 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1107 SidStr
= GetNextParamStr (&TextDeviceNode
);
1108 TidStr
= GetNextParamStr (&TextDeviceNode
);
1109 DidStr
= GetNextParamStr (&TextDeviceNode
);
1110 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1111 MESSAGING_DEVICE_PATH
,
1113 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1116 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1117 StrToGuid (GuidStr
, (EFI_GUID
*) InfiniBand
->PortGid
);
1118 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1119 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1120 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1122 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1126 Converts a text device path node to Vendor-Defined Messaging device path structure.
1128 @param TextDeviceNode The input Text device path node.
1130 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1133 EFI_DEVICE_PATH_PROTOCOL
*
1134 DevPathFromTextVenMsg (
1135 CHAR16
*TextDeviceNode
1138 return ConvertFromTextVendor (
1140 MESSAGING_DEVICE_PATH
,
1146 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1148 @param TextDeviceNode The input Text device path node.
1150 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1153 EFI_DEVICE_PATH_PROTOCOL
*
1154 DevPathFromTextVenPcAnsi (
1155 CHAR16
*TextDeviceNode
1158 VENDOR_DEVICE_PATH
*Vendor
;
1160 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1161 MESSAGING_DEVICE_PATH
,
1163 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1164 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1166 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1170 Converts a text device path node to Vendor defined VT100 device path structure.
1172 @param TextDeviceNode The input Text device path node.
1174 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1177 EFI_DEVICE_PATH_PROTOCOL
*
1178 DevPathFromTextVenVt100 (
1179 CHAR16
*TextDeviceNode
1182 VENDOR_DEVICE_PATH
*Vendor
;
1184 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1185 MESSAGING_DEVICE_PATH
,
1187 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1188 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1190 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1194 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1196 @param TextDeviceNode The input Text device path node.
1198 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1201 EFI_DEVICE_PATH_PROTOCOL
*
1202 DevPathFromTextVenVt100Plus (
1203 CHAR16
*TextDeviceNode
1206 VENDOR_DEVICE_PATH
*Vendor
;
1208 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1209 MESSAGING_DEVICE_PATH
,
1211 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1212 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1214 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1218 Converts a text device path node to Vendor defined UTF8 device path structure.
1220 @param TextDeviceNode The input Text device path node.
1222 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1225 EFI_DEVICE_PATH_PROTOCOL
*
1226 DevPathFromTextVenUtf8 (
1227 CHAR16
*TextDeviceNode
1230 VENDOR_DEVICE_PATH
*Vendor
;
1232 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1233 MESSAGING_DEVICE_PATH
,
1235 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1236 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1238 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1242 Converts a text device path node to UART Flow Control device path structure.
1244 @param TextDeviceNode The input Text device path node.
1246 @return A pointer to the newly-created UART Flow Control device path structure.
1249 EFI_DEVICE_PATH_PROTOCOL
*
1250 DevPathFromTextUartFlowCtrl (
1251 CHAR16
*TextDeviceNode
1255 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1257 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1258 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1259 MESSAGING_DEVICE_PATH
,
1261 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1264 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1265 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1266 UartFlowControl
->FlowControlMap
= 2;
1267 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1268 UartFlowControl
->FlowControlMap
= 1;
1270 UartFlowControl
->FlowControlMap
= 0;
1273 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1277 Converts a text device path node to Serial Attached SCSI device path structure.
1279 @param TextDeviceNode The input Text device path node.
1281 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1284 EFI_DEVICE_PATH_PROTOCOL
*
1285 DevPathFromTextSAS (
1286 CHAR16
*TextDeviceNode
1293 CHAR16
*LocationStr
;
1295 CHAR16
*DriveBayStr
;
1296 CHAR16
*ReservedStr
;
1299 SAS_DEVICE_PATH
*Sas
;
1301 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1302 LunStr
= GetNextParamStr (&TextDeviceNode
);
1303 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1304 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1305 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1306 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1307 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1308 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1309 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1310 MESSAGING_DEVICE_PATH
,
1312 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1315 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1316 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1317 Strtoi64 (LunStr
, &Sas
->Lun
);
1318 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1320 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1323 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1325 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1329 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1332 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1337 // Location is an integer between 0 and 1 or else
1338 // the keyword Internal (0) or External (1).
1340 if (StrCmp (LocationStr
, L
"External") == 0) {
1342 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1345 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1347 Info
|= (Uint16
<< 5);
1350 // Connect is an integer between 0 and 3 or else
1351 // the keyword Direct (0) or Expanded (1).
1353 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1355 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1358 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1360 Info
|= (Uint16
<< 6);
1363 Info
= (UINT16
) Strtoi (SASSATAStr
);
1366 Sas
->DeviceTopology
= Info
;
1367 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1369 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1373 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1375 @param TextDeviceNode The input Text device path node.
1377 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1380 EFI_DEVICE_PATH_PROTOCOL
*
1381 DevPathFromTextSasEx (
1382 CHAR16
*TextDeviceNode
1389 CHAR16
*LocationStr
;
1391 CHAR16
*DriveBayStr
;
1396 SASEX_DEVICE_PATH
*SasEx
;
1398 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1399 LunStr
= GetNextParamStr (&TextDeviceNode
);
1400 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1401 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1402 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1403 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1404 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1405 SasEx
= (SASEX_DEVICE_PATH
*) CreateDeviceNode (
1406 MESSAGING_DEVICE_PATH
,
1408 (UINT16
) sizeof (SASEX_DEVICE_PATH
)
1411 Strtoi64 (AddressStr
, &SasAddress
);
1412 Strtoi64 (LunStr
, &Lun
);
1413 WriteUnaligned64 ((UINT64
*) &SasEx
->SasAddress
, SwapBytes64 (SasAddress
));
1414 WriteUnaligned64 ((UINT64
*) &SasEx
->Lun
, SwapBytes64 (Lun
));
1415 SasEx
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1417 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1420 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1422 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1426 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1429 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1434 // Location is an integer between 0 and 1 or else
1435 // the keyword Internal (0) or External (1).
1437 if (StrCmp (LocationStr
, L
"External") == 0) {
1439 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1442 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1444 Info
|= (Uint16
<< 5);
1447 // Connect is an integer between 0 and 3 or else
1448 // the keyword Direct (0) or Expanded (1).
1450 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1452 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1455 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1457 Info
|= (Uint16
<< 6);
1460 Info
= (UINT16
) Strtoi (SASSATAStr
);
1463 SasEx
->DeviceTopology
= Info
;
1465 return (EFI_DEVICE_PATH_PROTOCOL
*) SasEx
;
1469 Converts a text device path node to NVM Express Namespace device path structure.
1471 @param TextDeviceNode The input Text device path node.
1473 @return A pointer to the newly-created NVM Express Namespace device path structure.
1476 EFI_DEVICE_PATH_PROTOCOL
*
1477 DevPathFromTextNVMe (
1478 CHAR16
*TextDeviceNode
1481 CHAR16
*NamespaceIdStr
;
1482 CHAR16
*NamespaceUuidStr
;
1483 NVME_NAMESPACE_DEVICE_PATH
*Nvme
;
1487 NamespaceIdStr
= GetNextParamStr (&TextDeviceNode
);
1488 NamespaceUuidStr
= GetNextParamStr (&TextDeviceNode
);
1489 Nvme
= (NVME_NAMESPACE_DEVICE_PATH
*) CreateDeviceNode (
1490 MESSAGING_DEVICE_PATH
,
1491 MSG_NVME_NAMESPACE_DP
,
1492 (UINT16
) sizeof (NVME_NAMESPACE_DEVICE_PATH
)
1495 Nvme
->NamespaceId
= (UINT32
) Strtoi (NamespaceIdStr
);
1496 Uuid
= (UINT8
*) &Nvme
->NamespaceUuid
;
1498 Index
= sizeof (Nvme
->NamespaceUuid
) / sizeof (UINT8
);
1499 while (Index
-- != 0) {
1500 Uuid
[Index
] = (UINT8
) StrHexToUintn (SplitStr (&NamespaceUuidStr
, L
'-'));
1503 return (EFI_DEVICE_PATH_PROTOCOL
*) Nvme
;
1507 Converts a text device path node to UFS device path structure.
1509 @param TextDeviceNode The input Text device path node.
1511 @return A pointer to the newly-created UFS device path structure.
1514 EFI_DEVICE_PATH_PROTOCOL
*
1515 DevPathFromTextUfs (
1516 CHAR16
*TextDeviceNode
1521 UFS_DEVICE_PATH
*Ufs
;
1523 PunStr
= GetNextParamStr (&TextDeviceNode
);
1524 LunStr
= GetNextParamStr (&TextDeviceNode
);
1525 Ufs
= (UFS_DEVICE_PATH
*) CreateDeviceNode (
1526 MESSAGING_DEVICE_PATH
,
1528 (UINT16
) sizeof (UFS_DEVICE_PATH
)
1531 Ufs
->Pun
= (UINT8
) Strtoi (PunStr
);
1532 Ufs
->Lun
= (UINT8
) Strtoi (LunStr
);
1534 return (EFI_DEVICE_PATH_PROTOCOL
*) Ufs
;
1538 Converts a text device path node to SD (Secure Digital) device path structure.
1540 @param TextDeviceNode The input Text device path node.
1542 @return A pointer to the newly-created SD device path structure.
1545 EFI_DEVICE_PATH_PROTOCOL
*
1547 CHAR16
*TextDeviceNode
1550 CHAR16
*SlotNumberStr
;
1553 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1554 Sd
= (SD_DEVICE_PATH
*) CreateDeviceNode (
1555 MESSAGING_DEVICE_PATH
,
1557 (UINT16
) sizeof (SD_DEVICE_PATH
)
1560 Sd
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1562 return (EFI_DEVICE_PATH_PROTOCOL
*) Sd
;
1566 Converts a text device path node to EMMC (Embedded MMC) device path structure.
1568 @param TextDeviceNode The input Text device path node.
1570 @return A pointer to the newly-created EMMC device path structure.
1573 EFI_DEVICE_PATH_PROTOCOL
*
1574 DevPathFromTextEmmc (
1575 CHAR16
*TextDeviceNode
1578 CHAR16
*SlotNumberStr
;
1579 EMMC_DEVICE_PATH
*Emmc
;
1581 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1582 Emmc
= (EMMC_DEVICE_PATH
*) CreateDeviceNode (
1583 MESSAGING_DEVICE_PATH
,
1585 (UINT16
) sizeof (EMMC_DEVICE_PATH
)
1588 Emmc
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1590 return (EFI_DEVICE_PATH_PROTOCOL
*) Emmc
;
1594 Converts a text device path node to Debug Port device path structure.
1596 @param TextDeviceNode The input Text device path node.
1598 @return A pointer to the newly-created Debug Port device path structure.
1601 EFI_DEVICE_PATH_PROTOCOL
*
1602 DevPathFromTextDebugPort (
1603 CHAR16
*TextDeviceNode
1606 VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*Vend
;
1608 Vend
= (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*) CreateDeviceNode (
1609 MESSAGING_DEVICE_PATH
,
1611 (UINT16
) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
)
1614 CopyGuid (&Vend
->Guid
, &gEfiDebugPortDevicePathGuid
);
1616 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1620 Converts a text device path node to MAC device path structure.
1622 @param TextDeviceNode The input Text device path node.
1624 @return A pointer to the newly-created MAC device path structure.
1627 EFI_DEVICE_PATH_PROTOCOL
*
1628 DevPathFromTextMAC (
1629 CHAR16
*TextDeviceNode
1635 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1637 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1638 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1639 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1640 MESSAGING_DEVICE_PATH
,
1642 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1645 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1647 Length
= sizeof (EFI_MAC_ADDRESS
);
1648 if (MACDevPath
->IfType
== 0x01 || MACDevPath
->IfType
== 0x00) {
1652 StrHexToBytes (AddressStr
, Length
* 2, MACDevPath
->MacAddress
.Addr
, Length
);
1654 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1659 Converts a text format to the network protocol ID.
1661 @param Text String of protocol field.
1663 @return Network protocol ID .
1667 NetworkProtocolFromText (
1671 if (StrCmp (Text
, L
"UDP") == 0) {
1672 return RFC_1700_UDP_PROTOCOL
;
1675 if (StrCmp (Text
, L
"TCP") == 0) {
1676 return RFC_1700_TCP_PROTOCOL
;
1679 return Strtoi (Text
);
1684 Converts a text device path node to IPV4 device path structure.
1686 @param TextDeviceNode The input Text device path node.
1688 @return A pointer to the newly-created IPV4 device path structure.
1691 EFI_DEVICE_PATH_PROTOCOL
*
1692 DevPathFromTextIPv4 (
1693 CHAR16
*TextDeviceNode
1696 CHAR16
*RemoteIPStr
;
1697 CHAR16
*ProtocolStr
;
1700 CHAR16
*GatewayIPStr
;
1701 CHAR16
*SubnetMaskStr
;
1702 IPv4_DEVICE_PATH
*IPv4
;
1704 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1705 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1706 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1707 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1708 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1709 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
1710 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1711 MESSAGING_DEVICE_PATH
,
1713 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
1716 StrToIpv4Address (RemoteIPStr
, NULL
, &IPv4
->RemoteIpAddress
, NULL
);
1717 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1718 if (StrCmp (TypeStr
, L
"Static") == 0) {
1719 IPv4
->StaticIpAddress
= TRUE
;
1721 IPv4
->StaticIpAddress
= FALSE
;
1724 StrToIpv4Address (LocalIPStr
, NULL
, &IPv4
->LocalIpAddress
, NULL
);
1725 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
1726 StrToIpv4Address (GatewayIPStr
, NULL
, &IPv4
->GatewayIpAddress
, NULL
);
1727 StrToIpv4Address (SubnetMaskStr
, NULL
, &IPv4
->SubnetMask
, NULL
);
1729 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
1730 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
1733 IPv4
->LocalPort
= 0;
1734 IPv4
->RemotePort
= 0;
1736 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1740 Converts a text device path node to IPV6 device path structure.
1742 @param TextDeviceNode The input Text device path node.
1744 @return A pointer to the newly-created IPV6 device path structure.
1747 EFI_DEVICE_PATH_PROTOCOL
*
1748 DevPathFromTextIPv6 (
1749 CHAR16
*TextDeviceNode
1752 CHAR16
*RemoteIPStr
;
1753 CHAR16
*ProtocolStr
;
1756 CHAR16
*GatewayIPStr
;
1757 CHAR16
*PrefixLengthStr
;
1758 IPv6_DEVICE_PATH
*IPv6
;
1760 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1761 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1762 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1763 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1764 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
1765 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1766 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1767 MESSAGING_DEVICE_PATH
,
1769 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
1772 StrToIpv6Address (RemoteIPStr
, NULL
, &IPv6
->RemoteIpAddress
, NULL
);
1773 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1774 if (StrCmp (TypeStr
, L
"Static") == 0) {
1775 IPv6
->IpAddressOrigin
= 0;
1776 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
1777 IPv6
->IpAddressOrigin
= 1;
1779 IPv6
->IpAddressOrigin
= 2;
1782 StrToIpv6Address (LocalIPStr
, NULL
, &IPv6
->LocalIpAddress
, NULL
);
1783 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
1784 StrToIpv6Address (GatewayIPStr
, NULL
, &IPv6
->GatewayIpAddress
, NULL
);
1785 IPv6
->PrefixLength
= (UINT8
) Strtoi (PrefixLengthStr
);
1787 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
1788 IPv6
->PrefixLength
= 0;
1791 IPv6
->LocalPort
= 0;
1792 IPv6
->RemotePort
= 0;
1794 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
1798 Converts a text device path node to UART device path structure.
1800 @param TextDeviceNode The input Text device path node.
1802 @return A pointer to the newly-created UART device path structure.
1805 EFI_DEVICE_PATH_PROTOCOL
*
1806 DevPathFromTextUart (
1807 CHAR16
*TextDeviceNode
1811 CHAR16
*DataBitsStr
;
1813 CHAR16
*StopBitsStr
;
1814 UART_DEVICE_PATH
*Uart
;
1816 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1817 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1818 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1819 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1820 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
1821 MESSAGING_DEVICE_PATH
,
1823 (UINT16
) sizeof (UART_DEVICE_PATH
)
1826 if (StrCmp (BaudStr
, L
"DEFAULT") == 0) {
1827 Uart
->BaudRate
= 115200;
1829 Strtoi64 (BaudStr
, &Uart
->BaudRate
);
1831 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr
));
1832 switch (*ParityStr
) {
1858 Uart
->Parity
= (UINT8
) Strtoi (ParityStr
);
1862 if (StrCmp (StopBitsStr
, L
"D") == 0) {
1863 Uart
->StopBits
= (UINT8
) 0;
1864 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
1865 Uart
->StopBits
= (UINT8
) 1;
1866 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
1867 Uart
->StopBits
= (UINT8
) 2;
1868 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
1869 Uart
->StopBits
= (UINT8
) 3;
1871 Uart
->StopBits
= (UINT8
) Strtoi (StopBitsStr
);
1874 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
1878 Converts a text device path node to USB class device path structure.
1880 @param TextDeviceNode The input Text device path node.
1881 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
1883 @return A pointer to the newly-created USB class device path structure.
1886 EFI_DEVICE_PATH_PROTOCOL
*
1887 ConvertFromTextUsbClass (
1888 CHAR16
*TextDeviceNode
,
1889 USB_CLASS_TEXT
*UsbClassText
1895 CHAR16
*SubClassStr
;
1896 CHAR16
*ProtocolStr
;
1897 USB_CLASS_DEVICE_PATH
*UsbClass
;
1899 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
1900 MESSAGING_DEVICE_PATH
,
1902 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
1905 VIDStr
= GetNextParamStr (&TextDeviceNode
);
1906 PIDStr
= GetNextParamStr (&TextDeviceNode
);
1907 if (UsbClassText
->ClassExist
) {
1908 ClassStr
= GetNextParamStr (&TextDeviceNode
);
1909 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
1911 UsbClass
->DeviceClass
= UsbClassText
->Class
;
1913 if (UsbClassText
->SubClassExist
) {
1914 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
1915 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
1917 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
1920 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1922 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
1923 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
1924 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
1926 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
1931 Converts a text device path node to USB class device path structure.
1933 @param TextDeviceNode The input Text device path node.
1935 @return A pointer to the newly-created USB class device path structure.
1938 EFI_DEVICE_PATH_PROTOCOL
*
1939 DevPathFromTextUsbClass (
1940 CHAR16
*TextDeviceNode
1943 USB_CLASS_TEXT UsbClassText
;
1945 UsbClassText
.ClassExist
= TRUE
;
1946 UsbClassText
.SubClassExist
= TRUE
;
1948 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1952 Converts a text device path node to USB audio device path structure.
1954 @param TextDeviceNode The input Text device path node.
1956 @return A pointer to the newly-created USB audio device path structure.
1959 EFI_DEVICE_PATH_PROTOCOL
*
1960 DevPathFromTextUsbAudio (
1961 CHAR16
*TextDeviceNode
1964 USB_CLASS_TEXT UsbClassText
;
1966 UsbClassText
.ClassExist
= FALSE
;
1967 UsbClassText
.Class
= USB_CLASS_AUDIO
;
1968 UsbClassText
.SubClassExist
= TRUE
;
1970 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1974 Converts a text device path node to USB CDC Control device path structure.
1976 @param TextDeviceNode The input Text device path node.
1978 @return A pointer to the newly-created USB CDC Control device path structure.
1981 EFI_DEVICE_PATH_PROTOCOL
*
1982 DevPathFromTextUsbCDCControl (
1983 CHAR16
*TextDeviceNode
1986 USB_CLASS_TEXT UsbClassText
;
1988 UsbClassText
.ClassExist
= FALSE
;
1989 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
1990 UsbClassText
.SubClassExist
= TRUE
;
1992 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1996 Converts a text device path node to USB HID device path structure.
1998 @param TextDeviceNode The input Text device path node.
2000 @return A pointer to the newly-created USB HID device path structure.
2003 EFI_DEVICE_PATH_PROTOCOL
*
2004 DevPathFromTextUsbHID (
2005 CHAR16
*TextDeviceNode
2008 USB_CLASS_TEXT UsbClassText
;
2010 UsbClassText
.ClassExist
= FALSE
;
2011 UsbClassText
.Class
= USB_CLASS_HID
;
2012 UsbClassText
.SubClassExist
= TRUE
;
2014 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2018 Converts a text device path node to USB Image device path structure.
2020 @param TextDeviceNode The input Text device path node.
2022 @return A pointer to the newly-created USB Image device path structure.
2025 EFI_DEVICE_PATH_PROTOCOL
*
2026 DevPathFromTextUsbImage (
2027 CHAR16
*TextDeviceNode
2030 USB_CLASS_TEXT UsbClassText
;
2032 UsbClassText
.ClassExist
= FALSE
;
2033 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2034 UsbClassText
.SubClassExist
= TRUE
;
2036 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2040 Converts a text device path node to USB Print device path structure.
2042 @param TextDeviceNode The input Text device path node.
2044 @return A pointer to the newly-created USB Print device path structure.
2047 EFI_DEVICE_PATH_PROTOCOL
*
2048 DevPathFromTextUsbPrinter (
2049 CHAR16
*TextDeviceNode
2052 USB_CLASS_TEXT UsbClassText
;
2054 UsbClassText
.ClassExist
= FALSE
;
2055 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2056 UsbClassText
.SubClassExist
= TRUE
;
2058 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2062 Converts a text device path node to USB mass storage device path structure.
2064 @param TextDeviceNode The input Text device path node.
2066 @return A pointer to the newly-created USB mass storage device path structure.
2069 EFI_DEVICE_PATH_PROTOCOL
*
2070 DevPathFromTextUsbMassStorage (
2071 CHAR16
*TextDeviceNode
2074 USB_CLASS_TEXT UsbClassText
;
2076 UsbClassText
.ClassExist
= FALSE
;
2077 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2078 UsbClassText
.SubClassExist
= TRUE
;
2080 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2084 Converts a text device path node to USB HUB device path structure.
2086 @param TextDeviceNode The input Text device path node.
2088 @return A pointer to the newly-created USB HUB device path structure.
2091 EFI_DEVICE_PATH_PROTOCOL
*
2092 DevPathFromTextUsbHub (
2093 CHAR16
*TextDeviceNode
2096 USB_CLASS_TEXT UsbClassText
;
2098 UsbClassText
.ClassExist
= FALSE
;
2099 UsbClassText
.Class
= USB_CLASS_HUB
;
2100 UsbClassText
.SubClassExist
= TRUE
;
2102 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2106 Converts a text device path node to USB CDC data device path structure.
2108 @param TextDeviceNode The input Text device path node.
2110 @return A pointer to the newly-created USB CDC data device path structure.
2113 EFI_DEVICE_PATH_PROTOCOL
*
2114 DevPathFromTextUsbCDCData (
2115 CHAR16
*TextDeviceNode
2118 USB_CLASS_TEXT UsbClassText
;
2120 UsbClassText
.ClassExist
= FALSE
;
2121 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2122 UsbClassText
.SubClassExist
= TRUE
;
2124 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2128 Converts a text device path node to USB smart card device path structure.
2130 @param TextDeviceNode The input Text device path node.
2132 @return A pointer to the newly-created USB smart card device path structure.
2135 EFI_DEVICE_PATH_PROTOCOL
*
2136 DevPathFromTextUsbSmartCard (
2137 CHAR16
*TextDeviceNode
2140 USB_CLASS_TEXT UsbClassText
;
2142 UsbClassText
.ClassExist
= FALSE
;
2143 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2144 UsbClassText
.SubClassExist
= TRUE
;
2146 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2150 Converts a text device path node to USB video device path structure.
2152 @param TextDeviceNode The input Text device path node.
2154 @return A pointer to the newly-created USB video device path structure.
2157 EFI_DEVICE_PATH_PROTOCOL
*
2158 DevPathFromTextUsbVideo (
2159 CHAR16
*TextDeviceNode
2162 USB_CLASS_TEXT UsbClassText
;
2164 UsbClassText
.ClassExist
= FALSE
;
2165 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2166 UsbClassText
.SubClassExist
= TRUE
;
2168 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2172 Converts a text device path node to USB diagnostic device path structure.
2174 @param TextDeviceNode The input Text device path node.
2176 @return A pointer to the newly-created USB diagnostic device path structure.
2179 EFI_DEVICE_PATH_PROTOCOL
*
2180 DevPathFromTextUsbDiagnostic (
2181 CHAR16
*TextDeviceNode
2184 USB_CLASS_TEXT UsbClassText
;
2186 UsbClassText
.ClassExist
= FALSE
;
2187 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2188 UsbClassText
.SubClassExist
= TRUE
;
2190 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2194 Converts a text device path node to USB wireless device path structure.
2196 @param TextDeviceNode The input Text device path node.
2198 @return A pointer to the newly-created USB wireless device path structure.
2201 EFI_DEVICE_PATH_PROTOCOL
*
2202 DevPathFromTextUsbWireless (
2203 CHAR16
*TextDeviceNode
2206 USB_CLASS_TEXT UsbClassText
;
2208 UsbClassText
.ClassExist
= FALSE
;
2209 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2210 UsbClassText
.SubClassExist
= TRUE
;
2212 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2216 Converts a text device path node to USB device firmware update device path structure.
2218 @param TextDeviceNode The input Text device path node.
2220 @return A pointer to the newly-created USB device firmware update device path structure.
2223 EFI_DEVICE_PATH_PROTOCOL
*
2224 DevPathFromTextUsbDeviceFirmwareUpdate (
2225 CHAR16
*TextDeviceNode
2228 USB_CLASS_TEXT UsbClassText
;
2230 UsbClassText
.ClassExist
= FALSE
;
2231 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2232 UsbClassText
.SubClassExist
= FALSE
;
2233 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2235 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2239 Converts a text device path node to USB IRDA bridge device path structure.
2241 @param TextDeviceNode The input Text device path node.
2243 @return A pointer to the newly-created USB IRDA bridge device path structure.
2246 EFI_DEVICE_PATH_PROTOCOL
*
2247 DevPathFromTextUsbIrdaBridge (
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_IRDA_BRIDGE
;
2258 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2262 Converts a text device path node to USB text and measurement device path structure.
2264 @param TextDeviceNode The input Text device path node.
2266 @return A pointer to the newly-created USB text and measurement device path structure.
2269 EFI_DEVICE_PATH_PROTOCOL
*
2270 DevPathFromTextUsbTestAndMeasurement (
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_TEST
;
2281 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2285 Converts a text device path node to USB WWID device path structure.
2287 @param TextDeviceNode The input Text device path node.
2289 @return A pointer to the newly-created USB WWID device path structure.
2292 EFI_DEVICE_PATH_PROTOCOL
*
2293 DevPathFromTextUsbWwid (
2294 CHAR16
*TextDeviceNode
2299 CHAR16
*InterfaceNumStr
;
2300 CHAR16
*SerialNumberStr
;
2301 USB_WWID_DEVICE_PATH
*UsbWwid
;
2302 UINTN SerialNumberStrLen
;
2304 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2305 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2306 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2307 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2308 SerialNumberStrLen
= StrLen (SerialNumberStr
);
2309 if (SerialNumberStrLen
>= 2 &&
2310 SerialNumberStr
[0] == L
'\"' &&
2311 SerialNumberStr
[SerialNumberStrLen
- 1] == L
'\"'
2313 SerialNumberStr
[SerialNumberStrLen
- 1] = L
'\0';
2315 SerialNumberStrLen
-= 2;
2317 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2318 MESSAGING_DEVICE_PATH
,
2320 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + SerialNumberStrLen
* sizeof (CHAR16
))
2322 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2323 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2324 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2327 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
2328 // Therefore, the '\0' will not be copied.
2331 (UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
),
2333 SerialNumberStrLen
* sizeof (CHAR16
)
2336 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2340 Converts a text device path node to Logic Unit device path structure.
2342 @param TextDeviceNode The input Text device path node.
2344 @return A pointer to the newly-created Logic Unit device path structure.
2347 EFI_DEVICE_PATH_PROTOCOL
*
2348 DevPathFromTextUnit (
2349 CHAR16
*TextDeviceNode
2353 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2355 LunStr
= GetNextParamStr (&TextDeviceNode
);
2356 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2357 MESSAGING_DEVICE_PATH
,
2358 MSG_DEVICE_LOGICAL_UNIT_DP
,
2359 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2362 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2364 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2368 Converts a text device path node to iSCSI device path structure.
2370 @param TextDeviceNode The input Text device path node.
2372 @return A pointer to the newly-created iSCSI device path structure.
2375 EFI_DEVICE_PATH_PROTOCOL
*
2376 DevPathFromTextiSCSI (
2377 CHAR16
*TextDeviceNode
2382 CHAR16
*PortalGroupStr
;
2384 CHAR16
*HeaderDigestStr
;
2385 CHAR16
*DataDigestStr
;
2386 CHAR16
*AuthenticationStr
;
2387 CHAR16
*ProtocolStr
;
2389 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2392 NameStr
= GetNextParamStr (&TextDeviceNode
);
2393 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2394 LunStr
= GetNextParamStr (&TextDeviceNode
);
2395 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2396 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2397 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2398 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2399 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2400 MESSAGING_DEVICE_PATH
,
2402 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2405 AsciiStr
= ISCSIDevPath
->TargetName
;
2406 StrToAscii (NameStr
, &AsciiStr
);
2408 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2409 Strtoi64 (LunStr
, &Lun
);
2410 WriteUnaligned64 ((UINT64
*) &ISCSIDevPath
->Lun
, SwapBytes64 (Lun
));
2413 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2417 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2421 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2425 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2429 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2431 if (IS_NULL (*ProtocolStr
) || (StrCmp (ProtocolStr
, L
"TCP") == 0)) {
2432 ISCSIDevPath
->NetworkProtocol
= 0;
2435 // Undefined and reserved.
2437 ISCSIDevPath
->NetworkProtocol
= 1;
2440 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2444 Converts a text device path node to VLAN device path structure.
2446 @param TextDeviceNode The input Text device path node.
2448 @return A pointer to the newly-created VLAN device path structure.
2451 EFI_DEVICE_PATH_PROTOCOL
*
2452 DevPathFromTextVlan (
2453 CHAR16
*TextDeviceNode
2457 VLAN_DEVICE_PATH
*Vlan
;
2459 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2460 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2461 MESSAGING_DEVICE_PATH
,
2463 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2466 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2468 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2472 Converts a text device path node to Bluetooth device path structure.
2474 @param TextDeviceNode The input Text device path node.
2476 @return A pointer to the newly-created Bluetooth device path structure.
2479 EFI_DEVICE_PATH_PROTOCOL
*
2480 DevPathFromTextBluetooth (
2481 CHAR16
*TextDeviceNode
2484 CHAR16
*BluetoothStr
;
2485 BLUETOOTH_DEVICE_PATH
*BluetoothDp
;
2487 BluetoothStr
= GetNextParamStr (&TextDeviceNode
);
2488 BluetoothDp
= (BLUETOOTH_DEVICE_PATH
*) CreateDeviceNode (
2489 MESSAGING_DEVICE_PATH
,
2491 (UINT16
) sizeof (BLUETOOTH_DEVICE_PATH
)
2495 sizeof (BLUETOOTH_ADDRESS
) * 2,
2496 BluetoothDp
->BD_ADDR
.Address
,
2497 sizeof (BLUETOOTH_ADDRESS
)
2499 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothDp
;
2503 Converts a text device path node to Wi-Fi device path structure.
2505 @param TextDeviceNode The input Text device path node.
2507 @return A pointer to the newly-created Wi-Fi device path structure.
2510 EFI_DEVICE_PATH_PROTOCOL
*
2511 DevPathFromTextWiFi (
2512 CHAR16
*TextDeviceNode
2518 WIFI_DEVICE_PATH
*WiFiDp
;
2520 SSIdStr
= GetNextParamStr (&TextDeviceNode
);
2521 WiFiDp
= (WIFI_DEVICE_PATH
*) CreateDeviceNode (
2522 MESSAGING_DEVICE_PATH
,
2524 (UINT16
) sizeof (WIFI_DEVICE_PATH
)
2527 if (NULL
!= SSIdStr
) {
2528 DataLen
= StrLen (SSIdStr
);
2529 if (StrLen (SSIdStr
) > 32) {
2530 SSIdStr
[32] = L
'\0';
2534 UnicodeStrToAsciiStrS (SSIdStr
, AsciiStr
, sizeof (AsciiStr
));
2535 memcpy (WiFiDp
->SSId
, AsciiStr
, DataLen
);
2538 return (EFI_DEVICE_PATH_PROTOCOL
*) WiFiDp
;
2542 Converts a text device path node to Bluetooth LE device path structure.
2544 @param TextDeviceNode The input Text device path node.
2546 @return A pointer to the newly-created Bluetooth LE device path structure.
2549 EFI_DEVICE_PATH_PROTOCOL
*
2550 DevPathFromTextBluetoothLE (
2551 IN CHAR16
*TextDeviceNode
2554 CHAR16
*BluetoothLeAddrStr
;
2555 CHAR16
*BluetoothLeAddrTypeStr
;
2556 BLUETOOTH_LE_DEVICE_PATH
*BluetoothLeDp
;
2558 BluetoothLeAddrStr
= GetNextParamStr (&TextDeviceNode
);
2559 BluetoothLeAddrTypeStr
= GetNextParamStr (&TextDeviceNode
);
2560 BluetoothLeDp
= (BLUETOOTH_LE_DEVICE_PATH
*) CreateDeviceNode (
2561 MESSAGING_DEVICE_PATH
,
2562 MSG_BLUETOOTH_LE_DP
,
2563 (UINT16
) sizeof (BLUETOOTH_LE_DEVICE_PATH
)
2566 BluetoothLeDp
->Address
.Type
= (UINT8
) Strtoi (BluetoothLeAddrTypeStr
);
2568 BluetoothLeAddrStr
, sizeof (BluetoothLeDp
->Address
.Address
) * 2,
2569 BluetoothLeDp
->Address
.Address
, sizeof (BluetoothLeDp
->Address
.Address
)
2571 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothLeDp
;
2575 Converts a text device path node to DNS device path structure.
2577 @param TextDeviceNode The input Text device path node.
2579 @return A pointer to the newly-created DNS device path structure.
2582 EFI_DEVICE_PATH_PROTOCOL
*
2583 DevPathFromTextDns (
2584 IN CHAR16
*TextDeviceNode
2587 CHAR16
*DeviceNodeStr
;
2588 CHAR16
*DeviceNodeStrPtr
;
2589 UINT32 DnsServerIpCount
;
2590 UINT16 DnsDeviceNodeLength
;
2591 DNS_DEVICE_PATH
*DnsDeviceNode
;
2592 UINT32 DnsServerIpIndex
;
2593 CHAR16
*DnsServerIp
;
2597 // Count the DNS server address number.
2599 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
2600 if (DeviceNodeStr
== NULL
) {
2604 DeviceNodeStrPtr
= DeviceNodeStr
;
2606 DnsServerIpCount
= 0;
2607 while (DeviceNodeStrPtr
!= NULL
&& *DeviceNodeStrPtr
!= L
'\0') {
2608 GetNextParamStr (&DeviceNodeStrPtr
);
2609 DnsServerIpCount
++;
2612 free (DeviceNodeStr
);
2613 DeviceNodeStr
= NULL
;
2616 // One or more instances of the DNS server address in EFI_IP_ADDRESS,
2617 // otherwise, NULL will be returned.
2619 if (DnsServerIpCount
== 0) {
2624 // Create the DNS DeviceNode.
2626 DnsDeviceNodeLength
= (UINT16
) (sizeof (EFI_DEVICE_PATH_PROTOCOL
) + sizeof (UINT8
) + DnsServerIpCount
* sizeof (EFI_IP_ADDRESS
));
2627 DnsDeviceNode
= (DNS_DEVICE_PATH
*) CreateDeviceNode (
2628 MESSAGING_DEVICE_PATH
,
2632 if (DnsDeviceNode
== NULL
) {
2637 // Confirm the DNS server address is IPv4 or IPv6 type.
2639 DeviceNodeStrPtr
= TextDeviceNode
;
2640 while (!IS_NULL (*DeviceNodeStrPtr
)) {
2641 if (*DeviceNodeStrPtr
== L
'.') {
2642 DnsDeviceNode
->IsIPv6
= 0x00;
2646 if (*DeviceNodeStrPtr
== L
':') {
2647 DnsDeviceNode
->IsIPv6
= 0x01;
2654 for (DnsServerIpIndex
= 0; DnsServerIpIndex
< DnsServerIpCount
; DnsServerIpIndex
++) {
2655 DnsServerIp
= GetNextParamStr (&TextDeviceNode
);
2656 if (DnsDeviceNode
->IsIPv6
== 0x00) {
2657 StrToIpv4Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v4
), NULL
);
2659 StrToIpv6Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v6
), NULL
);
2663 return (EFI_DEVICE_PATH_PROTOCOL
*) DnsDeviceNode
;
2667 Converts a text device path node to URI device path structure.
2669 @param TextDeviceNode The input Text device path node.
2671 @return A pointer to the newly-created URI device path structure.
2674 EFI_DEVICE_PATH_PROTOCOL
*
2675 DevPathFromTextUri (
2676 CHAR16
*TextDeviceNode
2681 URI_DEVICE_PATH
*Uri
;
2683 UriStr
= GetNextParamStr (&TextDeviceNode
);
2684 UriLength
= StrnLenS (UriStr
, MAX_UINT16
- sizeof (URI_DEVICE_PATH
));
2685 Uri
= (URI_DEVICE_PATH
*) CreateDeviceNode (
2686 MESSAGING_DEVICE_PATH
,
2688 (UINT16
) (sizeof (URI_DEVICE_PATH
) + UriLength
)
2691 while (UriLength
-- != 0) {
2692 Uri
->Uri
[UriLength
] = (CHAR8
) UriStr
[UriLength
];
2695 return (EFI_DEVICE_PATH_PROTOCOL
*) Uri
;
2699 Converts a media text device path node to media device path structure.
2701 @param TextDeviceNode The input Text device path node.
2703 @return A pointer to media device path structure.
2706 EFI_DEVICE_PATH_PROTOCOL
*
2707 DevPathFromTextMediaPath (
2708 CHAR16
*TextDeviceNode
2711 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH
, TextDeviceNode
);
2715 Converts a text device path node to HD device path structure.
2717 @param TextDeviceNode The input Text device path node.
2719 @return A pointer to the newly-created HD device path structure.
2722 EFI_DEVICE_PATH_PROTOCOL
*
2724 CHAR16
*TextDeviceNode
2727 CHAR16
*PartitionStr
;
2729 CHAR16
*SignatureStr
;
2733 HARDDRIVE_DEVICE_PATH
*Hd
;
2735 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2736 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2737 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2738 StartStr
= GetNextParamStr (&TextDeviceNode
);
2739 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2740 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2743 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2746 Hd
->PartitionNumber
= (UINT32
) Strtoi (PartitionStr
);
2748 ZeroMem (Hd
->Signature
, 16);
2749 Hd
->MBRType
= (UINT8
) 0;
2751 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2752 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2755 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2756 memcpy (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2757 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2758 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2761 StrToGuid (SignatureStr
, (EFI_GUID
*) Hd
->Signature
);
2763 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2766 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2767 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2769 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2773 Converts a text device path node to CDROM device path structure.
2775 @param TextDeviceNode The input Text device path node.
2777 @return A pointer to the newly-created CDROM device path structure.
2780 EFI_DEVICE_PATH_PROTOCOL
*
2781 DevPathFromTextCDROM (
2782 CHAR16
*TextDeviceNode
2788 CDROM_DEVICE_PATH
*CDROMDevPath
;
2790 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2791 StartStr
= GetNextParamStr (&TextDeviceNode
);
2792 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2793 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2796 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2799 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2800 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2801 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2803 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2807 Converts a text device path node to Vendor-defined media device path structure.
2809 @param TextDeviceNode The input Text device path node.
2811 @return A pointer to the newly-created Vendor-defined media device path structure.
2814 EFI_DEVICE_PATH_PROTOCOL
*
2815 DevPathFromTextVenMedia (
2816 CHAR16
*TextDeviceNode
2819 return ConvertFromTextVendor (
2827 Converts a text device path node to File device path structure.
2829 @param TextDeviceNode The input Text device path node.
2831 @return A pointer to the newly-created File device path structure.
2834 EFI_DEVICE_PATH_PROTOCOL
*
2835 DevPathFromTextFilePath (
2836 CHAR16
*TextDeviceNode
2839 FILEPATH_DEVICE_PATH
*File
;
2841 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2844 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
2847 StrCpyS (File
->PathName
, StrLen (TextDeviceNode
) + 1, TextDeviceNode
);
2849 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
2853 Converts a text device path node to Media protocol device path structure.
2855 @param TextDeviceNode The input Text device path node.
2857 @return A pointer to the newly-created Media protocol device path structure.
2860 EFI_DEVICE_PATH_PROTOCOL
*
2861 DevPathFromTextMedia (
2862 CHAR16
*TextDeviceNode
2866 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
2868 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2869 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
2872 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
2875 StrToGuid (GuidStr
, &Media
->Protocol
);
2877 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
2881 Converts a text device path node to firmware volume device path structure.
2883 @param TextDeviceNode The input Text device path node.
2885 @return A pointer to the newly-created firmware volume device path structure.
2888 EFI_DEVICE_PATH_PROTOCOL
*
2890 CHAR16
*TextDeviceNode
2894 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
2896 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2897 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
2899 MEDIA_PIWG_FW_VOL_DP
,
2900 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
2903 StrToGuid (GuidStr
, &Fv
->FvName
);
2905 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
2909 Converts a text device path node to firmware file device path structure.
2911 @param TextDeviceNode The input Text device path node.
2913 @return A pointer to the newly-created firmware file device path structure.
2916 EFI_DEVICE_PATH_PROTOCOL
*
2917 DevPathFromTextFvFile (
2918 CHAR16
*TextDeviceNode
2922 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
2924 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2925 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2927 MEDIA_PIWG_FW_FILE_DP
,
2928 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
2931 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
2933 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
2937 Converts a text device path node to text relative offset device path structure.
2939 @param TextDeviceNode The input Text device path node.
2941 @return A pointer to the newly-created Text device path structure.
2944 EFI_DEVICE_PATH_PROTOCOL
*
2945 DevPathFromTextRelativeOffsetRange (
2946 CHAR16
*TextDeviceNode
2949 CHAR16
*StartingOffsetStr
;
2950 CHAR16
*EndingOffsetStr
;
2951 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
2953 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2954 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2955 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
2957 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
2958 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
2961 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
2962 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
2964 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
2968 Converts a text device path node to text ram disk device path structure.
2970 @param TextDeviceNode The input Text device path node.
2972 @return A pointer to the newly-created Text device path structure.
2975 EFI_DEVICE_PATH_PROTOCOL
*
2976 DevPathFromTextRamDisk (
2977 CHAR16
*TextDeviceNode
2980 CHAR16
*StartingAddrStr
;
2981 CHAR16
*EndingAddrStr
;
2982 CHAR16
*TypeGuidStr
;
2983 CHAR16
*InstanceStr
;
2984 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
2985 UINT64 StartingAddr
;
2988 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
2989 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
2990 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
2991 TypeGuidStr
= GetNextParamStr (&TextDeviceNode
);
2992 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
2995 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
2998 Strtoi64 (StartingAddrStr
, &StartingAddr
);
2999 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3000 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3001 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3002 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3003 StrToGuid (TypeGuidStr
, &RamDisk
->TypeGuid
);
3005 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3009 Converts a text device path node to text virtual disk device path structure.
3011 @param TextDeviceNode The input Text device path node.
3013 @return A pointer to the newly-created Text device path structure.
3016 EFI_DEVICE_PATH_PROTOCOL
*
3017 DevPathFromTextVirtualDisk (
3018 CHAR16
*TextDeviceNode
3021 CHAR16
*StartingAddrStr
;
3022 CHAR16
*EndingAddrStr
;
3023 CHAR16
*InstanceStr
;
3024 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3025 UINT64 StartingAddr
;
3028 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3029 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3030 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3032 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3035 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3038 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3039 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3040 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3041 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3042 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3043 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualDiskGuid
);
3045 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3049 Converts a text device path node to text virtual cd device path structure.
3051 @param TextDeviceNode The input Text device path node.
3053 @return A pointer to the newly-created Text device path structure.
3056 EFI_DEVICE_PATH_PROTOCOL
*
3057 DevPathFromTextVirtualCd (
3058 CHAR16
*TextDeviceNode
3061 CHAR16
*StartingAddrStr
;
3062 CHAR16
*EndingAddrStr
;
3063 CHAR16
*InstanceStr
;
3064 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3065 UINT64 StartingAddr
;
3068 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3069 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3070 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3072 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3075 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3078 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3079 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3080 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3081 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3082 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3083 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualCdGuid
);
3085 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3089 Converts a text device path node to text persistent virtual disk device path structure.
3091 @param TextDeviceNode The input Text device path node.
3093 @return A pointer to the newly-created Text device path structure.
3096 EFI_DEVICE_PATH_PROTOCOL
*
3097 DevPathFromTextPersistentVirtualDisk (
3098 CHAR16
*TextDeviceNode
3101 CHAR16
*StartingAddrStr
;
3102 CHAR16
*EndingAddrStr
;
3103 CHAR16
*InstanceStr
;
3104 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3105 UINT64 StartingAddr
;
3108 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3109 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3110 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3112 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3115 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3118 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3119 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3120 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3121 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3122 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3123 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualDiskGuid
);
3125 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3129 Converts a text device path node to text persistent virtual cd device path structure.
3131 @param TextDeviceNode The input Text device path node.
3133 @return A pointer to the newly-created Text device path structure.
3136 EFI_DEVICE_PATH_PROTOCOL
*
3137 DevPathFromTextPersistentVirtualCd (
3138 CHAR16
*TextDeviceNode
3141 CHAR16
*StartingAddrStr
;
3142 CHAR16
*EndingAddrStr
;
3143 CHAR16
*InstanceStr
;
3144 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3145 UINT64 StartingAddr
;
3148 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3149 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3150 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3152 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3155 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3158 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3159 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3160 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3161 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3162 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3163 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualCdGuid
);
3165 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3169 Converts a BBS text device path node to BBS device path structure.
3171 @param TextDeviceNode The input Text device path node.
3173 @return A pointer to BBS device path structure.
3176 EFI_DEVICE_PATH_PROTOCOL
*
3177 DevPathFromTextBbsPath (
3178 CHAR16
*TextDeviceNode
3181 return DevPathFromTextGenericPath (BBS_DEVICE_PATH
, TextDeviceNode
);
3185 Converts a text device path node to BIOS Boot Specification device path structure.
3187 @param TextDeviceNode The input Text device path node.
3189 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3192 EFI_DEVICE_PATH_PROTOCOL
*
3193 DevPathFromTextBBS (
3194 CHAR16
*TextDeviceNode
3201 BBS_BBS_DEVICE_PATH
*Bbs
;
3203 TypeStr
= GetNextParamStr (&TextDeviceNode
);
3204 IdStr
= GetNextParamStr (&TextDeviceNode
);
3205 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
3206 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
3209 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
3212 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
3213 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
3214 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
3215 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
3216 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
3217 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
3218 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
3219 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
3220 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
3221 Bbs
->DeviceType
= BBS_TYPE_USB
;
3222 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
3223 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
3225 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
3228 AsciiStr
= Bbs
->String
;
3229 StrToAscii (IdStr
, &AsciiStr
);
3231 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
3233 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
3237 Converts a text device path node to SATA device path structure.
3239 @param TextDeviceNode The input Text device path node.
3241 @return A pointer to the newly-created SATA device path structure.
3244 EFI_DEVICE_PATH_PROTOCOL
*
3245 DevPathFromTextSata (
3246 CHAR16
*TextDeviceNode
3249 SATA_DEVICE_PATH
*Sata
;
3254 Param1
= GetNextParamStr (&TextDeviceNode
);
3255 Param2
= GetNextParamStr (&TextDeviceNode
);
3256 Param3
= GetNextParamStr (&TextDeviceNode
);
3258 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
3259 MESSAGING_DEVICE_PATH
,
3261 (UINT16
) sizeof (SATA_DEVICE_PATH
)
3263 Sata
->HBAPortNumber
= (UINT16
) Strtoi (Param1
);
3264 Sata
->PortMultiplierPortNumber
= (UINT16
) Strtoi (Param2
);
3265 Sata
->Lun
= (UINT16
) Strtoi (Param3
);
3267 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
3270 DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
3271 {L
"Path", DevPathFromTextPath
},
3273 {L
"HardwarePath", DevPathFromTextHardwarePath
},
3274 {L
"Pci", DevPathFromTextPci
},
3275 {L
"PcCard", DevPathFromTextPcCard
},
3276 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
3277 {L
"VenHw", DevPathFromTextVenHw
},
3278 {L
"Ctrl", DevPathFromTextCtrl
},
3279 {L
"BMC", DevPathFromTextBmc
},
3281 {L
"AcpiPath", DevPathFromTextAcpiPath
},
3282 {L
"Acpi", DevPathFromTextAcpi
},
3283 {L
"PciRoot", DevPathFromTextPciRoot
},
3284 {L
"PcieRoot", DevPathFromTextPcieRoot
},
3285 {L
"Floppy", DevPathFromTextFloppy
},
3286 {L
"Keyboard", DevPathFromTextKeyboard
},
3287 {L
"Serial", DevPathFromTextSerial
},
3288 {L
"ParallelPort", DevPathFromTextParallelPort
},
3289 {L
"AcpiEx", DevPathFromTextAcpiEx
},
3290 {L
"AcpiExp", DevPathFromTextAcpiExp
},
3291 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
3293 {L
"Msg", DevPathFromTextMsg
},
3294 {L
"Ata", DevPathFromTextAta
},
3295 {L
"Scsi", DevPathFromTextScsi
},
3296 {L
"Fibre", DevPathFromTextFibre
},
3297 {L
"FibreEx", DevPathFromTextFibreEx
},
3298 {L
"I1394", DevPathFromText1394
},
3299 {L
"USB", DevPathFromTextUsb
},
3300 {L
"I2O", DevPathFromTextI2O
},
3301 {L
"Infiniband", DevPathFromTextInfiniband
},
3302 {L
"VenMsg", DevPathFromTextVenMsg
},
3303 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
3304 {L
"VenVt100", DevPathFromTextVenVt100
},
3305 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
3306 {L
"VenUtf8", DevPathFromTextVenUtf8
},
3307 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
3308 {L
"SAS", DevPathFromTextSAS
},
3309 {L
"SasEx", DevPathFromTextSasEx
},
3310 {L
"NVMe", DevPathFromTextNVMe
},
3311 {L
"UFS", DevPathFromTextUfs
},
3312 {L
"SD", DevPathFromTextSd
},
3313 {L
"eMMC", DevPathFromTextEmmc
},
3314 {L
"DebugPort", DevPathFromTextDebugPort
},
3315 {L
"MAC", DevPathFromTextMAC
},
3316 {L
"IPv4", DevPathFromTextIPv4
},
3317 {L
"IPv6", DevPathFromTextIPv6
},
3318 {L
"Uart", DevPathFromTextUart
},
3319 {L
"UsbClass", DevPathFromTextUsbClass
},
3320 {L
"UsbAudio", DevPathFromTextUsbAudio
},
3321 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
3322 {L
"UsbHID", DevPathFromTextUsbHID
},
3323 {L
"UsbImage", DevPathFromTextUsbImage
},
3324 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
3325 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
3326 {L
"UsbHub", DevPathFromTextUsbHub
},
3327 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
3328 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
3329 {L
"UsbVideo", DevPathFromTextUsbVideo
},
3330 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
3331 {L
"UsbWireless", DevPathFromTextUsbWireless
},
3332 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
3333 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
3334 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
3335 {L
"UsbWwid", DevPathFromTextUsbWwid
},
3336 {L
"Unit", DevPathFromTextUnit
},
3337 {L
"iSCSI", DevPathFromTextiSCSI
},
3338 {L
"Vlan", DevPathFromTextVlan
},
3339 {L
"Dns", DevPathFromTextDns
},
3340 {L
"Uri", DevPathFromTextUri
},
3341 {L
"Bluetooth", DevPathFromTextBluetooth
},
3342 {L
"Wi-Fi", DevPathFromTextWiFi
},
3343 {L
"BluetoothLE", DevPathFromTextBluetoothLE
},
3344 {L
"MediaPath", DevPathFromTextMediaPath
},
3345 {L
"HD", DevPathFromTextHD
},
3346 {L
"CDROM", DevPathFromTextCDROM
},
3347 {L
"VenMedia", DevPathFromTextVenMedia
},
3348 {L
"Media", DevPathFromTextMedia
},
3349 {L
"Fv", DevPathFromTextFv
},
3350 {L
"FvFile", DevPathFromTextFvFile
},
3351 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
3352 {L
"RamDisk", DevPathFromTextRamDisk
},
3353 {L
"VirtualDisk", DevPathFromTextVirtualDisk
},
3354 {L
"VirtualCD", DevPathFromTextVirtualCd
},
3355 {L
"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk
},
3356 {L
"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd
},
3358 {L
"BbsPath", DevPathFromTextBbsPath
},
3359 {L
"BBS", DevPathFromTextBBS
},
3360 {L
"Sata", DevPathFromTextSata
},
3365 Convert text to the binary representation of a device node.
3367 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3368 node. Conversion starts with the first character and continues
3369 until the first non-device node character.
3371 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3372 insufficient memory or text unsupported.
3375 EFI_DEVICE_PATH_PROTOCOL
*
3376 UefiDevicePathLibConvertTextToDeviceNode (
3377 CONST CHAR16
*TextDeviceNode
3380 DEVICE_PATH_FROM_TEXT FromText
;
3382 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3383 CHAR16
*DeviceNodeStr
;
3386 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
3392 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
3393 ASSERT (DeviceNodeStr
!= NULL
);
3395 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3396 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
3397 if (ParamStr
!= NULL
) {
3398 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
3403 if (FromText
== NULL
) {
3407 FromText
= DevPathFromTextFilePath
;
3408 DeviceNode
= FromText (DeviceNodeStr
);
3410 // According to above logic, if 'FromText' is NULL in the 'if' statement,
3411 // then 'ParamStr' must be NULL as well. No memory allocation has been made
3414 // The below check is for addressing a false positive potential memory leak
3415 // issue raised from static analysis.
3417 if (ParamStr
!= NULL
) {
3421 DeviceNode
= FromText (ParamStr
);
3425 free (DeviceNodeStr
);
3431 Convert text to the binary representation of a device path.
3434 @param TextDevicePath TextDevicePath points to the text representation of a device
3435 path. Conversion starts with the first character and continues
3436 until the first non-device node character.
3438 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3439 there was insufficient memory.
3442 EFI_DEVICE_PATH_PROTOCOL
*
3443 UefiDevicePathLibConvertTextToDevicePath (
3444 CONST CHAR16
*TextDevicePath
3447 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3448 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3449 CHAR16
*DevicePathStr
;
3451 CHAR16
*DeviceNodeStr
;
3452 BOOLEAN IsInstanceEnd
;
3453 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3455 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3459 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3460 ASSERT (DevicePath
!= NULL
);
3461 SetDevicePathEndNode (DevicePath
);
3463 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3465 Str
= DevicePathStr
;
3466 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3467 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3469 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3472 DevicePath
= NewDevicePath
;
3474 if (IsInstanceEnd
) {
3475 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3476 ASSERT (DeviceNode
!= NULL
);
3477 SetDevicePathEndNode (DeviceNode
);
3478 DeviceNode
->SubType
= END_INSTANCE_DEVICE_PATH_SUBTYPE
;
3480 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3483 DevicePath
= NewDevicePath
;
3487 free (DevicePathStr
);