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 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
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"
47 * This is a lie, but since we have converted everything
48 * from wide to narrow, it's the right lie now.
50 #define UnicodeSPrint snprintf
53 * Taken from MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
54 * hash a11928f3310518ab1c6fd34e8d0fdbb72de9602c 2017-Mar-01
56 * wide strings converted to narrow
57 * Low level printing code redone for narrow strings
58 * Routines made static
59 * %s -> %S in spots (where it is still UCS-2)
61 * %g -> %36s hack to print guid (see above for caveat)
62 * some tidying up of const and deconsting. It's evil, but const
63 * poisoning the whole file was too much.
67 DevicePathToText protocol as defined in the UEFI 2.0 specification.
69 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
70 Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>
71 This program and the accompanying materials
72 are licensed and made available under the terms and conditions of the BSD License
73 which accompanies this distribution. The full text of the license may be found at
74 http://opensource.org/licenses/bsd-license.php
76 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
77 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
81 // #include "UefiDevicePathLib.h"
84 Concatenates a formatted unicode string to allocated pool. The caller must
85 free the resulting buffer.
87 @param Str Tracks the allocated pool, size in use, and
88 amount of pool allocated.
89 @param Fmt The format string
90 @param ... Variable arguments based on the format string.
92 @return Allocated buffer with the formatted string printed in it.
93 The caller must free the allocated buffer. The buffer
94 allocation is not packed.
99 UefiDevicePathLibCatPrint (
100 IN OUT POOL_PRINT *Str,
108 VA_START (Args, Fmt);
109 Count = vsnprintf(NULL, 0, Fmt, Args);
112 if ((Str->Count + (Count + 1)) > Str->Capacity) {
113 Str->Capacity = (Str->Count + (Count + 1) * 2);
114 Str->Str = reallocf(Str->Str, Str->Capacity);
115 ASSERT (Str->Str != NULL);
117 VA_START (Args, Fmt);
118 vsnprintf(Str->Str + Str->Count, Str->Capacity - Str->Count, Fmt, Args);
126 Converts a PCI device path structure to its string representative.
128 @param Str The string representative of input device.
129 @param DevPath The input device path structure.
130 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
131 of the display node is used, where applicable. If DisplayOnly
132 is FALSE, then the longer text representation of the display node
134 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
135 representation for a device node can be used, where applicable.
140 IN OUT POOL_PRINT *Str,
142 IN BOOLEAN DisplayOnly,
143 IN BOOLEAN AllowShortcuts
146 PCI_DEVICE_PATH *Pci;
149 UefiDevicePathLibCatPrint (Str, "Pci(0x%x,0x%x)", Pci->Device, Pci->Function);
153 Converts a PC Card device path structure to its string representative.
155 @param Str The string representative of input device.
156 @param DevPath The input device path structure.
157 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
158 of the display node is used, where applicable. If DisplayOnly
159 is FALSE, then the longer text representation of the display node
161 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
162 representation for a device node can be used, where applicable.
166 DevPathToTextPccard (
167 IN OUT POOL_PRINT *Str,
169 IN BOOLEAN DisplayOnly,
170 IN BOOLEAN AllowShortcuts
173 PCCARD_DEVICE_PATH *Pccard;
176 UefiDevicePathLibCatPrint (Str, "PcCard(0x%x)", Pccard->FunctionNumber);
180 Converts a Memory Map device path structure to its string representative.
182 @param Str The string representative of input device.
183 @param DevPath The input device path structure.
184 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
185 of the display node is used, where applicable. If DisplayOnly
186 is FALSE, then the longer text representation of the display node
188 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
189 representation for a device node can be used, where applicable.
193 DevPathToTextMemMap (
194 IN OUT POOL_PRINT *Str,
196 IN BOOLEAN DisplayOnly,
197 IN BOOLEAN AllowShortcuts
200 MEMMAP_DEVICE_PATH *MemMap;
203 UefiDevicePathLibCatPrint (
205 "MemoryMapped(0x%x,0x%lx,0x%lx)",
207 MemMap->StartingAddress,
208 MemMap->EndingAddress
213 Converts a Vendor device path structure to its string representative.
215 @param Str The string representative of input device.
216 @param DevPath The input device path structure.
217 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
218 of the display node is used, where applicable. If DisplayOnly
219 is FALSE, then the longer text representation of the display node
221 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
222 representation for a device node can be used, where applicable.
226 DevPathToTextVendor (
227 IN OUT POOL_PRINT *Str,
229 IN BOOLEAN DisplayOnly,
230 IN BOOLEAN AllowShortcuts
233 VENDOR_DEVICE_PATH *Vendor;
237 UINT32 FlowControlMap;
240 Vendor = (VENDOR_DEVICE_PATH *) DevPath;
241 switch (DevicePathType (&Vendor->Header)) {
242 case HARDWARE_DEVICE_PATH:
246 case MESSAGING_DEVICE_PATH:
248 if (AllowShortcuts) {
249 if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {
250 UefiDevicePathLibCatPrint (Str, "VenPcAnsi()");
252 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {
253 UefiDevicePathLibCatPrint (Str, "VenVt100()");
255 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {
256 UefiDevicePathLibCatPrint (Str, "VenVt100Plus()");
258 } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {
259 UefiDevicePathLibCatPrint (Str, "VenUft8()");
261 } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) {
262 FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);
263 switch (FlowControlMap & 0x00000003) {
265 UefiDevicePathLibCatPrint (Str, "UartFlowCtrl(%s)", "None");
269 UefiDevicePathLibCatPrint (Str, "UartFlowCtrl(%s)", "Hardware");
273 UefiDevicePathLibCatPrint (Str, "UartFlowCtrl(%s)", "XonXoff");
281 } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {
282 UefiDevicePathLibCatPrint (
284 "SAS(0x%lx,0x%lx,0x%x,",
285 ((SAS_DEVICE_PATH *) Vendor)->SasAddress,
286 ((SAS_DEVICE_PATH *) Vendor)->Lun,
287 ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort
289 Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);
290 if (((Info & 0x0f) == 0) && ((Info & BIT7) == 0)) {
291 UefiDevicePathLibCatPrint (Str, "NoTopology,0,0,0,");
292 } else if (((Info & 0x0f) <= 2) && ((Info & BIT7) == 0)) {
293 UefiDevicePathLibCatPrint (
296 ((Info & BIT4) != 0) ? "SATA" : "SAS",
297 ((Info & BIT5) != 0) ? "External" : "Internal",
298 ((Info & BIT6) != 0) ? "Expanded" : "Direct"
300 if ((Info & 0x0f) == 1) {
301 UefiDevicePathLibCatPrint (Str, "0,");
304 // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256
306 UefiDevicePathLibCatPrint (Str, "0x%x,", ((Info >> 8) & 0xff) + 1);
309 UefiDevicePathLibCatPrint (Str, "0x%x,0,0,0,", Info);
312 UefiDevicePathLibCatPrint (Str, "0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);
314 } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {
315 UefiDevicePathLibCatPrint (Str, "DebugPort()");
321 case MEDIA_DEVICE_PATH:
330 DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);
331 UefiDevicePathLibCatPrint (Str, "Ven%s(%36s", Type, G(&Vendor->Guid));
332 if (DataLength != 0) {
333 UefiDevicePathLibCatPrint (Str, ",");
334 for (Index = 0; Index < DataLength; Index++) {
335 UefiDevicePathLibCatPrint (Str, "%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);
339 UefiDevicePathLibCatPrint (Str, ")");
343 Converts a Controller device path structure to its string representative.
345 @param Str The string representative of input device.
346 @param DevPath The input device path structure.
347 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
348 of the display node is used, where applicable. If DisplayOnly
349 is FALSE, then the longer text representation of the display node
351 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
352 representation for a device node can be used, where applicable.
356 DevPathToTextController (
357 IN OUT POOL_PRINT *Str,
359 IN BOOLEAN DisplayOnly,
360 IN BOOLEAN AllowShortcuts
363 CONTROLLER_DEVICE_PATH *Controller;
365 Controller = DevPath;
366 UefiDevicePathLibCatPrint (
369 Controller->ControllerNumber
374 Converts a BMC device path structure to its string representative.
376 @param Str The string representative of input device.
377 @param DevPath The input device path structure.
378 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
379 of the display node is used, where applicable. If DisplayOnly
380 is FALSE, then the longer text representation of the display node
382 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
383 representation for a device node can be used, where applicable.
388 IN OUT POOL_PRINT *Str,
390 IN BOOLEAN DisplayOnly,
391 IN BOOLEAN AllowShortcuts
394 BMC_DEVICE_PATH *Bmc;
397 UefiDevicePathLibCatPrint (
401 ReadUnaligned64 ((&Bmc->BaseAddress))
406 Converts a ACPI device path structure to its string representative.
408 @param Str The string representative of input device.
409 @param DevPath The input device path structure.
410 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
411 of the display node is used, where applicable. If DisplayOnly
412 is FALSE, then the longer text representation of the display node
414 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
415 representation for a device node can be used, where applicable.
420 IN OUT POOL_PRINT *Str,
422 IN BOOLEAN DisplayOnly,
423 IN BOOLEAN AllowShortcuts
426 ACPI_HID_DEVICE_PATH *Acpi;
429 if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
430 switch (EISA_ID_TO_NUM (Acpi->HID)) {
432 UefiDevicePathLibCatPrint (Str, "PciRoot(0x%x)", Acpi->UID);
436 UefiDevicePathLibCatPrint (Str, "PcieRoot(0x%x)", Acpi->UID);
440 UefiDevicePathLibCatPrint (Str, "Floppy(0x%x)", Acpi->UID);
444 UefiDevicePathLibCatPrint (Str, "Keyboard(0x%x)", Acpi->UID);
448 UefiDevicePathLibCatPrint (Str, "Serial(0x%x)", Acpi->UID);
452 UefiDevicePathLibCatPrint (Str, "ParallelPort(0x%x)", Acpi->UID);
456 UefiDevicePathLibCatPrint (Str, "Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);
460 UefiDevicePathLibCatPrint (Str, "Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID);
465 Converts a ACPI extended HID device path structure to its string representative.
467 @param Str The string representative of input device.
468 @param DevPath The input device path structure.
469 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
470 of the display node is used, where applicable. If DisplayOnly
471 is FALSE, then the longer text representation of the display node
473 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
474 representation for a device node can be used, where applicable.
478 DevPathToTextAcpiEx (
479 IN OUT POOL_PRINT *Str,
481 IN BOOLEAN DisplayOnly,
482 IN BOOLEAN AllowShortcuts
485 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;
493 HIDStr = (CHAR8 *) (((UINT8 *) AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
494 UIDStr = HIDStr + AsciiStrLen (HIDStr) + 1;
495 CIDStr = UIDStr + AsciiStrLen (UIDStr) + 1;
498 // Converts EISA identification to string.
504 ((AcpiEx->HID >> 10) & 0x1f) + 'A' - 1,
505 ((AcpiEx->HID >> 5) & 0x1f) + 'A' - 1,
506 ((AcpiEx->HID >> 0) & 0x1f) + 'A' - 1,
507 (AcpiEx->HID >> 16) & 0xFFFF
513 ((AcpiEx->CID >> 10) & 0x1f) + 'A' - 1,
514 ((AcpiEx->CID >> 5) & 0x1f) + 'A' - 1,
515 ((AcpiEx->CID >> 0) & 0x1f) + 'A' - 1,
516 (AcpiEx->CID >> 16) & 0xFFFF
519 if ((*HIDStr == '\0') && (*CIDStr == '\0') && (AcpiEx->UID == 0)) {
523 UefiDevicePathLibCatPrint (
531 if (AllowShortcuts) {
535 if (AcpiEx->HID == 0) {
536 UefiDevicePathLibCatPrint (Str, "AcpiEx(%s,", HIDStr);
538 UefiDevicePathLibCatPrint (Str, "AcpiEx(%s,", HIDText);
541 if (AcpiEx->UID == 0) {
542 UefiDevicePathLibCatPrint (Str, "%s,", UIDStr);
544 UefiDevicePathLibCatPrint (Str, "0x%x,", AcpiEx->UID);
547 if (AcpiEx->CID == 0) {
548 UefiDevicePathLibCatPrint (Str, "%s)", CIDStr);
550 UefiDevicePathLibCatPrint (Str, "%s)", CIDText);
553 UefiDevicePathLibCatPrint (
555 "AcpiEx(%s,%s,0x%x,%s,%s,%s)",
568 Converts a ACPI address device path structure to its string representative.
570 @param Str The string representative of input device.
571 @param DevPath The input device path structure.
572 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
573 of the display node is used, where applicable. If DisplayOnly
574 is FALSE, then the longer text representation of the display node
576 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
577 representation for a device node can be used, where applicable.
581 DevPathToTextAcpiAdr (
582 IN OUT POOL_PRINT *Str,
584 IN BOOLEAN DisplayOnly,
585 IN BOOLEAN AllowShortcuts
588 ACPI_ADR_DEVICE_PATH *AcpiAdr;
592 UINT16 AdditionalAdrCount;
595 Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);
596 AdditionalAdrCount = (UINT16) ((Length - 8) / 4);
598 UefiDevicePathLibCatPrint (Str, "AcpiAdr(0x%x", AcpiAdr->ADR);
599 Addr = &AcpiAdr->ADR + 1;
600 for (Index = 0; Index < AdditionalAdrCount; Index++) {
601 UefiDevicePathLibCatPrint (Str, ",0x%x", Addr[Index]);
603 UefiDevicePathLibCatPrint (Str, ")");
607 Converts a ATAPI device path structure to its string representative.
609 @param Str The string representative of input device.
610 @param DevPath The input device path structure.
611 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
612 of the display node is used, where applicable. If DisplayOnly
613 is FALSE, then the longer text representation of the display node
615 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
616 representation for a device node can be used, where applicable.
621 IN OUT POOL_PRINT *Str,
623 IN BOOLEAN DisplayOnly,
624 IN BOOLEAN AllowShortcuts
627 ATAPI_DEVICE_PATH *Atapi;
632 UefiDevicePathLibCatPrint (Str, "Ata(0x%x)", Atapi->Lun);
634 UefiDevicePathLibCatPrint (
637 (Atapi->PrimarySecondary == 1) ? "Secondary" : "Primary",
638 (Atapi->SlaveMaster == 1) ? "Slave" : "Master",
645 Converts a SCSI device path structure to its string representative.
647 @param Str The string representative of input device.
648 @param DevPath The input device path structure.
649 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
650 of the display node is used, where applicable. If DisplayOnly
651 is FALSE, then the longer text representation of the display node
653 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
654 representation for a device node can be used, where applicable.
659 IN OUT POOL_PRINT *Str,
661 IN BOOLEAN DisplayOnly,
662 IN BOOLEAN AllowShortcuts
665 SCSI_DEVICE_PATH *Scsi;
668 UefiDevicePathLibCatPrint (Str, "Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun);
672 Converts a Fibre device path structure to its string representative.
674 @param Str The string representative of input device.
675 @param DevPath The input device path structure.
676 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
677 of the display node is used, where applicable. If DisplayOnly
678 is FALSE, then the longer text representation of the display node
680 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
681 representation for a device node can be used, where applicable.
686 IN OUT POOL_PRINT *Str,
688 IN BOOLEAN DisplayOnly,
689 IN BOOLEAN AllowShortcuts
692 FIBRECHANNEL_DEVICE_PATH *Fibre;
695 UefiDevicePathLibCatPrint (Str, "Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);
699 Converts a FibreEx device path structure to its string representative.
701 @param Str The string representative of input device.
702 @param DevPath The input device path structure.
703 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
704 of the display node is used, where applicable. If DisplayOnly
705 is FALSE, then the longer text representation of the display node
707 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
708 representation for a device node can be used, where applicable.
712 DevPathToTextFibreEx (
713 IN OUT POOL_PRINT *Str,
715 IN BOOLEAN DisplayOnly,
716 IN BOOLEAN AllowShortcuts
719 FIBRECHANNELEX_DEVICE_PATH *FibreEx;
723 UefiDevicePathLibCatPrint (Str, "FibreEx(0x");
724 for (Index = 0; Index < sizeof (FibreEx->WWN) / sizeof (FibreEx->WWN[0]); Index++) {
725 UefiDevicePathLibCatPrint (Str, "%02x", FibreEx->WWN[Index]);
727 UefiDevicePathLibCatPrint (Str, ",0x");
728 for (Index = 0; Index < sizeof (FibreEx->Lun) / sizeof (FibreEx->Lun[0]); Index++) {
729 UefiDevicePathLibCatPrint (Str, "%02x", FibreEx->Lun[Index]);
731 UefiDevicePathLibCatPrint (Str, ")");
735 Converts a Sas Ex device path structure to its string representative.
737 @param Str The string representative of input device.
738 @param DevPath The input device path structure.
739 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
740 of the display node is used, where applicable. If DisplayOnly
741 is FALSE, then the longer text representation of the display node
743 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
744 representation for a device node can be used, where applicable.
749 IN OUT POOL_PRINT *Str,
751 IN BOOLEAN DisplayOnly,
752 IN BOOLEAN AllowShortcuts
755 SASEX_DEVICE_PATH *SasEx;
759 UefiDevicePathLibCatPrint (Str, "SasEx(0x");
761 for (Index = 0; Index < sizeof (SasEx->SasAddress) / sizeof (SasEx->SasAddress[0]); Index++) {
762 UefiDevicePathLibCatPrint (Str, "%02x", SasEx->SasAddress[Index]);
764 UefiDevicePathLibCatPrint (Str, ",0x");
765 for (Index = 0; Index < sizeof (SasEx->Lun) / sizeof (SasEx->Lun[0]); Index++) {
766 UefiDevicePathLibCatPrint (Str, "%02x", SasEx->Lun[Index]);
768 UefiDevicePathLibCatPrint (Str, ",0x%x,", SasEx->RelativeTargetPort);
770 if (((SasEx->DeviceTopology & 0x0f) == 0) && ((SasEx->DeviceTopology & BIT7) == 0)) {
771 UefiDevicePathLibCatPrint (Str, "NoTopology,0,0,0");
772 } else if (((SasEx->DeviceTopology & 0x0f) <= 2) && ((SasEx->DeviceTopology & BIT7) == 0)) {
773 UefiDevicePathLibCatPrint (
776 ((SasEx->DeviceTopology & BIT4) != 0) ? "SATA" : "SAS",
777 ((SasEx->DeviceTopology & BIT5) != 0) ? "External" : "Internal",
778 ((SasEx->DeviceTopology & BIT6) != 0) ? "Expanded" : "Direct"
780 if ((SasEx->DeviceTopology & 0x0f) == 1) {
781 UefiDevicePathLibCatPrint (Str, "0");
784 // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256
786 UefiDevicePathLibCatPrint (Str, "0x%x", ((SasEx->DeviceTopology >> 8) & 0xff) + 1);
789 UefiDevicePathLibCatPrint (Str, "0x%x,0,0,0", SasEx->DeviceTopology);
792 UefiDevicePathLibCatPrint (Str, ")");
798 Converts a NVM Express Namespace device path structure to its string representative.
800 @param Str The string representative of input device.
801 @param DevPath The input device path structure.
802 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
803 of the display node is used, where applicable. If DisplayOnly
804 is FALSE, then the longer text representation of the display node
806 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
807 representation for a device node can be used, where applicable.
812 IN OUT POOL_PRINT *Str,
814 IN BOOLEAN DisplayOnly,
815 IN BOOLEAN AllowShortcuts
818 NVME_NAMESPACE_DEVICE_PATH *Nvme;
822 Uuid = (UINT8 *) &Nvme->NamespaceUuid;
823 UefiDevicePathLibCatPrint (
825 "NVMe(0x%x,%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x)",
827 Uuid[7], Uuid[6], Uuid[5], Uuid[4],
828 Uuid[3], Uuid[2], Uuid[1], Uuid[0]
833 Converts a UFS device path structure to its string representative.
835 @param Str The string representative of input device.
836 @param DevPath The input device path structure.
837 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
838 of the display node is used, where applicable. If DisplayOnly
839 is FALSE, then the longer text representation of the display node
841 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
842 representation for a device node can be used, where applicable.
847 IN OUT POOL_PRINT *Str,
849 IN BOOLEAN DisplayOnly,
850 IN BOOLEAN AllowShortcuts
853 UFS_DEVICE_PATH *Ufs;
856 UefiDevicePathLibCatPrint (Str, "UFS(0x%x,0x%x)", Ufs->Pun, Ufs->Lun);
860 Converts a SD (Secure Digital) device path structure to its string representative.
862 @param Str The string representative of input device.
863 @param DevPath The input device path structure.
864 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
865 of the display node is used, where applicable. If DisplayOnly
866 is FALSE, then the longer text representation of the display node
868 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
869 representation for a device node can be used, where applicable.
874 IN OUT POOL_PRINT *Str,
876 IN BOOLEAN DisplayOnly,
877 IN BOOLEAN AllowShortcuts
883 UefiDevicePathLibCatPrint (
891 Converts a EMMC (Embedded MMC) device path structure to its string representative.
893 @param Str The string representative of input device.
894 @param DevPath The input device path structure.
895 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
896 of the display node is used, where applicable. If DisplayOnly
897 is FALSE, then the longer text representation of the display node
899 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
900 representation for a device node can be used, where applicable.
905 IN OUT POOL_PRINT *Str,
907 IN BOOLEAN DisplayOnly,
908 IN BOOLEAN AllowShortcuts
911 EMMC_DEVICE_PATH *Emmc;
914 UefiDevicePathLibCatPrint (
922 Converts a 1394 device path structure to its string representative.
924 @param Str The string representative of input device.
925 @param DevPath The input device path structure.
926 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
927 of the display node is used, where applicable. If DisplayOnly
928 is FALSE, then the longer text representation of the display node
930 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
931 representation for a device node can be used, where applicable.
936 IN OUT POOL_PRINT *Str,
938 IN BOOLEAN DisplayOnly,
939 IN BOOLEAN AllowShortcuts
942 F1394_DEVICE_PATH *F1394DevPath;
944 F1394DevPath = DevPath;
946 // Guid has format of IEEE-EUI64
948 UefiDevicePathLibCatPrint (Str, "I1394(%016lx)", F1394DevPath->Guid);
952 Converts a USB device path structure to its string representative.
954 @param Str The string representative of input device.
955 @param DevPath The input device path structure.
956 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
957 of the display node is used, where applicable. If DisplayOnly
958 is FALSE, then the longer text representation of the display node
960 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
961 representation for a device node can be used, where applicable.
966 IN OUT POOL_PRINT *Str,
968 IN BOOLEAN DisplayOnly,
969 IN BOOLEAN AllowShortcuts
972 USB_DEVICE_PATH *Usb;
975 UefiDevicePathLibCatPrint (Str, "USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);
979 Converts a USB WWID device path structure to its string representative.
981 @param Str The string representative of input device.
982 @param DevPath The input device path structure.
983 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
984 of the display node is used, where applicable. If DisplayOnly
985 is FALSE, then the longer text representation of the display node
987 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
988 representation for a device node can be used, where applicable.
992 DevPathToTextUsbWWID (
993 IN OUT POOL_PRINT *Str,
995 IN BOOLEAN DisplayOnly,
996 IN BOOLEAN AllowShortcuts
999 USB_WWID_DEVICE_PATH *UsbWWId;
1000 CHAR16 *SerialNumberStr;
1006 SerialNumberStr = (CHAR16 *) (&UsbWWId + 1);
1007 Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));
1008 if (SerialNumberStr [Length - 1] != 0) {
1010 // In case no NULL terminator in SerialNumber, create a new one with NULL terminator
1012 NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);
1013 ASSERT (NewStr != NULL);
1014 NewStr [Length] = 0;
1015 SerialNumberStr = NewStr;
1018 UefiDevicePathLibCatPrint (
1020 "UsbWwid(0x%x,0x%x,0x%x,\"%S\")",
1023 UsbWWId->InterfaceNumber,
1029 Converts a Logic Unit device path structure to its string representative.
1031 @param Str The string representative of input device.
1032 @param DevPath The input device path structure.
1033 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1034 of the display node is used, where applicable. If DisplayOnly
1035 is FALSE, then the longer text representation of the display node
1037 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1038 representation for a device node can be used, where applicable.
1042 DevPathToTextLogicalUnit (
1043 IN OUT POOL_PRINT *Str,
1045 IN BOOLEAN DisplayOnly,
1046 IN BOOLEAN AllowShortcuts
1049 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
1051 LogicalUnit = DevPath;
1052 UefiDevicePathLibCatPrint (Str, "Unit(0x%x)", LogicalUnit->Lun);
1056 Converts a USB class device path structure to its string representative.
1058 @param Str The string representative of input device.
1059 @param DevPath The input device path structure.
1060 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1061 of the display node is used, where applicable. If DisplayOnly
1062 is FALSE, then the longer text representation of the display node
1064 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1065 representation for a device node can be used, where applicable.
1069 DevPathToTextUsbClass (
1070 IN OUT POOL_PRINT *Str,
1072 IN BOOLEAN DisplayOnly,
1073 IN BOOLEAN AllowShortcuts
1076 USB_CLASS_DEVICE_PATH *UsbClass;
1077 BOOLEAN IsKnownSubClass;
1082 IsKnownSubClass = TRUE;
1083 switch (UsbClass->DeviceClass) {
1084 case USB_CLASS_AUDIO:
1085 UefiDevicePathLibCatPrint (Str, "UsbAudio");
1088 case USB_CLASS_CDCCONTROL:
1089 UefiDevicePathLibCatPrint (Str, "UsbCDCControl");
1093 UefiDevicePathLibCatPrint (Str, "UsbHID");
1096 case USB_CLASS_IMAGE:
1097 UefiDevicePathLibCatPrint (Str, "UsbImage");
1100 case USB_CLASS_PRINTER:
1101 UefiDevicePathLibCatPrint (Str, "UsbPrinter");
1104 case USB_CLASS_MASS_STORAGE:
1105 UefiDevicePathLibCatPrint (Str, "UsbMassStorage");
1109 UefiDevicePathLibCatPrint (Str, "UsbHub");
1112 case USB_CLASS_CDCDATA:
1113 UefiDevicePathLibCatPrint (Str, "UsbCDCData");
1116 case USB_CLASS_SMART_CARD:
1117 UefiDevicePathLibCatPrint (Str, "UsbSmartCard");
1120 case USB_CLASS_VIDEO:
1121 UefiDevicePathLibCatPrint (Str, "UsbVideo");
1124 case USB_CLASS_DIAGNOSTIC:
1125 UefiDevicePathLibCatPrint (Str, "UsbDiagnostic");
1128 case USB_CLASS_WIRELESS:
1129 UefiDevicePathLibCatPrint (Str, "UsbWireless");
1133 IsKnownSubClass = FALSE;
1137 if (IsKnownSubClass) {
1138 UefiDevicePathLibCatPrint (
1140 "(0x%x,0x%x,0x%x,0x%x)",
1142 UsbClass->ProductId,
1143 UsbClass->DeviceSubClass,
1144 UsbClass->DeviceProtocol
1149 if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {
1150 if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {
1151 UefiDevicePathLibCatPrint (
1153 "UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",
1155 UsbClass->ProductId,
1156 UsbClass->DeviceProtocol
1159 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {
1160 UefiDevicePathLibCatPrint (
1162 "UsbIrdaBridge(0x%x,0x%x,0x%x)",
1164 UsbClass->ProductId,
1165 UsbClass->DeviceProtocol
1168 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {
1169 UefiDevicePathLibCatPrint (
1171 "UsbTestAndMeasurement(0x%x,0x%x,0x%x)",
1173 UsbClass->ProductId,
1174 UsbClass->DeviceProtocol
1180 UefiDevicePathLibCatPrint (
1182 "UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",
1184 UsbClass->ProductId,
1185 UsbClass->DeviceClass,
1186 UsbClass->DeviceSubClass,
1187 UsbClass->DeviceProtocol
1192 Converts a SATA device path structure to its string representative.
1194 @param Str The string representative of input device.
1195 @param DevPath The input device path structure.
1196 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1197 of the display node is used, where applicable. If DisplayOnly
1198 is FALSE, then the longer text representation of the display node
1200 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1201 representation for a device node can be used, where applicable.
1206 IN OUT POOL_PRINT *Str,
1208 IN BOOLEAN DisplayOnly,
1209 IN BOOLEAN AllowShortcuts
1212 SATA_DEVICE_PATH *Sata;
1215 UefiDevicePathLibCatPrint (
1217 "Sata(0x%x,0x%x,0x%x)",
1218 Sata->HBAPortNumber,
1219 Sata->PortMultiplierPortNumber,
1225 Converts a I20 device path structure to its string representative.
1227 @param Str The string representative of input device.
1228 @param DevPath The input device path structure.
1229 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1230 of the display node is used, where applicable. If DisplayOnly
1231 is FALSE, then the longer text representation of the display node
1233 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1234 representation for a device node can be used, where applicable.
1239 IN OUT POOL_PRINT *Str,
1241 IN BOOLEAN DisplayOnly,
1242 IN BOOLEAN AllowShortcuts
1245 I2O_DEVICE_PATH *I2ODevPath;
1247 I2ODevPath = DevPath;
1248 UefiDevicePathLibCatPrint (Str, "I2O(0x%x)", I2ODevPath->Tid);
1252 Converts a MAC address device path structure to its string representative.
1254 @param Str The string representative of input device.
1255 @param DevPath The input device path structure.
1256 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1257 of the display node is used, where applicable. If DisplayOnly
1258 is FALSE, then the longer text representation of the display node
1260 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1261 representation for a device node can be used, where applicable.
1265 DevPathToTextMacAddr (
1266 IN OUT POOL_PRINT *Str,
1268 IN BOOLEAN DisplayOnly,
1269 IN BOOLEAN AllowShortcuts
1272 MAC_ADDR_DEVICE_PATH *MacDevPath;
1273 UINTN HwAddressSize;
1276 MacDevPath = DevPath;
1278 HwAddressSize = sizeof (EFI_MAC_ADDRESS);
1279 if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {
1283 UefiDevicePathLibCatPrint (Str, "MAC(");
1285 for (Index = 0; Index < HwAddressSize; Index++) {
1286 UefiDevicePathLibCatPrint (Str, "%02x", MacDevPath->MacAddress.Addr[Index]);
1289 UefiDevicePathLibCatPrint (Str, ",0x%x)", MacDevPath->IfType);
1293 Converts network protocol string to its text representation.
1295 @param Str The string representative of input device.
1296 @param Protocol The network protocol ID.
1300 CatNetworkProtocol (
1301 IN OUT POOL_PRINT *Str,
1305 if (Protocol == RFC_1700_TCP_PROTOCOL) {
1306 UefiDevicePathLibCatPrint (Str, "TCP");
1307 } else if (Protocol == RFC_1700_UDP_PROTOCOL) {
1308 UefiDevicePathLibCatPrint (Str, "UDP");
1310 UefiDevicePathLibCatPrint (Str, "0x%x", Protocol);
1315 Converts IP v4 address to its text representation.
1317 @param Str The string representative of input device.
1318 @param Address The IP v4 address.
1322 IN OUT POOL_PRINT *Str,
1323 IN EFI_IPv4_ADDRESS *Address
1326 UefiDevicePathLibCatPrint (Str, "%d.%d.%d.%d", Address->Addr[0], Address->Addr[1], Address->Addr[2], Address->Addr[3]);
1330 Converts IP v6 address to its text representation.
1332 @param Str The string representative of input device.
1333 @param Address The IP v6 address.
1337 IN OUT POOL_PRINT *Str,
1338 IN EFI_IPv6_ADDRESS *Address
1341 UefiDevicePathLibCatPrint (
1342 Str, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
1343 Address->Addr[0], Address->Addr[1],
1344 Address->Addr[2], Address->Addr[3],
1345 Address->Addr[4], Address->Addr[5],
1346 Address->Addr[6], Address->Addr[7],
1347 Address->Addr[8], Address->Addr[9],
1348 Address->Addr[10], Address->Addr[11],
1349 Address->Addr[12], Address->Addr[13],
1350 Address->Addr[14], Address->Addr[15]
1355 Converts a IPv4 device path structure to its string representative.
1357 @param Str The string representative of input device.
1358 @param DevPath The input device path structure.
1359 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1360 of the display node is used, where applicable. If DisplayOnly
1361 is FALSE, then the longer text representation of the display node
1363 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1364 representation for a device node can be used, where applicable.
1369 IN OUT POOL_PRINT *Str,
1371 IN BOOLEAN DisplayOnly,
1372 IN BOOLEAN AllowShortcuts
1375 IPv4_DEVICE_PATH *IPDevPath;
1377 IPDevPath = DevPath;
1378 UefiDevicePathLibCatPrint (Str, "IPv4(");
1379 CatIPv4Address (Str, &IPDevPath->RemoteIpAddress);
1382 UefiDevicePathLibCatPrint (Str, ")");
1386 UefiDevicePathLibCatPrint (Str, ",");
1387 CatNetworkProtocol (Str, IPDevPath->Protocol);
1389 UefiDevicePathLibCatPrint (Str, ",%s,", IPDevPath->StaticIpAddress ? "Static" : "DHCP");
1390 CatIPv4Address (Str, &IPDevPath->LocalIpAddress);
1391 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv4_DEVICE_PATH)) {
1392 UefiDevicePathLibCatPrint (Str, ",");
1393 CatIPv4Address (Str, &IPDevPath->GatewayIpAddress);
1394 UefiDevicePathLibCatPrint (Str, ",");
1395 CatIPv4Address (Str, &IPDevPath->SubnetMask);
1397 UefiDevicePathLibCatPrint (Str, ")");
1401 Converts a IPv6 device path structure to its string representative.
1403 @param Str The string representative of input device.
1404 @param DevPath The input device path structure.
1405 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1406 of the display node is used, where applicable. If DisplayOnly
1407 is FALSE, then the longer text representation of the display node
1409 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1410 representation for a device node can be used, where applicable.
1415 IN OUT POOL_PRINT *Str,
1417 IN BOOLEAN DisplayOnly,
1418 IN BOOLEAN AllowShortcuts
1421 IPv6_DEVICE_PATH *IPDevPath;
1423 IPDevPath = DevPath;
1424 UefiDevicePathLibCatPrint (Str, "IPv6(");
1425 CatIPv6Address (Str, &IPDevPath->RemoteIpAddress);
1427 UefiDevicePathLibCatPrint (Str, ")");
1431 UefiDevicePathLibCatPrint (Str, ",");
1432 CatNetworkProtocol (Str, IPDevPath->Protocol);
1434 switch (IPDevPath->IpAddressOrigin) {
1436 UefiDevicePathLibCatPrint (Str, ",Static,");
1439 UefiDevicePathLibCatPrint (Str, ",StatelessAutoConfigure,");
1442 UefiDevicePathLibCatPrint (Str, ",StatefulAutoConfigure,");
1446 CatIPv6Address (Str, &IPDevPath->LocalIpAddress);
1448 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv6_DEVICE_PATH)) {
1449 UefiDevicePathLibCatPrint (Str, ",0x%x,", IPDevPath->PrefixLength);
1450 CatIPv6Address (Str, &IPDevPath->GatewayIpAddress);
1452 UefiDevicePathLibCatPrint (Str, ")");
1456 Converts an Infini Band device path structure to its string representative.
1458 @param Str The string representative of input device.
1459 @param DevPath The input device path structure.
1460 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1461 of the display node is used, where applicable. If DisplayOnly
1462 is FALSE, then the longer text representation of the display node
1464 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1465 representation for a device node can be used, where applicable.
1469 DevPathToTextInfiniBand (
1470 IN OUT POOL_PRINT *Str,
1472 IN BOOLEAN DisplayOnly,
1473 IN BOOLEAN AllowShortcuts
1476 INFINIBAND_DEVICE_PATH *InfiniBand;
1478 InfiniBand = DevPath;
1479 UefiDevicePathLibCatPrint (
1481 "Infiniband(0x%x,%36s,0x%lx,0x%lx,0x%lx)",
1482 InfiniBand->ResourceFlags,
1483 G(InfiniBand->PortGid),
1484 InfiniBand->ServiceId,
1485 InfiniBand->TargetPortId,
1486 InfiniBand->DeviceId
1491 Converts a UART device path structure to its string representative.
1493 @param Str The string representative of input device.
1494 @param DevPath The input device path structure.
1495 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1496 of the display node is used, where applicable. If DisplayOnly
1497 is FALSE, then the longer text representation of the display node
1499 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1500 representation for a device node can be used, where applicable.
1505 IN OUT POOL_PRINT *Str,
1507 IN BOOLEAN DisplayOnly,
1508 IN BOOLEAN AllowShortcuts
1511 UART_DEVICE_PATH *Uart;
1515 switch (Uart->Parity) {
1545 if (Uart->BaudRate == 0) {
1546 UefiDevicePathLibCatPrint (Str, "Uart(DEFAULT,");
1548 UefiDevicePathLibCatPrint (Str, "Uart(%ld,", Uart->BaudRate);
1551 if (Uart->DataBits == 0) {
1552 UefiDevicePathLibCatPrint (Str, "DEFAULT,");
1554 UefiDevicePathLibCatPrint (Str, "%d,", Uart->DataBits);
1557 UefiDevicePathLibCatPrint (Str, "%c,", Parity);
1559 switch (Uart->StopBits) {
1561 UefiDevicePathLibCatPrint (Str, "D)");
1565 UefiDevicePathLibCatPrint (Str, "1)");
1569 UefiDevicePathLibCatPrint (Str, "1.5)");
1573 UefiDevicePathLibCatPrint (Str, "2)");
1577 UefiDevicePathLibCatPrint (Str, "x)");
1583 Converts an iSCSI device path structure to its string representative.
1585 @param Str The string representative of input device.
1586 @param DevPath The input device path structure.
1587 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1588 of the display node is used, where applicable. If DisplayOnly
1589 is FALSE, then the longer text representation of the display node
1591 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1592 representation for a device node can be used, where applicable.
1596 DevPathToTextiSCSI (
1597 IN OUT POOL_PRINT *Str,
1599 IN BOOLEAN DisplayOnly,
1600 IN BOOLEAN AllowShortcuts
1603 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
1606 ISCSIDevPath = DevPath;
1607 UefiDevicePathLibCatPrint (
1609 "iSCSI(%s,0x%x,0x%lx,",
1610 ISCSIDevPath->TargetName,
1611 ISCSIDevPath->TargetPortalGroupTag,
1615 Options = ISCSIDevPath->LoginOption;
1616 UefiDevicePathLibCatPrint (Str, "%s,", (((Options >> 1) & 0x0001) != 0) ? "CRC32C" : "None");
1617 UefiDevicePathLibCatPrint (Str, "%s,", (((Options >> 3) & 0x0001) != 0) ? "CRC32C" : "None");
1618 if (((Options >> 11) & 0x0001) != 0) {
1619 UefiDevicePathLibCatPrint (Str, "%s,", "None");
1620 } else if (((Options >> 12) & 0x0001) != 0) {
1621 UefiDevicePathLibCatPrint (Str, "%s,", "CHAP_UNI");
1623 UefiDevicePathLibCatPrint (Str, "%s,", "CHAP_BI");
1627 UefiDevicePathLibCatPrint (Str, "%s)", (ISCSIDevPath->NetworkProtocol == 0) ? "TCP" : "reserved");
1631 Converts a VLAN device path structure to its string representative.
1633 @param Str The string representative of input device.
1634 @param DevPath The input device path structure.
1635 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1636 of the display node is used, where applicable. If DisplayOnly
1637 is FALSE, then the longer text representation of the display node
1639 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1640 representation for a device node can be used, where applicable.
1645 IN OUT POOL_PRINT *Str,
1647 IN BOOLEAN DisplayOnly,
1648 IN BOOLEAN AllowShortcuts
1651 VLAN_DEVICE_PATH *Vlan;
1654 UefiDevicePathLibCatPrint (Str, "Vlan(%d)", Vlan->VlanId);
1658 Converts a Bluetooth device path structure to its string representative.
1660 @param Str The string representative of input device.
1661 @param DevPath The input device path structure.
1662 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1663 of the display node is used, where applicable. If DisplayOnly
1664 is FALSE, then the longer text representation of the display node
1666 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1667 representation for a device node can be used, where applicable.
1671 DevPathToTextBluetooth (
1672 IN OUT POOL_PRINT *Str,
1674 IN BOOLEAN DisplayOnly,
1675 IN BOOLEAN AllowShortcuts
1678 BLUETOOTH_DEVICE_PATH *Bluetooth;
1680 Bluetooth = DevPath;
1681 UefiDevicePathLibCatPrint (
1683 "Bluetooth(%02x%02x%02x%02x%02x%02x)",
1684 Bluetooth->BD_ADDR.Address[5],
1685 Bluetooth->BD_ADDR.Address[4],
1686 Bluetooth->BD_ADDR.Address[3],
1687 Bluetooth->BD_ADDR.Address[2],
1688 Bluetooth->BD_ADDR.Address[1],
1689 Bluetooth->BD_ADDR.Address[0]
1694 Converts a Wi-Fi device path structure to its string representative.
1696 @param Str The string representative of input device.
1697 @param DevPath The input device path structure.
1698 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1699 of the display node is used, where applicable. If DisplayOnly
1700 is FALSE, then the longer text representation of the display node
1702 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1703 representation for a device node can be used, where applicable.
1708 IN OUT POOL_PRINT *Str,
1710 IN BOOLEAN DisplayOnly,
1711 IN BOOLEAN AllowShortcuts
1714 WIFI_DEVICE_PATH *WiFi;
1720 CopyMem (SSId, WiFi->SSId, 32);
1722 UefiDevicePathLibCatPrint (Str, "Wi-Fi(%s)", SSId);
1726 Converts a URI device path structure to its string representative.
1728 @param Str The string representative of input device.
1729 @param DevPath The input device path structure.
1730 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1731 of the display node is used, where applicable. If DisplayOnly
1732 is FALSE, then the longer text representation of the display node
1734 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1735 representation for a device node can be used, where applicable.
1740 IN OUT POOL_PRINT *Str,
1742 IN BOOLEAN DisplayOnly,
1743 IN BOOLEAN AllowShortcuts
1746 URI_DEVICE_PATH *Uri;
1751 // Uri in the device path may not be null terminated.
1754 UriLength = DevicePathNodeLength (Uri) - sizeof (URI_DEVICE_PATH);
1755 UriStr = AllocatePool (UriLength + 1);
1756 ASSERT (UriStr != NULL);
1758 CopyMem (UriStr, Uri->Uri, UriLength);
1759 UriStr[UriLength] = '\0';
1760 UefiDevicePathLibCatPrint (Str, "Uri(%s)", UriStr);
1765 Converts a Hard drive device path structure to its string representative.
1767 @param Str The string representative of input device.
1768 @param DevPath The input device path structure.
1769 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1770 of the display node is used, where applicable. If DisplayOnly
1771 is FALSE, then the longer text representation of the display node
1773 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1774 representation for a device node can be used, where applicable.
1778 DevPathToTextHardDrive (
1779 IN OUT POOL_PRINT *Str,
1781 IN BOOLEAN DisplayOnly,
1782 IN BOOLEAN AllowShortcuts
1785 HARDDRIVE_DEVICE_PATH *Hd;
1788 switch (Hd->SignatureType) {
1789 case SIGNATURE_TYPE_MBR:
1790 UefiDevicePathLibCatPrint (
1793 Hd->PartitionNumber,
1795 // *((UINT32 *) (&(Hd->Signature[0])))
1796 le32dec(&(Hd->Signature[0]))
1800 case SIGNATURE_TYPE_GUID:
1801 UefiDevicePathLibCatPrint (
1804 Hd->PartitionNumber,
1806 G(&(Hd->Signature[0]))
1811 UefiDevicePathLibCatPrint (
1814 Hd->PartitionNumber,
1820 UefiDevicePathLibCatPrint (Str, "0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);
1824 Converts a CDROM device path structure to its string representative.
1826 @param Str The string representative of input device.
1827 @param DevPath The input device path structure.
1828 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1829 of the display node is used, where applicable. If DisplayOnly
1830 is FALSE, then the longer text representation of the display node
1832 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1833 representation for a device node can be used, where applicable.
1837 DevPathToTextCDROM (
1838 IN OUT POOL_PRINT *Str,
1840 IN BOOLEAN DisplayOnly,
1841 IN BOOLEAN AllowShortcuts
1844 CDROM_DEVICE_PATH *Cd;
1848 UefiDevicePathLibCatPrint (Str, "CDROM(0x%x)", Cd->BootEntry);
1852 UefiDevicePathLibCatPrint (Str, "CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);
1856 Converts a File device path structure to its string representative.
1858 @param Str The string representative of input device.
1859 @param DevPath The input device path structure.
1860 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1861 of the display node is used, where applicable. If DisplayOnly
1862 is FALSE, then the longer text representation of the display node
1864 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1865 representation for a device node can be used, where applicable.
1869 DevPathToTextFilePath (
1870 IN OUT POOL_PRINT *Str,
1872 IN BOOLEAN DisplayOnly,
1873 IN BOOLEAN AllowShortcuts
1876 FILEPATH_DEVICE_PATH *Fp;
1880 ucs2_to_utf8(Fp->PathName, &name);
1881 UefiDevicePathLibCatPrint (Str, "File(%s)", name);
1886 Converts a Media protocol device path structure to its string representative.
1888 @param Str The string representative of input device.
1889 @param DevPath The input device path structure.
1890 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1891 of the display node is used, where applicable. If DisplayOnly
1892 is FALSE, then the longer text representation of the display node
1894 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1895 representation for a device node can be used, where applicable.
1899 DevPathToTextMediaProtocol (
1900 IN OUT POOL_PRINT *Str,
1902 IN BOOLEAN DisplayOnly,
1903 IN BOOLEAN AllowShortcuts
1906 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;
1908 MediaProt = DevPath;
1909 UefiDevicePathLibCatPrint (Str, "Media(%36s)", G(&MediaProt->Protocol));
1913 Converts a Firmware Volume device path structure to its string representative.
1915 @param Str The string representative of input device.
1916 @param DevPath The input device path structure.
1917 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1918 of the display node is used, where applicable. If DisplayOnly
1919 is FALSE, then the longer text representation of the display node
1921 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1922 representation for a device node can be used, where applicable.
1927 IN OUT POOL_PRINT *Str,
1929 IN BOOLEAN DisplayOnly,
1930 IN BOOLEAN AllowShortcuts
1933 MEDIA_FW_VOL_DEVICE_PATH *Fv;
1936 UefiDevicePathLibCatPrint (Str, "Fv(%36s)", G(&Fv->FvName));
1940 Converts a Firmware Volume File device path structure to its string representative.
1942 @param Str The string representative of input device.
1943 @param DevPath The input device path structure.
1944 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1945 of the display node is used, where applicable. If DisplayOnly
1946 is FALSE, then the longer text representation of the display node
1948 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1949 representation for a device node can be used, where applicable.
1953 DevPathToTextFvFile (
1954 IN OUT POOL_PRINT *Str,
1956 IN BOOLEAN DisplayOnly,
1957 IN BOOLEAN AllowShortcuts
1960 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;
1963 UefiDevicePathLibCatPrint (Str, "FvFile(%36s)", G(&FvFile->FvFileName));
1967 Converts a Relative Offset device path structure to its string representative.
1969 @param Str The string representative of input device.
1970 @param DevPath The input device path structure.
1971 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1972 of the display node is used, where applicable. If DisplayOnly
1973 is FALSE, then the longer text representation of the display node
1975 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1976 representation for a device node can be used, where applicable.
1980 DevPathRelativeOffsetRange (
1981 IN OUT POOL_PRINT *Str,
1983 IN BOOLEAN DisplayOnly,
1984 IN BOOLEAN AllowShortcuts
1987 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;
1990 UefiDevicePathLibCatPrint (
1992 "Offset(0x%lx,0x%lx)",
1993 Offset->StartingOffset,
1994 Offset->EndingOffset
1999 Converts a Ram Disk device path structure to its string representative.
2001 @param Str The string representative of input device.
2002 @param DevPath The input device path structure.
2003 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2004 of the display node is used, where applicable. If DisplayOnly
2005 is FALSE, then the longer text representation of the display node
2007 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2008 representation for a device node can be used, where applicable.
2012 DevPathToTextRamDisk (
2013 IN OUT POOL_PRINT *Str,
2015 IN BOOLEAN DisplayOnly,
2016 IN BOOLEAN AllowShortcuts
2019 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
2023 if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid)) {
2024 UefiDevicePathLibCatPrint (
2026 "VirtualDisk(0x%lx,0x%lx,%d)",
2027 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2028 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2031 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid)) {
2032 UefiDevicePathLibCatPrint (
2034 "VirtualCD(0x%lx,0x%lx,%d)",
2035 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2036 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2039 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid)) {
2040 UefiDevicePathLibCatPrint (
2042 "PersistentVirtualDisk(0x%lx,0x%lx,%d)",
2043 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2044 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2047 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid)) {
2048 UefiDevicePathLibCatPrint (
2050 "PersistentVirtualCD(0x%lx,0x%lx,%d)",
2051 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2052 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2056 UefiDevicePathLibCatPrint (
2058 "RamDisk(0x%lx,0x%lx,%d,%36s)",
2059 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2060 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2062 G(&RamDisk->TypeGuid)
2068 Converts a BIOS Boot Specification device path structure to its string representative.
2070 @param Str The string representative of input device.
2071 @param DevPath The input device path structure.
2072 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2073 of the display node is used, where applicable. If DisplayOnly
2074 is FALSE, then the longer text representation of the display node
2076 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2077 representation for a device node can be used, where applicable.
2082 IN OUT POOL_PRINT *Str,
2084 IN BOOLEAN DisplayOnly,
2085 IN BOOLEAN AllowShortcuts
2088 BBS_BBS_DEVICE_PATH *Bbs;
2092 switch (Bbs->DeviceType) {
2093 case BBS_TYPE_FLOPPY:
2097 case BBS_TYPE_HARDDRIVE:
2101 case BBS_TYPE_CDROM:
2105 case BBS_TYPE_PCMCIA:
2113 case BBS_TYPE_EMBEDDED_NETWORK:
2123 UefiDevicePathLibCatPrint (Str, "BBS(%s,%s", Type, Bbs->String);
2125 UefiDevicePathLibCatPrint (Str, "BBS(0x%x,%s", Bbs->DeviceType, Bbs->String);
2129 UefiDevicePathLibCatPrint (Str, ")");
2133 UefiDevicePathLibCatPrint (Str, ",0x%x)", Bbs->StatusFlag);
2137 Converts an End-of-Device-Path structure to its string representative.
2139 @param Str The string representative of input device.
2140 @param DevPath The input device path structure.
2141 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2142 of the display node is used, where applicable. If DisplayOnly
2143 is FALSE, then the longer text representation of the display node
2145 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2146 representation for a device node can be used, where applicable.
2150 DevPathToTextEndInstance (
2151 IN OUT POOL_PRINT *Str,
2153 IN BOOLEAN DisplayOnly,
2154 IN BOOLEAN AllowShortcuts
2157 UefiDevicePathLibCatPrint (Str, ",");
2160 GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_GENERIC_TABLE mUefiDevicePathLibToTextTableGeneric[] = {
2161 {HARDWARE_DEVICE_PATH, "HardwarePath" },
2162 {ACPI_DEVICE_PATH, "AcpiPath" },
2163 {MESSAGING_DEVICE_PATH, "Msg" },
2164 {MEDIA_DEVICE_PATH, "MediaPath" },
2165 {BBS_DEVICE_PATH, "BbsPath" },
2170 Converts an unknown device path structure to its string representative.
2172 @param Str The string representative of input device.
2173 @param DevPath The input device path structure.
2174 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2175 of the display node is used, where applicable. If DisplayOnly
2176 is FALSE, then the longer text representation of the display node
2178 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2179 representation for a device node can be used, where applicable.
2183 DevPathToTextNodeGeneric (
2184 IN OUT POOL_PRINT *Str,
2186 IN BOOLEAN DisplayOnly,
2187 IN BOOLEAN AllowShortcuts
2190 EFI_DEVICE_PATH_PROTOCOL *Node;
2195 for (Index = 0; mUefiDevicePathLibToTextTableGeneric[Index].Text != NULL; Index++) {
2196 if (DevicePathType (Node) == mUefiDevicePathLibToTextTableGeneric[Index].Type) {
2201 if (mUefiDevicePathLibToTextTableGeneric[Index].Text == NULL) {
2203 // It's a node whose type cannot be recognized
2205 UefiDevicePathLibCatPrint (Str, "Path(%d,%d", DevicePathType (Node), DevicePathSubType (Node));
2208 // It's a node whose type can be recognized
2210 UefiDevicePathLibCatPrint (Str, "%s(%d", mUefiDevicePathLibToTextTableGeneric[Index].Text, DevicePathSubType (Node));
2213 Index = sizeof (EFI_DEVICE_PATH_PROTOCOL);
2214 if (Index < DevicePathNodeLength (Node)) {
2215 UefiDevicePathLibCatPrint (Str, ",");
2216 for (; Index < DevicePathNodeLength (Node); Index++) {
2217 UefiDevicePathLibCatPrint (Str, "%02x", ((UINT8 *) Node)[Index]);
2221 UefiDevicePathLibCatPrint (Str, ")");
2224 static const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = {
2225 {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci },
2226 {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard },
2227 {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap },
2228 {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor },
2229 {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController },
2230 {HARDWARE_DEVICE_PATH, HW_BMC_DP, DevPathToTextBmc },
2231 {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi },
2232 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx },
2233 {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr },
2234 {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi },
2235 {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi },
2236 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre },
2237 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx },
2238 {MESSAGING_DEVICE_PATH, MSG_SASEX_DP, DevPathToTextSasEx },
2239 {MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP, DevPathToTextNVMe },
2240 {MESSAGING_DEVICE_PATH, MSG_UFS_DP, DevPathToTextUfs },
2241 {MESSAGING_DEVICE_PATH, MSG_SD_DP, DevPathToTextSd },
2242 {MESSAGING_DEVICE_PATH, MSG_EMMC_DP, DevPathToTextEmmc },
2243 {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394 },
2244 {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb },
2245 {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID },
2246 {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit },
2247 {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass },
2248 {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata },
2249 {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O },
2250 {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr },
2251 {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4 },
2252 {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6 },
2253 {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand },
2254 {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart },
2255 {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor },
2256 {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI },
2257 {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan },
2258 {MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextUri },
2259 {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextBluetooth },
2260 {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextWiFi },
2261 {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive },
2262 {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM },
2263 {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor },
2264 {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol },
2265 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath },
2266 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv },
2267 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile },
2268 {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange },
2269 {MEDIA_DEVICE_PATH, MEDIA_RAM_DISK_DP, DevPathToTextRamDisk },
2270 {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS },
2271 {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance },
2276 Converts a device node to its string representation.
2278 @param DeviceNode A Pointer to the device node to be converted.
2279 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2280 of the display node is used, where applicable. If DisplayOnly
2281 is FALSE, then the longer text representation of the display node
2283 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2284 representation for a device node can be used, where applicable.
2286 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode
2287 is NULL or there was insufficient memory.
2292 UefiDevicePathLibConvertDeviceNodeToText (
2293 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
2294 IN BOOLEAN DisplayOnly,
2295 IN BOOLEAN AllowShortcuts
2300 DEVICE_PATH_TO_TEXT ToText;
2301 EFI_DEVICE_PATH_PROTOCOL *Node;
2303 if (DeviceNode == NULL) {
2307 ZeroMem (&Str, sizeof (Str));
2310 // Process the device path node
2311 // If not found, use a generic function
2313 Node = __DECONST(EFI_DEVICE_PATH_PROTOCOL *, DeviceNode);
2314 ToText = DevPathToTextNodeGeneric;
2315 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index++) {
2316 if (DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type &&
2317 DevicePathSubType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].SubType
2319 ToText = mUefiDevicePathLibToTextTable[Index].Function;
2327 ToText (&Str, (VOID *) Node, DisplayOnly, AllowShortcuts);
2329 ASSERT (Str.Str != NULL);
2334 Converts a device path to its text representation.
2336 @param DevicePath A Pointer to the device to be converted.
2337 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2338 of the display node is used, where applicable. If DisplayOnly
2339 is FALSE, then the longer text representation of the display node
2341 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2342 representation for a device node can be used, where applicable.
2344 @return A pointer to the allocated text representation of the device path or
2345 NULL if DeviceNode is NULL or there was insufficient memory.
2350 UefiDevicePathLibConvertDevicePathToText (
2351 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
2352 IN BOOLEAN DisplayOnly,
2353 IN BOOLEAN AllowShortcuts
2357 EFI_DEVICE_PATH_PROTOCOL *Node;
2358 EFI_DEVICE_PATH_PROTOCOL *AlignedNode;
2360 DEVICE_PATH_TO_TEXT ToText;
2362 if (DevicePath == NULL) {
2366 ZeroMem (&Str, sizeof (Str));
2369 // Process each device path node
2371 Node = __DECONST(EFI_DEVICE_PATH_PROTOCOL *, DevicePath);
2372 while (!IsDevicePathEnd (Node)) {
2374 // Find the handler to dump this device path node
2375 // If not found, use a generic function
2377 ToText = DevPathToTextNodeGeneric;
2378 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index += 1) {
2380 if (DevicePathType (Node) == mUefiDevicePathLibToTextTable[Index].Type &&
2381 DevicePathSubType (Node) == mUefiDevicePathLibToTextTable[Index].SubType
2383 ToText = mUefiDevicePathLibToTextTable[Index].Function;
2388 // Put a path separator in if needed
2390 if ((Str.Count != 0) && (ToText != DevPathToTextEndInstance)) {
2391 if (Str.Str[Str.Count] != ',') {
2392 UefiDevicePathLibCatPrint (&Str, "/");
2396 AlignedNode = AllocateCopyPool (DevicePathNodeLength (Node), Node);
2398 // Print this node of the device path
2400 ToText (&Str, AlignedNode, DisplayOnly, AllowShortcuts);
2401 FreePool (AlignedNode);
2404 // Next device path node
2406 Node = NextDevicePathNode (Node);
2409 if (Str.Str == NULL) {
2410 return AllocateZeroPool (sizeof (CHAR16));
2418 efidp_format_device_path(char *buf, size_t len, const_efidp dp, ssize_t max)
2423 str = UefiDevicePathLibConvertDevicePathToText (
2424 __DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp), FALSE, TRUE);
2427 strlcpy(buf, str, len);
2428 retval = strlen(str);
2435 efidp_format_device_path_node(char *buf, size_t len, const_efidp dp)
2440 str = UefiDevicePathLibConvertDeviceNodeToText (
2441 __DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp), FALSE, TRUE);
2444 strlcpy(buf, str, len);
2445 retval = strlen(str);
2452 efidp_size(const_efidp dp)
2455 return GetDevicePathSize(__DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp));
2459 efidp_extract_file_path(const_efidp dp)
2461 const FILEPATH_DEVICE_PATH *fp;
2464 fp = (const void *)dp;
2465 ucs2_to_utf8(fp->PathName, &name);