2 * Copyright (c) 2017 Netflix, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer
10 * in this position and unchanged.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Routines to format EFI_DEVICE_PATHs from the UEFI standard. Much of
29 * this file is taken from EDK2 and rototilled.
32 #include <sys/cdefs.h>
33 __FBSDID("$FreeBSD$");
43 #include "efi-osdep.h"
44 #include "efivar-dp.h"
46 #include "uefi-dplib.h"
48 /* XXX STUBS -- this stuff doesn't work yet */
49 #define StrToIpv4Address(str, unk, ipv4ptr, unk2)
50 #define StrToIpv6Address(str, unk, ipv6ptr, unk2)
53 * OK. Now this is evil. Can't typedef it again. Sure beats changing them all.
54 * Since we're doing it all as narrow characters since wchar_t can't be used on
55 * FreeBSD and CHAR16 strings generally aren't a good fit. Since this parsing
56 * doesn't need Unicode for anything, this works out well.
61 * Taken from MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
62 * hash a11928f3310518ab1c6fd34e8d0fdbb72de9602c 2017-Mar-01
66 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
68 Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>
69 This program and the accompanying materials
70 are licensed and made available under the terms and conditions of the BSD License
71 which accompanies this distribution. The full text of the license may be found at
72 http://opensource.org/licenses/bsd-license.php
74 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
75 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
79 // #include "UefiDevicePathLib.h"
85 @param Src Source string.
87 @return The duplicated string.
92 UefiDevicePathLibStrDuplicate (
96 return AllocateCopyPool (StrSize (Src), Src);
101 Get parameter in a pair of parentheses follow the given node name.
102 For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".
104 @param Str Device Path Text.
105 @param NodeName Name of the node.
107 @return Parameter text for the node.
114 IN const CHAR16 *NodeName
119 UINTN NodeNameLength;
120 UINTN ParameterLength;
123 // Check whether the node name matchs
125 NodeNameLength = StrLen (NodeName);
126 if (StrnCmp (Str, NodeName, NodeNameLength) != 0) {
130 ParamStr = Str + NodeNameLength;
131 if (!IS_LEFT_PARENTH (*ParamStr)) {
136 // Skip the found '(' and find first occurrence of ')'
140 StrPointer = ParamStr;
141 while (!IS_NULL (*StrPointer)) {
142 if (IS_RIGHT_PARENTH (*StrPointer)) {
148 if (IS_NULL (*StrPointer)) {
155 ParamStr = AllocateCopyPool ((ParameterLength + 1) * sizeof (CHAR16), ParamStr);
156 if (ParamStr == NULL) {
160 // Terminate the parameter string
162 ParamStr[ParameterLength] = '\0';
168 Gets current sub-string from a string list, before return
169 the list header is moved to next sub-string. The sub-string is separated
170 by the specified character. For example, the separator is ',', the string
171 list is "2,0,3", it returns "2", the remain list move to "0,3"
173 @param List A string list separated by the specified separator
174 @param Separator The separator character
176 @return A pointer to the current sub-string
182 IN OUT CHAR16 **List,
192 if (IS_NULL (*Str)) {
197 // Find first occurrence of the separator
199 while (!IS_NULL (*Str)) {
200 if (*Str == Separator) {
206 if (*Str == Separator) {
208 // Find a sub-string, terminate it
215 // Move to next sub-string
223 Gets the next parameter string from the list.
225 @param List A string list separated by the specified separator
227 @return A pointer to the current sub-string
237 // The separator is comma
239 return SplitStr (List, ',');
243 Get one device node from entire device path text.
245 @param DevicePath On input, the current Device Path node; on output, the next device path node
246 @param IsInstanceEnd This node is the end of a device path instance
248 @return A device node text or NULL if no more device node available
253 GetNextDeviceNodeStr (
254 IN OUT CHAR16 **DevicePath,
255 OUT BOOLEAN *IsInstanceEnd
260 UINTN ParenthesesStack;
263 if (IS_NULL (*Str)) {
268 // Skip the leading '/', '(', ')' and ','
270 while (!IS_NULL (*Str)) {
271 if (!IS_SLASH (*Str) &&
273 !IS_LEFT_PARENTH (*Str) &&
274 !IS_RIGHT_PARENTH (*Str)) {
283 // Scan for the separator of this device node, '/' or ','
285 ParenthesesStack = 0;
286 while (!IS_NULL (*Str)) {
287 if ((IS_COMMA (*Str) || IS_SLASH (*Str)) && (ParenthesesStack == 0)) {
291 if (IS_LEFT_PARENTH (*Str)) {
293 } else if (IS_RIGHT_PARENTH (*Str)) {
300 if (ParenthesesStack != 0) {
302 // The '(' doesn't pair with ')', invalid device path text
307 if (IS_COMMA (*Str)) {
308 *IsInstanceEnd = TRUE;
312 *IsInstanceEnd = FALSE;
313 if (!IS_NULL (*Str)) {
327 Return whether the integer string is a hex string.
329 @param Str The integer string
331 @retval TRUE Hex string
332 @retval FALSE Decimal string
342 // skip preceeding white space
344 while ((*Str != 0) && *Str == ' ') {
348 // skip preceeding zeros
350 while ((*Str != 0) && *Str == '0') {
354 return (BOOLEAN) (*Str == 'x' || *Str == 'X');
359 Convert integer string to uint.
361 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
363 @return A UINTN value represented by Str
372 if (IsHexStr (Str)) {
373 return StrHexToUintn (Str);
375 return StrDecimalToUintn (Str);
381 Convert integer string to 64 bit data.
383 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
384 @param Data A pointer to the UINT64 value represented by Str
394 if (IsHexStr (Str)) {
395 *Data = StrHexToUint64 (Str);
397 *Data = StrDecimalToUint64 (Str);
403 Converts a Unicode string to ASCII string.
405 @param Str The equivalent Unicode string
406 @param AsciiStr On input, it points to destination ASCII string buffer; on output, it points
407 to the next ASCII string next to it
414 IN OUT CHAR8 **AsciiStr
420 while (!IS_NULL (*Str)) {
421 *(Dest++) = (CHAR8) *(Str++);
426 // Return the string next to it
428 *AsciiStr = Dest + 1;
432 Converts a generic text device path node to device path structure.
434 @param Type The type of the device path node.
435 @param TextDeviceNode The input text device path node.
437 @return A pointer to device path structure.
440 EFI_DEVICE_PATH_PROTOCOL *
441 DevPathFromTextGenericPath (
443 IN CHAR16 *TextDeviceNode
446 EFI_DEVICE_PATH_PROTOCOL *Node;
451 SubtypeStr = GetNextParamStr (&TextDeviceNode);
452 DataStr = GetNextParamStr (&TextDeviceNode);
454 if (DataStr == NULL) {
457 DataLength = StrLen (DataStr) / 2;
459 Node = CreateDeviceNode (
461 (UINT8) Strtoi (SubtypeStr),
462 (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)
465 StrHexToBytes (DataStr, DataLength * 2, (UINT8 *) (Node + 1), DataLength);
470 Converts a generic text device path node to device path structure.
472 @param TextDeviceNode The input Text device path node.
474 @return A pointer to device path structure.
478 EFI_DEVICE_PATH_PROTOCOL *
479 DevPathFromTextPath (
480 IN CHAR16 *TextDeviceNode
485 TypeStr = GetNextParamStr (&TextDeviceNode);
487 return DevPathFromTextGenericPath ((UINT8) Strtoi (TypeStr), TextDeviceNode);
491 Converts a generic hardware text device path node to Hardware device path structure.
493 @param TextDeviceNode The input Text device path node.
495 @return A pointer to Hardware device path structure.
499 EFI_DEVICE_PATH_PROTOCOL *
500 DevPathFromTextHardwarePath (
501 IN CHAR16 *TextDeviceNode
504 return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH, TextDeviceNode);
508 Converts a text device path node to Hardware PCI device path structure.
510 @param TextDeviceNode The input Text device path node.
512 @return A pointer to Hardware PCI device path structure.
516 EFI_DEVICE_PATH_PROTOCOL *
518 IN CHAR16 *TextDeviceNode
523 PCI_DEVICE_PATH *Pci;
525 DeviceStr = GetNextParamStr (&TextDeviceNode);
526 FunctionStr = GetNextParamStr (&TextDeviceNode);
527 Pci = (PCI_DEVICE_PATH *) CreateDeviceNode (
528 HARDWARE_DEVICE_PATH,
530 (UINT16) sizeof (PCI_DEVICE_PATH)
533 Pci->Function = (UINT8) Strtoi (FunctionStr);
534 Pci->Device = (UINT8) Strtoi (DeviceStr);
536 return (EFI_DEVICE_PATH_PROTOCOL *) Pci;
540 Converts a text device path node to Hardware PC card device path structure.
542 @param TextDeviceNode The input Text device path node.
544 @return A pointer to Hardware PC card device path structure.
548 EFI_DEVICE_PATH_PROTOCOL *
549 DevPathFromTextPcCard (
550 IN CHAR16 *TextDeviceNode
553 CHAR16 *FunctionNumberStr;
554 PCCARD_DEVICE_PATH *Pccard;
556 FunctionNumberStr = GetNextParamStr (&TextDeviceNode);
557 Pccard = (PCCARD_DEVICE_PATH *) CreateDeviceNode (
558 HARDWARE_DEVICE_PATH,
560 (UINT16) sizeof (PCCARD_DEVICE_PATH)
563 Pccard->FunctionNumber = (UINT8) Strtoi (FunctionNumberStr);
565 return (EFI_DEVICE_PATH_PROTOCOL *) Pccard;
569 Converts a text device path node to Hardware memory map device path structure.
571 @param TextDeviceNode The input Text device path node.
573 @return A pointer to Hardware memory map device path structure.
577 EFI_DEVICE_PATH_PROTOCOL *
578 DevPathFromTextMemoryMapped (
579 IN CHAR16 *TextDeviceNode
582 CHAR16 *MemoryTypeStr;
583 CHAR16 *StartingAddressStr;
584 CHAR16 *EndingAddressStr;
585 MEMMAP_DEVICE_PATH *MemMap;
587 MemoryTypeStr = GetNextParamStr (&TextDeviceNode);
588 StartingAddressStr = GetNextParamStr (&TextDeviceNode);
589 EndingAddressStr = GetNextParamStr (&TextDeviceNode);
590 MemMap = (MEMMAP_DEVICE_PATH *) CreateDeviceNode (
591 HARDWARE_DEVICE_PATH,
593 (UINT16) sizeof (MEMMAP_DEVICE_PATH)
596 MemMap->MemoryType = (UINT32) Strtoi (MemoryTypeStr);
597 Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);
598 Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);
600 return (EFI_DEVICE_PATH_PROTOCOL *) MemMap;
604 Converts a text device path node to Vendor device path structure based on the input Type
607 @param TextDeviceNode The input Text device path node.
608 @param Type The type of device path node.
609 @param SubType The subtype of device path node.
611 @return A pointer to the newly-created Vendor device path structure.
615 EFI_DEVICE_PATH_PROTOCOL *
616 ConvertFromTextVendor (
617 IN CHAR16 *TextDeviceNode,
625 VENDOR_DEVICE_PATH *Vendor;
627 GuidStr = GetNextParamStr (&TextDeviceNode);
629 DataStr = GetNextParamStr (&TextDeviceNode);
630 Length = StrLen (DataStr);
632 // Two hex characters make up 1 buffer byte
634 Length = (Length + 1) / 2;
636 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
639 (UINT16) (sizeof (VENDOR_DEVICE_PATH) + Length)
642 StrToGuid (GuidStr, &Vendor->Guid);
643 StrHexToBytes (DataStr, Length * 2, (UINT8 *) (Vendor + 1), Length);
645 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
649 Converts a text device path node to Vendor Hardware device path structure.
651 @param TextDeviceNode The input Text device path node.
653 @return A pointer to the newly-created Vendor Hardware device path structure.
657 EFI_DEVICE_PATH_PROTOCOL *
658 DevPathFromTextVenHw (
659 IN CHAR16 *TextDeviceNode
662 return ConvertFromTextVendor (
664 HARDWARE_DEVICE_PATH,
670 Converts a text device path node to Hardware Controller device path structure.
672 @param TextDeviceNode The input Text device path node.
674 @return A pointer to the newly-created Hardware Controller device path structure.
678 EFI_DEVICE_PATH_PROTOCOL *
679 DevPathFromTextCtrl (
680 IN CHAR16 *TextDeviceNode
683 CHAR16 *ControllerStr;
684 CONTROLLER_DEVICE_PATH *Controller;
686 ControllerStr = GetNextParamStr (&TextDeviceNode);
687 Controller = (CONTROLLER_DEVICE_PATH *) CreateDeviceNode (
688 HARDWARE_DEVICE_PATH,
690 (UINT16) sizeof (CONTROLLER_DEVICE_PATH)
692 Controller->ControllerNumber = (UINT32) Strtoi (ControllerStr);
694 return (EFI_DEVICE_PATH_PROTOCOL *) Controller;
698 Converts a text device path node to BMC device path structure.
700 @param TextDeviceNode The input Text device path node.
702 @return A pointer to the newly-created BMC device path structure.
706 EFI_DEVICE_PATH_PROTOCOL *
708 IN CHAR16 *TextDeviceNode
711 CHAR16 *InterfaceTypeStr;
712 CHAR16 *BaseAddressStr;
713 BMC_DEVICE_PATH *BmcDp;
715 InterfaceTypeStr = GetNextParamStr (&TextDeviceNode);
716 BaseAddressStr = GetNextParamStr (&TextDeviceNode);
717 BmcDp = (BMC_DEVICE_PATH *) CreateDeviceNode (
718 HARDWARE_DEVICE_PATH,
720 (UINT16) sizeof (BMC_DEVICE_PATH)
723 BmcDp->InterfaceType = (UINT8) Strtoi (InterfaceTypeStr);
725 (UINT64 *) (&BmcDp->BaseAddress),
726 StrHexToUint64 (BaseAddressStr)
729 return (EFI_DEVICE_PATH_PROTOCOL *) BmcDp;
733 Converts a generic ACPI text device path node to ACPI device path structure.
735 @param TextDeviceNode The input Text device path node.
737 @return A pointer to ACPI device path structure.
741 EFI_DEVICE_PATH_PROTOCOL *
742 DevPathFromTextAcpiPath (
743 IN CHAR16 *TextDeviceNode
746 return DevPathFromTextGenericPath (ACPI_DEVICE_PATH, TextDeviceNode);
750 Converts a string to EisaId.
752 @param Text The input string.
754 @return UINT32 EISA ID.
762 return (((Text[0] - 'A' + 1) & 0x1f) << 10)
763 + (((Text[1] - 'A' + 1) & 0x1f) << 5)
764 + (((Text[2] - 'A' + 1) & 0x1f) << 0)
765 + (UINT32) (StrHexToUintn (&Text[3]) << 16)
770 Converts a text device path node to ACPI HID device path structure.
772 @param TextDeviceNode The input Text device path node.
774 @return A pointer to the newly-created ACPI HID device path structure.
778 EFI_DEVICE_PATH_PROTOCOL *
779 DevPathFromTextAcpi (
780 IN CHAR16 *TextDeviceNode
785 ACPI_HID_DEVICE_PATH *Acpi;
787 HIDStr = GetNextParamStr (&TextDeviceNode);
788 UIDStr = GetNextParamStr (&TextDeviceNode);
789 Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (
792 (UINT16) sizeof (ACPI_HID_DEVICE_PATH)
795 Acpi->HID = EisaIdFromText (HIDStr);
796 Acpi->UID = (UINT32) Strtoi (UIDStr);
798 return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;
802 Converts a text device path node to ACPI HID device path structure.
804 @param TextDeviceNode The input Text device path node.
805 @param PnPId The input plug and play identification.
807 @return A pointer to the newly-created ACPI HID device path structure.
811 EFI_DEVICE_PATH_PROTOCOL *
812 ConvertFromTextAcpi (
813 IN CHAR16 *TextDeviceNode,
818 ACPI_HID_DEVICE_PATH *Acpi;
820 UIDStr = GetNextParamStr (&TextDeviceNode);
821 Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (
824 (UINT16) sizeof (ACPI_HID_DEVICE_PATH)
827 Acpi->HID = EFI_PNP_ID (PnPId);
828 Acpi->UID = (UINT32) Strtoi (UIDStr);
830 return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;
834 Converts a text device path node to PCI root device path structure.
836 @param TextDeviceNode The input Text device path node.
838 @return A pointer to the newly-created PCI root device path structure.
842 EFI_DEVICE_PATH_PROTOCOL *
843 DevPathFromTextPciRoot (
844 IN CHAR16 *TextDeviceNode
847 return ConvertFromTextAcpi (TextDeviceNode, 0x0a03);
851 Converts a text device path node to PCIE root device path structure.
853 @param TextDeviceNode The input Text device path node.
855 @return A pointer to the newly-created PCIE root device path structure.
859 EFI_DEVICE_PATH_PROTOCOL *
860 DevPathFromTextPcieRoot (
861 IN CHAR16 *TextDeviceNode
864 return ConvertFromTextAcpi (TextDeviceNode, 0x0a08);
868 Converts a text device path node to Floppy device path structure.
870 @param TextDeviceNode The input Text device path node.
872 @return A pointer to the newly-created Floppy device path structure.
876 EFI_DEVICE_PATH_PROTOCOL *
877 DevPathFromTextFloppy (
878 IN CHAR16 *TextDeviceNode
881 return ConvertFromTextAcpi (TextDeviceNode, 0x0604);
885 Converts a text device path node to Keyboard device path structure.
887 @param TextDeviceNode The input Text device path node.
889 @return A pointer to the newly-created Keyboard device path structure.
893 EFI_DEVICE_PATH_PROTOCOL *
894 DevPathFromTextKeyboard (
895 IN CHAR16 *TextDeviceNode
898 return ConvertFromTextAcpi (TextDeviceNode, 0x0301);
902 Converts a text device path node to Serial device path structure.
904 @param TextDeviceNode The input Text device path node.
906 @return A pointer to the newly-created Serial device path structure.
910 EFI_DEVICE_PATH_PROTOCOL *
911 DevPathFromTextSerial (
912 IN CHAR16 *TextDeviceNode
915 return ConvertFromTextAcpi (TextDeviceNode, 0x0501);
919 Converts a text device path node to Parallel Port device path structure.
921 @param TextDeviceNode The input Text device path node.
923 @return A pointer to the newly-created Parallel Port device path structure.
927 EFI_DEVICE_PATH_PROTOCOL *
928 DevPathFromTextParallelPort (
929 IN CHAR16 *TextDeviceNode
932 return ConvertFromTextAcpi (TextDeviceNode, 0x0401);
936 Converts a text device path node to ACPI extension device path structure.
938 @param TextDeviceNode The input Text device path node.
940 @return A pointer to the newly-created ACPI extension device path structure.
944 EFI_DEVICE_PATH_PROTOCOL *
945 DevPathFromTextAcpiEx (
946 IN CHAR16 *TextDeviceNode
957 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;
959 HIDStr = GetNextParamStr (&TextDeviceNode);
960 CIDStr = GetNextParamStr (&TextDeviceNode);
961 UIDStr = GetNextParamStr (&TextDeviceNode);
962 HIDSTRStr = GetNextParamStr (&TextDeviceNode);
963 CIDSTRStr = GetNextParamStr (&TextDeviceNode);
964 UIDSTRStr = GetNextParamStr (&TextDeviceNode);
966 Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (HIDSTRStr) + 1);
967 Length = (UINT16) (Length + StrLen (UIDSTRStr) + 1);
968 Length = (UINT16) (Length + StrLen (CIDSTRStr) + 1);
969 AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (
975 AcpiEx->HID = EisaIdFromText (HIDStr);
976 AcpiEx->CID = EisaIdFromText (CIDStr);
977 AcpiEx->UID = (UINT32) Strtoi (UIDStr);
979 AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
980 StrToAscii (HIDSTRStr, &AsciiStr);
981 StrToAscii (UIDSTRStr, &AsciiStr);
982 StrToAscii (CIDSTRStr, &AsciiStr);
984 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;
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.
996 EFI_DEVICE_PATH_PROTOCOL *
997 DevPathFromTextAcpiExp (
998 IN CHAR16 *TextDeviceNode
1006 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;
1008 HIDStr = GetNextParamStr (&TextDeviceNode);
1009 CIDStr = GetNextParamStr (&TextDeviceNode);
1010 UIDSTRStr = GetNextParamStr (&TextDeviceNode);
1011 Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (UIDSTRStr) + 3);
1012 AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (
1018 AcpiEx->HID = EisaIdFromText (HIDStr);
1019 AcpiEx->CID = EisaIdFromText (CIDStr);
1022 AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
1024 // HID string is NULL
1028 // Convert UID string
1031 StrToAscii (UIDSTRStr, &AsciiStr);
1033 // CID string is NULL
1037 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;
1041 Converts a text device path node to ACPI _ADR device path structure.
1043 @param TextDeviceNode The input Text device path node.
1045 @return A pointer to the newly-created ACPI _ADR device path structure.
1049 EFI_DEVICE_PATH_PROTOCOL *
1050 DevPathFromTextAcpiAdr (
1051 IN CHAR16 *TextDeviceNode
1054 CHAR16 *DisplayDeviceStr;
1055 ACPI_ADR_DEVICE_PATH *AcpiAdr;
1059 AcpiAdr = (ACPI_ADR_DEVICE_PATH *) CreateDeviceNode (
1062 (UINT16) sizeof (ACPI_ADR_DEVICE_PATH)
1064 ASSERT (AcpiAdr != NULL);
1066 for (Index = 0; ; Index++) {
1067 DisplayDeviceStr = GetNextParamStr (&TextDeviceNode);
1068 if (IS_NULL (*DisplayDeviceStr)) {
1072 Length = DevicePathNodeLength (AcpiAdr);
1073 AcpiAdr = ReallocatePool (
1075 Length + sizeof (UINT32),
1078 ASSERT (AcpiAdr != NULL);
1079 SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));
1082 (&AcpiAdr->ADR)[Index] = (UINT32) Strtoi (DisplayDeviceStr);
1085 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr;
1089 Converts a generic messaging text device path node to messaging device path structure.
1091 @param TextDeviceNode The input Text device path node.
1093 @return A pointer to messaging device path structure.
1097 EFI_DEVICE_PATH_PROTOCOL *
1098 DevPathFromTextMsg (
1099 IN CHAR16 *TextDeviceNode
1102 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH, TextDeviceNode);
1106 Converts a text device path node to Parallel Port device path structure.
1108 @param TextDeviceNode The input Text device path node.
1110 @return A pointer to the newly-created Parallel Port device path structure.
1114 EFI_DEVICE_PATH_PROTOCOL *
1115 DevPathFromTextAta (
1116 IN CHAR16 *TextDeviceNode
1119 CHAR16 *PrimarySecondaryStr;
1120 CHAR16 *SlaveMasterStr;
1122 ATAPI_DEVICE_PATH *Atapi;
1124 Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (
1125 MESSAGING_DEVICE_PATH,
1127 (UINT16) sizeof (ATAPI_DEVICE_PATH)
1130 PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);
1131 SlaveMasterStr = GetNextParamStr (&TextDeviceNode);
1132 LunStr = GetNextParamStr (&TextDeviceNode);
1134 if (StrCmp (PrimarySecondaryStr, "Primary") == 0) {
1135 Atapi->PrimarySecondary = 0;
1136 } else if (StrCmp (PrimarySecondaryStr, "Secondary") == 0) {
1137 Atapi->PrimarySecondary = 1;
1139 Atapi->PrimarySecondary = (UINT8) Strtoi (PrimarySecondaryStr);
1141 if (StrCmp (SlaveMasterStr, "Master") == 0) {
1142 Atapi->SlaveMaster = 0;
1143 } else if (StrCmp (SlaveMasterStr, "Slave") == 0) {
1144 Atapi->SlaveMaster = 1;
1146 Atapi->SlaveMaster = (UINT8) Strtoi (SlaveMasterStr);
1149 Atapi->Lun = (UINT16) Strtoi (LunStr);
1151 return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;
1155 Converts a text device path node to SCSI device path structure.
1157 @param TextDeviceNode The input Text device path node.
1159 @return A pointer to the newly-created SCSI device path structure.
1163 EFI_DEVICE_PATH_PROTOCOL *
1164 DevPathFromTextScsi (
1165 IN CHAR16 *TextDeviceNode
1170 SCSI_DEVICE_PATH *Scsi;
1172 PunStr = GetNextParamStr (&TextDeviceNode);
1173 LunStr = GetNextParamStr (&TextDeviceNode);
1174 Scsi = (SCSI_DEVICE_PATH *) CreateDeviceNode (
1175 MESSAGING_DEVICE_PATH,
1177 (UINT16) sizeof (SCSI_DEVICE_PATH)
1180 Scsi->Pun = (UINT16) Strtoi (PunStr);
1181 Scsi->Lun = (UINT16) Strtoi (LunStr);
1183 return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;
1187 Converts a text device path node to Fibre device path structure.
1189 @param TextDeviceNode The input Text device path node.
1191 @return A pointer to the newly-created Fibre device path structure.
1195 EFI_DEVICE_PATH_PROTOCOL *
1196 DevPathFromTextFibre (
1197 IN CHAR16 *TextDeviceNode
1202 FIBRECHANNEL_DEVICE_PATH *Fibre;
1204 WWNStr = GetNextParamStr (&TextDeviceNode);
1205 LunStr = GetNextParamStr (&TextDeviceNode);
1206 Fibre = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (
1207 MESSAGING_DEVICE_PATH,
1208 MSG_FIBRECHANNEL_DP,
1209 (UINT16) sizeof (FIBRECHANNEL_DEVICE_PATH)
1212 Fibre->Reserved = 0;
1213 Strtoi64 (WWNStr, &Fibre->WWN);
1214 Strtoi64 (LunStr, &Fibre->Lun);
1216 return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;
1220 Converts a text device path node to FibreEx device path structure.
1222 @param TextDeviceNode The input Text device path node.
1224 @return A pointer to the newly-created FibreEx device path structure.
1228 EFI_DEVICE_PATH_PROTOCOL *
1229 DevPathFromTextFibreEx (
1230 IN CHAR16 *TextDeviceNode
1235 FIBRECHANNELEX_DEVICE_PATH *FibreEx;
1237 WWNStr = GetNextParamStr (&TextDeviceNode);
1238 LunStr = GetNextParamStr (&TextDeviceNode);
1239 FibreEx = (FIBRECHANNELEX_DEVICE_PATH *) CreateDeviceNode (
1240 MESSAGING_DEVICE_PATH,
1241 MSG_FIBRECHANNELEX_DP,
1242 (UINT16) sizeof (FIBRECHANNELEX_DEVICE_PATH)
1245 FibreEx->Reserved = 0;
1246 Strtoi64 (WWNStr, (UINT64 *) (&FibreEx->WWN));
1247 Strtoi64 (LunStr, (UINT64 *) (&FibreEx->Lun));
1249 *(UINT64 *) (&FibreEx->WWN) = SwapBytes64 (*(UINT64 *) (&FibreEx->WWN));
1250 *(UINT64 *) (&FibreEx->Lun) = SwapBytes64 (*(UINT64 *) (&FibreEx->Lun));
1252 return (EFI_DEVICE_PATH_PROTOCOL *) FibreEx;
1256 Converts a text device path node to 1394 device path structure.
1258 @param TextDeviceNode The input Text device path node.
1260 @return A pointer to the newly-created 1394 device path structure.
1264 EFI_DEVICE_PATH_PROTOCOL *
1265 DevPathFromText1394 (
1266 IN CHAR16 *TextDeviceNode
1270 F1394_DEVICE_PATH *F1394DevPath;
1272 GuidStr = GetNextParamStr (&TextDeviceNode);
1273 F1394DevPath = (F1394_DEVICE_PATH *) CreateDeviceNode (
1274 MESSAGING_DEVICE_PATH,
1276 (UINT16) sizeof (F1394_DEVICE_PATH)
1279 F1394DevPath->Reserved = 0;
1280 F1394DevPath->Guid = StrHexToUint64 (GuidStr);
1282 return (EFI_DEVICE_PATH_PROTOCOL *) F1394DevPath;
1286 Converts a text device path node to USB device path structure.
1288 @param TextDeviceNode The input Text device path node.
1290 @return A pointer to the newly-created USB device path structure.
1294 EFI_DEVICE_PATH_PROTOCOL *
1295 DevPathFromTextUsb (
1296 IN CHAR16 *TextDeviceNode
1300 CHAR16 *InterfaceStr;
1301 USB_DEVICE_PATH *Usb;
1303 PortStr = GetNextParamStr (&TextDeviceNode);
1304 InterfaceStr = GetNextParamStr (&TextDeviceNode);
1305 Usb = (USB_DEVICE_PATH *) CreateDeviceNode (
1306 MESSAGING_DEVICE_PATH,
1308 (UINT16) sizeof (USB_DEVICE_PATH)
1311 Usb->ParentPortNumber = (UINT8) Strtoi (PortStr);
1312 Usb->InterfaceNumber = (UINT8) Strtoi (InterfaceStr);
1314 return (EFI_DEVICE_PATH_PROTOCOL *) Usb;
1318 Converts a text device path node to I20 device path structure.
1320 @param TextDeviceNode The input Text device path node.
1322 @return A pointer to the newly-created I20 device path structure.
1326 EFI_DEVICE_PATH_PROTOCOL *
1327 DevPathFromTextI2O (
1328 IN CHAR16 *TextDeviceNode
1332 I2O_DEVICE_PATH *I2ODevPath;
1334 TIDStr = GetNextParamStr (&TextDeviceNode);
1335 I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode (
1336 MESSAGING_DEVICE_PATH,
1338 (UINT16) sizeof (I2O_DEVICE_PATH)
1341 I2ODevPath->Tid = (UINT32) Strtoi (TIDStr);
1343 return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath;
1347 Converts a text device path node to Infini Band device path structure.
1349 @param TextDeviceNode The input Text device path node.
1351 @return A pointer to the newly-created Infini Band device path structure.
1355 EFI_DEVICE_PATH_PROTOCOL *
1356 DevPathFromTextInfiniband (
1357 IN CHAR16 *TextDeviceNode
1365 INFINIBAND_DEVICE_PATH *InfiniBand;
1367 FlagsStr = GetNextParamStr (&TextDeviceNode);
1368 GuidStr = GetNextParamStr (&TextDeviceNode);
1369 SidStr = GetNextParamStr (&TextDeviceNode);
1370 TidStr = GetNextParamStr (&TextDeviceNode);
1371 DidStr = GetNextParamStr (&TextDeviceNode);
1372 InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (
1373 MESSAGING_DEVICE_PATH,
1375 (UINT16) sizeof (INFINIBAND_DEVICE_PATH)
1378 InfiniBand->ResourceFlags = (UINT32) Strtoi (FlagsStr);
1379 StrToGuid (GuidStr, (EFI_GUID *) InfiniBand->PortGid);
1380 Strtoi64 (SidStr, &InfiniBand->ServiceId);
1381 Strtoi64 (TidStr, &InfiniBand->TargetPortId);
1382 Strtoi64 (DidStr, &InfiniBand->DeviceId);
1384 return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;
1388 Converts a text device path node to Vendor-Defined Messaging device path structure.
1390 @param TextDeviceNode The input Text device path node.
1392 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1396 EFI_DEVICE_PATH_PROTOCOL *
1397 DevPathFromTextVenMsg (
1398 IN CHAR16 *TextDeviceNode
1401 return ConvertFromTextVendor (
1403 MESSAGING_DEVICE_PATH,
1409 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1411 @param TextDeviceNode The input Text device path node.
1413 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1417 EFI_DEVICE_PATH_PROTOCOL *
1418 DevPathFromTextVenPcAnsi (
1419 IN CHAR16 *TextDeviceNode
1422 VENDOR_DEVICE_PATH *Vendor;
1424 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
1425 MESSAGING_DEVICE_PATH,
1427 (UINT16) sizeof (VENDOR_DEVICE_PATH));
1428 CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);
1430 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
1434 Converts a text device path node to Vendor defined VT100 device path structure.
1436 @param TextDeviceNode The input Text device path node.
1438 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1442 EFI_DEVICE_PATH_PROTOCOL *
1443 DevPathFromTextVenVt100 (
1444 IN CHAR16 *TextDeviceNode
1447 VENDOR_DEVICE_PATH *Vendor;
1449 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
1450 MESSAGING_DEVICE_PATH,
1452 (UINT16) sizeof (VENDOR_DEVICE_PATH));
1453 CopyGuid (&Vendor->Guid, &gEfiVT100Guid);
1455 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
1459 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1461 @param TextDeviceNode The input Text device path node.
1463 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1467 EFI_DEVICE_PATH_PROTOCOL *
1468 DevPathFromTextVenVt100Plus (
1469 IN CHAR16 *TextDeviceNode
1472 VENDOR_DEVICE_PATH *Vendor;
1474 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
1475 MESSAGING_DEVICE_PATH,
1477 (UINT16) sizeof (VENDOR_DEVICE_PATH));
1478 CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);
1480 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
1484 Converts a text device path node to Vendor defined UTF8 device path structure.
1486 @param TextDeviceNode The input Text device path node.
1488 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1492 EFI_DEVICE_PATH_PROTOCOL *
1493 DevPathFromTextVenUtf8 (
1494 IN CHAR16 *TextDeviceNode
1497 VENDOR_DEVICE_PATH *Vendor;
1499 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
1500 MESSAGING_DEVICE_PATH,
1502 (UINT16) sizeof (VENDOR_DEVICE_PATH));
1503 CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);
1505 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
1509 Converts a text device path node to UART Flow Control device path structure.
1511 @param TextDeviceNode The input Text device path node.
1513 @return A pointer to the newly-created UART Flow Control device path structure.
1517 EFI_DEVICE_PATH_PROTOCOL *
1518 DevPathFromTextUartFlowCtrl (
1519 IN CHAR16 *TextDeviceNode
1523 UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;
1525 ValueStr = GetNextParamStr (&TextDeviceNode);
1526 UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (
1527 MESSAGING_DEVICE_PATH,
1529 (UINT16) sizeof (UART_FLOW_CONTROL_DEVICE_PATH)
1532 CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);
1533 if (StrCmp (ValueStr, "XonXoff") == 0) {
1534 UartFlowControl->FlowControlMap = 2;
1535 } else if (StrCmp (ValueStr, "Hardware") == 0) {
1536 UartFlowControl->FlowControlMap = 1;
1538 UartFlowControl->FlowControlMap = 0;
1541 return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;
1545 Converts a text device path node to Serial Attached SCSI device path structure.
1547 @param TextDeviceNode The input Text device path node.
1549 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1553 EFI_DEVICE_PATH_PROTOCOL *
1554 DevPathFromTextSAS (
1555 IN CHAR16 *TextDeviceNode
1562 CHAR16 *LocationStr;
1564 CHAR16 *DriveBayStr;
1565 CHAR16 *ReservedStr;
1568 SAS_DEVICE_PATH *Sas;
1570 AddressStr = GetNextParamStr (&TextDeviceNode);
1571 LunStr = GetNextParamStr (&TextDeviceNode);
1572 RTPStr = GetNextParamStr (&TextDeviceNode);
1573 SASSATAStr = GetNextParamStr (&TextDeviceNode);
1574 LocationStr = GetNextParamStr (&TextDeviceNode);
1575 ConnectStr = GetNextParamStr (&TextDeviceNode);
1576 DriveBayStr = GetNextParamStr (&TextDeviceNode);
1577 ReservedStr = GetNextParamStr (&TextDeviceNode);
1578 Sas = (SAS_DEVICE_PATH *) CreateDeviceNode (
1579 MESSAGING_DEVICE_PATH,
1581 (UINT16) sizeof (SAS_DEVICE_PATH)
1584 CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid);
1585 Strtoi64 (AddressStr, &Sas->SasAddress);
1586 Strtoi64 (LunStr, &Sas->Lun);
1587 Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr);
1589 if (StrCmp (SASSATAStr, "NoTopology") == 0) {
1592 } else if ((StrCmp (SASSATAStr, "SATA") == 0) || (StrCmp (SASSATAStr, "SAS") == 0)) {
1594 Uint16 = (UINT16) Strtoi (DriveBayStr);
1598 Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));
1601 if (StrCmp (SASSATAStr, "SATA") == 0) {
1606 // Location is an integer between 0 and 1 or else
1607 // the keyword Internal (0) or External (1).
1609 if (StrCmp (LocationStr, "External") == 0) {
1611 } else if (StrCmp (LocationStr, "Internal") == 0) {
1614 Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);
1616 Info |= (Uint16 << 5);
1619 // Connect is an integer between 0 and 3 or else
1620 // the keyword Direct (0) or Expanded (1).
1622 if (StrCmp (ConnectStr, "Expanded") == 0) {
1624 } else if (StrCmp (ConnectStr, "Direct") == 0) {
1627 Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));
1629 Info |= (Uint16 << 6);
1632 Info = (UINT16) Strtoi (SASSATAStr);
1635 Sas->DeviceTopology = Info;
1636 Sas->Reserved = (UINT32) Strtoi (ReservedStr);
1638 return (EFI_DEVICE_PATH_PROTOCOL *) Sas;
1642 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1644 @param TextDeviceNode The input Text device path node.
1646 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1650 EFI_DEVICE_PATH_PROTOCOL *
1651 DevPathFromTextSasEx (
1652 IN CHAR16 *TextDeviceNode
1659 CHAR16 *LocationStr;
1661 CHAR16 *DriveBayStr;
1666 SASEX_DEVICE_PATH *SasEx;
1668 AddressStr = GetNextParamStr (&TextDeviceNode);
1669 LunStr = GetNextParamStr (&TextDeviceNode);
1670 RTPStr = GetNextParamStr (&TextDeviceNode);
1671 SASSATAStr = GetNextParamStr (&TextDeviceNode);
1672 LocationStr = GetNextParamStr (&TextDeviceNode);
1673 ConnectStr = GetNextParamStr (&TextDeviceNode);
1674 DriveBayStr = GetNextParamStr (&TextDeviceNode);
1675 SasEx = (SASEX_DEVICE_PATH *) CreateDeviceNode (
1676 MESSAGING_DEVICE_PATH,
1678 (UINT16) sizeof (SASEX_DEVICE_PATH)
1681 Strtoi64 (AddressStr, &SasAddress);
1682 Strtoi64 (LunStr, &Lun);
1683 WriteUnaligned64 ((UINT64 *) &SasEx->SasAddress, SwapBytes64 (SasAddress));
1684 WriteUnaligned64 ((UINT64 *) &SasEx->Lun, SwapBytes64 (Lun));
1685 SasEx->RelativeTargetPort = (UINT16) Strtoi (RTPStr);
1687 if (StrCmp (SASSATAStr, "NoTopology") == 0) {
1690 } else if ((StrCmp (SASSATAStr, "SATA") == 0) || (StrCmp (SASSATAStr, "SAS") == 0)) {
1692 Uint16 = (UINT16) Strtoi (DriveBayStr);
1696 Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));
1699 if (StrCmp (SASSATAStr, "SATA") == 0) {
1704 // Location is an integer between 0 and 1 or else
1705 // the keyword Internal (0) or External (1).
1707 if (StrCmp (LocationStr, "External") == 0) {
1709 } else if (StrCmp (LocationStr, "Internal") == 0) {
1712 Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);
1714 Info |= (Uint16 << 5);
1717 // Connect is an integer between 0 and 3 or else
1718 // the keyword Direct (0) or Expanded (1).
1720 if (StrCmp (ConnectStr, "Expanded") == 0) {
1722 } else if (StrCmp (ConnectStr, "Direct") == 0) {
1725 Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));
1727 Info |= (Uint16 << 6);
1730 Info = (UINT16) Strtoi (SASSATAStr);
1733 SasEx->DeviceTopology = Info;
1735 return (EFI_DEVICE_PATH_PROTOCOL *) SasEx;
1739 Converts a text device path node to NVM Express Namespace device path structure.
1741 @param TextDeviceNode The input Text device path node.
1743 @return A pointer to the newly-created NVM Express Namespace device path structure.
1747 EFI_DEVICE_PATH_PROTOCOL *
1748 DevPathFromTextNVMe (
1749 IN CHAR16 *TextDeviceNode
1752 CHAR16 *NamespaceIdStr;
1753 CHAR16 *NamespaceUuidStr;
1754 NVME_NAMESPACE_DEVICE_PATH *Nvme;
1758 NamespaceIdStr = GetNextParamStr (&TextDeviceNode);
1759 NamespaceUuidStr = GetNextParamStr (&TextDeviceNode);
1760 Nvme = (NVME_NAMESPACE_DEVICE_PATH *) CreateDeviceNode (
1761 MESSAGING_DEVICE_PATH,
1762 MSG_NVME_NAMESPACE_DP,
1763 (UINT16) sizeof (NVME_NAMESPACE_DEVICE_PATH)
1766 Nvme->NamespaceId = (UINT32) Strtoi (NamespaceIdStr);
1767 Uuid = (UINT8 *) &Nvme->NamespaceUuid;
1769 Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);
1770 while (Index-- != 0) {
1771 Uuid[Index] = (UINT8) StrHexToUintn (SplitStr (&NamespaceUuidStr, '-'));
1774 return (EFI_DEVICE_PATH_PROTOCOL *) Nvme;
1778 Converts a text device path node to UFS device path structure.
1780 @param TextDeviceNode The input Text device path node.
1782 @return A pointer to the newly-created UFS device path structure.
1786 EFI_DEVICE_PATH_PROTOCOL *
1787 DevPathFromTextUfs (
1788 IN CHAR16 *TextDeviceNode
1793 UFS_DEVICE_PATH *Ufs;
1795 PunStr = GetNextParamStr (&TextDeviceNode);
1796 LunStr = GetNextParamStr (&TextDeviceNode);
1797 Ufs = (UFS_DEVICE_PATH *) CreateDeviceNode (
1798 MESSAGING_DEVICE_PATH,
1800 (UINT16) sizeof (UFS_DEVICE_PATH)
1803 Ufs->Pun = (UINT8) Strtoi (PunStr);
1804 Ufs->Lun = (UINT8) Strtoi (LunStr);
1806 return (EFI_DEVICE_PATH_PROTOCOL *) Ufs;
1810 Converts a text device path node to SD (Secure Digital) device path structure.
1812 @param TextDeviceNode The input Text device path node.
1814 @return A pointer to the newly-created SD device path structure.
1818 EFI_DEVICE_PATH_PROTOCOL *
1820 IN CHAR16 *TextDeviceNode
1823 CHAR16 *SlotNumberStr;
1826 SlotNumberStr = GetNextParamStr (&TextDeviceNode);
1827 Sd = (SD_DEVICE_PATH *) CreateDeviceNode (
1828 MESSAGING_DEVICE_PATH,
1830 (UINT16) sizeof (SD_DEVICE_PATH)
1833 Sd->SlotNumber = (UINT8) Strtoi (SlotNumberStr);
1835 return (EFI_DEVICE_PATH_PROTOCOL *) Sd;
1839 Converts a text device path node to EMMC (Embedded MMC) device path structure.
1841 @param TextDeviceNode The input Text device path node.
1843 @return A pointer to the newly-created EMMC device path structure.
1847 EFI_DEVICE_PATH_PROTOCOL *
1848 DevPathFromTextEmmc (
1849 IN CHAR16 *TextDeviceNode
1852 CHAR16 *SlotNumberStr;
1853 EMMC_DEVICE_PATH *Emmc;
1855 SlotNumberStr = GetNextParamStr (&TextDeviceNode);
1856 Emmc = (EMMC_DEVICE_PATH *) CreateDeviceNode (
1857 MESSAGING_DEVICE_PATH,
1859 (UINT16) sizeof (EMMC_DEVICE_PATH)
1862 Emmc->SlotNumber = (UINT8) Strtoi (SlotNumberStr);
1864 return (EFI_DEVICE_PATH_PROTOCOL *) Emmc;
1868 Converts a text device path node to Debug Port device path structure.
1870 @param TextDeviceNode The input Text device path node.
1872 @return A pointer to the newly-created Debug Port device path structure.
1876 EFI_DEVICE_PATH_PROTOCOL *
1877 DevPathFromTextDebugPort (
1878 IN CHAR16 *TextDeviceNode
1881 VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend;
1883 Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (
1884 MESSAGING_DEVICE_PATH,
1886 (UINT16) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)
1889 CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);
1891 return (EFI_DEVICE_PATH_PROTOCOL *) Vend;
1895 Converts a text device path node to MAC device path structure.
1897 @param TextDeviceNode The input Text device path node.
1899 @return A pointer to the newly-created MAC device path structure.
1903 EFI_DEVICE_PATH_PROTOCOL *
1904 DevPathFromTextMAC (
1905 IN CHAR16 *TextDeviceNode
1911 MAC_ADDR_DEVICE_PATH *MACDevPath;
1913 AddressStr = GetNextParamStr (&TextDeviceNode);
1914 IfTypeStr = GetNextParamStr (&TextDeviceNode);
1915 MACDevPath = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (
1916 MESSAGING_DEVICE_PATH,
1918 (UINT16) sizeof (MAC_ADDR_DEVICE_PATH)
1921 MACDevPath->IfType = (UINT8) Strtoi (IfTypeStr);
1923 Length = sizeof (EFI_MAC_ADDRESS);
1924 StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length);
1926 return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;
1931 Converts a text format to the network protocol ID.
1933 @param Text String of protocol field.
1935 @return Network protocol ID .
1940 NetworkProtocolFromText (
1944 if (StrCmp (Text, "UDP") == 0) {
1945 return RFC_1700_UDP_PROTOCOL;
1948 if (StrCmp (Text, "TCP") == 0) {
1949 return RFC_1700_TCP_PROTOCOL;
1952 return Strtoi (Text);
1957 Converts a text device path node to IPV4 device path structure.
1959 @param TextDeviceNode The input Text device path node.
1961 @return A pointer to the newly-created IPV4 device path structure.
1965 EFI_DEVICE_PATH_PROTOCOL *
1966 DevPathFromTextIPv4 (
1967 IN CHAR16 *TextDeviceNode
1970 CHAR16 *RemoteIPStr;
1971 CHAR16 *ProtocolStr;
1974 CHAR16 *GatewayIPStr;
1975 CHAR16 *SubnetMaskStr;
1976 IPv4_DEVICE_PATH *IPv4;
1978 RemoteIPStr = GetNextParamStr (&TextDeviceNode);
1979 ProtocolStr = GetNextParamStr (&TextDeviceNode);
1980 TypeStr = GetNextParamStr (&TextDeviceNode);
1981 LocalIPStr = GetNextParamStr (&TextDeviceNode);
1982 GatewayIPStr = GetNextParamStr (&TextDeviceNode);
1983 SubnetMaskStr = GetNextParamStr (&TextDeviceNode);
1984 IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (
1985 MESSAGING_DEVICE_PATH,
1987 (UINT16) sizeof (IPv4_DEVICE_PATH)
1990 StrToIpv4Address (RemoteIPStr, NULL, &IPv4->RemoteIpAddress, NULL);
1991 IPv4->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);
1992 if (StrCmp (TypeStr, "Static") == 0) {
1993 IPv4->StaticIpAddress = TRUE;
1995 IPv4->StaticIpAddress = FALSE;
1998 StrToIpv4Address (LocalIPStr, NULL, &IPv4->LocalIpAddress, NULL);
1999 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*SubnetMaskStr)) {
2000 StrToIpv4Address (GatewayIPStr, NULL, &IPv4->GatewayIpAddress, NULL);
2001 StrToIpv4Address (SubnetMaskStr, NULL, &IPv4->SubnetMask, NULL);
2003 ZeroMem (&IPv4->GatewayIpAddress, sizeof (IPv4->GatewayIpAddress));
2004 ZeroMem (&IPv4->SubnetMask, sizeof (IPv4->SubnetMask));
2007 IPv4->LocalPort = 0;
2008 IPv4->RemotePort = 0;
2010 return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;
2014 Converts a text device path node to IPV6 device path structure.
2016 @param TextDeviceNode The input Text device path node.
2018 @return A pointer to the newly-created IPV6 device path structure.
2022 EFI_DEVICE_PATH_PROTOCOL *
2023 DevPathFromTextIPv6 (
2024 IN CHAR16 *TextDeviceNode
2027 CHAR16 *RemoteIPStr;
2028 CHAR16 *ProtocolStr;
2031 CHAR16 *GatewayIPStr;
2032 CHAR16 *PrefixLengthStr;
2033 IPv6_DEVICE_PATH *IPv6;
2035 RemoteIPStr = GetNextParamStr (&TextDeviceNode);
2036 ProtocolStr = GetNextParamStr (&TextDeviceNode);
2037 TypeStr = GetNextParamStr (&TextDeviceNode);
2038 LocalIPStr = GetNextParamStr (&TextDeviceNode);
2039 PrefixLengthStr = GetNextParamStr (&TextDeviceNode);
2040 GatewayIPStr = GetNextParamStr (&TextDeviceNode);
2041 IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (
2042 MESSAGING_DEVICE_PATH,
2044 (UINT16) sizeof (IPv6_DEVICE_PATH)
2047 StrToIpv6Address (RemoteIPStr, NULL, &IPv6->RemoteIpAddress, NULL);
2048 IPv6->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);
2049 if (StrCmp (TypeStr, "Static") == 0) {
2050 IPv6->IpAddressOrigin = 0;
2051 } else if (StrCmp (TypeStr, "StatelessAutoConfigure") == 0) {
2052 IPv6->IpAddressOrigin = 1;
2054 IPv6->IpAddressOrigin = 2;
2057 StrToIpv6Address (LocalIPStr, NULL, &IPv6->LocalIpAddress, NULL);
2058 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*PrefixLengthStr)) {
2059 StrToIpv6Address (GatewayIPStr, NULL, &IPv6->GatewayIpAddress, NULL);
2060 IPv6->PrefixLength = (UINT8) Strtoi (PrefixLengthStr);
2062 ZeroMem (&IPv6->GatewayIpAddress, sizeof (IPv6->GatewayIpAddress));
2063 IPv6->PrefixLength = 0;
2066 IPv6->LocalPort = 0;
2067 IPv6->RemotePort = 0;
2069 return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;
2073 Converts a text device path node to UART device path structure.
2075 @param TextDeviceNode The input Text device path node.
2077 @return A pointer to the newly-created UART device path structure.
2081 EFI_DEVICE_PATH_PROTOCOL *
2082 DevPathFromTextUart (
2083 IN CHAR16 *TextDeviceNode
2087 CHAR16 *DataBitsStr;
2089 CHAR16 *StopBitsStr;
2090 UART_DEVICE_PATH *Uart;
2092 BaudStr = GetNextParamStr (&TextDeviceNode);
2093 DataBitsStr = GetNextParamStr (&TextDeviceNode);
2094 ParityStr = GetNextParamStr (&TextDeviceNode);
2095 StopBitsStr = GetNextParamStr (&TextDeviceNode);
2096 Uart = (UART_DEVICE_PATH *) CreateDeviceNode (
2097 MESSAGING_DEVICE_PATH,
2099 (UINT16) sizeof (UART_DEVICE_PATH)
2102 if (StrCmp (BaudStr, "DEFAULT") == 0) {
2103 Uart->BaudRate = 115200;
2105 Strtoi64 (BaudStr, &Uart->BaudRate);
2107 Uart->DataBits = (UINT8) ((StrCmp (DataBitsStr, "DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr));
2108 switch (*ParityStr) {
2134 Uart->Parity = (UINT8) Strtoi (ParityStr);
2138 if (StrCmp (StopBitsStr, "D") == 0) {
2139 Uart->StopBits = (UINT8) 0;
2140 } else if (StrCmp (StopBitsStr, "1") == 0) {
2141 Uart->StopBits = (UINT8) 1;
2142 } else if (StrCmp (StopBitsStr, "1.5") == 0) {
2143 Uart->StopBits = (UINT8) 2;
2144 } else if (StrCmp (StopBitsStr, "2") == 0) {
2145 Uart->StopBits = (UINT8) 3;
2147 Uart->StopBits = (UINT8) Strtoi (StopBitsStr);
2150 return (EFI_DEVICE_PATH_PROTOCOL *) Uart;
2154 Converts a text device path node to USB class device path structure.
2156 @param TextDeviceNode The input Text device path node.
2157 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
2159 @return A pointer to the newly-created USB class device path structure.
2163 EFI_DEVICE_PATH_PROTOCOL *
2164 ConvertFromTextUsbClass (
2165 IN CHAR16 *TextDeviceNode,
2166 IN USB_CLASS_TEXT *UsbClassText
2172 CHAR16 *SubClassStr;
2173 CHAR16 *ProtocolStr;
2174 USB_CLASS_DEVICE_PATH *UsbClass;
2176 UsbClass = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (
2177 MESSAGING_DEVICE_PATH,
2179 (UINT16) sizeof (USB_CLASS_DEVICE_PATH)
2182 VIDStr = GetNextParamStr (&TextDeviceNode);
2183 PIDStr = GetNextParamStr (&TextDeviceNode);
2184 if (UsbClassText->ClassExist) {
2185 ClassStr = GetNextParamStr (&TextDeviceNode);
2186 UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);
2188 UsbClass->DeviceClass = UsbClassText->Class;
2190 if (UsbClassText->SubClassExist) {
2191 SubClassStr = GetNextParamStr (&TextDeviceNode);
2192 UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);
2194 UsbClass->DeviceSubClass = UsbClassText->SubClass;
2197 ProtocolStr = GetNextParamStr (&TextDeviceNode);
2199 UsbClass->VendorId = (UINT16) Strtoi (VIDStr);
2200 UsbClass->ProductId = (UINT16) Strtoi (PIDStr);
2201 UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);
2203 return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;
2208 Converts a text device path node to USB class device path structure.
2210 @param TextDeviceNode The input Text device path node.
2212 @return A pointer to the newly-created USB class device path structure.
2216 EFI_DEVICE_PATH_PROTOCOL *
2217 DevPathFromTextUsbClass (
2218 IN CHAR16 *TextDeviceNode
2221 USB_CLASS_TEXT UsbClassText;
2223 UsbClassText.ClassExist = TRUE;
2224 UsbClassText.SubClassExist = TRUE;
2226 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2230 Converts a text device path node to USB audio device path structure.
2232 @param TextDeviceNode The input Text device path node.
2234 @return A pointer to the newly-created USB audio device path structure.
2238 EFI_DEVICE_PATH_PROTOCOL *
2239 DevPathFromTextUsbAudio (
2240 IN CHAR16 *TextDeviceNode
2243 USB_CLASS_TEXT UsbClassText;
2245 UsbClassText.ClassExist = FALSE;
2246 UsbClassText.Class = USB_CLASS_AUDIO;
2247 UsbClassText.SubClassExist = TRUE;
2249 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2253 Converts a text device path node to USB CDC Control device path structure.
2255 @param TextDeviceNode The input Text device path node.
2257 @return A pointer to the newly-created USB CDC Control device path structure.
2261 EFI_DEVICE_PATH_PROTOCOL *
2262 DevPathFromTextUsbCDCControl (
2263 IN CHAR16 *TextDeviceNode
2266 USB_CLASS_TEXT UsbClassText;
2268 UsbClassText.ClassExist = FALSE;
2269 UsbClassText.Class = USB_CLASS_CDCCONTROL;
2270 UsbClassText.SubClassExist = TRUE;
2272 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2276 Converts a text device path node to USB HID device path structure.
2278 @param TextDeviceNode The input Text device path node.
2280 @return A pointer to the newly-created USB HID device path structure.
2284 EFI_DEVICE_PATH_PROTOCOL *
2285 DevPathFromTextUsbHID (
2286 IN CHAR16 *TextDeviceNode
2289 USB_CLASS_TEXT UsbClassText;
2291 UsbClassText.ClassExist = FALSE;
2292 UsbClassText.Class = USB_CLASS_HID;
2293 UsbClassText.SubClassExist = TRUE;
2295 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2299 Converts a text device path node to USB Image device path structure.
2301 @param TextDeviceNode The input Text device path node.
2303 @return A pointer to the newly-created USB Image device path structure.
2307 EFI_DEVICE_PATH_PROTOCOL *
2308 DevPathFromTextUsbImage (
2309 IN CHAR16 *TextDeviceNode
2312 USB_CLASS_TEXT UsbClassText;
2314 UsbClassText.ClassExist = FALSE;
2315 UsbClassText.Class = USB_CLASS_IMAGE;
2316 UsbClassText.SubClassExist = TRUE;
2318 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2322 Converts a text device path node to USB Print device path structure.
2324 @param TextDeviceNode The input Text device path node.
2326 @return A pointer to the newly-created USB Print device path structure.
2330 EFI_DEVICE_PATH_PROTOCOL *
2331 DevPathFromTextUsbPrinter (
2332 IN CHAR16 *TextDeviceNode
2335 USB_CLASS_TEXT UsbClassText;
2337 UsbClassText.ClassExist = FALSE;
2338 UsbClassText.Class = USB_CLASS_PRINTER;
2339 UsbClassText.SubClassExist = TRUE;
2341 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2345 Converts a text device path node to USB mass storage device path structure.
2347 @param TextDeviceNode The input Text device path node.
2349 @return A pointer to the newly-created USB mass storage device path structure.
2353 EFI_DEVICE_PATH_PROTOCOL *
2354 DevPathFromTextUsbMassStorage (
2355 IN CHAR16 *TextDeviceNode
2358 USB_CLASS_TEXT UsbClassText;
2360 UsbClassText.ClassExist = FALSE;
2361 UsbClassText.Class = USB_CLASS_MASS_STORAGE;
2362 UsbClassText.SubClassExist = TRUE;
2364 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2368 Converts a text device path node to USB HUB device path structure.
2370 @param TextDeviceNode The input Text device path node.
2372 @return A pointer to the newly-created USB HUB device path structure.
2376 EFI_DEVICE_PATH_PROTOCOL *
2377 DevPathFromTextUsbHub (
2378 IN CHAR16 *TextDeviceNode
2381 USB_CLASS_TEXT UsbClassText;
2383 UsbClassText.ClassExist = FALSE;
2384 UsbClassText.Class = USB_CLASS_HUB;
2385 UsbClassText.SubClassExist = TRUE;
2387 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2391 Converts a text device path node to USB CDC data device path structure.
2393 @param TextDeviceNode The input Text device path node.
2395 @return A pointer to the newly-created USB CDC data device path structure.
2399 EFI_DEVICE_PATH_PROTOCOL *
2400 DevPathFromTextUsbCDCData (
2401 IN CHAR16 *TextDeviceNode
2404 USB_CLASS_TEXT UsbClassText;
2406 UsbClassText.ClassExist = FALSE;
2407 UsbClassText.Class = USB_CLASS_CDCDATA;
2408 UsbClassText.SubClassExist = TRUE;
2410 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2414 Converts a text device path node to USB smart card device path structure.
2416 @param TextDeviceNode The input Text device path node.
2418 @return A pointer to the newly-created USB smart card device path structure.
2422 EFI_DEVICE_PATH_PROTOCOL *
2423 DevPathFromTextUsbSmartCard (
2424 IN CHAR16 *TextDeviceNode
2427 USB_CLASS_TEXT UsbClassText;
2429 UsbClassText.ClassExist = FALSE;
2430 UsbClassText.Class = USB_CLASS_SMART_CARD;
2431 UsbClassText.SubClassExist = TRUE;
2433 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2437 Converts a text device path node to USB video device path structure.
2439 @param TextDeviceNode The input Text device path node.
2441 @return A pointer to the newly-created USB video device path structure.
2445 EFI_DEVICE_PATH_PROTOCOL *
2446 DevPathFromTextUsbVideo (
2447 IN CHAR16 *TextDeviceNode
2450 USB_CLASS_TEXT UsbClassText;
2452 UsbClassText.ClassExist = FALSE;
2453 UsbClassText.Class = USB_CLASS_VIDEO;
2454 UsbClassText.SubClassExist = TRUE;
2456 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2460 Converts a text device path node to USB diagnostic device path structure.
2462 @param TextDeviceNode The input Text device path node.
2464 @return A pointer to the newly-created USB diagnostic device path structure.
2468 EFI_DEVICE_PATH_PROTOCOL *
2469 DevPathFromTextUsbDiagnostic (
2470 IN CHAR16 *TextDeviceNode
2473 USB_CLASS_TEXT UsbClassText;
2475 UsbClassText.ClassExist = FALSE;
2476 UsbClassText.Class = USB_CLASS_DIAGNOSTIC;
2477 UsbClassText.SubClassExist = TRUE;
2479 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2483 Converts a text device path node to USB wireless device path structure.
2485 @param TextDeviceNode The input Text device path node.
2487 @return A pointer to the newly-created USB wireless device path structure.
2491 EFI_DEVICE_PATH_PROTOCOL *
2492 DevPathFromTextUsbWireless (
2493 IN CHAR16 *TextDeviceNode
2496 USB_CLASS_TEXT UsbClassText;
2498 UsbClassText.ClassExist = FALSE;
2499 UsbClassText.Class = USB_CLASS_WIRELESS;
2500 UsbClassText.SubClassExist = TRUE;
2502 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2506 Converts a text device path node to USB device firmware update device path structure.
2508 @param TextDeviceNode The input Text device path node.
2510 @return A pointer to the newly-created USB device firmware update device path structure.
2514 EFI_DEVICE_PATH_PROTOCOL *
2515 DevPathFromTextUsbDeviceFirmwareUpdate (
2516 IN CHAR16 *TextDeviceNode
2519 USB_CLASS_TEXT UsbClassText;
2521 UsbClassText.ClassExist = FALSE;
2522 UsbClassText.Class = USB_CLASS_RESERVE;
2523 UsbClassText.SubClassExist = FALSE;
2524 UsbClassText.SubClass = USB_SUBCLASS_FW_UPDATE;
2526 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2530 Converts a text device path node to USB IRDA bridge device path structure.
2532 @param TextDeviceNode The input Text device path node.
2534 @return A pointer to the newly-created USB IRDA bridge device path structure.
2538 EFI_DEVICE_PATH_PROTOCOL *
2539 DevPathFromTextUsbIrdaBridge (
2540 IN CHAR16 *TextDeviceNode
2543 USB_CLASS_TEXT UsbClassText;
2545 UsbClassText.ClassExist = FALSE;
2546 UsbClassText.Class = USB_CLASS_RESERVE;
2547 UsbClassText.SubClassExist = FALSE;
2548 UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE;
2550 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2554 Converts a text device path node to USB text and measurement device path structure.
2556 @param TextDeviceNode The input Text device path node.
2558 @return A pointer to the newly-created USB text and measurement device path structure.
2562 EFI_DEVICE_PATH_PROTOCOL *
2563 DevPathFromTextUsbTestAndMeasurement (
2564 IN CHAR16 *TextDeviceNode
2567 USB_CLASS_TEXT UsbClassText;
2569 UsbClassText.ClassExist = FALSE;
2570 UsbClassText.Class = USB_CLASS_RESERVE;
2571 UsbClassText.SubClassExist = FALSE;
2572 UsbClassText.SubClass = USB_SUBCLASS_TEST;
2574 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2578 Converts a text device path node to USB WWID device path structure.
2580 @param TextDeviceNode The input Text device path node.
2582 @return A pointer to the newly-created USB WWID device path structure.
2586 EFI_DEVICE_PATH_PROTOCOL *
2587 DevPathFromTextUsbWwid (
2588 IN CHAR16 *TextDeviceNode
2593 CHAR16 *InterfaceNumStr;
2594 CHAR16 *SerialNumberStr;
2595 USB_WWID_DEVICE_PATH *UsbWwid;
2596 UINTN SerialNumberStrLen;
2598 VIDStr = GetNextParamStr (&TextDeviceNode);
2599 PIDStr = GetNextParamStr (&TextDeviceNode);
2600 InterfaceNumStr = GetNextParamStr (&TextDeviceNode);
2601 SerialNumberStr = GetNextParamStr (&TextDeviceNode);
2602 SerialNumberStrLen = StrLen (SerialNumberStr);
2603 if (SerialNumberStrLen >= 2 &&
2604 SerialNumberStr[0] == '\"' &&
2605 SerialNumberStr[SerialNumberStrLen - 1] == '\"'
2607 SerialNumberStr[SerialNumberStrLen - 1] = '\0';
2609 SerialNumberStrLen -= 2;
2611 UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (
2612 MESSAGING_DEVICE_PATH,
2614 (UINT16) (sizeof (USB_WWID_DEVICE_PATH) + SerialNumberStrLen * sizeof (CHAR16))
2616 UsbWwid->VendorId = (UINT16) Strtoi (VIDStr);
2617 UsbWwid->ProductId = (UINT16) Strtoi (PIDStr);
2618 UsbWwid->InterfaceNumber = (UINT16) Strtoi (InterfaceNumStr);
2621 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
2622 // Therefore, the '\0' will not be copied.
2625 (UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH),
2627 SerialNumberStrLen * sizeof (CHAR16)
2630 return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;
2634 Converts a text device path node to Logic Unit device path structure.
2636 @param TextDeviceNode The input Text device path node.
2638 @return A pointer to the newly-created Logic Unit device path structure.
2642 EFI_DEVICE_PATH_PROTOCOL *
2643 DevPathFromTextUnit (
2644 IN CHAR16 *TextDeviceNode
2648 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
2650 LunStr = GetNextParamStr (&TextDeviceNode);
2651 LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (
2652 MESSAGING_DEVICE_PATH,
2653 MSG_DEVICE_LOGICAL_UNIT_DP,
2654 (UINT16) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)
2657 LogicalUnit->Lun = (UINT8) Strtoi (LunStr);
2659 return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;
2663 Converts a text device path node to iSCSI device path structure.
2665 @param TextDeviceNode The input Text device path node.
2667 @return A pointer to the newly-created iSCSI device path structure.
2671 EFI_DEVICE_PATH_PROTOCOL *
2672 DevPathFromTextiSCSI (
2673 IN CHAR16 *TextDeviceNode
2678 CHAR16 *PortalGroupStr;
2680 CHAR16 *HeaderDigestStr;
2681 CHAR16 *DataDigestStr;
2682 CHAR16 *AuthenticationStr;
2683 CHAR16 *ProtocolStr;
2685 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
2687 NameStr = GetNextParamStr (&TextDeviceNode);
2688 PortalGroupStr = GetNextParamStr (&TextDeviceNode);
2689 LunStr = GetNextParamStr (&TextDeviceNode);
2690 HeaderDigestStr = GetNextParamStr (&TextDeviceNode);
2691 DataDigestStr = GetNextParamStr (&TextDeviceNode);
2692 AuthenticationStr = GetNextParamStr (&TextDeviceNode);
2693 ProtocolStr = GetNextParamStr (&TextDeviceNode);
2694 ISCSIDevPath = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (
2695 MESSAGING_DEVICE_PATH,
2697 (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))
2700 AsciiStr = ISCSIDevPath->TargetName;
2701 StrToAscii (NameStr, &AsciiStr);
2703 ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);
2704 Strtoi64 (LunStr, &ISCSIDevPath->Lun);
2707 if (StrCmp (HeaderDigestStr, "CRC32C") == 0) {
2711 if (StrCmp (DataDigestStr, "CRC32C") == 0) {
2715 if (StrCmp (AuthenticationStr, "None") == 0) {
2719 if (StrCmp (AuthenticationStr, "CHAP_UNI") == 0) {
2723 ISCSIDevPath->LoginOption = (UINT16) Options;
2725 ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, "TCP");
2727 return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;
2731 Converts a text device path node to VLAN device path structure.
2733 @param TextDeviceNode The input Text device path node.
2735 @return A pointer to the newly-created VLAN device path structure.
2739 EFI_DEVICE_PATH_PROTOCOL *
2740 DevPathFromTextVlan (
2741 IN CHAR16 *TextDeviceNode
2745 VLAN_DEVICE_PATH *Vlan;
2747 VlanStr = GetNextParamStr (&TextDeviceNode);
2748 Vlan = (VLAN_DEVICE_PATH *) CreateDeviceNode (
2749 MESSAGING_DEVICE_PATH,
2751 (UINT16) sizeof (VLAN_DEVICE_PATH)
2754 Vlan->VlanId = (UINT16) Strtoi (VlanStr);
2756 return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;
2760 Converts a text device path node to Bluetooth device path structure.
2762 @param TextDeviceNode The input Text device path node.
2764 @return A pointer to the newly-created Bluetooth device path structure.
2768 EFI_DEVICE_PATH_PROTOCOL *
2769 DevPathFromTextBluetooth (
2770 IN CHAR16 *TextDeviceNode
2773 CHAR16 *BluetoothStr;
2775 CHAR16 *TempNumBuffer;
2776 UINTN TempBufferSize;
2778 BLUETOOTH_DEVICE_PATH *BluetoothDp;
2780 BluetoothStr = GetNextParamStr (&TextDeviceNode);
2781 BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (
2782 MESSAGING_DEVICE_PATH,
2784 (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)
2787 Index = sizeof (BLUETOOTH_ADDRESS) - 1;
2788 Walker = BluetoothStr;
2789 while (!IS_NULL(*Walker) && Index >= 0) {
2790 TempBufferSize = 2 * sizeof(CHAR16) + StrSize("0x");
2791 TempNumBuffer = AllocateZeroPool (TempBufferSize);
2792 if (TempNumBuffer == NULL) {
2795 StrCpyS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), "0x");
2796 StrnCatS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), Walker, 2);
2797 BluetoothDp->BD_ADDR.Address[Index] = (UINT8)Strtoi (TempNumBuffer);
2798 FreePool (TempNumBuffer);
2803 return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothDp;
2807 Converts a text device path node to Wi-Fi device path structure.
2809 @param TextDeviceNode The input Text device path node.
2811 @return A pointer to the newly-created Wi-Fi device path structure.
2815 EFI_DEVICE_PATH_PROTOCOL *
2816 DevPathFromTextWiFi (
2817 IN CHAR16 *TextDeviceNode
2823 WIFI_DEVICE_PATH *WiFiDp;
2825 SSIdStr = GetNextParamStr (&TextDeviceNode);
2826 WiFiDp = (WIFI_DEVICE_PATH *) CreateDeviceNode (
2827 MESSAGING_DEVICE_PATH,
2829 (UINT16) sizeof (WIFI_DEVICE_PATH)
2832 if (NULL != SSIdStr) {
2833 DataLen = StrLen (SSIdStr);
2834 if (StrLen (SSIdStr) > 32) {
2839 UnicodeStrToAsciiStrS (SSIdStr, AsciiStr, sizeof (AsciiStr));
2840 CopyMem (WiFiDp->SSId, AsciiStr, DataLen);
2843 return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp;
2847 Converts a text device path node to URI device path structure.
2849 @param TextDeviceNode The input Text device path node.
2851 @return A pointer to the newly-created URI device path structure.
2855 EFI_DEVICE_PATH_PROTOCOL *
2856 DevPathFromTextUri (
2857 IN CHAR16 *TextDeviceNode
2862 URI_DEVICE_PATH *Uri;
2864 UriStr = GetNextParamStr (&TextDeviceNode);
2865 UriLength = StrnLenS (UriStr, MAX_UINT16 - sizeof (URI_DEVICE_PATH));
2866 Uri = (URI_DEVICE_PATH *) CreateDeviceNode (
2867 MESSAGING_DEVICE_PATH,
2869 (UINT16) (sizeof (URI_DEVICE_PATH) + UriLength)
2872 while (UriLength-- != 0) {
2873 Uri->Uri[UriLength] = (CHAR8) UriStr[UriLength];
2876 return (EFI_DEVICE_PATH_PROTOCOL *) Uri;
2880 Converts a media text device path node to media device path structure.
2882 @param TextDeviceNode The input Text device path node.
2884 @return A pointer to media device path structure.
2888 EFI_DEVICE_PATH_PROTOCOL *
2889 DevPathFromTextMediaPath (
2890 IN CHAR16 *TextDeviceNode
2893 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH, TextDeviceNode);
2897 Converts a text device path node to HD device path structure.
2899 @param TextDeviceNode The input Text device path node.
2901 @return A pointer to the newly-created HD device path structure.
2905 EFI_DEVICE_PATH_PROTOCOL *
2907 IN CHAR16 *TextDeviceNode
2910 CHAR16 *PartitionStr;
2912 CHAR16 *SignatureStr;
2916 HARDDRIVE_DEVICE_PATH *Hd;
2918 PartitionStr = GetNextParamStr (&TextDeviceNode);
2919 TypeStr = GetNextParamStr (&TextDeviceNode);
2920 SignatureStr = GetNextParamStr (&TextDeviceNode);
2921 StartStr = GetNextParamStr (&TextDeviceNode);
2922 SizeStr = GetNextParamStr (&TextDeviceNode);
2923 Hd = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (
2926 (UINT16) sizeof (HARDDRIVE_DEVICE_PATH)
2929 Hd->PartitionNumber = (UINT32) Strtoi (PartitionStr);
2931 ZeroMem (Hd->Signature, 16);
2932 Hd->MBRType = (UINT8) 0;
2934 if (StrCmp (TypeStr, "MBR") == 0) {
2935 Hd->SignatureType = SIGNATURE_TYPE_MBR;
2938 Signature32 = (UINT32) Strtoi (SignatureStr);
2939 CopyMem (Hd->Signature, &Signature32, sizeof (UINT32));
2940 } else if (StrCmp (TypeStr, "GPT") == 0) {
2941 Hd->SignatureType = SIGNATURE_TYPE_GUID;
2944 StrToGuid (SignatureStr, (EFI_GUID *) Hd->Signature);
2946 Hd->SignatureType = (UINT8) Strtoi (TypeStr);
2949 Strtoi64 (StartStr, &Hd->PartitionStart);
2950 Strtoi64 (SizeStr, &Hd->PartitionSize);
2952 return (EFI_DEVICE_PATH_PROTOCOL *) Hd;
2956 Converts a text device path node to CDROM device path structure.
2958 @param TextDeviceNode The input Text device path node.
2960 @return A pointer to the newly-created CDROM device path structure.
2964 EFI_DEVICE_PATH_PROTOCOL *
2965 DevPathFromTextCDROM (
2966 IN CHAR16 *TextDeviceNode
2972 CDROM_DEVICE_PATH *CDROMDevPath;
2974 EntryStr = GetNextParamStr (&TextDeviceNode);
2975 StartStr = GetNextParamStr (&TextDeviceNode);
2976 SizeStr = GetNextParamStr (&TextDeviceNode);
2977 CDROMDevPath = (CDROM_DEVICE_PATH *) CreateDeviceNode (
2980 (UINT16) sizeof (CDROM_DEVICE_PATH)
2983 CDROMDevPath->BootEntry = (UINT32) Strtoi (EntryStr);
2984 Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);
2985 Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);
2987 return (EFI_DEVICE_PATH_PROTOCOL *) CDROMDevPath;
2991 Converts a text device path node to Vendor-defined media device path structure.
2993 @param TextDeviceNode The input Text device path node.
2995 @return A pointer to the newly-created Vendor-defined media device path structure.
2999 EFI_DEVICE_PATH_PROTOCOL *
3000 DevPathFromTextVenMedia (
3001 IN CHAR16 *TextDeviceNode
3004 return ConvertFromTextVendor (
3012 Converts a text device path node to File device path structure.
3014 @param TextDeviceNode The input Text device path node.
3016 @return A pointer to the newly-created File device path structure.
3020 EFI_DEVICE_PATH_PROTOCOL *
3021 DevPathFromTextFilePath (
3022 IN CHAR16 *TextDeviceNode
3025 FILEPATH_DEVICE_PATH *File;
3028 File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (
3031 (UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)
3034 StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);
3036 size_t len = (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2);
3038 File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (
3044 utf8_to_ucs2(TextDeviceNode, &v, &len);
3047 return (EFI_DEVICE_PATH_PROTOCOL *) File;
3051 Converts a text device path node to Media protocol device path structure.
3053 @param TextDeviceNode The input Text device path node.
3055 @return A pointer to the newly-created Media protocol device path structure.
3059 EFI_DEVICE_PATH_PROTOCOL *
3060 DevPathFromTextMedia (
3061 IN CHAR16 *TextDeviceNode
3065 MEDIA_PROTOCOL_DEVICE_PATH *Media;
3067 GuidStr = GetNextParamStr (&TextDeviceNode);
3068 Media = (MEDIA_PROTOCOL_DEVICE_PATH *) CreateDeviceNode (
3071 (UINT16) sizeof (MEDIA_PROTOCOL_DEVICE_PATH)
3074 StrToGuid (GuidStr, &Media->Protocol);
3076 return (EFI_DEVICE_PATH_PROTOCOL *) Media;
3080 Converts a text device path node to firmware volume device path structure.
3082 @param TextDeviceNode The input Text device path node.
3084 @return A pointer to the newly-created firmware volume device path structure.
3088 EFI_DEVICE_PATH_PROTOCOL *
3090 IN CHAR16 *TextDeviceNode
3094 MEDIA_FW_VOL_DEVICE_PATH *Fv;
3096 GuidStr = GetNextParamStr (&TextDeviceNode);
3097 Fv = (MEDIA_FW_VOL_DEVICE_PATH *) CreateDeviceNode (
3099 MEDIA_PIWG_FW_VOL_DP,
3100 (UINT16) sizeof (MEDIA_FW_VOL_DEVICE_PATH)
3103 StrToGuid (GuidStr, &Fv->FvName);
3105 return (EFI_DEVICE_PATH_PROTOCOL *) Fv;
3109 Converts a text device path node to firmware file device path structure.
3111 @param TextDeviceNode The input Text device path node.
3113 @return A pointer to the newly-created firmware file device path structure.
3117 EFI_DEVICE_PATH_PROTOCOL *
3118 DevPathFromTextFvFile (
3119 IN CHAR16 *TextDeviceNode
3123 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;
3125 GuidStr = GetNextParamStr (&TextDeviceNode);
3126 FvFile = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) CreateDeviceNode (
3128 MEDIA_PIWG_FW_FILE_DP,
3129 (UINT16) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)
3132 StrToGuid (GuidStr, &FvFile->FvFileName);
3134 return (EFI_DEVICE_PATH_PROTOCOL *) FvFile;
3138 Converts a text device path node to text relative offset device path structure.
3140 @param TextDeviceNode The input Text device path node.
3142 @return A pointer to the newly-created Text device path structure.
3146 EFI_DEVICE_PATH_PROTOCOL *
3147 DevPathFromTextRelativeOffsetRange (
3148 IN CHAR16 *TextDeviceNode
3151 CHAR16 *StartingOffsetStr;
3152 CHAR16 *EndingOffsetStr;
3153 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;
3155 StartingOffsetStr = GetNextParamStr (&TextDeviceNode);
3156 EndingOffsetStr = GetNextParamStr (&TextDeviceNode);
3157 Offset = (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *) CreateDeviceNode (
3159 MEDIA_RELATIVE_OFFSET_RANGE_DP,
3160 (UINT16) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH)
3163 Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);
3164 Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);
3166 return (EFI_DEVICE_PATH_PROTOCOL *) Offset;
3170 Converts a text device path node to text ram disk device path structure.
3172 @param TextDeviceNode The input Text device path node.
3174 @return A pointer to the newly-created Text device path structure.
3178 EFI_DEVICE_PATH_PROTOCOL *
3179 DevPathFromTextRamDisk (
3180 IN CHAR16 *TextDeviceNode
3183 CHAR16 *StartingAddrStr;
3184 CHAR16 *EndingAddrStr;
3185 CHAR16 *TypeGuidStr;
3186 CHAR16 *InstanceStr;
3187 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3188 UINT64 StartingAddr;
3191 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3192 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3193 InstanceStr = GetNextParamStr (&TextDeviceNode);
3194 TypeGuidStr = GetNextParamStr (&TextDeviceNode);
3195 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3198 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3201 Strtoi64 (StartingAddrStr, &StartingAddr);
3202 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3203 Strtoi64 (EndingAddrStr, &EndingAddr);
3204 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3205 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3206 StrToGuid (TypeGuidStr, &RamDisk->TypeGuid);
3208 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3212 Converts a text device path node to text virtual disk device path structure.
3214 @param TextDeviceNode The input Text device path node.
3216 @return A pointer to the newly-created Text device path structure.
3220 EFI_DEVICE_PATH_PROTOCOL *
3221 DevPathFromTextVirtualDisk (
3222 IN CHAR16 *TextDeviceNode
3225 CHAR16 *StartingAddrStr;
3226 CHAR16 *EndingAddrStr;
3227 CHAR16 *InstanceStr;
3228 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3229 UINT64 StartingAddr;
3232 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3233 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3234 InstanceStr = GetNextParamStr (&TextDeviceNode);
3236 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3239 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3242 Strtoi64 (StartingAddrStr, &StartingAddr);
3243 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3244 Strtoi64 (EndingAddrStr, &EndingAddr);
3245 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3246 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3247 CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid);
3249 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3253 Converts a text device path node to text virtual cd device path structure.
3255 @param TextDeviceNode The input Text device path node.
3257 @return A pointer to the newly-created Text device path structure.
3261 EFI_DEVICE_PATH_PROTOCOL *
3262 DevPathFromTextVirtualCd (
3263 IN CHAR16 *TextDeviceNode
3266 CHAR16 *StartingAddrStr;
3267 CHAR16 *EndingAddrStr;
3268 CHAR16 *InstanceStr;
3269 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3270 UINT64 StartingAddr;
3273 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3274 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3275 InstanceStr = GetNextParamStr (&TextDeviceNode);
3277 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3280 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3283 Strtoi64 (StartingAddrStr, &StartingAddr);
3284 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3285 Strtoi64 (EndingAddrStr, &EndingAddr);
3286 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3287 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3288 CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid);
3290 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3294 Converts a text device path node to text persistent virtual disk device path structure.
3296 @param TextDeviceNode The input Text device path node.
3298 @return A pointer to the newly-created Text device path structure.
3302 EFI_DEVICE_PATH_PROTOCOL *
3303 DevPathFromTextPersistentVirtualDisk (
3304 IN CHAR16 *TextDeviceNode
3307 CHAR16 *StartingAddrStr;
3308 CHAR16 *EndingAddrStr;
3309 CHAR16 *InstanceStr;
3310 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3311 UINT64 StartingAddr;
3314 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3315 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3316 InstanceStr = GetNextParamStr (&TextDeviceNode);
3318 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3321 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3324 Strtoi64 (StartingAddrStr, &StartingAddr);
3325 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3326 Strtoi64 (EndingAddrStr, &EndingAddr);
3327 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3328 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3329 CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid);
3331 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3335 Converts a text device path node to text persistent virtual cd device path structure.
3337 @param TextDeviceNode The input Text device path node.
3339 @return A pointer to the newly-created Text device path structure.
3343 EFI_DEVICE_PATH_PROTOCOL *
3344 DevPathFromTextPersistentVirtualCd (
3345 IN CHAR16 *TextDeviceNode
3348 CHAR16 *StartingAddrStr;
3349 CHAR16 *EndingAddrStr;
3350 CHAR16 *InstanceStr;
3351 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3352 UINT64 StartingAddr;
3355 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3356 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3357 InstanceStr = GetNextParamStr (&TextDeviceNode);
3359 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3362 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3365 Strtoi64 (StartingAddrStr, &StartingAddr);
3366 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3367 Strtoi64 (EndingAddrStr, &EndingAddr);
3368 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3369 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3370 CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid);
3372 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3376 Converts a BBS text device path node to BBS device path structure.
3378 @param TextDeviceNode The input Text device path node.
3380 @return A pointer to BBS device path structure.
3384 EFI_DEVICE_PATH_PROTOCOL *
3385 DevPathFromTextBbsPath (
3386 IN CHAR16 *TextDeviceNode
3389 return DevPathFromTextGenericPath (BBS_DEVICE_PATH, TextDeviceNode);
3393 Converts a text device path node to BIOS Boot Specification device path structure.
3395 @param TextDeviceNode The input Text device path node.
3397 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3401 EFI_DEVICE_PATH_PROTOCOL *
3402 DevPathFromTextBBS (
3403 IN CHAR16 *TextDeviceNode
3410 BBS_BBS_DEVICE_PATH *Bbs;
3412 TypeStr = GetNextParamStr (&TextDeviceNode);
3413 IdStr = GetNextParamStr (&TextDeviceNode);
3414 FlagsStr = GetNextParamStr (&TextDeviceNode);
3415 Bbs = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode (
3418 (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr))
3421 if (StrCmp (TypeStr, "Floppy") == 0) {
3422 Bbs->DeviceType = BBS_TYPE_FLOPPY;
3423 } else if (StrCmp (TypeStr, "HD") == 0) {
3424 Bbs->DeviceType = BBS_TYPE_HARDDRIVE;
3425 } else if (StrCmp (TypeStr, "CDROM") == 0) {
3426 Bbs->DeviceType = BBS_TYPE_CDROM;
3427 } else if (StrCmp (TypeStr, "PCMCIA") == 0) {
3428 Bbs->DeviceType = BBS_TYPE_PCMCIA;
3429 } else if (StrCmp (TypeStr, "USB") == 0) {
3430 Bbs->DeviceType = BBS_TYPE_USB;
3431 } else if (StrCmp (TypeStr, "Network") == 0) {
3432 Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK;
3434 Bbs->DeviceType = (UINT16) Strtoi (TypeStr);
3437 AsciiStr = Bbs->String;
3438 StrToAscii (IdStr, &AsciiStr);
3440 Bbs->StatusFlag = (UINT16) Strtoi (FlagsStr);
3442 return (EFI_DEVICE_PATH_PROTOCOL *) Bbs;
3446 Converts a text device path node to SATA device path structure.
3448 @param TextDeviceNode The input Text device path node.
3450 @return A pointer to the newly-created SATA device path structure.
3454 EFI_DEVICE_PATH_PROTOCOL *
3455 DevPathFromTextSata (
3456 IN CHAR16 *TextDeviceNode
3459 SATA_DEVICE_PATH *Sata;
3464 Param1 = GetNextParamStr (&TextDeviceNode);
3465 Param2 = GetNextParamStr (&TextDeviceNode);
3466 Param3 = GetNextParamStr (&TextDeviceNode);
3468 Sata = (SATA_DEVICE_PATH *) CreateDeviceNode (
3469 MESSAGING_DEVICE_PATH,
3471 (UINT16) sizeof (SATA_DEVICE_PATH)
3473 Sata->HBAPortNumber = (UINT16) Strtoi (Param1);
3474 Sata->PortMultiplierPortNumber = (UINT16) Strtoi (Param2);
3475 Sata->Lun = (UINT16) Strtoi (Param3);
3477 return (EFI_DEVICE_PATH_PROTOCOL *) Sata;
3480 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable[] = {
3481 {"Path", DevPathFromTextPath },
3483 {"HardwarePath", DevPathFromTextHardwarePath },
3484 {"Pci", DevPathFromTextPci },
3485 {"PcCard", DevPathFromTextPcCard },
3486 {"MemoryMapped", DevPathFromTextMemoryMapped },
3487 {"VenHw", DevPathFromTextVenHw },
3488 {"Ctrl", DevPathFromTextCtrl },
3489 {"BMC", DevPathFromTextBmc },
3491 {"AcpiPath", DevPathFromTextAcpiPath },
3492 {"Acpi", DevPathFromTextAcpi },
3493 {"PciRoot", DevPathFromTextPciRoot },
3494 {"PcieRoot", DevPathFromTextPcieRoot },
3495 {"Floppy", DevPathFromTextFloppy },
3496 {"Keyboard", DevPathFromTextKeyboard },
3497 {"Serial", DevPathFromTextSerial },
3498 {"ParallelPort", DevPathFromTextParallelPort },
3499 {"AcpiEx", DevPathFromTextAcpiEx },
3500 {"AcpiExp", DevPathFromTextAcpiExp },
3501 {"AcpiAdr", DevPathFromTextAcpiAdr },
3503 {"Msg", DevPathFromTextMsg },
3504 {"Ata", DevPathFromTextAta },
3505 {"Scsi", DevPathFromTextScsi },
3506 {"Fibre", DevPathFromTextFibre },
3507 {"FibreEx", DevPathFromTextFibreEx },
3508 {"I1394", DevPathFromText1394 },
3509 {"USB", DevPathFromTextUsb },
3510 {"I2O", DevPathFromTextI2O },
3511 {"Infiniband", DevPathFromTextInfiniband },
3512 {"VenMsg", DevPathFromTextVenMsg },
3513 {"VenPcAnsi", DevPathFromTextVenPcAnsi },
3514 {"VenVt100", DevPathFromTextVenVt100 },
3515 {"VenVt100Plus", DevPathFromTextVenVt100Plus },
3516 {"VenUtf8", DevPathFromTextVenUtf8 },
3517 {"UartFlowCtrl", DevPathFromTextUartFlowCtrl },
3518 {"SAS", DevPathFromTextSAS },
3519 {"SasEx", DevPathFromTextSasEx },
3520 {"NVMe", DevPathFromTextNVMe },
3521 {"UFS", DevPathFromTextUfs },
3522 {"SD", DevPathFromTextSd },
3523 {"eMMC", DevPathFromTextEmmc },
3524 {"DebugPort", DevPathFromTextDebugPort },
3525 {"MAC", DevPathFromTextMAC },
3526 {"IPv4", DevPathFromTextIPv4 },
3527 {"IPv6", DevPathFromTextIPv6 },
3528 {"Uart", DevPathFromTextUart },
3529 {"UsbClass", DevPathFromTextUsbClass },
3530 {"UsbAudio", DevPathFromTextUsbAudio },
3531 {"UsbCDCControl", DevPathFromTextUsbCDCControl },
3532 {"UsbHID", DevPathFromTextUsbHID },
3533 {"UsbImage", DevPathFromTextUsbImage },
3534 {"UsbPrinter", DevPathFromTextUsbPrinter },
3535 {"UsbMassStorage", DevPathFromTextUsbMassStorage },
3536 {"UsbHub", DevPathFromTextUsbHub },
3537 {"UsbCDCData", DevPathFromTextUsbCDCData },
3538 {"UsbSmartCard", DevPathFromTextUsbSmartCard },
3539 {"UsbVideo", DevPathFromTextUsbVideo },
3540 {"UsbDiagnostic", DevPathFromTextUsbDiagnostic },
3541 {"UsbWireless", DevPathFromTextUsbWireless },
3542 {"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate },
3543 {"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge },
3544 {"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement },
3545 {"UsbWwid", DevPathFromTextUsbWwid },
3546 {"Unit", DevPathFromTextUnit },
3547 {"iSCSI", DevPathFromTextiSCSI },
3548 {"Vlan", DevPathFromTextVlan },
3549 {"Uri", DevPathFromTextUri },
3550 {"Bluetooth", DevPathFromTextBluetooth },
3551 {"Wi-Fi", DevPathFromTextWiFi },
3552 {"MediaPath", DevPathFromTextMediaPath },
3553 {"HD", DevPathFromTextHD },
3554 {"CDROM", DevPathFromTextCDROM },
3555 {"VenMedia", DevPathFromTextVenMedia },
3556 {"Media", DevPathFromTextMedia },
3557 {"Fv", DevPathFromTextFv },
3558 {"FvFile", DevPathFromTextFvFile },
3559 {"File", DevPathFromTextFilePath },
3560 {"Offset", DevPathFromTextRelativeOffsetRange },
3561 {"RamDisk", DevPathFromTextRamDisk },
3562 {"VirtualDisk", DevPathFromTextVirtualDisk },
3563 {"VirtualCD", DevPathFromTextVirtualCd },
3564 {"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk },
3565 {"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd },
3567 {"BbsPath", DevPathFromTextBbsPath },
3568 {"BBS", DevPathFromTextBBS },
3569 {"Sata", DevPathFromTextSata },
3574 Convert text to the binary representation of a device node.
3576 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3577 node. Conversion starts with the first character and continues
3578 until the first non-device node character.
3580 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3581 insufficient memory or text unsupported.
3585 EFI_DEVICE_PATH_PROTOCOL *
3587 UefiDevicePathLibConvertTextToDeviceNode (
3588 IN CONST CHAR16 *TextDeviceNode
3591 DEVICE_PATH_FROM_TEXT FromText;
3593 EFI_DEVICE_PATH_PROTOCOL *DeviceNode;
3594 CHAR16 *DeviceNodeStr;
3597 if ((TextDeviceNode == NULL) || (IS_NULL (*TextDeviceNode))) {
3603 DeviceNodeStr = UefiDevicePathLibStrDuplicate (TextDeviceNode);
3604 ASSERT (DeviceNodeStr != NULL);
3606 for (Index = 0; mUefiDevicePathLibDevPathFromTextTable[Index].Function != NULL; Index++) {
3607 ParamStr = GetParamByNodeName (DeviceNodeStr, mUefiDevicePathLibDevPathFromTextTable[Index].DevicePathNodeText);
3608 if (ParamStr != NULL) {
3609 FromText = mUefiDevicePathLibDevPathFromTextTable[Index].Function;
3614 if (FromText == NULL) {
3618 FromText = DevPathFromTextFilePath;
3619 DeviceNode = FromText (DeviceNodeStr);
3621 DeviceNode = FromText (ParamStr);
3622 FreePool (ParamStr);
3625 FreePool (DeviceNodeStr);
3631 Convert text to the binary representation of a device path.
3634 @param TextDevicePath TextDevicePath points to the text representation of a device
3635 path. Conversion starts with the first character and continues
3636 until the first non-device node character.
3638 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3639 there was insufficient memory.
3643 EFI_DEVICE_PATH_PROTOCOL *
3645 UefiDevicePathLibConvertTextToDevicePath (
3646 IN CONST CHAR16 *TextDevicePath
3649 EFI_DEVICE_PATH_PROTOCOL *DeviceNode;
3650 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
3651 CHAR16 *DevicePathStr;
3653 CHAR16 *DeviceNodeStr;
3654 BOOLEAN IsInstanceEnd;
3655 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
3657 if ((TextDevicePath == NULL) || (IS_NULL (*TextDevicePath))) {
3661 DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
3662 ASSERT (DevicePath != NULL);
3663 SetDevicePathEndNode (DevicePath);
3665 DevicePathStr = UefiDevicePathLibStrDuplicate (TextDevicePath);
3667 Str = DevicePathStr;
3668 while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {
3669 DeviceNode = UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr);
3671 NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
3672 FreePool (DevicePath);
3673 FreePool (DeviceNode);
3674 DevicePath = NewDevicePath;
3676 if (IsInstanceEnd) {
3677 DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
3678 ASSERT (DeviceNode != NULL);
3679 SetDevicePathEndNode (DeviceNode);
3680 // Fix from https://bugzilla.tianocore.org/show_bug.cgi?id=419
3681 DeviceNode->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
3683 NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
3684 FreePool (DevicePath);
3685 FreePool (DeviceNode);
3686 DevicePath = NewDevicePath;
3690 FreePool (DevicePathStr);
3695 efidp_parse_device_path(char *path, efidp out, size_t max)
3697 EFI_DEVICE_PATH_PROTOCOL *dp;
3700 dp = UefiDevicePathLibConvertTextToDevicePath (path);
3703 len = GetDevicePathSize(dp);
3708 memcpy(out, dp, len);