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$");
41 #include "efi-osdep.h"
42 #include "efivar-dp.h"
44 #include "uefi-dplib.h"
46 /* XXX STUBS -- this stuff doesn't work yet */
47 #define StrToIpv4Address(str, unk, ipv4ptr, unk2)
48 #define StrToIpv6Address(str, unk, ipv6ptr, unk2)
51 * OK. Now this is evil. Can't typedef it again. Sure beats changing them all.
52 * Since we're doing it all as narrow characters since wchar_t can't be used on
53 * FreeBSD and CHAR16 strings generally aren't a good fit. Since this parsing
54 * doesn't need Unicode for anything, this works out well.
59 * Taken from MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
60 * hash a11928f3310518ab1c6fd34e8d0fdbb72de9602c 2017-Mar-01
64 DevicePathFromText protocol as defined in the UEFI 2.0 specification.
66 Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>
67 This program and the accompanying materials
68 are licensed and made available under the terms and conditions of the BSD License
69 which accompanies this distribution. The full text of the license may be found at
70 http://opensource.org/licenses/bsd-license.php
72 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
73 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
77 // #include "UefiDevicePathLib.h"
83 @param Src Source string.
85 @return The duplicated string.
90 UefiDevicePathLibStrDuplicate (
94 return AllocateCopyPool (StrSize (Src), Src);
99 Get parameter in a pair of parentheses follow the given node name.
100 For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".
102 @param Str Device Path Text.
103 @param NodeName Name of the node.
105 @return Parameter text for the node.
112 IN const CHAR16 *NodeName
117 UINTN NodeNameLength;
118 UINTN ParameterLength;
121 // Check whether the node name matchs
123 NodeNameLength = StrLen (NodeName);
124 if (StrnCmp (Str, NodeName, NodeNameLength) != 0) {
128 ParamStr = Str + NodeNameLength;
129 if (!IS_LEFT_PARENTH (*ParamStr)) {
134 // Skip the found '(' and find first occurrence of ')'
138 StrPointer = ParamStr;
139 while (!IS_NULL (*StrPointer)) {
140 if (IS_RIGHT_PARENTH (*StrPointer)) {
146 if (IS_NULL (*StrPointer)) {
153 ParamStr = AllocateCopyPool ((ParameterLength + 1) * sizeof (CHAR16), ParamStr);
154 if (ParamStr == NULL) {
158 // Terminate the parameter string
160 ParamStr[ParameterLength] = '\0';
166 Gets current sub-string from a string list, before return
167 the list header is moved to next sub-string. The sub-string is separated
168 by the specified character. For example, the separator is ',', the string
169 list is "2,0,3", it returns "2", the remain list move to "0,3"
171 @param List A string list separated by the specified separator
172 @param Separator The separator character
174 @return A pointer to the current sub-string
180 IN OUT CHAR16 **List,
190 if (IS_NULL (*Str)) {
195 // Find first occurrence of the separator
197 while (!IS_NULL (*Str)) {
198 if (*Str == Separator) {
204 if (*Str == Separator) {
206 // Find a sub-string, terminate it
213 // Move to next sub-string
221 Gets the next parameter string from the list.
223 @param List A string list separated by the specified separator
225 @return A pointer to the current sub-string
235 // The separator is comma
237 return SplitStr (List, ',');
241 Get one device node from entire device path text.
243 @param DevicePath On input, the current Device Path node; on output, the next device path node
244 @param IsInstanceEnd This node is the end of a device path instance
246 @return A device node text or NULL if no more device node available
251 GetNextDeviceNodeStr (
252 IN OUT CHAR16 **DevicePath,
253 OUT BOOLEAN *IsInstanceEnd
258 UINTN ParenthesesStack;
261 if (IS_NULL (*Str)) {
266 // Skip the leading '/', '(', ')' and ','
268 while (!IS_NULL (*Str)) {
269 if (!IS_SLASH (*Str) &&
271 !IS_LEFT_PARENTH (*Str) &&
272 !IS_RIGHT_PARENTH (*Str)) {
281 // Scan for the separator of this device node, '/' or ','
283 ParenthesesStack = 0;
284 while (!IS_NULL (*Str)) {
285 if ((IS_COMMA (*Str) || IS_SLASH (*Str)) && (ParenthesesStack == 0)) {
289 if (IS_LEFT_PARENTH (*Str)) {
291 } else if (IS_RIGHT_PARENTH (*Str)) {
298 if (ParenthesesStack != 0) {
300 // The '(' doesn't pair with ')', invalid device path text
305 if (IS_COMMA (*Str)) {
306 *IsInstanceEnd = TRUE;
310 *IsInstanceEnd = FALSE;
311 if (!IS_NULL (*Str)) {
325 Return whether the integer string is a hex string.
327 @param Str The integer string
329 @retval TRUE Hex string
330 @retval FALSE Decimal string
340 // skip preceeding white space
342 while ((*Str != 0) && *Str == ' ') {
346 // skip preceeding zeros
348 while ((*Str != 0) && *Str == '0') {
352 return (BOOLEAN) (*Str == 'x' || *Str == 'X');
357 Convert integer string to uint.
359 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
361 @return A UINTN value represented by Str
370 if (IsHexStr (Str)) {
371 return StrHexToUintn (Str);
373 return StrDecimalToUintn (Str);
379 Convert integer string to 64 bit data.
381 @param Str The integer string. If leading with "0x" or "0X", it's hexadecimal.
382 @param Data A pointer to the UINT64 value represented by Str
392 if (IsHexStr (Str)) {
393 *Data = StrHexToUint64 (Str);
395 *Data = StrDecimalToUint64 (Str);
401 Converts a Unicode string to ASCII string.
403 @param Str The equivalent Unicode string
404 @param AsciiStr On input, it points to destination ASCII string buffer; on output, it points
405 to the next ASCII string next to it
412 IN OUT CHAR8 **AsciiStr
418 while (!IS_NULL (*Str)) {
419 *(Dest++) = (CHAR8) *(Str++);
424 // Return the string next to it
426 *AsciiStr = Dest + 1;
430 Converts a generic text device path node to device path structure.
432 @param Type The type of the device path node.
433 @param TextDeviceNode The input text device path node.
435 @return A pointer to device path structure.
438 EFI_DEVICE_PATH_PROTOCOL *
439 DevPathFromTextGenericPath (
441 IN CHAR16 *TextDeviceNode
444 EFI_DEVICE_PATH_PROTOCOL *Node;
449 SubtypeStr = GetNextParamStr (&TextDeviceNode);
450 DataStr = GetNextParamStr (&TextDeviceNode);
452 if (DataStr == NULL) {
455 DataLength = StrLen (DataStr) / 2;
457 Node = CreateDeviceNode (
459 (UINT8) Strtoi (SubtypeStr),
460 (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)
463 StrHexToBytes (DataStr, DataLength * 2, (UINT8 *) (Node + 1), DataLength);
468 Converts a generic text device path node to device path structure.
470 @param TextDeviceNode The input Text device path node.
472 @return A pointer to device path structure.
476 EFI_DEVICE_PATH_PROTOCOL *
477 DevPathFromTextPath (
478 IN CHAR16 *TextDeviceNode
483 TypeStr = GetNextParamStr (&TextDeviceNode);
485 return DevPathFromTextGenericPath ((UINT8) Strtoi (TypeStr), TextDeviceNode);
489 Converts a generic hardware text device path node to Hardware device path structure.
491 @param TextDeviceNode The input Text device path node.
493 @return A pointer to Hardware device path structure.
497 EFI_DEVICE_PATH_PROTOCOL *
498 DevPathFromTextHardwarePath (
499 IN CHAR16 *TextDeviceNode
502 return DevPathFromTextGenericPath (HARDWARE_DEVICE_PATH, TextDeviceNode);
506 Converts a text device path node to Hardware PCI device path structure.
508 @param TextDeviceNode The input Text device path node.
510 @return A pointer to Hardware PCI device path structure.
514 EFI_DEVICE_PATH_PROTOCOL *
516 IN CHAR16 *TextDeviceNode
521 PCI_DEVICE_PATH *Pci;
523 DeviceStr = GetNextParamStr (&TextDeviceNode);
524 FunctionStr = GetNextParamStr (&TextDeviceNode);
525 Pci = (PCI_DEVICE_PATH *) CreateDeviceNode (
526 HARDWARE_DEVICE_PATH,
528 (UINT16) sizeof (PCI_DEVICE_PATH)
531 Pci->Function = (UINT8) Strtoi (FunctionStr);
532 Pci->Device = (UINT8) Strtoi (DeviceStr);
534 return (EFI_DEVICE_PATH_PROTOCOL *) Pci;
538 Converts a text device path node to Hardware PC card device path structure.
540 @param TextDeviceNode The input Text device path node.
542 @return A pointer to Hardware PC card device path structure.
546 EFI_DEVICE_PATH_PROTOCOL *
547 DevPathFromTextPcCard (
548 IN CHAR16 *TextDeviceNode
551 CHAR16 *FunctionNumberStr;
552 PCCARD_DEVICE_PATH *Pccard;
554 FunctionNumberStr = GetNextParamStr (&TextDeviceNode);
555 Pccard = (PCCARD_DEVICE_PATH *) CreateDeviceNode (
556 HARDWARE_DEVICE_PATH,
558 (UINT16) sizeof (PCCARD_DEVICE_PATH)
561 Pccard->FunctionNumber = (UINT8) Strtoi (FunctionNumberStr);
563 return (EFI_DEVICE_PATH_PROTOCOL *) Pccard;
567 Converts a text device path node to Hardware memory map device path structure.
569 @param TextDeviceNode The input Text device path node.
571 @return A pointer to Hardware memory map device path structure.
575 EFI_DEVICE_PATH_PROTOCOL *
576 DevPathFromTextMemoryMapped (
577 IN CHAR16 *TextDeviceNode
580 CHAR16 *MemoryTypeStr;
581 CHAR16 *StartingAddressStr;
582 CHAR16 *EndingAddressStr;
583 MEMMAP_DEVICE_PATH *MemMap;
585 MemoryTypeStr = GetNextParamStr (&TextDeviceNode);
586 StartingAddressStr = GetNextParamStr (&TextDeviceNode);
587 EndingAddressStr = GetNextParamStr (&TextDeviceNode);
588 MemMap = (MEMMAP_DEVICE_PATH *) CreateDeviceNode (
589 HARDWARE_DEVICE_PATH,
591 (UINT16) sizeof (MEMMAP_DEVICE_PATH)
594 MemMap->MemoryType = (UINT32) Strtoi (MemoryTypeStr);
595 Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);
596 Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);
598 return (EFI_DEVICE_PATH_PROTOCOL *) MemMap;
602 Converts a text device path node to Vendor device path structure based on the input Type
605 @param TextDeviceNode The input Text device path node.
606 @param Type The type of device path node.
607 @param SubType The subtype of device path node.
609 @return A pointer to the newly-created Vendor device path structure.
613 EFI_DEVICE_PATH_PROTOCOL *
614 ConvertFromTextVendor (
615 IN CHAR16 *TextDeviceNode,
623 VENDOR_DEVICE_PATH *Vendor;
625 GuidStr = GetNextParamStr (&TextDeviceNode);
627 DataStr = GetNextParamStr (&TextDeviceNode);
628 Length = StrLen (DataStr);
630 // Two hex characters make up 1 buffer byte
632 Length = (Length + 1) / 2;
634 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
637 (UINT16) (sizeof (VENDOR_DEVICE_PATH) + Length)
640 StrToGuid (GuidStr, &Vendor->Guid);
641 StrHexToBytes (DataStr, Length * 2, (UINT8 *) (Vendor + 1), Length);
643 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
647 Converts a text device path node to Vendor Hardware device path structure.
649 @param TextDeviceNode The input Text device path node.
651 @return A pointer to the newly-created Vendor Hardware device path structure.
655 EFI_DEVICE_PATH_PROTOCOL *
656 DevPathFromTextVenHw (
657 IN CHAR16 *TextDeviceNode
660 return ConvertFromTextVendor (
662 HARDWARE_DEVICE_PATH,
668 Converts a text device path node to Hardware Controller device path structure.
670 @param TextDeviceNode The input Text device path node.
672 @return A pointer to the newly-created Hardware Controller device path structure.
676 EFI_DEVICE_PATH_PROTOCOL *
677 DevPathFromTextCtrl (
678 IN CHAR16 *TextDeviceNode
681 CHAR16 *ControllerStr;
682 CONTROLLER_DEVICE_PATH *Controller;
684 ControllerStr = GetNextParamStr (&TextDeviceNode);
685 Controller = (CONTROLLER_DEVICE_PATH *) CreateDeviceNode (
686 HARDWARE_DEVICE_PATH,
688 (UINT16) sizeof (CONTROLLER_DEVICE_PATH)
690 Controller->ControllerNumber = (UINT32) Strtoi (ControllerStr);
692 return (EFI_DEVICE_PATH_PROTOCOL *) Controller;
696 Converts a text device path node to BMC device path structure.
698 @param TextDeviceNode The input Text device path node.
700 @return A pointer to the newly-created BMC device path structure.
704 EFI_DEVICE_PATH_PROTOCOL *
706 IN CHAR16 *TextDeviceNode
709 CHAR16 *InterfaceTypeStr;
710 CHAR16 *BaseAddressStr;
711 BMC_DEVICE_PATH *BmcDp;
713 InterfaceTypeStr = GetNextParamStr (&TextDeviceNode);
714 BaseAddressStr = GetNextParamStr (&TextDeviceNode);
715 BmcDp = (BMC_DEVICE_PATH *) CreateDeviceNode (
716 HARDWARE_DEVICE_PATH,
718 (UINT16) sizeof (BMC_DEVICE_PATH)
721 BmcDp->InterfaceType = (UINT8) Strtoi (InterfaceTypeStr);
723 (UINT64 *) (&BmcDp->BaseAddress),
724 StrHexToUint64 (BaseAddressStr)
727 return (EFI_DEVICE_PATH_PROTOCOL *) BmcDp;
731 Converts a generic ACPI text device path node to ACPI device path structure.
733 @param TextDeviceNode The input Text device path node.
735 @return A pointer to ACPI device path structure.
739 EFI_DEVICE_PATH_PROTOCOL *
740 DevPathFromTextAcpiPath (
741 IN CHAR16 *TextDeviceNode
744 return DevPathFromTextGenericPath (ACPI_DEVICE_PATH, TextDeviceNode);
748 Converts a string to EisaId.
750 @param Text The input string.
752 @return UINT32 EISA ID.
760 return (((Text[0] - 'A' + 1) & 0x1f) << 10)
761 + (((Text[1] - 'A' + 1) & 0x1f) << 5)
762 + (((Text[2] - 'A' + 1) & 0x1f) << 0)
763 + (UINT32) (StrHexToUintn (&Text[3]) << 16)
768 Converts a text device path node to ACPI HID device path structure.
770 @param TextDeviceNode The input Text device path node.
772 @return A pointer to the newly-created ACPI HID device path structure.
776 EFI_DEVICE_PATH_PROTOCOL *
777 DevPathFromTextAcpi (
778 IN CHAR16 *TextDeviceNode
783 ACPI_HID_DEVICE_PATH *Acpi;
785 HIDStr = GetNextParamStr (&TextDeviceNode);
786 UIDStr = GetNextParamStr (&TextDeviceNode);
787 Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (
790 (UINT16) sizeof (ACPI_HID_DEVICE_PATH)
793 Acpi->HID = EisaIdFromText (HIDStr);
794 Acpi->UID = (UINT32) Strtoi (UIDStr);
796 return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;
800 Converts a text device path node to ACPI HID device path structure.
802 @param TextDeviceNode The input Text device path node.
803 @param PnPId The input plug and play identification.
805 @return A pointer to the newly-created ACPI HID device path structure.
809 EFI_DEVICE_PATH_PROTOCOL *
810 ConvertFromTextAcpi (
811 IN CHAR16 *TextDeviceNode,
816 ACPI_HID_DEVICE_PATH *Acpi;
818 UIDStr = GetNextParamStr (&TextDeviceNode);
819 Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (
822 (UINT16) sizeof (ACPI_HID_DEVICE_PATH)
825 Acpi->HID = EFI_PNP_ID (PnPId);
826 Acpi->UID = (UINT32) Strtoi (UIDStr);
828 return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;
832 Converts a text device path node to PCI root device path structure.
834 @param TextDeviceNode The input Text device path node.
836 @return A pointer to the newly-created PCI root device path structure.
840 EFI_DEVICE_PATH_PROTOCOL *
841 DevPathFromTextPciRoot (
842 IN CHAR16 *TextDeviceNode
845 return ConvertFromTextAcpi (TextDeviceNode, 0x0a03);
849 Converts a text device path node to PCIE root device path structure.
851 @param TextDeviceNode The input Text device path node.
853 @return A pointer to the newly-created PCIE root device path structure.
857 EFI_DEVICE_PATH_PROTOCOL *
858 DevPathFromTextPcieRoot (
859 IN CHAR16 *TextDeviceNode
862 return ConvertFromTextAcpi (TextDeviceNode, 0x0a08);
866 Converts a text device path node to Floppy device path structure.
868 @param TextDeviceNode The input Text device path node.
870 @return A pointer to the newly-created Floppy device path structure.
874 EFI_DEVICE_PATH_PROTOCOL *
875 DevPathFromTextFloppy (
876 IN CHAR16 *TextDeviceNode
879 return ConvertFromTextAcpi (TextDeviceNode, 0x0604);
883 Converts a text device path node to Keyboard device path structure.
885 @param TextDeviceNode The input Text device path node.
887 @return A pointer to the newly-created Keyboard device path structure.
891 EFI_DEVICE_PATH_PROTOCOL *
892 DevPathFromTextKeyboard (
893 IN CHAR16 *TextDeviceNode
896 return ConvertFromTextAcpi (TextDeviceNode, 0x0301);
900 Converts a text device path node to Serial device path structure.
902 @param TextDeviceNode The input Text device path node.
904 @return A pointer to the newly-created Serial device path structure.
908 EFI_DEVICE_PATH_PROTOCOL *
909 DevPathFromTextSerial (
910 IN CHAR16 *TextDeviceNode
913 return ConvertFromTextAcpi (TextDeviceNode, 0x0501);
917 Converts a text device path node to Parallel Port device path structure.
919 @param TextDeviceNode The input Text device path node.
921 @return A pointer to the newly-created Parallel Port device path structure.
925 EFI_DEVICE_PATH_PROTOCOL *
926 DevPathFromTextParallelPort (
927 IN CHAR16 *TextDeviceNode
930 return ConvertFromTextAcpi (TextDeviceNode, 0x0401);
934 Converts a text device path node to ACPI extension device path structure.
936 @param TextDeviceNode The input Text device path node.
938 @return A pointer to the newly-created ACPI extension device path structure.
942 EFI_DEVICE_PATH_PROTOCOL *
943 DevPathFromTextAcpiEx (
944 IN CHAR16 *TextDeviceNode
955 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;
957 HIDStr = GetNextParamStr (&TextDeviceNode);
958 CIDStr = GetNextParamStr (&TextDeviceNode);
959 UIDStr = GetNextParamStr (&TextDeviceNode);
960 HIDSTRStr = GetNextParamStr (&TextDeviceNode);
961 CIDSTRStr = GetNextParamStr (&TextDeviceNode);
962 UIDSTRStr = GetNextParamStr (&TextDeviceNode);
964 Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (HIDSTRStr) + 1);
965 Length = (UINT16) (Length + StrLen (UIDSTRStr) + 1);
966 Length = (UINT16) (Length + StrLen (CIDSTRStr) + 1);
967 AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (
973 AcpiEx->HID = EisaIdFromText (HIDStr);
974 AcpiEx->CID = EisaIdFromText (CIDStr);
975 AcpiEx->UID = (UINT32) Strtoi (UIDStr);
977 AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
978 StrToAscii (HIDSTRStr, &AsciiStr);
979 StrToAscii (UIDSTRStr, &AsciiStr);
980 StrToAscii (CIDSTRStr, &AsciiStr);
982 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;
986 Converts a text device path node to ACPI extension device path structure.
988 @param TextDeviceNode The input Text device path node.
990 @return A pointer to the newly-created ACPI extension device path structure.
994 EFI_DEVICE_PATH_PROTOCOL *
995 DevPathFromTextAcpiExp (
996 IN CHAR16 *TextDeviceNode
1004 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;
1006 HIDStr = GetNextParamStr (&TextDeviceNode);
1007 CIDStr = GetNextParamStr (&TextDeviceNode);
1008 UIDSTRStr = GetNextParamStr (&TextDeviceNode);
1009 Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (UIDSTRStr) + 3);
1010 AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (
1016 AcpiEx->HID = EisaIdFromText (HIDStr);
1017 AcpiEx->CID = EisaIdFromText (CIDStr);
1020 AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
1022 // HID string is NULL
1026 // Convert UID string
1029 StrToAscii (UIDSTRStr, &AsciiStr);
1031 // CID string is NULL
1035 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;
1039 Converts a text device path node to ACPI _ADR device path structure.
1041 @param TextDeviceNode The input Text device path node.
1043 @return A pointer to the newly-created ACPI _ADR device path structure.
1047 EFI_DEVICE_PATH_PROTOCOL *
1048 DevPathFromTextAcpiAdr (
1049 IN CHAR16 *TextDeviceNode
1052 CHAR16 *DisplayDeviceStr;
1053 ACPI_ADR_DEVICE_PATH *AcpiAdr;
1057 AcpiAdr = (ACPI_ADR_DEVICE_PATH *) CreateDeviceNode (
1060 (UINT16) sizeof (ACPI_ADR_DEVICE_PATH)
1062 ASSERT (AcpiAdr != NULL);
1064 for (Index = 0; ; Index++) {
1065 DisplayDeviceStr = GetNextParamStr (&TextDeviceNode);
1066 if (IS_NULL (*DisplayDeviceStr)) {
1070 Length = DevicePathNodeLength (AcpiAdr);
1071 AcpiAdr = ReallocatePool (
1073 Length + sizeof (UINT32),
1076 ASSERT (AcpiAdr != NULL);
1077 SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));
1080 (&AcpiAdr->ADR)[Index] = (UINT32) Strtoi (DisplayDeviceStr);
1083 return (EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr;
1087 Converts a generic messaging text device path node to messaging device path structure.
1089 @param TextDeviceNode The input Text device path node.
1091 @return A pointer to messaging device path structure.
1095 EFI_DEVICE_PATH_PROTOCOL *
1096 DevPathFromTextMsg (
1097 IN CHAR16 *TextDeviceNode
1100 return DevPathFromTextGenericPath (MESSAGING_DEVICE_PATH, TextDeviceNode);
1104 Converts a text device path node to Parallel Port device path structure.
1106 @param TextDeviceNode The input Text device path node.
1108 @return A pointer to the newly-created Parallel Port device path structure.
1112 EFI_DEVICE_PATH_PROTOCOL *
1113 DevPathFromTextAta (
1114 IN CHAR16 *TextDeviceNode
1117 CHAR16 *PrimarySecondaryStr;
1118 CHAR16 *SlaveMasterStr;
1120 ATAPI_DEVICE_PATH *Atapi;
1122 Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (
1123 MESSAGING_DEVICE_PATH,
1125 (UINT16) sizeof (ATAPI_DEVICE_PATH)
1128 PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);
1129 SlaveMasterStr = GetNextParamStr (&TextDeviceNode);
1130 LunStr = GetNextParamStr (&TextDeviceNode);
1132 if (StrCmp (PrimarySecondaryStr, "Primary") == 0) {
1133 Atapi->PrimarySecondary = 0;
1134 } else if (StrCmp (PrimarySecondaryStr, "Secondary") == 0) {
1135 Atapi->PrimarySecondary = 1;
1137 Atapi->PrimarySecondary = (UINT8) Strtoi (PrimarySecondaryStr);
1139 if (StrCmp (SlaveMasterStr, "Master") == 0) {
1140 Atapi->SlaveMaster = 0;
1141 } else if (StrCmp (SlaveMasterStr, "Slave") == 0) {
1142 Atapi->SlaveMaster = 1;
1144 Atapi->SlaveMaster = (UINT8) Strtoi (SlaveMasterStr);
1147 Atapi->Lun = (UINT16) Strtoi (LunStr);
1149 return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;
1153 Converts a text device path node to SCSI device path structure.
1155 @param TextDeviceNode The input Text device path node.
1157 @return A pointer to the newly-created SCSI device path structure.
1161 EFI_DEVICE_PATH_PROTOCOL *
1162 DevPathFromTextScsi (
1163 IN CHAR16 *TextDeviceNode
1168 SCSI_DEVICE_PATH *Scsi;
1170 PunStr = GetNextParamStr (&TextDeviceNode);
1171 LunStr = GetNextParamStr (&TextDeviceNode);
1172 Scsi = (SCSI_DEVICE_PATH *) CreateDeviceNode (
1173 MESSAGING_DEVICE_PATH,
1175 (UINT16) sizeof (SCSI_DEVICE_PATH)
1178 Scsi->Pun = (UINT16) Strtoi (PunStr);
1179 Scsi->Lun = (UINT16) Strtoi (LunStr);
1181 return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;
1185 Converts a text device path node to Fibre device path structure.
1187 @param TextDeviceNode The input Text device path node.
1189 @return A pointer to the newly-created Fibre device path structure.
1193 EFI_DEVICE_PATH_PROTOCOL *
1194 DevPathFromTextFibre (
1195 IN CHAR16 *TextDeviceNode
1200 FIBRECHANNEL_DEVICE_PATH *Fibre;
1202 WWNStr = GetNextParamStr (&TextDeviceNode);
1203 LunStr = GetNextParamStr (&TextDeviceNode);
1204 Fibre = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (
1205 MESSAGING_DEVICE_PATH,
1206 MSG_FIBRECHANNEL_DP,
1207 (UINT16) sizeof (FIBRECHANNEL_DEVICE_PATH)
1210 Fibre->Reserved = 0;
1211 Strtoi64 (WWNStr, &Fibre->WWN);
1212 Strtoi64 (LunStr, &Fibre->Lun);
1214 return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;
1218 Converts a text device path node to FibreEx device path structure.
1220 @param TextDeviceNode The input Text device path node.
1222 @return A pointer to the newly-created FibreEx device path structure.
1226 EFI_DEVICE_PATH_PROTOCOL *
1227 DevPathFromTextFibreEx (
1228 IN CHAR16 *TextDeviceNode
1233 FIBRECHANNELEX_DEVICE_PATH *FibreEx;
1235 WWNStr = GetNextParamStr (&TextDeviceNode);
1236 LunStr = GetNextParamStr (&TextDeviceNode);
1237 FibreEx = (FIBRECHANNELEX_DEVICE_PATH *) CreateDeviceNode (
1238 MESSAGING_DEVICE_PATH,
1239 MSG_FIBRECHANNELEX_DP,
1240 (UINT16) sizeof (FIBRECHANNELEX_DEVICE_PATH)
1243 FibreEx->Reserved = 0;
1244 Strtoi64 (WWNStr, (UINT64 *) (&FibreEx->WWN));
1245 Strtoi64 (LunStr, (UINT64 *) (&FibreEx->Lun));
1247 *(UINT64 *) (&FibreEx->WWN) = SwapBytes64 (*(UINT64 *) (&FibreEx->WWN));
1248 *(UINT64 *) (&FibreEx->Lun) = SwapBytes64 (*(UINT64 *) (&FibreEx->Lun));
1250 return (EFI_DEVICE_PATH_PROTOCOL *) FibreEx;
1254 Converts a text device path node to 1394 device path structure.
1256 @param TextDeviceNode The input Text device path node.
1258 @return A pointer to the newly-created 1394 device path structure.
1262 EFI_DEVICE_PATH_PROTOCOL *
1263 DevPathFromText1394 (
1264 IN CHAR16 *TextDeviceNode
1268 F1394_DEVICE_PATH *F1394DevPath;
1270 GuidStr = GetNextParamStr (&TextDeviceNode);
1271 F1394DevPath = (F1394_DEVICE_PATH *) CreateDeviceNode (
1272 MESSAGING_DEVICE_PATH,
1274 (UINT16) sizeof (F1394_DEVICE_PATH)
1277 F1394DevPath->Reserved = 0;
1278 F1394DevPath->Guid = StrHexToUint64 (GuidStr);
1280 return (EFI_DEVICE_PATH_PROTOCOL *) F1394DevPath;
1284 Converts a text device path node to USB device path structure.
1286 @param TextDeviceNode The input Text device path node.
1288 @return A pointer to the newly-created USB device path structure.
1292 EFI_DEVICE_PATH_PROTOCOL *
1293 DevPathFromTextUsb (
1294 IN CHAR16 *TextDeviceNode
1298 CHAR16 *InterfaceStr;
1299 USB_DEVICE_PATH *Usb;
1301 PortStr = GetNextParamStr (&TextDeviceNode);
1302 InterfaceStr = GetNextParamStr (&TextDeviceNode);
1303 Usb = (USB_DEVICE_PATH *) CreateDeviceNode (
1304 MESSAGING_DEVICE_PATH,
1306 (UINT16) sizeof (USB_DEVICE_PATH)
1309 Usb->ParentPortNumber = (UINT8) Strtoi (PortStr);
1310 Usb->InterfaceNumber = (UINT8) Strtoi (InterfaceStr);
1312 return (EFI_DEVICE_PATH_PROTOCOL *) Usb;
1316 Converts a text device path node to I20 device path structure.
1318 @param TextDeviceNode The input Text device path node.
1320 @return A pointer to the newly-created I20 device path structure.
1324 EFI_DEVICE_PATH_PROTOCOL *
1325 DevPathFromTextI2O (
1326 IN CHAR16 *TextDeviceNode
1330 I2O_DEVICE_PATH *I2ODevPath;
1332 TIDStr = GetNextParamStr (&TextDeviceNode);
1333 I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode (
1334 MESSAGING_DEVICE_PATH,
1336 (UINT16) sizeof (I2O_DEVICE_PATH)
1339 I2ODevPath->Tid = (UINT32) Strtoi (TIDStr);
1341 return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath;
1345 Converts a text device path node to Infini Band device path structure.
1347 @param TextDeviceNode The input Text device path node.
1349 @return A pointer to the newly-created Infini Band device path structure.
1353 EFI_DEVICE_PATH_PROTOCOL *
1354 DevPathFromTextInfiniband (
1355 IN CHAR16 *TextDeviceNode
1363 INFINIBAND_DEVICE_PATH *InfiniBand;
1365 FlagsStr = GetNextParamStr (&TextDeviceNode);
1366 GuidStr = GetNextParamStr (&TextDeviceNode);
1367 SidStr = GetNextParamStr (&TextDeviceNode);
1368 TidStr = GetNextParamStr (&TextDeviceNode);
1369 DidStr = GetNextParamStr (&TextDeviceNode);
1370 InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (
1371 MESSAGING_DEVICE_PATH,
1373 (UINT16) sizeof (INFINIBAND_DEVICE_PATH)
1376 InfiniBand->ResourceFlags = (UINT32) Strtoi (FlagsStr);
1377 StrToGuid (GuidStr, (EFI_GUID *) InfiniBand->PortGid);
1378 Strtoi64 (SidStr, &InfiniBand->ServiceId);
1379 Strtoi64 (TidStr, &InfiniBand->TargetPortId);
1380 Strtoi64 (DidStr, &InfiniBand->DeviceId);
1382 return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;
1386 Converts a text device path node to Vendor-Defined Messaging device path structure.
1388 @param TextDeviceNode The input Text device path node.
1390 @return A pointer to the newly-created Vendor-Defined Messaging device path structure.
1394 EFI_DEVICE_PATH_PROTOCOL *
1395 DevPathFromTextVenMsg (
1396 IN CHAR16 *TextDeviceNode
1399 return ConvertFromTextVendor (
1401 MESSAGING_DEVICE_PATH,
1407 Converts a text device path node to Vendor defined PC-ANSI device path structure.
1409 @param TextDeviceNode The input Text device path node.
1411 @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.
1415 EFI_DEVICE_PATH_PROTOCOL *
1416 DevPathFromTextVenPcAnsi (
1417 IN CHAR16 *TextDeviceNode
1420 VENDOR_DEVICE_PATH *Vendor;
1422 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
1423 MESSAGING_DEVICE_PATH,
1425 (UINT16) sizeof (VENDOR_DEVICE_PATH));
1426 CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);
1428 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
1432 Converts a text device path node to Vendor defined VT100 device path structure.
1434 @param TextDeviceNode The input Text device path node.
1436 @return A pointer to the newly-created Vendor defined VT100 device path structure.
1440 EFI_DEVICE_PATH_PROTOCOL *
1441 DevPathFromTextVenVt100 (
1442 IN CHAR16 *TextDeviceNode
1445 VENDOR_DEVICE_PATH *Vendor;
1447 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
1448 MESSAGING_DEVICE_PATH,
1450 (UINT16) sizeof (VENDOR_DEVICE_PATH));
1451 CopyGuid (&Vendor->Guid, &gEfiVT100Guid);
1453 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
1457 Converts a text device path node to Vendor defined VT100 Plus device path structure.
1459 @param TextDeviceNode The input Text device path node.
1461 @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.
1465 EFI_DEVICE_PATH_PROTOCOL *
1466 DevPathFromTextVenVt100Plus (
1467 IN CHAR16 *TextDeviceNode
1470 VENDOR_DEVICE_PATH *Vendor;
1472 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
1473 MESSAGING_DEVICE_PATH,
1475 (UINT16) sizeof (VENDOR_DEVICE_PATH));
1476 CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);
1478 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
1482 Converts a text device path node to Vendor defined UTF8 device path structure.
1484 @param TextDeviceNode The input Text device path node.
1486 @return A pointer to the newly-created Vendor defined UTF8 device path structure.
1490 EFI_DEVICE_PATH_PROTOCOL *
1491 DevPathFromTextVenUtf8 (
1492 IN CHAR16 *TextDeviceNode
1495 VENDOR_DEVICE_PATH *Vendor;
1497 Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
1498 MESSAGING_DEVICE_PATH,
1500 (UINT16) sizeof (VENDOR_DEVICE_PATH));
1501 CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);
1503 return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
1507 Converts a text device path node to UART Flow Control device path structure.
1509 @param TextDeviceNode The input Text device path node.
1511 @return A pointer to the newly-created UART Flow Control device path structure.
1515 EFI_DEVICE_PATH_PROTOCOL *
1516 DevPathFromTextUartFlowCtrl (
1517 IN CHAR16 *TextDeviceNode
1521 UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;
1523 ValueStr = GetNextParamStr (&TextDeviceNode);
1524 UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (
1525 MESSAGING_DEVICE_PATH,
1527 (UINT16) sizeof (UART_FLOW_CONTROL_DEVICE_PATH)
1530 CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);
1531 if (StrCmp (ValueStr, "XonXoff") == 0) {
1532 UartFlowControl->FlowControlMap = 2;
1533 } else if (StrCmp (ValueStr, "Hardware") == 0) {
1534 UartFlowControl->FlowControlMap = 1;
1536 UartFlowControl->FlowControlMap = 0;
1539 return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;
1543 Converts a text device path node to Serial Attached SCSI device path structure.
1545 @param TextDeviceNode The input Text device path node.
1547 @return A pointer to the newly-created Serial Attached SCSI device path structure.
1551 EFI_DEVICE_PATH_PROTOCOL *
1552 DevPathFromTextSAS (
1553 IN CHAR16 *TextDeviceNode
1560 CHAR16 *LocationStr;
1562 CHAR16 *DriveBayStr;
1563 CHAR16 *ReservedStr;
1566 SAS_DEVICE_PATH *Sas;
1568 AddressStr = GetNextParamStr (&TextDeviceNode);
1569 LunStr = GetNextParamStr (&TextDeviceNode);
1570 RTPStr = GetNextParamStr (&TextDeviceNode);
1571 SASSATAStr = GetNextParamStr (&TextDeviceNode);
1572 LocationStr = GetNextParamStr (&TextDeviceNode);
1573 ConnectStr = GetNextParamStr (&TextDeviceNode);
1574 DriveBayStr = GetNextParamStr (&TextDeviceNode);
1575 ReservedStr = GetNextParamStr (&TextDeviceNode);
1576 Sas = (SAS_DEVICE_PATH *) CreateDeviceNode (
1577 MESSAGING_DEVICE_PATH,
1579 (UINT16) sizeof (SAS_DEVICE_PATH)
1582 CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid);
1583 Strtoi64 (AddressStr, &Sas->SasAddress);
1584 Strtoi64 (LunStr, &Sas->Lun);
1585 Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr);
1587 if (StrCmp (SASSATAStr, "NoTopology") == 0) {
1590 } else if ((StrCmp (SASSATAStr, "SATA") == 0) || (StrCmp (SASSATAStr, "SAS") == 0)) {
1592 Uint16 = (UINT16) Strtoi (DriveBayStr);
1596 Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));
1599 if (StrCmp (SASSATAStr, "SATA") == 0) {
1604 // Location is an integer between 0 and 1 or else
1605 // the keyword Internal (0) or External (1).
1607 if (StrCmp (LocationStr, "External") == 0) {
1609 } else if (StrCmp (LocationStr, "Internal") == 0) {
1612 Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);
1614 Info |= (Uint16 << 5);
1617 // Connect is an integer between 0 and 3 or else
1618 // the keyword Direct (0) or Expanded (1).
1620 if (StrCmp (ConnectStr, "Expanded") == 0) {
1622 } else if (StrCmp (ConnectStr, "Direct") == 0) {
1625 Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));
1627 Info |= (Uint16 << 6);
1630 Info = (UINT16) Strtoi (SASSATAStr);
1633 Sas->DeviceTopology = Info;
1634 Sas->Reserved = (UINT32) Strtoi (ReservedStr);
1636 return (EFI_DEVICE_PATH_PROTOCOL *) Sas;
1640 Converts a text device path node to Serial Attached SCSI Ex device path structure.
1642 @param TextDeviceNode The input Text device path node.
1644 @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.
1648 EFI_DEVICE_PATH_PROTOCOL *
1649 DevPathFromTextSasEx (
1650 IN CHAR16 *TextDeviceNode
1657 CHAR16 *LocationStr;
1659 CHAR16 *DriveBayStr;
1664 SASEX_DEVICE_PATH *SasEx;
1666 AddressStr = GetNextParamStr (&TextDeviceNode);
1667 LunStr = GetNextParamStr (&TextDeviceNode);
1668 RTPStr = GetNextParamStr (&TextDeviceNode);
1669 SASSATAStr = GetNextParamStr (&TextDeviceNode);
1670 LocationStr = GetNextParamStr (&TextDeviceNode);
1671 ConnectStr = GetNextParamStr (&TextDeviceNode);
1672 DriveBayStr = GetNextParamStr (&TextDeviceNode);
1673 SasEx = (SASEX_DEVICE_PATH *) CreateDeviceNode (
1674 MESSAGING_DEVICE_PATH,
1676 (UINT16) sizeof (SASEX_DEVICE_PATH)
1679 Strtoi64 (AddressStr, &SasAddress);
1680 Strtoi64 (LunStr, &Lun);
1681 WriteUnaligned64 ((UINT64 *) &SasEx->SasAddress, SwapBytes64 (SasAddress));
1682 WriteUnaligned64 ((UINT64 *) &SasEx->Lun, SwapBytes64 (Lun));
1683 SasEx->RelativeTargetPort = (UINT16) Strtoi (RTPStr);
1685 if (StrCmp (SASSATAStr, "NoTopology") == 0) {
1688 } else if ((StrCmp (SASSATAStr, "SATA") == 0) || (StrCmp (SASSATAStr, "SAS") == 0)) {
1690 Uint16 = (UINT16) Strtoi (DriveBayStr);
1694 Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));
1697 if (StrCmp (SASSATAStr, "SATA") == 0) {
1702 // Location is an integer between 0 and 1 or else
1703 // the keyword Internal (0) or External (1).
1705 if (StrCmp (LocationStr, "External") == 0) {
1707 } else if (StrCmp (LocationStr, "Internal") == 0) {
1710 Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);
1712 Info |= (Uint16 << 5);
1715 // Connect is an integer between 0 and 3 or else
1716 // the keyword Direct (0) or Expanded (1).
1718 if (StrCmp (ConnectStr, "Expanded") == 0) {
1720 } else if (StrCmp (ConnectStr, "Direct") == 0) {
1723 Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));
1725 Info |= (Uint16 << 6);
1728 Info = (UINT16) Strtoi (SASSATAStr);
1731 SasEx->DeviceTopology = Info;
1733 return (EFI_DEVICE_PATH_PROTOCOL *) SasEx;
1737 Converts a text device path node to NVM Express Namespace device path structure.
1739 @param TextDeviceNode The input Text device path node.
1741 @return A pointer to the newly-created NVM Express Namespace device path structure.
1745 EFI_DEVICE_PATH_PROTOCOL *
1746 DevPathFromTextNVMe (
1747 IN CHAR16 *TextDeviceNode
1750 CHAR16 *NamespaceIdStr;
1751 CHAR16 *NamespaceUuidStr;
1752 NVME_NAMESPACE_DEVICE_PATH *Nvme;
1756 NamespaceIdStr = GetNextParamStr (&TextDeviceNode);
1757 NamespaceUuidStr = GetNextParamStr (&TextDeviceNode);
1758 Nvme = (NVME_NAMESPACE_DEVICE_PATH *) CreateDeviceNode (
1759 MESSAGING_DEVICE_PATH,
1760 MSG_NVME_NAMESPACE_DP,
1761 (UINT16) sizeof (NVME_NAMESPACE_DEVICE_PATH)
1764 Nvme->NamespaceId = (UINT32) Strtoi (NamespaceIdStr);
1765 Uuid = (UINT8 *) &Nvme->NamespaceUuid;
1767 Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);
1768 while (Index-- != 0) {
1769 Uuid[Index] = (UINT8) StrHexToUintn (SplitStr (&NamespaceUuidStr, '-'));
1772 return (EFI_DEVICE_PATH_PROTOCOL *) Nvme;
1776 Converts a text device path node to UFS device path structure.
1778 @param TextDeviceNode The input Text device path node.
1780 @return A pointer to the newly-created UFS device path structure.
1784 EFI_DEVICE_PATH_PROTOCOL *
1785 DevPathFromTextUfs (
1786 IN CHAR16 *TextDeviceNode
1791 UFS_DEVICE_PATH *Ufs;
1793 PunStr = GetNextParamStr (&TextDeviceNode);
1794 LunStr = GetNextParamStr (&TextDeviceNode);
1795 Ufs = (UFS_DEVICE_PATH *) CreateDeviceNode (
1796 MESSAGING_DEVICE_PATH,
1798 (UINT16) sizeof (UFS_DEVICE_PATH)
1801 Ufs->Pun = (UINT8) Strtoi (PunStr);
1802 Ufs->Lun = (UINT8) Strtoi (LunStr);
1804 return (EFI_DEVICE_PATH_PROTOCOL *) Ufs;
1808 Converts a text device path node to SD (Secure Digital) device path structure.
1810 @param TextDeviceNode The input Text device path node.
1812 @return A pointer to the newly-created SD device path structure.
1816 EFI_DEVICE_PATH_PROTOCOL *
1818 IN CHAR16 *TextDeviceNode
1821 CHAR16 *SlotNumberStr;
1824 SlotNumberStr = GetNextParamStr (&TextDeviceNode);
1825 Sd = (SD_DEVICE_PATH *) CreateDeviceNode (
1826 MESSAGING_DEVICE_PATH,
1828 (UINT16) sizeof (SD_DEVICE_PATH)
1831 Sd->SlotNumber = (UINT8) Strtoi (SlotNumberStr);
1833 return (EFI_DEVICE_PATH_PROTOCOL *) Sd;
1837 Converts a text device path node to EMMC (Embedded MMC) device path structure.
1839 @param TextDeviceNode The input Text device path node.
1841 @return A pointer to the newly-created EMMC device path structure.
1845 EFI_DEVICE_PATH_PROTOCOL *
1846 DevPathFromTextEmmc (
1847 IN CHAR16 *TextDeviceNode
1850 CHAR16 *SlotNumberStr;
1851 EMMC_DEVICE_PATH *Emmc;
1853 SlotNumberStr = GetNextParamStr (&TextDeviceNode);
1854 Emmc = (EMMC_DEVICE_PATH *) CreateDeviceNode (
1855 MESSAGING_DEVICE_PATH,
1857 (UINT16) sizeof (EMMC_DEVICE_PATH)
1860 Emmc->SlotNumber = (UINT8) Strtoi (SlotNumberStr);
1862 return (EFI_DEVICE_PATH_PROTOCOL *) Emmc;
1866 Converts a text device path node to Debug Port device path structure.
1868 @param TextDeviceNode The input Text device path node.
1870 @return A pointer to the newly-created Debug Port device path structure.
1874 EFI_DEVICE_PATH_PROTOCOL *
1875 DevPathFromTextDebugPort (
1876 IN CHAR16 *TextDeviceNode
1879 VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend;
1881 Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (
1882 MESSAGING_DEVICE_PATH,
1884 (UINT16) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)
1887 CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);
1889 return (EFI_DEVICE_PATH_PROTOCOL *) Vend;
1893 Converts a text device path node to MAC device path structure.
1895 @param TextDeviceNode The input Text device path node.
1897 @return A pointer to the newly-created MAC device path structure.
1901 EFI_DEVICE_PATH_PROTOCOL *
1902 DevPathFromTextMAC (
1903 IN CHAR16 *TextDeviceNode
1909 MAC_ADDR_DEVICE_PATH *MACDevPath;
1911 AddressStr = GetNextParamStr (&TextDeviceNode);
1912 IfTypeStr = GetNextParamStr (&TextDeviceNode);
1913 MACDevPath = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (
1914 MESSAGING_DEVICE_PATH,
1916 (UINT16) sizeof (MAC_ADDR_DEVICE_PATH)
1919 MACDevPath->IfType = (UINT8) Strtoi (IfTypeStr);
1921 Length = sizeof (EFI_MAC_ADDRESS);
1922 StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length);
1924 return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;
1929 Converts a text format to the network protocol ID.
1931 @param Text String of protocol field.
1933 @return Network protocol ID .
1938 NetworkProtocolFromText (
1942 if (StrCmp (Text, "UDP") == 0) {
1943 return RFC_1700_UDP_PROTOCOL;
1946 if (StrCmp (Text, "TCP") == 0) {
1947 return RFC_1700_TCP_PROTOCOL;
1950 return Strtoi (Text);
1955 Converts a text device path node to IPV4 device path structure.
1957 @param TextDeviceNode The input Text device path node.
1959 @return A pointer to the newly-created IPV4 device path structure.
1963 EFI_DEVICE_PATH_PROTOCOL *
1964 DevPathFromTextIPv4 (
1965 IN CHAR16 *TextDeviceNode
1968 CHAR16 *RemoteIPStr;
1969 CHAR16 *ProtocolStr;
1972 CHAR16 *GatewayIPStr;
1973 CHAR16 *SubnetMaskStr;
1974 IPv4_DEVICE_PATH *IPv4;
1976 RemoteIPStr = GetNextParamStr (&TextDeviceNode);
1977 ProtocolStr = GetNextParamStr (&TextDeviceNode);
1978 TypeStr = GetNextParamStr (&TextDeviceNode);
1979 LocalIPStr = GetNextParamStr (&TextDeviceNode);
1980 GatewayIPStr = GetNextParamStr (&TextDeviceNode);
1981 SubnetMaskStr = GetNextParamStr (&TextDeviceNode);
1982 IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (
1983 MESSAGING_DEVICE_PATH,
1985 (UINT16) sizeof (IPv4_DEVICE_PATH)
1988 StrToIpv4Address (RemoteIPStr, NULL, &IPv4->RemoteIpAddress, NULL);
1989 IPv4->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);
1990 if (StrCmp (TypeStr, "Static") == 0) {
1991 IPv4->StaticIpAddress = TRUE;
1993 IPv4->StaticIpAddress = FALSE;
1996 StrToIpv4Address (LocalIPStr, NULL, &IPv4->LocalIpAddress, NULL);
1997 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*SubnetMaskStr)) {
1998 StrToIpv4Address (GatewayIPStr, NULL, &IPv4->GatewayIpAddress, NULL);
1999 StrToIpv4Address (SubnetMaskStr, NULL, &IPv4->SubnetMask, NULL);
2001 ZeroMem (&IPv4->GatewayIpAddress, sizeof (IPv4->GatewayIpAddress));
2002 ZeroMem (&IPv4->SubnetMask, sizeof (IPv4->SubnetMask));
2005 IPv4->LocalPort = 0;
2006 IPv4->RemotePort = 0;
2008 return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;
2012 Converts a text device path node to IPV6 device path structure.
2014 @param TextDeviceNode The input Text device path node.
2016 @return A pointer to the newly-created IPV6 device path structure.
2020 EFI_DEVICE_PATH_PROTOCOL *
2021 DevPathFromTextIPv6 (
2022 IN CHAR16 *TextDeviceNode
2025 CHAR16 *RemoteIPStr;
2026 CHAR16 *ProtocolStr;
2029 CHAR16 *GatewayIPStr;
2030 CHAR16 *PrefixLengthStr;
2031 IPv6_DEVICE_PATH *IPv6;
2033 RemoteIPStr = GetNextParamStr (&TextDeviceNode);
2034 ProtocolStr = GetNextParamStr (&TextDeviceNode);
2035 TypeStr = GetNextParamStr (&TextDeviceNode);
2036 LocalIPStr = GetNextParamStr (&TextDeviceNode);
2037 PrefixLengthStr = GetNextParamStr (&TextDeviceNode);
2038 GatewayIPStr = GetNextParamStr (&TextDeviceNode);
2039 IPv6 = (IPv6_DEVICE_PATH *) CreateDeviceNode (
2040 MESSAGING_DEVICE_PATH,
2042 (UINT16) sizeof (IPv6_DEVICE_PATH)
2045 StrToIpv6Address (RemoteIPStr, NULL, &IPv6->RemoteIpAddress, NULL);
2046 IPv6->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);
2047 if (StrCmp (TypeStr, "Static") == 0) {
2048 IPv6->IpAddressOrigin = 0;
2049 } else if (StrCmp (TypeStr, "StatelessAutoConfigure") == 0) {
2050 IPv6->IpAddressOrigin = 1;
2052 IPv6->IpAddressOrigin = 2;
2055 StrToIpv6Address (LocalIPStr, NULL, &IPv6->LocalIpAddress, NULL);
2056 if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*PrefixLengthStr)) {
2057 StrToIpv6Address (GatewayIPStr, NULL, &IPv6->GatewayIpAddress, NULL);
2058 IPv6->PrefixLength = (UINT8) Strtoi (PrefixLengthStr);
2060 ZeroMem (&IPv6->GatewayIpAddress, sizeof (IPv6->GatewayIpAddress));
2061 IPv6->PrefixLength = 0;
2064 IPv6->LocalPort = 0;
2065 IPv6->RemotePort = 0;
2067 return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;
2071 Converts a text device path node to UART device path structure.
2073 @param TextDeviceNode The input Text device path node.
2075 @return A pointer to the newly-created UART device path structure.
2079 EFI_DEVICE_PATH_PROTOCOL *
2080 DevPathFromTextUart (
2081 IN CHAR16 *TextDeviceNode
2085 CHAR16 *DataBitsStr;
2087 CHAR16 *StopBitsStr;
2088 UART_DEVICE_PATH *Uart;
2090 BaudStr = GetNextParamStr (&TextDeviceNode);
2091 DataBitsStr = GetNextParamStr (&TextDeviceNode);
2092 ParityStr = GetNextParamStr (&TextDeviceNode);
2093 StopBitsStr = GetNextParamStr (&TextDeviceNode);
2094 Uart = (UART_DEVICE_PATH *) CreateDeviceNode (
2095 MESSAGING_DEVICE_PATH,
2097 (UINT16) sizeof (UART_DEVICE_PATH)
2100 if (StrCmp (BaudStr, "DEFAULT") == 0) {
2101 Uart->BaudRate = 115200;
2103 Strtoi64 (BaudStr, &Uart->BaudRate);
2105 Uart->DataBits = (UINT8) ((StrCmp (DataBitsStr, "DEFAULT") == 0) ? 8 : Strtoi (DataBitsStr));
2106 switch (*ParityStr) {
2132 Uart->Parity = (UINT8) Strtoi (ParityStr);
2136 if (StrCmp (StopBitsStr, "D") == 0) {
2137 Uart->StopBits = (UINT8) 0;
2138 } else if (StrCmp (StopBitsStr, "1") == 0) {
2139 Uart->StopBits = (UINT8) 1;
2140 } else if (StrCmp (StopBitsStr, "1.5") == 0) {
2141 Uart->StopBits = (UINT8) 2;
2142 } else if (StrCmp (StopBitsStr, "2") == 0) {
2143 Uart->StopBits = (UINT8) 3;
2145 Uart->StopBits = (UINT8) Strtoi (StopBitsStr);
2148 return (EFI_DEVICE_PATH_PROTOCOL *) Uart;
2152 Converts a text device path node to USB class device path structure.
2154 @param TextDeviceNode The input Text device path node.
2155 @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.
2157 @return A pointer to the newly-created USB class device path structure.
2161 EFI_DEVICE_PATH_PROTOCOL *
2162 ConvertFromTextUsbClass (
2163 IN CHAR16 *TextDeviceNode,
2164 IN USB_CLASS_TEXT *UsbClassText
2170 CHAR16 *SubClassStr;
2171 CHAR16 *ProtocolStr;
2172 USB_CLASS_DEVICE_PATH *UsbClass;
2174 UsbClass = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (
2175 MESSAGING_DEVICE_PATH,
2177 (UINT16) sizeof (USB_CLASS_DEVICE_PATH)
2180 VIDStr = GetNextParamStr (&TextDeviceNode);
2181 PIDStr = GetNextParamStr (&TextDeviceNode);
2182 if (UsbClassText->ClassExist) {
2183 ClassStr = GetNextParamStr (&TextDeviceNode);
2184 UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);
2186 UsbClass->DeviceClass = UsbClassText->Class;
2188 if (UsbClassText->SubClassExist) {
2189 SubClassStr = GetNextParamStr (&TextDeviceNode);
2190 UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);
2192 UsbClass->DeviceSubClass = UsbClassText->SubClass;
2195 ProtocolStr = GetNextParamStr (&TextDeviceNode);
2197 UsbClass->VendorId = (UINT16) Strtoi (VIDStr);
2198 UsbClass->ProductId = (UINT16) Strtoi (PIDStr);
2199 UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);
2201 return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;
2206 Converts a text device path node to USB class device path structure.
2208 @param TextDeviceNode The input Text device path node.
2210 @return A pointer to the newly-created USB class device path structure.
2214 EFI_DEVICE_PATH_PROTOCOL *
2215 DevPathFromTextUsbClass (
2216 IN CHAR16 *TextDeviceNode
2219 USB_CLASS_TEXT UsbClassText;
2221 UsbClassText.ClassExist = TRUE;
2222 UsbClassText.SubClassExist = TRUE;
2224 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2228 Converts a text device path node to USB audio device path structure.
2230 @param TextDeviceNode The input Text device path node.
2232 @return A pointer to the newly-created USB audio device path structure.
2236 EFI_DEVICE_PATH_PROTOCOL *
2237 DevPathFromTextUsbAudio (
2238 IN CHAR16 *TextDeviceNode
2241 USB_CLASS_TEXT UsbClassText;
2243 UsbClassText.ClassExist = FALSE;
2244 UsbClassText.Class = USB_CLASS_AUDIO;
2245 UsbClassText.SubClassExist = TRUE;
2247 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2251 Converts a text device path node to USB CDC Control device path structure.
2253 @param TextDeviceNode The input Text device path node.
2255 @return A pointer to the newly-created USB CDC Control device path structure.
2259 EFI_DEVICE_PATH_PROTOCOL *
2260 DevPathFromTextUsbCDCControl (
2261 IN CHAR16 *TextDeviceNode
2264 USB_CLASS_TEXT UsbClassText;
2266 UsbClassText.ClassExist = FALSE;
2267 UsbClassText.Class = USB_CLASS_CDCCONTROL;
2268 UsbClassText.SubClassExist = TRUE;
2270 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2274 Converts a text device path node to USB HID device path structure.
2276 @param TextDeviceNode The input Text device path node.
2278 @return A pointer to the newly-created USB HID device path structure.
2282 EFI_DEVICE_PATH_PROTOCOL *
2283 DevPathFromTextUsbHID (
2284 IN CHAR16 *TextDeviceNode
2287 USB_CLASS_TEXT UsbClassText;
2289 UsbClassText.ClassExist = FALSE;
2290 UsbClassText.Class = USB_CLASS_HID;
2291 UsbClassText.SubClassExist = TRUE;
2293 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2297 Converts a text device path node to USB Image device path structure.
2299 @param TextDeviceNode The input Text device path node.
2301 @return A pointer to the newly-created USB Image device path structure.
2305 EFI_DEVICE_PATH_PROTOCOL *
2306 DevPathFromTextUsbImage (
2307 IN CHAR16 *TextDeviceNode
2310 USB_CLASS_TEXT UsbClassText;
2312 UsbClassText.ClassExist = FALSE;
2313 UsbClassText.Class = USB_CLASS_IMAGE;
2314 UsbClassText.SubClassExist = TRUE;
2316 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2320 Converts a text device path node to USB Print device path structure.
2322 @param TextDeviceNode The input Text device path node.
2324 @return A pointer to the newly-created USB Print device path structure.
2328 EFI_DEVICE_PATH_PROTOCOL *
2329 DevPathFromTextUsbPrinter (
2330 IN CHAR16 *TextDeviceNode
2333 USB_CLASS_TEXT UsbClassText;
2335 UsbClassText.ClassExist = FALSE;
2336 UsbClassText.Class = USB_CLASS_PRINTER;
2337 UsbClassText.SubClassExist = TRUE;
2339 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2343 Converts a text device path node to USB mass storage device path structure.
2345 @param TextDeviceNode The input Text device path node.
2347 @return A pointer to the newly-created USB mass storage device path structure.
2351 EFI_DEVICE_PATH_PROTOCOL *
2352 DevPathFromTextUsbMassStorage (
2353 IN CHAR16 *TextDeviceNode
2356 USB_CLASS_TEXT UsbClassText;
2358 UsbClassText.ClassExist = FALSE;
2359 UsbClassText.Class = USB_CLASS_MASS_STORAGE;
2360 UsbClassText.SubClassExist = TRUE;
2362 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2366 Converts a text device path node to USB HUB device path structure.
2368 @param TextDeviceNode The input Text device path node.
2370 @return A pointer to the newly-created USB HUB device path structure.
2374 EFI_DEVICE_PATH_PROTOCOL *
2375 DevPathFromTextUsbHub (
2376 IN CHAR16 *TextDeviceNode
2379 USB_CLASS_TEXT UsbClassText;
2381 UsbClassText.ClassExist = FALSE;
2382 UsbClassText.Class = USB_CLASS_HUB;
2383 UsbClassText.SubClassExist = TRUE;
2385 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2389 Converts a text device path node to USB CDC data device path structure.
2391 @param TextDeviceNode The input Text device path node.
2393 @return A pointer to the newly-created USB CDC data device path structure.
2397 EFI_DEVICE_PATH_PROTOCOL *
2398 DevPathFromTextUsbCDCData (
2399 IN CHAR16 *TextDeviceNode
2402 USB_CLASS_TEXT UsbClassText;
2404 UsbClassText.ClassExist = FALSE;
2405 UsbClassText.Class = USB_CLASS_CDCDATA;
2406 UsbClassText.SubClassExist = TRUE;
2408 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2412 Converts a text device path node to USB smart card device path structure.
2414 @param TextDeviceNode The input Text device path node.
2416 @return A pointer to the newly-created USB smart card device path structure.
2420 EFI_DEVICE_PATH_PROTOCOL *
2421 DevPathFromTextUsbSmartCard (
2422 IN CHAR16 *TextDeviceNode
2425 USB_CLASS_TEXT UsbClassText;
2427 UsbClassText.ClassExist = FALSE;
2428 UsbClassText.Class = USB_CLASS_SMART_CARD;
2429 UsbClassText.SubClassExist = TRUE;
2431 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2435 Converts a text device path node to USB video device path structure.
2437 @param TextDeviceNode The input Text device path node.
2439 @return A pointer to the newly-created USB video device path structure.
2443 EFI_DEVICE_PATH_PROTOCOL *
2444 DevPathFromTextUsbVideo (
2445 IN CHAR16 *TextDeviceNode
2448 USB_CLASS_TEXT UsbClassText;
2450 UsbClassText.ClassExist = FALSE;
2451 UsbClassText.Class = USB_CLASS_VIDEO;
2452 UsbClassText.SubClassExist = TRUE;
2454 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2458 Converts a text device path node to USB diagnostic device path structure.
2460 @param TextDeviceNode The input Text device path node.
2462 @return A pointer to the newly-created USB diagnostic device path structure.
2466 EFI_DEVICE_PATH_PROTOCOL *
2467 DevPathFromTextUsbDiagnostic (
2468 IN CHAR16 *TextDeviceNode
2471 USB_CLASS_TEXT UsbClassText;
2473 UsbClassText.ClassExist = FALSE;
2474 UsbClassText.Class = USB_CLASS_DIAGNOSTIC;
2475 UsbClassText.SubClassExist = TRUE;
2477 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2481 Converts a text device path node to USB wireless device path structure.
2483 @param TextDeviceNode The input Text device path node.
2485 @return A pointer to the newly-created USB wireless device path structure.
2489 EFI_DEVICE_PATH_PROTOCOL *
2490 DevPathFromTextUsbWireless (
2491 IN CHAR16 *TextDeviceNode
2494 USB_CLASS_TEXT UsbClassText;
2496 UsbClassText.ClassExist = FALSE;
2497 UsbClassText.Class = USB_CLASS_WIRELESS;
2498 UsbClassText.SubClassExist = TRUE;
2500 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2504 Converts a text device path node to USB device firmware update device path structure.
2506 @param TextDeviceNode The input Text device path node.
2508 @return A pointer to the newly-created USB device firmware update device path structure.
2512 EFI_DEVICE_PATH_PROTOCOL *
2513 DevPathFromTextUsbDeviceFirmwareUpdate (
2514 IN CHAR16 *TextDeviceNode
2517 USB_CLASS_TEXT UsbClassText;
2519 UsbClassText.ClassExist = FALSE;
2520 UsbClassText.Class = USB_CLASS_RESERVE;
2521 UsbClassText.SubClassExist = FALSE;
2522 UsbClassText.SubClass = USB_SUBCLASS_FW_UPDATE;
2524 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2528 Converts a text device path node to USB IRDA bridge device path structure.
2530 @param TextDeviceNode The input Text device path node.
2532 @return A pointer to the newly-created USB IRDA bridge device path structure.
2536 EFI_DEVICE_PATH_PROTOCOL *
2537 DevPathFromTextUsbIrdaBridge (
2538 IN CHAR16 *TextDeviceNode
2541 USB_CLASS_TEXT UsbClassText;
2543 UsbClassText.ClassExist = FALSE;
2544 UsbClassText.Class = USB_CLASS_RESERVE;
2545 UsbClassText.SubClassExist = FALSE;
2546 UsbClassText.SubClass = USB_SUBCLASS_IRDA_BRIDGE;
2548 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2552 Converts a text device path node to USB text and measurement device path structure.
2554 @param TextDeviceNode The input Text device path node.
2556 @return A pointer to the newly-created USB text and measurement device path structure.
2560 EFI_DEVICE_PATH_PROTOCOL *
2561 DevPathFromTextUsbTestAndMeasurement (
2562 IN CHAR16 *TextDeviceNode
2565 USB_CLASS_TEXT UsbClassText;
2567 UsbClassText.ClassExist = FALSE;
2568 UsbClassText.Class = USB_CLASS_RESERVE;
2569 UsbClassText.SubClassExist = FALSE;
2570 UsbClassText.SubClass = USB_SUBCLASS_TEST;
2572 return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
2576 Converts a text device path node to USB WWID device path structure.
2578 @param TextDeviceNode The input Text device path node.
2580 @return A pointer to the newly-created USB WWID device path structure.
2584 EFI_DEVICE_PATH_PROTOCOL *
2585 DevPathFromTextUsbWwid (
2586 IN CHAR16 *TextDeviceNode
2591 CHAR16 *InterfaceNumStr;
2592 CHAR16 *SerialNumberStr;
2593 USB_WWID_DEVICE_PATH *UsbWwid;
2594 UINTN SerialNumberStrLen;
2596 VIDStr = GetNextParamStr (&TextDeviceNode);
2597 PIDStr = GetNextParamStr (&TextDeviceNode);
2598 InterfaceNumStr = GetNextParamStr (&TextDeviceNode);
2599 SerialNumberStr = GetNextParamStr (&TextDeviceNode);
2600 SerialNumberStrLen = StrLen (SerialNumberStr);
2601 if (SerialNumberStrLen >= 2 &&
2602 SerialNumberStr[0] == '\"' &&
2603 SerialNumberStr[SerialNumberStrLen - 1] == '\"'
2605 SerialNumberStr[SerialNumberStrLen - 1] = '\0';
2607 SerialNumberStrLen -= 2;
2609 UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (
2610 MESSAGING_DEVICE_PATH,
2612 (UINT16) (sizeof (USB_WWID_DEVICE_PATH) + SerialNumberStrLen * sizeof (CHAR16))
2614 UsbWwid->VendorId = (UINT16) Strtoi (VIDStr);
2615 UsbWwid->ProductId = (UINT16) Strtoi (PIDStr);
2616 UsbWwid->InterfaceNumber = (UINT16) Strtoi (InterfaceNumStr);
2619 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
2620 // Therefore, the '\0' will not be copied.
2623 (UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH),
2625 SerialNumberStrLen * sizeof (CHAR16)
2628 return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;
2632 Converts a text device path node to Logic Unit device path structure.
2634 @param TextDeviceNode The input Text device path node.
2636 @return A pointer to the newly-created Logic Unit device path structure.
2640 EFI_DEVICE_PATH_PROTOCOL *
2641 DevPathFromTextUnit (
2642 IN CHAR16 *TextDeviceNode
2646 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
2648 LunStr = GetNextParamStr (&TextDeviceNode);
2649 LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (
2650 MESSAGING_DEVICE_PATH,
2651 MSG_DEVICE_LOGICAL_UNIT_DP,
2652 (UINT16) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)
2655 LogicalUnit->Lun = (UINT8) Strtoi (LunStr);
2657 return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;
2661 Converts a text device path node to iSCSI device path structure.
2663 @param TextDeviceNode The input Text device path node.
2665 @return A pointer to the newly-created iSCSI device path structure.
2669 EFI_DEVICE_PATH_PROTOCOL *
2670 DevPathFromTextiSCSI (
2671 IN CHAR16 *TextDeviceNode
2676 CHAR16 *PortalGroupStr;
2678 CHAR16 *HeaderDigestStr;
2679 CHAR16 *DataDigestStr;
2680 CHAR16 *AuthenticationStr;
2681 CHAR16 *ProtocolStr;
2683 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
2685 NameStr = GetNextParamStr (&TextDeviceNode);
2686 PortalGroupStr = GetNextParamStr (&TextDeviceNode);
2687 LunStr = GetNextParamStr (&TextDeviceNode);
2688 HeaderDigestStr = GetNextParamStr (&TextDeviceNode);
2689 DataDigestStr = GetNextParamStr (&TextDeviceNode);
2690 AuthenticationStr = GetNextParamStr (&TextDeviceNode);
2691 ProtocolStr = GetNextParamStr (&TextDeviceNode);
2692 ISCSIDevPath = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (
2693 MESSAGING_DEVICE_PATH,
2695 (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))
2698 AsciiStr = ISCSIDevPath->TargetName;
2699 StrToAscii (NameStr, &AsciiStr);
2701 ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);
2702 Strtoi64 (LunStr, &ISCSIDevPath->Lun);
2705 if (StrCmp (HeaderDigestStr, "CRC32C") == 0) {
2709 if (StrCmp (DataDigestStr, "CRC32C") == 0) {
2713 if (StrCmp (AuthenticationStr, "None") == 0) {
2717 if (StrCmp (AuthenticationStr, "CHAP_UNI") == 0) {
2721 ISCSIDevPath->LoginOption = (UINT16) Options;
2723 ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, "TCP");
2725 return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;
2729 Converts a text device path node to VLAN device path structure.
2731 @param TextDeviceNode The input Text device path node.
2733 @return A pointer to the newly-created VLAN device path structure.
2737 EFI_DEVICE_PATH_PROTOCOL *
2738 DevPathFromTextVlan (
2739 IN CHAR16 *TextDeviceNode
2743 VLAN_DEVICE_PATH *Vlan;
2745 VlanStr = GetNextParamStr (&TextDeviceNode);
2746 Vlan = (VLAN_DEVICE_PATH *) CreateDeviceNode (
2747 MESSAGING_DEVICE_PATH,
2749 (UINT16) sizeof (VLAN_DEVICE_PATH)
2752 Vlan->VlanId = (UINT16) Strtoi (VlanStr);
2754 return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;
2758 Converts a text device path node to Bluetooth device path structure.
2760 @param TextDeviceNode The input Text device path node.
2762 @return A pointer to the newly-created Bluetooth device path structure.
2766 EFI_DEVICE_PATH_PROTOCOL *
2767 DevPathFromTextBluetooth (
2768 IN CHAR16 *TextDeviceNode
2771 CHAR16 *BluetoothStr;
2773 CHAR16 *TempNumBuffer;
2774 UINTN TempBufferSize;
2776 BLUETOOTH_DEVICE_PATH *BluetoothDp;
2778 BluetoothStr = GetNextParamStr (&TextDeviceNode);
2779 BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (
2780 MESSAGING_DEVICE_PATH,
2782 (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)
2785 Index = sizeof (BLUETOOTH_ADDRESS) - 1;
2786 Walker = BluetoothStr;
2787 while (!IS_NULL(*Walker) && Index >= 0) {
2788 TempBufferSize = 2 * sizeof(CHAR16) + StrSize("0x");
2789 TempNumBuffer = AllocateZeroPool (TempBufferSize);
2790 if (TempNumBuffer == NULL) {
2793 StrCpyS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), "0x");
2794 StrnCatS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), Walker, 2);
2795 BluetoothDp->BD_ADDR.Address[Index] = (UINT8)Strtoi (TempNumBuffer);
2796 FreePool (TempNumBuffer);
2801 return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothDp;
2805 Converts a text device path node to Wi-Fi device path structure.
2807 @param TextDeviceNode The input Text device path node.
2809 @return A pointer to the newly-created Wi-Fi device path structure.
2813 EFI_DEVICE_PATH_PROTOCOL *
2814 DevPathFromTextWiFi (
2815 IN CHAR16 *TextDeviceNode
2821 WIFI_DEVICE_PATH *WiFiDp;
2823 SSIdStr = GetNextParamStr (&TextDeviceNode);
2824 WiFiDp = (WIFI_DEVICE_PATH *) CreateDeviceNode (
2825 MESSAGING_DEVICE_PATH,
2827 (UINT16) sizeof (WIFI_DEVICE_PATH)
2830 if (NULL != SSIdStr) {
2831 DataLen = StrLen (SSIdStr);
2832 if (StrLen (SSIdStr) > 32) {
2837 UnicodeStrToAsciiStrS (SSIdStr, AsciiStr, sizeof (AsciiStr));
2838 CopyMem (WiFiDp->SSId, AsciiStr, DataLen);
2841 return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp;
2845 Converts a text device path node to URI device path structure.
2847 @param TextDeviceNode The input Text device path node.
2849 @return A pointer to the newly-created URI device path structure.
2853 EFI_DEVICE_PATH_PROTOCOL *
2854 DevPathFromTextUri (
2855 IN CHAR16 *TextDeviceNode
2860 URI_DEVICE_PATH *Uri;
2862 UriStr = GetNextParamStr (&TextDeviceNode);
2863 UriLength = StrnLenS (UriStr, MAX_UINT16 - sizeof (URI_DEVICE_PATH));
2864 Uri = (URI_DEVICE_PATH *) CreateDeviceNode (
2865 MESSAGING_DEVICE_PATH,
2867 (UINT16) (sizeof (URI_DEVICE_PATH) + UriLength)
2870 while (UriLength-- != 0) {
2871 Uri->Uri[UriLength] = (CHAR8) UriStr[UriLength];
2874 return (EFI_DEVICE_PATH_PROTOCOL *) Uri;
2878 Converts a media text device path node to media device path structure.
2880 @param TextDeviceNode The input Text device path node.
2882 @return A pointer to media device path structure.
2886 EFI_DEVICE_PATH_PROTOCOL *
2887 DevPathFromTextMediaPath (
2888 IN CHAR16 *TextDeviceNode
2891 return DevPathFromTextGenericPath (MEDIA_DEVICE_PATH, TextDeviceNode);
2895 Converts a text device path node to HD device path structure.
2897 @param TextDeviceNode The input Text device path node.
2899 @return A pointer to the newly-created HD device path structure.
2903 EFI_DEVICE_PATH_PROTOCOL *
2905 IN CHAR16 *TextDeviceNode
2908 CHAR16 *PartitionStr;
2910 CHAR16 *SignatureStr;
2914 HARDDRIVE_DEVICE_PATH *Hd;
2916 PartitionStr = GetNextParamStr (&TextDeviceNode);
2917 TypeStr = GetNextParamStr (&TextDeviceNode);
2918 SignatureStr = GetNextParamStr (&TextDeviceNode);
2919 StartStr = GetNextParamStr (&TextDeviceNode);
2920 SizeStr = GetNextParamStr (&TextDeviceNode);
2921 Hd = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (
2924 (UINT16) sizeof (HARDDRIVE_DEVICE_PATH)
2927 Hd->PartitionNumber = (UINT32) Strtoi (PartitionStr);
2929 ZeroMem (Hd->Signature, 16);
2930 Hd->MBRType = (UINT8) 0;
2932 if (StrCmp (TypeStr, "MBR") == 0) {
2933 Hd->SignatureType = SIGNATURE_TYPE_MBR;
2936 Signature32 = (UINT32) Strtoi (SignatureStr);
2937 CopyMem (Hd->Signature, &Signature32, sizeof (UINT32));
2938 } else if (StrCmp (TypeStr, "GPT") == 0) {
2939 Hd->SignatureType = SIGNATURE_TYPE_GUID;
2942 StrToGuid (SignatureStr, (EFI_GUID *) Hd->Signature);
2944 Hd->SignatureType = (UINT8) Strtoi (TypeStr);
2947 Strtoi64 (StartStr, &Hd->PartitionStart);
2948 Strtoi64 (SizeStr, &Hd->PartitionSize);
2950 return (EFI_DEVICE_PATH_PROTOCOL *) Hd;
2954 Converts a text device path node to CDROM device path structure.
2956 @param TextDeviceNode The input Text device path node.
2958 @return A pointer to the newly-created CDROM device path structure.
2962 EFI_DEVICE_PATH_PROTOCOL *
2963 DevPathFromTextCDROM (
2964 IN CHAR16 *TextDeviceNode
2970 CDROM_DEVICE_PATH *CDROMDevPath;
2972 EntryStr = GetNextParamStr (&TextDeviceNode);
2973 StartStr = GetNextParamStr (&TextDeviceNode);
2974 SizeStr = GetNextParamStr (&TextDeviceNode);
2975 CDROMDevPath = (CDROM_DEVICE_PATH *) CreateDeviceNode (
2978 (UINT16) sizeof (CDROM_DEVICE_PATH)
2981 CDROMDevPath->BootEntry = (UINT32) Strtoi (EntryStr);
2982 Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);
2983 Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);
2985 return (EFI_DEVICE_PATH_PROTOCOL *) CDROMDevPath;
2989 Converts a text device path node to Vendor-defined media device path structure.
2991 @param TextDeviceNode The input Text device path node.
2993 @return A pointer to the newly-created Vendor-defined media device path structure.
2997 EFI_DEVICE_PATH_PROTOCOL *
2998 DevPathFromTextVenMedia (
2999 IN CHAR16 *TextDeviceNode
3002 return ConvertFromTextVendor (
3010 Converts a text device path node to File device path structure.
3012 @param TextDeviceNode The input Text device path node.
3014 @return A pointer to the newly-created File device path structure.
3018 EFI_DEVICE_PATH_PROTOCOL *
3019 DevPathFromTextFilePath (
3020 IN CHAR16 *TextDeviceNode
3023 FILEPATH_DEVICE_PATH *File;
3026 File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (
3029 (UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)
3032 StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);
3034 File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (
3037 (UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) + 1)
3041 * Note: We'd have to change the Tianocore header files to fix this
3042 * to not need a cast. Instead we just cast it here. The Interface
3043 * to the user may have issues since this won't be a UCS-2
3044 * string. Also note that in the original code, a NUL wasn't
3045 * allocated for the end of the string, but we copy that below. This
3046 * has been corrected.
3048 StrCpyS ((char *)File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);
3051 return (EFI_DEVICE_PATH_PROTOCOL *) File;
3055 Converts a text device path node to Media protocol device path structure.
3057 @param TextDeviceNode The input Text device path node.
3059 @return A pointer to the newly-created Media protocol device path structure.
3063 EFI_DEVICE_PATH_PROTOCOL *
3064 DevPathFromTextMedia (
3065 IN CHAR16 *TextDeviceNode
3069 MEDIA_PROTOCOL_DEVICE_PATH *Media;
3071 GuidStr = GetNextParamStr (&TextDeviceNode);
3072 Media = (MEDIA_PROTOCOL_DEVICE_PATH *) CreateDeviceNode (
3075 (UINT16) sizeof (MEDIA_PROTOCOL_DEVICE_PATH)
3078 StrToGuid (GuidStr, &Media->Protocol);
3080 return (EFI_DEVICE_PATH_PROTOCOL *) Media;
3084 Converts a text device path node to firmware volume device path structure.
3086 @param TextDeviceNode The input Text device path node.
3088 @return A pointer to the newly-created firmware volume device path structure.
3092 EFI_DEVICE_PATH_PROTOCOL *
3094 IN CHAR16 *TextDeviceNode
3098 MEDIA_FW_VOL_DEVICE_PATH *Fv;
3100 GuidStr = GetNextParamStr (&TextDeviceNode);
3101 Fv = (MEDIA_FW_VOL_DEVICE_PATH *) CreateDeviceNode (
3103 MEDIA_PIWG_FW_VOL_DP,
3104 (UINT16) sizeof (MEDIA_FW_VOL_DEVICE_PATH)
3107 StrToGuid (GuidStr, &Fv->FvName);
3109 return (EFI_DEVICE_PATH_PROTOCOL *) Fv;
3113 Converts a text device path node to firmware file device path structure.
3115 @param TextDeviceNode The input Text device path node.
3117 @return A pointer to the newly-created firmware file device path structure.
3121 EFI_DEVICE_PATH_PROTOCOL *
3122 DevPathFromTextFvFile (
3123 IN CHAR16 *TextDeviceNode
3127 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;
3129 GuidStr = GetNextParamStr (&TextDeviceNode);
3130 FvFile = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) CreateDeviceNode (
3132 MEDIA_PIWG_FW_FILE_DP,
3133 (UINT16) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)
3136 StrToGuid (GuidStr, &FvFile->FvFileName);
3138 return (EFI_DEVICE_PATH_PROTOCOL *) FvFile;
3142 Converts a text device path node to text relative offset device path structure.
3144 @param TextDeviceNode The input Text device path node.
3146 @return A pointer to the newly-created Text device path structure.
3150 EFI_DEVICE_PATH_PROTOCOL *
3151 DevPathFromTextRelativeOffsetRange (
3152 IN CHAR16 *TextDeviceNode
3155 CHAR16 *StartingOffsetStr;
3156 CHAR16 *EndingOffsetStr;
3157 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;
3159 StartingOffsetStr = GetNextParamStr (&TextDeviceNode);
3160 EndingOffsetStr = GetNextParamStr (&TextDeviceNode);
3161 Offset = (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *) CreateDeviceNode (
3163 MEDIA_RELATIVE_OFFSET_RANGE_DP,
3164 (UINT16) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH)
3167 Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);
3168 Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);
3170 return (EFI_DEVICE_PATH_PROTOCOL *) Offset;
3174 Converts a text device path node to text ram disk device path structure.
3176 @param TextDeviceNode The input Text device path node.
3178 @return A pointer to the newly-created Text device path structure.
3182 EFI_DEVICE_PATH_PROTOCOL *
3183 DevPathFromTextRamDisk (
3184 IN CHAR16 *TextDeviceNode
3187 CHAR16 *StartingAddrStr;
3188 CHAR16 *EndingAddrStr;
3189 CHAR16 *TypeGuidStr;
3190 CHAR16 *InstanceStr;
3191 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3192 UINT64 StartingAddr;
3195 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3196 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3197 InstanceStr = GetNextParamStr (&TextDeviceNode);
3198 TypeGuidStr = GetNextParamStr (&TextDeviceNode);
3199 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3202 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3205 Strtoi64 (StartingAddrStr, &StartingAddr);
3206 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3207 Strtoi64 (EndingAddrStr, &EndingAddr);
3208 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3209 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3210 StrToGuid (TypeGuidStr, &RamDisk->TypeGuid);
3212 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3216 Converts a text device path node to text virtual disk device path structure.
3218 @param TextDeviceNode The input Text device path node.
3220 @return A pointer to the newly-created Text device path structure.
3224 EFI_DEVICE_PATH_PROTOCOL *
3225 DevPathFromTextVirtualDisk (
3226 IN CHAR16 *TextDeviceNode
3229 CHAR16 *StartingAddrStr;
3230 CHAR16 *EndingAddrStr;
3231 CHAR16 *InstanceStr;
3232 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3233 UINT64 StartingAddr;
3236 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3237 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3238 InstanceStr = GetNextParamStr (&TextDeviceNode);
3240 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3243 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3246 Strtoi64 (StartingAddrStr, &StartingAddr);
3247 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3248 Strtoi64 (EndingAddrStr, &EndingAddr);
3249 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3250 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3251 CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid);
3253 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3257 Converts a text device path node to text virtual cd device path structure.
3259 @param TextDeviceNode The input Text device path node.
3261 @return A pointer to the newly-created Text device path structure.
3265 EFI_DEVICE_PATH_PROTOCOL *
3266 DevPathFromTextVirtualCd (
3267 IN CHAR16 *TextDeviceNode
3270 CHAR16 *StartingAddrStr;
3271 CHAR16 *EndingAddrStr;
3272 CHAR16 *InstanceStr;
3273 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3274 UINT64 StartingAddr;
3277 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3278 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3279 InstanceStr = GetNextParamStr (&TextDeviceNode);
3281 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3284 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3287 Strtoi64 (StartingAddrStr, &StartingAddr);
3288 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3289 Strtoi64 (EndingAddrStr, &EndingAddr);
3290 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3291 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3292 CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid);
3294 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3298 Converts a text device path node to text persistent virtual disk device path structure.
3300 @param TextDeviceNode The input Text device path node.
3302 @return A pointer to the newly-created Text device path structure.
3306 EFI_DEVICE_PATH_PROTOCOL *
3307 DevPathFromTextPersistentVirtualDisk (
3308 IN CHAR16 *TextDeviceNode
3311 CHAR16 *StartingAddrStr;
3312 CHAR16 *EndingAddrStr;
3313 CHAR16 *InstanceStr;
3314 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3315 UINT64 StartingAddr;
3318 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3319 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3320 InstanceStr = GetNextParamStr (&TextDeviceNode);
3322 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3325 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3328 Strtoi64 (StartingAddrStr, &StartingAddr);
3329 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3330 Strtoi64 (EndingAddrStr, &EndingAddr);
3331 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3332 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3333 CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid);
3335 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3339 Converts a text device path node to text persistent virtual cd device path structure.
3341 @param TextDeviceNode The input Text device path node.
3343 @return A pointer to the newly-created Text device path structure.
3347 EFI_DEVICE_PATH_PROTOCOL *
3348 DevPathFromTextPersistentVirtualCd (
3349 IN CHAR16 *TextDeviceNode
3352 CHAR16 *StartingAddrStr;
3353 CHAR16 *EndingAddrStr;
3354 CHAR16 *InstanceStr;
3355 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
3356 UINT64 StartingAddr;
3359 StartingAddrStr = GetNextParamStr (&TextDeviceNode);
3360 EndingAddrStr = GetNextParamStr (&TextDeviceNode);
3361 InstanceStr = GetNextParamStr (&TextDeviceNode);
3363 RamDisk = (MEDIA_RAM_DISK_DEVICE_PATH *) CreateDeviceNode (
3366 (UINT16) sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
3369 Strtoi64 (StartingAddrStr, &StartingAddr);
3370 WriteUnaligned64 ((UINT64 *) &(RamDisk->StartingAddr[0]), StartingAddr);
3371 Strtoi64 (EndingAddrStr, &EndingAddr);
3372 WriteUnaligned64 ((UINT64 *) &(RamDisk->EndingAddr[0]), EndingAddr);
3373 RamDisk->Instance = (UINT16) Strtoi (InstanceStr);
3374 CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid);
3376 return (EFI_DEVICE_PATH_PROTOCOL *) RamDisk;
3380 Converts a BBS text device path node to BBS device path structure.
3382 @param TextDeviceNode The input Text device path node.
3384 @return A pointer to BBS device path structure.
3388 EFI_DEVICE_PATH_PROTOCOL *
3389 DevPathFromTextBbsPath (
3390 IN CHAR16 *TextDeviceNode
3393 return DevPathFromTextGenericPath (BBS_DEVICE_PATH, TextDeviceNode);
3397 Converts a text device path node to BIOS Boot Specification device path structure.
3399 @param TextDeviceNode The input Text device path node.
3401 @return A pointer to the newly-created BIOS Boot Specification device path structure.
3405 EFI_DEVICE_PATH_PROTOCOL *
3406 DevPathFromTextBBS (
3407 IN CHAR16 *TextDeviceNode
3414 BBS_BBS_DEVICE_PATH *Bbs;
3416 TypeStr = GetNextParamStr (&TextDeviceNode);
3417 IdStr = GetNextParamStr (&TextDeviceNode);
3418 FlagsStr = GetNextParamStr (&TextDeviceNode);
3419 Bbs = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode (
3422 (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr))
3425 if (StrCmp (TypeStr, "Floppy") == 0) {
3426 Bbs->DeviceType = BBS_TYPE_FLOPPY;
3427 } else if (StrCmp (TypeStr, "HD") == 0) {
3428 Bbs->DeviceType = BBS_TYPE_HARDDRIVE;
3429 } else if (StrCmp (TypeStr, "CDROM") == 0) {
3430 Bbs->DeviceType = BBS_TYPE_CDROM;
3431 } else if (StrCmp (TypeStr, "PCMCIA") == 0) {
3432 Bbs->DeviceType = BBS_TYPE_PCMCIA;
3433 } else if (StrCmp (TypeStr, "USB") == 0) {
3434 Bbs->DeviceType = BBS_TYPE_USB;
3435 } else if (StrCmp (TypeStr, "Network") == 0) {
3436 Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK;
3438 Bbs->DeviceType = (UINT16) Strtoi (TypeStr);
3441 AsciiStr = Bbs->String;
3442 StrToAscii (IdStr, &AsciiStr);
3444 Bbs->StatusFlag = (UINT16) Strtoi (FlagsStr);
3446 return (EFI_DEVICE_PATH_PROTOCOL *) Bbs;
3450 Converts a text device path node to SATA device path structure.
3452 @param TextDeviceNode The input Text device path node.
3454 @return A pointer to the newly-created SATA device path structure.
3458 EFI_DEVICE_PATH_PROTOCOL *
3459 DevPathFromTextSata (
3460 IN CHAR16 *TextDeviceNode
3463 SATA_DEVICE_PATH *Sata;
3468 Param1 = GetNextParamStr (&TextDeviceNode);
3469 Param2 = GetNextParamStr (&TextDeviceNode);
3470 Param3 = GetNextParamStr (&TextDeviceNode);
3472 Sata = (SATA_DEVICE_PATH *) CreateDeviceNode (
3473 MESSAGING_DEVICE_PATH,
3475 (UINT16) sizeof (SATA_DEVICE_PATH)
3477 Sata->HBAPortNumber = (UINT16) Strtoi (Param1);
3478 Sata->PortMultiplierPortNumber = (UINT16) Strtoi (Param2);
3479 Sata->Lun = (UINT16) Strtoi (Param3);
3481 return (EFI_DEVICE_PATH_PROTOCOL *) Sata;
3484 GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable[] = {
3485 {"Path", DevPathFromTextPath },
3487 {"HardwarePath", DevPathFromTextHardwarePath },
3488 {"Pci", DevPathFromTextPci },
3489 {"PcCard", DevPathFromTextPcCard },
3490 {"MemoryMapped", DevPathFromTextMemoryMapped },
3491 {"VenHw", DevPathFromTextVenHw },
3492 {"Ctrl", DevPathFromTextCtrl },
3493 {"BMC", DevPathFromTextBmc },
3495 {"AcpiPath", DevPathFromTextAcpiPath },
3496 {"Acpi", DevPathFromTextAcpi },
3497 {"PciRoot", DevPathFromTextPciRoot },
3498 {"PcieRoot", DevPathFromTextPcieRoot },
3499 {"Floppy", DevPathFromTextFloppy },
3500 {"Keyboard", DevPathFromTextKeyboard },
3501 {"Serial", DevPathFromTextSerial },
3502 {"ParallelPort", DevPathFromTextParallelPort },
3503 {"AcpiEx", DevPathFromTextAcpiEx },
3504 {"AcpiExp", DevPathFromTextAcpiExp },
3505 {"AcpiAdr", DevPathFromTextAcpiAdr },
3507 {"Msg", DevPathFromTextMsg },
3508 {"Ata", DevPathFromTextAta },
3509 {"Scsi", DevPathFromTextScsi },
3510 {"Fibre", DevPathFromTextFibre },
3511 {"FibreEx", DevPathFromTextFibreEx },
3512 {"I1394", DevPathFromText1394 },
3513 {"USB", DevPathFromTextUsb },
3514 {"I2O", DevPathFromTextI2O },
3515 {"Infiniband", DevPathFromTextInfiniband },
3516 {"VenMsg", DevPathFromTextVenMsg },
3517 {"VenPcAnsi", DevPathFromTextVenPcAnsi },
3518 {"VenVt100", DevPathFromTextVenVt100 },
3519 {"VenVt100Plus", DevPathFromTextVenVt100Plus },
3520 {"VenUtf8", DevPathFromTextVenUtf8 },
3521 {"UartFlowCtrl", DevPathFromTextUartFlowCtrl },
3522 {"SAS", DevPathFromTextSAS },
3523 {"SasEx", DevPathFromTextSasEx },
3524 {"NVMe", DevPathFromTextNVMe },
3525 {"UFS", DevPathFromTextUfs },
3526 {"SD", DevPathFromTextSd },
3527 {"eMMC", DevPathFromTextEmmc },
3528 {"DebugPort", DevPathFromTextDebugPort },
3529 {"MAC", DevPathFromTextMAC },
3530 {"IPv4", DevPathFromTextIPv4 },
3531 {"IPv6", DevPathFromTextIPv6 },
3532 {"Uart", DevPathFromTextUart },
3533 {"UsbClass", DevPathFromTextUsbClass },
3534 {"UsbAudio", DevPathFromTextUsbAudio },
3535 {"UsbCDCControl", DevPathFromTextUsbCDCControl },
3536 {"UsbHID", DevPathFromTextUsbHID },
3537 {"UsbImage", DevPathFromTextUsbImage },
3538 {"UsbPrinter", DevPathFromTextUsbPrinter },
3539 {"UsbMassStorage", DevPathFromTextUsbMassStorage },
3540 {"UsbHub", DevPathFromTextUsbHub },
3541 {"UsbCDCData", DevPathFromTextUsbCDCData },
3542 {"UsbSmartCard", DevPathFromTextUsbSmartCard },
3543 {"UsbVideo", DevPathFromTextUsbVideo },
3544 {"UsbDiagnostic", DevPathFromTextUsbDiagnostic },
3545 {"UsbWireless", DevPathFromTextUsbWireless },
3546 {"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate },
3547 {"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge },
3548 {"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement },
3549 {"UsbWwid", DevPathFromTextUsbWwid },
3550 {"Unit", DevPathFromTextUnit },
3551 {"iSCSI", DevPathFromTextiSCSI },
3552 {"Vlan", DevPathFromTextVlan },
3553 {"Uri", DevPathFromTextUri },
3554 {"Bluetooth", DevPathFromTextBluetooth },
3555 {"Wi-Fi", DevPathFromTextWiFi },
3556 {"MediaPath", DevPathFromTextMediaPath },
3557 {"HD", DevPathFromTextHD },
3558 {"CDROM", DevPathFromTextCDROM },
3559 {"VenMedia", DevPathFromTextVenMedia },
3560 {"Media", DevPathFromTextMedia },
3561 {"Fv", DevPathFromTextFv },
3562 {"FvFile", DevPathFromTextFvFile },
3563 {"Offset", DevPathFromTextRelativeOffsetRange },
3564 {"RamDisk", DevPathFromTextRamDisk },
3565 {"VirtualDisk", DevPathFromTextVirtualDisk },
3566 {"VirtualCD", DevPathFromTextVirtualCd },
3567 {"PersistentVirtualDisk", DevPathFromTextPersistentVirtualDisk },
3568 {"PersistentVirtualCD", DevPathFromTextPersistentVirtualCd },
3570 {"BbsPath", DevPathFromTextBbsPath },
3571 {"BBS", DevPathFromTextBBS },
3572 {"Sata", DevPathFromTextSata },
3577 Convert text to the binary representation of a device node.
3579 @param TextDeviceNode TextDeviceNode points to the text representation of a device
3580 node. Conversion starts with the first character and continues
3581 until the first non-device node character.
3583 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
3584 insufficient memory or text unsupported.
3588 EFI_DEVICE_PATH_PROTOCOL *
3590 UefiDevicePathLibConvertTextToDeviceNode (
3591 IN CONST CHAR16 *TextDeviceNode
3594 DEVICE_PATH_FROM_TEXT FromText;
3596 EFI_DEVICE_PATH_PROTOCOL *DeviceNode;
3597 CHAR16 *DeviceNodeStr;
3600 if ((TextDeviceNode == NULL) || (IS_NULL (*TextDeviceNode))) {
3606 DeviceNodeStr = UefiDevicePathLibStrDuplicate (TextDeviceNode);
3607 ASSERT (DeviceNodeStr != NULL);
3609 for (Index = 0; mUefiDevicePathLibDevPathFromTextTable[Index].Function != NULL; Index++) {
3610 ParamStr = GetParamByNodeName (DeviceNodeStr, mUefiDevicePathLibDevPathFromTextTable[Index].DevicePathNodeText);
3611 if (ParamStr != NULL) {
3612 FromText = mUefiDevicePathLibDevPathFromTextTable[Index].Function;
3617 if (FromText == NULL) {
3621 FromText = DevPathFromTextFilePath;
3622 DeviceNode = FromText (DeviceNodeStr);
3624 DeviceNode = FromText (ParamStr);
3625 FreePool (ParamStr);
3628 FreePool (DeviceNodeStr);
3634 Convert text to the binary representation of a device path.
3637 @param TextDevicePath TextDevicePath points to the text representation of a device
3638 path. Conversion starts with the first character and continues
3639 until the first non-device node character.
3641 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
3642 there was insufficient memory.
3646 EFI_DEVICE_PATH_PROTOCOL *
3648 UefiDevicePathLibConvertTextToDevicePath (
3649 IN CONST CHAR16 *TextDevicePath
3652 EFI_DEVICE_PATH_PROTOCOL *DeviceNode;
3653 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
3654 CHAR16 *DevicePathStr;
3656 CHAR16 *DeviceNodeStr;
3657 BOOLEAN IsInstanceEnd;
3658 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
3660 if ((TextDevicePath == NULL) || (IS_NULL (*TextDevicePath))) {
3664 DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
3665 ASSERT (DevicePath != NULL);
3666 SetDevicePathEndNode (DevicePath);
3668 DevicePathStr = UefiDevicePathLibStrDuplicate (TextDevicePath);
3670 Str = DevicePathStr;
3671 while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {
3672 DeviceNode = UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr);
3674 NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
3675 FreePool (DevicePath);
3676 FreePool (DeviceNode);
3677 DevicePath = NewDevicePath;
3679 if (IsInstanceEnd) {
3680 DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
3681 ASSERT (DeviceNode != NULL);
3682 SetDevicePathEndNode (DeviceNode);
3683 // Fix from https://bugzilla.tianocore.org/show_bug.cgi?id=419
3684 DeviceNode->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
3686 NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
3687 FreePool (DevicePath);
3688 FreePool (DeviceNode);
3689 DevicePath = NewDevicePath;
3693 FreePool (DevicePathStr);
3698 efidp_parse_device_path(char *path, efidp out, size_t max)
3700 EFI_DEVICE_PATH_PROTOCOL *dp;
3703 dp = UefiDevicePathLibConvertTextToDevicePath (path);
3706 len = GetDevicePathSize(dp);
3711 memcpy(out, dp, len);