2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
4 Copyright (c) 2017, 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
;
2391 NameStr
= GetNextParamStr (&TextDeviceNode
);
2392 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2393 LunStr
= GetNextParamStr (&TextDeviceNode
);
2394 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2395 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2396 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2397 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2398 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2399 MESSAGING_DEVICE_PATH
,
2401 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2404 AsciiStr
= ISCSIDevPath
->TargetName
;
2405 StrToAscii (NameStr
, &AsciiStr
);
2407 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2408 Strtoi64 (LunStr
, &ISCSIDevPath
->Lun
);
2411 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2415 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2419 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2423 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2427 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2429 if (StrCmp (ProtocolStr
, L
"TCP") == 0) {
2430 ISCSIDevPath
->NetworkProtocol
= 0;
2433 // Undefined and reserved.
2435 ISCSIDevPath
->NetworkProtocol
= 1;
2438 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2442 Converts a text device path node to VLAN device path structure.
2444 @param TextDeviceNode The input Text device path node.
2446 @return A pointer to the newly-created VLAN device path structure.
2449 EFI_DEVICE_PATH_PROTOCOL
*
2450 DevPathFromTextVlan (
2451 CHAR16
*TextDeviceNode
2455 VLAN_DEVICE_PATH
*Vlan
;
2457 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2458 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2459 MESSAGING_DEVICE_PATH
,
2461 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2464 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2466 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2470 Converts a text device path node to Bluetooth device path structure.
2472 @param TextDeviceNode The input Text device path node.
2474 @return A pointer to the newly-created Bluetooth device path structure.
2477 EFI_DEVICE_PATH_PROTOCOL
*
2478 DevPathFromTextBluetooth (
2479 CHAR16
*TextDeviceNode
2482 CHAR16
*BluetoothStr
;
2483 BLUETOOTH_DEVICE_PATH
*BluetoothDp
;
2485 BluetoothStr
= GetNextParamStr (&TextDeviceNode
);
2486 BluetoothDp
= (BLUETOOTH_DEVICE_PATH
*) CreateDeviceNode (
2487 MESSAGING_DEVICE_PATH
,
2489 (UINT16
) sizeof (BLUETOOTH_DEVICE_PATH
)
2493 sizeof (BLUETOOTH_ADDRESS
) * 2,
2494 BluetoothDp
->BD_ADDR
.Address
,
2495 sizeof (BLUETOOTH_ADDRESS
)
2497 return (EFI_DEVICE_PATH_PROTOCOL
*) BluetoothDp
;
2501 Converts a text device path node to Wi-Fi device path structure.
2503 @param TextDeviceNode The input Text device path node.
2505 @return A pointer to the newly-created Wi-Fi device path structure.
2508 EFI_DEVICE_PATH_PROTOCOL
*
2509 DevPathFromTextWiFi (
2510 CHAR16
*TextDeviceNode
2516 WIFI_DEVICE_PATH
*WiFiDp
;
2518 SSIdStr
= GetNextParamStr (&TextDeviceNode
);
2519 WiFiDp
= (WIFI_DEVICE_PATH
*) CreateDeviceNode (
2520 MESSAGING_DEVICE_PATH
,
2522 (UINT16
) sizeof (WIFI_DEVICE_PATH
)
2525 if (NULL
!= SSIdStr
) {
2526 DataLen
= StrLen (SSIdStr
);
2527 if (StrLen (SSIdStr
) > 32) {
2528 SSIdStr
[32] = L
'\0';
2532 UnicodeStrToAsciiStrS (SSIdStr
, AsciiStr
, sizeof (AsciiStr
));
2533 memcpy (WiFiDp
->SSId
, AsciiStr
, DataLen
);
2536 return (EFI_DEVICE_PATH_PROTOCOL
*) WiFiDp
;
2540 Converts a text device path node to URI device path structure.
2542 @param TextDeviceNode The input Text device path node.
2544 @return A pointer to the newly-created URI device path structure.
2547 EFI_DEVICE_PATH_PROTOCOL
*
2548 DevPathFromTextUri (
2549 CHAR16
*TextDeviceNode
2554 URI_DEVICE_PATH
*Uri
;
2556 UriStr
= GetNextParamStr (&TextDeviceNode
);
2557 UriLength
= StrnLenS (UriStr
, MAX_UINT16
- sizeof (URI_DEVICE_PATH
));
2558 Uri
= (URI_DEVICE_PATH
*) CreateDeviceNode (
2559 MESSAGING_DEVICE_PATH
,
2561 (UINT16
) (sizeof (URI_DEVICE_PATH
) + UriLength
)
2564 while (UriLength
-- != 0) {
2565 Uri
->Uri
[UriLength
] = (CHAR8
) UriStr
[UriLength
];
2568 return (EFI_DEVICE_PATH_PROTOCOL
*) Uri
;
2572 Converts a media text device path node to media device path structure.
2574 @param TextDeviceNode The input Text device path node.
2576 @return A pointer to media device path structure.
2579 EFI_DEVICE_PATH_PROTOCOL
*
2580 DevPathFromTextMediaPath (
2581 CHAR16
*TextDeviceNode
2584 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH
, TextDeviceNode
);
2588 Converts a text device path node to HD device path structure.
2590 @param TextDeviceNode The input Text device path node.
2592 @return A pointer to the newly-created HD device path structure.
2595 EFI_DEVICE_PATH_PROTOCOL
*
2597 CHAR16
*TextDeviceNode
2600 CHAR16
*PartitionStr
;
2602 CHAR16
*SignatureStr
;
2606 HARDDRIVE_DEVICE_PATH
*Hd
;
2608 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2609 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2610 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2611 StartStr
= GetNextParamStr (&TextDeviceNode
);
2612 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2613 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2616 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2619 Hd
->PartitionNumber
= (UINT32
) Strtoi (PartitionStr
);
2621 ZeroMem (Hd
->Signature
, 16);
2622 Hd
->MBRType
= (UINT8
) 0;
2624 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2625 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2628 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2629 memcpy (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2630 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2631 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2634 StrToGuid (SignatureStr
, (EFI_GUID
*) Hd
->Signature
);
2636 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2639 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2640 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2642 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2646 Converts a text device path node to CDROM device path structure.
2648 @param TextDeviceNode The input Text device path node.
2650 @return A pointer to the newly-created CDROM device path structure.
2653 EFI_DEVICE_PATH_PROTOCOL
*
2654 DevPathFromTextCDROM (
2655 CHAR16
*TextDeviceNode
2661 CDROM_DEVICE_PATH
*CDROMDevPath
;
2663 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2664 StartStr
= GetNextParamStr (&TextDeviceNode
);
2665 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2666 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2669 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2672 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2673 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2674 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2676 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2680 Converts a text device path node to Vendor-defined media device path structure.
2682 @param TextDeviceNode The input Text device path node.
2684 @return A pointer to the newly-created Vendor-defined media device path structure.
2687 EFI_DEVICE_PATH_PROTOCOL
*
2688 DevPathFromTextVenMedia (
2689 CHAR16
*TextDeviceNode
2692 return ConvertFromTextVendor (
2700 Converts a text device path node to File device path structure.
2702 @param TextDeviceNode The input Text device path node.
2704 @return A pointer to the newly-created File device path structure.
2707 EFI_DEVICE_PATH_PROTOCOL
*
2708 DevPathFromTextFilePath (
2709 CHAR16
*TextDeviceNode
2712 FILEPATH_DEVICE_PATH
*File
;
2714 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2717 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
2720 StrCpyS (File
->PathName
, StrLen (TextDeviceNode
) + 1, TextDeviceNode
);
2722 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
2726 Converts a text device path node to Media protocol device path structure.
2728 @param TextDeviceNode The input Text device path node.
2730 @return A pointer to the newly-created Media protocol device path structure.
2733 EFI_DEVICE_PATH_PROTOCOL
*
2734 DevPathFromTextMedia (
2735 CHAR16
*TextDeviceNode
2739 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
2741 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2742 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
2745 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
2748 StrToGuid (GuidStr
, &Media
->Protocol
);
2750 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
2754 Converts a text device path node to firmware volume device path structure.
2756 @param TextDeviceNode The input Text device path node.
2758 @return A pointer to the newly-created firmware volume device path structure.
2761 EFI_DEVICE_PATH_PROTOCOL
*
2763 CHAR16
*TextDeviceNode
2767 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
2769 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2770 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
2772 MEDIA_PIWG_FW_VOL_DP
,
2773 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
2776 StrToGuid (GuidStr
, &Fv
->FvName
);
2778 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
2782 Converts a text device path node to firmware file device path structure.
2784 @param TextDeviceNode The input Text device path node.
2786 @return A pointer to the newly-created firmware file device path structure.
2789 EFI_DEVICE_PATH_PROTOCOL
*
2790 DevPathFromTextFvFile (
2791 CHAR16
*TextDeviceNode
2795 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
2797 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2798 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2800 MEDIA_PIWG_FW_FILE_DP
,
2801 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
2804 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
2806 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
2810 Converts a text device path node to text relative offset device path structure.
2812 @param TextDeviceNode The input Text device path node.
2814 @return A pointer to the newly-created Text device path structure.
2817 EFI_DEVICE_PATH_PROTOCOL
*
2818 DevPathFromTextRelativeOffsetRange (
2819 CHAR16
*TextDeviceNode
2822 CHAR16
*StartingOffsetStr
;
2823 CHAR16
*EndingOffsetStr
;
2824 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
2826 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2827 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2828 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
2830 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
2831 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
2834 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
2835 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
2837 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
2841 Converts a text device path node to text ram disk device path structure.
2843 @param TextDeviceNode The input Text device path node.
2845 @return A pointer to the newly-created Text device path structure.
2848 EFI_DEVICE_PATH_PROTOCOL
*
2849 DevPathFromTextRamDisk (
2850 CHAR16
*TextDeviceNode
2853 CHAR16
*StartingAddrStr
;
2854 CHAR16
*EndingAddrStr
;
2855 CHAR16
*TypeGuidStr
;
2856 CHAR16
*InstanceStr
;
2857 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
2858 UINT64 StartingAddr
;
2861 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
2862 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
2863 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
2864 TypeGuidStr
= GetNextParamStr (&TextDeviceNode
);
2865 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
2868 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
2871 Strtoi64 (StartingAddrStr
, &StartingAddr
);
2872 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
2873 Strtoi64 (EndingAddrStr
, &EndingAddr
);
2874 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
2875 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
2876 StrToGuid (TypeGuidStr
, &RamDisk
->TypeGuid
);
2878 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
2882 Converts a text device path node to text virtual disk device path structure.
2884 @param TextDeviceNode The input Text device path node.
2886 @return A pointer to the newly-created Text device path structure.
2889 EFI_DEVICE_PATH_PROTOCOL
*
2890 DevPathFromTextVirtualDisk (
2891 CHAR16
*TextDeviceNode
2894 CHAR16
*StartingAddrStr
;
2895 CHAR16
*EndingAddrStr
;
2896 CHAR16
*InstanceStr
;
2897 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
2898 UINT64 StartingAddr
;
2901 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
2902 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
2903 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
2905 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
2908 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
2911 Strtoi64 (StartingAddrStr
, &StartingAddr
);
2912 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
2913 Strtoi64 (EndingAddrStr
, &EndingAddr
);
2914 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
2915 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
2916 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualDiskGuid
);
2918 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
2922 Converts a text device path node to text virtual cd device path structure.
2924 @param TextDeviceNode The input Text device path node.
2926 @return A pointer to the newly-created Text device path structure.
2929 EFI_DEVICE_PATH_PROTOCOL
*
2930 DevPathFromTextVirtualCd (
2931 CHAR16
*TextDeviceNode
2934 CHAR16
*StartingAddrStr
;
2935 CHAR16
*EndingAddrStr
;
2936 CHAR16
*InstanceStr
;
2937 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
2938 UINT64 StartingAddr
;
2941 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
2942 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
2943 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
2945 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
2948 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
2951 Strtoi64 (StartingAddrStr
, &StartingAddr
);
2952 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
2953 Strtoi64 (EndingAddrStr
, &EndingAddr
);
2954 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
2955 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
2956 CopyGuid (&RamDisk
->TypeGuid
, &gEfiVirtualCdGuid
);
2958 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
2962 Converts a text device path node to text persistent virtual disk device path structure.
2964 @param TextDeviceNode The input Text device path node.
2966 @return A pointer to the newly-created Text device path structure.
2969 EFI_DEVICE_PATH_PROTOCOL
*
2970 DevPathFromTextPersistentVirtualDisk (
2971 CHAR16
*TextDeviceNode
2974 CHAR16
*StartingAddrStr
;
2975 CHAR16
*EndingAddrStr
;
2976 CHAR16
*InstanceStr
;
2977 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
2978 UINT64 StartingAddr
;
2981 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
2982 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
2983 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
2985 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
2988 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
2991 Strtoi64 (StartingAddrStr
, &StartingAddr
);
2992 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
2993 Strtoi64 (EndingAddrStr
, &EndingAddr
);
2994 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
2995 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
2996 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualDiskGuid
);
2998 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3002 Converts a text device path node to text persistent virtual cd device path structure.
3004 @param TextDeviceNode The input Text device path node.
3006 @return A pointer to the newly-created Text device path structure.
3009 EFI_DEVICE_PATH_PROTOCOL
*
3010 DevPathFromTextPersistentVirtualCd (
3011 CHAR16
*TextDeviceNode
3014 CHAR16
*StartingAddrStr
;
3015 CHAR16
*EndingAddrStr
;
3016 CHAR16
*InstanceStr
;
3017 MEDIA_RAM_DISK_DEVICE_PATH
*RamDisk
;
3018 UINT64 StartingAddr
;
3021 StartingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3022 EndingAddrStr
= GetNextParamStr (&TextDeviceNode
);
3023 InstanceStr
= GetNextParamStr (&TextDeviceNode
);
3025 RamDisk
= (MEDIA_RAM_DISK_DEVICE_PATH
*) CreateDeviceNode (
3028 (UINT16
) sizeof (MEDIA_RAM_DISK_DEVICE_PATH
)
3031 Strtoi64 (StartingAddrStr
, &StartingAddr
);
3032 WriteUnaligned64 ((UINT64
*) &(RamDisk
->StartingAddr
[0]), StartingAddr
);
3033 Strtoi64 (EndingAddrStr
, &EndingAddr
);
3034 WriteUnaligned64 ((UINT64
*) &(RamDisk
->EndingAddr
[0]), EndingAddr
);
3035 RamDisk
->Instance
= (UINT16
) Strtoi (InstanceStr
);
3036 CopyGuid (&RamDisk
->TypeGuid
, &gEfiPersistentVirtualCdGuid
);
3038 return (EFI_DEVICE_PATH_PROTOCOL
*) RamDisk
;
3042 Converts a BBS text device path node to BBS device path structure.
3044 @param TextDeviceNode The input Text device path node.
3046 @return A pointer to BBS device path structure.
3049 EFI_DEVICE_PATH_PROTOCOL
*
3050 DevPathFromTextBbsPath (
3051 CHAR16
*TextDeviceNode
3054 return DevPathFromTextGenericPath (BBS_DEVICE_PATH
, TextDeviceNode
);
3058 Converts a text device path node to BIOS Boot Specification device path structure.
3060 @param TextDeviceNode The input Text device path node.
3062 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3065 EFI_DEVICE_PATH_PROTOCOL
*
3066 DevPathFromTextBBS (
3067 CHAR16
*TextDeviceNode
3074 BBS_BBS_DEVICE_PATH
*Bbs
;
3076 TypeStr
= GetNextParamStr (&TextDeviceNode
);
3077 IdStr
= GetNextParamStr (&TextDeviceNode
);
3078 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
3079 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
3082 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
3085 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
3086 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
3087 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
3088 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
3089 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
3090 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
3091 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
3092 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
3093 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
3094 Bbs
->DeviceType
= BBS_TYPE_USB
;
3095 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
3096 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
3098 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
3101 AsciiStr
= Bbs
->String
;
3102 StrToAscii (IdStr
, &AsciiStr
);
3104 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
3106 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
3110 Converts a text device path node to SATA device path structure.
3112 @param TextDeviceNode The input Text device path node.
3114 @return A pointer to the newly-created SATA device path structure.
3117 EFI_DEVICE_PATH_PROTOCOL
*
3118 DevPathFromTextSata (
3119 CHAR16
*TextDeviceNode
3122 SATA_DEVICE_PATH
*Sata
;
3127 Param1
= GetNextParamStr (&TextDeviceNode
);
3128 Param2
= GetNextParamStr (&TextDeviceNode
);
3129 Param3
= GetNextParamStr (&TextDeviceNode
);
3131 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
3132 MESSAGING_DEVICE_PATH
,
3134 (UINT16
) sizeof (SATA_DEVICE_PATH
)
3136 Sata
->HBAPortNumber
= (UINT16
) Strtoi (Param1
);
3137 Sata
->PortMultiplierPortNumber
= (UINT16
) Strtoi (Param2
);
3138 Sata
->Lun
= (UINT16
) Strtoi (Param3
);
3140 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
3143 DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
3144 {L
"Path", DevPathFromTextPath
},
3146 {L
"HardwarePath", DevPathFromTextHardwarePath
},
3147 {L
"Pci", DevPathFromTextPci
},
3148 {L
"PcCard", DevPathFromTextPcCard
},
3149 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
3150 {L
"VenHw", DevPathFromTextVenHw
},
3151 {L
"Ctrl", DevPathFromTextCtrl
},
3152 {L
"BMC", DevPathFromTextBmc
},
3154 {L
"AcpiPath", DevPathFromTextAcpiPath
},
3155 {L
"Acpi", DevPathFromTextAcpi
},
3156 {L
"PciRoot", DevPathFromTextPciRoot
},
3157 {L
"PcieRoot", DevPathFromTextPcieRoot
},
3158 {L
"Floppy", DevPathFromTextFloppy
},
3159 {L
"Keyboard", DevPathFromTextKeyboard
},
3160 {L
"Serial", DevPathFromTextSerial
},
3161 {L
"ParallelPort", DevPathFromTextParallelPort
},
3162 {L
"AcpiEx", DevPathFromTextAcpiEx
},
3163 {L
"AcpiExp", DevPathFromTextAcpiExp
},
3164 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
3166 {L
"Msg", DevPathFromTextMsg
},
3167 {L
"Ata", DevPathFromTextAta
},
3168 {L
"Scsi", DevPathFromTextScsi
},
3169 {L
"Fibre", DevPathFromTextFibre
},
3170 {L
"FibreEx", DevPathFromTextFibreEx
},
3171 {L
"I1394", DevPathFromText1394
},
3172 {L
"USB", DevPathFromTextUsb
},
3173 {L
"I2O", DevPathFromTextI2O
},
3174 {L
"Infiniband", DevPathFromTextInfiniband
},
3175 {L
"VenMsg", DevPathFromTextVenMsg
},
3176 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
3177 {L
"VenVt100", DevPathFromTextVenVt100
},
3178 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
3179 {L
"VenUtf8", DevPathFromTextVenUtf8
},
3180 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
3181 {L
"SAS", DevPathFromTextSAS
},
3182 {L
"SasEx", DevPathFromTextSasEx
},
3183 {L
"NVMe", DevPathFromTextNVMe
},
3184 {L
"UFS", DevPathFromTextUfs
},
3185 {L
"SD", DevPathFromTextSd
},
3186 {L
"eMMC", DevPathFromTextEmmc
},
3187 {L
"DebugPort", DevPathFromTextDebugPort
},
3188 {L
"MAC", DevPathFromTextMAC
},
3189 {L
"IPv4", DevPathFromTextIPv4
},
3190 {L
"IPv6", DevPathFromTextIPv6
},
3191 {L
"Uart", DevPathFromTextUart
},
3192 {L
"UsbClass", DevPathFromTextUsbClass
},
3193 {L
"UsbAudio", DevPathFromTextUsbAudio
},
3194 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
3195 {L
"UsbHID", DevPathFromTextUsbHID
},
3196 {L
"UsbImage", DevPathFromTextUsbImage
},
3197 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
3198 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
3199 {L
"UsbHub", DevPathFromTextUsbHub
},
3200 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
3201 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
3202 {L
"UsbVideo", DevPathFromTextUsbVideo
},
3203 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
3204 {L
"UsbWireless", DevPathFromTextUsbWireless
},
3205 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
3206 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
3207 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
3208 {L
"UsbWwid", DevPathFromTextUsbWwid
},
3209 {L
"Unit", DevPathFromTextUnit
},
3210 {L
"iSCSI", DevPathFromTextiSCSI
},
3211 {L
"Vlan", DevPathFromTextVlan
},
3212 {L
"Uri", DevPathFromTextUri
},
3213 {L
"Bluetooth", DevPathFromTextBluetooth
},
3214 {L
"Wi-Fi", DevPathFromTextWiFi
},
3215 {L
"MediaPath", DevPathFromTextMediaPath
},
3216 {L
"HD", DevPathFromTextHD
},
3217 {L
"CDROM", DevPathFromTextCDROM
},
3218 {L
"VenMedia", DevPathFromTextVenMedia
},
3219 {L
"Media", DevPathFromTextMedia
},
3220 {L
"Fv", DevPathFromTextFv
},
3221 {L
"FvFile", DevPathFromTextFvFile
},
3222 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
3223 {L
"RamDisk", DevPathFromTextRamDisk
},
3224 {L
"VirtualDisk", DevPathFromTextVirtualDisk
},
3225 {L
"VirtualCD", DevPathFromTextVirtualCd
},
3226 {L
"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk
},
3227 {L
"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd
},
3229 {L
"BbsPath", DevPathFromTextBbsPath
},
3230 {L
"BBS", DevPathFromTextBBS
},
3231 {L
"Sata", DevPathFromTextSata
},
3236 Convert text to the binary representation of a device node.
3238 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3239 node. Conversion starts with the first character and continues
3240 until the first non-device node character.
3242 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3243 insufficient memory or text unsupported.
3246 EFI_DEVICE_PATH_PROTOCOL
*
3247 UefiDevicePathLibConvertTextToDeviceNode (
3248 CONST CHAR16
*TextDeviceNode
3251 DEVICE_PATH_FROM_TEXT FromText
;
3253 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3254 CHAR16
*DeviceNodeStr
;
3257 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
3263 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
3264 ASSERT (DeviceNodeStr
!= NULL
);
3266 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3267 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
3268 if (ParamStr
!= NULL
) {
3269 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
3274 if (FromText
== NULL
) {
3278 FromText
= DevPathFromTextFilePath
;
3279 DeviceNode
= FromText (DeviceNodeStr
);
3281 DeviceNode
= FromText (ParamStr
);
3285 free (DeviceNodeStr
);
3291 Convert text to the binary representation of a device path.
3294 @param TextDevicePath TextDevicePath points to the text representation of a device
3295 path. Conversion starts with the first character and continues
3296 until the first non-device node character.
3298 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3299 there was insufficient memory.
3302 EFI_DEVICE_PATH_PROTOCOL
*
3303 UefiDevicePathLibConvertTextToDevicePath (
3304 CONST CHAR16
*TextDevicePath
3307 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3308 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3309 CHAR16
*DevicePathStr
;
3311 CHAR16
*DeviceNodeStr
;
3312 BOOLEAN IsInstanceEnd
;
3313 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3315 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3319 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3320 ASSERT (DevicePath
!= NULL
);
3321 SetDevicePathEndNode (DevicePath
);
3323 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3325 Str
= DevicePathStr
;
3326 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3327 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3329 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3332 DevicePath
= NewDevicePath
;
3334 if (IsInstanceEnd
) {
3335 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3336 ASSERT (DeviceNode
!= NULL
);
3337 SetDevicePathEndNode (DeviceNode
);
3338 DeviceNode
->SubType
= END_INSTANCE_DEVICE_PATH_SUBTYPE
;
3340 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3343 DevicePath
= NewDevicePath
;
3347 free (DevicePathStr
);