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
54 * wide strings converted to narrow
55 * Low level printing code redone for narrow strings
56 * Routines made static
57 * %s -> %S in spots (where it is still UCS-2)
59 * %g -> %36s hack to print guid (see above for caveat)
60 * some tidying up of const and deconsting. It's evil, but const
61 * poisoning the whole file was too much.
65 DevicePathToText protocol as defined in the UEFI 2.0 specification.
67 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
68 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
69 SPDX-License-Identifier: BSD-2-Clause-Patent
73 // #include "UefiDevicePathLib.h"
76 Concatenates a formatted unicode string to allocated pool. The caller must
77 free the resulting buffer.
79 @param Str Tracks the allocated pool, size in use, and
80 amount of pool allocated.
81 @param Fmt The format string
82 @param ... Variable arguments based on the format string.
84 @return Allocated buffer with the formatted string printed in it.
85 The caller must free the allocated buffer. The buffer
86 allocation is not packed.
91 UefiDevicePathLibCatPrint (
92 IN OUT POOL_PRINT *Str,
100 VA_START (Args, Fmt);
101 Count = vsnprintf (NULL, 0, Fmt, Args);
104 if ((Str->Count + (Count + 1)) > Str->Capacity) {
105 Str->Capacity = (Str->Count + (Count + 1) * 2);
106 Str->Str = reallocf (
110 ASSERT (Str->Str != NULL);
113 VA_START (Args, Fmt);
114 vsnprintf (Str->Str + Str->Count, Str->Capacity - Str->Count, Fmt, Args);
122 Converts a PCI device path structure to its string representative.
124 @param Str The string representative of input device.
125 @param DevPath The input device path structure.
126 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
127 of the display node is used, where applicable. If DisplayOnly
128 is FALSE, then the longer text representation of the display node
130 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
131 representation for a device node can be used, where applicable.
136 IN OUT POOL_PRINT *Str,
138 IN BOOLEAN DisplayOnly,
139 IN BOOLEAN AllowShortcuts
142 PCI_DEVICE_PATH *Pci;
145 UefiDevicePathLibCatPrint (Str, "Pci(0x%x,0x%x)", Pci->Device, Pci->Function);
149 Converts a PC Card device path structure to its string representative.
151 @param Str The string representative of input device.
152 @param DevPath The input device path structure.
153 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
154 of the display node is used, where applicable. If DisplayOnly
155 is FALSE, then the longer text representation of the display node
157 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
158 representation for a device node can be used, where applicable.
162 DevPathToTextPccard (
163 IN OUT POOL_PRINT *Str,
165 IN BOOLEAN DisplayOnly,
166 IN BOOLEAN AllowShortcuts
169 PCCARD_DEVICE_PATH *Pccard;
172 UefiDevicePathLibCatPrint (Str, "PcCard(0x%x)", Pccard->FunctionNumber);
176 Converts a Memory Map device path structure to its string representative.
178 @param Str The string representative of input device.
179 @param DevPath The input device path structure.
180 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
181 of the display node is used, where applicable. If DisplayOnly
182 is FALSE, then the longer text representation of the display node
184 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
185 representation for a device node can be used, where applicable.
189 DevPathToTextMemMap (
190 IN OUT POOL_PRINT *Str,
192 IN BOOLEAN DisplayOnly,
193 IN BOOLEAN AllowShortcuts
196 MEMMAP_DEVICE_PATH *MemMap;
199 UefiDevicePathLibCatPrint (
201 "MemoryMapped(0x%x,0x%lx,0x%lx)",
203 MemMap->StartingAddress,
204 MemMap->EndingAddress
209 Converts a Vendor device path structure to its string representative.
211 @param Str The string representative of input device.
212 @param DevPath The input device path structure.
213 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
214 of the display node is used, where applicable. If DisplayOnly
215 is FALSE, then the longer text representation of the display node
217 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
218 representation for a device node can be used, where applicable.
222 DevPathToTextVendor (
223 IN OUT POOL_PRINT *Str,
225 IN BOOLEAN DisplayOnly,
226 IN BOOLEAN AllowShortcuts
229 VENDOR_DEVICE_PATH *Vendor;
233 UINT32 FlowControlMap;
236 Vendor = (VENDOR_DEVICE_PATH *)DevPath;
237 switch (DevicePathType (&Vendor->Header)) {
238 case HARDWARE_DEVICE_PATH:
242 case MESSAGING_DEVICE_PATH:
244 if (AllowShortcuts) {
245 if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {
246 UefiDevicePathLibCatPrint (Str, "VenPcAnsi()");
248 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {
249 UefiDevicePathLibCatPrint (Str, "VenVt100()");
251 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {
252 UefiDevicePathLibCatPrint (Str, "VenVt100Plus()");
254 } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {
255 UefiDevicePathLibCatPrint (Str, "VenUtf8()");
257 } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) {
258 FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *)Vendor)->FlowControlMap);
259 switch (FlowControlMap & 0x00000003) {
261 UefiDevicePathLibCatPrint (Str, "UartFlowCtrl(%s)", "None");
265 UefiDevicePathLibCatPrint (Str, "UartFlowCtrl(%s)", "Hardware");
269 UefiDevicePathLibCatPrint (Str, "UartFlowCtrl(%s)", "XonXoff");
277 } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {
278 UefiDevicePathLibCatPrint (
280 "SAS(0x%lx,0x%lx,0x%x,",
281 ((SAS_DEVICE_PATH *)Vendor)->SasAddress,
282 ((SAS_DEVICE_PATH *)Vendor)->Lun,
283 ((SAS_DEVICE_PATH *)Vendor)->RelativeTargetPort
285 Info = (((SAS_DEVICE_PATH *)Vendor)->DeviceTopology);
286 if (((Info & 0x0f) == 0) && ((Info & BIT7) == 0)) {
287 UefiDevicePathLibCatPrint (Str, "NoTopology,0,0,0,");
288 } else if (((Info & 0x0f) <= 2) && ((Info & BIT7) == 0)) {
289 UefiDevicePathLibCatPrint (
292 ((Info & BIT4) != 0) ? "SATA" : "SAS",
293 ((Info & BIT5) != 0) ? "External" : "Internal",
294 ((Info & BIT6) != 0) ? "Expanded" : "Direct"
296 if ((Info & 0x0f) == 1) {
297 UefiDevicePathLibCatPrint (Str, "0,");
300 // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256
302 UefiDevicePathLibCatPrint (Str, "0x%x,", ((Info >> 8) & 0xff) + 1);
305 UefiDevicePathLibCatPrint (Str, "0x%x,0,0,0,", Info);
308 UefiDevicePathLibCatPrint (Str, "0x%x)", ((SAS_DEVICE_PATH *)Vendor)->Reserved);
310 } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {
311 UefiDevicePathLibCatPrint (Str, "DebugPort()");
318 case MEDIA_DEVICE_PATH:
327 DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);
328 UefiDevicePathLibCatPrint (Str, "Ven%s(%36s", Type, G(&Vendor->Guid));
329 if (DataLength != 0) {
330 UefiDevicePathLibCatPrint (Str, ",");
331 for (Index = 0; Index < DataLength; Index++) {
332 UefiDevicePathLibCatPrint (Str, "%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *)Vendor)->VendorDefinedData[Index]);
336 UefiDevicePathLibCatPrint (Str, ")");
340 Converts a Controller device path structure to its string representative.
342 @param Str The string representative of input device.
343 @param DevPath The input device path structure.
344 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
345 of the display node is used, where applicable. If DisplayOnly
346 is FALSE, then the longer text representation of the display node
348 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
349 representation for a device node can be used, where applicable.
353 DevPathToTextController (
354 IN OUT POOL_PRINT *Str,
356 IN BOOLEAN DisplayOnly,
357 IN BOOLEAN AllowShortcuts
360 CONTROLLER_DEVICE_PATH *Controller;
362 Controller = DevPath;
363 UefiDevicePathLibCatPrint (
366 Controller->ControllerNumber
371 Converts a BMC device path structure to its string representative.
373 @param Str The string representative of input device.
374 @param DevPath The input device path structure.
375 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
376 of the display node is used, where applicable. If DisplayOnly
377 is FALSE, then the longer text representation of the display node
379 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
380 representation for a device node can be used, where applicable.
385 IN OUT POOL_PRINT *Str,
387 IN BOOLEAN DisplayOnly,
388 IN BOOLEAN AllowShortcuts
391 BMC_DEVICE_PATH *Bmc;
394 UefiDevicePathLibCatPrint (
398 ReadUnaligned64 ((&Bmc->BaseAddress))
403 Converts a ACPI device path structure to its string representative.
405 @param Str The string representative of input device.
406 @param DevPath The input device path structure.
407 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
408 of the display node is used, where applicable. If DisplayOnly
409 is FALSE, then the longer text representation of the display node
411 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
412 representation for a device node can be used, where applicable.
417 IN OUT POOL_PRINT *Str,
419 IN BOOLEAN DisplayOnly,
420 IN BOOLEAN AllowShortcuts
423 ACPI_HID_DEVICE_PATH *Acpi;
426 if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
427 switch (EISA_ID_TO_NUM (Acpi->HID)) {
429 UefiDevicePathLibCatPrint (Str, "PciRoot(0x%x)", Acpi->UID);
433 UefiDevicePathLibCatPrint (Str, "PcieRoot(0x%x)", Acpi->UID);
437 UefiDevicePathLibCatPrint (Str, "Floppy(0x%x)", Acpi->UID);
441 UefiDevicePathLibCatPrint (Str, "Keyboard(0x%x)", Acpi->UID);
445 UefiDevicePathLibCatPrint (Str, "Serial(0x%x)", Acpi->UID);
449 UefiDevicePathLibCatPrint (Str, "ParallelPort(0x%x)", Acpi->UID);
453 UefiDevicePathLibCatPrint (Str, "Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);
457 UefiDevicePathLibCatPrint (Str, "Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID);
462 Converts a ACPI extended HID device path structure to its string representative.
464 @param Str The string representative of input device.
465 @param DevPath The input device path structure.
466 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
467 of the display node is used, where applicable. If DisplayOnly
468 is FALSE, then the longer text representation of the display node
470 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
471 representation for a device node can be used, where applicable.
475 DevPathToTextAcpiEx (
476 IN OUT POOL_PRINT *Str,
478 IN BOOLEAN DisplayOnly,
479 IN BOOLEAN AllowShortcuts
482 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;
490 HIDStr = (CHAR8 *)(((UINT8 *)AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
491 UIDStr = HIDStr + AsciiStrLen (HIDStr) + 1;
492 CIDStr = UIDStr + AsciiStrLen (UIDStr) + 1;
495 if ((EISA_ID_TO_NUM (AcpiEx->HID) == 0x0A03) ||
496 ((EISA_ID_TO_NUM (AcpiEx->CID) == 0x0A03) && (EISA_ID_TO_NUM (AcpiEx->HID) != 0x0A08)))
498 if (AcpiEx->UID == 0) {
499 UefiDevicePathLibCatPrint (Str, "PciRoot(%s)", UIDStr);
501 UefiDevicePathLibCatPrint (Str, "PciRoot(0x%x)", AcpiEx->UID);
507 if ((EISA_ID_TO_NUM (AcpiEx->HID) == 0x0A08) || (EISA_ID_TO_NUM (AcpiEx->CID) == 0x0A08)) {
508 if (AcpiEx->UID == 0) {
509 UefiDevicePathLibCatPrint (Str, "PcieRoot(%s)", UIDStr);
511 UefiDevicePathLibCatPrint (Str, "PcieRoot(0x%x)", AcpiEx->UID);
519 // Converts EISA identification to string.
525 ((AcpiEx->HID >> 10) & 0x1f) + 'A' - 1,
526 ((AcpiEx->HID >> 5) & 0x1f) + 'A' - 1,
527 ((AcpiEx->HID >> 0) & 0x1f) + 'A' - 1,
528 (AcpiEx->HID >> 16) & 0xFFFF
534 ((AcpiEx->CID >> 10) & 0x1f) + 'A' - 1,
535 ((AcpiEx->CID >> 5) & 0x1f) + 'A' - 1,
536 ((AcpiEx->CID >> 0) & 0x1f) + 'A' - 1,
537 (AcpiEx->CID >> 16) & 0xFFFF
540 if ((*HIDStr == '\0') && (*CIDStr == '\0') && (*UIDStr != '\0')) {
544 if (AcpiEx->CID == 0) {
545 UefiDevicePathLibCatPrint (
552 UefiDevicePathLibCatPrint (
565 if (AcpiEx->HID == 0) {
566 UefiDevicePathLibCatPrint (Str, "AcpiEx(%s,", HIDStr);
568 UefiDevicePathLibCatPrint (Str, "AcpiEx(%s,", HIDText);
571 if (AcpiEx->CID == 0) {
572 UefiDevicePathLibCatPrint (Str, "%s,", CIDStr);
574 UefiDevicePathLibCatPrint (Str, "%s,", CIDText);
577 if (AcpiEx->UID == 0) {
578 UefiDevicePathLibCatPrint (Str, "%s)", UIDStr);
580 UefiDevicePathLibCatPrint (Str, "0x%x)", AcpiEx->UID);
583 UefiDevicePathLibCatPrint (
585 "AcpiEx(%s,%s,0x%x,%s,%s,%s)",
598 Converts a ACPI address device path structure to its string representative.
600 @param Str The string representative of input device.
601 @param DevPath The input device path structure.
602 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
603 of the display node is used, where applicable. If DisplayOnly
604 is FALSE, then the longer text representation of the display node
606 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
607 representation for a device node can be used, where applicable.
611 DevPathToTextAcpiAdr (
612 IN OUT POOL_PRINT *Str,
614 IN BOOLEAN DisplayOnly,
615 IN BOOLEAN AllowShortcuts
618 ACPI_ADR_DEVICE_PATH *AcpiAdr;
622 UINT16 AdditionalAdrCount;
625 Length = (UINT16)DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *)AcpiAdr);
626 AdditionalAdrCount = (UINT16)((Length - 8) / 4);
628 UefiDevicePathLibCatPrint (Str, "AcpiAdr(0x%x", AcpiAdr->ADR);
629 Addr = &AcpiAdr->ADR + 1;
630 for (Index = 0; Index < AdditionalAdrCount; Index++) {
631 UefiDevicePathLibCatPrint (Str, ",0x%x", Addr[Index]);
634 UefiDevicePathLibCatPrint (Str, ")");
638 Converts a ATAPI device path structure to its string representative.
640 @param Str The string representative of input device.
641 @param DevPath The input device path structure.
642 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
643 of the display node is used, where applicable. If DisplayOnly
644 is FALSE, then the longer text representation of the display node
646 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
647 representation for a device node can be used, where applicable.
652 IN OUT POOL_PRINT *Str,
654 IN BOOLEAN DisplayOnly,
655 IN BOOLEAN AllowShortcuts
658 ATAPI_DEVICE_PATH *Atapi;
663 UefiDevicePathLibCatPrint (Str, "Ata(0x%x)", Atapi->Lun);
665 UefiDevicePathLibCatPrint (
668 (Atapi->PrimarySecondary == 1) ? "Secondary" : "Primary",
669 (Atapi->SlaveMaster == 1) ? "Slave" : "Master",
676 Converts a SCSI device path structure to its string representative.
678 @param Str The string representative of input device.
679 @param DevPath The input device path structure.
680 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
681 of the display node is used, where applicable. If DisplayOnly
682 is FALSE, then the longer text representation of the display node
684 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
685 representation for a device node can be used, where applicable.
690 IN OUT POOL_PRINT *Str,
692 IN BOOLEAN DisplayOnly,
693 IN BOOLEAN AllowShortcuts
696 SCSI_DEVICE_PATH *Scsi;
699 UefiDevicePathLibCatPrint (Str, "Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun);
703 Converts a Fibre device path structure to its string representative.
705 @param Str The string representative of input device.
706 @param DevPath The input device path structure.
707 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
708 of the display node is used, where applicable. If DisplayOnly
709 is FALSE, then the longer text representation of the display node
711 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
712 representation for a device node can be used, where applicable.
717 IN OUT POOL_PRINT *Str,
719 IN BOOLEAN DisplayOnly,
720 IN BOOLEAN AllowShortcuts
723 FIBRECHANNEL_DEVICE_PATH *Fibre;
726 UefiDevicePathLibCatPrint (Str, "Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);
730 Converts a FibreEx device path structure to its string representative.
732 @param Str The string representative of input device.
733 @param DevPath The input device path structure.
734 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
735 of the display node is used, where applicable. If DisplayOnly
736 is FALSE, then the longer text representation of the display node
738 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
739 representation for a device node can be used, where applicable.
743 DevPathToTextFibreEx (
744 IN OUT POOL_PRINT *Str,
746 IN BOOLEAN DisplayOnly,
747 IN BOOLEAN AllowShortcuts
750 FIBRECHANNELEX_DEVICE_PATH *FibreEx;
754 UefiDevicePathLibCatPrint (Str, "FibreEx(0x");
755 for (Index = 0; Index < sizeof (FibreEx->WWN) / sizeof (FibreEx->WWN[0]); Index++) {
756 UefiDevicePathLibCatPrint (Str, "%02x", FibreEx->WWN[Index]);
759 UefiDevicePathLibCatPrint (Str, ",0x");
760 for (Index = 0; Index < sizeof (FibreEx->Lun) / sizeof (FibreEx->Lun[0]); Index++) {
761 UefiDevicePathLibCatPrint (Str, "%02x", FibreEx->Lun[Index]);
764 UefiDevicePathLibCatPrint (Str, ")");
768 Converts a Sas Ex device path structure to its string representative.
770 @param Str The string representative of input device.
771 @param DevPath The input device path structure.
772 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
773 of the display node is used, where applicable. If DisplayOnly
774 is FALSE, then the longer text representation of the display node
776 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
777 representation for a device node can be used, where applicable.
782 IN OUT POOL_PRINT *Str,
784 IN BOOLEAN DisplayOnly,
785 IN BOOLEAN AllowShortcuts
788 SASEX_DEVICE_PATH *SasEx;
792 UefiDevicePathLibCatPrint (Str, "SasEx(0x");
794 for (Index = 0; Index < sizeof (SasEx->SasAddress) / sizeof (SasEx->SasAddress[0]); Index++) {
795 UefiDevicePathLibCatPrint (Str, "%02x", SasEx->SasAddress[Index]);
798 UefiDevicePathLibCatPrint (Str, ",0x");
799 for (Index = 0; Index < sizeof (SasEx->Lun) / sizeof (SasEx->Lun[0]); Index++) {
800 UefiDevicePathLibCatPrint (Str, "%02x", SasEx->Lun[Index]);
803 UefiDevicePathLibCatPrint (Str, ",0x%x,", SasEx->RelativeTargetPort);
805 if (((SasEx->DeviceTopology & 0x0f) == 0) && ((SasEx->DeviceTopology & BIT7) == 0)) {
806 UefiDevicePathLibCatPrint (Str, "NoTopology,0,0,0");
807 } else if (((SasEx->DeviceTopology & 0x0f) <= 2) && ((SasEx->DeviceTopology & BIT7) == 0)) {
808 UefiDevicePathLibCatPrint (
811 ((SasEx->DeviceTopology & BIT4) != 0) ? "SATA" : "SAS",
812 ((SasEx->DeviceTopology & BIT5) != 0) ? "External" : "Internal",
813 ((SasEx->DeviceTopology & BIT6) != 0) ? "Expanded" : "Direct"
815 if ((SasEx->DeviceTopology & 0x0f) == 1) {
816 UefiDevicePathLibCatPrint (Str, "0");
819 // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256
821 UefiDevicePathLibCatPrint (Str, "0x%x", ((SasEx->DeviceTopology >> 8) & 0xff) + 1);
824 UefiDevicePathLibCatPrint (Str, "0x%x,0,0,0", SasEx->DeviceTopology);
827 UefiDevicePathLibCatPrint (Str, ")");
832 Converts a NVM Express Namespace 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 NVME_NAMESPACE_DEVICE_PATH *Nvme;
856 Uuid = (UINT8 *)&Nvme->NamespaceUuid;
857 UefiDevicePathLibCatPrint (
859 "NVMe(0x%x,%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x)",
873 Converts a UFS device path structure to its string representative.
875 @param Str The string representative of input device.
876 @param DevPath The input device path structure.
877 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
878 of the display node is used, where applicable. If DisplayOnly
879 is FALSE, then the longer text representation of the display node
881 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
882 representation for a device node can be used, where applicable.
887 IN OUT POOL_PRINT *Str,
889 IN BOOLEAN DisplayOnly,
890 IN BOOLEAN AllowShortcuts
893 UFS_DEVICE_PATH *Ufs;
896 UefiDevicePathLibCatPrint (Str, "UFS(0x%x,0x%x)", Ufs->Pun, Ufs->Lun);
900 Converts a SD (Secure Digital) device path structure to its string representative.
902 @param Str The string representative of input device.
903 @param DevPath The input device path structure.
904 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
905 of the display node is used, where applicable. If DisplayOnly
906 is FALSE, then the longer text representation of the display node
908 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
909 representation for a device node can be used, where applicable.
914 IN OUT POOL_PRINT *Str,
916 IN BOOLEAN DisplayOnly,
917 IN BOOLEAN AllowShortcuts
923 UefiDevicePathLibCatPrint (
931 Converts a EMMC (Embedded MMC) device path structure to its string representative.
933 @param Str The string representative of input device.
934 @param DevPath The input device path structure.
935 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
936 of the display node is used, where applicable. If DisplayOnly
937 is FALSE, then the longer text representation of the display node
939 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
940 representation for a device node can be used, where applicable.
945 IN OUT POOL_PRINT *Str,
947 IN BOOLEAN DisplayOnly,
948 IN BOOLEAN AllowShortcuts
951 EMMC_DEVICE_PATH *Emmc;
954 UefiDevicePathLibCatPrint (
962 Converts a 1394 device path structure to its string representative.
964 @param Str The string representative of input device.
965 @param DevPath The input device path structure.
966 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
967 of the display node is used, where applicable. If DisplayOnly
968 is FALSE, then the longer text representation of the display node
970 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
971 representation for a device node can be used, where applicable.
976 IN OUT POOL_PRINT *Str,
978 IN BOOLEAN DisplayOnly,
979 IN BOOLEAN AllowShortcuts
982 F1394_DEVICE_PATH *F1394DevPath;
984 F1394DevPath = DevPath;
986 // Guid has format of IEEE-EUI64
988 UefiDevicePathLibCatPrint (Str, "I1394(%016lx)", F1394DevPath->Guid);
992 Converts a USB device path structure to its string representative.
994 @param Str The string representative of input device.
995 @param DevPath The input device path structure.
996 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
997 of the display node is used, where applicable. If DisplayOnly
998 is FALSE, then the longer text representation of the display node
1000 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1001 representation for a device node can be used, where applicable.
1006 IN OUT POOL_PRINT *Str,
1008 IN BOOLEAN DisplayOnly,
1009 IN BOOLEAN AllowShortcuts
1012 USB_DEVICE_PATH *Usb;
1015 UefiDevicePathLibCatPrint (Str, "USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);
1019 Converts a USB WWID device path structure to its string representative.
1021 @param Str The string representative of input device.
1022 @param DevPath The input device path structure.
1023 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1024 of the display node is used, where applicable. If DisplayOnly
1025 is FALSE, then the longer text representation of the display node
1027 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1028 representation for a device node can be used, where applicable.
1032 DevPathToTextUsbWWID (
1033 IN OUT POOL_PRINT *Str,
1035 IN BOOLEAN DisplayOnly,
1036 IN BOOLEAN AllowShortcuts
1039 USB_WWID_DEVICE_PATH *UsbWWId;
1040 CHAR16 *SerialNumberStr;
1046 SerialNumberStr = (CHAR16 *)(&UsbWWId + 1);
1047 Length = (UINT16)((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *)UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));
1048 if ((Length >= 1) && (SerialNumberStr[Length - 1] != 0)) {
1050 // In case no NULL terminator in SerialNumber, create a new one with NULL terminator
1052 NewStr = AllocatePool ((Length + 1) * sizeof (CHAR16));
1053 ASSERT (NewStr != NULL);
1054 CopyMem (NewStr, SerialNumberStr, Length * sizeof (CHAR16));
1056 SerialNumberStr = NewStr;
1059 UefiDevicePathLibCatPrint (
1061 "UsbWwid(0x%x,0x%x,0x%x,\"%S\")",
1064 UsbWWId->InterfaceNumber,
1070 Converts a Logic Unit device path structure to its string representative.
1072 @param Str The string representative of input device.
1073 @param DevPath The input device path structure.
1074 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1075 of the display node is used, where applicable. If DisplayOnly
1076 is FALSE, then the longer text representation of the display node
1078 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1079 representation for a device node can be used, where applicable.
1083 DevPathToTextLogicalUnit (
1084 IN OUT POOL_PRINT *Str,
1086 IN BOOLEAN DisplayOnly,
1087 IN BOOLEAN AllowShortcuts
1090 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
1092 LogicalUnit = DevPath;
1093 UefiDevicePathLibCatPrint (Str, "Unit(0x%x)", LogicalUnit->Lun);
1097 Converts a USB class device path structure to its string representative.
1099 @param Str The string representative of input device.
1100 @param DevPath The input device path structure.
1101 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1102 of the display node is used, where applicable. If DisplayOnly
1103 is FALSE, then the longer text representation of the display node
1105 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1106 representation for a device node can be used, where applicable.
1110 DevPathToTextUsbClass (
1111 IN OUT POOL_PRINT *Str,
1113 IN BOOLEAN DisplayOnly,
1114 IN BOOLEAN AllowShortcuts
1117 USB_CLASS_DEVICE_PATH *UsbClass;
1118 BOOLEAN IsKnownSubClass;
1122 IsKnownSubClass = TRUE;
1123 switch (UsbClass->DeviceClass) {
1124 case USB_CLASS_AUDIO:
1125 UefiDevicePathLibCatPrint (Str, "UsbAudio");
1128 case USB_CLASS_CDCCONTROL:
1129 UefiDevicePathLibCatPrint (Str, "UsbCDCControl");
1133 UefiDevicePathLibCatPrint (Str, "UsbHID");
1136 case USB_CLASS_IMAGE:
1137 UefiDevicePathLibCatPrint (Str, "UsbImage");
1140 case USB_CLASS_PRINTER:
1141 UefiDevicePathLibCatPrint (Str, "UsbPrinter");
1144 case USB_CLASS_MASS_STORAGE:
1145 UefiDevicePathLibCatPrint (Str, "UsbMassStorage");
1149 UefiDevicePathLibCatPrint (Str, "UsbHub");
1152 case USB_CLASS_CDCDATA:
1153 UefiDevicePathLibCatPrint (Str, "UsbCDCData");
1156 case USB_CLASS_SMART_CARD:
1157 UefiDevicePathLibCatPrint (Str, "UsbSmartCard");
1160 case USB_CLASS_VIDEO:
1161 UefiDevicePathLibCatPrint (Str, "UsbVideo");
1164 case USB_CLASS_DIAGNOSTIC:
1165 UefiDevicePathLibCatPrint (Str, "UsbDiagnostic");
1168 case USB_CLASS_WIRELESS:
1169 UefiDevicePathLibCatPrint (Str, "UsbWireless");
1173 IsKnownSubClass = FALSE;
1177 if (IsKnownSubClass) {
1178 UefiDevicePathLibCatPrint (
1180 "(0x%x,0x%x,0x%x,0x%x)",
1182 UsbClass->ProductId,
1183 UsbClass->DeviceSubClass,
1184 UsbClass->DeviceProtocol
1189 if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {
1190 if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {
1191 UefiDevicePathLibCatPrint (
1193 "UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",
1195 UsbClass->ProductId,
1196 UsbClass->DeviceProtocol
1199 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {
1200 UefiDevicePathLibCatPrint (
1202 "UsbIrdaBridge(0x%x,0x%x,0x%x)",
1204 UsbClass->ProductId,
1205 UsbClass->DeviceProtocol
1208 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {
1209 UefiDevicePathLibCatPrint (
1211 "UsbTestAndMeasurement(0x%x,0x%x,0x%x)",
1213 UsbClass->ProductId,
1214 UsbClass->DeviceProtocol
1220 UefiDevicePathLibCatPrint (
1222 "UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",
1224 UsbClass->ProductId,
1225 UsbClass->DeviceClass,
1226 UsbClass->DeviceSubClass,
1227 UsbClass->DeviceProtocol
1232 Converts a SATA device path structure to its string representative.
1234 @param Str The string representative of input device.
1235 @param DevPath The input device path structure.
1236 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1237 of the display node is used, where applicable. If DisplayOnly
1238 is FALSE, then the longer text representation of the display node
1240 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1241 representation for a device node can be used, where applicable.
1246 IN OUT POOL_PRINT *Str,
1248 IN BOOLEAN DisplayOnly,
1249 IN BOOLEAN AllowShortcuts
1252 SATA_DEVICE_PATH *Sata;
1255 UefiDevicePathLibCatPrint (
1257 "Sata(0x%x,0x%x,0x%x)",
1258 Sata->HBAPortNumber,
1259 Sata->PortMultiplierPortNumber,
1265 Converts a I20 device path structure to its string representative.
1267 @param Str The string representative of input device.
1268 @param DevPath The input device path structure.
1269 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1270 of the display node is used, where applicable. If DisplayOnly
1271 is FALSE, then the longer text representation of the display node
1273 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1274 representation for a device node can be used, where applicable.
1279 IN OUT POOL_PRINT *Str,
1281 IN BOOLEAN DisplayOnly,
1282 IN BOOLEAN AllowShortcuts
1285 I2O_DEVICE_PATH *I2ODevPath;
1287 I2ODevPath = DevPath;
1288 UefiDevicePathLibCatPrint (Str, "I2O(0x%x)", I2ODevPath->Tid);
1292 Converts a MAC address device path structure to its string representative.
1294 @param Str The string representative of input device.
1295 @param DevPath The input device path structure.
1296 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1297 of the display node is used, where applicable. If DisplayOnly
1298 is FALSE, then the longer text representation of the display node
1300 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1301 representation for a device node can be used, where applicable.
1305 DevPathToTextMacAddr (
1306 IN OUT POOL_PRINT *Str,
1308 IN BOOLEAN DisplayOnly,
1309 IN BOOLEAN AllowShortcuts
1312 MAC_ADDR_DEVICE_PATH *MacDevPath;
1313 UINTN HwAddressSize;
1316 MacDevPath = DevPath;
1318 HwAddressSize = sizeof (EFI_MAC_ADDRESS);
1319 if ((MacDevPath->IfType == 0x01) || (MacDevPath->IfType == 0x00)) {
1323 UefiDevicePathLibCatPrint (Str, "MAC(");
1325 for (Index = 0; Index < HwAddressSize; Index++) {
1326 UefiDevicePathLibCatPrint (Str, "%02x", MacDevPath->MacAddress.Addr[Index]);
1329 UefiDevicePathLibCatPrint (Str, ",0x%x)", MacDevPath->IfType);
1333 Converts network protocol string to its text representation.
1335 @param Str The string representative of input device.
1336 @param Protocol The network protocol ID.
1340 CatNetworkProtocol (
1341 IN OUT POOL_PRINT *Str,
1345 if (Protocol == RFC_1700_TCP_PROTOCOL) {
1346 UefiDevicePathLibCatPrint (Str, "TCP");
1347 } else if (Protocol == RFC_1700_UDP_PROTOCOL) {
1348 UefiDevicePathLibCatPrint (Str, "UDP");
1350 UefiDevicePathLibCatPrint (Str, "0x%x", Protocol);
1355 Converts IP v4 address to its text representation.
1357 @param Str The string representative of input device.
1358 @param Address The IP v4 address.
1362 IN OUT POOL_PRINT *Str,
1363 IN EFI_IPv4_ADDRESS *Address
1366 UefiDevicePathLibCatPrint (Str, "%d.%d.%d.%d", Address->Addr[0], Address->Addr[1], Address->Addr[2], Address->Addr[3]);
1370 Converts IP v6 address to its text representation.
1372 @param Str The string representative of input device.
1373 @param Address The IP v6 address.
1377 IN OUT POOL_PRINT *Str,
1378 IN EFI_IPv6_ADDRESS *Address
1381 UefiDevicePathLibCatPrint (
1383 "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
1404 Converts a IPv4 device path structure to its string representative.
1406 @param Str The string representative of input device.
1407 @param DevPath The input device path structure.
1408 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1409 of the display node is used, where applicable. If DisplayOnly
1410 is FALSE, then the longer text representation of the display node
1412 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1413 representation for a device node can be used, where applicable.
1418 IN OUT POOL_PRINT *Str,
1420 IN BOOLEAN DisplayOnly,
1421 IN BOOLEAN AllowShortcuts
1424 IPv4_DEVICE_PATH *IPDevPath;
1426 IPDevPath = DevPath;
1427 UefiDevicePathLibCatPrint (Str, "IPv4(");
1428 CatIPv4Address (Str, &IPDevPath->RemoteIpAddress);
1431 UefiDevicePathLibCatPrint (Str, ")");
1435 UefiDevicePathLibCatPrint (Str, ",");
1436 CatNetworkProtocol (Str, IPDevPath->Protocol);
1438 UefiDevicePathLibCatPrint (Str, ",%s,", IPDevPath->StaticIpAddress ? "Static" : "DHCP");
1439 CatIPv4Address (Str, &IPDevPath->LocalIpAddress);
1440 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv4_DEVICE_PATH)) {
1441 UefiDevicePathLibCatPrint (Str, ",");
1442 CatIPv4Address (Str, &IPDevPath->GatewayIpAddress);
1443 UefiDevicePathLibCatPrint (Str, ",");
1444 CatIPv4Address (Str, &IPDevPath->SubnetMask);
1447 UefiDevicePathLibCatPrint (Str, ")");
1451 Converts a IPv6 device path structure to its string representative.
1453 @param Str The string representative of input device.
1454 @param DevPath The input device path structure.
1455 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1456 of the display node is used, where applicable. If DisplayOnly
1457 is FALSE, then the longer text representation of the display node
1459 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1460 representation for a device node can be used, where applicable.
1465 IN OUT POOL_PRINT *Str,
1467 IN BOOLEAN DisplayOnly,
1468 IN BOOLEAN AllowShortcuts
1471 IPv6_DEVICE_PATH *IPDevPath;
1473 IPDevPath = DevPath;
1474 UefiDevicePathLibCatPrint (Str, "IPv6(");
1475 CatIPv6Address (Str, &IPDevPath->RemoteIpAddress);
1477 UefiDevicePathLibCatPrint (Str, ")");
1481 UefiDevicePathLibCatPrint (Str, ",");
1482 CatNetworkProtocol (Str, IPDevPath->Protocol);
1484 switch (IPDevPath->IpAddressOrigin) {
1486 UefiDevicePathLibCatPrint (Str, ",Static,");
1489 UefiDevicePathLibCatPrint (Str, ",StatelessAutoConfigure,");
1492 UefiDevicePathLibCatPrint (Str, ",StatefulAutoConfigure,");
1496 CatIPv6Address (Str, &IPDevPath->LocalIpAddress);
1498 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv6_DEVICE_PATH)) {
1499 UefiDevicePathLibCatPrint (Str, ",0x%x,", IPDevPath->PrefixLength);
1500 CatIPv6Address (Str, &IPDevPath->GatewayIpAddress);
1503 UefiDevicePathLibCatPrint (Str, ")");
1507 Converts an Infini Band device path structure to its string representative.
1509 @param Str The string representative of input device.
1510 @param DevPath The input device path structure.
1511 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1512 of the display node is used, where applicable. If DisplayOnly
1513 is FALSE, then the longer text representation of the display node
1515 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1516 representation for a device node can be used, where applicable.
1520 DevPathToTextInfiniBand (
1521 IN OUT POOL_PRINT *Str,
1523 IN BOOLEAN DisplayOnly,
1524 IN BOOLEAN AllowShortcuts
1527 INFINIBAND_DEVICE_PATH *InfiniBand;
1529 InfiniBand = DevPath;
1530 UefiDevicePathLibCatPrint (
1532 "Infiniband(0x%x,%36s,0x%lx,0x%lx,0x%lx)",
1533 InfiniBand->ResourceFlags,
1534 G(InfiniBand->PortGid),
1535 InfiniBand->ServiceId,
1536 InfiniBand->TargetPortId,
1537 InfiniBand->DeviceId
1542 Converts a UART device path structure to its string representative.
1544 @param Str The string representative of input device.
1545 @param DevPath The input device path structure.
1546 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1547 of the display node is used, where applicable. If DisplayOnly
1548 is FALSE, then the longer text representation of the display node
1550 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1551 representation for a device node can be used, where applicable.
1556 IN OUT POOL_PRINT *Str,
1558 IN BOOLEAN DisplayOnly,
1559 IN BOOLEAN AllowShortcuts
1562 UART_DEVICE_PATH *Uart;
1566 switch (Uart->Parity) {
1596 if (Uart->BaudRate == 0) {
1597 UefiDevicePathLibCatPrint (Str, "Uart(DEFAULT,");
1599 UefiDevicePathLibCatPrint (Str, "Uart(%ld,", Uart->BaudRate);
1602 if (Uart->DataBits == 0) {
1603 UefiDevicePathLibCatPrint (Str, "DEFAULT,");
1605 UefiDevicePathLibCatPrint (Str, "%d,", Uart->DataBits);
1608 UefiDevicePathLibCatPrint (Str, "%c,", Parity);
1610 switch (Uart->StopBits) {
1612 UefiDevicePathLibCatPrint (Str, "D)");
1616 UefiDevicePathLibCatPrint (Str, "1)");
1620 UefiDevicePathLibCatPrint (Str, "1.5)");
1624 UefiDevicePathLibCatPrint (Str, "2)");
1628 UefiDevicePathLibCatPrint (Str, "x)");
1634 Converts an iSCSI device path structure to its string representative.
1636 @param Str The string representative of input device.
1637 @param DevPath The input device path structure.
1638 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1639 of the display node is used, where applicable. If DisplayOnly
1640 is FALSE, then the longer text representation of the display node
1642 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1643 representation for a device node can be used, where applicable.
1647 DevPathToTextiSCSI (
1648 IN OUT POOL_PRINT *Str,
1650 IN BOOLEAN DisplayOnly,
1651 IN BOOLEAN AllowShortcuts
1654 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
1658 ISCSIDevPath = DevPath;
1659 UefiDevicePathLibCatPrint (
1662 ISCSIDevPath->TargetName,
1663 ISCSIDevPath->TargetPortalGroupTag
1665 for (Index = 0; Index < sizeof (ISCSIDevPath->Lun) / sizeof (UINT8); Index++) {
1666 UefiDevicePathLibCatPrint (Str, "%02x", ((UINT8 *)&ISCSIDevPath->Lun)[Index]);
1669 Options = ISCSIDevPath->LoginOption;
1670 UefiDevicePathLibCatPrint (Str, ",%s,", (((Options >> 1) & 0x0001) != 0) ? "CRC32C" : "None");
1671 UefiDevicePathLibCatPrint (Str, "%s,", (((Options >> 3) & 0x0001) != 0) ? "CRC32C" : "None");
1672 if (((Options >> 11) & 0x0001) != 0) {
1673 UefiDevicePathLibCatPrint (Str, "%s,", "None");
1674 } else if (((Options >> 12) & 0x0001) != 0) {
1675 UefiDevicePathLibCatPrint (Str, "%s,", "CHAP_UNI");
1677 UefiDevicePathLibCatPrint (Str, "%s,", "CHAP_BI");
1680 UefiDevicePathLibCatPrint (Str, "%s)", (ISCSIDevPath->NetworkProtocol == 0) ? "TCP" : "reserved");
1684 Converts a VLAN device path structure to its string representative.
1686 @param Str The string representative of input device.
1687 @param DevPath The input device path structure.
1688 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1689 of the display node is used, where applicable. If DisplayOnly
1690 is FALSE, then the longer text representation of the display node
1692 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1693 representation for a device node can be used, where applicable.
1698 IN OUT POOL_PRINT *Str,
1700 IN BOOLEAN DisplayOnly,
1701 IN BOOLEAN AllowShortcuts
1704 VLAN_DEVICE_PATH *Vlan;
1707 UefiDevicePathLibCatPrint (Str, "Vlan(%d)", Vlan->VlanId);
1711 Converts a Bluetooth device path structure to its string representative.
1713 @param Str The string representative of input device.
1714 @param DevPath The input device path structure.
1715 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1716 of the display node is used, where applicable. If DisplayOnly
1717 is FALSE, then the longer text representation of the display node
1719 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1720 representation for a device node can be used, where applicable.
1724 DevPathToTextBluetooth (
1725 IN OUT POOL_PRINT *Str,
1727 IN BOOLEAN DisplayOnly,
1728 IN BOOLEAN AllowShortcuts
1731 BLUETOOTH_DEVICE_PATH *Bluetooth;
1733 Bluetooth = DevPath;
1734 UefiDevicePathLibCatPrint (
1736 "Bluetooth(%02x%02x%02x%02x%02x%02x)",
1737 Bluetooth->BD_ADDR.Address[0],
1738 Bluetooth->BD_ADDR.Address[1],
1739 Bluetooth->BD_ADDR.Address[2],
1740 Bluetooth->BD_ADDR.Address[3],
1741 Bluetooth->BD_ADDR.Address[4],
1742 Bluetooth->BD_ADDR.Address[5]
1747 Converts a Wi-Fi device path structure to its string representative.
1749 @param Str The string representative of input device.
1750 @param DevPath The input device path structure.
1751 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1752 of the display node is used, where applicable. If DisplayOnly
1753 is FALSE, then the longer text representation of the display node
1755 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1756 representation for a device node can be used, where applicable.
1761 IN OUT POOL_PRINT *Str,
1763 IN BOOLEAN DisplayOnly,
1764 IN BOOLEAN AllowShortcuts
1767 WIFI_DEVICE_PATH *WiFi;
1773 CopyMem (SSId, WiFi->SSId, 32);
1775 UefiDevicePathLibCatPrint (Str, "Wi-Fi(%s)", SSId);
1779 Converts a Bluetooth device path structure to its string representative.
1781 @param Str The string representative of input device.
1782 @param DevPath The input device path structure.
1783 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1784 of the display node is used, where applicable. If DisplayOnly
1785 is FALSE, then the longer text representation of the display node
1787 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1788 representation for a device node can be used, where applicable.
1792 DevPathToTextBluetoothLE (
1793 IN OUT POOL_PRINT *Str,
1795 IN BOOLEAN DisplayOnly,
1796 IN BOOLEAN AllowShortcuts
1799 BLUETOOTH_LE_DEVICE_PATH *BluetoothLE;
1801 BluetoothLE = DevPath;
1802 UefiDevicePathLibCatPrint (
1804 "BluetoothLE(%02x%02x%02x%02x%02x%02x,0x%02x)",
1805 BluetoothLE->Address.Address[0],
1806 BluetoothLE->Address.Address[1],
1807 BluetoothLE->Address.Address[2],
1808 BluetoothLE->Address.Address[3],
1809 BluetoothLE->Address.Address[4],
1810 BluetoothLE->Address.Address[5],
1811 BluetoothLE->Address.Type
1816 Converts a DNS device path structure to its string representative.
1818 @param Str The string representative of input device.
1819 @param DevPath The input device path structure.
1820 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1821 of the display node is used, where applicable. If DisplayOnly
1822 is FALSE, then the longer text representation of the display node
1824 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1825 representation for a device node can be used, where applicable.
1830 IN OUT POOL_PRINT *Str,
1832 IN BOOLEAN DisplayOnly,
1833 IN BOOLEAN AllowShortcuts
1836 DNS_DEVICE_PATH *DnsDevPath;
1837 UINT32 DnsServerIpCount;
1838 UINT32 DnsServerIpIndex;
1840 DnsDevPath = DevPath;
1841 DnsServerIpCount = (UINT32)(DevicePathNodeLength (DnsDevPath) - sizeof (EFI_DEVICE_PATH_PROTOCOL) - sizeof (DnsDevPath->IsIPv6)) / sizeof (EFI_IP_ADDRESS);
1843 UefiDevicePathLibCatPrint (Str, "Dns(");
1845 for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; DnsServerIpIndex++) {
1846 if (DnsDevPath->IsIPv6 == 0x00) {
1847 CatIPv4Address (Str, &(DnsDevPath->DnsServerIp[DnsServerIpIndex].v4));
1849 CatIPv6Address (Str, &(DnsDevPath->DnsServerIp[DnsServerIpIndex].v6));
1852 if (DnsServerIpIndex < DnsServerIpCount - 1) {
1853 UefiDevicePathLibCatPrint (Str, ",");
1857 UefiDevicePathLibCatPrint (Str, ")");
1861 Converts a URI device path structure to its string representative.
1863 @param Str The string representative of input device.
1864 @param DevPath The input device path structure.
1865 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1866 of the display node is used, where applicable. If DisplayOnly
1867 is FALSE, then the longer text representation of the display node
1869 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1870 representation for a device node can be used, where applicable.
1875 IN OUT POOL_PRINT *Str,
1877 IN BOOLEAN DisplayOnly,
1878 IN BOOLEAN AllowShortcuts
1881 URI_DEVICE_PATH *Uri;
1886 // Uri in the device path may not be null terminated.
1889 UriLength = DevicePathNodeLength (Uri) - sizeof (URI_DEVICE_PATH);
1890 UriStr = AllocatePool (UriLength + 1);
1891 ASSERT (UriStr != NULL);
1893 CopyMem (UriStr, Uri->Uri, UriLength);
1894 UriStr[UriLength] = '\0';
1895 UefiDevicePathLibCatPrint (Str, "Uri(%s)", UriStr);
1900 Converts a Hard drive device path structure to its string representative.
1902 @param Str The string representative of input device.
1903 @param DevPath The input device path structure.
1904 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1905 of the display node is used, where applicable. If DisplayOnly
1906 is FALSE, then the longer text representation of the display node
1908 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1909 representation for a device node can be used, where applicable.
1913 DevPathToTextHardDrive (
1914 IN OUT POOL_PRINT *Str,
1916 IN BOOLEAN DisplayOnly,
1917 IN BOOLEAN AllowShortcuts
1920 HARDDRIVE_DEVICE_PATH *Hd;
1923 switch (Hd->SignatureType) {
1924 case SIGNATURE_TYPE_MBR:
1925 UefiDevicePathLibCatPrint (
1928 Hd->PartitionNumber,
1930 // *((UINT32 *)(&(Hd->Signature[0])))
1931 le32dec(&(Hd->Signature[0]))
1935 case SIGNATURE_TYPE_GUID:
1936 UefiDevicePathLibCatPrint (
1939 Hd->PartitionNumber,
1941 G(&(Hd->Signature[0]))
1946 UefiDevicePathLibCatPrint (
1949 Hd->PartitionNumber,
1955 UefiDevicePathLibCatPrint (Str, "0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);
1959 Converts a CDROM device path structure to its string representative.
1961 @param Str The string representative of input device.
1962 @param DevPath The input device path structure.
1963 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1964 of the display node is used, where applicable. If DisplayOnly
1965 is FALSE, then the longer text representation of the display node
1967 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1968 representation for a device node can be used, where applicable.
1972 DevPathToTextCDROM (
1973 IN OUT POOL_PRINT *Str,
1975 IN BOOLEAN DisplayOnly,
1976 IN BOOLEAN AllowShortcuts
1979 CDROM_DEVICE_PATH *Cd;
1983 UefiDevicePathLibCatPrint (Str, "CDROM(0x%x)", Cd->BootEntry);
1987 UefiDevicePathLibCatPrint (Str, "CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);
1991 Converts a File device path structure to its string representative.
1993 @param Str The string representative of input device.
1994 @param DevPath The input device path structure.
1995 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1996 of the display node is used, where applicable. If DisplayOnly
1997 is FALSE, then the longer text representation of the display node
1999 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2000 representation for a device node can be used, where applicable.
2004 DevPathToTextFilePath (
2005 IN OUT POOL_PRINT *Str,
2007 IN BOOLEAN DisplayOnly,
2008 IN BOOLEAN AllowShortcuts
2011 FILEPATH_DEVICE_PATH *Fp;
2015 ucs2_to_utf8(Fp->PathName, &name);
2016 UefiDevicePathLibCatPrint (Str, "File(%s)", name);
2021 Converts a Media protocol device path structure to its string representative.
2023 @param Str The string representative of input device.
2024 @param DevPath The input device path structure.
2025 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2026 of the display node is used, where applicable. If DisplayOnly
2027 is FALSE, then the longer text representation of the display node
2029 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2030 representation for a device node can be used, where applicable.
2034 DevPathToTextMediaProtocol (
2035 IN OUT POOL_PRINT *Str,
2037 IN BOOLEAN DisplayOnly,
2038 IN BOOLEAN AllowShortcuts
2041 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;
2043 MediaProt = DevPath;
2044 UefiDevicePathLibCatPrint (Str, "Media(%36s)", G(&MediaProt->Protocol));
2048 Converts a Firmware Volume device path structure to its string representative.
2050 @param Str The string representative of input device.
2051 @param DevPath The input device path structure.
2052 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2053 of the display node is used, where applicable. If DisplayOnly
2054 is FALSE, then the longer text representation of the display node
2056 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2057 representation for a device node can be used, where applicable.
2062 IN OUT POOL_PRINT *Str,
2064 IN BOOLEAN DisplayOnly,
2065 IN BOOLEAN AllowShortcuts
2068 MEDIA_FW_VOL_DEVICE_PATH *Fv;
2071 UefiDevicePathLibCatPrint (Str, "Fv(%36s)", G(&Fv->FvName));
2075 Converts a Firmware Volume File device path structure to its string representative.
2077 @param Str The string representative of input device.
2078 @param DevPath The input device path structure.
2079 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2080 of the display node is used, where applicable. If DisplayOnly
2081 is FALSE, then the longer text representation of the display node
2083 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2084 representation for a device node can be used, where applicable.
2088 DevPathToTextFvFile (
2089 IN OUT POOL_PRINT *Str,
2091 IN BOOLEAN DisplayOnly,
2092 IN BOOLEAN AllowShortcuts
2095 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;
2098 UefiDevicePathLibCatPrint (Str, "FvFile(%36s)", G(&FvFile->FvFileName));
2102 Converts a Relative Offset device path structure to its string representative.
2104 @param Str The string representative of input device.
2105 @param DevPath The input device path structure.
2106 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2107 of the display node is used, where applicable. If DisplayOnly
2108 is FALSE, then the longer text representation of the display node
2110 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2111 representation for a device node can be used, where applicable.
2115 DevPathRelativeOffsetRange (
2116 IN OUT POOL_PRINT *Str,
2118 IN BOOLEAN DisplayOnly,
2119 IN BOOLEAN AllowShortcuts
2122 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;
2125 UefiDevicePathLibCatPrint (
2127 "Offset(0x%lx,0x%lx)",
2128 Offset->StartingOffset,
2129 Offset->EndingOffset
2134 Converts a Ram Disk device path structure to its string representative.
2136 @param Str The string representative of input device.
2137 @param DevPath The input device path structure.
2138 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2139 of the display node is used, where applicable. If DisplayOnly
2140 is FALSE, then the longer text representation of the display node
2142 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2143 representation for a device node can be used, where applicable.
2147 DevPathToTextRamDisk (
2148 IN OUT POOL_PRINT *Str,
2150 IN BOOLEAN DisplayOnly,
2151 IN BOOLEAN AllowShortcuts
2154 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
2158 if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid)) {
2159 UefiDevicePathLibCatPrint (
2161 "VirtualDisk(0x%lx,0x%lx,%d)",
2162 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2163 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2166 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid)) {
2167 UefiDevicePathLibCatPrint (
2169 "VirtualCD(0x%lx,0x%lx,%d)",
2170 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2171 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2174 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid)) {
2175 UefiDevicePathLibCatPrint (
2177 "PersistentVirtualDisk(0x%lx,0x%lx,%d)",
2178 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2179 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2182 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid)) {
2183 UefiDevicePathLibCatPrint (
2185 "PersistentVirtualCD(0x%lx,0x%lx,%d)",
2186 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2187 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2191 UefiDevicePathLibCatPrint (
2193 "RamDisk(0x%lx,0x%lx,%d,%36s)",
2194 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2195 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2197 G(&RamDisk->TypeGuid)
2203 Converts a BIOS Boot Specification device path structure to its string representative.
2205 @param Str The string representative of input device.
2206 @param DevPath The input device path structure.
2207 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2208 of the display node is used, where applicable. If DisplayOnly
2209 is FALSE, then the longer text representation of the display node
2211 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2212 representation for a device node can be used, where applicable.
2217 IN OUT POOL_PRINT *Str,
2219 IN BOOLEAN DisplayOnly,
2220 IN BOOLEAN AllowShortcuts
2223 BBS_BBS_DEVICE_PATH *Bbs;
2227 switch (Bbs->DeviceType) {
2228 case BBS_TYPE_FLOPPY:
2232 case BBS_TYPE_HARDDRIVE:
2236 case BBS_TYPE_CDROM:
2240 case BBS_TYPE_PCMCIA:
2248 case BBS_TYPE_EMBEDDED_NETWORK:
2258 UefiDevicePathLibCatPrint (Str, "BBS(%s,%s", Type, Bbs->String);
2260 UefiDevicePathLibCatPrint (Str, "BBS(0x%x,%s", Bbs->DeviceType, Bbs->String);
2264 UefiDevicePathLibCatPrint (Str, ")");
2268 UefiDevicePathLibCatPrint (Str, ",0x%x)", Bbs->StatusFlag);
2272 Converts an End-of-Device-Path structure to its string representative.
2274 @param Str The string representative of input device.
2275 @param DevPath The input device path structure.
2276 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2277 of the display node is used, where applicable. If DisplayOnly
2278 is FALSE, then the longer text representation of the display node
2280 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2281 representation for a device node can be used, where applicable.
2285 DevPathToTextEndInstance (
2286 IN OUT POOL_PRINT *Str,
2288 IN BOOLEAN DisplayOnly,
2289 IN BOOLEAN AllowShortcuts
2292 UefiDevicePathLibCatPrint (Str, ",");
2295 GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_GENERIC_TABLE mUefiDevicePathLibToTextTableGeneric[] = {
2296 { HARDWARE_DEVICE_PATH, "HardwarePath" },
2297 { ACPI_DEVICE_PATH, "AcpiPath" },
2298 { MESSAGING_DEVICE_PATH, "Msg" },
2299 { MEDIA_DEVICE_PATH, "MediaPath" },
2300 { BBS_DEVICE_PATH, "BbsPath" },
2305 Converts an unknown device path structure to its string representative.
2307 @param Str The string representative of input device.
2308 @param DevPath The input device path structure.
2309 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2310 of the display node is used, where applicable. If DisplayOnly
2311 is FALSE, then the longer text representation of the display node
2313 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2314 representation for a device node can be used, where applicable.
2318 DevPathToTextNodeGeneric (
2319 IN OUT POOL_PRINT *Str,
2321 IN BOOLEAN DisplayOnly,
2322 IN BOOLEAN AllowShortcuts
2325 EFI_DEVICE_PATH_PROTOCOL *Node;
2330 for (Index = 0; mUefiDevicePathLibToTextTableGeneric[Index].Text != NULL; Index++) {
2331 if (DevicePathType (Node) == mUefiDevicePathLibToTextTableGeneric[Index].Type) {
2336 if (mUefiDevicePathLibToTextTableGeneric[Index].Text == NULL) {
2338 // It's a node whose type cannot be recognized
2340 UefiDevicePathLibCatPrint (Str, "Path(%d,%d", DevicePathType (Node), DevicePathSubType (Node));
2343 // It's a node whose type can be recognized
2345 UefiDevicePathLibCatPrint (Str, "%s(%d", mUefiDevicePathLibToTextTableGeneric[Index].Text, DevicePathSubType (Node));
2348 Index = sizeof (EFI_DEVICE_PATH_PROTOCOL);
2349 if (Index < DevicePathNodeLength (Node)) {
2350 UefiDevicePathLibCatPrint (Str, ",");
2351 for ( ; Index < DevicePathNodeLength (Node); Index++) {
2352 UefiDevicePathLibCatPrint (Str, "%02x", ((UINT8 *)Node)[Index]);
2356 UefiDevicePathLibCatPrint (Str, ")");
2359 static const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = {
2360 { HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci },
2361 { HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard },
2362 { HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap },
2363 { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor },
2364 { HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController },
2365 { HARDWARE_DEVICE_PATH, HW_BMC_DP, DevPathToTextBmc },
2366 { ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi },
2367 { ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx },
2368 { ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr },
2369 { MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi },
2370 { MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi },
2371 { MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre },
2372 { MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx },
2373 { MESSAGING_DEVICE_PATH, MSG_SASEX_DP, DevPathToTextSasEx },
2374 { MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP, DevPathToTextNVMe },
2375 { MESSAGING_DEVICE_PATH, MSG_UFS_DP, DevPathToTextUfs },
2376 { MESSAGING_DEVICE_PATH, MSG_SD_DP, DevPathToTextSd },
2377 { MESSAGING_DEVICE_PATH, MSG_EMMC_DP, DevPathToTextEmmc },
2378 { MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394 },
2379 { MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb },
2380 { MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID },
2381 { MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit },
2382 { MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass },
2383 { MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata },
2384 { MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O },
2385 { MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr },
2386 { MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4 },
2387 { MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6 },
2388 { MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand },
2389 { MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart },
2390 { MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor },
2391 { MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI },
2392 { MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan },
2393 { MESSAGING_DEVICE_PATH, MSG_DNS_DP, DevPathToTextDns },
2394 { MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextUri },
2395 { MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextBluetooth },
2396 { MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextWiFi },
2397 { MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, DevPathToTextBluetoothLE },
2398 { MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive },
2399 { MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM },
2400 { MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor },
2401 { MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol },
2402 { MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath },
2403 { MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv },
2404 { MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile },
2405 { MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange },
2406 { MEDIA_DEVICE_PATH, MEDIA_RAM_DISK_DP, DevPathToTextRamDisk },
2407 { BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS },
2408 { END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance },
2413 Converts a device node to its string representation.
2415 @param DeviceNode A Pointer to the device node to be converted.
2416 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2417 of the display node is used, where applicable. If DisplayOnly
2418 is FALSE, then the longer text representation of the display node
2420 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2421 representation for a device node can be used, where applicable.
2423 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode
2424 is NULL or there was insufficient memory.
2429 UefiDevicePathLibConvertDeviceNodeToText (
2430 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
2431 IN BOOLEAN DisplayOnly,
2432 IN BOOLEAN AllowShortcuts
2437 DEVICE_PATH_TO_TEXT ToText;
2438 EFI_DEVICE_PATH_PROTOCOL *Node;
2440 if (DeviceNode == NULL) {
2444 ZeroMem (&Str, sizeof (Str));
2447 // Process the device path node
2448 // If not found, use a generic function
2450 Node = __DECONST(EFI_DEVICE_PATH_PROTOCOL *, DeviceNode);
2451 ToText = DevPathToTextNodeGeneric;
2452 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index++) {
2453 if ((DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type) &&
2454 (DevicePathSubType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].SubType)
2457 ToText = mUefiDevicePathLibToTextTable[Index].Function;
2465 ToText (&Str, (VOID *)Node, DisplayOnly, AllowShortcuts);
2467 ASSERT (Str.Str != NULL);
2472 Converts a device path to its text representation.
2474 @param DevicePath A Pointer to the device to be converted.
2475 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2476 of the display node is used, where applicable. If DisplayOnly
2477 is FALSE, then the longer text representation of the display node
2479 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2480 representation for a device node can be used, where applicable.
2482 @return A pointer to the allocated text representation of the device path or
2483 NULL if DeviceNode is NULL or there was insufficient memory.
2488 UefiDevicePathLibConvertDevicePathToText (
2489 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
2490 IN BOOLEAN DisplayOnly,
2491 IN BOOLEAN AllowShortcuts
2495 EFI_DEVICE_PATH_PROTOCOL *Node;
2496 EFI_DEVICE_PATH_PROTOCOL *AlignedNode;
2498 DEVICE_PATH_TO_TEXT ToText;
2500 if (DevicePath == NULL) {
2504 ZeroMem (&Str, sizeof (Str));
2507 // Process each device path node
2509 Node = __DECONST(EFI_DEVICE_PATH_PROTOCOL *, DevicePath);
2510 while (!IsDevicePathEnd (Node)) {
2512 // Find the handler to dump this device path node
2513 // If not found, use a generic function
2515 ToText = DevPathToTextNodeGeneric;
2516 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index += 1) {
2517 if ((DevicePathType (Node) == mUefiDevicePathLibToTextTable[Index].Type) &&
2518 (DevicePathSubType (Node) == mUefiDevicePathLibToTextTable[Index].SubType)
2521 ToText = mUefiDevicePathLibToTextTable[Index].Function;
2527 // Put a path separator in if needed
2529 if ((Str.Count != 0) && (ToText != DevPathToTextEndInstance)) {
2530 if (Str.Str[Str.Count] != ',') {
2531 UefiDevicePathLibCatPrint (&Str, "/");
2535 AlignedNode = AllocateCopyPool (DevicePathNodeLength (Node), Node);
2537 // Print this node of the device path
2539 ToText (&Str, AlignedNode, DisplayOnly, AllowShortcuts);
2540 FreePool (AlignedNode);
2543 // Next device path node
2545 Node = NextDevicePathNode (Node);
2548 if (Str.Str == NULL) {
2549 return AllocateZeroPool (sizeof (CHAR16));
2556 efidp_format_device_path(char *buf, size_t len, const_efidp dp, ssize_t max)
2562 * Basic sanity check on the device path.
2564 if (!IsDevicePathValid((CONST EFI_DEVICE_PATH_PROTOCOL *) dp, max)) {
2569 str = UefiDevicePathLibConvertDevicePathToText (
2570 __DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp), FALSE, TRUE);
2573 strlcpy(buf, str, len);
2574 retval = strlen(str);
2581 efidp_format_device_path_node(char *buf, size_t len, const_efidp dp)
2586 str = UefiDevicePathLibConvertDeviceNodeToText (
2587 __DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp), FALSE, TRUE);
2590 strlcpy(buf, str, len);
2591 retval = strlen(str);
2598 efidp_size(const_efidp dp)
2601 return GetDevicePathSize(__DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp));
2605 efidp_extract_file_path(const_efidp dp)
2607 const FILEPATH_DEVICE_PATH *fp;
2610 fp = (const void *)dp;
2611 ucs2_to_utf8(fp->PathName, &name);