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
) (StrHexToUint64 (&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
);
768 // According to UEFI spec, the CID parametr is optional and has a default value of 0.
769 // So when the CID parametr is not specified or specified as 0 in the text device node.
770 // Set the CID to 0 in the ACPI extension device path structure.
772 if (*CIDStr
== L
'\0' || *CIDStr
== L
'0') {
775 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
779 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
781 // HID string is NULL
785 // Convert UID string
788 StrToAscii (UIDSTRStr
, &AsciiStr
);
790 // CID string is NULL
794 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
798 Converts a text device path node to ACPI _ADR device path structure.
800 @param TextDeviceNode The input Text device path node.
802 @return A pointer to the newly-created ACPI _ADR device path structure.
805 EFI_DEVICE_PATH_PROTOCOL
*
806 DevPathFromTextAcpiAdr (
807 CHAR16
*TextDeviceNode
810 CHAR16
*DisplayDeviceStr
;
811 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
815 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*) CreateDeviceNode (
818 (UINT16
) sizeof (ACPI_ADR_DEVICE_PATH
)
820 ASSERT (AcpiAdr
!= NULL
);
822 for (Index
= 0; ; Index
++) {
823 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
824 if (IS_NULL (*DisplayDeviceStr
)) {
828 Length
= DevicePathNodeLength (AcpiAdr
);
829 AcpiAdr
= ReallocatePool (
831 Length
+ sizeof (UINT32
),
834 ASSERT (AcpiAdr
!= NULL
);
835 SetDevicePathNodeLength (AcpiAdr
, Length
+ sizeof (UINT32
));
838 (&AcpiAdr
->ADR
)[Index
] = (UINT32
) Strtoi (DisplayDeviceStr
);
841 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
;
845 Converts a generic messaging text device path node to messaging device path structure.
847 @param TextDeviceNode The input Text device path node.
849 @return A pointer to messaging device path structure.
852 EFI_DEVICE_PATH_PROTOCOL
*
854 CHAR16
*TextDeviceNode
857 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH
, TextDeviceNode
);
861 Converts a text device path node to Parallel Port device path structure.
863 @param TextDeviceNode The input Text device path node.
865 @return A pointer to the newly-created Parallel Port device path structure.
868 EFI_DEVICE_PATH_PROTOCOL
*
870 CHAR16
*TextDeviceNode
873 CHAR16
*PrimarySecondaryStr
;
874 CHAR16
*SlaveMasterStr
;
876 ATAPI_DEVICE_PATH
*Atapi
;
878 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
879 MESSAGING_DEVICE_PATH
,
881 (UINT16
) sizeof (ATAPI_DEVICE_PATH
)
884 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
885 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
886 LunStr
= GetNextParamStr (&TextDeviceNode
);
888 if (StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) {
889 Atapi
->PrimarySecondary
= 0;
890 } else if (StrCmp (PrimarySecondaryStr
, L
"Secondary") == 0) {
891 Atapi
->PrimarySecondary
= 1;
893 Atapi
->PrimarySecondary
= (UINT8
) Strtoi (PrimarySecondaryStr
);
895 if (StrCmp (SlaveMasterStr
, L
"Master") == 0) {
896 Atapi
->SlaveMaster
= 0;
897 } else if (StrCmp (SlaveMasterStr
, L
"Slave") == 0) {
898 Atapi
->SlaveMaster
= 1;
900 Atapi
->SlaveMaster
= (UINT8
) Strtoi (SlaveMasterStr
);
903 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
905 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
909 Converts a text device path node to SCSI device path structure.
911 @param TextDeviceNode The input Text device path node.
913 @return A pointer to the newly-created SCSI device path structure.
916 EFI_DEVICE_PATH_PROTOCOL
*
917 DevPathFromTextScsi (
918 CHAR16
*TextDeviceNode
923 SCSI_DEVICE_PATH
*Scsi
;
925 PunStr
= GetNextParamStr (&TextDeviceNode
);
926 LunStr
= GetNextParamStr (&TextDeviceNode
);
927 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
928 MESSAGING_DEVICE_PATH
,
930 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
933 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
934 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
936 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
940 Converts a text device path node to Fibre device path structure.
942 @param TextDeviceNode The input Text device path node.
944 @return A pointer to the newly-created Fibre device path structure.
947 EFI_DEVICE_PATH_PROTOCOL
*
948 DevPathFromTextFibre (
949 CHAR16
*TextDeviceNode
954 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
956 WWNStr
= GetNextParamStr (&TextDeviceNode
);
957 LunStr
= GetNextParamStr (&TextDeviceNode
);
958 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
959 MESSAGING_DEVICE_PATH
,
961 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
965 Strtoi64 (WWNStr
, &Fibre
->WWN
);
966 Strtoi64 (LunStr
, &Fibre
->Lun
);
968 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
972 Converts a text device path node to FibreEx device path structure.
974 @param TextDeviceNode The input Text device path node.
976 @return A pointer to the newly-created FibreEx device path structure.
979 EFI_DEVICE_PATH_PROTOCOL
*
980 DevPathFromTextFibreEx (
981 CHAR16
*TextDeviceNode
986 FIBRECHANNELEX_DEVICE_PATH
*FibreEx
;
988 WWNStr
= GetNextParamStr (&TextDeviceNode
);
989 LunStr
= GetNextParamStr (&TextDeviceNode
);
990 FibreEx
= (FIBRECHANNELEX_DEVICE_PATH
*) CreateDeviceNode (
991 MESSAGING_DEVICE_PATH
,
992 MSG_FIBRECHANNELEX_DP
,
993 (UINT16
) sizeof (FIBRECHANNELEX_DEVICE_PATH
)
996 FibreEx
->Reserved
= 0;
997 Strtoi64 (WWNStr
, (UINT64
*) (&FibreEx
->WWN
));
998 Strtoi64 (LunStr
, (UINT64
*) (&FibreEx
->Lun
));
1000 *(UINT64
*) (&FibreEx
->WWN
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->WWN
));
1001 *(UINT64
*) (&FibreEx
->Lun
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->Lun
));
1003 return (EFI_DEVICE_PATH_PROTOCOL
*) FibreEx
;
1007 Converts a text device path node to 1394 device path structure.
1009 @param TextDeviceNode The input Text device path node.
1011 @return A pointer to the newly-created 1394 device path structure.
1014 EFI_DEVICE_PATH_PROTOCOL
*
1015 DevPathFromText1394 (
1016 CHAR16
*TextDeviceNode
1020 F1394_DEVICE_PATH
*F1394DevPath
;
1022 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1023 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1024 MESSAGING_DEVICE_PATH
,
1026 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1029 F1394DevPath
->Reserved
= 0;
1030 F1394DevPath
->Guid
= StrHexToUint64 (GuidStr
);
1032 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1036 Converts a text device path node to USB device path structure.
1038 @param TextDeviceNode The input Text device path node.
1040 @return A pointer to the newly-created USB device path structure.
1043 EFI_DEVICE_PATH_PROTOCOL
*
1044 DevPathFromTextUsb (
1045 CHAR16
*TextDeviceNode
1049 CHAR16
*InterfaceStr
;
1050 USB_DEVICE_PATH
*Usb
;
1052 PortStr
= GetNextParamStr (&TextDeviceNode
);
1053 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1054 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1055 MESSAGING_DEVICE_PATH
,
1057 (UINT16
) sizeof (USB_DEVICE_PATH
)
1060 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1061 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1063 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1067 Converts a text device path node to I20 device path structure.
1069 @param TextDeviceNode The input Text device path node.
1071 @return A pointer to the newly-created I20 device path structure.
1074 EFI_DEVICE_PATH_PROTOCOL
*
1075 DevPathFromTextI2O (
1076 CHAR16
*TextDeviceNode
1080 I2O_DEVICE_PATH
*I2ODevPath
;
1082 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1083 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1084 MESSAGING_DEVICE_PATH
,
1086 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1089 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1091 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1095 Converts a text device path node to Infini Band device path structure.
1097 @param TextDeviceNode The input Text device path node.
1099 @return A pointer to the newly-created Infini Band device path structure.
1102 EFI_DEVICE_PATH_PROTOCOL
*
1103 DevPathFromTextInfiniband (
1104 CHAR16
*TextDeviceNode
1112 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1114 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1115 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1116 SidStr
= GetNextParamStr (&TextDeviceNode
);
1117 TidStr
= GetNextParamStr (&TextDeviceNode
);
1118 DidStr
= GetNextParamStr (&TextDeviceNode
);
1119 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1120 MESSAGING_DEVICE_PATH
,
1122 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1125 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1126 StrToGuid (GuidStr
, (EFI_GUID
*) InfiniBand
->PortGid
);
1127 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1128 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1129 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1131 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1135 Converts a text device path node to Vendor-Defined Messaging device path structure.
1137 @param TextDeviceNode The input Text device path node.
1139 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1142 EFI_DEVICE_PATH_PROTOCOL
*
1143 DevPathFromTextVenMsg (
1144 CHAR16
*TextDeviceNode
1147 return ConvertFromTextVendor (
1149 MESSAGING_DEVICE_PATH
,
1155 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1157 @param TextDeviceNode The input Text device path node.
1159 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1162 EFI_DEVICE_PATH_PROTOCOL
*
1163 DevPathFromTextVenPcAnsi (
1164 CHAR16
*TextDeviceNode
1167 VENDOR_DEVICE_PATH
*Vendor
;
1169 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1170 MESSAGING_DEVICE_PATH
,
1172 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1173 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1175 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1179 Converts a text device path node to Vendor defined VT100 device path structure.
1181 @param TextDeviceNode The input Text device path node.
1183 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1186 EFI_DEVICE_PATH_PROTOCOL
*
1187 DevPathFromTextVenVt100 (
1188 CHAR16
*TextDeviceNode
1191 VENDOR_DEVICE_PATH
*Vendor
;
1193 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1194 MESSAGING_DEVICE_PATH
,
1196 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1197 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1199 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1203 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1205 @param TextDeviceNode The input Text device path node.
1207 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1210 EFI_DEVICE_PATH_PROTOCOL
*
1211 DevPathFromTextVenVt100Plus (
1212 CHAR16
*TextDeviceNode
1215 VENDOR_DEVICE_PATH
*Vendor
;
1217 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1218 MESSAGING_DEVICE_PATH
,
1220 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1221 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1223 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1227 Converts a text device path node to Vendor defined UTF8 device path structure.
1229 @param TextDeviceNode The input Text device path node.
1231 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1234 EFI_DEVICE_PATH_PROTOCOL
*
1235 DevPathFromTextVenUtf8 (
1236 CHAR16
*TextDeviceNode
1239 VENDOR_DEVICE_PATH
*Vendor
;
1241 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1242 MESSAGING_DEVICE_PATH
,
1244 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1245 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1247 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1251 Converts a text device path node to UART Flow Control device path structure.
1253 @param TextDeviceNode The input Text device path node.
1255 @return A pointer to the newly-created UART Flow Control device path structure.
1258 EFI_DEVICE_PATH_PROTOCOL
*
1259 DevPathFromTextUartFlowCtrl (
1260 CHAR16
*TextDeviceNode
1264 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1266 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1267 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1268 MESSAGING_DEVICE_PATH
,
1270 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1273 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1274 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1275 UartFlowControl
->FlowControlMap
= 2;
1276 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1277 UartFlowControl
->FlowControlMap
= 1;
1279 UartFlowControl
->FlowControlMap
= 0;
1282 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1286 Converts a text device path node to Serial Attached SCSI device path structure.
1288 @param TextDeviceNode The input Text device path node.
1290 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1293 EFI_DEVICE_PATH_PROTOCOL
*
1294 DevPathFromTextSAS (
1295 CHAR16
*TextDeviceNode
1302 CHAR16
*LocationStr
;
1304 CHAR16
*DriveBayStr
;
1305 CHAR16
*ReservedStr
;
1308 SAS_DEVICE_PATH
*Sas
;
1310 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1311 LunStr
= GetNextParamStr (&TextDeviceNode
);
1312 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1313 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1314 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1315 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1316 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1317 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1318 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1319 MESSAGING_DEVICE_PATH
,
1321 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1324 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1325 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1326 Strtoi64 (LunStr
, &Sas
->Lun
);
1327 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1329 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1332 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1334 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1338 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1341 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1346 // Location is an integer between 0 and 1 or else
1347 // the keyword Internal (0) or External (1).
1349 if (StrCmp (LocationStr
, L
"External") == 0) {
1351 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1354 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1356 Info
|= (Uint16
<< 5);
1359 // Connect is an integer between 0 and 3 or else
1360 // the keyword Direct (0) or Expanded (1).
1362 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1364 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1367 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1369 Info
|= (Uint16
<< 6);
1372 Info
= (UINT16
) Strtoi (SASSATAStr
);
1375 Sas
->DeviceTopology
= Info
;
1376 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1378 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1382 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1384 @param TextDeviceNode The input Text device path node.
1386 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1389 EFI_DEVICE_PATH_PROTOCOL
*
1390 DevPathFromTextSasEx (
1391 CHAR16
*TextDeviceNode
1398 CHAR16
*LocationStr
;
1400 CHAR16
*DriveBayStr
;
1405 SASEX_DEVICE_PATH
*SasEx
;
1407 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1408 LunStr
= GetNextParamStr (&TextDeviceNode
);
1409 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1410 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1411 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1412 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1413 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1414 SasEx
= (SASEX_DEVICE_PATH
*) CreateDeviceNode (
1415 MESSAGING_DEVICE_PATH
,
1417 (UINT16
) sizeof (SASEX_DEVICE_PATH
)
1420 Strtoi64 (AddressStr
, &SasAddress
);
1421 Strtoi64 (LunStr
, &Lun
);
1422 WriteUnaligned64 ((UINT64
*) &SasEx
->SasAddress
, SwapBytes64 (SasAddress
));
1423 WriteUnaligned64 ((UINT64
*) &SasEx
->Lun
, SwapBytes64 (Lun
));
1424 SasEx
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1426 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1429 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1431 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1435 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1438 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1443 // Location is an integer between 0 and 1 or else
1444 // the keyword Internal (0) or External (1).
1446 if (StrCmp (LocationStr
, L
"External") == 0) {
1448 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1451 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1453 Info
|= (Uint16
<< 5);
1456 // Connect is an integer between 0 and 3 or else
1457 // the keyword Direct (0) or Expanded (1).
1459 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1461 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1464 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1466 Info
|= (Uint16
<< 6);
1469 Info
= (UINT16
) Strtoi (SASSATAStr
);
1472 SasEx
->DeviceTopology
= Info
;
1474 return (EFI_DEVICE_PATH_PROTOCOL
*) SasEx
;
1478 Converts a text device path node to NVM Express Namespace device path structure.
1480 @param TextDeviceNode The input Text device path node.
1482 @return A pointer to the newly-created NVM Express Namespace device path structure.
1485 EFI_DEVICE_PATH_PROTOCOL
*
1486 DevPathFromTextNVMe (
1487 CHAR16
*TextDeviceNode
1490 CHAR16
*NamespaceIdStr
;
1491 CHAR16
*NamespaceUuidStr
;
1492 NVME_NAMESPACE_DEVICE_PATH
*Nvme
;
1496 NamespaceIdStr
= GetNextParamStr (&TextDeviceNode
);
1497 NamespaceUuidStr
= GetNextParamStr (&TextDeviceNode
);
1498 Nvme
= (NVME_NAMESPACE_DEVICE_PATH
*) CreateDeviceNode (
1499 MESSAGING_DEVICE_PATH
,
1500 MSG_NVME_NAMESPACE_DP
,
1501 (UINT16
) sizeof (NVME_NAMESPACE_DEVICE_PATH
)
1504 Nvme
->NamespaceId
= (UINT32
) Strtoi (NamespaceIdStr
);
1505 Uuid
= (UINT8
*) &Nvme
->NamespaceUuid
;
1507 Index
= sizeof (Nvme
->NamespaceUuid
) / sizeof (UINT8
);
1508 while (Index
-- != 0) {
1509 Uuid
[Index
] = (UINT8
) StrHexToUint64 (SplitStr (&NamespaceUuidStr
, L
'-'));
1512 return (EFI_DEVICE_PATH_PROTOCOL
*) Nvme
;
1516 Converts a text device path node to UFS device path structure.
1518 @param TextDeviceNode The input Text device path node.
1520 @return A pointer to the newly-created UFS device path structure.
1523 EFI_DEVICE_PATH_PROTOCOL
*
1524 DevPathFromTextUfs (
1525 CHAR16
*TextDeviceNode
1530 UFS_DEVICE_PATH
*Ufs
;
1532 PunStr
= GetNextParamStr (&TextDeviceNode
);
1533 LunStr
= GetNextParamStr (&TextDeviceNode
);
1534 Ufs
= (UFS_DEVICE_PATH
*) CreateDeviceNode (
1535 MESSAGING_DEVICE_PATH
,
1537 (UINT16
) sizeof (UFS_DEVICE_PATH
)
1540 Ufs
->Pun
= (UINT8
) Strtoi (PunStr
);
1541 Ufs
->Lun
= (UINT8
) Strtoi (LunStr
);
1543 return (EFI_DEVICE_PATH_PROTOCOL
*) Ufs
;
1547 Converts a text device path node to SD (Secure Digital) device path structure.
1549 @param TextDeviceNode The input Text device path node.
1551 @return A pointer to the newly-created SD device path structure.
1554 EFI_DEVICE_PATH_PROTOCOL
*
1556 CHAR16
*TextDeviceNode
1559 CHAR16
*SlotNumberStr
;
1562 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1563 Sd
= (SD_DEVICE_PATH
*) CreateDeviceNode (
1564 MESSAGING_DEVICE_PATH
,
1566 (UINT16
) sizeof (SD_DEVICE_PATH
)
1569 Sd
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1571 return (EFI_DEVICE_PATH_PROTOCOL
*) Sd
;
1575 Converts a text device path node to EMMC (Embedded MMC) device path structure.
1577 @param TextDeviceNode The input Text device path node.
1579 @return A pointer to the newly-created EMMC device path structure.
1582 EFI_DEVICE_PATH_PROTOCOL
*
1583 DevPathFromTextEmmc (
1584 CHAR16
*TextDeviceNode
1587 CHAR16
*SlotNumberStr
;
1588 EMMC_DEVICE_PATH
*Emmc
;
1590 SlotNumberStr
= GetNextParamStr (&TextDeviceNode
);
1591 Emmc
= (EMMC_DEVICE_PATH
*) CreateDeviceNode (
1592 MESSAGING_DEVICE_PATH
,
1594 (UINT16
) sizeof (EMMC_DEVICE_PATH
)
1597 Emmc
->SlotNumber
= (UINT8
) Strtoi (SlotNumberStr
);
1599 return (EFI_DEVICE_PATH_PROTOCOL
*) Emmc
;
1603 Converts a text device path node to Debug Port device path structure.
1605 @param TextDeviceNode The input Text device path node.
1607 @return A pointer to the newly-created Debug Port device path structure.
1610 EFI_DEVICE_PATH_PROTOCOL
*
1611 DevPathFromTextDebugPort (
1612 CHAR16
*TextDeviceNode
1615 VENDOR_DEVICE_PATH
*Vend
;
1617 Vend
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1618 MESSAGING_DEVICE_PATH
,
1620 (UINT16
) sizeof (VENDOR_DEVICE_PATH
)
1623 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1625 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1629 Converts a text device path node to MAC device path structure.
1631 @param TextDeviceNode The input Text device path node.
1633 @return A pointer to the newly-created MAC device path structure.
1636 EFI_DEVICE_PATH_PROTOCOL
*
1637 DevPathFromTextMAC (
1638 CHAR16
*TextDeviceNode
1644 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1646 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1647 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1648 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1649 MESSAGING_DEVICE_PATH
,
1651 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1654 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1656 Length
= sizeof (EFI_MAC_ADDRESS
);
1657 if (MACDevPath
->IfType
== 0x01 || MACDevPath
->IfType
== 0x00) {
1661 StrHexToBytes (AddressStr
, Length
* 2, MACDevPath
->MacAddress
.Addr
, Length
);
1663 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1668 Converts a text format to the network protocol ID.
1670 @param Text String of protocol field.
1672 @return Network protocol ID .
1676 NetworkProtocolFromText (
1680 if (StrCmp (Text
, L
"UDP") == 0) {
1681 return RFC_1700_UDP_PROTOCOL
;
1684 if (StrCmp (Text
, L
"TCP") == 0) {
1685 return RFC_1700_TCP_PROTOCOL
;
1688 return Strtoi (Text
);
1693 Converts a text device path node to IPV4 device path structure.
1695 @param TextDeviceNode The input Text device path node.
1697 @return A pointer to the newly-created IPV4 device path structure.
1700 EFI_DEVICE_PATH_PROTOCOL
*
1701 DevPathFromTextIPv4 (
1702 CHAR16
*TextDeviceNode
1705 CHAR16
*RemoteIPStr
;
1706 CHAR16
*ProtocolStr
;
1709 CHAR16
*GatewayIPStr
;
1710 CHAR16
*SubnetMaskStr
;
1711 IPv4_DEVICE_PATH
*IPv4
;
1713 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1714 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1715 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1716 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1717 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1718 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
1719 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1720 MESSAGING_DEVICE_PATH
,
1722 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
1725 StrToIpv4Address (RemoteIPStr
, NULL
, &IPv4
->RemoteIpAddress
, NULL
);
1726 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1727 if (StrCmp (TypeStr
, L
"Static") == 0) {
1728 IPv4
->StaticIpAddress
= TRUE
;
1730 IPv4
->StaticIpAddress
= FALSE
;
1733 StrToIpv4Address (LocalIPStr
, NULL
, &IPv4
->LocalIpAddress
, NULL
);
1734 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
1735 StrToIpv4Address (GatewayIPStr
, NULL
, &IPv4
->GatewayIpAddress
, NULL
);
1736 StrToIpv4Address (SubnetMaskStr
, NULL
, &IPv4
->SubnetMask
, NULL
);
1738 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
1739 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
1742 IPv4
->LocalPort
= 0;
1743 IPv4
->RemotePort
= 0;
1745 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1749 Converts a text device path node to IPV6 device path structure.
1751 @param TextDeviceNode The input Text device path node.
1753 @return A pointer to the newly-created IPV6 device path structure.
1756 EFI_DEVICE_PATH_PROTOCOL
*
1757 DevPathFromTextIPv6 (
1758 CHAR16
*TextDeviceNode
1761 CHAR16
*RemoteIPStr
;
1762 CHAR16
*ProtocolStr
;
1765 CHAR16
*GatewayIPStr
;
1766 CHAR16
*PrefixLengthStr
;
1767 IPv6_DEVICE_PATH
*IPv6
;
1769 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1770 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1771 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1772 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1773 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
1774 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1775 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1776 MESSAGING_DEVICE_PATH
,
1778 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
1781 StrToIpv6Address (RemoteIPStr
, NULL
, &IPv6
->RemoteIpAddress
, NULL
);
1782 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1783 if (StrCmp (TypeStr
, L
"Static") == 0) {
1784 IPv6
->IpAddressOrigin
= 0;
1785 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
1786 IPv6
->IpAddressOrigin
= 1;
1788 IPv6
->IpAddressOrigin
= 2;
1791 StrToIpv6Address (LocalIPStr
, NULL
, &IPv6
->LocalIpAddress
, NULL
);
1792 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
1793 StrToIpv6Address (GatewayIPStr
, NULL
, &IPv6
->GatewayIpAddress
, NULL
);
1794 IPv6
->PrefixLength
= (UINT8
) Strtoi (PrefixLengthStr
);
1796 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
1797 IPv6
->PrefixLength
= 0;
1800 IPv6
->LocalPort
= 0;
1801 IPv6
->RemotePort
= 0;
1803 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
1807 Converts a text device path node to UART device path structure.
1809 @param TextDeviceNode The input Text device path node.
1811 @return A pointer to the newly-created UART device path structure.
1814 EFI_DEVICE_PATH_PROTOCOL
*
1815 DevPathFromTextUart (
1816 CHAR16
*TextDeviceNode
1820 CHAR16
*DataBitsStr
;
1822 CHAR16
*StopBitsStr
;
1823 UART_DEVICE_PATH
*Uart
;
1825 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1826 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1827 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1828 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1829 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
1830 MESSAGING_DEVICE_PATH
,
1832 (UINT16
) sizeof (UART_DEVICE_PATH
)
1835 if (StrCmp (BaudStr
, L
"DEFAULT") == 0) {
1836 Uart
->BaudRate
= 115200;
1838 Strtoi64 (BaudStr
, &Uart
->BaudRate
);
1840 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr
));
1841 switch (*ParityStr
) {
1867 Uart
->Parity
= (UINT8
) Strtoi (ParityStr
);
1871 if (StrCmp (StopBitsStr
, L
"D") == 0) {
1872 Uart
->StopBits
= (UINT8
) 0;
1873 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
1874 Uart
->StopBits
= (UINT8
) 1;
1875 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
1876 Uart
->StopBits
= (UINT8
) 2;
1877 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
1878 Uart
->StopBits
= (UINT8
) 3;
1880 Uart
->StopBits
= (UINT8
) Strtoi (StopBitsStr
);
1883 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
1887 Converts a text device path node to USB class device path structure.
1889 @param TextDeviceNode The input Text device path node.
1890 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
1892 @return A pointer to the newly-created USB class device path structure.
1895 EFI_DEVICE_PATH_PROTOCOL
*
1896 ConvertFromTextUsbClass (
1897 CHAR16
*TextDeviceNode
,
1898 USB_CLASS_TEXT
*UsbClassText
1904 CHAR16
*SubClassStr
;
1905 CHAR16
*ProtocolStr
;
1906 USB_CLASS_DEVICE_PATH
*UsbClass
;
1908 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
1909 MESSAGING_DEVICE_PATH
,
1911 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
1914 VIDStr
= GetNextParamStr (&TextDeviceNode
);
1915 PIDStr
= GetNextParamStr (&TextDeviceNode
);
1916 if (UsbClassText
->ClassExist
) {
1917 ClassStr
= GetNextParamStr (&TextDeviceNode
);
1918 if (*ClassStr
== L
'\0') {
1919 UsbClass
->DeviceClass
= 0xFF;
1921 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
1924 UsbClass
->DeviceClass
= UsbClassText
->Class
;
1926 if (UsbClassText
->SubClassExist
) {
1927 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
1928 if (*SubClassStr
== L
'\0') {
1929 UsbClass
->DeviceSubClass
= 0xFF;
1931 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
1934 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
1937 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1939 if (*VIDStr
== L
'\0') {
1940 UsbClass
->VendorId
= 0xFFFF;
1942 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
1944 if (*PIDStr
== L
'\0') {
1945 UsbClass
->ProductId
= 0xFFFF;
1947 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
1949 if (*ProtocolStr
== L
'\0') {
1950 UsbClass
->DeviceProtocol
= 0xFF;
1952 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
1955 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
1960 Converts a text device path node to USB class device path structure.
1962 @param TextDeviceNode The input Text device path node.
1964 @return A pointer to the newly-created USB class device path structure.
1967 EFI_DEVICE_PATH_PROTOCOL
*
1968 DevPathFromTextUsbClass (
1969 CHAR16
*TextDeviceNode
1972 USB_CLASS_TEXT UsbClassText
;
1974 UsbClassText
.ClassExist
= TRUE
;
1975 UsbClassText
.SubClassExist
= TRUE
;
1977 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
1981 Converts a text device path node to USB audio device path structure.
1983 @param TextDeviceNode The input Text device path node.
1985 @return A pointer to the newly-created USB audio device path structure.
1988 EFI_DEVICE_PATH_PROTOCOL
*
1989 DevPathFromTextUsbAudio (
1990 CHAR16
*TextDeviceNode
1993 USB_CLASS_TEXT UsbClassText
;
1995 UsbClassText
.ClassExist
= FALSE
;
1996 UsbClassText
.Class
= USB_CLASS_AUDIO
;
1997 UsbClassText
.SubClassExist
= TRUE
;
1999 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2003 Converts a text device path node to USB CDC Control device path structure.
2005 @param TextDeviceNode The input Text device path node.
2007 @return A pointer to the newly-created USB CDC Control device path structure.
2010 EFI_DEVICE_PATH_PROTOCOL
*
2011 DevPathFromTextUsbCDCControl (
2012 CHAR16
*TextDeviceNode
2015 USB_CLASS_TEXT UsbClassText
;
2017 UsbClassText
.ClassExist
= FALSE
;
2018 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
2019 UsbClassText
.SubClassExist
= TRUE
;
2021 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2025 Converts a text device path node to USB HID device path structure.
2027 @param TextDeviceNode The input Text device path node.
2029 @return A pointer to the newly-created USB HID device path structure.
2032 EFI_DEVICE_PATH_PROTOCOL
*
2033 DevPathFromTextUsbHID (
2034 CHAR16
*TextDeviceNode
2037 USB_CLASS_TEXT UsbClassText
;
2039 UsbClassText
.ClassExist
= FALSE
;
2040 UsbClassText
.Class
= USB_CLASS_HID
;
2041 UsbClassText
.SubClassExist
= TRUE
;
2043 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2047 Converts a text device path node to USB Image device path structure.
2049 @param TextDeviceNode The input Text device path node.
2051 @return A pointer to the newly-created USB Image device path structure.
2054 EFI_DEVICE_PATH_PROTOCOL
*
2055 DevPathFromTextUsbImage (
2056 CHAR16
*TextDeviceNode
2059 USB_CLASS_TEXT UsbClassText
;
2061 UsbClassText
.ClassExist
= FALSE
;
2062 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2063 UsbClassText
.SubClassExist
= TRUE
;
2065 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2069 Converts a text device path node to USB Print device path structure.
2071 @param TextDeviceNode The input Text device path node.
2073 @return A pointer to the newly-created USB Print device path structure.
2076 EFI_DEVICE_PATH_PROTOCOL
*
2077 DevPathFromTextUsbPrinter (
2078 CHAR16
*TextDeviceNode
2081 USB_CLASS_TEXT UsbClassText
;
2083 UsbClassText
.ClassExist
= FALSE
;
2084 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2085 UsbClassText
.SubClassExist
= TRUE
;
2087 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2091 Converts a text device path node to USB mass storage device path structure.
2093 @param TextDeviceNode The input Text device path node.
2095 @return A pointer to the newly-created USB mass storage device path structure.
2098 EFI_DEVICE_PATH_PROTOCOL
*
2099 DevPathFromTextUsbMassStorage (
2100 CHAR16
*TextDeviceNode
2103 USB_CLASS_TEXT UsbClassText
;
2105 UsbClassText
.ClassExist
= FALSE
;
2106 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2107 UsbClassText
.SubClassExist
= TRUE
;
2109 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2113 Converts a text device path node to USB HUB device path structure.
2115 @param TextDeviceNode The input Text device path node.
2117 @return A pointer to the newly-created USB HUB device path structure.
2120 EFI_DEVICE_PATH_PROTOCOL
*
2121 DevPathFromTextUsbHub (
2122 CHAR16
*TextDeviceNode
2125 USB_CLASS_TEXT UsbClassText
;
2127 UsbClassText
.ClassExist
= FALSE
;
2128 UsbClassText
.Class
= USB_CLASS_HUB
;
2129 UsbClassText
.SubClassExist
= TRUE
;
2131 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2135 Converts a text device path node to USB CDC data device path structure.
2137 @param TextDeviceNode The input Text device path node.
2139 @return A pointer to the newly-created USB CDC data device path structure.
2142 EFI_DEVICE_PATH_PROTOCOL
*
2143 DevPathFromTextUsbCDCData (
2144 CHAR16
*TextDeviceNode
2147 USB_CLASS_TEXT UsbClassText
;
2149 UsbClassText
.ClassExist
= FALSE
;
2150 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2151 UsbClassText
.SubClassExist
= TRUE
;
2153 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2157 Converts a text device path node to USB smart card device path structure.
2159 @param TextDeviceNode The input Text device path node.
2161 @return A pointer to the newly-created USB smart card device path structure.
2164 EFI_DEVICE_PATH_PROTOCOL
*
2165 DevPathFromTextUsbSmartCard (
2166 CHAR16
*TextDeviceNode
2169 USB_CLASS_TEXT UsbClassText
;
2171 UsbClassText
.ClassExist
= FALSE
;
2172 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2173 UsbClassText
.SubClassExist
= TRUE
;
2175 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2179 Converts a text device path node to USB video device path structure.
2181 @param TextDeviceNode The input Text device path node.
2183 @return A pointer to the newly-created USB video device path structure.
2186 EFI_DEVICE_PATH_PROTOCOL
*
2187 DevPathFromTextUsbVideo (
2188 CHAR16
*TextDeviceNode
2191 USB_CLASS_TEXT UsbClassText
;
2193 UsbClassText
.ClassExist
= FALSE
;
2194 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2195 UsbClassText
.SubClassExist
= TRUE
;
2197 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2201 Converts a text device path node to USB diagnostic device path structure.
2203 @param TextDeviceNode The input Text device path node.
2205 @return A pointer to the newly-created USB diagnostic device path structure.
2208 EFI_DEVICE_PATH_PROTOCOL
*
2209 DevPathFromTextUsbDiagnostic (
2210 CHAR16
*TextDeviceNode
2213 USB_CLASS_TEXT UsbClassText
;
2215 UsbClassText
.ClassExist
= FALSE
;
2216 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2217 UsbClassText
.SubClassExist
= TRUE
;
2219 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2223 Converts a text device path node to USB wireless device path structure.
2225 @param TextDeviceNode The input Text device path node.
2227 @return A pointer to the newly-created USB wireless device path structure.
2230 EFI_DEVICE_PATH_PROTOCOL
*
2231 DevPathFromTextUsbWireless (
2232 CHAR16
*TextDeviceNode
2235 USB_CLASS_TEXT UsbClassText
;
2237 UsbClassText
.ClassExist
= FALSE
;
2238 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2239 UsbClassText
.SubClassExist
= TRUE
;
2241 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2245 Converts a text device path node to USB device firmware update device path structure.
2247 @param TextDeviceNode The input Text device path node.
2249 @return A pointer to the newly-created USB device firmware update device path structure.
2252 EFI_DEVICE_PATH_PROTOCOL
*
2253 DevPathFromTextUsbDeviceFirmwareUpdate (
2254 CHAR16
*TextDeviceNode
2257 USB_CLASS_TEXT UsbClassText
;
2259 UsbClassText
.ClassExist
= FALSE
;
2260 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2261 UsbClassText
.SubClassExist
= FALSE
;
2262 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2264 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2268 Converts a text device path node to USB IRDA bridge device path structure.
2270 @param TextDeviceNode The input Text device path node.
2272 @return A pointer to the newly-created USB IRDA bridge device path structure.
2275 EFI_DEVICE_PATH_PROTOCOL
*
2276 DevPathFromTextUsbIrdaBridge (
2277 CHAR16
*TextDeviceNode
2280 USB_CLASS_TEXT UsbClassText
;
2282 UsbClassText
.ClassExist
= FALSE
;
2283 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2284 UsbClassText
.SubClassExist
= FALSE
;
2285 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2287 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2291 Converts a text device path node to USB text and measurement device path structure.
2293 @param TextDeviceNode The input Text device path node.
2295 @return A pointer to the newly-created USB text and measurement device path structure.
2298 EFI_DEVICE_PATH_PROTOCOL
*
2299 DevPathFromTextUsbTestAndMeasurement (
2300 CHAR16
*TextDeviceNode
2303 USB_CLASS_TEXT UsbClassText
;
2305 UsbClassText
.ClassExist
= FALSE
;
2306 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2307 UsbClassText
.SubClassExist
= FALSE
;
2308 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2310 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2314 Converts a text device path node to USB WWID device path structure.
2316 @param TextDeviceNode The input Text device path node.
2318 @return A pointer to the newly-created USB WWID device path structure.
2321 EFI_DEVICE_PATH_PROTOCOL
*
2322 DevPathFromTextUsbWwid (
2323 CHAR16
*TextDeviceNode
2328 CHAR16
*InterfaceNumStr
;
2329 CHAR16
*SerialNumberStr
;
2330 USB_WWID_DEVICE_PATH
*UsbWwid
;
2331 UINTN SerialNumberStrLen
;
2333 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2334 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2335 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2336 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2337 SerialNumberStrLen
= StrLen (SerialNumberStr
);
2338 if (SerialNumberStrLen
>= 2 &&
2339 SerialNumberStr
[0] == L
'\"' &&
2340 SerialNumberStr
[SerialNumberStrLen
- 1] == L
'\"'
2342 SerialNumberStr
[SerialNumberStrLen
- 1] = L
'\0';
2344 SerialNumberStrLen
-= 2;
2346 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2347 MESSAGING_DEVICE_PATH
,
2349 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + SerialNumberStrLen
* sizeof (CHAR16
))
2351 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2352 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2353 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2356 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
2357 // Therefore, the '\0' will not be copied.
2360 (UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
),
2362 SerialNumberStrLen
* sizeof (CHAR16
)
2365 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2369 Converts a text device path node to Logic Unit device path structure.
2371 @param TextDeviceNode The input Text device path node.
2373 @return A pointer to the newly-created Logic Unit device path structure.
2376 EFI_DEVICE_PATH_PROTOCOL
*
2377 DevPathFromTextUnit (
2378 CHAR16
*TextDeviceNode
2382 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2384 LunStr
= GetNextParamStr (&TextDeviceNode
);
2385 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2386 MESSAGING_DEVICE_PATH
,
2387 MSG_DEVICE_LOGICAL_UNIT_DP
,
2388 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2391 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2393 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2397 Converts a text device path node to iSCSI device path structure.
2399 @param TextDeviceNode The input Text device path node.
2401 @return A pointer to the newly-created iSCSI device path structure.
2404 EFI_DEVICE_PATH_PROTOCOL
*
2405 DevPathFromTextiSCSI (
2406 CHAR16
*TextDeviceNode
2411 CHAR16
*PortalGroupStr
;
2413 CHAR16
*HeaderDigestStr
;
2414 CHAR16
*DataDigestStr
;
2415 CHAR16
*AuthenticationStr
;
2416 CHAR16
*ProtocolStr
;
2418 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2421 NameStr
= GetNextParamStr (&TextDeviceNode
);
2422 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2423 LunStr
= GetNextParamStr (&TextDeviceNode
);
2424 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2425 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2426 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2427 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2428 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2429 MESSAGING_DEVICE_PATH
,
2431 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2434 AsciiStr
= ISCSIDevPath
->TargetName
;
2435 StrToAscii (NameStr
, &AsciiStr
);
2437 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2438 Strtoi64 (LunStr
, &Lun
);
2439 WriteUnaligned64 ((UINT64
*) &ISCSIDevPath
->Lun
, SwapBytes64 (Lun
));
2442 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2446 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2450 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2454 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2458 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2460 if (IS_NULL (*ProtocolStr
) || (StrCmp (ProtocolStr
, L
"TCP") == 0)) {
2461 ISCSIDevPath
->NetworkProtocol
= 0;
2464 // Undefined and reserved.
2466 ISCSIDevPath
->NetworkProtocol
= 1;
2469 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2473 Converts a text device path node to VLAN device path structure.
2475 @param TextDeviceNode The input Text device path node.
2477 @return A pointer to the newly-created VLAN device path structure.
2480 EFI_DEVICE_PATH_PROTOCOL
*
2481 DevPathFromTextVlan (
2482 CHAR16
*TextDeviceNode
2486 VLAN_DEVICE_PATH
*Vlan
;
2488 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2489 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2490 MESSAGING_DEVICE_PATH
,
2492 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2495 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2497 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2501 Converts a text device path node to Bluetooth device path structure.
2503 @param TextDeviceNode The input Text device path node.
2505 @return A pointer to the newly-created Bluetooth device path structure.
2508 EFI_DEVICE_PATH_PROTOCOL
*
2509 DevPathFromTextBluetooth (
2510 CHAR16
*TextDeviceNode
2513 CHAR16
*BluetoothStr
;
2514 BLUETOOTH_DEVICE_PATH
*BluetoothDp
;
2516 BluetoothStr
= GetNextParamStr (&TextDeviceNode
);
2517 BluetoothDp
= (BLUETOOTH_DEVICE_PATH
*) CreateDeviceNode (
2518 MESSAGING_DEVICE_PATH
,
2520 (UINT16
) sizeof (BLUETOOTH_DEVICE_PATH
)
2524 sizeof (BLUETOOTH_ADDRESS
) * 2,
2525 BluetoothDp
->BD_ADDR
.Address
,
2526 sizeof (BLUETOOTH_ADDRESS
)
2528 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothDp
;
2532 Converts a text device path node to Wi-Fi device path structure.
2534 @param TextDeviceNode The input Text device path node.
2536 @return A pointer to the newly-created Wi-Fi device path structure.
2539 EFI_DEVICE_PATH_PROTOCOL
*
2540 DevPathFromTextWiFi (
2541 CHAR16
*TextDeviceNode
2547 WIFI_DEVICE_PATH
*WiFiDp
;
2549 SSIdStr
= GetNextParamStr (&TextDeviceNode
);
2550 WiFiDp
= (WIFI_DEVICE_PATH
*) CreateDeviceNode (
2551 MESSAGING_DEVICE_PATH
,
2553 (UINT16
) sizeof (WIFI_DEVICE_PATH
)
2556 if (NULL
!= SSIdStr
) {
2557 DataLen
= StrLen (SSIdStr
);
2558 if (StrLen (SSIdStr
) > 32) {
2559 SSIdStr
[32] = L
'\0';
2563 UnicodeStrToAsciiStrS (SSIdStr
, AsciiStr
, sizeof (AsciiStr
));
2564 memcpy (WiFiDp
->SSId
, AsciiStr
, DataLen
);
2567 return (EFI_DEVICE_PATH_PROTOCOL
*) WiFiDp
;
2571 Converts a text device path node to Bluetooth LE device path structure.
2573 @param TextDeviceNode The input Text device path node.
2575 @return A pointer to the newly-created Bluetooth LE device path structure.
2578 EFI_DEVICE_PATH_PROTOCOL
*
2579 DevPathFromTextBluetoothLE (
2580 IN CHAR16
*TextDeviceNode
2583 CHAR16
*BluetoothLeAddrStr
;
2584 CHAR16
*BluetoothLeAddrTypeStr
;
2585 BLUETOOTH_LE_DEVICE_PATH
*BluetoothLeDp
;
2587 BluetoothLeAddrStr
= GetNextParamStr (&TextDeviceNode
);
2588 BluetoothLeAddrTypeStr
= GetNextParamStr (&TextDeviceNode
);
2589 BluetoothLeDp
= (BLUETOOTH_LE_DEVICE_PATH
*) CreateDeviceNode (
2590 MESSAGING_DEVICE_PATH
,
2591 MSG_BLUETOOTH_LE_DP
,
2592 (UINT16
) sizeof (BLUETOOTH_LE_DEVICE_PATH
)
2595 BluetoothLeDp
->Address
.Type
= (UINT8
) Strtoi (BluetoothLeAddrTypeStr
);
2597 BluetoothLeAddrStr
, sizeof (BluetoothLeDp
->Address
.Address
) * 2,
2598 BluetoothLeDp
->Address
.Address
, sizeof (BluetoothLeDp
->Address
.Address
)
2600 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothLeDp
;
2604 Converts a text device path node to DNS device path structure.
2606 @param TextDeviceNode The input Text device path node.
2608 @return A pointer to the newly-created DNS device path structure.
2611 EFI_DEVICE_PATH_PROTOCOL
*
2612 DevPathFromTextDns (
2613 IN CHAR16
*TextDeviceNode
2616 CHAR16
*DeviceNodeStr
;
2617 CHAR16
*DeviceNodeStrPtr
;
2618 UINT32 DnsServerIpCount
;
2619 UINT16 DnsDeviceNodeLength
;
2620 DNS_DEVICE_PATH
*DnsDeviceNode
;
2621 UINT32 DnsServerIpIndex
;
2622 CHAR16
*DnsServerIp
;
2626 // Count the DNS server address number.
2628 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
2629 if (DeviceNodeStr
== NULL
) {
2633 DeviceNodeStrPtr
= DeviceNodeStr
;
2635 DnsServerIpCount
= 0;
2636 while (DeviceNodeStrPtr
!= NULL
&& *DeviceNodeStrPtr
!= L
'\0') {
2637 GetNextParamStr (&DeviceNodeStrPtr
);
2638 DnsServerIpCount
++;
2641 free (DeviceNodeStr
);
2642 DeviceNodeStr
= NULL
;
2645 // One or more instances of the DNS server address in EFI_IP_ADDRESS,
2646 // otherwise, NULL will be returned.
2648 if (DnsServerIpCount
== 0) {
2653 // Create the DNS DeviceNode.
2655 DnsDeviceNodeLength
= (UINT16
) (sizeof (EFI_DEVICE_PATH_PROTOCOL
) + sizeof (UINT8
) + DnsServerIpCount
* sizeof (EFI_IP_ADDRESS
));
2656 DnsDeviceNode
= (DNS_DEVICE_PATH
*) CreateDeviceNode (
2657 MESSAGING_DEVICE_PATH
,
2661 if (DnsDeviceNode
== NULL
) {
2666 // Confirm the DNS server address is IPv4 or IPv6 type.
2668 DeviceNodeStrPtr
= TextDeviceNode
;
2669 while (!IS_NULL (*DeviceNodeStrPtr
)) {
2670 if (*DeviceNodeStrPtr
== L
'.') {
2671 DnsDeviceNode
->IsIPv6
= 0x00;
2675 if (*DeviceNodeStrPtr
== L
':') {
2676 DnsDeviceNode
->IsIPv6
= 0x01;
2683 for (DnsServerIpIndex
= 0; DnsServerIpIndex
< DnsServerIpCount
; DnsServerIpIndex
++) {
2684 DnsServerIp
= GetNextParamStr (&TextDeviceNode
);
2685 if (DnsDeviceNode
->IsIPv6
== 0x00) {
2686 StrToIpv4Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v4
), NULL
);
2688 StrToIpv6Address (DnsServerIp
, NULL
, &(DnsDeviceNode
->DnsServerIp
[DnsServerIpIndex
].v6
), NULL
);
2692 return (EFI_DEVICE_PATH_PROTOCOL
*) DnsDeviceNode
;
2696 Converts a text device path node to URI device path structure.
2698 @param TextDeviceNode The input Text device path node.
2700 @return A pointer to the newly-created URI device path structure.
2703 EFI_DEVICE_PATH_PROTOCOL
*
2704 DevPathFromTextUri (
2705 CHAR16
*TextDeviceNode
2710 URI_DEVICE_PATH
*Uri
;
2712 UriStr
= GetNextParamStr (&TextDeviceNode
);
2713 UriLength
= StrnLenS (UriStr
, MAX_UINT16
- sizeof (URI_DEVICE_PATH
));
2714 Uri
= (URI_DEVICE_PATH
*) CreateDeviceNode (
2715 MESSAGING_DEVICE_PATH
,
2717 (UINT16
) (sizeof (URI_DEVICE_PATH
) + UriLength
)
2720 while (UriLength
-- != 0) {
2721 Uri
->Uri
[UriLength
] = (CHAR8
) UriStr
[UriLength
];
2724 return (EFI_DEVICE_PATH_PROTOCOL
*) Uri
;
2728 Converts a media text device path node to media device path structure.
2730 @param TextDeviceNode The input Text device path node.
2732 @return A pointer to media device path structure.
2735 EFI_DEVICE_PATH_PROTOCOL
*
2736 DevPathFromTextMediaPath (
2737 CHAR16
*TextDeviceNode
2740 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH
, TextDeviceNode
);
2744 Converts a text device path node to HD device path structure.
2746 @param TextDeviceNode The input Text device path node.
2748 @return A pointer to the newly-created HD device path structure.
2751 EFI_DEVICE_PATH_PROTOCOL
*
2753 CHAR16
*TextDeviceNode
2756 CHAR16
*PartitionStr
;
2758 CHAR16
*SignatureStr
;
2762 HARDDRIVE_DEVICE_PATH
*Hd
;
2764 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2765 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2766 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2767 StartStr
= GetNextParamStr (&TextDeviceNode
);
2768 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2769 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2772 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2775 Hd
->PartitionNumber
= (UINT32
) Strtoi (PartitionStr
);
2777 ZeroMem (Hd
->Signature
, 16);
2778 Hd
->MBRType
= (UINT8
) 0;
2780 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2781 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2784 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2785 memcpy (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2786 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2787 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2790 StrToGuid (SignatureStr
, (EFI_GUID
*) Hd
->Signature
);
2792 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2795 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2796 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2798 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2802 Converts a text device path node to CDROM device path structure.
2804 @param TextDeviceNode The input Text device path node.
2806 @return A pointer to the newly-created CDROM device path structure.
2809 EFI_DEVICE_PATH_PROTOCOL
*
2810 DevPathFromTextCDROM (
2811 CHAR16
*TextDeviceNode
2817 CDROM_DEVICE_PATH
*CDROMDevPath
;
2819 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2820 StartStr
= GetNextParamStr (&TextDeviceNode
);
2821 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2822 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2825 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2828 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2829 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2830 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2832 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2836 Converts a text device path node to Vendor-defined media device path structure.
2838 @param TextDeviceNode The input Text device path node.
2840 @return A pointer to the newly-created Vendor-defined media device path structure.
2843 EFI_DEVICE_PATH_PROTOCOL
*
2844 DevPathFromTextVenMedia (
2845 CHAR16
*TextDeviceNode
2848 return ConvertFromTextVendor (
2856 Converts a text device path node to File device path structure.
2858 @param TextDeviceNode The input Text device path node.
2860 @return A pointer to the newly-created File device path structure.
2863 EFI_DEVICE_PATH_PROTOCOL
*
2864 DevPathFromTextFilePath (
2865 CHAR16
*TextDeviceNode
2868 FILEPATH_DEVICE_PATH
*File
;
2870 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2873 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
2876 StrCpyS (File
->PathName
, StrLen (TextDeviceNode
) + 1, TextDeviceNode
);
2878 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
2882 Converts a text device path node to Media protocol device path structure.
2884 @param TextDeviceNode The input Text device path node.
2886 @return A pointer to the newly-created Media protocol device path structure.
2889 EFI_DEVICE_PATH_PROTOCOL
*
2890 DevPathFromTextMedia (
2891 CHAR16
*TextDeviceNode
2895 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
2897 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2898 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
2901 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
2904 StrToGuid (GuidStr
, &Media
->Protocol
);
2906 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
2910 Converts a text device path node to firmware volume device path structure.
2912 @param TextDeviceNode The input Text device path node.
2914 @return A pointer to the newly-created firmware volume device path structure.
2917 EFI_DEVICE_PATH_PROTOCOL
*
2919 CHAR16
*TextDeviceNode
2923 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
2925 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2926 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
2928 MEDIA_PIWG_FW_VOL_DP
,
2929 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
2932 StrToGuid (GuidStr
, &Fv
->FvName
);
2934 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
2938 Converts a text device path node to firmware file device path structure.
2940 @param TextDeviceNode The input Text device path node.
2942 @return A pointer to the newly-created firmware file device path structure.
2945 EFI_DEVICE_PATH_PROTOCOL
*
2946 DevPathFromTextFvFile (
2947 CHAR16
*TextDeviceNode
2951 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
2953 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2954 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2956 MEDIA_PIWG_FW_FILE_DP
,
2957 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
2960 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
2962 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
2966 Converts a text device path node to text relative offset device path structure.
2968 @param TextDeviceNode The input Text device path node.
2970 @return A pointer to the newly-created Text device path structure.
2973 EFI_DEVICE_PATH_PROTOCOL
*
2974 DevPathFromTextRelativeOffsetRange (
2975 CHAR16
*TextDeviceNode
2978 CHAR16
*StartingOffsetStr
;
2979 CHAR16
*EndingOffsetStr
;
2980 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
2982 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2983 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2984 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
2986 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
2987 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
2990 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
2991 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
2993 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
2997 Converts a text device path node to text ram disk device path structure.
2999 @param TextDeviceNode The input Text device path node.
3001 @return A pointer to the newly-created Text device path structure.
3004 EFI_DEVICE_PATH_PROTOCOL
*
3005 DevPathFromTextRamDisk (
3006 CHAR16
*TextDeviceNode
3009 CHAR16
*StartingAddrStr
;
3010 CHAR16
*EndingAddrStr
;
3011 CHAR16
*TypeGuidStr
;
3012 CHAR16
*InstanceStr
;
3013 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3014 UINT64 StartingAddr
;
3017 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3018 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3019 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3020 TypeGuidStr
= GetNextParamStr (&TextDeviceNode
);
3021 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3024 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3027 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3028 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3029 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3030 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3031 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3032 StrToGuid (TypeGuidStr
, &RamDisk
->TypeGuid
);
3034 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3038 Converts a text device path node to text virtual disk device path structure.
3040 @param TextDeviceNode The input Text device path node.
3042 @return A pointer to the newly-created Text device path structure.
3045 EFI_DEVICE_PATH_PROTOCOL
*
3046 DevPathFromTextVirtualDisk (
3047 CHAR16
*TextDeviceNode
3050 CHAR16
*StartingAddrStr
;
3051 CHAR16
*EndingAddrStr
;
3052 CHAR16
*InstanceStr
;
3053 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3054 UINT64 StartingAddr
;
3057 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3058 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3059 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3061 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3064 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3067 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3068 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3069 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3070 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3071 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3072 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualDiskGuid
);
3074 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3078 Converts a text device path node to text virtual cd device path structure.
3080 @param TextDeviceNode The input Text device path node.
3082 @return A pointer to the newly-created Text device path structure.
3085 EFI_DEVICE_PATH_PROTOCOL
*
3086 DevPathFromTextVirtualCd (
3087 CHAR16
*TextDeviceNode
3090 CHAR16
*StartingAddrStr
;
3091 CHAR16
*EndingAddrStr
;
3092 CHAR16
*InstanceStr
;
3093 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3094 UINT64 StartingAddr
;
3097 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3098 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3099 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3101 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3104 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3107 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3108 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3109 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3110 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3111 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3112 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualCdGuid
);
3114 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3118 Converts a text device path node to text persistent virtual disk device path structure.
3120 @param TextDeviceNode The input Text device path node.
3122 @return A pointer to the newly-created Text device path structure.
3125 EFI_DEVICE_PATH_PROTOCOL
*
3126 DevPathFromTextPersistentVirtualDisk (
3127 CHAR16
*TextDeviceNode
3130 CHAR16
*StartingAddrStr
;
3131 CHAR16
*EndingAddrStr
;
3132 CHAR16
*InstanceStr
;
3133 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3134 UINT64 StartingAddr
;
3137 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3138 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3139 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3141 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3144 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3147 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3148 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3149 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3150 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3151 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3152 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualDiskGuid
);
3154 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3158 Converts a text device path node to text persistent virtual cd device path structure.
3160 @param TextDeviceNode The input Text device path node.
3162 @return A pointer to the newly-created Text device path structure.
3165 EFI_DEVICE_PATH_PROTOCOL
*
3166 DevPathFromTextPersistentVirtualCd (
3167 CHAR16
*TextDeviceNode
3170 CHAR16
*StartingAddrStr
;
3171 CHAR16
*EndingAddrStr
;
3172 CHAR16
*InstanceStr
;
3173 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3174 UINT64 StartingAddr
;
3177 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3178 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3179 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3181 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3184 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3187 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3188 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3189 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3190 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3191 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3192 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualCdGuid
);
3194 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3198 Converts a BBS text device path node to BBS device path structure.
3200 @param TextDeviceNode The input Text device path node.
3202 @return A pointer to BBS device path structure.
3205 EFI_DEVICE_PATH_PROTOCOL
*
3206 DevPathFromTextBbsPath (
3207 CHAR16
*TextDeviceNode
3210 return DevPathFromTextGenericPath (BBS_DEVICE_PATH
, TextDeviceNode
);
3214 Converts a text device path node to BIOS Boot Specification device path structure.
3216 @param TextDeviceNode The input Text device path node.
3218 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3221 EFI_DEVICE_PATH_PROTOCOL
*
3222 DevPathFromTextBBS (
3223 CHAR16
*TextDeviceNode
3230 BBS_BBS_DEVICE_PATH
*Bbs
;
3232 TypeStr
= GetNextParamStr (&TextDeviceNode
);
3233 IdStr
= GetNextParamStr (&TextDeviceNode
);
3234 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
3235 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
3238 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
3241 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
3242 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
3243 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
3244 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
3245 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
3246 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
3247 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
3248 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
3249 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
3250 Bbs
->DeviceType
= BBS_TYPE_USB
;
3251 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
3252 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
3254 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
3257 AsciiStr
= Bbs
->String
;
3258 StrToAscii (IdStr
, &AsciiStr
);
3260 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
3262 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
3266 Converts a text device path node to SATA device path structure.
3268 @param TextDeviceNode The input Text device path node.
3270 @return A pointer to the newly-created SATA device path structure.
3273 EFI_DEVICE_PATH_PROTOCOL
*
3274 DevPathFromTextSata (
3275 CHAR16
*TextDeviceNode
3278 SATA_DEVICE_PATH
*Sata
;
3283 Param1
= GetNextParamStr (&TextDeviceNode
);
3284 Param2
= GetNextParamStr (&TextDeviceNode
);
3285 Param3
= GetNextParamStr (&TextDeviceNode
);
3287 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
3288 MESSAGING_DEVICE_PATH
,
3290 (UINT16
) sizeof (SATA_DEVICE_PATH
)
3292 Sata
->HBAPortNumber
= (UINT16
) Strtoi (Param1
);
3295 // According to UEFI spec, if PMPN is not provided, the default is 0xFFFF
3297 if (*Param2
== L
'\0' ) {
3298 Sata
->PortMultiplierPortNumber
= 0xFFFF;
3300 Sata
->PortMultiplierPortNumber
= (UINT16
) Strtoi (Param2
);
3302 Sata
->Lun
= (UINT16
) Strtoi (Param3
);
3304 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
3307 DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
3308 {L
"Path", DevPathFromTextPath
},
3310 {L
"HardwarePath", DevPathFromTextHardwarePath
},
3311 {L
"Pci", DevPathFromTextPci
},
3312 {L
"PcCard", DevPathFromTextPcCard
},
3313 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
3314 {L
"VenHw", DevPathFromTextVenHw
},
3315 {L
"Ctrl", DevPathFromTextCtrl
},
3316 {L
"BMC", DevPathFromTextBmc
},
3318 {L
"AcpiPath", DevPathFromTextAcpiPath
},
3319 {L
"Acpi", DevPathFromTextAcpi
},
3320 {L
"PciRoot", DevPathFromTextPciRoot
},
3321 {L
"PcieRoot", DevPathFromTextPcieRoot
},
3322 {L
"Floppy", DevPathFromTextFloppy
},
3323 {L
"Keyboard", DevPathFromTextKeyboard
},
3324 {L
"Serial", DevPathFromTextSerial
},
3325 {L
"ParallelPort", DevPathFromTextParallelPort
},
3326 {L
"AcpiEx", DevPathFromTextAcpiEx
},
3327 {L
"AcpiExp", DevPathFromTextAcpiExp
},
3328 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
3330 {L
"Msg", DevPathFromTextMsg
},
3331 {L
"Ata", DevPathFromTextAta
},
3332 {L
"Scsi", DevPathFromTextScsi
},
3333 {L
"Fibre", DevPathFromTextFibre
},
3334 {L
"FibreEx", DevPathFromTextFibreEx
},
3335 {L
"I1394", DevPathFromText1394
},
3336 {L
"USB", DevPathFromTextUsb
},
3337 {L
"I2O", DevPathFromTextI2O
},
3338 {L
"Infiniband", DevPathFromTextInfiniband
},
3339 {L
"VenMsg", DevPathFromTextVenMsg
},
3340 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
3341 {L
"VenVt100", DevPathFromTextVenVt100
},
3342 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
3343 {L
"VenUtf8", DevPathFromTextVenUtf8
},
3344 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
3345 {L
"SAS", DevPathFromTextSAS
},
3346 {L
"SasEx", DevPathFromTextSasEx
},
3347 {L
"NVMe", DevPathFromTextNVMe
},
3348 {L
"UFS", DevPathFromTextUfs
},
3349 {L
"SD", DevPathFromTextSd
},
3350 {L
"eMMC", DevPathFromTextEmmc
},
3351 {L
"DebugPort", DevPathFromTextDebugPort
},
3352 {L
"MAC", DevPathFromTextMAC
},
3353 {L
"IPv4", DevPathFromTextIPv4
},
3354 {L
"IPv6", DevPathFromTextIPv6
},
3355 {L
"Uart", DevPathFromTextUart
},
3356 {L
"UsbClass", DevPathFromTextUsbClass
},
3357 {L
"UsbAudio", DevPathFromTextUsbAudio
},
3358 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
3359 {L
"UsbHID", DevPathFromTextUsbHID
},
3360 {L
"UsbImage", DevPathFromTextUsbImage
},
3361 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
3362 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
3363 {L
"UsbHub", DevPathFromTextUsbHub
},
3364 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
3365 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
3366 {L
"UsbVideo", DevPathFromTextUsbVideo
},
3367 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
3368 {L
"UsbWireless", DevPathFromTextUsbWireless
},
3369 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
3370 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
3371 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
3372 {L
"UsbWwid", DevPathFromTextUsbWwid
},
3373 {L
"Unit", DevPathFromTextUnit
},
3374 {L
"iSCSI", DevPathFromTextiSCSI
},
3375 {L
"Vlan", DevPathFromTextVlan
},
3376 {L
"Dns", DevPathFromTextDns
},
3377 {L
"Uri", DevPathFromTextUri
},
3378 {L
"Bluetooth", DevPathFromTextBluetooth
},
3379 {L
"Wi-Fi", DevPathFromTextWiFi
},
3380 {L
"BluetoothLE", DevPathFromTextBluetoothLE
},
3381 {L
"MediaPath", DevPathFromTextMediaPath
},
3382 {L
"HD", DevPathFromTextHD
},
3383 {L
"CDROM", DevPathFromTextCDROM
},
3384 {L
"VenMedia", DevPathFromTextVenMedia
},
3385 {L
"Media", DevPathFromTextMedia
},
3386 {L
"Fv", DevPathFromTextFv
},
3387 {L
"FvFile", DevPathFromTextFvFile
},
3388 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
3389 {L
"RamDisk", DevPathFromTextRamDisk
},
3390 {L
"VirtualDisk", DevPathFromTextVirtualDisk
},
3391 {L
"VirtualCD", DevPathFromTextVirtualCd
},
3392 {L
"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk
},
3393 {L
"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd
},
3395 {L
"BbsPath", DevPathFromTextBbsPath
},
3396 {L
"BBS", DevPathFromTextBBS
},
3397 {L
"Sata", DevPathFromTextSata
},
3402 Convert text to the binary representation of a device node.
3404 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3405 node. Conversion starts with the first character and continues
3406 until the first non-device node character.
3408 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3409 insufficient memory or text unsupported.
3412 EFI_DEVICE_PATH_PROTOCOL
*
3413 UefiDevicePathLibConvertTextToDeviceNode (
3414 CONST CHAR16
*TextDeviceNode
3417 DEVICE_PATH_FROM_TEXT FromText
;
3419 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3420 CHAR16
*DeviceNodeStr
;
3423 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
3429 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
3430 ASSERT (DeviceNodeStr
!= NULL
);
3432 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3433 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
3434 if (ParamStr
!= NULL
) {
3435 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
3440 if (FromText
== NULL
) {
3444 FromText
= DevPathFromTextFilePath
;
3445 DeviceNode
= FromText (DeviceNodeStr
);
3447 // According to above logic, if 'FromText' is NULL in the 'if' statement,
3448 // then 'ParamStr' must be NULL as well. No memory allocation has been made
3451 // The below check is for addressing a false positive potential memory leak
3452 // issue raised from static analysis.
3454 if (ParamStr
!= NULL
) {
3458 DeviceNode
= FromText (ParamStr
);
3462 free (DeviceNodeStr
);
3468 Convert text to the binary representation of a device path.
3471 @param TextDevicePath TextDevicePath points to the text representation of a device
3472 path. Conversion starts with the first character and continues
3473 until the first non-device node character.
3475 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3476 there was insufficient memory.
3479 EFI_DEVICE_PATH_PROTOCOL
*
3480 UefiDevicePathLibConvertTextToDevicePath (
3481 CONST CHAR16
*TextDevicePath
3484 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3485 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3486 CHAR16
*DevicePathStr
;
3488 CHAR16
*DeviceNodeStr
;
3489 BOOLEAN IsInstanceEnd
;
3490 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3492 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3496 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3497 ASSERT (DevicePath
!= NULL
);
3498 SetDevicePathEndNode (DevicePath
);
3500 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3502 Str
= DevicePathStr
;
3503 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3504 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3506 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3509 DevicePath
= NewDevicePath
;
3511 if (IsInstanceEnd
) {
3512 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3513 ASSERT (DeviceNode
!= NULL
);
3514 SetDevicePathEndNode (DeviceNode
);
3515 DeviceNode
->SubType
= END_INSTANCE_DEVICE_PATH_SUBTYPE
;
3517 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3520 DevicePath
= NewDevicePath
;
3524 free (DevicePathStr
);