2 * Copyright (c) 2017 Netflix, Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * Routines to format EFI_DEVICE_PATHs from the UEFI standard. Much of
28 * this file is taken from EDK2 and rototilled.
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
40 #include "efi-osdep.h"
41 #include "efivar-dp.h"
43 #include "uefi-dplib.h"
46 * This is a lie, but since we have converted everything
47 * from wide to narrow, it's the right lie now.
49 #define UnicodeSPrint snprintf
52 * Taken from MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
53 * hash a11928f3310518ab1c6fd34e8d0fdbb72de9602c 2017-Mar-01
55 * wide strings converted to narrow
56 * Low level printing code redone for narrow strings
57 * Routines made static
58 * %s -> %S in spots (where it is still UCS-2)
60 * %g -> %36s hack to print guid (see above for caveat)
61 * some tidying up of const and deconsting. It's evil, but const
62 * poisoning the whole file was too much.
66 DevicePathToText protocol as defined in the UEFI 2.0 specification.
68 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
69 Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>
70 This program and the accompanying materials
71 are licensed and made available under the terms and conditions of the BSD License
72 which accompanies this distribution. The full text of the license may be found at
73 http://opensource.org/licenses/bsd-license.php
75 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
76 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
80 // #include "UefiDevicePathLib.h"
83 Concatenates a formatted unicode string to allocated pool. The caller must
84 free the resulting buffer.
86 @param Str Tracks the allocated pool, size in use, and
87 amount of pool allocated.
88 @param Fmt The format string
89 @param ... Variable arguments based on the format string.
91 @return Allocated buffer with the formatted string printed in it.
92 The caller must free the allocated buffer. The buffer
93 allocation is not packed.
98 UefiDevicePathLibCatPrint (
99 IN OUT POOL_PRINT *Str,
107 VA_START (Args, Fmt);
108 Count = vsnprintf(NULL, 0, Fmt, Args);
111 if ((Str->Count + (Count + 1)) > Str->Capacity) {
112 Str->Capacity = (Str->Count + (Count + 1) * 2);
113 Str->Str = reallocf(Str->Str, Str->Capacity);
114 ASSERT (Str->Str != NULL);
116 VA_START (Args, Fmt);
117 vsnprintf(Str->Str + Str->Count, Str->Capacity - Str->Count, Fmt, Args);
125 Converts a PCI device path structure to its string representative.
127 @param Str The string representative of input device.
128 @param DevPath The input device path structure.
129 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
130 of the display node is used, where applicable. If DisplayOnly
131 is FALSE, then the longer text representation of the display node
133 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
134 representation for a device node can be used, where applicable.
139 IN OUT POOL_PRINT *Str,
141 IN BOOLEAN DisplayOnly,
142 IN BOOLEAN AllowShortcuts
145 PCI_DEVICE_PATH *Pci;
148 UefiDevicePathLibCatPrint (Str, "Pci(0x%x,0x%x)", Pci->Device, Pci->Function);
152 Converts a PC Card device path structure to its string representative.
154 @param Str The string representative of input device.
155 @param DevPath The input device path structure.
156 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
157 of the display node is used, where applicable. If DisplayOnly
158 is FALSE, then the longer text representation of the display node
160 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
161 representation for a device node can be used, where applicable.
165 DevPathToTextPccard (
166 IN OUT POOL_PRINT *Str,
168 IN BOOLEAN DisplayOnly,
169 IN BOOLEAN AllowShortcuts
172 PCCARD_DEVICE_PATH *Pccard;
175 UefiDevicePathLibCatPrint (Str, "PcCard(0x%x)", Pccard->FunctionNumber);
179 Converts a Memory Map device path structure to its string representative.
181 @param Str The string representative of input device.
182 @param DevPath The input device path structure.
183 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
184 of the display node is used, where applicable. If DisplayOnly
185 is FALSE, then the longer text representation of the display node
187 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
188 representation for a device node can be used, where applicable.
192 DevPathToTextMemMap (
193 IN OUT POOL_PRINT *Str,
195 IN BOOLEAN DisplayOnly,
196 IN BOOLEAN AllowShortcuts
199 MEMMAP_DEVICE_PATH *MemMap;
202 UefiDevicePathLibCatPrint (
204 "MemoryMapped(0x%x,0x%lx,0x%lx)",
206 MemMap->StartingAddress,
207 MemMap->EndingAddress
212 Converts a Vendor device path structure to its string representative.
214 @param Str The string representative of input device.
215 @param DevPath The input device path structure.
216 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
217 of the display node is used, where applicable. If DisplayOnly
218 is FALSE, then the longer text representation of the display node
220 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
221 representation for a device node can be used, where applicable.
225 DevPathToTextVendor (
226 IN OUT POOL_PRINT *Str,
228 IN BOOLEAN DisplayOnly,
229 IN BOOLEAN AllowShortcuts
232 VENDOR_DEVICE_PATH *Vendor;
236 UINT32 FlowControlMap;
239 Vendor = (VENDOR_DEVICE_PATH *) DevPath;
240 switch (DevicePathType (&Vendor->Header)) {
241 case HARDWARE_DEVICE_PATH:
245 case MESSAGING_DEVICE_PATH:
247 if (AllowShortcuts) {
248 if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {
249 UefiDevicePathLibCatPrint (Str, "VenPcAnsi()");
251 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {
252 UefiDevicePathLibCatPrint (Str, "VenVt100()");
254 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {
255 UefiDevicePathLibCatPrint (Str, "VenVt100Plus()");
257 } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {
258 UefiDevicePathLibCatPrint (Str, "VenUft8()");
260 } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) {
261 FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);
262 switch (FlowControlMap & 0x00000003) {
264 UefiDevicePathLibCatPrint (Str, "UartFlowCtrl(%s)", "None");
268 UefiDevicePathLibCatPrint (Str, "UartFlowCtrl(%s)", "Hardware");
272 UefiDevicePathLibCatPrint (Str, "UartFlowCtrl(%s)", "XonXoff");
280 } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {
281 UefiDevicePathLibCatPrint (
283 "SAS(0x%lx,0x%lx,0x%x,",
284 ((SAS_DEVICE_PATH *) Vendor)->SasAddress,
285 ((SAS_DEVICE_PATH *) Vendor)->Lun,
286 ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort
288 Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);
289 if (((Info & 0x0f) == 0) && ((Info & BIT7) == 0)) {
290 UefiDevicePathLibCatPrint (Str, "NoTopology,0,0,0,");
291 } else if (((Info & 0x0f) <= 2) && ((Info & BIT7) == 0)) {
292 UefiDevicePathLibCatPrint (
295 ((Info & BIT4) != 0) ? "SATA" : "SAS",
296 ((Info & BIT5) != 0) ? "External" : "Internal",
297 ((Info & BIT6) != 0) ? "Expanded" : "Direct"
299 if ((Info & 0x0f) == 1) {
300 UefiDevicePathLibCatPrint (Str, "0,");
303 // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256
305 UefiDevicePathLibCatPrint (Str, "0x%x,", ((Info >> 8) & 0xff) + 1);
308 UefiDevicePathLibCatPrint (Str, "0x%x,0,0,0,", Info);
311 UefiDevicePathLibCatPrint (Str, "0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);
313 } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {
314 UefiDevicePathLibCatPrint (Str, "DebugPort()");
320 case MEDIA_DEVICE_PATH:
329 DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);
330 UefiDevicePathLibCatPrint (Str, "Ven%s(%36s", Type, G(&Vendor->Guid));
331 if (DataLength != 0) {
332 UefiDevicePathLibCatPrint (Str, ",");
333 for (Index = 0; Index < DataLength; Index++) {
334 UefiDevicePathLibCatPrint (Str, "%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);
338 UefiDevicePathLibCatPrint (Str, ")");
342 Converts a Controller device path structure to its string representative.
344 @param Str The string representative of input device.
345 @param DevPath The input device path structure.
346 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
347 of the display node is used, where applicable. If DisplayOnly
348 is FALSE, then the longer text representation of the display node
350 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
351 representation for a device node can be used, where applicable.
355 DevPathToTextController (
356 IN OUT POOL_PRINT *Str,
358 IN BOOLEAN DisplayOnly,
359 IN BOOLEAN AllowShortcuts
362 CONTROLLER_DEVICE_PATH *Controller;
364 Controller = DevPath;
365 UefiDevicePathLibCatPrint (
368 Controller->ControllerNumber
373 Converts a BMC device path structure to its string representative.
375 @param Str The string representative of input device.
376 @param DevPath The input device path structure.
377 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
378 of the display node is used, where applicable. If DisplayOnly
379 is FALSE, then the longer text representation of the display node
381 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
382 representation for a device node can be used, where applicable.
387 IN OUT POOL_PRINT *Str,
389 IN BOOLEAN DisplayOnly,
390 IN BOOLEAN AllowShortcuts
393 BMC_DEVICE_PATH *Bmc;
396 UefiDevicePathLibCatPrint (
400 ReadUnaligned64 ((&Bmc->BaseAddress))
405 Converts a ACPI device path structure to its string representative.
407 @param Str The string representative of input device.
408 @param DevPath The input device path structure.
409 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
410 of the display node is used, where applicable. If DisplayOnly
411 is FALSE, then the longer text representation of the display node
413 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
414 representation for a device node can be used, where applicable.
419 IN OUT POOL_PRINT *Str,
421 IN BOOLEAN DisplayOnly,
422 IN BOOLEAN AllowShortcuts
425 ACPI_HID_DEVICE_PATH *Acpi;
428 if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
429 switch (EISA_ID_TO_NUM (Acpi->HID)) {
431 UefiDevicePathLibCatPrint (Str, "PciRoot(0x%x)", Acpi->UID);
435 UefiDevicePathLibCatPrint (Str, "PcieRoot(0x%x)", Acpi->UID);
439 UefiDevicePathLibCatPrint (Str, "Floppy(0x%x)", Acpi->UID);
443 UefiDevicePathLibCatPrint (Str, "Keyboard(0x%x)", Acpi->UID);
447 UefiDevicePathLibCatPrint (Str, "Serial(0x%x)", Acpi->UID);
451 UefiDevicePathLibCatPrint (Str, "ParallelPort(0x%x)", Acpi->UID);
455 UefiDevicePathLibCatPrint (Str, "Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);
459 UefiDevicePathLibCatPrint (Str, "Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID);
464 Converts a ACPI extended HID device path structure to its string representative.
466 @param Str The string representative of input device.
467 @param DevPath The input device path structure.
468 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
469 of the display node is used, where applicable. If DisplayOnly
470 is FALSE, then the longer text representation of the display node
472 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
473 representation for a device node can be used, where applicable.
477 DevPathToTextAcpiEx (
478 IN OUT POOL_PRINT *Str,
480 IN BOOLEAN DisplayOnly,
481 IN BOOLEAN AllowShortcuts
484 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;
492 HIDStr = (CHAR8 *) (((UINT8 *) AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
493 UIDStr = HIDStr + AsciiStrLen (HIDStr) + 1;
494 CIDStr = UIDStr + AsciiStrLen (UIDStr) + 1;
497 // Converts EISA identification to string.
503 ((AcpiEx->HID >> 10) & 0x1f) + 'A' - 1,
504 ((AcpiEx->HID >> 5) & 0x1f) + 'A' - 1,
505 ((AcpiEx->HID >> 0) & 0x1f) + 'A' - 1,
506 (AcpiEx->HID >> 16) & 0xFFFF
512 ((AcpiEx->CID >> 10) & 0x1f) + 'A' - 1,
513 ((AcpiEx->CID >> 5) & 0x1f) + 'A' - 1,
514 ((AcpiEx->CID >> 0) & 0x1f) + 'A' - 1,
515 (AcpiEx->CID >> 16) & 0xFFFF
518 if ((*HIDStr == '\0') && (*CIDStr == '\0') && (AcpiEx->UID == 0)) {
522 UefiDevicePathLibCatPrint (
530 if (AllowShortcuts) {
534 if (AcpiEx->HID == 0) {
535 UefiDevicePathLibCatPrint (Str, "AcpiEx(%s,", HIDStr);
537 UefiDevicePathLibCatPrint (Str, "AcpiEx(%s,", HIDText);
540 if (AcpiEx->UID == 0) {
541 UefiDevicePathLibCatPrint (Str, "%s,", UIDStr);
543 UefiDevicePathLibCatPrint (Str, "0x%x,", AcpiEx->UID);
546 if (AcpiEx->CID == 0) {
547 UefiDevicePathLibCatPrint (Str, "%s)", CIDStr);
549 UefiDevicePathLibCatPrint (Str, "%s)", CIDText);
552 UefiDevicePathLibCatPrint (
554 "AcpiEx(%s,%s,0x%x,%s,%s,%s)",
567 Converts a ACPI address device path structure to its string representative.
569 @param Str The string representative of input device.
570 @param DevPath The input device path structure.
571 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
572 of the display node is used, where applicable. If DisplayOnly
573 is FALSE, then the longer text representation of the display node
575 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
576 representation for a device node can be used, where applicable.
580 DevPathToTextAcpiAdr (
581 IN OUT POOL_PRINT *Str,
583 IN BOOLEAN DisplayOnly,
584 IN BOOLEAN AllowShortcuts
587 ACPI_ADR_DEVICE_PATH *AcpiAdr;
591 UINT16 AdditionalAdrCount;
594 Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);
595 AdditionalAdrCount = (UINT16) ((Length - 8) / 4);
597 UefiDevicePathLibCatPrint (Str, "AcpiAdr(0x%x", AcpiAdr->ADR);
598 Addr = &AcpiAdr->ADR + 1;
599 for (Index = 0; Index < AdditionalAdrCount; Index++) {
600 UefiDevicePathLibCatPrint (Str, ",0x%x", Addr[Index]);
602 UefiDevicePathLibCatPrint (Str, ")");
606 Converts a ATAPI device path structure to its string representative.
608 @param Str The string representative of input device.
609 @param DevPath The input device path structure.
610 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
611 of the display node is used, where applicable. If DisplayOnly
612 is FALSE, then the longer text representation of the display node
614 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
615 representation for a device node can be used, where applicable.
620 IN OUT POOL_PRINT *Str,
622 IN BOOLEAN DisplayOnly,
623 IN BOOLEAN AllowShortcuts
626 ATAPI_DEVICE_PATH *Atapi;
631 UefiDevicePathLibCatPrint (Str, "Ata(0x%x)", Atapi->Lun);
633 UefiDevicePathLibCatPrint (
636 (Atapi->PrimarySecondary == 1) ? "Secondary" : "Primary",
637 (Atapi->SlaveMaster == 1) ? "Slave" : "Master",
644 Converts a SCSI device path structure to its string representative.
646 @param Str The string representative of input device.
647 @param DevPath The input device path structure.
648 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
649 of the display node is used, where applicable. If DisplayOnly
650 is FALSE, then the longer text representation of the display node
652 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
653 representation for a device node can be used, where applicable.
658 IN OUT POOL_PRINT *Str,
660 IN BOOLEAN DisplayOnly,
661 IN BOOLEAN AllowShortcuts
664 SCSI_DEVICE_PATH *Scsi;
667 UefiDevicePathLibCatPrint (Str, "Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun);
671 Converts a Fibre device path structure to its string representative.
673 @param Str The string representative of input device.
674 @param DevPath The input device path structure.
675 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
676 of the display node is used, where applicable. If DisplayOnly
677 is FALSE, then the longer text representation of the display node
679 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
680 representation for a device node can be used, where applicable.
685 IN OUT POOL_PRINT *Str,
687 IN BOOLEAN DisplayOnly,
688 IN BOOLEAN AllowShortcuts
691 FIBRECHANNEL_DEVICE_PATH *Fibre;
694 UefiDevicePathLibCatPrint (Str, "Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);
698 Converts a FibreEx device path structure to its string representative.
700 @param Str The string representative of input device.
701 @param DevPath The input device path structure.
702 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
703 of the display node is used, where applicable. If DisplayOnly
704 is FALSE, then the longer text representation of the display node
706 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
707 representation for a device node can be used, where applicable.
711 DevPathToTextFibreEx (
712 IN OUT POOL_PRINT *Str,
714 IN BOOLEAN DisplayOnly,
715 IN BOOLEAN AllowShortcuts
718 FIBRECHANNELEX_DEVICE_PATH *FibreEx;
722 UefiDevicePathLibCatPrint (Str, "FibreEx(0x");
723 for (Index = 0; Index < sizeof (FibreEx->WWN) / sizeof (FibreEx->WWN[0]); Index++) {
724 UefiDevicePathLibCatPrint (Str, "%02x", FibreEx->WWN[Index]);
726 UefiDevicePathLibCatPrint (Str, ",0x");
727 for (Index = 0; Index < sizeof (FibreEx->Lun) / sizeof (FibreEx->Lun[0]); Index++) {
728 UefiDevicePathLibCatPrint (Str, "%02x", FibreEx->Lun[Index]);
730 UefiDevicePathLibCatPrint (Str, ")");
734 Converts a Sas Ex device path structure to its string representative.
736 @param Str The string representative of input device.
737 @param DevPath The input device path structure.
738 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
739 of the display node is used, where applicable. If DisplayOnly
740 is FALSE, then the longer text representation of the display node
742 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
743 representation for a device node can be used, where applicable.
748 IN OUT POOL_PRINT *Str,
750 IN BOOLEAN DisplayOnly,
751 IN BOOLEAN AllowShortcuts
754 SASEX_DEVICE_PATH *SasEx;
758 UefiDevicePathLibCatPrint (Str, "SasEx(0x");
760 for (Index = 0; Index < sizeof (SasEx->SasAddress) / sizeof (SasEx->SasAddress[0]); Index++) {
761 UefiDevicePathLibCatPrint (Str, "%02x", SasEx->SasAddress[Index]);
763 UefiDevicePathLibCatPrint (Str, ",0x");
764 for (Index = 0; Index < sizeof (SasEx->Lun) / sizeof (SasEx->Lun[0]); Index++) {
765 UefiDevicePathLibCatPrint (Str, "%02x", SasEx->Lun[Index]);
767 UefiDevicePathLibCatPrint (Str, ",0x%x,", SasEx->RelativeTargetPort);
769 if (((SasEx->DeviceTopology & 0x0f) == 0) && ((SasEx->DeviceTopology & BIT7) == 0)) {
770 UefiDevicePathLibCatPrint (Str, "NoTopology,0,0,0");
771 } else if (((SasEx->DeviceTopology & 0x0f) <= 2) && ((SasEx->DeviceTopology & BIT7) == 0)) {
772 UefiDevicePathLibCatPrint (
775 ((SasEx->DeviceTopology & BIT4) != 0) ? "SATA" : "SAS",
776 ((SasEx->DeviceTopology & BIT5) != 0) ? "External" : "Internal",
777 ((SasEx->DeviceTopology & BIT6) != 0) ? "Expanded" : "Direct"
779 if ((SasEx->DeviceTopology & 0x0f) == 1) {
780 UefiDevicePathLibCatPrint (Str, "0");
783 // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256
785 UefiDevicePathLibCatPrint (Str, "0x%x", ((SasEx->DeviceTopology >> 8) & 0xff) + 1);
788 UefiDevicePathLibCatPrint (Str, "0x%x,0,0,0", SasEx->DeviceTopology);
791 UefiDevicePathLibCatPrint (Str, ")");
797 Converts a NVM Express Namespace device path structure to its string representative.
799 @param Str The string representative of input device.
800 @param DevPath The input device path structure.
801 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
802 of the display node is used, where applicable. If DisplayOnly
803 is FALSE, then the longer text representation of the display node
805 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
806 representation for a device node can be used, where applicable.
811 IN OUT POOL_PRINT *Str,
813 IN BOOLEAN DisplayOnly,
814 IN BOOLEAN AllowShortcuts
817 NVME_NAMESPACE_DEVICE_PATH *Nvme;
821 Uuid = (UINT8 *) &Nvme->NamespaceUuid;
822 UefiDevicePathLibCatPrint (
824 "NVMe(0x%x,%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x)",
826 Uuid[7], Uuid[6], Uuid[5], Uuid[4],
827 Uuid[3], Uuid[2], Uuid[1], Uuid[0]
832 Converts a UFS device path structure to its string representative.
834 @param Str The string representative of input device.
835 @param DevPath The input device path structure.
836 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
837 of the display node is used, where applicable. If DisplayOnly
838 is FALSE, then the longer text representation of the display node
840 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
841 representation for a device node can be used, where applicable.
846 IN OUT POOL_PRINT *Str,
848 IN BOOLEAN DisplayOnly,
849 IN BOOLEAN AllowShortcuts
852 UFS_DEVICE_PATH *Ufs;
855 UefiDevicePathLibCatPrint (Str, "UFS(0x%x,0x%x)", Ufs->Pun, Ufs->Lun);
859 Converts a SD (Secure Digital) device path structure to its string representative.
861 @param Str The string representative of input device.
862 @param DevPath The input device path structure.
863 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
864 of the display node is used, where applicable. If DisplayOnly
865 is FALSE, then the longer text representation of the display node
867 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
868 representation for a device node can be used, where applicable.
873 IN OUT POOL_PRINT *Str,
875 IN BOOLEAN DisplayOnly,
876 IN BOOLEAN AllowShortcuts
882 UefiDevicePathLibCatPrint (
890 Converts a EMMC (Embedded MMC) device path structure to its string representative.
892 @param Str The string representative of input device.
893 @param DevPath The input device path structure.
894 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
895 of the display node is used, where applicable. If DisplayOnly
896 is FALSE, then the longer text representation of the display node
898 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
899 representation for a device node can be used, where applicable.
904 IN OUT POOL_PRINT *Str,
906 IN BOOLEAN DisplayOnly,
907 IN BOOLEAN AllowShortcuts
910 EMMC_DEVICE_PATH *Emmc;
913 UefiDevicePathLibCatPrint (
921 Converts a 1394 device path structure to its string representative.
923 @param Str The string representative of input device.
924 @param DevPath The input device path structure.
925 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
926 of the display node is used, where applicable. If DisplayOnly
927 is FALSE, then the longer text representation of the display node
929 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
930 representation for a device node can be used, where applicable.
935 IN OUT POOL_PRINT *Str,
937 IN BOOLEAN DisplayOnly,
938 IN BOOLEAN AllowShortcuts
941 F1394_DEVICE_PATH *F1394DevPath;
943 F1394DevPath = DevPath;
945 // Guid has format of IEEE-EUI64
947 UefiDevicePathLibCatPrint (Str, "I1394(%016lx)", F1394DevPath->Guid);
951 Converts a USB device path structure to its string representative.
953 @param Str The string representative of input device.
954 @param DevPath The input device path structure.
955 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
956 of the display node is used, where applicable. If DisplayOnly
957 is FALSE, then the longer text representation of the display node
959 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
960 representation for a device node can be used, where applicable.
965 IN OUT POOL_PRINT *Str,
967 IN BOOLEAN DisplayOnly,
968 IN BOOLEAN AllowShortcuts
971 USB_DEVICE_PATH *Usb;
974 UefiDevicePathLibCatPrint (Str, "USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);
978 Converts a USB WWID device path structure to its string representative.
980 @param Str The string representative of input device.
981 @param DevPath The input device path structure.
982 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
983 of the display node is used, where applicable. If DisplayOnly
984 is FALSE, then the longer text representation of the display node
986 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
987 representation for a device node can be used, where applicable.
991 DevPathToTextUsbWWID (
992 IN OUT POOL_PRINT *Str,
994 IN BOOLEAN DisplayOnly,
995 IN BOOLEAN AllowShortcuts
998 USB_WWID_DEVICE_PATH *UsbWWId;
999 CHAR16 *SerialNumberStr;
1005 SerialNumberStr = (CHAR16 *) (&UsbWWId + 1);
1006 Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));
1007 if (SerialNumberStr [Length - 1] != 0) {
1009 // In case no NULL terminator in SerialNumber, create a new one with NULL terminator
1011 NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);
1012 ASSERT (NewStr != NULL);
1013 NewStr [Length] = 0;
1014 SerialNumberStr = NewStr;
1017 UefiDevicePathLibCatPrint (
1019 "UsbWwid(0x%x,0x%x,0x%x,\"%S\")",
1022 UsbWWId->InterfaceNumber,
1028 Converts a Logic Unit device path structure to its string representative.
1030 @param Str The string representative of input device.
1031 @param DevPath The input device path structure.
1032 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1033 of the display node is used, where applicable. If DisplayOnly
1034 is FALSE, then the longer text representation of the display node
1036 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1037 representation for a device node can be used, where applicable.
1041 DevPathToTextLogicalUnit (
1042 IN OUT POOL_PRINT *Str,
1044 IN BOOLEAN DisplayOnly,
1045 IN BOOLEAN AllowShortcuts
1048 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
1050 LogicalUnit = DevPath;
1051 UefiDevicePathLibCatPrint (Str, "Unit(0x%x)", LogicalUnit->Lun);
1055 Converts a USB class device path structure to its string representative.
1057 @param Str The string representative of input device.
1058 @param DevPath The input device path structure.
1059 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1060 of the display node is used, where applicable. If DisplayOnly
1061 is FALSE, then the longer text representation of the display node
1063 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1064 representation for a device node can be used, where applicable.
1068 DevPathToTextUsbClass (
1069 IN OUT POOL_PRINT *Str,
1071 IN BOOLEAN DisplayOnly,
1072 IN BOOLEAN AllowShortcuts
1075 USB_CLASS_DEVICE_PATH *UsbClass;
1076 BOOLEAN IsKnownSubClass;
1081 IsKnownSubClass = TRUE;
1082 switch (UsbClass->DeviceClass) {
1083 case USB_CLASS_AUDIO:
1084 UefiDevicePathLibCatPrint (Str, "UsbAudio");
1087 case USB_CLASS_CDCCONTROL:
1088 UefiDevicePathLibCatPrint (Str, "UsbCDCControl");
1092 UefiDevicePathLibCatPrint (Str, "UsbHID");
1095 case USB_CLASS_IMAGE:
1096 UefiDevicePathLibCatPrint (Str, "UsbImage");
1099 case USB_CLASS_PRINTER:
1100 UefiDevicePathLibCatPrint (Str, "UsbPrinter");
1103 case USB_CLASS_MASS_STORAGE:
1104 UefiDevicePathLibCatPrint (Str, "UsbMassStorage");
1108 UefiDevicePathLibCatPrint (Str, "UsbHub");
1111 case USB_CLASS_CDCDATA:
1112 UefiDevicePathLibCatPrint (Str, "UsbCDCData");
1115 case USB_CLASS_SMART_CARD:
1116 UefiDevicePathLibCatPrint (Str, "UsbSmartCard");
1119 case USB_CLASS_VIDEO:
1120 UefiDevicePathLibCatPrint (Str, "UsbVideo");
1123 case USB_CLASS_DIAGNOSTIC:
1124 UefiDevicePathLibCatPrint (Str, "UsbDiagnostic");
1127 case USB_CLASS_WIRELESS:
1128 UefiDevicePathLibCatPrint (Str, "UsbWireless");
1132 IsKnownSubClass = FALSE;
1136 if (IsKnownSubClass) {
1137 UefiDevicePathLibCatPrint (
1139 "(0x%x,0x%x,0x%x,0x%x)",
1141 UsbClass->ProductId,
1142 UsbClass->DeviceSubClass,
1143 UsbClass->DeviceProtocol
1148 if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {
1149 if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {
1150 UefiDevicePathLibCatPrint (
1152 "UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",
1154 UsbClass->ProductId,
1155 UsbClass->DeviceProtocol
1158 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {
1159 UefiDevicePathLibCatPrint (
1161 "UsbIrdaBridge(0x%x,0x%x,0x%x)",
1163 UsbClass->ProductId,
1164 UsbClass->DeviceProtocol
1167 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {
1168 UefiDevicePathLibCatPrint (
1170 "UsbTestAndMeasurement(0x%x,0x%x,0x%x)",
1172 UsbClass->ProductId,
1173 UsbClass->DeviceProtocol
1179 UefiDevicePathLibCatPrint (
1181 "UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",
1183 UsbClass->ProductId,
1184 UsbClass->DeviceClass,
1185 UsbClass->DeviceSubClass,
1186 UsbClass->DeviceProtocol
1191 Converts a SATA device path structure to its string representative.
1193 @param Str The string representative of input device.
1194 @param DevPath The input device path structure.
1195 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1196 of the display node is used, where applicable. If DisplayOnly
1197 is FALSE, then the longer text representation of the display node
1199 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1200 representation for a device node can be used, where applicable.
1205 IN OUT POOL_PRINT *Str,
1207 IN BOOLEAN DisplayOnly,
1208 IN BOOLEAN AllowShortcuts
1211 SATA_DEVICE_PATH *Sata;
1214 UefiDevicePathLibCatPrint (
1216 "Sata(0x%x,0x%x,0x%x)",
1217 Sata->HBAPortNumber,
1218 Sata->PortMultiplierPortNumber,
1224 Converts a I20 device path structure to its string representative.
1226 @param Str The string representative of input device.
1227 @param DevPath The input device path structure.
1228 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1229 of the display node is used, where applicable. If DisplayOnly
1230 is FALSE, then the longer text representation of the display node
1232 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1233 representation for a device node can be used, where applicable.
1238 IN OUT POOL_PRINT *Str,
1240 IN BOOLEAN DisplayOnly,
1241 IN BOOLEAN AllowShortcuts
1244 I2O_DEVICE_PATH *I2ODevPath;
1246 I2ODevPath = DevPath;
1247 UefiDevicePathLibCatPrint (Str, "I2O(0x%x)", I2ODevPath->Tid);
1251 Converts a MAC address device path structure to its string representative.
1253 @param Str The string representative of input device.
1254 @param DevPath The input device path structure.
1255 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1256 of the display node is used, where applicable. If DisplayOnly
1257 is FALSE, then the longer text representation of the display node
1259 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1260 representation for a device node can be used, where applicable.
1264 DevPathToTextMacAddr (
1265 IN OUT POOL_PRINT *Str,
1267 IN BOOLEAN DisplayOnly,
1268 IN BOOLEAN AllowShortcuts
1271 MAC_ADDR_DEVICE_PATH *MacDevPath;
1272 UINTN HwAddressSize;
1275 MacDevPath = DevPath;
1277 HwAddressSize = sizeof (EFI_MAC_ADDRESS);
1278 if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {
1282 UefiDevicePathLibCatPrint (Str, "MAC(");
1284 for (Index = 0; Index < HwAddressSize; Index++) {
1285 UefiDevicePathLibCatPrint (Str, "%02x", MacDevPath->MacAddress.Addr[Index]);
1288 UefiDevicePathLibCatPrint (Str, ",0x%x)", MacDevPath->IfType);
1292 Converts network protocol string to its text representation.
1294 @param Str The string representative of input device.
1295 @param Protocol The network protocol ID.
1299 CatNetworkProtocol (
1300 IN OUT POOL_PRINT *Str,
1304 if (Protocol == RFC_1700_TCP_PROTOCOL) {
1305 UefiDevicePathLibCatPrint (Str, "TCP");
1306 } else if (Protocol == RFC_1700_UDP_PROTOCOL) {
1307 UefiDevicePathLibCatPrint (Str, "UDP");
1309 UefiDevicePathLibCatPrint (Str, "0x%x", Protocol);
1314 Converts IP v4 address to its text representation.
1316 @param Str The string representative of input device.
1317 @param Address The IP v4 address.
1321 IN OUT POOL_PRINT *Str,
1322 IN EFI_IPv4_ADDRESS *Address
1325 UefiDevicePathLibCatPrint (Str, "%d.%d.%d.%d", Address->Addr[0], Address->Addr[1], Address->Addr[2], Address->Addr[3]);
1329 Converts IP v6 address to its text representation.
1331 @param Str The string representative of input device.
1332 @param Address The IP v6 address.
1336 IN OUT POOL_PRINT *Str,
1337 IN EFI_IPv6_ADDRESS *Address
1340 UefiDevicePathLibCatPrint (
1341 Str, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
1342 Address->Addr[0], Address->Addr[1],
1343 Address->Addr[2], Address->Addr[3],
1344 Address->Addr[4], Address->Addr[5],
1345 Address->Addr[6], Address->Addr[7],
1346 Address->Addr[8], Address->Addr[9],
1347 Address->Addr[10], Address->Addr[11],
1348 Address->Addr[12], Address->Addr[13],
1349 Address->Addr[14], Address->Addr[15]
1354 Converts a IPv4 device path structure to its string representative.
1356 @param Str The string representative of input device.
1357 @param DevPath The input device path structure.
1358 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1359 of the display node is used, where applicable. If DisplayOnly
1360 is FALSE, then the longer text representation of the display node
1362 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1363 representation for a device node can be used, where applicable.
1368 IN OUT POOL_PRINT *Str,
1370 IN BOOLEAN DisplayOnly,
1371 IN BOOLEAN AllowShortcuts
1374 IPv4_DEVICE_PATH *IPDevPath;
1376 IPDevPath = DevPath;
1377 UefiDevicePathLibCatPrint (Str, "IPv4(");
1378 CatIPv4Address (Str, &IPDevPath->RemoteIpAddress);
1381 UefiDevicePathLibCatPrint (Str, ")");
1385 UefiDevicePathLibCatPrint (Str, ",");
1386 CatNetworkProtocol (Str, IPDevPath->Protocol);
1388 UefiDevicePathLibCatPrint (Str, ",%s,", IPDevPath->StaticIpAddress ? "Static" : "DHCP");
1389 CatIPv4Address (Str, &IPDevPath->LocalIpAddress);
1390 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv4_DEVICE_PATH)) {
1391 UefiDevicePathLibCatPrint (Str, ",");
1392 CatIPv4Address (Str, &IPDevPath->GatewayIpAddress);
1393 UefiDevicePathLibCatPrint (Str, ",");
1394 CatIPv4Address (Str, &IPDevPath->SubnetMask);
1396 UefiDevicePathLibCatPrint (Str, ")");
1400 Converts a IPv6 device path structure to its string representative.
1402 @param Str The string representative of input device.
1403 @param DevPath The input device path structure.
1404 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1405 of the display node is used, where applicable. If DisplayOnly
1406 is FALSE, then the longer text representation of the display node
1408 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1409 representation for a device node can be used, where applicable.
1414 IN OUT POOL_PRINT *Str,
1416 IN BOOLEAN DisplayOnly,
1417 IN BOOLEAN AllowShortcuts
1420 IPv6_DEVICE_PATH *IPDevPath;
1422 IPDevPath = DevPath;
1423 UefiDevicePathLibCatPrint (Str, "IPv6(");
1424 CatIPv6Address (Str, &IPDevPath->RemoteIpAddress);
1426 UefiDevicePathLibCatPrint (Str, ")");
1430 UefiDevicePathLibCatPrint (Str, ",");
1431 CatNetworkProtocol (Str, IPDevPath->Protocol);
1433 switch (IPDevPath->IpAddressOrigin) {
1435 UefiDevicePathLibCatPrint (Str, ",Static,");
1438 UefiDevicePathLibCatPrint (Str, ",StatelessAutoConfigure,");
1441 UefiDevicePathLibCatPrint (Str, ",StatefulAutoConfigure,");
1445 CatIPv6Address (Str, &IPDevPath->LocalIpAddress);
1447 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv6_DEVICE_PATH)) {
1448 UefiDevicePathLibCatPrint (Str, ",0x%x,", IPDevPath->PrefixLength);
1449 CatIPv6Address (Str, &IPDevPath->GatewayIpAddress);
1451 UefiDevicePathLibCatPrint (Str, ")");
1455 Converts an Infini Band device path structure to its string representative.
1457 @param Str The string representative of input device.
1458 @param DevPath The input device path structure.
1459 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1460 of the display node is used, where applicable. If DisplayOnly
1461 is FALSE, then the longer text representation of the display node
1463 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1464 representation for a device node can be used, where applicable.
1468 DevPathToTextInfiniBand (
1469 IN OUT POOL_PRINT *Str,
1471 IN BOOLEAN DisplayOnly,
1472 IN BOOLEAN AllowShortcuts
1475 INFINIBAND_DEVICE_PATH *InfiniBand;
1477 InfiniBand = DevPath;
1478 UefiDevicePathLibCatPrint (
1480 "Infiniband(0x%x,%36s,0x%lx,0x%lx,0x%lx)",
1481 InfiniBand->ResourceFlags,
1482 G(InfiniBand->PortGid),
1483 InfiniBand->ServiceId,
1484 InfiniBand->TargetPortId,
1485 InfiniBand->DeviceId
1490 Converts a UART device path structure to its string representative.
1492 @param Str The string representative of input device.
1493 @param DevPath The input device path structure.
1494 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1495 of the display node is used, where applicable. If DisplayOnly
1496 is FALSE, then the longer text representation of the display node
1498 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1499 representation for a device node can be used, where applicable.
1504 IN OUT POOL_PRINT *Str,
1506 IN BOOLEAN DisplayOnly,
1507 IN BOOLEAN AllowShortcuts
1510 UART_DEVICE_PATH *Uart;
1514 switch (Uart->Parity) {
1544 if (Uart->BaudRate == 0) {
1545 UefiDevicePathLibCatPrint (Str, "Uart(DEFAULT,");
1547 UefiDevicePathLibCatPrint (Str, "Uart(%ld,", Uart->BaudRate);
1550 if (Uart->DataBits == 0) {
1551 UefiDevicePathLibCatPrint (Str, "DEFAULT,");
1553 UefiDevicePathLibCatPrint (Str, "%d,", Uart->DataBits);
1556 UefiDevicePathLibCatPrint (Str, "%c,", Parity);
1558 switch (Uart->StopBits) {
1560 UefiDevicePathLibCatPrint (Str, "D)");
1564 UefiDevicePathLibCatPrint (Str, "1)");
1568 UefiDevicePathLibCatPrint (Str, "1.5)");
1572 UefiDevicePathLibCatPrint (Str, "2)");
1576 UefiDevicePathLibCatPrint (Str, "x)");
1582 Converts an iSCSI device path structure to its string representative.
1584 @param Str The string representative of input device.
1585 @param DevPath The input device path structure.
1586 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1587 of the display node is used, where applicable. If DisplayOnly
1588 is FALSE, then the longer text representation of the display node
1590 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1591 representation for a device node can be used, where applicable.
1595 DevPathToTextiSCSI (
1596 IN OUT POOL_PRINT *Str,
1598 IN BOOLEAN DisplayOnly,
1599 IN BOOLEAN AllowShortcuts
1602 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
1605 ISCSIDevPath = DevPath;
1606 UefiDevicePathLibCatPrint (
1608 "iSCSI(%s,0x%x,0x%lx,",
1609 ISCSIDevPath->TargetName,
1610 ISCSIDevPath->TargetPortalGroupTag,
1614 Options = ISCSIDevPath->LoginOption;
1615 UefiDevicePathLibCatPrint (Str, "%s,", (((Options >> 1) & 0x0001) != 0) ? "CRC32C" : "None");
1616 UefiDevicePathLibCatPrint (Str, "%s,", (((Options >> 3) & 0x0001) != 0) ? "CRC32C" : "None");
1617 if (((Options >> 11) & 0x0001) != 0) {
1618 UefiDevicePathLibCatPrint (Str, "%s,", "None");
1619 } else if (((Options >> 12) & 0x0001) != 0) {
1620 UefiDevicePathLibCatPrint (Str, "%s,", "CHAP_UNI");
1622 UefiDevicePathLibCatPrint (Str, "%s,", "CHAP_BI");
1626 UefiDevicePathLibCatPrint (Str, "%s)", (ISCSIDevPath->NetworkProtocol == 0) ? "TCP" : "reserved");
1630 Converts a VLAN device path structure to its string representative.
1632 @param Str The string representative of input device.
1633 @param DevPath The input device path structure.
1634 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1635 of the display node is used, where applicable. If DisplayOnly
1636 is FALSE, then the longer text representation of the display node
1638 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1639 representation for a device node can be used, where applicable.
1644 IN OUT POOL_PRINT *Str,
1646 IN BOOLEAN DisplayOnly,
1647 IN BOOLEAN AllowShortcuts
1650 VLAN_DEVICE_PATH *Vlan;
1653 UefiDevicePathLibCatPrint (Str, "Vlan(%d)", Vlan->VlanId);
1657 Converts a Bluetooth device path structure to its string representative.
1659 @param Str The string representative of input device.
1660 @param DevPath The input device path structure.
1661 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1662 of the display node is used, where applicable. If DisplayOnly
1663 is FALSE, then the longer text representation of the display node
1665 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1666 representation for a device node can be used, where applicable.
1670 DevPathToTextBluetooth (
1671 IN OUT POOL_PRINT *Str,
1673 IN BOOLEAN DisplayOnly,
1674 IN BOOLEAN AllowShortcuts
1677 BLUETOOTH_DEVICE_PATH *Bluetooth;
1679 Bluetooth = DevPath;
1680 UefiDevicePathLibCatPrint (
1682 "Bluetooth(%02x%02x%02x%02x%02x%02x)",
1683 Bluetooth->BD_ADDR.Address[5],
1684 Bluetooth->BD_ADDR.Address[4],
1685 Bluetooth->BD_ADDR.Address[3],
1686 Bluetooth->BD_ADDR.Address[2],
1687 Bluetooth->BD_ADDR.Address[1],
1688 Bluetooth->BD_ADDR.Address[0]
1693 Converts a Wi-Fi device path structure to its string representative.
1695 @param Str The string representative of input device.
1696 @param DevPath The input device path structure.
1697 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1698 of the display node is used, where applicable. If DisplayOnly
1699 is FALSE, then the longer text representation of the display node
1701 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1702 representation for a device node can be used, where applicable.
1707 IN OUT POOL_PRINT *Str,
1709 IN BOOLEAN DisplayOnly,
1710 IN BOOLEAN AllowShortcuts
1713 WIFI_DEVICE_PATH *WiFi;
1719 CopyMem (SSId, WiFi->SSId, 32);
1721 UefiDevicePathLibCatPrint (Str, "Wi-Fi(%s)", SSId);
1725 Converts a URI device path structure to its string representative.
1727 @param Str The string representative of input device.
1728 @param DevPath The input device path structure.
1729 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1730 of the display node is used, where applicable. If DisplayOnly
1731 is FALSE, then the longer text representation of the display node
1733 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1734 representation for a device node can be used, where applicable.
1739 IN OUT POOL_PRINT *Str,
1741 IN BOOLEAN DisplayOnly,
1742 IN BOOLEAN AllowShortcuts
1745 URI_DEVICE_PATH *Uri;
1750 // Uri in the device path may not be null terminated.
1753 UriLength = DevicePathNodeLength (Uri) - sizeof (URI_DEVICE_PATH);
1754 UriStr = AllocatePool (UriLength + 1);
1755 ASSERT (UriStr != NULL);
1757 CopyMem (UriStr, Uri->Uri, UriLength);
1758 UriStr[UriLength] = '\0';
1759 UefiDevicePathLibCatPrint (Str, "Uri(%s)", UriStr);
1764 Converts a Hard drive device path structure to its string representative.
1766 @param Str The string representative of input device.
1767 @param DevPath The input device path structure.
1768 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1769 of the display node is used, where applicable. If DisplayOnly
1770 is FALSE, then the longer text representation of the display node
1772 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1773 representation for a device node can be used, where applicable.
1777 DevPathToTextHardDrive (
1778 IN OUT POOL_PRINT *Str,
1780 IN BOOLEAN DisplayOnly,
1781 IN BOOLEAN AllowShortcuts
1784 HARDDRIVE_DEVICE_PATH *Hd;
1787 switch (Hd->SignatureType) {
1788 case SIGNATURE_TYPE_MBR:
1789 UefiDevicePathLibCatPrint (
1792 Hd->PartitionNumber,
1794 // *((UINT32 *) (&(Hd->Signature[0])))
1795 le32dec(&(Hd->Signature[0]))
1799 case SIGNATURE_TYPE_GUID:
1800 UefiDevicePathLibCatPrint (
1803 Hd->PartitionNumber,
1805 G(&(Hd->Signature[0]))
1810 UefiDevicePathLibCatPrint (
1813 Hd->PartitionNumber,
1819 UefiDevicePathLibCatPrint (Str, "0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);
1823 Converts a CDROM device path structure to its string representative.
1825 @param Str The string representative of input device.
1826 @param DevPath The input device path structure.
1827 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1828 of the display node is used, where applicable. If DisplayOnly
1829 is FALSE, then the longer text representation of the display node
1831 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1832 representation for a device node can be used, where applicable.
1836 DevPathToTextCDROM (
1837 IN OUT POOL_PRINT *Str,
1839 IN BOOLEAN DisplayOnly,
1840 IN BOOLEAN AllowShortcuts
1843 CDROM_DEVICE_PATH *Cd;
1847 UefiDevicePathLibCatPrint (Str, "CDROM(0x%x)", Cd->BootEntry);
1851 UefiDevicePathLibCatPrint (Str, "CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);
1855 Converts a File device path structure to its string representative.
1857 @param Str The string representative of input device.
1858 @param DevPath The input device path structure.
1859 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1860 of the display node is used, where applicable. If DisplayOnly
1861 is FALSE, then the longer text representation of the display node
1863 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1864 representation for a device node can be used, where applicable.
1868 DevPathToTextFilePath (
1869 IN OUT POOL_PRINT *Str,
1871 IN BOOLEAN DisplayOnly,
1872 IN BOOLEAN AllowShortcuts
1875 FILEPATH_DEVICE_PATH *Fp;
1879 ucs2_to_utf8(Fp->PathName, &name);
1880 UefiDevicePathLibCatPrint (Str, "File(%s)", name);
1885 Converts a Media protocol device path structure to its string representative.
1887 @param Str The string representative of input device.
1888 @param DevPath The input device path structure.
1889 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1890 of the display node is used, where applicable. If DisplayOnly
1891 is FALSE, then the longer text representation of the display node
1893 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1894 representation for a device node can be used, where applicable.
1898 DevPathToTextMediaProtocol (
1899 IN OUT POOL_PRINT *Str,
1901 IN BOOLEAN DisplayOnly,
1902 IN BOOLEAN AllowShortcuts
1905 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;
1907 MediaProt = DevPath;
1908 UefiDevicePathLibCatPrint (Str, "Media(%36s)", G(&MediaProt->Protocol));
1912 Converts a Firmware Volume device path structure to its string representative.
1914 @param Str The string representative of input device.
1915 @param DevPath The input device path structure.
1916 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1917 of the display node is used, where applicable. If DisplayOnly
1918 is FALSE, then the longer text representation of the display node
1920 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1921 representation for a device node can be used, where applicable.
1926 IN OUT POOL_PRINT *Str,
1928 IN BOOLEAN DisplayOnly,
1929 IN BOOLEAN AllowShortcuts
1932 MEDIA_FW_VOL_DEVICE_PATH *Fv;
1935 UefiDevicePathLibCatPrint (Str, "Fv(%36s)", G(&Fv->FvName));
1939 Converts a Firmware Volume File device path structure to its string representative.
1941 @param Str The string representative of input device.
1942 @param DevPath The input device path structure.
1943 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1944 of the display node is used, where applicable. If DisplayOnly
1945 is FALSE, then the longer text representation of the display node
1947 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1948 representation for a device node can be used, where applicable.
1952 DevPathToTextFvFile (
1953 IN OUT POOL_PRINT *Str,
1955 IN BOOLEAN DisplayOnly,
1956 IN BOOLEAN AllowShortcuts
1959 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;
1962 UefiDevicePathLibCatPrint (Str, "FvFile(%36s)", G(&FvFile->FvFileName));
1966 Converts a Relative Offset device path structure to its string representative.
1968 @param Str The string representative of input device.
1969 @param DevPath The input device path structure.
1970 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1971 of the display node is used, where applicable. If DisplayOnly
1972 is FALSE, then the longer text representation of the display node
1974 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1975 representation for a device node can be used, where applicable.
1979 DevPathRelativeOffsetRange (
1980 IN OUT POOL_PRINT *Str,
1982 IN BOOLEAN DisplayOnly,
1983 IN BOOLEAN AllowShortcuts
1986 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;
1989 UefiDevicePathLibCatPrint (
1991 "Offset(0x%lx,0x%lx)",
1992 Offset->StartingOffset,
1993 Offset->EndingOffset
1998 Converts a Ram Disk device path structure to its string representative.
2000 @param Str The string representative of input device.
2001 @param DevPath The input device path structure.
2002 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2003 of the display node is used, where applicable. If DisplayOnly
2004 is FALSE, then the longer text representation of the display node
2006 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2007 representation for a device node can be used, where applicable.
2011 DevPathToTextRamDisk (
2012 IN OUT POOL_PRINT *Str,
2014 IN BOOLEAN DisplayOnly,
2015 IN BOOLEAN AllowShortcuts
2018 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
2022 if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid)) {
2023 UefiDevicePathLibCatPrint (
2025 "VirtualDisk(0x%lx,0x%lx,%d)",
2026 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2027 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2030 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid)) {
2031 UefiDevicePathLibCatPrint (
2033 "VirtualCD(0x%lx,0x%lx,%d)",
2034 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2035 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2038 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid)) {
2039 UefiDevicePathLibCatPrint (
2041 "PersistentVirtualDisk(0x%lx,0x%lx,%d)",
2042 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2043 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2046 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid)) {
2047 UefiDevicePathLibCatPrint (
2049 "PersistentVirtualCD(0x%lx,0x%lx,%d)",
2050 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2051 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2055 UefiDevicePathLibCatPrint (
2057 "RamDisk(0x%lx,0x%lx,%d,%36s)",
2058 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2059 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2061 G(&RamDisk->TypeGuid)
2067 Converts a BIOS Boot Specification device path structure to its string representative.
2069 @param Str The string representative of input device.
2070 @param DevPath The input device path structure.
2071 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2072 of the display node is used, where applicable. If DisplayOnly
2073 is FALSE, then the longer text representation of the display node
2075 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2076 representation for a device node can be used, where applicable.
2081 IN OUT POOL_PRINT *Str,
2083 IN BOOLEAN DisplayOnly,
2084 IN BOOLEAN AllowShortcuts
2087 BBS_BBS_DEVICE_PATH *Bbs;
2091 switch (Bbs->DeviceType) {
2092 case BBS_TYPE_FLOPPY:
2096 case BBS_TYPE_HARDDRIVE:
2100 case BBS_TYPE_CDROM:
2104 case BBS_TYPE_PCMCIA:
2112 case BBS_TYPE_EMBEDDED_NETWORK:
2122 UefiDevicePathLibCatPrint (Str, "BBS(%s,%s", Type, Bbs->String);
2124 UefiDevicePathLibCatPrint (Str, "BBS(0x%x,%s", Bbs->DeviceType, Bbs->String);
2128 UefiDevicePathLibCatPrint (Str, ")");
2132 UefiDevicePathLibCatPrint (Str, ",0x%x)", Bbs->StatusFlag);
2136 Converts an End-of-Device-Path structure to its string representative.
2138 @param Str The string representative of input device.
2139 @param DevPath The input device path structure.
2140 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2141 of the display node is used, where applicable. If DisplayOnly
2142 is FALSE, then the longer text representation of the display node
2144 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2145 representation for a device node can be used, where applicable.
2149 DevPathToTextEndInstance (
2150 IN OUT POOL_PRINT *Str,
2152 IN BOOLEAN DisplayOnly,
2153 IN BOOLEAN AllowShortcuts
2156 UefiDevicePathLibCatPrint (Str, ",");
2159 GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_GENERIC_TABLE mUefiDevicePathLibToTextTableGeneric[] = {
2160 {HARDWARE_DEVICE_PATH, "HardwarePath" },
2161 {ACPI_DEVICE_PATH, "AcpiPath" },
2162 {MESSAGING_DEVICE_PATH, "Msg" },
2163 {MEDIA_DEVICE_PATH, "MediaPath" },
2164 {BBS_DEVICE_PATH, "BbsPath" },
2169 Converts an unknown device path structure to its string representative.
2171 @param Str The string representative of input device.
2172 @param DevPath The input device path structure.
2173 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2174 of the display node is used, where applicable. If DisplayOnly
2175 is FALSE, then the longer text representation of the display node
2177 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2178 representation for a device node can be used, where applicable.
2182 DevPathToTextNodeGeneric (
2183 IN OUT POOL_PRINT *Str,
2185 IN BOOLEAN DisplayOnly,
2186 IN BOOLEAN AllowShortcuts
2189 EFI_DEVICE_PATH_PROTOCOL *Node;
2194 for (Index = 0; mUefiDevicePathLibToTextTableGeneric[Index].Text != NULL; Index++) {
2195 if (DevicePathType (Node) == mUefiDevicePathLibToTextTableGeneric[Index].Type) {
2200 if (mUefiDevicePathLibToTextTableGeneric[Index].Text == NULL) {
2202 // It's a node whose type cannot be recognized
2204 UefiDevicePathLibCatPrint (Str, "Path(%d,%d", DevicePathType (Node), DevicePathSubType (Node));
2207 // It's a node whose type can be recognized
2209 UefiDevicePathLibCatPrint (Str, "%s(%d", mUefiDevicePathLibToTextTableGeneric[Index].Text, DevicePathSubType (Node));
2212 Index = sizeof (EFI_DEVICE_PATH_PROTOCOL);
2213 if (Index < DevicePathNodeLength (Node)) {
2214 UefiDevicePathLibCatPrint (Str, ",");
2215 for (; Index < DevicePathNodeLength (Node); Index++) {
2216 UefiDevicePathLibCatPrint (Str, "%02x", ((UINT8 *) Node)[Index]);
2220 UefiDevicePathLibCatPrint (Str, ")");
2223 static const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = {
2224 {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci },
2225 {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard },
2226 {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap },
2227 {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor },
2228 {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController },
2229 {HARDWARE_DEVICE_PATH, HW_BMC_DP, DevPathToTextBmc },
2230 {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi },
2231 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx },
2232 {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr },
2233 {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi },
2234 {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi },
2235 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre },
2236 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx },
2237 {MESSAGING_DEVICE_PATH, MSG_SASEX_DP, DevPathToTextSasEx },
2238 {MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP, DevPathToTextNVMe },
2239 {MESSAGING_DEVICE_PATH, MSG_UFS_DP, DevPathToTextUfs },
2240 {MESSAGING_DEVICE_PATH, MSG_SD_DP, DevPathToTextSd },
2241 {MESSAGING_DEVICE_PATH, MSG_EMMC_DP, DevPathToTextEmmc },
2242 {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394 },
2243 {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb },
2244 {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID },
2245 {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit },
2246 {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass },
2247 {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata },
2248 {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O },
2249 {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr },
2250 {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4 },
2251 {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6 },
2252 {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand },
2253 {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart },
2254 {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor },
2255 {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI },
2256 {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan },
2257 {MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextUri },
2258 {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextBluetooth },
2259 {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextWiFi },
2260 {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive },
2261 {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM },
2262 {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor },
2263 {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol },
2264 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath },
2265 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv },
2266 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile },
2267 {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange },
2268 {MEDIA_DEVICE_PATH, MEDIA_RAM_DISK_DP, DevPathToTextRamDisk },
2269 {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS },
2270 {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance },
2275 Converts a device node to its string representation.
2277 @param DeviceNode A Pointer to the device node to be converted.
2278 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2279 of the display node is used, where applicable. If DisplayOnly
2280 is FALSE, then the longer text representation of the display node
2282 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2283 representation for a device node can be used, where applicable.
2285 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode
2286 is NULL or there was insufficient memory.
2291 UefiDevicePathLibConvertDeviceNodeToText (
2292 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
2293 IN BOOLEAN DisplayOnly,
2294 IN BOOLEAN AllowShortcuts
2299 DEVICE_PATH_TO_TEXT ToText;
2300 EFI_DEVICE_PATH_PROTOCOL *Node;
2302 if (DeviceNode == NULL) {
2306 ZeroMem (&Str, sizeof (Str));
2309 // Process the device path node
2310 // If not found, use a generic function
2312 Node = __DECONST(EFI_DEVICE_PATH_PROTOCOL *, DeviceNode);
2313 ToText = DevPathToTextNodeGeneric;
2314 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index++) {
2315 if (DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type &&
2316 DevicePathSubType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].SubType
2318 ToText = mUefiDevicePathLibToTextTable[Index].Function;
2326 ToText (&Str, (VOID *) Node, DisplayOnly, AllowShortcuts);
2328 ASSERT (Str.Str != NULL);
2333 Converts a device path to its text representation.
2335 @param DevicePath A Pointer to the device to be converted.
2336 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2337 of the display node is used, where applicable. If DisplayOnly
2338 is FALSE, then the longer text representation of the display node
2340 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2341 representation for a device node can be used, where applicable.
2343 @return A pointer to the allocated text representation of the device path or
2344 NULL if DeviceNode is NULL or there was insufficient memory.
2349 UefiDevicePathLibConvertDevicePathToText (
2350 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
2351 IN BOOLEAN DisplayOnly,
2352 IN BOOLEAN AllowShortcuts
2356 EFI_DEVICE_PATH_PROTOCOL *Node;
2357 EFI_DEVICE_PATH_PROTOCOL *AlignedNode;
2359 DEVICE_PATH_TO_TEXT ToText;
2361 if (DevicePath == NULL) {
2365 ZeroMem (&Str, sizeof (Str));
2368 // Process each device path node
2370 Node = __DECONST(EFI_DEVICE_PATH_PROTOCOL *, DevicePath);
2371 while (!IsDevicePathEnd (Node)) {
2373 // Find the handler to dump this device path node
2374 // If not found, use a generic function
2376 ToText = DevPathToTextNodeGeneric;
2377 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index += 1) {
2379 if (DevicePathType (Node) == mUefiDevicePathLibToTextTable[Index].Type &&
2380 DevicePathSubType (Node) == mUefiDevicePathLibToTextTable[Index].SubType
2382 ToText = mUefiDevicePathLibToTextTable[Index].Function;
2387 // Put a path separator in if needed
2389 if ((Str.Count != 0) && (ToText != DevPathToTextEndInstance)) {
2390 if (Str.Str[Str.Count] != ',') {
2391 UefiDevicePathLibCatPrint (&Str, "/");
2395 AlignedNode = AllocateCopyPool (DevicePathNodeLength (Node), Node);
2397 // Print this node of the device path
2399 ToText (&Str, AlignedNode, DisplayOnly, AllowShortcuts);
2400 FreePool (AlignedNode);
2403 // Next device path node
2405 Node = NextDevicePathNode (Node);
2408 if (Str.Str == NULL) {
2409 return AllocateZeroPool (sizeof (CHAR16));
2417 efidp_format_device_path(char *buf, size_t len, const_efidp dp, ssize_t max)
2422 str = UefiDevicePathLibConvertDevicePathToText (
2423 __DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp), FALSE, TRUE);
2426 strlcpy(buf, str, len);
2427 retval = strlen(str);
2434 efidp_format_device_path_node(char *buf, size_t len, const_efidp dp)
2439 str = UefiDevicePathLibConvertDeviceNodeToText (
2440 __DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp), FALSE, TRUE);
2443 strlcpy(buf, str, len);
2444 retval = strlen(str);
2451 efidp_size(const_efidp dp)
2454 return GetDevicePathSize(__DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp));
2458 efidp_extract_file_path(const_efidp dp)
2460 const FILEPATH_DEVICE_PATH *fp;
2463 fp = (const void *)dp;
2464 ucs2_to_utf8(fp->PathName, &name);