2 * Copyright (c) 2017 Netflix, Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * Routines to format EFI_DEVICE_PATHs from the UEFI standard. Much of
28 * this file is taken from EDK2 and rototilled.
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
42 #include "efi-osdep.h"
43 #include "efivar-dp.h"
45 #include "uefi-dplib.h"
47 /* XXX STUBS -- this stuff doesn't work yet */
48 #define StrToIpv4Address(str, unk, ipv4ptr, unk2)
49 #define StrToIpv6Address(str, unk, ipv6ptr, unk2)
52 * OK. Now this is evil. Can't typedef it again. Sure beats changing them all.
53 * Since we're doing it all as narrow characters since wchar_t can't be used on
54 * FreeBSD and CHAR16 strings generally aren't a good fit. Since this parsing
55 * doesn't need Unicode for anything, this works out well.
60 * Taken from MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
61 * hash a11928f3310518ab1c6fd34e8d0fdbb72de9602c 2017-Mar-01
65 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
67 Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>
68 This program and the accompanying materials
69 are licensed and made available under the terms and conditions of the BSD License
70 which accompanies this distribution. The full text of the license may be found at
71 http://opensource.org/licenses/bsd-license.php
73 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
74 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
78 // #include "UefiDevicePathLib.h"
84 @param Src Source string.
86 @return The duplicated string.
91 UefiDevicePathLibStrDuplicate (
95 return AllocateCopyPool (StrSize (Src), Src);
100 Get parameter in a pair of parentheses follow the given node name.
101 For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".
103 @param Str Device Path Text.
104 @param NodeName Name of the node.
106 @return Parameter text for the node.
113 IN const CHAR16 *NodeName
118 UINTN NodeNameLength;
119 UINTN ParameterLength;
122 // Check whether the node name matchs
124 NodeNameLength = StrLen (NodeName);
125 if (StrnCmp (Str, NodeName, NodeNameLength) != 0) {
129 ParamStr = Str + NodeNameLength;
130 if (!IS_LEFT_PARENTH (*ParamStr)) {
135 // Skip the found '(' and find first occurrence of ')'
139 StrPointer = ParamStr;
140 while (!IS_NULL (*StrPointer)) {
141 if (IS_RIGHT_PARENTH (*StrPointer)) {
147 if (IS_NULL (*StrPointer)) {
154 ParamStr = AllocateCopyPool ((ParameterLength + 1) * sizeof (CHAR16), ParamStr);
155 if (ParamStr == NULL) {
159 // Terminate the parameter string
161 ParamStr[ParameterLength] = '\0';
167 Gets current sub-string from a string list, before return
168 the list header is moved to next sub-string. The sub-string is separated
169 by the specified character. For example, the separator is ',', the string
170 list is "2,0,3", it returns "2", the remain list move to "0,3"
172 @param List A string list separated by the specified separator
173 @param Separator The separator character
175 @return A pointer to the current sub-string
181 IN OUT CHAR16 **List,
191 if (IS_NULL (*Str)) {
196 // Find first occurrence of the separator
198 while (!IS_NULL (*Str)) {
199 if (*Str == Separator) {
205 if (*Str == Separator) {
207 // Find a sub-string, terminate it
214 // Move to next sub-string
222 Gets the next parameter string from the list.
224 @param List A string list separated by the specified separator
226 @return A pointer to the current sub-string
236 // The separator is comma
238 return SplitStr (List, ',');
242 Get one device node from entire device path text.
244 @param DevicePath On input, the current Device Path node; on output, the next device path node
245 @param IsInstanceEnd This node is the end of a device path instance
247 @return A device node text or NULL if no more device node available
252 GetNextDeviceNodeStr (
253 IN OUT CHAR16 **DevicePath,
254 OUT BOOLEAN *IsInstanceEnd
259 UINTN ParenthesesStack;
262 if (IS_NULL (*Str)) {
267 // Skip the leading '/', '(', ')' and ','
269 while (!IS_NULL (*Str)) {
270 if (!IS_SLASH (*Str) &&
272 !IS_LEFT_PARENTH (*Str) &&
273 !IS_RIGHT_PARENTH (*Str)) {
282 // Scan for the separator of this device node, '/' or ','
284 ParenthesesStack = 0;
285 while (!IS_NULL (*Str)) {
286 if ((IS_COMMA (*Str) || IS_SLASH (*Str)) && (ParenthesesStack == 0)) {
290 if (IS_LEFT_PARENTH (*Str)) {
292 } else if (IS_RIGHT_PARENTH (*Str)) {
299 if (ParenthesesStack != 0) {
301 // The '(' doesn't pair with ')', invalid device path text
306 if (IS_COMMA (*Str)) {
307 *IsInstanceEnd = TRUE;
311 *IsInstanceEnd = FALSE;
312 if (!IS_NULL (*Str)) {
326 Return whether the integer string is a hex string.
328 @param Str The integer string
330 @retval TRUE Hex string
331 @retval FALSE Decimal string
341 // skip preceeding white space
343 while ((*Str != 0) && *Str == ' ') {
347 // skip preceeding zeros
349 while ((*Str != 0) && *Str == '0') {
353 return (BOOLEAN) (*Str == 'x' || *Str == 'X');
358 Convert integer string to uint.
360 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
362 @return A UINTN value represented by Str
371 if (IsHexStr (Str)) {
372 return StrHexToUintn (Str);
374 return StrDecimalToUintn (Str);
380 Convert integer string to 64 bit data.
382 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
383 @param Data A pointer to the UINT64 value represented by Str
393 if (IsHexStr (Str)) {
394 *Data = StrHexToUint64 (Str);
396 *Data = StrDecimalToUint64 (Str);
402 Converts a Unicode string to ASCII string.
404 @param Str The equivalent Unicode string
405 @param AsciiStr On input, it points to destination ASCII string buffer; on output, it points
406 to the next ASCII string next to it
413 IN OUT CHAR8 **AsciiStr
419 while (!IS_NULL (*Str)) {
420 *(Dest++) = (CHAR8) *(Str++);
425 // Return the string next to it
427 *AsciiStr = Dest + 1;
431 Converts a generic text device path node to device path structure.
433 @param Type The type of the device path node.
434 @param TextDeviceNode The input text device path node.
436 @return A pointer to device path structure.
439 EFI_DEVICE_PATH_PROTOCOL *
440 DevPathFromTextGenericPath (
442 IN CHAR16 *TextDeviceNode
445 EFI_DEVICE_PATH_PROTOCOL *Node;
450 SubtypeStr = GetNextParamStr (&TextDeviceNode);
451 DataStr = GetNextParamStr (&TextDeviceNode);
453 if (DataStr == NULL) {
456 DataLength = StrLen (DataStr) / 2;
458 Node = CreateDeviceNode (
460 (UINT8) Strtoi (SubtypeStr),
461 (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)
464 StrHexToBytes (DataStr, DataLength * 2, (UINT8 *) (Node + 1), DataLength);
469 Converts a generic text device path node to device path structure.
471 @param TextDeviceNode The input Text device path node.
473 @return A pointer to device path structure.
477 EFI_DEVICE_PATH_PROTOCOL *
478 DevPathFromTextPath (
479 IN CHAR16 *TextDeviceNode
484 TypeStr = GetNextParamStr (&TextDeviceNode);
486 return DevPathFromTextGenericPath ((UINT8) Strtoi (TypeStr), TextDeviceNode);
490 Converts a generic hardware text device path node to Hardware device path structure.
492 @param TextDeviceNode The input Text device path node.
494 @return A pointer to Hardware device path structure.
498 EFI_DEVICE_PATH_PROTOCOL *
499 DevPathFromTextHardwarePath (
500 IN CHAR16 *TextDeviceNode
503 return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH, TextDeviceNode);
507 Converts a text device path node to Hardware PCI device path structure.
509 @param TextDeviceNode The input Text device path node.
511 @return A pointer to Hardware PCI device path structure.
515 EFI_DEVICE_PATH_PROTOCOL *
517 IN CHAR16 *TextDeviceNode
522 PCI_DEVICE_PATH *Pci;
524 DeviceStr = GetNextParamStr (&TextDeviceNode);
525 FunctionStr = GetNextParamStr (&TextDeviceNode);
526 Pci = (PCI_DEVICE_PATH *) CreateDeviceNode (
527 HARDWARE_DEVICE_PATH,
529 (UINT16) sizeof (PCI_DEVICE_PATH)
532 Pci->Function = (UINT8) Strtoi (FunctionStr);
533 Pci->Device = (UINT8) Strtoi (DeviceStr);
535 return (EFI_DEVICE_PATH_PROTOCOL *) Pci;
539 Converts a text device path node to Hardware PC card device path structure.
541 @param TextDeviceNode The input Text device path node.
543 @return A pointer to Hardware PC card device path structure.
547 EFI_DEVICE_PATH_PROTOCOL *
548 DevPathFromTextPcCard (
549 IN CHAR16 *TextDeviceNode
552 CHAR16 *FunctionNumberStr;
553 PCCARD_DEVICE_PATH *Pccard;
555 FunctionNumberStr = GetNextParamStr (&TextDeviceNode);
556 Pccard = (PCCARD_DEVICE_PATH *) CreateDeviceNode (
557 HARDWARE_DEVICE_PATH,
559 (UINT16) sizeof (PCCARD_DEVICE_PATH)
562 Pccard->FunctionNumber = (UINT8) Strtoi (FunctionNumberStr);
564 return (EFI_DEVICE_PATH_PROTOCOL *) Pccard;
568 Converts a text device path node to Hardware memory map device path structure.
570 @param TextDeviceNode The input Text device path node.
572 @return A pointer to Hardware memory map device path structure.
576 EFI_DEVICE_PATH_PROTOCOL *
577 DevPathFromTextMemoryMapped (
578 IN CHAR16 *TextDeviceNode
581 CHAR16 *MemoryTypeStr;
582 CHAR16 *StartingAddressStr;
583 CHAR16 *EndingAddressStr;
584 MEMMAP_DEVICE_PATH *MemMap;
586 MemoryTypeStr = GetNextParamStr (&TextDeviceNode);
587 StartingAddressStr = GetNextParamStr (&TextDeviceNode);
588 EndingAddressStr = GetNextParamStr (&TextDeviceNode);
589 MemMap = (MEMMAP_DEVICE_PATH *) CreateDeviceNode (
590 HARDWARE_DEVICE_PATH,
592 (UINT16) sizeof (MEMMAP_DEVICE_PATH)
595 MemMap->MemoryType = (UINT32) Strtoi (MemoryTypeStr);
596 Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);
597 Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);
599 return (EFI_DEVICE_PATH_PROTOCOL *) MemMap;
603 Converts a text device path node to Vendor device path structure based on the input Type
606 @param TextDeviceNode The input Text device path node.
607 @param Type The type of device path node.
608 @param SubType The subtype of device path node.
610 @return A pointer to the newly-created Vendor device path structure.
614 EFI_DEVICE_PATH_PROTOCOL *
615 ConvertFromTextVendor (
616 IN CHAR16 *TextDeviceNode,
624 VENDOR_DEVICE_PATH *Vendor;
626 GuidStr = GetNextParamStr (&TextDeviceNode);
628 DataStr = GetNextParamStr (&TextDeviceNode);
629 Length = StrLen (DataStr);
631 // Two hex characters make up 1 buffer byte
633 Length = (Length + 1) / 2;
635 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
638 (UINT16) (sizeof (VENDOR_DEVICE_PATH) + Length)
641 StrToGuid (GuidStr, &Vendor->Guid);
642 StrHexToBytes (DataStr, Length * 2, (UINT8 *) (Vendor + 1), Length);
644 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
648 Converts a text device path node to Vendor Hardware device path structure.
650 @param TextDeviceNode The input Text device path node.
652 @return A pointer to the newly-created Vendor Hardware device path structure.
656 EFI_DEVICE_PATH_PROTOCOL *
657 DevPathFromTextVenHw (
658 IN CHAR16 *TextDeviceNode
661 return ConvertFromTextVendor (
663 HARDWARE_DEVICE_PATH,
669 Converts a text device path node to Hardware Controller device path structure.
671 @param TextDeviceNode The input Text device path node.
673 @return A pointer to the newly-created Hardware Controller device path structure.
677 EFI_DEVICE_PATH_PROTOCOL *
678 DevPathFromTextCtrl (
679 IN CHAR16 *TextDeviceNode
682 CHAR16 *ControllerStr;
683 CONTROLLER_DEVICE_PATH *Controller;
685 ControllerStr = GetNextParamStr (&TextDeviceNode);
686 Controller = (CONTROLLER_DEVICE_PATH *) CreateDeviceNode (
687 HARDWARE_DEVICE_PATH,
689 (UINT16) sizeof (CONTROLLER_DEVICE_PATH)
691 Controller->ControllerNumber = (UINT32) Strtoi (ControllerStr);
693 return (EFI_DEVICE_PATH_PROTOCOL *) Controller;
697 Converts a text device path node to BMC device path structure.
699 @param TextDeviceNode The input Text device path node.
701 @return A pointer to the newly-created BMC device path structure.
705 EFI_DEVICE_PATH_PROTOCOL *
707 IN CHAR16 *TextDeviceNode
710 CHAR16 *InterfaceTypeStr;
711 CHAR16 *BaseAddressStr;
712 BMC_DEVICE_PATH *BmcDp;
714 InterfaceTypeStr = GetNextParamStr (&TextDeviceNode);
715 BaseAddressStr = GetNextParamStr (&TextDeviceNode);
716 BmcDp = (BMC_DEVICE_PATH *) CreateDeviceNode (
717 HARDWARE_DEVICE_PATH,
719 (UINT16) sizeof (BMC_DEVICE_PATH)
722 BmcDp->InterfaceType = (UINT8) Strtoi (InterfaceTypeStr);
724 (UINT64 *) (&BmcDp->BaseAddress),
725 StrHexToUint64 (BaseAddressStr)
728 return (EFI_DEVICE_PATH_PROTOCOL *) BmcDp;
732 Converts a generic ACPI text device path node to ACPI device path structure.
734 @param TextDeviceNode The input Text device path node.
736 @return A pointer to ACPI device path structure.
740 EFI_DEVICE_PATH_PROTOCOL *
741 DevPathFromTextAcpiPath (
742 IN CHAR16 *TextDeviceNode
745 return DevPathFromTextGenericPath (ACPI_DEVICE_PATH, TextDeviceNode);
749 Converts a string to EisaId.
751 @param Text The input string.
753 @return UINT32 EISA ID.
761 return (((Text[0] - 'A' + 1) & 0x1f) << 10)
762 + (((Text[1] - 'A' + 1) & 0x1f) << 5)
763 + (((Text[2] - 'A' + 1) & 0x1f) << 0)
764 + (UINT32) (StrHexToUintn (&Text[3]) << 16)
769 Converts a text device path node to ACPI HID device path structure.
771 @param TextDeviceNode The input Text device path node.
773 @return A pointer to the newly-created ACPI HID device path structure.
777 EFI_DEVICE_PATH_PROTOCOL *
778 DevPathFromTextAcpi (
779 IN CHAR16 *TextDeviceNode
784 ACPI_HID_DEVICE_PATH *Acpi;
786 HIDStr = GetNextParamStr (&TextDeviceNode);
787 UIDStr = GetNextParamStr (&TextDeviceNode);
788 Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (
791 (UINT16) sizeof (ACPI_HID_DEVICE_PATH)
794 Acpi->HID = EisaIdFromText (HIDStr);
795 Acpi->UID = (UINT32) Strtoi (UIDStr);
797 return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;
801 Converts a text device path node to ACPI HID device path structure.
803 @param TextDeviceNode The input Text device path node.
804 @param PnPId The input plug and play identification.
806 @return A pointer to the newly-created ACPI HID device path structure.
810 EFI_DEVICE_PATH_PROTOCOL *
811 ConvertFromTextAcpi (
812 IN CHAR16 *TextDeviceNode,
817 ACPI_HID_DEVICE_PATH *Acpi;
819 UIDStr = GetNextParamStr (&TextDeviceNode);
820 Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (
823 (UINT16) sizeof (ACPI_HID_DEVICE_PATH)
826 Acpi->HID = EFI_PNP_ID (PnPId);
827 Acpi->UID = (UINT32) Strtoi (UIDStr);
829 return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;
833 Converts a text device path node to PCI root device path structure.
835 @param TextDeviceNode The input Text device path node.
837 @return A pointer to the newly-created PCI root device path structure.
841 EFI_DEVICE_PATH_PROTOCOL *
842 DevPathFromTextPciRoot (
843 IN CHAR16 *TextDeviceNode
846 return ConvertFromTextAcpi (TextDeviceNode, 0x0a03);
850 Converts a text device path node to PCIE root device path structure.
852 @param TextDeviceNode The input Text device path node.
854 @return A pointer to the newly-created PCIE root device path structure.
858 EFI_DEVICE_PATH_PROTOCOL *
859 DevPathFromTextPcieRoot (
860 IN CHAR16 *TextDeviceNode
863 return ConvertFromTextAcpi (TextDeviceNode, 0x0a08);
867 Converts a text device path node to Floppy device path structure.
869 @param TextDeviceNode The input Text device path node.
871 @return A pointer to the newly-created Floppy device path structure.
875 EFI_DEVICE_PATH_PROTOCOL *
876 DevPathFromTextFloppy (
877 IN CHAR16 *TextDeviceNode
880 return ConvertFromTextAcpi (TextDeviceNode, 0x0604);
884 Converts a text device path node to Keyboard device path structure.
886 @param TextDeviceNode The input Text device path node.
888 @return A pointer to the newly-created Keyboard device path structure.
892 EFI_DEVICE_PATH_PROTOCOL *
893 DevPathFromTextKeyboard (
894 IN CHAR16 *TextDeviceNode
897 return ConvertFromTextAcpi (TextDeviceNode, 0x0301);
901 Converts a text device path node to Serial device path structure.
903 @param TextDeviceNode The input Text device path node.
905 @return A pointer to the newly-created Serial device path structure.
909 EFI_DEVICE_PATH_PROTOCOL *
910 DevPathFromTextSerial (
911 IN CHAR16 *TextDeviceNode
914 return ConvertFromTextAcpi (TextDeviceNode, 0x0501);
918 Converts a text device path node to Parallel Port device path structure.
920 @param TextDeviceNode The input Text device path node.
922 @return A pointer to the newly-created Parallel Port device path structure.
926 EFI_DEVICE_PATH_PROTOCOL *
927 DevPathFromTextParallelPort (
928 IN CHAR16 *TextDeviceNode
931 return ConvertFromTextAcpi (TextDeviceNode, 0x0401);
935 Converts a text device path node to ACPI extension device path structure.
937 @param TextDeviceNode The input Text device path node.
939 @return A pointer to the newly-created ACPI extension device path structure.
943 EFI_DEVICE_PATH_PROTOCOL *
944 DevPathFromTextAcpiEx (
945 IN CHAR16 *TextDeviceNode
956 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;
958 HIDStr = GetNextParamStr (&TextDeviceNode);
959 CIDStr = GetNextParamStr (&TextDeviceNode);
960 UIDStr = GetNextParamStr (&TextDeviceNode);
961 HIDSTRStr = GetNextParamStr (&TextDeviceNode);
962 CIDSTRStr = GetNextParamStr (&TextDeviceNode);
963 UIDSTRStr = GetNextParamStr (&TextDeviceNode);
965 Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (HIDSTRStr) + 1);
966 Length = (UINT16) (Length + StrLen (UIDSTRStr) + 1);
967 Length = (UINT16) (Length + StrLen (CIDSTRStr) + 1);
968 AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (
974 AcpiEx->HID = EisaIdFromText (HIDStr);
975 AcpiEx->CID = EisaIdFromText (CIDStr);
976 AcpiEx->UID = (UINT32) Strtoi (UIDStr);
978 AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
979 StrToAscii (HIDSTRStr, &AsciiStr);
980 StrToAscii (UIDSTRStr, &AsciiStr);
981 StrToAscii (CIDSTRStr, &AsciiStr);
983 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;
987 Converts a text device path node to ACPI extension device path structure.
989 @param TextDeviceNode The input Text device path node.
991 @return A pointer to the newly-created ACPI extension device path structure.
995 EFI_DEVICE_PATH_PROTOCOL *
996 DevPathFromTextAcpiExp (
997 IN CHAR16 *TextDeviceNode
1005 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;
1007 HIDStr = GetNextParamStr (&TextDeviceNode);
1008 CIDStr = GetNextParamStr (&TextDeviceNode);
1009 UIDSTRStr = GetNextParamStr (&TextDeviceNode);
1010 Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (UIDSTRStr) + 3);
1011 AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (
1017 AcpiEx->HID = EisaIdFromText (HIDStr);
1018 AcpiEx->CID = EisaIdFromText (CIDStr);
1021 AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
1023 // HID string is NULL
1027 // Convert UID string
1030 StrToAscii (UIDSTRStr, &AsciiStr);
1032 // CID string is NULL
1036 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;
1040 Converts a text device path node to ACPI _ADR device path structure.
1042 @param TextDeviceNode The input Text device path node.
1044 @return A pointer to the newly-created ACPI _ADR device path structure.
1048 EFI_DEVICE_PATH_PROTOCOL *
1049 DevPathFromTextAcpiAdr (
1050 IN CHAR16 *TextDeviceNode
1053 CHAR16 *DisplayDeviceStr;
1054 ACPI_ADR_DEVICE_PATH *AcpiAdr;
1058 AcpiAdr = (ACPI_ADR_DEVICE_PATH *) CreateDeviceNode (
1061 (UINT16) sizeof (ACPI_ADR_DEVICE_PATH)
1063 ASSERT (AcpiAdr != NULL);
1065 for (Index = 0; ; Index++) {
1066 DisplayDeviceStr = GetNextParamStr (&TextDeviceNode);
1067 if (IS_NULL (*DisplayDeviceStr)) {
1071 Length = DevicePathNodeLength (AcpiAdr);
1072 AcpiAdr = ReallocatePool (
1074 Length + sizeof (UINT32),
1077 ASSERT (AcpiAdr != NULL);
1078 SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));
1081 (&AcpiAdr->ADR)[Index] = (UINT32) Strtoi (DisplayDeviceStr);
1084 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr;
1088 Converts a generic messaging text device path node to messaging device path structure.
1090 @param TextDeviceNode The input Text device path node.
1092 @return A pointer to messaging device path structure.
1096 EFI_DEVICE_PATH_PROTOCOL *
1097 DevPathFromTextMsg (
1098 IN CHAR16 *TextDeviceNode
1101 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH, TextDeviceNode);
1105 Converts a text device path node to Parallel Port device path structure.
1107 @param TextDeviceNode The input Text device path node.
1109 @return A pointer to the newly-created Parallel Port device path structure.
1113 EFI_DEVICE_PATH_PROTOCOL *
1114 DevPathFromTextAta (
1115 IN CHAR16 *TextDeviceNode
1118 CHAR16 *PrimarySecondaryStr;
1119 CHAR16 *SlaveMasterStr;
1121 ATAPI_DEVICE_PATH *Atapi;
1123 Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (
1124 MESSAGING_DEVICE_PATH,
1126 (UINT16) sizeof (ATAPI_DEVICE_PATH)
1129 PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);
1130 SlaveMasterStr = GetNextParamStr (&TextDeviceNode);
1131 LunStr = GetNextParamStr (&TextDeviceNode);
1133 if (StrCmp (PrimarySecondaryStr, "Primary") == 0) {
1134 Atapi->PrimarySecondary = 0;
1135 } else if (StrCmp (PrimarySecondaryStr, "Secondary") == 0) {
1136 Atapi->PrimarySecondary = 1;
1138 Atapi->PrimarySecondary = (UINT8) Strtoi (PrimarySecondaryStr);
1140 if (StrCmp (SlaveMasterStr, "Master") == 0) {
1141 Atapi->SlaveMaster = 0;
1142 } else if (StrCmp (SlaveMasterStr, "Slave") == 0) {
1143 Atapi->SlaveMaster = 1;
1145 Atapi->SlaveMaster = (UINT8) Strtoi (SlaveMasterStr);
1148 Atapi->Lun = (UINT16) Strtoi (LunStr);
1150 return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;
1154 Converts a text device path node to SCSI device path structure.
1156 @param TextDeviceNode The input Text device path node.
1158 @return A pointer to the newly-created SCSI device path structure.
1162 EFI_DEVICE_PATH_PROTOCOL *
1163 DevPathFromTextScsi (
1164 IN CHAR16 *TextDeviceNode
1169 SCSI_DEVICE_PATH *Scsi;
1171 PunStr = GetNextParamStr (&TextDeviceNode);
1172 LunStr = GetNextParamStr (&TextDeviceNode);
1173 Scsi = (SCSI_DEVICE_PATH *) CreateDeviceNode (
1174 MESSAGING_DEVICE_PATH,
1176 (UINT16) sizeof (SCSI_DEVICE_PATH)
1179 Scsi->Pun = (UINT16) Strtoi (PunStr);
1180 Scsi->Lun = (UINT16) Strtoi (LunStr);
1182 return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;
1186 Converts a text device path node to Fibre device path structure.
1188 @param TextDeviceNode The input Text device path node.
1190 @return A pointer to the newly-created Fibre device path structure.
1194 EFI_DEVICE_PATH_PROTOCOL *
1195 DevPathFromTextFibre (
1196 IN CHAR16 *TextDeviceNode
1201 FIBRECHANNEL_DEVICE_PATH *Fibre;
1203 WWNStr = GetNextParamStr (&TextDeviceNode);
1204 LunStr = GetNextParamStr (&TextDeviceNode);
1205 Fibre = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (
1206 MESSAGING_DEVICE_PATH,
1207 MSG_FIBRECHANNEL_DP,
1208 (UINT16) sizeof (FIBRECHANNEL_DEVICE_PATH)
1211 Fibre->Reserved = 0;
1212 Strtoi64 (WWNStr, &Fibre->WWN);
1213 Strtoi64 (LunStr, &Fibre->Lun);
1215 return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;
1219 Converts a text device path node to FibreEx device path structure.
1221 @param TextDeviceNode The input Text device path node.
1223 @return A pointer to the newly-created FibreEx device path structure.
1227 EFI_DEVICE_PATH_PROTOCOL *
1228 DevPathFromTextFibreEx (
1229 IN CHAR16 *TextDeviceNode
1234 FIBRECHANNELEX_DEVICE_PATH *FibreEx;
1236 WWNStr = GetNextParamStr (&TextDeviceNode);
1237 LunStr = GetNextParamStr (&TextDeviceNode);
1238 FibreEx = (FIBRECHANNELEX_DEVICE_PATH *) CreateDeviceNode (
1239 MESSAGING_DEVICE_PATH,
1240 MSG_FIBRECHANNELEX_DP,
1241 (UINT16) sizeof (FIBRECHANNELEX_DEVICE_PATH)
1244 FibreEx->Reserved = 0;
1245 Strtoi64 (WWNStr, (UINT64 *) (&FibreEx->WWN));
1246 Strtoi64 (LunStr, (UINT64 *) (&FibreEx->Lun));
1248 *(UINT64 *) (&FibreEx->WWN) = SwapBytes64 (*(UINT64 *) (&FibreEx->WWN));
1249 *(UINT64 *) (&FibreEx->Lun) = SwapBytes64 (*(UINT64 *) (&FibreEx->Lun));
1251 return (EFI_DEVICE_PATH_PROTOCOL *) FibreEx;
1255 Converts a text device path node to 1394 device path structure.
1257 @param TextDeviceNode The input Text device path node.
1259 @return A pointer to the newly-created 1394 device path structure.
1263 EFI_DEVICE_PATH_PROTOCOL *
1264 DevPathFromText1394 (
1265 IN CHAR16 *TextDeviceNode
1269 F1394_DEVICE_PATH *F1394DevPath;
1271 GuidStr = GetNextParamStr (&TextDeviceNode);
1272 F1394DevPath = (F1394_DEVICE_PATH *) CreateDeviceNode (
1273 MESSAGING_DEVICE_PATH,
1275 (UINT16) sizeof (F1394_DEVICE_PATH)
1278 F1394DevPath->Reserved = 0;
1279 F1394DevPath->Guid = StrHexToUint64 (GuidStr);
1281 return (EFI_DEVICE_PATH_PROTOCOL *) F1394DevPath;
1285 Converts a text device path node to USB device path structure.
1287 @param TextDeviceNode The input Text device path node.
1289 @return A pointer to the newly-created USB device path structure.
1293 EFI_DEVICE_PATH_PROTOCOL *
1294 DevPathFromTextUsb (
1295 IN CHAR16 *TextDeviceNode
1299 CHAR16 *InterfaceStr;
1300 USB_DEVICE_PATH *Usb;
1302 PortStr = GetNextParamStr (&TextDeviceNode);
1303 InterfaceStr = GetNextParamStr (&TextDeviceNode);
1304 Usb = (USB_DEVICE_PATH *) CreateDeviceNode (
1305 MESSAGING_DEVICE_PATH,
1307 (UINT16) sizeof (USB_DEVICE_PATH)
1310 Usb->ParentPortNumber = (UINT8) Strtoi (PortStr);
1311 Usb->InterfaceNumber = (UINT8) Strtoi (InterfaceStr);
1313 return (EFI_DEVICE_PATH_PROTOCOL *) Usb;
1317 Converts a text device path node to I20 device path structure.
1319 @param TextDeviceNode The input Text device path node.
1321 @return A pointer to the newly-created I20 device path structure.
1325 EFI_DEVICE_PATH_PROTOCOL *
1326 DevPathFromTextI2O (
1327 IN CHAR16 *TextDeviceNode
1331 I2O_DEVICE_PATH *I2ODevPath;
1333 TIDStr = GetNextParamStr (&TextDeviceNode);
1334 I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode (
1335 MESSAGING_DEVICE_PATH,
1337 (UINT16) sizeof (I2O_DEVICE_PATH)
1340 I2ODevPath->Tid = (UINT32) Strtoi (TIDStr);
1342 return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath;
1346 Converts a text device path node to Infini Band device path structure.
1348 @param TextDeviceNode The input Text device path node.
1350 @return A pointer to the newly-created Infini Band device path structure.
1354 EFI_DEVICE_PATH_PROTOCOL *
1355 DevPathFromTextInfiniband (
1356 IN CHAR16 *TextDeviceNode
1364 INFINIBAND_DEVICE_PATH *InfiniBand;
1366 FlagsStr = GetNextParamStr (&TextDeviceNode);
1367 GuidStr = GetNextParamStr (&TextDeviceNode);
1368 SidStr = GetNextParamStr (&TextDeviceNode);
1369 TidStr = GetNextParamStr (&TextDeviceNode);
1370 DidStr = GetNextParamStr (&TextDeviceNode);
1371 InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (
1372 MESSAGING_DEVICE_PATH,
1374 (UINT16) sizeof (INFINIBAND_DEVICE_PATH)
1377 InfiniBand->ResourceFlags = (UINT32) Strtoi (FlagsStr);
1378 StrToGuid (GuidStr, (EFI_GUID *) InfiniBand->PortGid);
1379 Strtoi64 (SidStr, &InfiniBand->ServiceId);
1380 Strtoi64 (TidStr, &InfiniBand->TargetPortId);
1381 Strtoi64 (DidStr, &InfiniBand->DeviceId);
1383 return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;
1387 Converts a text device path node to Vendor-Defined Messaging device path structure.
1389 @param TextDeviceNode The input Text device path node.
1391 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1395 EFI_DEVICE_PATH_PROTOCOL *
1396 DevPathFromTextVenMsg (
1397 IN CHAR16 *TextDeviceNode
1400 return ConvertFromTextVendor (
1402 MESSAGING_DEVICE_PATH,
1408 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1410 @param TextDeviceNode The input Text device path node.
1412 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1416 EFI_DEVICE_PATH_PROTOCOL *
1417 DevPathFromTextVenPcAnsi (
1418 IN CHAR16 *TextDeviceNode
1421 VENDOR_DEVICE_PATH *Vendor;
1423 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
1424 MESSAGING_DEVICE_PATH,
1426 (UINT16) sizeof (VENDOR_DEVICE_PATH));
1427 CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);
1429 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
1433 Converts a text device path node to Vendor defined VT100 device path structure.
1435 @param TextDeviceNode The input Text device path node.
1437 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1441 EFI_DEVICE_PATH_PROTOCOL *
1442 DevPathFromTextVenVt100 (
1443 IN CHAR16 *TextDeviceNode
1446 VENDOR_DEVICE_PATH *Vendor;
1448 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
1449 MESSAGING_DEVICE_PATH,
1451 (UINT16) sizeof (VENDOR_DEVICE_PATH));
1452 CopyGuid (&Vendor->Guid, &gEfiVT100Guid);
1454 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
1458 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1460 @param TextDeviceNode The input Text device path node.
1462 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1466 EFI_DEVICE_PATH_PROTOCOL *
1467 DevPathFromTextVenVt100Plus (
1468 IN CHAR16 *TextDeviceNode
1471 VENDOR_DEVICE_PATH *Vendor;
1473 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
1474 MESSAGING_DEVICE_PATH,
1476 (UINT16) sizeof (VENDOR_DEVICE_PATH));
1477 CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);
1479 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
1483 Converts a text device path node to Vendor defined UTF8 device path structure.
1485 @param TextDeviceNode The input Text device path node.
1487 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1491 EFI_DEVICE_PATH_PROTOCOL *
1492 DevPathFromTextVenUtf8 (
1493 IN CHAR16 *TextDeviceNode
1496 VENDOR_DEVICE_PATH *Vendor;
1498 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
1499 MESSAGING_DEVICE_PATH,
1501 (UINT16) sizeof (VENDOR_DEVICE_PATH));
1502 CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);
1504 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
1508 Converts a text device path node to UART Flow Control device path structure.
1510 @param TextDeviceNode The input Text device path node.
1512 @return A pointer to the newly-created UART Flow Control device path structure.
1516 EFI_DEVICE_PATH_PROTOCOL *
1517 DevPathFromTextUartFlowCtrl (
1518 IN CHAR16 *TextDeviceNode
1522 UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;
1524 ValueStr = GetNextParamStr (&TextDeviceNode);
1525 UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (
1526 MESSAGING_DEVICE_PATH,
1528 (UINT16) sizeof (UART_FLOW_CONTROL_DEVICE_PATH)
1531 CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);
1532 if (StrCmp (ValueStr, "XonXoff") == 0) {
1533 UartFlowControl->FlowControlMap = 2;
1534 } else if (StrCmp (ValueStr, "Hardware") == 0) {
1535 UartFlowControl->FlowControlMap = 1;
1537 UartFlowControl->FlowControlMap = 0;
1540 return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;
1544 Converts a text device path node to Serial Attached SCSI device path structure.
1546 @param TextDeviceNode The input Text device path node.
1548 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1552 EFI_DEVICE_PATH_PROTOCOL *
1553 DevPathFromTextSAS (
1554 IN CHAR16 *TextDeviceNode
1561 CHAR16 *LocationStr;
1563 CHAR16 *DriveBayStr;
1564 CHAR16 *ReservedStr;
1567 SAS_DEVICE_PATH *Sas;
1569 AddressStr = GetNextParamStr (&TextDeviceNode);
1570 LunStr = GetNextParamStr (&TextDeviceNode);
1571 RTPStr = GetNextParamStr (&TextDeviceNode);
1572 SASSATAStr = GetNextParamStr (&TextDeviceNode);
1573 LocationStr = GetNextParamStr (&TextDeviceNode);
1574 ConnectStr = GetNextParamStr (&TextDeviceNode);
1575 DriveBayStr = GetNextParamStr (&TextDeviceNode);
1576 ReservedStr = GetNextParamStr (&TextDeviceNode);
1577 Sas = (SAS_DEVICE_PATH *) CreateDeviceNode (
1578 MESSAGING_DEVICE_PATH,
1580 (UINT16) sizeof (SAS_DEVICE_PATH)
1583 CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid);
1584 Strtoi64 (AddressStr, &Sas->SasAddress);
1585 Strtoi64 (LunStr, &Sas->Lun);
1586 Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr);
1588 if (StrCmp (SASSATAStr, "NoTopology") == 0) {
1591 } else if ((StrCmp (SASSATAStr, "SATA") == 0) || (StrCmp (SASSATAStr, "SAS") == 0)) {
1593 Uint16 = (UINT16) Strtoi (DriveBayStr);
1597 Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));
1600 if (StrCmp (SASSATAStr, "SATA") == 0) {
1605 // Location is an integer between 0 and 1 or else
1606 // the keyword Internal (0) or External (1).
1608 if (StrCmp (LocationStr, "External") == 0) {
1610 } else if (StrCmp (LocationStr, "Internal") == 0) {
1613 Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);
1615 Info |= (Uint16 << 5);
1618 // Connect is an integer between 0 and 3 or else
1619 // the keyword Direct (0) or Expanded (1).
1621 if (StrCmp (ConnectStr, "Expanded") == 0) {
1623 } else if (StrCmp (ConnectStr, "Direct") == 0) {
1626 Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));
1628 Info |= (Uint16 << 6);
1631 Info = (UINT16) Strtoi (SASSATAStr);
1634 Sas->DeviceTopology = Info;
1635 Sas->Reserved = (UINT32) Strtoi (ReservedStr);
1637 return (EFI_DEVICE_PATH_PROTOCOL *) Sas;
1641 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1643 @param TextDeviceNode The input Text device path node.
1645 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1649 EFI_DEVICE_PATH_PROTOCOL *
1650 DevPathFromTextSasEx (
1651 IN CHAR16 *TextDeviceNode
1658 CHAR16 *LocationStr;
1660 CHAR16 *DriveBayStr;
1665 SASEX_DEVICE_PATH *SasEx;
1667 AddressStr = GetNextParamStr (&TextDeviceNode);
1668 LunStr = GetNextParamStr (&TextDeviceNode);
1669 RTPStr = GetNextParamStr (&TextDeviceNode);
1670 SASSATAStr = GetNextParamStr (&TextDeviceNode);
1671 LocationStr = GetNextParamStr (&TextDeviceNode);
1672 ConnectStr = GetNextParamStr (&TextDeviceNode);
1673 DriveBayStr = GetNextParamStr (&TextDeviceNode);
1674 SasEx = (SASEX_DEVICE_PATH *) CreateDeviceNode (
1675 MESSAGING_DEVICE_PATH,
1677 (UINT16) sizeof (SASEX_DEVICE_PATH)
1680 Strtoi64 (AddressStr, &SasAddress);
1681 Strtoi64 (LunStr, &Lun);
1682 WriteUnaligned64 ((UINT64 *) &SasEx->SasAddress, SwapBytes64 (SasAddress));
1683 WriteUnaligned64 ((UINT64 *) &SasEx->Lun, SwapBytes64 (Lun));
1684 SasEx->RelativeTargetPort = (UINT16) Strtoi (RTPStr);
1686 if (StrCmp (SASSATAStr, "NoTopology") == 0) {
1689 } else if ((StrCmp (SASSATAStr, "SATA") == 0) || (StrCmp (SASSATAStr, "SAS") == 0)) {
1691 Uint16 = (UINT16) Strtoi (DriveBayStr);
1695 Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));
1698 if (StrCmp (SASSATAStr, "SATA") == 0) {
1703 // Location is an integer between 0 and 1 or else
1704 // the keyword Internal (0) or External (1).
1706 if (StrCmp (LocationStr, "External") == 0) {
1708 } else if (StrCmp (LocationStr, "Internal") == 0) {
1711 Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);
1713 Info |= (Uint16 << 5);
1716 // Connect is an integer between 0 and 3 or else
1717 // the keyword Direct (0) or Expanded (1).
1719 if (StrCmp (ConnectStr, "Expanded") == 0) {
1721 } else if (StrCmp (ConnectStr, "Direct") == 0) {
1724 Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));
1726 Info |= (Uint16 << 6);
1729 Info = (UINT16) Strtoi (SASSATAStr);
1732 SasEx->DeviceTopology = Info;
1734 return (EFI_DEVICE_PATH_PROTOCOL *) SasEx;
1738 Converts a text device path node to NVM Express Namespace device path structure.
1740 @param TextDeviceNode The input Text device path node.
1742 @return A pointer to the newly-created NVM Express Namespace device path structure.
1746 EFI_DEVICE_PATH_PROTOCOL *
1747 DevPathFromTextNVMe (
1748 IN CHAR16 *TextDeviceNode
1751 CHAR16 *NamespaceIdStr;
1752 CHAR16 *NamespaceUuidStr;
1753 NVME_NAMESPACE_DEVICE_PATH *Nvme;
1757 NamespaceIdStr = GetNextParamStr (&TextDeviceNode);
1758 NamespaceUuidStr = GetNextParamStr (&TextDeviceNode);
1759 Nvme = (NVME_NAMESPACE_DEVICE_PATH *) CreateDeviceNode (
1760 MESSAGING_DEVICE_PATH,
1761 MSG_NVME_NAMESPACE_DP,
1762 (UINT16) sizeof (NVME_NAMESPACE_DEVICE_PATH)
1765 Nvme->NamespaceId = (UINT32) Strtoi (NamespaceIdStr);
1766 Uuid = (UINT8 *) &Nvme->NamespaceUuid;
1768 Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);
1769 while (Index-- != 0) {
1770 Uuid[Index] = (UINT8) StrHexToUintn (SplitStr (&NamespaceUuidStr, '-'));
1773 return (EFI_DEVICE_PATH_PROTOCOL *) Nvme;
1777 Converts a text device path node to UFS device path structure.
1779 @param TextDeviceNode The input Text device path node.
1781 @return A pointer to the newly-created UFS device path structure.
1785 EFI_DEVICE_PATH_PROTOCOL *
1786 DevPathFromTextUfs (
1787 IN CHAR16 *TextDeviceNode
1792 UFS_DEVICE_PATH *Ufs;
1794 PunStr = GetNextParamStr (&TextDeviceNode);
1795 LunStr = GetNextParamStr (&TextDeviceNode);
1796 Ufs = (UFS_DEVICE_PATH *) CreateDeviceNode (
1797 MESSAGING_DEVICE_PATH,
1799 (UINT16) sizeof (UFS_DEVICE_PATH)
1802 Ufs->Pun = (UINT8) Strtoi (PunStr);
1803 Ufs->Lun = (UINT8) Strtoi (LunStr);
1805 return (EFI_DEVICE_PATH_PROTOCOL *) Ufs;
1809 Converts a text device path node to SD (Secure Digital) device path structure.
1811 @param TextDeviceNode The input Text device path node.
1813 @return A pointer to the newly-created SD device path structure.
1817 EFI_DEVICE_PATH_PROTOCOL *
1819 IN CHAR16 *TextDeviceNode
1822 CHAR16 *SlotNumberStr;
1825 SlotNumberStr = GetNextParamStr (&TextDeviceNode);
1826 Sd = (SD_DEVICE_PATH *) CreateDeviceNode (
1827 MESSAGING_DEVICE_PATH,
1829 (UINT16) sizeof (SD_DEVICE_PATH)
1832 Sd->SlotNumber = (UINT8) Strtoi (SlotNumberStr);
1834 return (EFI_DEVICE_PATH_PROTOCOL *) Sd;
1838 Converts a text device path node to EMMC (Embedded MMC) device path structure.
1840 @param TextDeviceNode The input Text device path node.
1842 @return A pointer to the newly-created EMMC device path structure.
1846 EFI_DEVICE_PATH_PROTOCOL *
1847 DevPathFromTextEmmc (
1848 IN CHAR16 *TextDeviceNode
1851 CHAR16 *SlotNumberStr;
1852 EMMC_DEVICE_PATH *Emmc;
1854 SlotNumberStr = GetNextParamStr (&TextDeviceNode);
1855 Emmc = (EMMC_DEVICE_PATH *) CreateDeviceNode (
1856 MESSAGING_DEVICE_PATH,
1858 (UINT16) sizeof (EMMC_DEVICE_PATH)
1861 Emmc->SlotNumber = (UINT8) Strtoi (SlotNumberStr);
1863 return (EFI_DEVICE_PATH_PROTOCOL *) Emmc;
1867 Converts a text device path node to Debug Port device path structure.
1869 @param TextDeviceNode The input Text device path node.
1871 @return A pointer to the newly-created Debug Port device path structure.
1875 EFI_DEVICE_PATH_PROTOCOL *
1876 DevPathFromTextDebugPort (
1877 IN CHAR16 *TextDeviceNode
1880 VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend;
1882 Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (
1883 MESSAGING_DEVICE_PATH,
1885 (UINT16) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)
1888 CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);
1890 return (EFI_DEVICE_PATH_PROTOCOL *) Vend;
1894 Converts a text device path node to MAC device path structure.
1896 @param TextDeviceNode The input Text device path node.
1898 @return A pointer to the newly-created MAC device path structure.
1902 EFI_DEVICE_PATH_PROTOCOL *
1903 DevPathFromTextMAC (
1904 IN CHAR16 *TextDeviceNode
1910 MAC_ADDR_DEVICE_PATH *MACDevPath;
1912 AddressStr = GetNextParamStr (&TextDeviceNode);
1913 IfTypeStr = GetNextParamStr (&TextDeviceNode);
1914 MACDevPath = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (
1915 MESSAGING_DEVICE_PATH,
1917 (UINT16) sizeof (MAC_ADDR_DEVICE_PATH)
1920 MACDevPath->IfType = (UINT8) Strtoi (IfTypeStr);
1922 Length = sizeof (EFI_MAC_ADDRESS);
1923 StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length);
1925 return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;
1930 Converts a text format to the network protocol ID.
1932 @param Text String of protocol field.
1934 @return Network protocol ID .
1939 NetworkProtocolFromText (
1943 if (StrCmp (Text, "UDP") == 0) {
1944 return RFC_1700_UDP_PROTOCOL;
1947 if (StrCmp (Text, "TCP") == 0) {
1948 return RFC_1700_TCP_PROTOCOL;
1951 return Strtoi (Text);
1956 Converts a text device path node to IPV4 device path structure.
1958 @param TextDeviceNode The input Text device path node.
1960 @return A pointer to the newly-created IPV4 device path structure.
1964 EFI_DEVICE_PATH_PROTOCOL *
1965 DevPathFromTextIPv4 (
1966 IN CHAR16 *TextDeviceNode
1969 CHAR16 *RemoteIPStr;
1970 CHAR16 *ProtocolStr;
1973 CHAR16 *GatewayIPStr;
1974 CHAR16 *SubnetMaskStr;
1975 IPv4_DEVICE_PATH *IPv4;
1977 RemoteIPStr = GetNextParamStr (&TextDeviceNode);
1978 ProtocolStr = GetNextParamStr (&TextDeviceNode);
1979 TypeStr = GetNextParamStr (&TextDeviceNode);
1980 LocalIPStr = GetNextParamStr (&TextDeviceNode);
1981 GatewayIPStr = GetNextParamStr (&TextDeviceNode);
1982 SubnetMaskStr = GetNextParamStr (&TextDeviceNode);
1983 IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (
1984 MESSAGING_DEVICE_PATH,
1986 (UINT16) sizeof (IPv4_DEVICE_PATH)
1989 StrToIpv4Address (RemoteIPStr, NULL, &IPv4->RemoteIpAddress, NULL);
1990 IPv4->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);
1991 if (StrCmp (TypeStr, "Static") == 0) {
1992 IPv4->StaticIpAddress = TRUE;
1994 IPv4->StaticIpAddress = FALSE;
1997 StrToIpv4Address (LocalIPStr, NULL, &IPv4->LocalIpAddress, NULL);
1998 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*SubnetMaskStr)) {
1999 StrToIpv4Address (GatewayIPStr, NULL, &IPv4->GatewayIpAddress, NULL);
2000 StrToIpv4Address (SubnetMaskStr, NULL, &IPv4->SubnetMask, NULL);
2002 ZeroMem (&IPv4->GatewayIpAddress, sizeof (IPv4->GatewayIpAddress));
2003 ZeroMem (&IPv4->SubnetMask, sizeof (IPv4->SubnetMask));
2006 IPv4->LocalPort = 0;
2007 IPv4->RemotePort = 0;
2009 return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;
2013 Converts a text device path node to IPV6 device path structure.
2015 @param TextDeviceNode The input Text device path node.
2017 @return A pointer to the newly-created IPV6 device path structure.
2021 EFI_DEVICE_PATH_PROTOCOL *
2022 DevPathFromTextIPv6 (
2023 IN CHAR16 *TextDeviceNode
2026 CHAR16 *RemoteIPStr;
2027 CHAR16 *ProtocolStr;
2030 CHAR16 *GatewayIPStr;
2031 CHAR16 *PrefixLengthStr;
2032 IPv6_DEVICE_PATH *IPv6;
2034 RemoteIPStr = GetNextParamStr (&TextDeviceNode);
2035 ProtocolStr = GetNextParamStr (&TextDeviceNode);
2036 TypeStr = GetNextParamStr (&TextDeviceNode);
2037 LocalIPStr = GetNextParamStr (&TextDeviceNode);
2038 PrefixLengthStr = GetNextParamStr (&TextDeviceNode);
2039 GatewayIPStr = GetNextParamStr (&TextDeviceNode);
2040 IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (
2041 MESSAGING_DEVICE_PATH,
2043 (UINT16) sizeof (IPv6_DEVICE_PATH)
2046 StrToIpv6Address (RemoteIPStr, NULL, &IPv6->RemoteIpAddress, NULL);
2047 IPv6->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);
2048 if (StrCmp (TypeStr, "Static") == 0) {
2049 IPv6->IpAddressOrigin = 0;
2050 } else if (StrCmp (TypeStr, "StatelessAutoConfigure") == 0) {
2051 IPv6->IpAddressOrigin = 1;
2053 IPv6->IpAddressOrigin = 2;
2056 StrToIpv6Address (LocalIPStr, NULL, &IPv6->LocalIpAddress, NULL);
2057 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*PrefixLengthStr)) {
2058 StrToIpv6Address (GatewayIPStr, NULL, &IPv6->GatewayIpAddress, NULL);
2059 IPv6->PrefixLength = (UINT8) Strtoi (PrefixLengthStr);
2061 ZeroMem (&IPv6->GatewayIpAddress, sizeof (IPv6->GatewayIpAddress));
2062 IPv6->PrefixLength = 0;
2065 IPv6->LocalPort = 0;
2066 IPv6->RemotePort = 0;
2068 return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;
2072 Converts a text device path node to UART device path structure.
2074 @param TextDeviceNode The input Text device path node.
2076 @return A pointer to the newly-created UART device path structure.
2080 EFI_DEVICE_PATH_PROTOCOL *
2081 DevPathFromTextUart (
2082 IN CHAR16 *TextDeviceNode
2086 CHAR16 *DataBitsStr;
2088 CHAR16 *StopBitsStr;
2089 UART_DEVICE_PATH *Uart;
2091 BaudStr = GetNextParamStr (&TextDeviceNode);
2092 DataBitsStr = GetNextParamStr (&TextDeviceNode);
2093 ParityStr = GetNextParamStr (&TextDeviceNode);
2094 StopBitsStr = GetNextParamStr (&TextDeviceNode);
2095 Uart = (UART_DEVICE_PATH *) CreateDeviceNode (
2096 MESSAGING_DEVICE_PATH,
2098 (UINT16) sizeof (UART_DEVICE_PATH)
2101 if (StrCmp (BaudStr, "DEFAULT") == 0) {
2102 Uart->BaudRate = 115200;
2104 Strtoi64 (BaudStr, &Uart->BaudRate);
2106 Uart->DataBits = (UINT8) ((StrCmp (DataBitsStr, "DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr));
2107 switch (*ParityStr) {
2133 Uart->Parity = (UINT8) Strtoi (ParityStr);
2137 if (StrCmp (StopBitsStr, "D") == 0) {
2138 Uart->StopBits = (UINT8) 0;
2139 } else if (StrCmp (StopBitsStr, "1") == 0) {
2140 Uart->StopBits = (UINT8) 1;
2141 } else if (StrCmp (StopBitsStr, "1.5") == 0) {
2142 Uart->StopBits = (UINT8) 2;
2143 } else if (StrCmp (StopBitsStr, "2") == 0) {
2144 Uart->StopBits = (UINT8) 3;
2146 Uart->StopBits = (UINT8) Strtoi (StopBitsStr);
2149 return (EFI_DEVICE_PATH_PROTOCOL *) Uart;
2153 Converts a text device path node to USB class device path structure.
2155 @param TextDeviceNode The input Text device path node.
2156 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
2158 @return A pointer to the newly-created USB class device path structure.
2162 EFI_DEVICE_PATH_PROTOCOL *
2163 ConvertFromTextUsbClass (
2164 IN CHAR16 *TextDeviceNode,
2165 IN USB_CLASS_TEXT *UsbClassText
2171 CHAR16 *SubClassStr;
2172 CHAR16 *ProtocolStr;
2173 USB_CLASS_DEVICE_PATH *UsbClass;
2175 UsbClass = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (
2176 MESSAGING_DEVICE_PATH,
2178 (UINT16) sizeof (USB_CLASS_DEVICE_PATH)
2181 VIDStr = GetNextParamStr (&TextDeviceNode);
2182 PIDStr = GetNextParamStr (&TextDeviceNode);
2183 if (UsbClassText->ClassExist) {
2184 ClassStr = GetNextParamStr (&TextDeviceNode);
2185 UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);
2187 UsbClass->DeviceClass = UsbClassText->Class;
2189 if (UsbClassText->SubClassExist) {
2190 SubClassStr = GetNextParamStr (&TextDeviceNode);
2191 UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);
2193 UsbClass->DeviceSubClass = UsbClassText->SubClass;
2196 ProtocolStr = GetNextParamStr (&TextDeviceNode);
2198 UsbClass->VendorId = (UINT16) Strtoi (VIDStr);
2199 UsbClass->ProductId = (UINT16) Strtoi (PIDStr);
2200 UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);
2202 return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;
2207 Converts a text device path node to USB class device path structure.
2209 @param TextDeviceNode The input Text device path node.
2211 @return A pointer to the newly-created USB class device path structure.
2215 EFI_DEVICE_PATH_PROTOCOL *
2216 DevPathFromTextUsbClass (
2217 IN CHAR16 *TextDeviceNode
2220 USB_CLASS_TEXT UsbClassText;
2222 UsbClassText.ClassExist = TRUE;
2223 UsbClassText.SubClassExist = TRUE;
2225 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2229 Converts a text device path node to USB audio device path structure.
2231 @param TextDeviceNode The input Text device path node.
2233 @return A pointer to the newly-created USB audio device path structure.
2237 EFI_DEVICE_PATH_PROTOCOL *
2238 DevPathFromTextUsbAudio (
2239 IN CHAR16 *TextDeviceNode
2242 USB_CLASS_TEXT UsbClassText;
2244 UsbClassText.ClassExist = FALSE;
2245 UsbClassText.Class = USB_CLASS_AUDIO;
2246 UsbClassText.SubClassExist = TRUE;
2248 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2252 Converts a text device path node to USB CDC Control device path structure.
2254 @param TextDeviceNode The input Text device path node.
2256 @return A pointer to the newly-created USB CDC Control device path structure.
2260 EFI_DEVICE_PATH_PROTOCOL *
2261 DevPathFromTextUsbCDCControl (
2262 IN CHAR16 *TextDeviceNode
2265 USB_CLASS_TEXT UsbClassText;
2267 UsbClassText.ClassExist = FALSE;
2268 UsbClassText.Class = USB_CLASS_CDCCONTROL;
2269 UsbClassText.SubClassExist = TRUE;
2271 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2275 Converts a text device path node to USB HID device path structure.
2277 @param TextDeviceNode The input Text device path node.
2279 @return A pointer to the newly-created USB HID device path structure.
2283 EFI_DEVICE_PATH_PROTOCOL *
2284 DevPathFromTextUsbHID (
2285 IN CHAR16 *TextDeviceNode
2288 USB_CLASS_TEXT UsbClassText;
2290 UsbClassText.ClassExist = FALSE;
2291 UsbClassText.Class = USB_CLASS_HID;
2292 UsbClassText.SubClassExist = TRUE;
2294 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2298 Converts a text device path node to USB Image device path structure.
2300 @param TextDeviceNode The input Text device path node.
2302 @return A pointer to the newly-created USB Image device path structure.
2306 EFI_DEVICE_PATH_PROTOCOL *
2307 DevPathFromTextUsbImage (
2308 IN CHAR16 *TextDeviceNode
2311 USB_CLASS_TEXT UsbClassText;
2313 UsbClassText.ClassExist = FALSE;
2314 UsbClassText.Class = USB_CLASS_IMAGE;
2315 UsbClassText.SubClassExist = TRUE;
2317 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2321 Converts a text device path node to USB Print device path structure.
2323 @param TextDeviceNode The input Text device path node.
2325 @return A pointer to the newly-created USB Print device path structure.
2329 EFI_DEVICE_PATH_PROTOCOL *
2330 DevPathFromTextUsbPrinter (
2331 IN CHAR16 *TextDeviceNode
2334 USB_CLASS_TEXT UsbClassText;
2336 UsbClassText.ClassExist = FALSE;
2337 UsbClassText.Class = USB_CLASS_PRINTER;
2338 UsbClassText.SubClassExist = TRUE;
2340 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2344 Converts a text device path node to USB mass storage device path structure.
2346 @param TextDeviceNode The input Text device path node.
2348 @return A pointer to the newly-created USB mass storage device path structure.
2352 EFI_DEVICE_PATH_PROTOCOL *
2353 DevPathFromTextUsbMassStorage (
2354 IN CHAR16 *TextDeviceNode
2357 USB_CLASS_TEXT UsbClassText;
2359 UsbClassText.ClassExist = FALSE;
2360 UsbClassText.Class = USB_CLASS_MASS_STORAGE;
2361 UsbClassText.SubClassExist = TRUE;
2363 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2367 Converts a text device path node to USB HUB device path structure.
2369 @param TextDeviceNode The input Text device path node.
2371 @return A pointer to the newly-created USB HUB device path structure.
2375 EFI_DEVICE_PATH_PROTOCOL *
2376 DevPathFromTextUsbHub (
2377 IN CHAR16 *TextDeviceNode
2380 USB_CLASS_TEXT UsbClassText;
2382 UsbClassText.ClassExist = FALSE;
2383 UsbClassText.Class = USB_CLASS_HUB;
2384 UsbClassText.SubClassExist = TRUE;
2386 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2390 Converts a text device path node to USB CDC data device path structure.
2392 @param TextDeviceNode The input Text device path node.
2394 @return A pointer to the newly-created USB CDC data device path structure.
2398 EFI_DEVICE_PATH_PROTOCOL *
2399 DevPathFromTextUsbCDCData (
2400 IN CHAR16 *TextDeviceNode
2403 USB_CLASS_TEXT UsbClassText;
2405 UsbClassText.ClassExist = FALSE;
2406 UsbClassText.Class = USB_CLASS_CDCDATA;
2407 UsbClassText.SubClassExist = TRUE;
2409 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2413 Converts a text device path node to USB smart card device path structure.
2415 @param TextDeviceNode The input Text device path node.
2417 @return A pointer to the newly-created USB smart card device path structure.
2421 EFI_DEVICE_PATH_PROTOCOL *
2422 DevPathFromTextUsbSmartCard (
2423 IN CHAR16 *TextDeviceNode
2426 USB_CLASS_TEXT UsbClassText;
2428 UsbClassText.ClassExist = FALSE;
2429 UsbClassText.Class = USB_CLASS_SMART_CARD;
2430 UsbClassText.SubClassExist = TRUE;
2432 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2436 Converts a text device path node to USB video device path structure.
2438 @param TextDeviceNode The input Text device path node.
2440 @return A pointer to the newly-created USB video device path structure.
2444 EFI_DEVICE_PATH_PROTOCOL *
2445 DevPathFromTextUsbVideo (
2446 IN CHAR16 *TextDeviceNode
2449 USB_CLASS_TEXT UsbClassText;
2451 UsbClassText.ClassExist = FALSE;
2452 UsbClassText.Class = USB_CLASS_VIDEO;
2453 UsbClassText.SubClassExist = TRUE;
2455 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2459 Converts a text device path node to USB diagnostic device path structure.
2461 @param TextDeviceNode The input Text device path node.
2463 @return A pointer to the newly-created USB diagnostic device path structure.
2467 EFI_DEVICE_PATH_PROTOCOL *
2468 DevPathFromTextUsbDiagnostic (
2469 IN CHAR16 *TextDeviceNode
2472 USB_CLASS_TEXT UsbClassText;
2474 UsbClassText.ClassExist = FALSE;
2475 UsbClassText.Class = USB_CLASS_DIAGNOSTIC;
2476 UsbClassText.SubClassExist = TRUE;
2478 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2482 Converts a text device path node to USB wireless device path structure.
2484 @param TextDeviceNode The input Text device path node.
2486 @return A pointer to the newly-created USB wireless device path structure.
2490 EFI_DEVICE_PATH_PROTOCOL *
2491 DevPathFromTextUsbWireless (
2492 IN CHAR16 *TextDeviceNode
2495 USB_CLASS_TEXT UsbClassText;
2497 UsbClassText.ClassExist = FALSE;
2498 UsbClassText.Class = USB_CLASS_WIRELESS;
2499 UsbClassText.SubClassExist = TRUE;
2501 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2505 Converts a text device path node to USB device firmware update device path structure.
2507 @param TextDeviceNode The input Text device path node.
2509 @return A pointer to the newly-created USB device firmware update device path structure.
2513 EFI_DEVICE_PATH_PROTOCOL *
2514 DevPathFromTextUsbDeviceFirmwareUpdate (
2515 IN CHAR16 *TextDeviceNode
2518 USB_CLASS_TEXT UsbClassText;
2520 UsbClassText.ClassExist = FALSE;
2521 UsbClassText.Class = USB_CLASS_RESERVE;
2522 UsbClassText.SubClassExist = FALSE;
2523 UsbClassText.SubClass = USB_SUBCLASS_FW_UPDATE;
2525 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2529 Converts a text device path node to USB IRDA bridge device path structure.
2531 @param TextDeviceNode The input Text device path node.
2533 @return A pointer to the newly-created USB IRDA bridge device path structure.
2537 EFI_DEVICE_PATH_PROTOCOL *
2538 DevPathFromTextUsbIrdaBridge (
2539 IN CHAR16 *TextDeviceNode
2542 USB_CLASS_TEXT UsbClassText;
2544 UsbClassText.ClassExist = FALSE;
2545 UsbClassText.Class = USB_CLASS_RESERVE;
2546 UsbClassText.SubClassExist = FALSE;
2547 UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE;
2549 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2553 Converts a text device path node to USB text and measurement device path structure.
2555 @param TextDeviceNode The input Text device path node.
2557 @return A pointer to the newly-created USB text and measurement device path structure.
2561 EFI_DEVICE_PATH_PROTOCOL *
2562 DevPathFromTextUsbTestAndMeasurement (
2563 IN CHAR16 *TextDeviceNode
2566 USB_CLASS_TEXT UsbClassText;
2568 UsbClassText.ClassExist = FALSE;
2569 UsbClassText.Class = USB_CLASS_RESERVE;
2570 UsbClassText.SubClassExist = FALSE;
2571 UsbClassText.SubClass = USB_SUBCLASS_TEST;
2573 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2577 Converts a text device path node to USB WWID device path structure.
2579 @param TextDeviceNode The input Text device path node.
2581 @return A pointer to the newly-created USB WWID device path structure.
2585 EFI_DEVICE_PATH_PROTOCOL *
2586 DevPathFromTextUsbWwid (
2587 IN CHAR16 *TextDeviceNode
2592 CHAR16 *InterfaceNumStr;
2593 CHAR16 *SerialNumberStr;
2594 USB_WWID_DEVICE_PATH *UsbWwid;
2595 UINTN SerialNumberStrLen;
2597 VIDStr = GetNextParamStr (&TextDeviceNode);
2598 PIDStr = GetNextParamStr (&TextDeviceNode);
2599 InterfaceNumStr = GetNextParamStr (&TextDeviceNode);
2600 SerialNumberStr = GetNextParamStr (&TextDeviceNode);
2601 SerialNumberStrLen = StrLen (SerialNumberStr);
2602 if (SerialNumberStrLen >= 2 &&
2603 SerialNumberStr[0] == '\"' &&
2604 SerialNumberStr[SerialNumberStrLen - 1] == '\"'
2606 SerialNumberStr[SerialNumberStrLen - 1] = '\0';
2608 SerialNumberStrLen -= 2;
2610 UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (
2611 MESSAGING_DEVICE_PATH,
2613 (UINT16) (sizeof (USB_WWID_DEVICE_PATH) + SerialNumberStrLen * sizeof (CHAR16))
2615 UsbWwid->VendorId = (UINT16) Strtoi (VIDStr);
2616 UsbWwid->ProductId = (UINT16) Strtoi (PIDStr);
2617 UsbWwid->InterfaceNumber = (UINT16) Strtoi (InterfaceNumStr);
2620 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
2621 // Therefore, the '\0' will not be copied.
2624 (UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH),
2626 SerialNumberStrLen * sizeof (CHAR16)
2629 return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;
2633 Converts a text device path node to Logic Unit device path structure.
2635 @param TextDeviceNode The input Text device path node.
2637 @return A pointer to the newly-created Logic Unit device path structure.
2641 EFI_DEVICE_PATH_PROTOCOL *
2642 DevPathFromTextUnit (
2643 IN CHAR16 *TextDeviceNode
2647 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
2649 LunStr = GetNextParamStr (&TextDeviceNode);
2650 LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (
2651 MESSAGING_DEVICE_PATH,
2652 MSG_DEVICE_LOGICAL_UNIT_DP,
2653 (UINT16) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)
2656 LogicalUnit->Lun = (UINT8) Strtoi (LunStr);
2658 return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;
2662 Converts a text device path node to iSCSI device path structure.
2664 @param TextDeviceNode The input Text device path node.
2666 @return A pointer to the newly-created iSCSI device path structure.
2670 EFI_DEVICE_PATH_PROTOCOL *
2671 DevPathFromTextiSCSI (
2672 IN CHAR16 *TextDeviceNode
2677 CHAR16 *PortalGroupStr;
2679 CHAR16 *HeaderDigestStr;
2680 CHAR16 *DataDigestStr;
2681 CHAR16 *AuthenticationStr;
2682 CHAR16 *ProtocolStr;
2684 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
2686 NameStr = GetNextParamStr (&TextDeviceNode);
2687 PortalGroupStr = GetNextParamStr (&TextDeviceNode);
2688 LunStr = GetNextParamStr (&TextDeviceNode);
2689 HeaderDigestStr = GetNextParamStr (&TextDeviceNode);
2690 DataDigestStr = GetNextParamStr (&TextDeviceNode);
2691 AuthenticationStr = GetNextParamStr (&TextDeviceNode);
2692 ProtocolStr = GetNextParamStr (&TextDeviceNode);
2693 ISCSIDevPath = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (
2694 MESSAGING_DEVICE_PATH,
2696 (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))
2699 AsciiStr = ISCSIDevPath->TargetName;
2700 StrToAscii (NameStr, &AsciiStr);
2702 ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);
2703 Strtoi64 (LunStr, &ISCSIDevPath->Lun);
2706 if (StrCmp (HeaderDigestStr, "CRC32C") == 0) {
2710 if (StrCmp (DataDigestStr, "CRC32C") == 0) {
2714 if (StrCmp (AuthenticationStr, "None") == 0) {
2718 if (StrCmp (AuthenticationStr, "CHAP_UNI") == 0) {
2722 ISCSIDevPath->LoginOption = (UINT16) Options;
2724 ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, "TCP");
2726 return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;
2730 Converts a text device path node to VLAN device path structure.
2732 @param TextDeviceNode The input Text device path node.
2734 @return A pointer to the newly-created VLAN device path structure.
2738 EFI_DEVICE_PATH_PROTOCOL *
2739 DevPathFromTextVlan (
2740 IN CHAR16 *TextDeviceNode
2744 VLAN_DEVICE_PATH *Vlan;
2746 VlanStr = GetNextParamStr (&TextDeviceNode);
2747 Vlan = (VLAN_DEVICE_PATH *) CreateDeviceNode (
2748 MESSAGING_DEVICE_PATH,
2750 (UINT16) sizeof (VLAN_DEVICE_PATH)
2753 Vlan->VlanId = (UINT16) Strtoi (VlanStr);
2755 return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;
2759 Converts a text device path node to Bluetooth device path structure.
2761 @param TextDeviceNode The input Text device path node.
2763 @return A pointer to the newly-created Bluetooth device path structure.
2767 EFI_DEVICE_PATH_PROTOCOL *
2768 DevPathFromTextBluetooth (
2769 IN CHAR16 *TextDeviceNode
2772 CHAR16 *BluetoothStr;
2774 CHAR16 *TempNumBuffer;
2775 UINTN TempBufferSize;
2777 BLUETOOTH_DEVICE_PATH *BluetoothDp;
2779 BluetoothStr = GetNextParamStr (&TextDeviceNode);
2780 BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (
2781 MESSAGING_DEVICE_PATH,
2783 (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)
2786 Index = sizeof (BLUETOOTH_ADDRESS) - 1;
2787 Walker = BluetoothStr;
2788 while (!IS_NULL(*Walker) && Index >= 0) {
2789 TempBufferSize = 2 * sizeof(CHAR16) + StrSize("0x");
2790 TempNumBuffer = AllocateZeroPool (TempBufferSize);
2791 if (TempNumBuffer == NULL) {
2794 StrCpyS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), "0x");
2795 StrnCatS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), Walker, 2);
2796 BluetoothDp->BD_ADDR.Address[Index] = (UINT8)Strtoi (TempNumBuffer);
2797 FreePool (TempNumBuffer);
2802 return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothDp;
2806 Converts a text device path node to Wi-Fi device path structure.
2808 @param TextDeviceNode The input Text device path node.
2810 @return A pointer to the newly-created Wi-Fi device path structure.
2814 EFI_DEVICE_PATH_PROTOCOL *
2815 DevPathFromTextWiFi (
2816 IN CHAR16 *TextDeviceNode
2822 WIFI_DEVICE_PATH *WiFiDp;
2824 SSIdStr = GetNextParamStr (&TextDeviceNode);
2825 WiFiDp = (WIFI_DEVICE_PATH *) CreateDeviceNode (
2826 MESSAGING_DEVICE_PATH,
2828 (UINT16) sizeof (WIFI_DEVICE_PATH)
2831 if (NULL != SSIdStr) {
2832 DataLen = StrLen (SSIdStr);
2833 if (StrLen (SSIdStr) > 32) {
2838 UnicodeStrToAsciiStrS (SSIdStr, AsciiStr, sizeof (AsciiStr));
2839 CopyMem (WiFiDp->SSId, AsciiStr, DataLen);
2842 return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp;
2846 Converts a text device path node to URI device path structure.
2848 @param TextDeviceNode The input Text device path node.
2850 @return A pointer to the newly-created URI device path structure.
2854 EFI_DEVICE_PATH_PROTOCOL *
2855 DevPathFromTextUri (
2856 IN CHAR16 *TextDeviceNode
2861 URI_DEVICE_PATH *Uri;
2863 UriStr = GetNextParamStr (&TextDeviceNode);
2864 UriLength = StrnLenS (UriStr, MAX_UINT16 - sizeof (URI_DEVICE_PATH));
2865 Uri = (URI_DEVICE_PATH *) CreateDeviceNode (
2866 MESSAGING_DEVICE_PATH,
2868 (UINT16) (sizeof (URI_DEVICE_PATH) + UriLength)
2871 while (UriLength-- != 0) {
2872 Uri->Uri[UriLength] = (CHAR8) UriStr[UriLength];
2875 return (EFI_DEVICE_PATH_PROTOCOL *) Uri;
2879 Converts a media text device path node to media device path structure.
2881 @param TextDeviceNode The input Text device path node.
2883 @return A pointer to media device path structure.
2887 EFI_DEVICE_PATH_PROTOCOL *
2888 DevPathFromTextMediaPath (
2889 IN CHAR16 *TextDeviceNode
2892 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH, TextDeviceNode);
2896 Converts a text device path node to HD device path structure.
2898 @param TextDeviceNode The input Text device path node.
2900 @return A pointer to the newly-created HD device path structure.
2904 EFI_DEVICE_PATH_PROTOCOL *
2906 IN CHAR16 *TextDeviceNode
2909 CHAR16 *PartitionStr;
2911 CHAR16 *SignatureStr;
2915 HARDDRIVE_DEVICE_PATH *Hd;
2917 PartitionStr = GetNextParamStr (&TextDeviceNode);
2918 TypeStr = GetNextParamStr (&TextDeviceNode);
2919 SignatureStr = GetNextParamStr (&TextDeviceNode);
2920 StartStr = GetNextParamStr (&TextDeviceNode);
2921 SizeStr = GetNextParamStr (&TextDeviceNode);
2922 Hd = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (
2925 (UINT16) sizeof (HARDDRIVE_DEVICE_PATH)
2928 Hd->PartitionNumber = (UINT32) Strtoi (PartitionStr);
2930 ZeroMem (Hd->Signature, 16);
2931 Hd->MBRType = (UINT8) 0;
2933 if (StrCmp (TypeStr, "MBR") == 0) {
2934 Hd->SignatureType = SIGNATURE_TYPE_MBR;
2937 Signature32 = (UINT32) Strtoi (SignatureStr);
2938 CopyMem (Hd->Signature, &Signature32, sizeof (UINT32));
2939 } else if (StrCmp (TypeStr, "GPT") == 0) {
2940 Hd->SignatureType = SIGNATURE_TYPE_GUID;
2943 StrToGuid (SignatureStr, (EFI_GUID *) Hd->Signature);
2945 Hd->SignatureType = (UINT8) Strtoi (TypeStr);
2948 Strtoi64 (StartStr, &Hd->PartitionStart);
2949 Strtoi64 (SizeStr, &Hd->PartitionSize);
2951 return (EFI_DEVICE_PATH_PROTOCOL *) Hd;
2955 Converts a text device path node to CDROM device path structure.
2957 @param TextDeviceNode The input Text device path node.
2959 @return A pointer to the newly-created CDROM device path structure.
2963 EFI_DEVICE_PATH_PROTOCOL *
2964 DevPathFromTextCDROM (
2965 IN CHAR16 *TextDeviceNode
2971 CDROM_DEVICE_PATH *CDROMDevPath;
2973 EntryStr = GetNextParamStr (&TextDeviceNode);
2974 StartStr = GetNextParamStr (&TextDeviceNode);
2975 SizeStr = GetNextParamStr (&TextDeviceNode);
2976 CDROMDevPath = (CDROM_DEVICE_PATH *) CreateDeviceNode (
2979 (UINT16) sizeof (CDROM_DEVICE_PATH)
2982 CDROMDevPath->BootEntry = (UINT32) Strtoi (EntryStr);
2983 Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);
2984 Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);
2986 return (EFI_DEVICE_PATH_PROTOCOL *) CDROMDevPath;
2990 Converts a text device path node to Vendor-defined media device path structure.
2992 @param TextDeviceNode The input Text device path node.
2994 @return A pointer to the newly-created Vendor-defined media device path structure.
2998 EFI_DEVICE_PATH_PROTOCOL *
2999 DevPathFromTextVenMedia (
3000 IN CHAR16 *TextDeviceNode
3003 return ConvertFromTextVendor (
3011 Converts a text device path node to File device path structure.
3013 @param TextDeviceNode The input Text device path node.
3015 @return A pointer to the newly-created File device path structure.
3019 EFI_DEVICE_PATH_PROTOCOL *
3020 DevPathFromTextFilePath (
3021 IN CHAR16 *TextDeviceNode
3024 FILEPATH_DEVICE_PATH *File;
3027 File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (
3030 (UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)
3033 StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);
3035 size_t len = (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2);
3037 File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (
3043 utf8_to_ucs2(TextDeviceNode, &v, &len);
3046 return (EFI_DEVICE_PATH_PROTOCOL *) File;
3050 Converts a text device path node to Media protocol device path structure.
3052 @param TextDeviceNode The input Text device path node.
3054 @return A pointer to the newly-created Media protocol device path structure.
3058 EFI_DEVICE_PATH_PROTOCOL *
3059 DevPathFromTextMedia (
3060 IN CHAR16 *TextDeviceNode
3064 MEDIA_PROTOCOL_DEVICE_PATH *Media;
3066 GuidStr = GetNextParamStr (&TextDeviceNode);
3067 Media = (MEDIA_PROTOCOL_DEVICE_PATH *) CreateDeviceNode (
3070 (UINT16) sizeof (MEDIA_PROTOCOL_DEVICE_PATH)
3073 StrToGuid (GuidStr, &Media->Protocol);
3075 return (EFI_DEVICE_PATH_PROTOCOL *) Media;
3079 Converts a text device path node to firmware volume device path structure.
3081 @param TextDeviceNode The input Text device path node.
3083 @return A pointer to the newly-created firmware volume device path structure.
3087 EFI_DEVICE_PATH_PROTOCOL *
3089 IN CHAR16 *TextDeviceNode
3093 MEDIA_FW_VOL_DEVICE_PATH *Fv;
3095 GuidStr = GetNextParamStr (&TextDeviceNode);
3096 Fv = (MEDIA_FW_VOL_DEVICE_PATH *) CreateDeviceNode (
3098 MEDIA_PIWG_FW_VOL_DP,
3099 (UINT16) sizeof (MEDIA_FW_VOL_DEVICE_PATH)
3102 StrToGuid (GuidStr, &Fv->FvName);
3104 return (EFI_DEVICE_PATH_PROTOCOL *) Fv;
3108 Converts a text device path node to firmware file device path structure.
3110 @param TextDeviceNode The input Text device path node.
3112 @return A pointer to the newly-created firmware file device path structure.
3116 EFI_DEVICE_PATH_PROTOCOL *
3117 DevPathFromTextFvFile (
3118 IN CHAR16 *TextDeviceNode
3122 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;
3124 GuidStr = GetNextParamStr (&TextDeviceNode);
3125 FvFile = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) CreateDeviceNode (
3127 MEDIA_PIWG_FW_FILE_DP,
3128 (UINT16) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)
3131 StrToGuid (GuidStr, &FvFile->FvFileName);
3133 return (EFI_DEVICE_PATH_PROTOCOL *) FvFile;
3137 Converts a text device path node to text relative offset device path structure.
3139 @param TextDeviceNode The input Text device path node.
3141 @return A pointer to the newly-created Text device path structure.
3145 EFI_DEVICE_PATH_PROTOCOL *
3146 DevPathFromTextRelativeOffsetRange (
3147 IN CHAR16 *TextDeviceNode
3150 CHAR16 *StartingOffsetStr;
3151 CHAR16 *EndingOffsetStr;
3152 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;
3154 StartingOffsetStr = GetNextParamStr (&TextDeviceNode);
3155 EndingOffsetStr = GetNextParamStr (&TextDeviceNode);
3156 Offset = (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *) CreateDeviceNode (
3158 MEDIA_RELATIVE_OFFSET_RANGE_DP,
3159 (UINT16) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH)
3162 Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);
3163 Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);
3165 return (EFI_DEVICE_PATH_PROTOCOL *) Offset;
3169 Converts a text device path node to text ram disk device path structure.
3171 @param TextDeviceNode The input Text device path node.
3173 @return A pointer to the newly-created Text device path structure.
3177 EFI_DEVICE_PATH_PROTOCOL *
3178 DevPathFromTextRamDisk (
3179 IN CHAR16 *TextDeviceNode
3182 CHAR16 *StartingAddrStr;
3183 CHAR16 *EndingAddrStr;
3184 CHAR16 *TypeGuidStr;
3185 CHAR16 *InstanceStr;
3186 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3187 UINT64 StartingAddr;
3190 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3191 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3192 InstanceStr = GetNextParamStr (&TextDeviceNode);
3193 TypeGuidStr = GetNextParamStr (&TextDeviceNode);
3194 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3197 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3200 Strtoi64 (StartingAddrStr, &StartingAddr);
3201 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3202 Strtoi64 (EndingAddrStr, &EndingAddr);
3203 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3204 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3205 StrToGuid (TypeGuidStr, &RamDisk->TypeGuid);
3207 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3211 Converts a text device path node to text virtual disk device path structure.
3213 @param TextDeviceNode The input Text device path node.
3215 @return A pointer to the newly-created Text device path structure.
3219 EFI_DEVICE_PATH_PROTOCOL *
3220 DevPathFromTextVirtualDisk (
3221 IN CHAR16 *TextDeviceNode
3224 CHAR16 *StartingAddrStr;
3225 CHAR16 *EndingAddrStr;
3226 CHAR16 *InstanceStr;
3227 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3228 UINT64 StartingAddr;
3231 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3232 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3233 InstanceStr = GetNextParamStr (&TextDeviceNode);
3235 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3238 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3241 Strtoi64 (StartingAddrStr, &StartingAddr);
3242 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3243 Strtoi64 (EndingAddrStr, &EndingAddr);
3244 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3245 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3246 CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid);
3248 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3252 Converts a text device path node to text virtual cd device path structure.
3254 @param TextDeviceNode The input Text device path node.
3256 @return A pointer to the newly-created Text device path structure.
3260 EFI_DEVICE_PATH_PROTOCOL *
3261 DevPathFromTextVirtualCd (
3262 IN CHAR16 *TextDeviceNode
3265 CHAR16 *StartingAddrStr;
3266 CHAR16 *EndingAddrStr;
3267 CHAR16 *InstanceStr;
3268 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3269 UINT64 StartingAddr;
3272 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3273 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3274 InstanceStr = GetNextParamStr (&TextDeviceNode);
3276 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3279 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3282 Strtoi64 (StartingAddrStr, &StartingAddr);
3283 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3284 Strtoi64 (EndingAddrStr, &EndingAddr);
3285 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3286 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3287 CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid);
3289 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3293 Converts a text device path node to text persistent virtual disk device path structure.
3295 @param TextDeviceNode The input Text device path node.
3297 @return A pointer to the newly-created Text device path structure.
3301 EFI_DEVICE_PATH_PROTOCOL *
3302 DevPathFromTextPersistentVirtualDisk (
3303 IN CHAR16 *TextDeviceNode
3306 CHAR16 *StartingAddrStr;
3307 CHAR16 *EndingAddrStr;
3308 CHAR16 *InstanceStr;
3309 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3310 UINT64 StartingAddr;
3313 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3314 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3315 InstanceStr = GetNextParamStr (&TextDeviceNode);
3317 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3320 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3323 Strtoi64 (StartingAddrStr, &StartingAddr);
3324 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3325 Strtoi64 (EndingAddrStr, &EndingAddr);
3326 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3327 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3328 CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid);
3330 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3334 Converts a text device path node to text persistent virtual cd device path structure.
3336 @param TextDeviceNode The input Text device path node.
3338 @return A pointer to the newly-created Text device path structure.
3342 EFI_DEVICE_PATH_PROTOCOL *
3343 DevPathFromTextPersistentVirtualCd (
3344 IN CHAR16 *TextDeviceNode
3347 CHAR16 *StartingAddrStr;
3348 CHAR16 *EndingAddrStr;
3349 CHAR16 *InstanceStr;
3350 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3351 UINT64 StartingAddr;
3354 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3355 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3356 InstanceStr = GetNextParamStr (&TextDeviceNode);
3358 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3361 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3364 Strtoi64 (StartingAddrStr, &StartingAddr);
3365 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3366 Strtoi64 (EndingAddrStr, &EndingAddr);
3367 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3368 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3369 CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid);
3371 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3375 Converts a BBS text device path node to BBS device path structure.
3377 @param TextDeviceNode The input Text device path node.
3379 @return A pointer to BBS device path structure.
3383 EFI_DEVICE_PATH_PROTOCOL *
3384 DevPathFromTextBbsPath (
3385 IN CHAR16 *TextDeviceNode
3388 return DevPathFromTextGenericPath (BBS_DEVICE_PATH, TextDeviceNode);
3392 Converts a text device path node to BIOS Boot Specification device path structure.
3394 @param TextDeviceNode The input Text device path node.
3396 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3400 EFI_DEVICE_PATH_PROTOCOL *
3401 DevPathFromTextBBS (
3402 IN CHAR16 *TextDeviceNode
3409 BBS_BBS_DEVICE_PATH *Bbs;
3411 TypeStr = GetNextParamStr (&TextDeviceNode);
3412 IdStr = GetNextParamStr (&TextDeviceNode);
3413 FlagsStr = GetNextParamStr (&TextDeviceNode);
3414 Bbs = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode (
3417 (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr))
3420 if (StrCmp (TypeStr, "Floppy") == 0) {
3421 Bbs->DeviceType = BBS_TYPE_FLOPPY;
3422 } else if (StrCmp (TypeStr, "HD") == 0) {
3423 Bbs->DeviceType = BBS_TYPE_HARDDRIVE;
3424 } else if (StrCmp (TypeStr, "CDROM") == 0) {
3425 Bbs->DeviceType = BBS_TYPE_CDROM;
3426 } else if (StrCmp (TypeStr, "PCMCIA") == 0) {
3427 Bbs->DeviceType = BBS_TYPE_PCMCIA;
3428 } else if (StrCmp (TypeStr, "USB") == 0) {
3429 Bbs->DeviceType = BBS_TYPE_USB;
3430 } else if (StrCmp (TypeStr, "Network") == 0) {
3431 Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK;
3433 Bbs->DeviceType = (UINT16) Strtoi (TypeStr);
3436 AsciiStr = Bbs->String;
3437 StrToAscii (IdStr, &AsciiStr);
3439 Bbs->StatusFlag = (UINT16) Strtoi (FlagsStr);
3441 return (EFI_DEVICE_PATH_PROTOCOL *) Bbs;
3445 Converts a text device path node to SATA device path structure.
3447 @param TextDeviceNode The input Text device path node.
3449 @return A pointer to the newly-created SATA device path structure.
3453 EFI_DEVICE_PATH_PROTOCOL *
3454 DevPathFromTextSata (
3455 IN CHAR16 *TextDeviceNode
3458 SATA_DEVICE_PATH *Sata;
3463 Param1 = GetNextParamStr (&TextDeviceNode);
3464 Param2 = GetNextParamStr (&TextDeviceNode);
3465 Param3 = GetNextParamStr (&TextDeviceNode);
3467 Sata = (SATA_DEVICE_PATH *) CreateDeviceNode (
3468 MESSAGING_DEVICE_PATH,
3470 (UINT16) sizeof (SATA_DEVICE_PATH)
3472 Sata->HBAPortNumber = (UINT16) Strtoi (Param1);
3473 Sata->PortMultiplierPortNumber = (UINT16) Strtoi (Param2);
3474 Sata->Lun = (UINT16) Strtoi (Param3);
3476 return (EFI_DEVICE_PATH_PROTOCOL *) Sata;
3479 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable[] = {
3480 {"Path", DevPathFromTextPath },
3482 {"HardwarePath", DevPathFromTextHardwarePath },
3483 {"Pci", DevPathFromTextPci },
3484 {"PcCard", DevPathFromTextPcCard },
3485 {"MemoryMapped", DevPathFromTextMemoryMapped },
3486 {"VenHw", DevPathFromTextVenHw },
3487 {"Ctrl", DevPathFromTextCtrl },
3488 {"BMC", DevPathFromTextBmc },
3490 {"AcpiPath", DevPathFromTextAcpiPath },
3491 {"Acpi", DevPathFromTextAcpi },
3492 {"PciRoot", DevPathFromTextPciRoot },
3493 {"PcieRoot", DevPathFromTextPcieRoot },
3494 {"Floppy", DevPathFromTextFloppy },
3495 {"Keyboard", DevPathFromTextKeyboard },
3496 {"Serial", DevPathFromTextSerial },
3497 {"ParallelPort", DevPathFromTextParallelPort },
3498 {"AcpiEx", DevPathFromTextAcpiEx },
3499 {"AcpiExp", DevPathFromTextAcpiExp },
3500 {"AcpiAdr", DevPathFromTextAcpiAdr },
3502 {"Msg", DevPathFromTextMsg },
3503 {"Ata", DevPathFromTextAta },
3504 {"Scsi", DevPathFromTextScsi },
3505 {"Fibre", DevPathFromTextFibre },
3506 {"FibreEx", DevPathFromTextFibreEx },
3507 {"I1394", DevPathFromText1394 },
3508 {"USB", DevPathFromTextUsb },
3509 {"I2O", DevPathFromTextI2O },
3510 {"Infiniband", DevPathFromTextInfiniband },
3511 {"VenMsg", DevPathFromTextVenMsg },
3512 {"VenPcAnsi", DevPathFromTextVenPcAnsi },
3513 {"VenVt100", DevPathFromTextVenVt100 },
3514 {"VenVt100Plus", DevPathFromTextVenVt100Plus },
3515 {"VenUtf8", DevPathFromTextVenUtf8 },
3516 {"UartFlowCtrl", DevPathFromTextUartFlowCtrl },
3517 {"SAS", DevPathFromTextSAS },
3518 {"SasEx", DevPathFromTextSasEx },
3519 {"NVMe", DevPathFromTextNVMe },
3520 {"UFS", DevPathFromTextUfs },
3521 {"SD", DevPathFromTextSd },
3522 {"eMMC", DevPathFromTextEmmc },
3523 {"DebugPort", DevPathFromTextDebugPort },
3524 {"MAC", DevPathFromTextMAC },
3525 {"IPv4", DevPathFromTextIPv4 },
3526 {"IPv6", DevPathFromTextIPv6 },
3527 {"Uart", DevPathFromTextUart },
3528 {"UsbClass", DevPathFromTextUsbClass },
3529 {"UsbAudio", DevPathFromTextUsbAudio },
3530 {"UsbCDCControl", DevPathFromTextUsbCDCControl },
3531 {"UsbHID", DevPathFromTextUsbHID },
3532 {"UsbImage", DevPathFromTextUsbImage },
3533 {"UsbPrinter", DevPathFromTextUsbPrinter },
3534 {"UsbMassStorage", DevPathFromTextUsbMassStorage },
3535 {"UsbHub", DevPathFromTextUsbHub },
3536 {"UsbCDCData", DevPathFromTextUsbCDCData },
3537 {"UsbSmartCard", DevPathFromTextUsbSmartCard },
3538 {"UsbVideo", DevPathFromTextUsbVideo },
3539 {"UsbDiagnostic", DevPathFromTextUsbDiagnostic },
3540 {"UsbWireless", DevPathFromTextUsbWireless },
3541 {"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate },
3542 {"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge },
3543 {"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement },
3544 {"UsbWwid", DevPathFromTextUsbWwid },
3545 {"Unit", DevPathFromTextUnit },
3546 {"iSCSI", DevPathFromTextiSCSI },
3547 {"Vlan", DevPathFromTextVlan },
3548 {"Uri", DevPathFromTextUri },
3549 {"Bluetooth", DevPathFromTextBluetooth },
3550 {"Wi-Fi", DevPathFromTextWiFi },
3551 {"MediaPath", DevPathFromTextMediaPath },
3552 {"HD", DevPathFromTextHD },
3553 {"CDROM", DevPathFromTextCDROM },
3554 {"VenMedia", DevPathFromTextVenMedia },
3555 {"Media", DevPathFromTextMedia },
3556 {"Fv", DevPathFromTextFv },
3557 {"FvFile", DevPathFromTextFvFile },
3558 {"File", DevPathFromTextFilePath },
3559 {"Offset", DevPathFromTextRelativeOffsetRange },
3560 {"RamDisk", DevPathFromTextRamDisk },
3561 {"VirtualDisk", DevPathFromTextVirtualDisk },
3562 {"VirtualCD", DevPathFromTextVirtualCd },
3563 {"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk },
3564 {"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd },
3566 {"BbsPath", DevPathFromTextBbsPath },
3567 {"BBS", DevPathFromTextBBS },
3568 {"Sata", DevPathFromTextSata },
3573 Convert text to the binary representation of a device node.
3575 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3576 node. Conversion starts with the first character and continues
3577 until the first non-device node character.
3579 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3580 insufficient memory or text unsupported.
3584 EFI_DEVICE_PATH_PROTOCOL *
3586 UefiDevicePathLibConvertTextToDeviceNode (
3587 IN CONST CHAR16 *TextDeviceNode
3590 DEVICE_PATH_FROM_TEXT FromText;
3592 EFI_DEVICE_PATH_PROTOCOL *DeviceNode;
3593 CHAR16 *DeviceNodeStr;
3596 if ((TextDeviceNode == NULL) || (IS_NULL (*TextDeviceNode))) {
3602 DeviceNodeStr = UefiDevicePathLibStrDuplicate (TextDeviceNode);
3603 ASSERT (DeviceNodeStr != NULL);
3605 for (Index = 0; mUefiDevicePathLibDevPathFromTextTable[Index].Function != NULL; Index++) {
3606 ParamStr = GetParamByNodeName (DeviceNodeStr, mUefiDevicePathLibDevPathFromTextTable[Index].DevicePathNodeText);
3607 if (ParamStr != NULL) {
3608 FromText = mUefiDevicePathLibDevPathFromTextTable[Index].Function;
3613 if (FromText == NULL) {
3617 FromText = DevPathFromTextFilePath;
3618 DeviceNode = FromText (DeviceNodeStr);
3620 DeviceNode = FromText (ParamStr);
3621 FreePool (ParamStr);
3624 FreePool (DeviceNodeStr);
3630 Convert text to the binary representation of a device path.
3633 @param TextDevicePath TextDevicePath points to the text representation of a device
3634 path. Conversion starts with the first character and continues
3635 until the first non-device node character.
3637 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3638 there was insufficient memory.
3642 EFI_DEVICE_PATH_PROTOCOL *
3644 UefiDevicePathLibConvertTextToDevicePath (
3645 IN CONST CHAR16 *TextDevicePath
3648 EFI_DEVICE_PATH_PROTOCOL *DeviceNode;
3649 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
3650 CHAR16 *DevicePathStr;
3652 CHAR16 *DeviceNodeStr;
3653 BOOLEAN IsInstanceEnd;
3654 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
3656 if ((TextDevicePath == NULL) || (IS_NULL (*TextDevicePath))) {
3660 DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
3661 ASSERT (DevicePath != NULL);
3662 SetDevicePathEndNode (DevicePath);
3664 DevicePathStr = UefiDevicePathLibStrDuplicate (TextDevicePath);
3666 Str = DevicePathStr;
3667 while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {
3668 DeviceNode = UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr);
3670 NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
3671 FreePool (DevicePath);
3672 FreePool (DeviceNode);
3673 DevicePath = NewDevicePath;
3675 if (IsInstanceEnd) {
3676 DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
3677 ASSERT (DeviceNode != NULL);
3678 SetDevicePathEndNode (DeviceNode);
3679 // Fix from https://bugzilla.tianocore.org/show_bug.cgi?id=419
3680 DeviceNode->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
3682 NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
3683 FreePool (DevicePath);
3684 FreePool (DeviceNode);
3685 DevicePath = NewDevicePath;
3689 FreePool (DevicePathStr);
3694 efidp_parse_device_path(char *path, efidp out, size_t max)
3696 EFI_DEVICE_PATH_PROTOCOL *dp;
3699 dp = UefiDevicePathLibConvertTextToDevicePath (path);
3702 len = GetDevicePathSize(dp);
3707 memcpy(out, dp, len);