2 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
4 Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiDevicePathLib.h"
21 @param Src Source string.
23 @return The duplicated string.
27 UefiDevicePathLibStrDuplicate (
31 return AllocateCopyPool (StrSize (Src
), Src
);
36 Get parameter in a pair of parentheses follow the given node name.
37 For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".
39 @param Str Device Path Text.
40 @param NodeName Name of the node.
42 @return Parameter text for the node.
54 UINTN ParameterLength
;
57 // Check whether the node name matchs
59 NodeNameLength
= StrLen (NodeName
);
60 if (StrnCmp (Str
, NodeName
, NodeNameLength
) != 0) {
64 ParamStr
= Str
+ NodeNameLength
;
65 if (!IS_LEFT_PARENTH (*ParamStr
)) {
70 // Skip the found '(' and find first occurrence of ')'
74 StrPointer
= ParamStr
;
75 while (!IS_NULL (*StrPointer
)) {
76 if (IS_RIGHT_PARENTH (*StrPointer
)) {
82 if (IS_NULL (*StrPointer
)) {
89 ParamStr
= AllocateCopyPool ((ParameterLength
+ 1) * sizeof (CHAR16
), ParamStr
);
90 if (ParamStr
== NULL
) {
94 // Terminate the parameter string
96 ParamStr
[ParameterLength
] = L
'\0';
102 Gets current sub-string from a string list, before return
103 the list header is moved to next sub-string. The sub-string is separated
104 by the specified character. For example, the separator is ',', the string
105 list is "2,0,3", it returns "2", the remain list move to "0,3"
107 @param List A string list separated by the specified separator
108 @param Separator The separator character
110 @return A pointer to the current sub-string
115 IN OUT CHAR16
**List
,
125 if (IS_NULL (*Str
)) {
130 // Find first occurrence of the separator
132 while (!IS_NULL (*Str
)) {
133 if (*Str
== Separator
) {
139 if (*Str
== Separator
) {
141 // Find a sub-string, terminate it
148 // Move to next sub-string
156 Gets the next parameter string from the list.
158 @param List A string list separated by the specified separator
160 @return A pointer to the current sub-string
169 // The separator is comma
171 return SplitStr (List
, L
',');
175 Get one device node from entire device path text.
177 @param DevicePath On input, the current Device Path node; on output, the next device path node
178 @param IsInstanceEnd This node is the end of a device path instance
180 @return A device node text or NULL if no more device node available
184 GetNextDeviceNodeStr (
185 IN OUT CHAR16
**DevicePath
,
186 OUT BOOLEAN
*IsInstanceEnd
191 UINTN ParenthesesStack
;
194 if (IS_NULL (*Str
)) {
199 // Skip the leading '/', '(', ')' and ','
201 while (!IS_NULL (*Str
)) {
202 if (!IS_SLASH (*Str
) &&
204 !IS_LEFT_PARENTH (*Str
) &&
205 !IS_RIGHT_PARENTH (*Str
)) {
214 // Scan for the separator of this device node, '/' or ','
216 ParenthesesStack
= 0;
217 while (!IS_NULL (*Str
)) {
218 if ((IS_COMMA (*Str
) || IS_SLASH (*Str
)) && (ParenthesesStack
== 0)) {
222 if (IS_LEFT_PARENTH (*Str
)) {
224 } else if (IS_RIGHT_PARENTH (*Str
)) {
231 if (ParenthesesStack
!= 0) {
233 // The '(' doesn't pair with ')', invalid device path text
238 if (IS_COMMA (*Str
)) {
239 *IsInstanceEnd
= TRUE
;
243 *IsInstanceEnd
= FALSE
;
244 if (!IS_NULL (*Str
)) {
257 Return whether the integer string is a hex string.
259 @param Str The integer string
261 @retval TRUE Hex string
262 @retval FALSE Decimal string
271 // skip preceeding white space
273 while ((*Str
!= 0) && *Str
== L
' ') {
277 // skip preceeding zeros
279 while ((*Str
!= 0) && *Str
== L
'0') {
283 return (BOOLEAN
) (*Str
== L
'x' || *Str
== L
'X');
288 Convert integer string to uint.
290 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
292 @return A UINTN value represented by Str
300 if (IsHexStr (Str
)) {
301 return StrHexToUintn (Str
);
303 return StrDecimalToUintn (Str
);
309 Convert integer string to 64 bit data.
311 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
312 @param Data A pointer to the UINT64 value represented by Str
321 if (IsHexStr (Str
)) {
322 *Data
= StrHexToUint64 (Str
);
324 *Data
= StrDecimalToUint64 (Str
);
329 Converts a list of string to a specified buffer.
331 @param Buf The output buffer that contains the string.
332 @param BufferLength The length of the buffer
333 @param Str The input string that contains the hex number
335 @retval EFI_SUCCESS The string was successfully converted to the buffer.
341 IN UINTN BufferLength
,
353 // Two hex char make up one byte
355 StrLength
= BufferLength
* sizeof (CHAR16
);
357 for(Index
= 0; Index
< StrLength
; Index
++, Str
++) {
359 if ((*Str
>= L
'a') && (*Str
<= L
'f')) {
360 Digit
= (UINT8
) (*Str
- L
'a' + 0x0A);
361 } else if ((*Str
>= L
'A') && (*Str
<= L
'F')) {
362 Digit
= (UINT8
) (*Str
- L
'A' + 0x0A);
363 } else if ((*Str
>= L
'0') && (*Str
<= L
'9')) {
364 Digit
= (UINT8
) (*Str
- L
'0');
366 return EFI_INVALID_PARAMETER
;
370 // For odd characters, write the upper nibble for each buffer byte,
371 // and for even characters, the lower nibble.
373 if ((Index
& 1) == 0) {
374 Byte
= (UINT8
) (Digit
<< 4);
376 Byte
= Buf
[Index
/ 2];
378 Byte
= (UINT8
) (Byte
| Digit
);
381 Buf
[Index
/ 2] = Byte
;
388 Converts a string to GUID value.
389 Guid Format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
391 @param Str The registry format GUID string that contains the GUID value.
392 @param Guid A pointer to the converted GUID value.
394 @retval EFI_SUCCESS The GUID string was successfully converted to the GUID value.
395 @retval EFI_UNSUPPORTED The input string is not in registry format.
396 @return others Some error occurred when converting part of GUID value.
406 // Get the first UINT32 data
408 Guid
->Data1
= (UINT32
) StrHexToUint64 (Str
);
409 while (!IS_HYPHEN (*Str
) && !IS_NULL (*Str
)) {
413 if (IS_HYPHEN (*Str
)) {
416 return EFI_UNSUPPORTED
;
420 // Get the second UINT16 data
422 Guid
->Data2
= (UINT16
) StrHexToUint64 (Str
);
423 while (!IS_HYPHEN (*Str
) && !IS_NULL (*Str
)) {
427 if (IS_HYPHEN (*Str
)) {
430 return EFI_UNSUPPORTED
;
434 // Get the third UINT16 data
436 Guid
->Data3
= (UINT16
) StrHexToUint64 (Str
);
437 while (!IS_HYPHEN (*Str
) && !IS_NULL (*Str
)) {
441 if (IS_HYPHEN (*Str
)) {
444 return EFI_UNSUPPORTED
;
448 // Get the following 8 bytes data
450 StrToBuf (&Guid
->Data4
[0], 2, Str
);
452 // Skip 2 byte hex chars
456 if (IS_HYPHEN (*Str
)) {
459 return EFI_UNSUPPORTED
;
461 StrToBuf (&Guid
->Data4
[2], 6, Str
);
467 Converts a string to IPv4 address
469 @param Str A string representation of IPv4 address.
470 @param IPv4Addr A pointer to the converted IPv4 address.
476 OUT EFI_IPv4_ADDRESS
*IPv4Addr
481 for (Index
= 0; Index
< 4; Index
++) {
482 IPv4Addr
->Addr
[Index
] = (UINT8
) Strtoi (SplitStr (Str
, L
'.'));
487 Converts a string to IPv4 address
489 @param Str A string representation of IPv6 address.
490 @param IPv6Addr A pointer to the converted IPv6 address.
496 OUT EFI_IPv6_ADDRESS
*IPv6Addr
502 for (Index
= 0; Index
< 8; Index
++) {
503 Data
= (UINT16
) StrHexToUintn (SplitStr (Str
, L
':'));
504 IPv6Addr
->Addr
[Index
* 2] = (UINT8
) (Data
>> 8);
505 IPv6Addr
->Addr
[Index
* 2 + 1] = (UINT8
) (Data
& 0xff);
510 Converts a Unicode string to ASCII string.
512 @param Str The equivalent Unicode string
513 @param AsciiStr On input, it points to destination ASCII string buffer; on output, it points
514 to the next ASCII string next to it
520 IN OUT CHAR8
**AsciiStr
526 while (!IS_NULL (*Str
)) {
527 *(Dest
++) = (CHAR8
) *(Str
++);
532 // Return the string next to it
534 *AsciiStr
= Dest
+ 1;
538 Converts a generic text device path node to device path structure.
540 @param Type The type of the device path node.
541 @param TextDeviceNode The input text device path node.
543 @return A pointer to device path structure.
545 EFI_DEVICE_PATH_PROTOCOL
*
546 DevPathFromTextGenericPath (
548 IN CHAR16
*TextDeviceNode
551 EFI_DEVICE_PATH_PROTOCOL
*Node
;
556 SubtypeStr
= GetNextParamStr (&TextDeviceNode
);
557 DataStr
= GetNextParamStr (&TextDeviceNode
);
559 if (DataStr
== NULL
) {
562 DataLength
= StrLen (DataStr
) / 2;
564 Node
= CreateDeviceNode (
566 (UINT8
) Strtoi (SubtypeStr
),
567 (UINT16
) (sizeof (EFI_DEVICE_PATH_PROTOCOL
) + DataLength
)
570 StrToBuf ((UINT8
*) (Node
+ 1), DataLength
, DataStr
);
575 Converts a generic text device path node to device path structure.
577 @param TextDeviceNode The input Text device path node.
579 @return A pointer to device path structure.
582 EFI_DEVICE_PATH_PROTOCOL
*
583 DevPathFromTextPath (
584 IN CHAR16
*TextDeviceNode
589 TypeStr
= GetNextParamStr (&TextDeviceNode
);
591 return DevPathFromTextGenericPath ((UINT8
) Strtoi (TypeStr
), TextDeviceNode
);
595 Converts a generic hardware text device path node to Hardware device path structure.
597 @param TextDeviceNode The input Text device path node.
599 @return A pointer to Hardware device path structure.
602 EFI_DEVICE_PATH_PROTOCOL
*
603 DevPathFromTextHardwarePath (
604 IN CHAR16
*TextDeviceNode
607 return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH
, TextDeviceNode
);
611 Converts a text device path node to Hardware PCI device path structure.
613 @param TextDeviceNode The input Text device path node.
615 @return A pointer to Hardware PCI device path structure.
618 EFI_DEVICE_PATH_PROTOCOL
*
620 IN CHAR16
*TextDeviceNode
625 PCI_DEVICE_PATH
*Pci
;
627 DeviceStr
= GetNextParamStr (&TextDeviceNode
);
628 FunctionStr
= GetNextParamStr (&TextDeviceNode
);
629 Pci
= (PCI_DEVICE_PATH
*) CreateDeviceNode (
630 HARDWARE_DEVICE_PATH
,
632 (UINT16
) sizeof (PCI_DEVICE_PATH
)
635 Pci
->Function
= (UINT8
) Strtoi (FunctionStr
);
636 Pci
->Device
= (UINT8
) Strtoi (DeviceStr
);
638 return (EFI_DEVICE_PATH_PROTOCOL
*) Pci
;
642 Converts a text device path node to Hardware PC card device path structure.
644 @param TextDeviceNode The input Text device path node.
646 @return A pointer to Hardware PC card device path structure.
649 EFI_DEVICE_PATH_PROTOCOL
*
650 DevPathFromTextPcCard (
651 IN CHAR16
*TextDeviceNode
654 CHAR16
*FunctionNumberStr
;
655 PCCARD_DEVICE_PATH
*Pccard
;
657 FunctionNumberStr
= GetNextParamStr (&TextDeviceNode
);
658 Pccard
= (PCCARD_DEVICE_PATH
*) CreateDeviceNode (
659 HARDWARE_DEVICE_PATH
,
661 (UINT16
) sizeof (PCCARD_DEVICE_PATH
)
664 Pccard
->FunctionNumber
= (UINT8
) Strtoi (FunctionNumberStr
);
666 return (EFI_DEVICE_PATH_PROTOCOL
*) Pccard
;
670 Converts a text device path node to Hardware memory map device path structure.
672 @param TextDeviceNode The input Text device path node.
674 @return A pointer to Hardware memory map device path structure.
677 EFI_DEVICE_PATH_PROTOCOL
*
678 DevPathFromTextMemoryMapped (
679 IN CHAR16
*TextDeviceNode
682 CHAR16
*MemoryTypeStr
;
683 CHAR16
*StartingAddressStr
;
684 CHAR16
*EndingAddressStr
;
685 MEMMAP_DEVICE_PATH
*MemMap
;
687 MemoryTypeStr
= GetNextParamStr (&TextDeviceNode
);
688 StartingAddressStr
= GetNextParamStr (&TextDeviceNode
);
689 EndingAddressStr
= GetNextParamStr (&TextDeviceNode
);
690 MemMap
= (MEMMAP_DEVICE_PATH
*) CreateDeviceNode (
691 HARDWARE_DEVICE_PATH
,
693 (UINT16
) sizeof (MEMMAP_DEVICE_PATH
)
696 MemMap
->MemoryType
= (UINT32
) Strtoi (MemoryTypeStr
);
697 Strtoi64 (StartingAddressStr
, &MemMap
->StartingAddress
);
698 Strtoi64 (EndingAddressStr
, &MemMap
->EndingAddress
);
700 return (EFI_DEVICE_PATH_PROTOCOL
*) MemMap
;
704 Converts a text device path node to Vendor device path structure based on the input Type
707 @param TextDeviceNode The input Text device path node.
708 @param Type The type of device path node.
709 @param SubType The subtype of device path node.
711 @return A pointer to the newly-created Vendor device path structure.
714 EFI_DEVICE_PATH_PROTOCOL
*
715 ConvertFromTextVendor (
716 IN CHAR16
*TextDeviceNode
,
724 VENDOR_DEVICE_PATH
*Vendor
;
726 GuidStr
= GetNextParamStr (&TextDeviceNode
);
728 DataStr
= GetNextParamStr (&TextDeviceNode
);
729 Length
= StrLen (DataStr
);
731 // Two hex characters make up 1 buffer byte
733 Length
= (Length
+ 1) / 2;
735 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
738 (UINT16
) (sizeof (VENDOR_DEVICE_PATH
) + Length
)
741 StrToGuid (GuidStr
, &Vendor
->Guid
);
742 StrToBuf (((UINT8
*) Vendor
) + sizeof (VENDOR_DEVICE_PATH
), Length
, DataStr
);
744 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
748 Converts a text device path node to Vendor Hardware device path structure.
750 @param TextDeviceNode The input Text device path node.
752 @return A pointer to the newly-created Vendor Hardware device path structure.
755 EFI_DEVICE_PATH_PROTOCOL
*
756 DevPathFromTextVenHw (
757 IN CHAR16
*TextDeviceNode
760 return ConvertFromTextVendor (
762 HARDWARE_DEVICE_PATH
,
768 Converts a text device path node to Hardware Controller device path structure.
770 @param TextDeviceNode The input Text device path node.
772 @return A pointer to the newly-created Hardware Controller device path structure.
775 EFI_DEVICE_PATH_PROTOCOL
*
776 DevPathFromTextCtrl (
777 IN CHAR16
*TextDeviceNode
780 CHAR16
*ControllerStr
;
781 CONTROLLER_DEVICE_PATH
*Controller
;
783 ControllerStr
= GetNextParamStr (&TextDeviceNode
);
784 Controller
= (CONTROLLER_DEVICE_PATH
*) CreateDeviceNode (
785 HARDWARE_DEVICE_PATH
,
787 (UINT16
) sizeof (CONTROLLER_DEVICE_PATH
)
789 Controller
->ControllerNumber
= (UINT32
) Strtoi (ControllerStr
);
791 return (EFI_DEVICE_PATH_PROTOCOL
*) Controller
;
795 Converts a generic ACPI text device path node to ACPI device path structure.
797 @param TextDeviceNode The input Text device path node.
799 @return A pointer to ACPI device path structure.
802 EFI_DEVICE_PATH_PROTOCOL
*
803 DevPathFromTextAcpiPath (
804 IN CHAR16
*TextDeviceNode
807 return DevPathFromTextGenericPath (ACPI_DEVICE_PATH
, TextDeviceNode
);
811 Converts a string to EisaId.
813 @param Text The input string.
815 @return UINT32 EISA ID.
822 return (((Text
[0] - 'A' + 1) & 0x1f) << 10)
823 + (((Text
[1] - 'A' + 1) & 0x1f) << 5)
824 + (((Text
[2] - 'A' + 1) & 0x1f) << 0)
825 + (UINT32
) (StrHexToUintn (&Text
[3]) << 16)
830 Converts a text device path node to ACPI HID device path structure.
832 @param TextDeviceNode The input Text device path node.
834 @return A pointer to the newly-created ACPI HID device path structure.
837 EFI_DEVICE_PATH_PROTOCOL
*
838 DevPathFromTextAcpi (
839 IN CHAR16
*TextDeviceNode
844 ACPI_HID_DEVICE_PATH
*Acpi
;
846 HIDStr
= GetNextParamStr (&TextDeviceNode
);
847 UIDStr
= GetNextParamStr (&TextDeviceNode
);
848 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
851 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
854 Acpi
->HID
= EisaIdFromText (HIDStr
);
855 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
857 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
861 Converts a text device path node to ACPI HID device path structure.
863 @param TextDeviceNode The input Text device path node.
864 @param PnPId The input plug and play identification.
866 @return A pointer to the newly-created ACPI HID device path structure.
869 EFI_DEVICE_PATH_PROTOCOL
*
870 ConvertFromTextAcpi (
871 IN CHAR16
*TextDeviceNode
,
876 ACPI_HID_DEVICE_PATH
*Acpi
;
878 UIDStr
= GetNextParamStr (&TextDeviceNode
);
879 Acpi
= (ACPI_HID_DEVICE_PATH
*) CreateDeviceNode (
882 (UINT16
) sizeof (ACPI_HID_DEVICE_PATH
)
885 Acpi
->HID
= EFI_PNP_ID (PnPId
);
886 Acpi
->UID
= (UINT32
) Strtoi (UIDStr
);
888 return (EFI_DEVICE_PATH_PROTOCOL
*) Acpi
;
892 Converts a text device path node to PCI root device path structure.
894 @param TextDeviceNode The input Text device path node.
896 @return A pointer to the newly-created PCI root device path structure.
899 EFI_DEVICE_PATH_PROTOCOL
*
900 DevPathFromTextPciRoot (
901 IN CHAR16
*TextDeviceNode
904 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a03);
908 Converts a text device path node to PCIE root device path structure.
910 @param TextDeviceNode The input Text device path node.
912 @return A pointer to the newly-created PCIE root device path structure.
915 EFI_DEVICE_PATH_PROTOCOL
*
916 DevPathFromTextPcieRoot (
917 IN CHAR16
*TextDeviceNode
920 return ConvertFromTextAcpi (TextDeviceNode
, 0x0a08);
924 Converts a text device path node to Floppy device path structure.
926 @param TextDeviceNode The input Text device path node.
928 @return A pointer to the newly-created Floppy device path structure.
931 EFI_DEVICE_PATH_PROTOCOL
*
932 DevPathFromTextFloppy (
933 IN CHAR16
*TextDeviceNode
936 return ConvertFromTextAcpi (TextDeviceNode
, 0x0604);
940 Converts a text device path node to Keyboard device path structure.
942 @param TextDeviceNode The input Text device path node.
944 @return A pointer to the newly-created Keyboard device path structure.
947 EFI_DEVICE_PATH_PROTOCOL
*
948 DevPathFromTextKeyboard (
949 IN CHAR16
*TextDeviceNode
952 return ConvertFromTextAcpi (TextDeviceNode
, 0x0301);
956 Converts a text device path node to Serial device path structure.
958 @param TextDeviceNode The input Text device path node.
960 @return A pointer to the newly-created Serial device path structure.
963 EFI_DEVICE_PATH_PROTOCOL
*
964 DevPathFromTextSerial (
965 IN CHAR16
*TextDeviceNode
968 return ConvertFromTextAcpi (TextDeviceNode
, 0x0501);
972 Converts a text device path node to Parallel Port device path structure.
974 @param TextDeviceNode The input Text device path node.
976 @return A pointer to the newly-created Parallel Port device path structure.
979 EFI_DEVICE_PATH_PROTOCOL
*
980 DevPathFromTextParallelPort (
981 IN CHAR16
*TextDeviceNode
984 return ConvertFromTextAcpi (TextDeviceNode
, 0x0401);
988 Converts a text device path node to ACPI extension device path structure.
990 @param TextDeviceNode The input Text device path node.
992 @return A pointer to the newly-created ACPI extension device path structure.
995 EFI_DEVICE_PATH_PROTOCOL
*
996 DevPathFromTextAcpiEx (
997 IN CHAR16
*TextDeviceNode
1008 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
1010 HIDStr
= GetNextParamStr (&TextDeviceNode
);
1011 CIDStr
= GetNextParamStr (&TextDeviceNode
);
1012 UIDStr
= GetNextParamStr (&TextDeviceNode
);
1013 HIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1014 CIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1015 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1017 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (HIDSTRStr
) + 1);
1018 Length
= (UINT16
) (Length
+ StrLen (UIDSTRStr
) + 1);
1019 Length
= (UINT16
) (Length
+ StrLen (CIDSTRStr
) + 1);
1020 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
1026 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
1027 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
1028 AcpiEx
->UID
= (UINT32
) Strtoi (UIDStr
);
1030 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
1031 StrToAscii (HIDSTRStr
, &AsciiStr
);
1032 StrToAscii (UIDSTRStr
, &AsciiStr
);
1033 StrToAscii (CIDSTRStr
, &AsciiStr
);
1035 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
1039 Converts a text device path node to ACPI extension device path structure.
1041 @param TextDeviceNode The input Text device path node.
1043 @return A pointer to the newly-created ACPI extension device path structure.
1046 EFI_DEVICE_PATH_PROTOCOL
*
1047 DevPathFromTextAcpiExp (
1048 IN CHAR16
*TextDeviceNode
1056 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
1058 HIDStr
= GetNextParamStr (&TextDeviceNode
);
1059 CIDStr
= GetNextParamStr (&TextDeviceNode
);
1060 UIDSTRStr
= GetNextParamStr (&TextDeviceNode
);
1061 Length
= (UINT16
) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
) + StrLen (UIDSTRStr
) + 3);
1062 AcpiEx
= (ACPI_EXTENDED_HID_DEVICE_PATH
*) CreateDeviceNode (
1068 AcpiEx
->HID
= EisaIdFromText (HIDStr
);
1069 AcpiEx
->CID
= EisaIdFromText (CIDStr
);
1072 AsciiStr
= (CHAR8
*) ((UINT8
*)AcpiEx
+ sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
1074 // HID string is NULL
1078 // Convert UID string
1081 StrToAscii (UIDSTRStr
, &AsciiStr
);
1083 // CID string is NULL
1087 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiEx
;
1091 Converts a text device path node to ACPI _ADR device path structure.
1093 @param TextDeviceNode The input Text device path node.
1095 @return A pointer to the newly-created ACPI _ADR device path structure.
1098 EFI_DEVICE_PATH_PROTOCOL
*
1099 DevPathFromTextAcpiAdr (
1100 IN CHAR16
*TextDeviceNode
1103 CHAR16
*DisplayDeviceStr
;
1104 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
1108 AcpiAdr
= (ACPI_ADR_DEVICE_PATH
*) CreateDeviceNode (
1111 (UINT16
) sizeof (ACPI_ADR_DEVICE_PATH
)
1113 ASSERT (AcpiAdr
!= NULL
);
1115 for (Index
= 0; ; Index
++) {
1116 DisplayDeviceStr
= GetNextParamStr (&TextDeviceNode
);
1117 if (IS_NULL (*DisplayDeviceStr
)) {
1121 Length
= DevicePathNodeLength (AcpiAdr
);
1122 AcpiAdr
= ReallocatePool (
1124 Length
+ sizeof (UINT32
),
1127 ASSERT (AcpiAdr
!= NULL
);
1128 SetDevicePathNodeLength (AcpiAdr
, Length
+ sizeof (UINT32
));
1131 (&AcpiAdr
->ADR
)[Index
] = (UINT32
) Strtoi (DisplayDeviceStr
);
1134 return (EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
;
1138 Converts a generic messaging text device path node to messaging device path structure.
1140 @param TextDeviceNode The input Text device path node.
1142 @return A pointer to messaging device path structure.
1145 EFI_DEVICE_PATH_PROTOCOL
*
1146 DevPathFromTextMsg (
1147 IN CHAR16
*TextDeviceNode
1150 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH
, TextDeviceNode
);
1154 Converts a text device path node to Parallel Port device path structure.
1156 @param TextDeviceNode The input Text device path node.
1158 @return A pointer to the newly-created Parallel Port device path structure.
1161 EFI_DEVICE_PATH_PROTOCOL
*
1162 DevPathFromTextAta (
1163 IN CHAR16
*TextDeviceNode
1166 CHAR16
*PrimarySecondaryStr
;
1167 CHAR16
*SlaveMasterStr
;
1169 ATAPI_DEVICE_PATH
*Atapi
;
1171 Atapi
= (ATAPI_DEVICE_PATH
*) CreateDeviceNode (
1172 MESSAGING_DEVICE_PATH
,
1174 (UINT16
) sizeof (ATAPI_DEVICE_PATH
)
1177 PrimarySecondaryStr
= GetNextParamStr (&TextDeviceNode
);
1178 SlaveMasterStr
= GetNextParamStr (&TextDeviceNode
);
1179 LunStr
= GetNextParamStr (&TextDeviceNode
);
1181 if (StrCmp (PrimarySecondaryStr
, L
"Primary") == 0) {
1182 Atapi
->PrimarySecondary
= 0;
1183 } else if (StrCmp (PrimarySecondaryStr
, L
"Secondary") == 0) {
1184 Atapi
->PrimarySecondary
= 1;
1186 Atapi
->PrimarySecondary
= (UINT8
) Strtoi (PrimarySecondaryStr
);
1188 if (StrCmp (SlaveMasterStr
, L
"Master") == 0) {
1189 Atapi
->SlaveMaster
= 0;
1190 } else if (StrCmp (SlaveMasterStr
, L
"Slave") == 0) {
1191 Atapi
->SlaveMaster
= 1;
1193 Atapi
->SlaveMaster
= (UINT8
) Strtoi (SlaveMasterStr
);
1196 Atapi
->Lun
= (UINT16
) Strtoi (LunStr
);
1198 return (EFI_DEVICE_PATH_PROTOCOL
*) Atapi
;
1202 Converts a text device path node to SCSI device path structure.
1204 @param TextDeviceNode The input Text device path node.
1206 @return A pointer to the newly-created SCSI device path structure.
1209 EFI_DEVICE_PATH_PROTOCOL
*
1210 DevPathFromTextScsi (
1211 IN CHAR16
*TextDeviceNode
1216 SCSI_DEVICE_PATH
*Scsi
;
1218 PunStr
= GetNextParamStr (&TextDeviceNode
);
1219 LunStr
= GetNextParamStr (&TextDeviceNode
);
1220 Scsi
= (SCSI_DEVICE_PATH
*) CreateDeviceNode (
1221 MESSAGING_DEVICE_PATH
,
1223 (UINT16
) sizeof (SCSI_DEVICE_PATH
)
1226 Scsi
->Pun
= (UINT16
) Strtoi (PunStr
);
1227 Scsi
->Lun
= (UINT16
) Strtoi (LunStr
);
1229 return (EFI_DEVICE_PATH_PROTOCOL
*) Scsi
;
1233 Converts a text device path node to Fibre device path structure.
1235 @param TextDeviceNode The input Text device path node.
1237 @return A pointer to the newly-created Fibre device path structure.
1240 EFI_DEVICE_PATH_PROTOCOL
*
1241 DevPathFromTextFibre (
1242 IN CHAR16
*TextDeviceNode
1247 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
1249 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1250 LunStr
= GetNextParamStr (&TextDeviceNode
);
1251 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) CreateDeviceNode (
1252 MESSAGING_DEVICE_PATH
,
1253 MSG_FIBRECHANNEL_DP
,
1254 (UINT16
) sizeof (FIBRECHANNEL_DEVICE_PATH
)
1257 Fibre
->Reserved
= 0;
1258 Strtoi64 (WWNStr
, &Fibre
->WWN
);
1259 Strtoi64 (LunStr
, &Fibre
->Lun
);
1261 return (EFI_DEVICE_PATH_PROTOCOL
*) Fibre
;
1265 Converts a text device path node to FibreEx device path structure.
1267 @param TextDeviceNode The input Text device path node.
1269 @return A pointer to the newly-created FibreEx device path structure.
1272 EFI_DEVICE_PATH_PROTOCOL
*
1273 DevPathFromTextFibreEx (
1274 IN CHAR16
*TextDeviceNode
1279 FIBRECHANNELEX_DEVICE_PATH
*FibreEx
;
1281 WWNStr
= GetNextParamStr (&TextDeviceNode
);
1282 LunStr
= GetNextParamStr (&TextDeviceNode
);
1283 FibreEx
= (FIBRECHANNELEX_DEVICE_PATH
*) CreateDeviceNode (
1284 MESSAGING_DEVICE_PATH
,
1285 MSG_FIBRECHANNELEX_DP
,
1286 (UINT16
) sizeof (FIBRECHANNELEX_DEVICE_PATH
)
1289 FibreEx
->Reserved
= 0;
1290 Strtoi64 (WWNStr
, (UINT64
*) (&FibreEx
->WWN
));
1291 Strtoi64 (LunStr
, (UINT64
*) (&FibreEx
->Lun
));
1293 *(UINT64
*) (&FibreEx
->WWN
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->WWN
));
1294 *(UINT64
*) (&FibreEx
->Lun
) = SwapBytes64 (*(UINT64
*) (&FibreEx
->Lun
));
1296 return (EFI_DEVICE_PATH_PROTOCOL
*) FibreEx
;
1300 Converts a text device path node to 1394 device path structure.
1302 @param TextDeviceNode The input Text device path node.
1304 @return A pointer to the newly-created 1394 device path structure.
1307 EFI_DEVICE_PATH_PROTOCOL
*
1308 DevPathFromText1394 (
1309 IN CHAR16
*TextDeviceNode
1313 F1394_DEVICE_PATH
*F1394DevPath
;
1315 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1316 F1394DevPath
= (F1394_DEVICE_PATH
*) CreateDeviceNode (
1317 MESSAGING_DEVICE_PATH
,
1319 (UINT16
) sizeof (F1394_DEVICE_PATH
)
1322 F1394DevPath
->Reserved
= 0;
1323 F1394DevPath
->Guid
= StrHexToUint64 (GuidStr
);
1325 return (EFI_DEVICE_PATH_PROTOCOL
*) F1394DevPath
;
1329 Converts a text device path node to USB device path structure.
1331 @param TextDeviceNode The input Text device path node.
1333 @return A pointer to the newly-created USB device path structure.
1336 EFI_DEVICE_PATH_PROTOCOL
*
1337 DevPathFromTextUsb (
1338 IN CHAR16
*TextDeviceNode
1342 CHAR16
*InterfaceStr
;
1343 USB_DEVICE_PATH
*Usb
;
1345 PortStr
= GetNextParamStr (&TextDeviceNode
);
1346 InterfaceStr
= GetNextParamStr (&TextDeviceNode
);
1347 Usb
= (USB_DEVICE_PATH
*) CreateDeviceNode (
1348 MESSAGING_DEVICE_PATH
,
1350 (UINT16
) sizeof (USB_DEVICE_PATH
)
1353 Usb
->ParentPortNumber
= (UINT8
) Strtoi (PortStr
);
1354 Usb
->InterfaceNumber
= (UINT8
) Strtoi (InterfaceStr
);
1356 return (EFI_DEVICE_PATH_PROTOCOL
*) Usb
;
1360 Converts a text device path node to I20 device path structure.
1362 @param TextDeviceNode The input Text device path node.
1364 @return A pointer to the newly-created I20 device path structure.
1367 EFI_DEVICE_PATH_PROTOCOL
*
1368 DevPathFromTextI2O (
1369 IN CHAR16
*TextDeviceNode
1373 I2O_DEVICE_PATH
*I2ODevPath
;
1375 TIDStr
= GetNextParamStr (&TextDeviceNode
);
1376 I2ODevPath
= (I2O_DEVICE_PATH
*) CreateDeviceNode (
1377 MESSAGING_DEVICE_PATH
,
1379 (UINT16
) sizeof (I2O_DEVICE_PATH
)
1382 I2ODevPath
->Tid
= (UINT32
) Strtoi (TIDStr
);
1384 return (EFI_DEVICE_PATH_PROTOCOL
*) I2ODevPath
;
1388 Converts a text device path node to Infini Band device path structure.
1390 @param TextDeviceNode The input Text device path node.
1392 @return A pointer to the newly-created Infini Band device path structure.
1395 EFI_DEVICE_PATH_PROTOCOL
*
1396 DevPathFromTextInfiniband (
1397 IN CHAR16
*TextDeviceNode
1406 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1408 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
1409 GuidStr
= GetNextParamStr (&TextDeviceNode
);
1410 SidStr
= GetNextParamStr (&TextDeviceNode
);
1411 TidStr
= GetNextParamStr (&TextDeviceNode
);
1412 DidStr
= GetNextParamStr (&TextDeviceNode
);
1413 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) CreateDeviceNode (
1414 MESSAGING_DEVICE_PATH
,
1416 (UINT16
) sizeof (INFINIBAND_DEVICE_PATH
)
1419 InfiniBand
->ResourceFlags
= (UINT32
) Strtoi (FlagsStr
);
1420 StrToGuid (GuidStr
, &PortGid
);
1421 CopyMem (InfiniBand
->PortGid
, &PortGid
, sizeof (EFI_GUID
));
1422 Strtoi64 (SidStr
, &InfiniBand
->ServiceId
);
1423 Strtoi64 (TidStr
, &InfiniBand
->TargetPortId
);
1424 Strtoi64 (DidStr
, &InfiniBand
->DeviceId
);
1426 return (EFI_DEVICE_PATH_PROTOCOL
*) InfiniBand
;
1430 Converts a text device path node to Vendor-Defined Messaging device path structure.
1432 @param TextDeviceNode The input Text device path node.
1434 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1437 EFI_DEVICE_PATH_PROTOCOL
*
1438 DevPathFromTextVenMsg (
1439 IN CHAR16
*TextDeviceNode
1442 return ConvertFromTextVendor (
1444 MESSAGING_DEVICE_PATH
,
1450 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1452 @param TextDeviceNode The input Text device path node.
1454 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1457 EFI_DEVICE_PATH_PROTOCOL
*
1458 DevPathFromTextVenPcAnsi (
1459 IN CHAR16
*TextDeviceNode
1462 VENDOR_DEVICE_PATH
*Vendor
;
1464 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1465 MESSAGING_DEVICE_PATH
,
1467 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1468 CopyGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
);
1470 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1474 Converts a text device path node to Vendor defined VT100 device path structure.
1476 @param TextDeviceNode The input Text device path node.
1478 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1481 EFI_DEVICE_PATH_PROTOCOL
*
1482 DevPathFromTextVenVt100 (
1483 IN CHAR16
*TextDeviceNode
1486 VENDOR_DEVICE_PATH
*Vendor
;
1488 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1489 MESSAGING_DEVICE_PATH
,
1491 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1492 CopyGuid (&Vendor
->Guid
, &gEfiVT100Guid
);
1494 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1498 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1500 @param TextDeviceNode The input Text device path node.
1502 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1505 EFI_DEVICE_PATH_PROTOCOL
*
1506 DevPathFromTextVenVt100Plus (
1507 IN CHAR16
*TextDeviceNode
1510 VENDOR_DEVICE_PATH
*Vendor
;
1512 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1513 MESSAGING_DEVICE_PATH
,
1515 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1516 CopyGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
);
1518 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1522 Converts a text device path node to Vendor defined UTF8 device path structure.
1524 @param TextDeviceNode The input Text device path node.
1526 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1529 EFI_DEVICE_PATH_PROTOCOL
*
1530 DevPathFromTextVenUtf8 (
1531 IN CHAR16
*TextDeviceNode
1534 VENDOR_DEVICE_PATH
*Vendor
;
1536 Vendor
= (VENDOR_DEVICE_PATH
*) CreateDeviceNode (
1537 MESSAGING_DEVICE_PATH
,
1539 (UINT16
) sizeof (VENDOR_DEVICE_PATH
));
1540 CopyGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
);
1542 return (EFI_DEVICE_PATH_PROTOCOL
*) Vendor
;
1546 Converts a text device path node to UART Flow Control device path structure.
1548 @param TextDeviceNode The input Text device path node.
1550 @return A pointer to the newly-created UART Flow Control device path structure.
1553 EFI_DEVICE_PATH_PROTOCOL
*
1554 DevPathFromTextUartFlowCtrl (
1555 IN CHAR16
*TextDeviceNode
1559 UART_FLOW_CONTROL_DEVICE_PATH
*UartFlowControl
;
1561 ValueStr
= GetNextParamStr (&TextDeviceNode
);
1562 UartFlowControl
= (UART_FLOW_CONTROL_DEVICE_PATH
*) CreateDeviceNode (
1563 MESSAGING_DEVICE_PATH
,
1565 (UINT16
) sizeof (UART_FLOW_CONTROL_DEVICE_PATH
)
1568 CopyGuid (&UartFlowControl
->Guid
, &gEfiUartDevicePathGuid
);
1569 if (StrCmp (ValueStr
, L
"XonXoff") == 0) {
1570 UartFlowControl
->FlowControlMap
= 2;
1571 } else if (StrCmp (ValueStr
, L
"Hardware") == 0) {
1572 UartFlowControl
->FlowControlMap
= 1;
1574 UartFlowControl
->FlowControlMap
= 0;
1577 return (EFI_DEVICE_PATH_PROTOCOL
*) UartFlowControl
;
1581 Converts a text device path node to Serial Attached SCSI device path structure.
1583 @param TextDeviceNode The input Text device path node.
1585 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1588 EFI_DEVICE_PATH_PROTOCOL
*
1589 DevPathFromTextSAS (
1590 IN CHAR16
*TextDeviceNode
1597 CHAR16
*LocationStr
;
1599 CHAR16
*DriveBayStr
;
1600 CHAR16
*ReservedStr
;
1603 SAS_DEVICE_PATH
*Sas
;
1605 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1606 LunStr
= GetNextParamStr (&TextDeviceNode
);
1607 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1608 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1609 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1610 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1611 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1612 ReservedStr
= GetNextParamStr (&TextDeviceNode
);
1613 Sas
= (SAS_DEVICE_PATH
*) CreateDeviceNode (
1614 MESSAGING_DEVICE_PATH
,
1616 (UINT16
) sizeof (SAS_DEVICE_PATH
)
1619 CopyGuid (&Sas
->Guid
, &gEfiSasDevicePathGuid
);
1620 Strtoi64 (AddressStr
, &Sas
->SasAddress
);
1621 Strtoi64 (LunStr
, &Sas
->Lun
);
1622 Sas
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1624 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1627 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1629 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1633 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1636 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1641 // Location is an integer between 0 and 1 or else
1642 // the keyword Internal (0) or External (1).
1644 if (StrCmp (LocationStr
, L
"External") == 0) {
1646 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1649 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1651 Info
|= (Uint16
<< 5);
1654 // Connect is an integer between 0 and 3 or else
1655 // the keyword Direct (0) or Expanded (1).
1657 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1659 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1662 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1664 Info
|= (Uint16
<< 6);
1667 Info
= (UINT16
) Strtoi (SASSATAStr
);
1670 Sas
->DeviceTopology
= Info
;
1671 Sas
->Reserved
= (UINT32
) Strtoi (ReservedStr
);
1673 return (EFI_DEVICE_PATH_PROTOCOL
*) Sas
;
1677 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1679 @param TextDeviceNode The input Text device path node.
1681 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1684 EFI_DEVICE_PATH_PROTOCOL
*
1685 DevPathFromTextSasEx (
1686 IN CHAR16
*TextDeviceNode
1693 CHAR16
*LocationStr
;
1695 CHAR16
*DriveBayStr
;
1700 SASEX_DEVICE_PATH
*SasEx
;
1702 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1703 LunStr
= GetNextParamStr (&TextDeviceNode
);
1704 RTPStr
= GetNextParamStr (&TextDeviceNode
);
1705 SASSATAStr
= GetNextParamStr (&TextDeviceNode
);
1706 LocationStr
= GetNextParamStr (&TextDeviceNode
);
1707 ConnectStr
= GetNextParamStr (&TextDeviceNode
);
1708 DriveBayStr
= GetNextParamStr (&TextDeviceNode
);
1709 SasEx
= (SASEX_DEVICE_PATH
*) CreateDeviceNode (
1710 MESSAGING_DEVICE_PATH
,
1712 (UINT16
) sizeof (SASEX_DEVICE_PATH
)
1715 Strtoi64 (AddressStr
, &SasAddress
);
1716 Strtoi64 (LunStr
, &Lun
);
1717 WriteUnaligned64 ((UINT64
*) &SasEx
->SasAddress
, SwapBytes64 (SasAddress
));
1718 WriteUnaligned64 ((UINT64
*) &SasEx
->Lun
, SwapBytes64 (Lun
));
1719 SasEx
->RelativeTargetPort
= (UINT16
) Strtoi (RTPStr
);
1721 if (StrCmp (SASSATAStr
, L
"NoTopology") == 0) {
1724 } else if ((StrCmp (SASSATAStr
, L
"SATA") == 0) || (StrCmp (SASSATAStr
, L
"SAS") == 0)) {
1726 Uint16
= (UINT16
) Strtoi (DriveBayStr
);
1730 Info
= (UINT16
) (0x2 | ((Uint16
- 1) << 8));
1733 if (StrCmp (SASSATAStr
, L
"SATA") == 0) {
1738 // Location is an integer between 0 and 1 or else
1739 // the keyword Internal (0) or External (1).
1741 if (StrCmp (LocationStr
, L
"External") == 0) {
1743 } else if (StrCmp (LocationStr
, L
"Internal") == 0) {
1746 Uint16
= ((UINT16
) Strtoi (LocationStr
) & BIT0
);
1748 Info
|= (Uint16
<< 5);
1751 // Connect is an integer between 0 and 3 or else
1752 // the keyword Direct (0) or Expanded (1).
1754 if (StrCmp (ConnectStr
, L
"Expanded") == 0) {
1756 } else if (StrCmp (ConnectStr
, L
"Direct") == 0) {
1759 Uint16
= ((UINT16
) Strtoi (ConnectStr
) & (BIT0
| BIT1
));
1761 Info
|= (Uint16
<< 6);
1764 Info
= (UINT16
) Strtoi (SASSATAStr
);
1767 SasEx
->DeviceTopology
= Info
;
1769 return (EFI_DEVICE_PATH_PROTOCOL
*) SasEx
;
1773 Converts a text device path node to Debug Port device path structure.
1775 @param TextDeviceNode The input Text device path node.
1777 @return A pointer to the newly-created Debug Port device path structure.
1780 EFI_DEVICE_PATH_PROTOCOL
*
1781 DevPathFromTextDebugPort (
1782 IN CHAR16
*TextDeviceNode
1785 VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*Vend
;
1787 Vend
= (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
*) CreateDeviceNode (
1788 MESSAGING_DEVICE_PATH
,
1790 (UINT16
) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH
)
1793 CopyGuid (&Vend
->Guid
, &gEfiDebugPortProtocolGuid
);
1795 return (EFI_DEVICE_PATH_PROTOCOL
*) Vend
;
1799 Converts a text device path node to MAC device path structure.
1801 @param TextDeviceNode The input Text device path node.
1803 @return A pointer to the newly-created MAC device path structure.
1806 EFI_DEVICE_PATH_PROTOCOL
*
1807 DevPathFromTextMAC (
1808 IN CHAR16
*TextDeviceNode
1814 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
1816 AddressStr
= GetNextParamStr (&TextDeviceNode
);
1817 IfTypeStr
= GetNextParamStr (&TextDeviceNode
);
1818 MACDevPath
= (MAC_ADDR_DEVICE_PATH
*) CreateDeviceNode (
1819 MESSAGING_DEVICE_PATH
,
1821 (UINT16
) sizeof (MAC_ADDR_DEVICE_PATH
)
1824 MACDevPath
->IfType
= (UINT8
) Strtoi (IfTypeStr
);
1826 Length
= sizeof (EFI_MAC_ADDRESS
);
1827 StrToBuf (&MACDevPath
->MacAddress
.Addr
[0], Length
, AddressStr
);
1829 return (EFI_DEVICE_PATH_PROTOCOL
*) MACDevPath
;
1834 Converts a text format to the network protocol ID.
1836 @param Text String of protocol field.
1838 @return Network protocol ID .
1842 NetworkProtocolFromText (
1846 if (StrCmp (Text
, L
"UDP") == 0) {
1847 return RFC_1700_UDP_PROTOCOL
;
1850 if (StrCmp (Text
, L
"TCP") == 0) {
1851 return RFC_1700_TCP_PROTOCOL
;
1854 return Strtoi (Text
);
1859 Converts a text device path node to IPV4 device path structure.
1861 @param TextDeviceNode The input Text device path node.
1863 @return A pointer to the newly-created IPV4 device path structure.
1866 EFI_DEVICE_PATH_PROTOCOL
*
1867 DevPathFromTextIPv4 (
1868 IN CHAR16
*TextDeviceNode
1871 CHAR16
*RemoteIPStr
;
1872 CHAR16
*ProtocolStr
;
1875 CHAR16
*GatewayIPStr
;
1876 CHAR16
*SubnetMaskStr
;
1877 IPv4_DEVICE_PATH
*IPv4
;
1879 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1880 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1881 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1882 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1883 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1884 SubnetMaskStr
= GetNextParamStr (&TextDeviceNode
);
1885 IPv4
= (IPv4_DEVICE_PATH
*) CreateDeviceNode (
1886 MESSAGING_DEVICE_PATH
,
1888 (UINT16
) sizeof (IPv4_DEVICE_PATH
)
1891 StrToIPv4Addr (&RemoteIPStr
, &IPv4
->RemoteIpAddress
);
1892 IPv4
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1893 if (StrCmp (TypeStr
, L
"Static") == 0) {
1894 IPv4
->StaticIpAddress
= TRUE
;
1896 IPv4
->StaticIpAddress
= FALSE
;
1899 StrToIPv4Addr (&LocalIPStr
, &IPv4
->LocalIpAddress
);
1900 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*SubnetMaskStr
)) {
1901 StrToIPv4Addr (&GatewayIPStr
, &IPv4
->GatewayIpAddress
);
1902 StrToIPv4Addr (&SubnetMaskStr
, &IPv4
->SubnetMask
);
1904 ZeroMem (&IPv4
->GatewayIpAddress
, sizeof (IPv4
->GatewayIpAddress
));
1905 ZeroMem (&IPv4
->SubnetMask
, sizeof (IPv4
->SubnetMask
));
1908 IPv4
->LocalPort
= 0;
1909 IPv4
->RemotePort
= 0;
1911 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv4
;
1915 Converts a text device path node to IPV6 device path structure.
1917 @param TextDeviceNode The input Text device path node.
1919 @return A pointer to the newly-created IPV6 device path structure.
1922 EFI_DEVICE_PATH_PROTOCOL
*
1923 DevPathFromTextIPv6 (
1924 IN CHAR16
*TextDeviceNode
1927 CHAR16
*RemoteIPStr
;
1928 CHAR16
*ProtocolStr
;
1931 CHAR16
*GatewayIPStr
;
1932 CHAR16
*PrefixLengthStr
;
1933 IPv6_DEVICE_PATH
*IPv6
;
1935 RemoteIPStr
= GetNextParamStr (&TextDeviceNode
);
1936 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
1937 TypeStr
= GetNextParamStr (&TextDeviceNode
);
1938 LocalIPStr
= GetNextParamStr (&TextDeviceNode
);
1939 PrefixLengthStr
= GetNextParamStr (&TextDeviceNode
);
1940 GatewayIPStr
= GetNextParamStr (&TextDeviceNode
);
1941 IPv6
= (IPv6_DEVICE_PATH
*) CreateDeviceNode (
1942 MESSAGING_DEVICE_PATH
,
1944 (UINT16
) sizeof (IPv6_DEVICE_PATH
)
1947 StrToIPv6Addr (&RemoteIPStr
, &IPv6
->RemoteIpAddress
);
1948 IPv6
->Protocol
= (UINT16
) NetworkProtocolFromText (ProtocolStr
);
1949 if (StrCmp (TypeStr
, L
"Static") == 0) {
1950 IPv6
->IpAddressOrigin
= 0;
1951 } else if (StrCmp (TypeStr
, L
"StatelessAutoConfigure") == 0) {
1952 IPv6
->IpAddressOrigin
= 1;
1954 IPv6
->IpAddressOrigin
= 2;
1957 StrToIPv6Addr (&LocalIPStr
, &IPv6
->LocalIpAddress
);
1958 if (!IS_NULL (*GatewayIPStr
) && !IS_NULL (*PrefixLengthStr
)) {
1959 StrToIPv6Addr (&GatewayIPStr
, &IPv6
->GatewayIpAddress
);
1960 IPv6
->PrefixLength
= (UINT8
) Strtoi (PrefixLengthStr
);
1962 ZeroMem (&IPv6
->GatewayIpAddress
, sizeof (IPv6
->GatewayIpAddress
));
1963 IPv6
->PrefixLength
= 0;
1966 IPv6
->LocalPort
= 0;
1967 IPv6
->RemotePort
= 0;
1969 return (EFI_DEVICE_PATH_PROTOCOL
*) IPv6
;
1973 Converts a text device path node to UART device path structure.
1975 @param TextDeviceNode The input Text device path node.
1977 @return A pointer to the newly-created UART device path structure.
1980 EFI_DEVICE_PATH_PROTOCOL
*
1981 DevPathFromTextUart (
1982 IN CHAR16
*TextDeviceNode
1986 CHAR16
*DataBitsStr
;
1988 CHAR16
*StopBitsStr
;
1989 UART_DEVICE_PATH
*Uart
;
1991 BaudStr
= GetNextParamStr (&TextDeviceNode
);
1992 DataBitsStr
= GetNextParamStr (&TextDeviceNode
);
1993 ParityStr
= GetNextParamStr (&TextDeviceNode
);
1994 StopBitsStr
= GetNextParamStr (&TextDeviceNode
);
1995 Uart
= (UART_DEVICE_PATH
*) CreateDeviceNode (
1996 MESSAGING_DEVICE_PATH
,
1998 (UINT16
) sizeof (UART_DEVICE_PATH
)
2001 if (StrCmp (BaudStr
, L
"DEFAULT") == 0) {
2002 Uart
->BaudRate
= 115200;
2004 Strtoi64 (BaudStr
, &Uart
->BaudRate
);
2006 Uart
->DataBits
= (UINT8
) ((StrCmp (DataBitsStr
, L
"DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr
));
2007 switch (*ParityStr
) {
2033 Uart
->Parity
= (UINT8
) Strtoi (ParityStr
);
2037 if (StrCmp (StopBitsStr
, L
"D") == 0) {
2038 Uart
->StopBits
= (UINT8
) 0;
2039 } else if (StrCmp (StopBitsStr
, L
"1") == 0) {
2040 Uart
->StopBits
= (UINT8
) 1;
2041 } else if (StrCmp (StopBitsStr
, L
"1.5") == 0) {
2042 Uart
->StopBits
= (UINT8
) 2;
2043 } else if (StrCmp (StopBitsStr
, L
"2") == 0) {
2044 Uart
->StopBits
= (UINT8
) 3;
2046 Uart
->StopBits
= (UINT8
) Strtoi (StopBitsStr
);
2049 return (EFI_DEVICE_PATH_PROTOCOL
*) Uart
;
2053 Converts a text device path node to USB class device path structure.
2055 @param TextDeviceNode The input Text device path node.
2056 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
2058 @return A pointer to the newly-created USB class device path structure.
2061 EFI_DEVICE_PATH_PROTOCOL
*
2062 ConvertFromTextUsbClass (
2063 IN CHAR16
*TextDeviceNode
,
2064 IN USB_CLASS_TEXT
*UsbClassText
2070 CHAR16
*SubClassStr
;
2071 CHAR16
*ProtocolStr
;
2072 USB_CLASS_DEVICE_PATH
*UsbClass
;
2074 UsbClass
= (USB_CLASS_DEVICE_PATH
*) CreateDeviceNode (
2075 MESSAGING_DEVICE_PATH
,
2077 (UINT16
) sizeof (USB_CLASS_DEVICE_PATH
)
2080 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2081 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2082 if (UsbClassText
->ClassExist
) {
2083 ClassStr
= GetNextParamStr (&TextDeviceNode
);
2084 UsbClass
->DeviceClass
= (UINT8
) Strtoi (ClassStr
);
2086 UsbClass
->DeviceClass
= UsbClassText
->Class
;
2088 if (UsbClassText
->SubClassExist
) {
2089 SubClassStr
= GetNextParamStr (&TextDeviceNode
);
2090 UsbClass
->DeviceSubClass
= (UINT8
) Strtoi (SubClassStr
);
2092 UsbClass
->DeviceSubClass
= UsbClassText
->SubClass
;
2095 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2097 UsbClass
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2098 UsbClass
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2099 UsbClass
->DeviceProtocol
= (UINT8
) Strtoi (ProtocolStr
);
2101 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbClass
;
2106 Converts a text device path node to USB class device path structure.
2108 @param TextDeviceNode The input Text device path node.
2110 @return A pointer to the newly-created USB class device path structure.
2113 EFI_DEVICE_PATH_PROTOCOL
*
2114 DevPathFromTextUsbClass (
2115 IN CHAR16
*TextDeviceNode
2118 USB_CLASS_TEXT UsbClassText
;
2120 UsbClassText
.ClassExist
= TRUE
;
2121 UsbClassText
.SubClassExist
= TRUE
;
2123 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2127 Converts a text device path node to USB audio device path structure.
2129 @param TextDeviceNode The input Text device path node.
2131 @return A pointer to the newly-created USB audio device path structure.
2134 EFI_DEVICE_PATH_PROTOCOL
*
2135 DevPathFromTextUsbAudio (
2136 IN CHAR16
*TextDeviceNode
2139 USB_CLASS_TEXT UsbClassText
;
2141 UsbClassText
.ClassExist
= FALSE
;
2142 UsbClassText
.Class
= USB_CLASS_AUDIO
;
2143 UsbClassText
.SubClassExist
= TRUE
;
2145 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2149 Converts a text device path node to USB CDC Control device path structure.
2151 @param TextDeviceNode The input Text device path node.
2153 @return A pointer to the newly-created USB CDC Control device path structure.
2156 EFI_DEVICE_PATH_PROTOCOL
*
2157 DevPathFromTextUsbCDCControl (
2158 IN CHAR16
*TextDeviceNode
2161 USB_CLASS_TEXT UsbClassText
;
2163 UsbClassText
.ClassExist
= FALSE
;
2164 UsbClassText
.Class
= USB_CLASS_CDCCONTROL
;
2165 UsbClassText
.SubClassExist
= TRUE
;
2167 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2171 Converts a text device path node to USB HID device path structure.
2173 @param TextDeviceNode The input Text device path node.
2175 @return A pointer to the newly-created USB HID device path structure.
2178 EFI_DEVICE_PATH_PROTOCOL
*
2179 DevPathFromTextUsbHID (
2180 IN CHAR16
*TextDeviceNode
2183 USB_CLASS_TEXT UsbClassText
;
2185 UsbClassText
.ClassExist
= FALSE
;
2186 UsbClassText
.Class
= USB_CLASS_HID
;
2187 UsbClassText
.SubClassExist
= TRUE
;
2189 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2193 Converts a text device path node to USB Image device path structure.
2195 @param TextDeviceNode The input Text device path node.
2197 @return A pointer to the newly-created USB Image device path structure.
2200 EFI_DEVICE_PATH_PROTOCOL
*
2201 DevPathFromTextUsbImage (
2202 IN CHAR16
*TextDeviceNode
2205 USB_CLASS_TEXT UsbClassText
;
2207 UsbClassText
.ClassExist
= FALSE
;
2208 UsbClassText
.Class
= USB_CLASS_IMAGE
;
2209 UsbClassText
.SubClassExist
= TRUE
;
2211 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2215 Converts a text device path node to USB Print device path structure.
2217 @param TextDeviceNode The input Text device path node.
2219 @return A pointer to the newly-created USB Print device path structure.
2222 EFI_DEVICE_PATH_PROTOCOL
*
2223 DevPathFromTextUsbPrinter (
2224 IN CHAR16
*TextDeviceNode
2227 USB_CLASS_TEXT UsbClassText
;
2229 UsbClassText
.ClassExist
= FALSE
;
2230 UsbClassText
.Class
= USB_CLASS_PRINTER
;
2231 UsbClassText
.SubClassExist
= TRUE
;
2233 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2237 Converts a text device path node to USB mass storage device path structure.
2239 @param TextDeviceNode The input Text device path node.
2241 @return A pointer to the newly-created USB mass storage device path structure.
2244 EFI_DEVICE_PATH_PROTOCOL
*
2245 DevPathFromTextUsbMassStorage (
2246 IN CHAR16
*TextDeviceNode
2249 USB_CLASS_TEXT UsbClassText
;
2251 UsbClassText
.ClassExist
= FALSE
;
2252 UsbClassText
.Class
= USB_CLASS_MASS_STORAGE
;
2253 UsbClassText
.SubClassExist
= TRUE
;
2255 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2259 Converts a text device path node to USB HUB device path structure.
2261 @param TextDeviceNode The input Text device path node.
2263 @return A pointer to the newly-created USB HUB device path structure.
2266 EFI_DEVICE_PATH_PROTOCOL
*
2267 DevPathFromTextUsbHub (
2268 IN CHAR16
*TextDeviceNode
2271 USB_CLASS_TEXT UsbClassText
;
2273 UsbClassText
.ClassExist
= FALSE
;
2274 UsbClassText
.Class
= USB_CLASS_HUB
;
2275 UsbClassText
.SubClassExist
= TRUE
;
2277 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2281 Converts a text device path node to USB CDC data device path structure.
2283 @param TextDeviceNode The input Text device path node.
2285 @return A pointer to the newly-created USB CDC data device path structure.
2288 EFI_DEVICE_PATH_PROTOCOL
*
2289 DevPathFromTextUsbCDCData (
2290 IN CHAR16
*TextDeviceNode
2293 USB_CLASS_TEXT UsbClassText
;
2295 UsbClassText
.ClassExist
= FALSE
;
2296 UsbClassText
.Class
= USB_CLASS_CDCDATA
;
2297 UsbClassText
.SubClassExist
= TRUE
;
2299 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2303 Converts a text device path node to USB smart card device path structure.
2305 @param TextDeviceNode The input Text device path node.
2307 @return A pointer to the newly-created USB smart card device path structure.
2310 EFI_DEVICE_PATH_PROTOCOL
*
2311 DevPathFromTextUsbSmartCard (
2312 IN CHAR16
*TextDeviceNode
2315 USB_CLASS_TEXT UsbClassText
;
2317 UsbClassText
.ClassExist
= FALSE
;
2318 UsbClassText
.Class
= USB_CLASS_SMART_CARD
;
2319 UsbClassText
.SubClassExist
= TRUE
;
2321 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2325 Converts a text device path node to USB video device path structure.
2327 @param TextDeviceNode The input Text device path node.
2329 @return A pointer to the newly-created USB video device path structure.
2332 EFI_DEVICE_PATH_PROTOCOL
*
2333 DevPathFromTextUsbVideo (
2334 IN CHAR16
*TextDeviceNode
2337 USB_CLASS_TEXT UsbClassText
;
2339 UsbClassText
.ClassExist
= FALSE
;
2340 UsbClassText
.Class
= USB_CLASS_VIDEO
;
2341 UsbClassText
.SubClassExist
= TRUE
;
2343 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2347 Converts a text device path node to USB diagnostic device path structure.
2349 @param TextDeviceNode The input Text device path node.
2351 @return A pointer to the newly-created USB diagnostic device path structure.
2354 EFI_DEVICE_PATH_PROTOCOL
*
2355 DevPathFromTextUsbDiagnostic (
2356 IN CHAR16
*TextDeviceNode
2359 USB_CLASS_TEXT UsbClassText
;
2361 UsbClassText
.ClassExist
= FALSE
;
2362 UsbClassText
.Class
= USB_CLASS_DIAGNOSTIC
;
2363 UsbClassText
.SubClassExist
= TRUE
;
2365 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2369 Converts a text device path node to USB wireless device path structure.
2371 @param TextDeviceNode The input Text device path node.
2373 @return A pointer to the newly-created USB wireless device path structure.
2376 EFI_DEVICE_PATH_PROTOCOL
*
2377 DevPathFromTextUsbWireless (
2378 IN CHAR16
*TextDeviceNode
2381 USB_CLASS_TEXT UsbClassText
;
2383 UsbClassText
.ClassExist
= FALSE
;
2384 UsbClassText
.Class
= USB_CLASS_WIRELESS
;
2385 UsbClassText
.SubClassExist
= TRUE
;
2387 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2391 Converts a text device path node to USB device firmware update device path structure.
2393 @param TextDeviceNode The input Text device path node.
2395 @return A pointer to the newly-created USB device firmware update device path structure.
2398 EFI_DEVICE_PATH_PROTOCOL
*
2399 DevPathFromTextUsbDeviceFirmwareUpdate (
2400 IN CHAR16
*TextDeviceNode
2403 USB_CLASS_TEXT UsbClassText
;
2405 UsbClassText
.ClassExist
= FALSE
;
2406 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2407 UsbClassText
.SubClassExist
= FALSE
;
2408 UsbClassText
.SubClass
= USB_SUBCLASS_FW_UPDATE
;
2410 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2414 Converts a text device path node to USB IRDA bridge device path structure.
2416 @param TextDeviceNode The input Text device path node.
2418 @return A pointer to the newly-created USB IRDA bridge device path structure.
2421 EFI_DEVICE_PATH_PROTOCOL
*
2422 DevPathFromTextUsbIrdaBridge (
2423 IN CHAR16
*TextDeviceNode
2426 USB_CLASS_TEXT UsbClassText
;
2428 UsbClassText
.ClassExist
= FALSE
;
2429 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2430 UsbClassText
.SubClassExist
= FALSE
;
2431 UsbClassText
.SubClass
= USB_SUBCLASS_IRDA_BRIDGE
;
2433 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2437 Converts a text device path node to USB text and measurement device path structure.
2439 @param TextDeviceNode The input Text device path node.
2441 @return A pointer to the newly-created USB text and measurement device path structure.
2444 EFI_DEVICE_PATH_PROTOCOL
*
2445 DevPathFromTextUsbTestAndMeasurement (
2446 IN CHAR16
*TextDeviceNode
2449 USB_CLASS_TEXT UsbClassText
;
2451 UsbClassText
.ClassExist
= FALSE
;
2452 UsbClassText
.Class
= USB_CLASS_RESERVE
;
2453 UsbClassText
.SubClassExist
= FALSE
;
2454 UsbClassText
.SubClass
= USB_SUBCLASS_TEST
;
2456 return ConvertFromTextUsbClass (TextDeviceNode
, &UsbClassText
);
2460 Converts a text device path node to USB WWID device path structure.
2462 @param TextDeviceNode The input Text device path node.
2464 @return A pointer to the newly-created USB WWID device path structure.
2467 EFI_DEVICE_PATH_PROTOCOL
*
2468 DevPathFromTextUsbWwid (
2469 IN CHAR16
*TextDeviceNode
2474 CHAR16
*InterfaceNumStr
;
2475 CHAR16
*SerialNumberStr
;
2476 USB_WWID_DEVICE_PATH
*UsbWwid
;
2477 UINTN SerialNumberStrLen
;
2479 VIDStr
= GetNextParamStr (&TextDeviceNode
);
2480 PIDStr
= GetNextParamStr (&TextDeviceNode
);
2481 InterfaceNumStr
= GetNextParamStr (&TextDeviceNode
);
2482 SerialNumberStr
= GetNextParamStr (&TextDeviceNode
);
2483 SerialNumberStrLen
= StrLen (SerialNumberStr
);
2484 if (SerialNumberStrLen
>= 2 &&
2485 SerialNumberStr
[0] == L
'\"' &&
2486 SerialNumberStr
[SerialNumberStrLen
- 1] == L
'\"'
2488 SerialNumberStr
[SerialNumberStrLen
- 1] = L
'\0';
2490 SerialNumberStrLen
-= 2;
2492 UsbWwid
= (USB_WWID_DEVICE_PATH
*) CreateDeviceNode (
2493 MESSAGING_DEVICE_PATH
,
2495 (UINT16
) (sizeof (USB_WWID_DEVICE_PATH
) + SerialNumberStrLen
* sizeof (CHAR16
))
2497 UsbWwid
->VendorId
= (UINT16
) Strtoi (VIDStr
);
2498 UsbWwid
->ProductId
= (UINT16
) Strtoi (PIDStr
);
2499 UsbWwid
->InterfaceNumber
= (UINT16
) Strtoi (InterfaceNumStr
);
2500 StrnCpy ((CHAR16
*) ((UINT8
*) UsbWwid
+ sizeof (USB_WWID_DEVICE_PATH
)), SerialNumberStr
, SerialNumberStrLen
);
2502 return (EFI_DEVICE_PATH_PROTOCOL
*) UsbWwid
;
2506 Converts a text device path node to Logic Unit device path structure.
2508 @param TextDeviceNode The input Text device path node.
2510 @return A pointer to the newly-created Logic Unit device path structure.
2513 EFI_DEVICE_PATH_PROTOCOL
*
2514 DevPathFromTextUnit (
2515 IN CHAR16
*TextDeviceNode
2519 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
2521 LunStr
= GetNextParamStr (&TextDeviceNode
);
2522 LogicalUnit
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) CreateDeviceNode (
2523 MESSAGING_DEVICE_PATH
,
2524 MSG_DEVICE_LOGICAL_UNIT_DP
,
2525 (UINT16
) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH
)
2528 LogicalUnit
->Lun
= (UINT8
) Strtoi (LunStr
);
2530 return (EFI_DEVICE_PATH_PROTOCOL
*) LogicalUnit
;
2534 Converts a text device path node to iSCSI device path structure.
2536 @param TextDeviceNode The input Text device path node.
2538 @return A pointer to the newly-created iSCSI device path structure.
2541 EFI_DEVICE_PATH_PROTOCOL
*
2542 DevPathFromTextiSCSI (
2543 IN CHAR16
*TextDeviceNode
2548 CHAR16
*PortalGroupStr
;
2550 CHAR16
*HeaderDigestStr
;
2551 CHAR16
*DataDigestStr
;
2552 CHAR16
*AuthenticationStr
;
2553 CHAR16
*ProtocolStr
;
2555 ISCSI_DEVICE_PATH_WITH_NAME
*ISCSIDevPath
;
2557 NameStr
= GetNextParamStr (&TextDeviceNode
);
2558 PortalGroupStr
= GetNextParamStr (&TextDeviceNode
);
2559 LunStr
= GetNextParamStr (&TextDeviceNode
);
2560 HeaderDigestStr
= GetNextParamStr (&TextDeviceNode
);
2561 DataDigestStr
= GetNextParamStr (&TextDeviceNode
);
2562 AuthenticationStr
= GetNextParamStr (&TextDeviceNode
);
2563 ProtocolStr
= GetNextParamStr (&TextDeviceNode
);
2564 ISCSIDevPath
= (ISCSI_DEVICE_PATH_WITH_NAME
*) CreateDeviceNode (
2565 MESSAGING_DEVICE_PATH
,
2567 (UINT16
) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME
) + StrLen (NameStr
))
2570 AsciiStr
= ISCSIDevPath
->TargetName
;
2571 StrToAscii (NameStr
, &AsciiStr
);
2573 ISCSIDevPath
->TargetPortalGroupTag
= (UINT16
) Strtoi (PortalGroupStr
);
2574 Strtoi64 (LunStr
, &ISCSIDevPath
->Lun
);
2577 if (StrCmp (HeaderDigestStr
, L
"CRC32C") == 0) {
2581 if (StrCmp (DataDigestStr
, L
"CRC32C") == 0) {
2585 if (StrCmp (AuthenticationStr
, L
"None") == 0) {
2589 if (StrCmp (AuthenticationStr
, L
"CHAP_UNI") == 0) {
2593 ISCSIDevPath
->LoginOption
= (UINT16
) Options
;
2595 ISCSIDevPath
->NetworkProtocol
= (UINT16
) StrCmp (ProtocolStr
, L
"TCP");
2597 return (EFI_DEVICE_PATH_PROTOCOL
*) ISCSIDevPath
;
2601 Converts a text device path node to VLAN device path structure.
2603 @param TextDeviceNode The input Text device path node.
2605 @return A pointer to the newly-created VLAN device path structure.
2608 EFI_DEVICE_PATH_PROTOCOL
*
2609 DevPathFromTextVlan (
2610 IN CHAR16
*TextDeviceNode
2614 VLAN_DEVICE_PATH
*Vlan
;
2616 VlanStr
= GetNextParamStr (&TextDeviceNode
);
2617 Vlan
= (VLAN_DEVICE_PATH
*) CreateDeviceNode (
2618 MESSAGING_DEVICE_PATH
,
2620 (UINT16
) sizeof (VLAN_DEVICE_PATH
)
2623 Vlan
->VlanId
= (UINT16
) Strtoi (VlanStr
);
2625 return (EFI_DEVICE_PATH_PROTOCOL
*) Vlan
;
2629 Converts a media text device path node to media device path structure.
2631 @param TextDeviceNode The input Text device path node.
2633 @return A pointer to media device path structure.
2636 EFI_DEVICE_PATH_PROTOCOL
*
2637 DevPathFromTextMediaPath (
2638 IN CHAR16
*TextDeviceNode
2641 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH
, TextDeviceNode
);
2645 Converts a text device path node to HD device path structure.
2647 @param TextDeviceNode The input Text device path node.
2649 @return A pointer to the newly-created HD device path structure.
2652 EFI_DEVICE_PATH_PROTOCOL
*
2654 IN CHAR16
*TextDeviceNode
2657 CHAR16
*PartitionStr
;
2659 CHAR16
*SignatureStr
;
2663 EFI_GUID SignatureGuid
;
2664 HARDDRIVE_DEVICE_PATH
*Hd
;
2666 PartitionStr
= GetNextParamStr (&TextDeviceNode
);
2667 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2668 SignatureStr
= GetNextParamStr (&TextDeviceNode
);
2669 StartStr
= GetNextParamStr (&TextDeviceNode
);
2670 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2671 Hd
= (HARDDRIVE_DEVICE_PATH
*) CreateDeviceNode (
2674 (UINT16
) sizeof (HARDDRIVE_DEVICE_PATH
)
2677 Hd
->PartitionNumber
= (UINT32
) Strtoi (PartitionStr
);
2679 ZeroMem (Hd
->Signature
, 16);
2680 Hd
->MBRType
= (UINT8
) 0;
2682 if (StrCmp (TypeStr
, L
"MBR") == 0) {
2683 Hd
->SignatureType
= SIGNATURE_TYPE_MBR
;
2686 Signature32
= (UINT32
) Strtoi (SignatureStr
);
2687 CopyMem (Hd
->Signature
, &Signature32
, sizeof (UINT32
));
2688 } else if (StrCmp (TypeStr
, L
"GPT") == 0) {
2689 Hd
->SignatureType
= SIGNATURE_TYPE_GUID
;
2692 StrToGuid (SignatureStr
, &SignatureGuid
);
2693 CopyMem (Hd
->Signature
, &SignatureGuid
, sizeof (EFI_GUID
));
2695 Hd
->SignatureType
= (UINT8
) Strtoi (TypeStr
);
2698 Strtoi64 (StartStr
, &Hd
->PartitionStart
);
2699 Strtoi64 (SizeStr
, &Hd
->PartitionSize
);
2701 return (EFI_DEVICE_PATH_PROTOCOL
*) Hd
;
2705 Converts a text device path node to CDROM device path structure.
2707 @param TextDeviceNode The input Text device path node.
2709 @return A pointer to the newly-created CDROM device path structure.
2712 EFI_DEVICE_PATH_PROTOCOL
*
2713 DevPathFromTextCDROM (
2714 IN CHAR16
*TextDeviceNode
2720 CDROM_DEVICE_PATH
*CDROMDevPath
;
2722 EntryStr
= GetNextParamStr (&TextDeviceNode
);
2723 StartStr
= GetNextParamStr (&TextDeviceNode
);
2724 SizeStr
= GetNextParamStr (&TextDeviceNode
);
2725 CDROMDevPath
= (CDROM_DEVICE_PATH
*) CreateDeviceNode (
2728 (UINT16
) sizeof (CDROM_DEVICE_PATH
)
2731 CDROMDevPath
->BootEntry
= (UINT32
) Strtoi (EntryStr
);
2732 Strtoi64 (StartStr
, &CDROMDevPath
->PartitionStart
);
2733 Strtoi64 (SizeStr
, &CDROMDevPath
->PartitionSize
);
2735 return (EFI_DEVICE_PATH_PROTOCOL
*) CDROMDevPath
;
2739 Converts a text device path node to Vendor-defined media device path structure.
2741 @param TextDeviceNode The input Text device path node.
2743 @return A pointer to the newly-created Vendor-defined media device path structure.
2746 EFI_DEVICE_PATH_PROTOCOL
*
2747 DevPathFromTextVenMedia (
2748 IN CHAR16
*TextDeviceNode
2751 return ConvertFromTextVendor (
2759 Converts a text device path node to File device path structure.
2761 @param TextDeviceNode The input Text device path node.
2763 @return A pointer to the newly-created File device path structure.
2766 EFI_DEVICE_PATH_PROTOCOL
*
2767 DevPathFromTextFilePath (
2768 IN CHAR16
*TextDeviceNode
2771 FILEPATH_DEVICE_PATH
*File
;
2773 File
= (FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2776 (UINT16
) (sizeof (FILEPATH_DEVICE_PATH
) + StrLen (TextDeviceNode
) * 2)
2779 StrCpy (File
->PathName
, TextDeviceNode
);
2781 return (EFI_DEVICE_PATH_PROTOCOL
*) File
;
2785 Converts a text device path node to Media protocol device path structure.
2787 @param TextDeviceNode The input Text device path node.
2789 @return A pointer to the newly-created Media protocol device path structure.
2792 EFI_DEVICE_PATH_PROTOCOL
*
2793 DevPathFromTextMedia (
2794 IN CHAR16
*TextDeviceNode
2798 MEDIA_PROTOCOL_DEVICE_PATH
*Media
;
2800 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2801 Media
= (MEDIA_PROTOCOL_DEVICE_PATH
*) CreateDeviceNode (
2804 (UINT16
) sizeof (MEDIA_PROTOCOL_DEVICE_PATH
)
2807 StrToGuid (GuidStr
, &Media
->Protocol
);
2809 return (EFI_DEVICE_PATH_PROTOCOL
*) Media
;
2813 Converts a text device path node to firmware volume device path structure.
2815 @param TextDeviceNode The input Text device path node.
2817 @return A pointer to the newly-created firmware volume device path structure.
2820 EFI_DEVICE_PATH_PROTOCOL
*
2822 IN CHAR16
*TextDeviceNode
2826 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
2828 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2829 Fv
= (MEDIA_FW_VOL_DEVICE_PATH
*) CreateDeviceNode (
2831 MEDIA_PIWG_FW_VOL_DP
,
2832 (UINT16
) sizeof (MEDIA_FW_VOL_DEVICE_PATH
)
2835 StrToGuid (GuidStr
, &Fv
->FvName
);
2837 return (EFI_DEVICE_PATH_PROTOCOL
*) Fv
;
2841 Converts a text device path node to firmware file device path structure.
2843 @param TextDeviceNode The input Text device path node.
2845 @return A pointer to the newly-created firmware file device path structure.
2848 EFI_DEVICE_PATH_PROTOCOL
*
2849 DevPathFromTextFvFile (
2850 IN CHAR16
*TextDeviceNode
2854 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
2856 GuidStr
= GetNextParamStr (&TextDeviceNode
);
2857 FvFile
= (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*) CreateDeviceNode (
2859 MEDIA_PIWG_FW_FILE_DP
,
2860 (UINT16
) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
)
2863 StrToGuid (GuidStr
, &FvFile
->FvFileName
);
2865 return (EFI_DEVICE_PATH_PROTOCOL
*) FvFile
;
2869 Converts a text device path node to text relative offset device path structure.
2871 @param TextDeviceNode The input Text device path node.
2873 @return A pointer to the newly-created Text device path structure.
2876 EFI_DEVICE_PATH_PROTOCOL
*
2877 DevPathFromTextRelativeOffsetRange (
2878 IN CHAR16
*TextDeviceNode
2881 CHAR16
*StartingOffsetStr
;
2882 CHAR16
*EndingOffsetStr
;
2883 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*Offset
;
2885 StartingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2886 EndingOffsetStr
= GetNextParamStr (&TextDeviceNode
);
2887 Offset
= (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
*) CreateDeviceNode (
2889 MEDIA_RELATIVE_OFFSET_RANGE_DP
,
2890 (UINT16
) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
)
2893 Strtoi64 (StartingOffsetStr
, &Offset
->StartingOffset
);
2894 Strtoi64 (EndingOffsetStr
, &Offset
->EndingOffset
);
2896 return (EFI_DEVICE_PATH_PROTOCOL
*) Offset
;
2901 Converts a BBS text device path node to BBS device path structure.
2903 @param TextDeviceNode The input Text device path node.
2905 @return A pointer to BBS device path structure.
2908 EFI_DEVICE_PATH_PROTOCOL
*
2909 DevPathFromTextBbsPath (
2910 IN CHAR16
*TextDeviceNode
2913 return DevPathFromTextGenericPath (BBS_DEVICE_PATH
, TextDeviceNode
);
2917 Converts a text device path node to BIOS Boot Specification device path structure.
2919 @param TextDeviceNode The input Text device path node.
2921 @return A pointer to the newly-created BIOS Boot Specification device path structure.
2924 EFI_DEVICE_PATH_PROTOCOL
*
2925 DevPathFromTextBBS (
2926 IN CHAR16
*TextDeviceNode
2933 BBS_BBS_DEVICE_PATH
*Bbs
;
2935 TypeStr
= GetNextParamStr (&TextDeviceNode
);
2936 IdStr
= GetNextParamStr (&TextDeviceNode
);
2937 FlagsStr
= GetNextParamStr (&TextDeviceNode
);
2938 Bbs
= (BBS_BBS_DEVICE_PATH
*) CreateDeviceNode (
2941 (UINT16
) (sizeof (BBS_BBS_DEVICE_PATH
) + StrLen (IdStr
))
2944 if (StrCmp (TypeStr
, L
"Floppy") == 0) {
2945 Bbs
->DeviceType
= BBS_TYPE_FLOPPY
;
2946 } else if (StrCmp (TypeStr
, L
"HD") == 0) {
2947 Bbs
->DeviceType
= BBS_TYPE_HARDDRIVE
;
2948 } else if (StrCmp (TypeStr
, L
"CDROM") == 0) {
2949 Bbs
->DeviceType
= BBS_TYPE_CDROM
;
2950 } else if (StrCmp (TypeStr
, L
"PCMCIA") == 0) {
2951 Bbs
->DeviceType
= BBS_TYPE_PCMCIA
;
2952 } else if (StrCmp (TypeStr
, L
"USB") == 0) {
2953 Bbs
->DeviceType
= BBS_TYPE_USB
;
2954 } else if (StrCmp (TypeStr
, L
"Network") == 0) {
2955 Bbs
->DeviceType
= BBS_TYPE_EMBEDDED_NETWORK
;
2957 Bbs
->DeviceType
= (UINT16
) Strtoi (TypeStr
);
2960 AsciiStr
= Bbs
->String
;
2961 StrToAscii (IdStr
, &AsciiStr
);
2963 Bbs
->StatusFlag
= (UINT16
) Strtoi (FlagsStr
);
2965 return (EFI_DEVICE_PATH_PROTOCOL
*) Bbs
;
2969 Converts a text device path node to SATA device path structure.
2971 @param TextDeviceNode The input Text device path node.
2973 @return A pointer to the newly-created SATA device path structure.
2976 EFI_DEVICE_PATH_PROTOCOL
*
2977 DevPathFromTextSata (
2978 IN CHAR16
*TextDeviceNode
2981 SATA_DEVICE_PATH
*Sata
;
2986 Param1
= GetNextParamStr (&TextDeviceNode
);
2987 Param2
= GetNextParamStr (&TextDeviceNode
);
2988 Param3
= GetNextParamStr (&TextDeviceNode
);
2990 Sata
= (SATA_DEVICE_PATH
*) CreateDeviceNode (
2991 MESSAGING_DEVICE_PATH
,
2993 (UINT16
) sizeof (SATA_DEVICE_PATH
)
2995 Sata
->HBAPortNumber
= (UINT16
) Strtoi (Param1
);
2996 Sata
->PortMultiplierPortNumber
= (UINT16
) Strtoi (Param2
);
2997 Sata
->Lun
= (UINT16
) Strtoi (Param3
);
2999 return (EFI_DEVICE_PATH_PROTOCOL
*) Sata
;
3002 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable
[] = {
3003 {L
"Path", DevPathFromTextPath
},
3005 {L
"HardwarePath", DevPathFromTextHardwarePath
},
3006 {L
"Pci", DevPathFromTextPci
},
3007 {L
"PcCard", DevPathFromTextPcCard
},
3008 {L
"MemoryMapped", DevPathFromTextMemoryMapped
},
3009 {L
"VenHw", DevPathFromTextVenHw
},
3010 {L
"Ctrl", DevPathFromTextCtrl
},
3012 {L
"AcpiPath", DevPathFromTextAcpiPath
},
3013 {L
"Acpi", DevPathFromTextAcpi
},
3014 {L
"PciRoot", DevPathFromTextPciRoot
},
3015 {L
"PcieRoot", DevPathFromTextPcieRoot
},
3016 {L
"Floppy", DevPathFromTextFloppy
},
3017 {L
"Keyboard", DevPathFromTextKeyboard
},
3018 {L
"Serial", DevPathFromTextSerial
},
3019 {L
"ParallelPort", DevPathFromTextParallelPort
},
3020 {L
"AcpiEx", DevPathFromTextAcpiEx
},
3021 {L
"AcpiExp", DevPathFromTextAcpiExp
},
3022 {L
"AcpiAdr", DevPathFromTextAcpiAdr
},
3024 {L
"Msg", DevPathFromTextMsg
},
3025 {L
"Ata", DevPathFromTextAta
},
3026 {L
"Scsi", DevPathFromTextScsi
},
3027 {L
"Fibre", DevPathFromTextFibre
},
3028 {L
"FibreEx", DevPathFromTextFibreEx
},
3029 {L
"I1394", DevPathFromText1394
},
3030 {L
"USB", DevPathFromTextUsb
},
3031 {L
"I2O", DevPathFromTextI2O
},
3032 {L
"Infiniband", DevPathFromTextInfiniband
},
3033 {L
"VenMsg", DevPathFromTextVenMsg
},
3034 {L
"VenPcAnsi", DevPathFromTextVenPcAnsi
},
3035 {L
"VenVt100", DevPathFromTextVenVt100
},
3036 {L
"VenVt100Plus", DevPathFromTextVenVt100Plus
},
3037 {L
"VenUtf8", DevPathFromTextVenUtf8
},
3038 {L
"UartFlowCtrl", DevPathFromTextUartFlowCtrl
},
3039 {L
"SAS", DevPathFromTextSAS
},
3040 {L
"SasEx", DevPathFromTextSasEx
},
3041 {L
"DebugPort", DevPathFromTextDebugPort
},
3042 {L
"MAC", DevPathFromTextMAC
},
3043 {L
"IPv4", DevPathFromTextIPv4
},
3044 {L
"IPv6", DevPathFromTextIPv6
},
3045 {L
"Uart", DevPathFromTextUart
},
3046 {L
"UsbClass", DevPathFromTextUsbClass
},
3047 {L
"UsbAudio", DevPathFromTextUsbAudio
},
3048 {L
"UsbCDCControl", DevPathFromTextUsbCDCControl
},
3049 {L
"UsbHID", DevPathFromTextUsbHID
},
3050 {L
"UsbImage", DevPathFromTextUsbImage
},
3051 {L
"UsbPrinter", DevPathFromTextUsbPrinter
},
3052 {L
"UsbMassStorage", DevPathFromTextUsbMassStorage
},
3053 {L
"UsbHub", DevPathFromTextUsbHub
},
3054 {L
"UsbCDCData", DevPathFromTextUsbCDCData
},
3055 {L
"UsbSmartCard", DevPathFromTextUsbSmartCard
},
3056 {L
"UsbVideo", DevPathFromTextUsbVideo
},
3057 {L
"UsbDiagnostic", DevPathFromTextUsbDiagnostic
},
3058 {L
"UsbWireless", DevPathFromTextUsbWireless
},
3059 {L
"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate
},
3060 {L
"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge
},
3061 {L
"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement
},
3062 {L
"UsbWwid", DevPathFromTextUsbWwid
},
3063 {L
"Unit", DevPathFromTextUnit
},
3064 {L
"iSCSI", DevPathFromTextiSCSI
},
3065 {L
"Vlan", DevPathFromTextVlan
},
3067 {L
"MediaPath", DevPathFromTextMediaPath
},
3068 {L
"HD", DevPathFromTextHD
},
3069 {L
"CDROM", DevPathFromTextCDROM
},
3070 {L
"VenMedia", DevPathFromTextVenMedia
},
3071 {L
"Media", DevPathFromTextMedia
},
3072 {L
"Fv", DevPathFromTextFv
},
3073 {L
"FvFile", DevPathFromTextFvFile
},
3074 {L
"Offset", DevPathFromTextRelativeOffsetRange
},
3076 {L
"BbsPath", DevPathFromTextBbsPath
},
3077 {L
"BBS", DevPathFromTextBBS
},
3078 {L
"Sata", DevPathFromTextSata
},
3083 Convert text to the binary representation of a device node.
3085 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3086 node. Conversion starts with the first character and continues
3087 until the first non-device node character.
3089 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3090 insufficient memory or text unsupported.
3093 EFI_DEVICE_PATH_PROTOCOL
*
3095 UefiDevicePathLibConvertTextToDeviceNode (
3096 IN CONST CHAR16
*TextDeviceNode
3099 DEVICE_PATH_FROM_TEXT FromText
;
3101 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3102 CHAR16
*DeviceNodeStr
;
3105 if ((TextDeviceNode
== NULL
) || (IS_NULL (*TextDeviceNode
))) {
3111 DeviceNodeStr
= UefiDevicePathLibStrDuplicate (TextDeviceNode
);
3112 ASSERT (DeviceNodeStr
!= NULL
);
3114 for (Index
= 0; mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
!= NULL
; Index
++) {
3115 ParamStr
= GetParamByNodeName (DeviceNodeStr
, mUefiDevicePathLibDevPathFromTextTable
[Index
].DevicePathNodeText
);
3116 if (ParamStr
!= NULL
) {
3117 FromText
= mUefiDevicePathLibDevPathFromTextTable
[Index
].Function
;
3122 if (FromText
== NULL
) {
3126 FromText
= DevPathFromTextFilePath
;
3127 DeviceNode
= FromText (DeviceNodeStr
);
3129 DeviceNode
= FromText (ParamStr
);
3130 FreePool (ParamStr
);
3133 FreePool (DeviceNodeStr
);
3139 Convert text to the binary representation of a device path.
3142 @param TextDevicePath TextDevicePath points to the text representation of a device
3143 path. Conversion starts with the first character and continues
3144 until the first non-device node character.
3146 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3147 there was insufficient memory.
3150 EFI_DEVICE_PATH_PROTOCOL
*
3152 UefiDevicePathLibConvertTextToDevicePath (
3153 IN CONST CHAR16
*TextDevicePath
3156 EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
;
3157 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
3158 CHAR16
*DevicePathStr
;
3160 CHAR16
*DeviceNodeStr
;
3161 BOOLEAN IsInstanceEnd
;
3162 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3164 if ((TextDevicePath
== NULL
) || (IS_NULL (*TextDevicePath
))) {
3168 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3169 ASSERT (DevicePath
!= NULL
);
3170 SetDevicePathEndNode (DevicePath
);
3172 DevicePathStr
= UefiDevicePathLibStrDuplicate (TextDevicePath
);
3174 Str
= DevicePathStr
;
3175 while ((DeviceNodeStr
= GetNextDeviceNodeStr (&Str
, &IsInstanceEnd
)) != NULL
) {
3176 DeviceNode
= UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr
);
3178 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3179 FreePool (DevicePath
);
3180 FreePool (DeviceNode
);
3181 DevicePath
= NewDevicePath
;
3183 if (IsInstanceEnd
) {
3184 DeviceNode
= (EFI_DEVICE_PATH_PROTOCOL
*) AllocatePool (END_DEVICE_PATH_LENGTH
);
3185 ASSERT (DeviceNode
!= NULL
);
3186 SetDevicePathEndNode (DeviceNode
);
3188 NewDevicePath
= AppendDevicePathNode (DevicePath
, DeviceNode
);
3189 FreePool (DevicePath
);
3190 FreePool (DeviceNode
);
3191 DevicePath
= NewDevicePath
;
3195 FreePool (DevicePathStr
);