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 = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);
1053 ASSERT (NewStr != NULL);
1055 SerialNumberStr = NewStr;
1058 UefiDevicePathLibCatPrint (
1060 "UsbWwid(0x%x,0x%x,0x%x,\"%S\")",
1063 UsbWWId->InterfaceNumber,
1069 Converts a Logic Unit device path structure to its string representative.
1071 @param Str The string representative of input device.
1072 @param DevPath The input device path structure.
1073 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1074 of the display node is used, where applicable. If DisplayOnly
1075 is FALSE, then the longer text representation of the display node
1077 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1078 representation for a device node can be used, where applicable.
1082 DevPathToTextLogicalUnit (
1083 IN OUT POOL_PRINT *Str,
1085 IN BOOLEAN DisplayOnly,
1086 IN BOOLEAN AllowShortcuts
1089 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
1091 LogicalUnit = DevPath;
1092 UefiDevicePathLibCatPrint (Str, "Unit(0x%x)", LogicalUnit->Lun);
1096 Converts a USB class device path structure to its string representative.
1098 @param Str The string representative of input device.
1099 @param DevPath The input device path structure.
1100 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1101 of the display node is used, where applicable. If DisplayOnly
1102 is FALSE, then the longer text representation of the display node
1104 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1105 representation for a device node can be used, where applicable.
1109 DevPathToTextUsbClass (
1110 IN OUT POOL_PRINT *Str,
1112 IN BOOLEAN DisplayOnly,
1113 IN BOOLEAN AllowShortcuts
1116 USB_CLASS_DEVICE_PATH *UsbClass;
1117 BOOLEAN IsKnownSubClass;
1121 IsKnownSubClass = TRUE;
1122 switch (UsbClass->DeviceClass) {
1123 case USB_CLASS_AUDIO:
1124 UefiDevicePathLibCatPrint (Str, "UsbAudio");
1127 case USB_CLASS_CDCCONTROL:
1128 UefiDevicePathLibCatPrint (Str, "UsbCDCControl");
1132 UefiDevicePathLibCatPrint (Str, "UsbHID");
1135 case USB_CLASS_IMAGE:
1136 UefiDevicePathLibCatPrint (Str, "UsbImage");
1139 case USB_CLASS_PRINTER:
1140 UefiDevicePathLibCatPrint (Str, "UsbPrinter");
1143 case USB_CLASS_MASS_STORAGE:
1144 UefiDevicePathLibCatPrint (Str, "UsbMassStorage");
1148 UefiDevicePathLibCatPrint (Str, "UsbHub");
1151 case USB_CLASS_CDCDATA:
1152 UefiDevicePathLibCatPrint (Str, "UsbCDCData");
1155 case USB_CLASS_SMART_CARD:
1156 UefiDevicePathLibCatPrint (Str, "UsbSmartCard");
1159 case USB_CLASS_VIDEO:
1160 UefiDevicePathLibCatPrint (Str, "UsbVideo");
1163 case USB_CLASS_DIAGNOSTIC:
1164 UefiDevicePathLibCatPrint (Str, "UsbDiagnostic");
1167 case USB_CLASS_WIRELESS:
1168 UefiDevicePathLibCatPrint (Str, "UsbWireless");
1172 IsKnownSubClass = FALSE;
1176 if (IsKnownSubClass) {
1177 UefiDevicePathLibCatPrint (
1179 "(0x%x,0x%x,0x%x,0x%x)",
1181 UsbClass->ProductId,
1182 UsbClass->DeviceSubClass,
1183 UsbClass->DeviceProtocol
1188 if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {
1189 if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {
1190 UefiDevicePathLibCatPrint (
1192 "UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",
1194 UsbClass->ProductId,
1195 UsbClass->DeviceProtocol
1198 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {
1199 UefiDevicePathLibCatPrint (
1201 "UsbIrdaBridge(0x%x,0x%x,0x%x)",
1203 UsbClass->ProductId,
1204 UsbClass->DeviceProtocol
1207 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {
1208 UefiDevicePathLibCatPrint (
1210 "UsbTestAndMeasurement(0x%x,0x%x,0x%x)",
1212 UsbClass->ProductId,
1213 UsbClass->DeviceProtocol
1219 UefiDevicePathLibCatPrint (
1221 "UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",
1223 UsbClass->ProductId,
1224 UsbClass->DeviceClass,
1225 UsbClass->DeviceSubClass,
1226 UsbClass->DeviceProtocol
1231 Converts a SATA device path structure to its string representative.
1233 @param Str The string representative of input device.
1234 @param DevPath The input device path structure.
1235 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1236 of the display node is used, where applicable. If DisplayOnly
1237 is FALSE, then the longer text representation of the display node
1239 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1240 representation for a device node can be used, where applicable.
1245 IN OUT POOL_PRINT *Str,
1247 IN BOOLEAN DisplayOnly,
1248 IN BOOLEAN AllowShortcuts
1251 SATA_DEVICE_PATH *Sata;
1254 UefiDevicePathLibCatPrint (
1256 "Sata(0x%x,0x%x,0x%x)",
1257 Sata->HBAPortNumber,
1258 Sata->PortMultiplierPortNumber,
1264 Converts a I20 device path structure to its string representative.
1266 @param Str The string representative of input device.
1267 @param DevPath The input device path structure.
1268 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1269 of the display node is used, where applicable. If DisplayOnly
1270 is FALSE, then the longer text representation of the display node
1272 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1273 representation for a device node can be used, where applicable.
1278 IN OUT POOL_PRINT *Str,
1280 IN BOOLEAN DisplayOnly,
1281 IN BOOLEAN AllowShortcuts
1284 I2O_DEVICE_PATH *I2ODevPath;
1286 I2ODevPath = DevPath;
1287 UefiDevicePathLibCatPrint (Str, "I2O(0x%x)", I2ODevPath->Tid);
1291 Converts a MAC address device path structure to its string representative.
1293 @param Str The string representative of input device.
1294 @param DevPath The input device path structure.
1295 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1296 of the display node is used, where applicable. If DisplayOnly
1297 is FALSE, then the longer text representation of the display node
1299 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1300 representation for a device node can be used, where applicable.
1304 DevPathToTextMacAddr (
1305 IN OUT POOL_PRINT *Str,
1307 IN BOOLEAN DisplayOnly,
1308 IN BOOLEAN AllowShortcuts
1311 MAC_ADDR_DEVICE_PATH *MacDevPath;
1312 UINTN HwAddressSize;
1315 MacDevPath = DevPath;
1317 HwAddressSize = sizeof (EFI_MAC_ADDRESS);
1318 if ((MacDevPath->IfType == 0x01) || (MacDevPath->IfType == 0x00)) {
1322 UefiDevicePathLibCatPrint (Str, "MAC(");
1324 for (Index = 0; Index < HwAddressSize; Index++) {
1325 UefiDevicePathLibCatPrint (Str, "%02x", MacDevPath->MacAddress.Addr[Index]);
1328 UefiDevicePathLibCatPrint (Str, ",0x%x)", MacDevPath->IfType);
1332 Converts network protocol string to its text representation.
1334 @param Str The string representative of input device.
1335 @param Protocol The network protocol ID.
1339 CatNetworkProtocol (
1340 IN OUT POOL_PRINT *Str,
1344 if (Protocol == RFC_1700_TCP_PROTOCOL) {
1345 UefiDevicePathLibCatPrint (Str, "TCP");
1346 } else if (Protocol == RFC_1700_UDP_PROTOCOL) {
1347 UefiDevicePathLibCatPrint (Str, "UDP");
1349 UefiDevicePathLibCatPrint (Str, "0x%x", Protocol);
1354 Converts IP v4 address to its text representation.
1356 @param Str The string representative of input device.
1357 @param Address The IP v4 address.
1361 IN OUT POOL_PRINT *Str,
1362 IN EFI_IPv4_ADDRESS *Address
1365 UefiDevicePathLibCatPrint (Str, "%d.%d.%d.%d", Address->Addr[0], Address->Addr[1], Address->Addr[2], Address->Addr[3]);
1369 Converts IP v6 address to its text representation.
1371 @param Str The string representative of input device.
1372 @param Address The IP v6 address.
1376 IN OUT POOL_PRINT *Str,
1377 IN EFI_IPv6_ADDRESS *Address
1380 UefiDevicePathLibCatPrint (
1382 "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
1403 Converts a IPv4 device path structure to its string representative.
1405 @param Str The string representative of input device.
1406 @param DevPath The input device path structure.
1407 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1408 of the display node is used, where applicable. If DisplayOnly
1409 is FALSE, then the longer text representation of the display node
1411 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1412 representation for a device node can be used, where applicable.
1417 IN OUT POOL_PRINT *Str,
1419 IN BOOLEAN DisplayOnly,
1420 IN BOOLEAN AllowShortcuts
1423 IPv4_DEVICE_PATH *IPDevPath;
1425 IPDevPath = DevPath;
1426 UefiDevicePathLibCatPrint (Str, "IPv4(");
1427 CatIPv4Address (Str, &IPDevPath->RemoteIpAddress);
1430 UefiDevicePathLibCatPrint (Str, ")");
1434 UefiDevicePathLibCatPrint (Str, ",");
1435 CatNetworkProtocol (Str, IPDevPath->Protocol);
1437 UefiDevicePathLibCatPrint (Str, ",%s,", IPDevPath->StaticIpAddress ? "Static" : "DHCP");
1438 CatIPv4Address (Str, &IPDevPath->LocalIpAddress);
1439 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv4_DEVICE_PATH)) {
1440 UefiDevicePathLibCatPrint (Str, ",");
1441 CatIPv4Address (Str, &IPDevPath->GatewayIpAddress);
1442 UefiDevicePathLibCatPrint (Str, ",");
1443 CatIPv4Address (Str, &IPDevPath->SubnetMask);
1446 UefiDevicePathLibCatPrint (Str, ")");
1450 Converts a IPv6 device path structure to its string representative.
1452 @param Str The string representative of input device.
1453 @param DevPath The input device path structure.
1454 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1455 of the display node is used, where applicable. If DisplayOnly
1456 is FALSE, then the longer text representation of the display node
1458 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1459 representation for a device node can be used, where applicable.
1464 IN OUT POOL_PRINT *Str,
1466 IN BOOLEAN DisplayOnly,
1467 IN BOOLEAN AllowShortcuts
1470 IPv6_DEVICE_PATH *IPDevPath;
1472 IPDevPath = DevPath;
1473 UefiDevicePathLibCatPrint (Str, "IPv6(");
1474 CatIPv6Address (Str, &IPDevPath->RemoteIpAddress);
1476 UefiDevicePathLibCatPrint (Str, ")");
1480 UefiDevicePathLibCatPrint (Str, ",");
1481 CatNetworkProtocol (Str, IPDevPath->Protocol);
1483 switch (IPDevPath->IpAddressOrigin) {
1485 UefiDevicePathLibCatPrint (Str, ",Static,");
1488 UefiDevicePathLibCatPrint (Str, ",StatelessAutoConfigure,");
1491 UefiDevicePathLibCatPrint (Str, ",StatefulAutoConfigure,");
1495 CatIPv6Address (Str, &IPDevPath->LocalIpAddress);
1497 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv6_DEVICE_PATH)) {
1498 UefiDevicePathLibCatPrint (Str, ",0x%x,", IPDevPath->PrefixLength);
1499 CatIPv6Address (Str, &IPDevPath->GatewayIpAddress);
1502 UefiDevicePathLibCatPrint (Str, ")");
1506 Converts an Infini Band device path structure to its string representative.
1508 @param Str The string representative of input device.
1509 @param DevPath The input device path structure.
1510 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1511 of the display node is used, where applicable. If DisplayOnly
1512 is FALSE, then the longer text representation of the display node
1514 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1515 representation for a device node can be used, where applicable.
1519 DevPathToTextInfiniBand (
1520 IN OUT POOL_PRINT *Str,
1522 IN BOOLEAN DisplayOnly,
1523 IN BOOLEAN AllowShortcuts
1526 INFINIBAND_DEVICE_PATH *InfiniBand;
1528 InfiniBand = DevPath;
1529 UefiDevicePathLibCatPrint (
1531 "Infiniband(0x%x,%36s,0x%lx,0x%lx,0x%lx)",
1532 InfiniBand->ResourceFlags,
1533 G(InfiniBand->PortGid),
1534 InfiniBand->ServiceId,
1535 InfiniBand->TargetPortId,
1536 InfiniBand->DeviceId
1541 Converts a UART device path structure to its string representative.
1543 @param Str The string representative of input device.
1544 @param DevPath The input device path structure.
1545 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1546 of the display node is used, where applicable. If DisplayOnly
1547 is FALSE, then the longer text representation of the display node
1549 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1550 representation for a device node can be used, where applicable.
1555 IN OUT POOL_PRINT *Str,
1557 IN BOOLEAN DisplayOnly,
1558 IN BOOLEAN AllowShortcuts
1561 UART_DEVICE_PATH *Uart;
1565 switch (Uart->Parity) {
1595 if (Uart->BaudRate == 0) {
1596 UefiDevicePathLibCatPrint (Str, "Uart(DEFAULT,");
1598 UefiDevicePathLibCatPrint (Str, "Uart(%ld,", Uart->BaudRate);
1601 if (Uart->DataBits == 0) {
1602 UefiDevicePathLibCatPrint (Str, "DEFAULT,");
1604 UefiDevicePathLibCatPrint (Str, "%d,", Uart->DataBits);
1607 UefiDevicePathLibCatPrint (Str, "%c,", Parity);
1609 switch (Uart->StopBits) {
1611 UefiDevicePathLibCatPrint (Str, "D)");
1615 UefiDevicePathLibCatPrint (Str, "1)");
1619 UefiDevicePathLibCatPrint (Str, "1.5)");
1623 UefiDevicePathLibCatPrint (Str, "2)");
1627 UefiDevicePathLibCatPrint (Str, "x)");
1633 Converts an iSCSI device path structure to its string representative.
1635 @param Str The string representative of input device.
1636 @param DevPath The input device path structure.
1637 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1638 of the display node is used, where applicable. If DisplayOnly
1639 is FALSE, then the longer text representation of the display node
1641 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1642 representation for a device node can be used, where applicable.
1646 DevPathToTextiSCSI (
1647 IN OUT POOL_PRINT *Str,
1649 IN BOOLEAN DisplayOnly,
1650 IN BOOLEAN AllowShortcuts
1653 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
1657 ISCSIDevPath = DevPath;
1658 UefiDevicePathLibCatPrint (
1661 ISCSIDevPath->TargetName,
1662 ISCSIDevPath->TargetPortalGroupTag
1664 for (Index = 0; Index < sizeof (ISCSIDevPath->Lun) / sizeof (UINT8); Index++) {
1665 UefiDevicePathLibCatPrint (Str, "%02x", ((UINT8 *)&ISCSIDevPath->Lun)[Index]);
1668 Options = ISCSIDevPath->LoginOption;
1669 UefiDevicePathLibCatPrint (Str, ",%s,", (((Options >> 1) & 0x0001) != 0) ? "CRC32C" : "None");
1670 UefiDevicePathLibCatPrint (Str, "%s,", (((Options >> 3) & 0x0001) != 0) ? "CRC32C" : "None");
1671 if (((Options >> 11) & 0x0001) != 0) {
1672 UefiDevicePathLibCatPrint (Str, "%s,", "None");
1673 } else if (((Options >> 12) & 0x0001) != 0) {
1674 UefiDevicePathLibCatPrint (Str, "%s,", "CHAP_UNI");
1676 UefiDevicePathLibCatPrint (Str, "%s,", "CHAP_BI");
1679 UefiDevicePathLibCatPrint (Str, "%s)", (ISCSIDevPath->NetworkProtocol == 0) ? "TCP" : "reserved");
1683 Converts a VLAN device path structure to its string representative.
1685 @param Str The string representative of input device.
1686 @param DevPath The input device path structure.
1687 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1688 of the display node is used, where applicable. If DisplayOnly
1689 is FALSE, then the longer text representation of the display node
1691 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1692 representation for a device node can be used, where applicable.
1697 IN OUT POOL_PRINT *Str,
1699 IN BOOLEAN DisplayOnly,
1700 IN BOOLEAN AllowShortcuts
1703 VLAN_DEVICE_PATH *Vlan;
1706 UefiDevicePathLibCatPrint (Str, "Vlan(%d)", Vlan->VlanId);
1710 Converts a Bluetooth device path structure to its string representative.
1712 @param Str The string representative of input device.
1713 @param DevPath The input device path structure.
1714 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1715 of the display node is used, where applicable. If DisplayOnly
1716 is FALSE, then the longer text representation of the display node
1718 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1719 representation for a device node can be used, where applicable.
1723 DevPathToTextBluetooth (
1724 IN OUT POOL_PRINT *Str,
1726 IN BOOLEAN DisplayOnly,
1727 IN BOOLEAN AllowShortcuts
1730 BLUETOOTH_DEVICE_PATH *Bluetooth;
1732 Bluetooth = DevPath;
1733 UefiDevicePathLibCatPrint (
1735 "Bluetooth(%02x%02x%02x%02x%02x%02x)",
1736 Bluetooth->BD_ADDR.Address[0],
1737 Bluetooth->BD_ADDR.Address[1],
1738 Bluetooth->BD_ADDR.Address[2],
1739 Bluetooth->BD_ADDR.Address[3],
1740 Bluetooth->BD_ADDR.Address[4],
1741 Bluetooth->BD_ADDR.Address[5]
1746 Converts a Wi-Fi device path structure to its string representative.
1748 @param Str The string representative of input device.
1749 @param DevPath The input device path structure.
1750 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1751 of the display node is used, where applicable. If DisplayOnly
1752 is FALSE, then the longer text representation of the display node
1754 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1755 representation for a device node can be used, where applicable.
1760 IN OUT POOL_PRINT *Str,
1762 IN BOOLEAN DisplayOnly,
1763 IN BOOLEAN AllowShortcuts
1766 WIFI_DEVICE_PATH *WiFi;
1772 CopyMem (SSId, WiFi->SSId, 32);
1774 UefiDevicePathLibCatPrint (Str, "Wi-Fi(%s)", SSId);
1778 Converts a Bluetooth device path structure to its string representative.
1780 @param Str The string representative of input device.
1781 @param DevPath The input device path structure.
1782 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1783 of the display node is used, where applicable. If DisplayOnly
1784 is FALSE, then the longer text representation of the display node
1786 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1787 representation for a device node can be used, where applicable.
1791 DevPathToTextBluetoothLE (
1792 IN OUT POOL_PRINT *Str,
1794 IN BOOLEAN DisplayOnly,
1795 IN BOOLEAN AllowShortcuts
1798 BLUETOOTH_LE_DEVICE_PATH *BluetoothLE;
1800 BluetoothLE = DevPath;
1801 UefiDevicePathLibCatPrint (
1803 "BluetoothLE(%02x%02x%02x%02x%02x%02x,0x%02x)",
1804 BluetoothLE->Address.Address[0],
1805 BluetoothLE->Address.Address[1],
1806 BluetoothLE->Address.Address[2],
1807 BluetoothLE->Address.Address[3],
1808 BluetoothLE->Address.Address[4],
1809 BluetoothLE->Address.Address[5],
1810 BluetoothLE->Address.Type
1815 Converts a DNS device path structure to its string representative.
1817 @param Str The string representative of input device.
1818 @param DevPath The input device path structure.
1819 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1820 of the display node is used, where applicable. If DisplayOnly
1821 is FALSE, then the longer text representation of the display node
1823 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1824 representation for a device node can be used, where applicable.
1829 IN OUT POOL_PRINT *Str,
1831 IN BOOLEAN DisplayOnly,
1832 IN BOOLEAN AllowShortcuts
1835 DNS_DEVICE_PATH *DnsDevPath;
1836 UINT32 DnsServerIpCount;
1837 UINT32 DnsServerIpIndex;
1839 DnsDevPath = DevPath;
1840 DnsServerIpCount = (UINT32)(DevicePathNodeLength (DnsDevPath) - sizeof (EFI_DEVICE_PATH_PROTOCOL) - sizeof (DnsDevPath->IsIPv6)) / sizeof (EFI_IP_ADDRESS);
1842 UefiDevicePathLibCatPrint (Str, "Dns(");
1844 for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; DnsServerIpIndex++) {
1845 if (DnsDevPath->IsIPv6 == 0x00) {
1846 CatIPv4Address (Str, &(DnsDevPath->DnsServerIp[DnsServerIpIndex].v4));
1848 CatIPv6Address (Str, &(DnsDevPath->DnsServerIp[DnsServerIpIndex].v6));
1851 if (DnsServerIpIndex < DnsServerIpCount - 1) {
1852 UefiDevicePathLibCatPrint (Str, ",");
1856 UefiDevicePathLibCatPrint (Str, ")");
1860 Converts a URI device path structure to its string representative.
1862 @param Str The string representative of input device.
1863 @param DevPath The input device path structure.
1864 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1865 of the display node is used, where applicable. If DisplayOnly
1866 is FALSE, then the longer text representation of the display node
1868 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1869 representation for a device node can be used, where applicable.
1874 IN OUT POOL_PRINT *Str,
1876 IN BOOLEAN DisplayOnly,
1877 IN BOOLEAN AllowShortcuts
1880 URI_DEVICE_PATH *Uri;
1885 // Uri in the device path may not be null terminated.
1888 UriLength = DevicePathNodeLength (Uri) - sizeof (URI_DEVICE_PATH);
1889 UriStr = AllocatePool (UriLength + 1);
1890 ASSERT (UriStr != NULL);
1892 CopyMem (UriStr, Uri->Uri, UriLength);
1893 UriStr[UriLength] = '\0';
1894 UefiDevicePathLibCatPrint (Str, "Uri(%s)", UriStr);
1899 Converts a Hard drive device path structure to its string representative.
1901 @param Str The string representative of input device.
1902 @param DevPath The input device path structure.
1903 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1904 of the display node is used, where applicable. If DisplayOnly
1905 is FALSE, then the longer text representation of the display node
1907 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1908 representation for a device node can be used, where applicable.
1912 DevPathToTextHardDrive (
1913 IN OUT POOL_PRINT *Str,
1915 IN BOOLEAN DisplayOnly,
1916 IN BOOLEAN AllowShortcuts
1919 HARDDRIVE_DEVICE_PATH *Hd;
1922 switch (Hd->SignatureType) {
1923 case SIGNATURE_TYPE_MBR:
1924 UefiDevicePathLibCatPrint (
1927 Hd->PartitionNumber,
1929 // *((UINT32 *)(&(Hd->Signature[0])))
1930 le32dec(&(Hd->Signature[0]))
1934 case SIGNATURE_TYPE_GUID:
1935 UefiDevicePathLibCatPrint (
1938 Hd->PartitionNumber,
1940 G(&(Hd->Signature[0]))
1945 UefiDevicePathLibCatPrint (
1948 Hd->PartitionNumber,
1954 UefiDevicePathLibCatPrint (Str, "0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);
1958 Converts a CDROM device path structure to its string representative.
1960 @param Str The string representative of input device.
1961 @param DevPath The input device path structure.
1962 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1963 of the display node is used, where applicable. If DisplayOnly
1964 is FALSE, then the longer text representation of the display node
1966 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1967 representation for a device node can be used, where applicable.
1971 DevPathToTextCDROM (
1972 IN OUT POOL_PRINT *Str,
1974 IN BOOLEAN DisplayOnly,
1975 IN BOOLEAN AllowShortcuts
1978 CDROM_DEVICE_PATH *Cd;
1982 UefiDevicePathLibCatPrint (Str, "CDROM(0x%x)", Cd->BootEntry);
1986 UefiDevicePathLibCatPrint (Str, "CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);
1990 Converts a File device path structure to its string representative.
1992 @param Str The string representative of input device.
1993 @param DevPath The input device path structure.
1994 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1995 of the display node is used, where applicable. If DisplayOnly
1996 is FALSE, then the longer text representation of the display node
1998 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1999 representation for a device node can be used, where applicable.
2003 DevPathToTextFilePath (
2004 IN OUT POOL_PRINT *Str,
2006 IN BOOLEAN DisplayOnly,
2007 IN BOOLEAN AllowShortcuts
2010 FILEPATH_DEVICE_PATH *Fp;
2014 ucs2_to_utf8(Fp->PathName, &name);
2015 UefiDevicePathLibCatPrint (Str, "File(%s)", name);
2020 Converts a Media protocol device path structure to its string representative.
2022 @param Str The string representative of input device.
2023 @param DevPath The input device path structure.
2024 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2025 of the display node is used, where applicable. If DisplayOnly
2026 is FALSE, then the longer text representation of the display node
2028 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2029 representation for a device node can be used, where applicable.
2033 DevPathToTextMediaProtocol (
2034 IN OUT POOL_PRINT *Str,
2036 IN BOOLEAN DisplayOnly,
2037 IN BOOLEAN AllowShortcuts
2040 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;
2042 MediaProt = DevPath;
2043 UefiDevicePathLibCatPrint (Str, "Media(%36s)", G(&MediaProt->Protocol));
2047 Converts a Firmware Volume device path structure to its string representative.
2049 @param Str The string representative of input device.
2050 @param DevPath The input device path structure.
2051 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2052 of the display node is used, where applicable. If DisplayOnly
2053 is FALSE, then the longer text representation of the display node
2055 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2056 representation for a device node can be used, where applicable.
2061 IN OUT POOL_PRINT *Str,
2063 IN BOOLEAN DisplayOnly,
2064 IN BOOLEAN AllowShortcuts
2067 MEDIA_FW_VOL_DEVICE_PATH *Fv;
2070 UefiDevicePathLibCatPrint (Str, "Fv(%36s)", G(&Fv->FvName));
2074 Converts a Firmware Volume File device path structure to its string representative.
2076 @param Str The string representative of input device.
2077 @param DevPath The input device path structure.
2078 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2079 of the display node is used, where applicable. If DisplayOnly
2080 is FALSE, then the longer text representation of the display node
2082 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2083 representation for a device node can be used, where applicable.
2087 DevPathToTextFvFile (
2088 IN OUT POOL_PRINT *Str,
2090 IN BOOLEAN DisplayOnly,
2091 IN BOOLEAN AllowShortcuts
2094 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;
2097 UefiDevicePathLibCatPrint (Str, "FvFile(%36s)", G(&FvFile->FvFileName));
2101 Converts a Relative Offset device path structure to its string representative.
2103 @param Str The string representative of input device.
2104 @param DevPath The input device path structure.
2105 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2106 of the display node is used, where applicable. If DisplayOnly
2107 is FALSE, then the longer text representation of the display node
2109 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2110 representation for a device node can be used, where applicable.
2114 DevPathRelativeOffsetRange (
2115 IN OUT POOL_PRINT *Str,
2117 IN BOOLEAN DisplayOnly,
2118 IN BOOLEAN AllowShortcuts
2121 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;
2124 UefiDevicePathLibCatPrint (
2126 "Offset(0x%lx,0x%lx)",
2127 Offset->StartingOffset,
2128 Offset->EndingOffset
2133 Converts a Ram Disk device path structure to its string representative.
2135 @param Str The string representative of input device.
2136 @param DevPath The input device path structure.
2137 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2138 of the display node is used, where applicable. If DisplayOnly
2139 is FALSE, then the longer text representation of the display node
2141 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2142 representation for a device node can be used, where applicable.
2146 DevPathToTextRamDisk (
2147 IN OUT POOL_PRINT *Str,
2149 IN BOOLEAN DisplayOnly,
2150 IN BOOLEAN AllowShortcuts
2153 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;
2157 if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid)) {
2158 UefiDevicePathLibCatPrint (
2160 "VirtualDisk(0x%lx,0x%lx,%d)",
2161 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2162 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2165 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid)) {
2166 UefiDevicePathLibCatPrint (
2168 "VirtualCD(0x%lx,0x%lx,%d)",
2169 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2170 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2173 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid)) {
2174 UefiDevicePathLibCatPrint (
2176 "PersistentVirtualDisk(0x%lx,0x%lx,%d)",
2177 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2178 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2181 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid)) {
2182 UefiDevicePathLibCatPrint (
2184 "PersistentVirtualCD(0x%lx,0x%lx,%d)",
2185 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2186 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2190 UefiDevicePathLibCatPrint (
2192 "RamDisk(0x%lx,0x%lx,%d,%36s)",
2193 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],
2194 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],
2196 G(&RamDisk->TypeGuid)
2202 Converts a BIOS Boot Specification device path structure to its string representative.
2204 @param Str The string representative of input device.
2205 @param DevPath The input device path structure.
2206 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2207 of the display node is used, where applicable. If DisplayOnly
2208 is FALSE, then the longer text representation of the display node
2210 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2211 representation for a device node can be used, where applicable.
2216 IN OUT POOL_PRINT *Str,
2218 IN BOOLEAN DisplayOnly,
2219 IN BOOLEAN AllowShortcuts
2222 BBS_BBS_DEVICE_PATH *Bbs;
2226 switch (Bbs->DeviceType) {
2227 case BBS_TYPE_FLOPPY:
2231 case BBS_TYPE_HARDDRIVE:
2235 case BBS_TYPE_CDROM:
2239 case BBS_TYPE_PCMCIA:
2247 case BBS_TYPE_EMBEDDED_NETWORK:
2257 UefiDevicePathLibCatPrint (Str, "BBS(%s,%s", Type, Bbs->String);
2259 UefiDevicePathLibCatPrint (Str, "BBS(0x%x,%s", Bbs->DeviceType, Bbs->String);
2263 UefiDevicePathLibCatPrint (Str, ")");
2267 UefiDevicePathLibCatPrint (Str, ",0x%x)", Bbs->StatusFlag);
2271 Converts an End-of-Device-Path structure to its string representative.
2273 @param Str The string representative of input device.
2274 @param DevPath The input device path structure.
2275 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2276 of the display node is used, where applicable. If DisplayOnly
2277 is FALSE, then the longer text representation of the display node
2279 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2280 representation for a device node can be used, where applicable.
2284 DevPathToTextEndInstance (
2285 IN OUT POOL_PRINT *Str,
2287 IN BOOLEAN DisplayOnly,
2288 IN BOOLEAN AllowShortcuts
2291 UefiDevicePathLibCatPrint (Str, ",");
2294 GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_GENERIC_TABLE mUefiDevicePathLibToTextTableGeneric[] = {
2295 { HARDWARE_DEVICE_PATH, "HardwarePath" },
2296 { ACPI_DEVICE_PATH, "AcpiPath" },
2297 { MESSAGING_DEVICE_PATH, "Msg" },
2298 { MEDIA_DEVICE_PATH, "MediaPath" },
2299 { BBS_DEVICE_PATH, "BbsPath" },
2304 Converts an unknown device path structure to its string representative.
2306 @param Str The string representative of input device.
2307 @param DevPath The input device path structure.
2308 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2309 of the display node is used, where applicable. If DisplayOnly
2310 is FALSE, then the longer text representation of the display node
2312 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2313 representation for a device node can be used, where applicable.
2317 DevPathToTextNodeGeneric (
2318 IN OUT POOL_PRINT *Str,
2320 IN BOOLEAN DisplayOnly,
2321 IN BOOLEAN AllowShortcuts
2324 EFI_DEVICE_PATH_PROTOCOL *Node;
2329 for (Index = 0; mUefiDevicePathLibToTextTableGeneric[Index].Text != NULL; Index++) {
2330 if (DevicePathType (Node) == mUefiDevicePathLibToTextTableGeneric[Index].Type) {
2335 if (mUefiDevicePathLibToTextTableGeneric[Index].Text == NULL) {
2337 // It's a node whose type cannot be recognized
2339 UefiDevicePathLibCatPrint (Str, "Path(%d,%d", DevicePathType (Node), DevicePathSubType (Node));
2342 // It's a node whose type can be recognized
2344 UefiDevicePathLibCatPrint (Str, "%s(%d", mUefiDevicePathLibToTextTableGeneric[Index].Text, DevicePathSubType (Node));
2347 Index = sizeof (EFI_DEVICE_PATH_PROTOCOL);
2348 if (Index < DevicePathNodeLength (Node)) {
2349 UefiDevicePathLibCatPrint (Str, ",");
2350 for ( ; Index < DevicePathNodeLength (Node); Index++) {
2351 UefiDevicePathLibCatPrint (Str, "%02x", ((UINT8 *)Node)[Index]);
2355 UefiDevicePathLibCatPrint (Str, ")");
2358 static const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = {
2359 { HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci },
2360 { HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard },
2361 { HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap },
2362 { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor },
2363 { HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController },
2364 { HARDWARE_DEVICE_PATH, HW_BMC_DP, DevPathToTextBmc },
2365 { ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi },
2366 { ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx },
2367 { ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr },
2368 { MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi },
2369 { MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi },
2370 { MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre },
2371 { MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx },
2372 { MESSAGING_DEVICE_PATH, MSG_SASEX_DP, DevPathToTextSasEx },
2373 { MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP, DevPathToTextNVMe },
2374 { MESSAGING_DEVICE_PATH, MSG_UFS_DP, DevPathToTextUfs },
2375 { MESSAGING_DEVICE_PATH, MSG_SD_DP, DevPathToTextSd },
2376 { MESSAGING_DEVICE_PATH, MSG_EMMC_DP, DevPathToTextEmmc },
2377 { MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394 },
2378 { MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb },
2379 { MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID },
2380 { MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit },
2381 { MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass },
2382 { MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata },
2383 { MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O },
2384 { MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr },
2385 { MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4 },
2386 { MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6 },
2387 { MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand },
2388 { MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart },
2389 { MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor },
2390 { MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI },
2391 { MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan },
2392 { MESSAGING_DEVICE_PATH, MSG_DNS_DP, DevPathToTextDns },
2393 { MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextUri },
2394 { MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextBluetooth },
2395 { MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextWiFi },
2396 { MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, DevPathToTextBluetoothLE },
2397 { MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive },
2398 { MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM },
2399 { MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor },
2400 { MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol },
2401 { MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath },
2402 { MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv },
2403 { MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile },
2404 { MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange },
2405 { MEDIA_DEVICE_PATH, MEDIA_RAM_DISK_DP, DevPathToTextRamDisk },
2406 { BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS },
2407 { END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance },
2412 Converts a device node to its string representation.
2414 @param DeviceNode A Pointer to the device node to be converted.
2415 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2416 of the display node is used, where applicable. If DisplayOnly
2417 is FALSE, then the longer text representation of the display node
2419 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2420 representation for a device node can be used, where applicable.
2422 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode
2423 is NULL or there was insufficient memory.
2428 UefiDevicePathLibConvertDeviceNodeToText (
2429 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
2430 IN BOOLEAN DisplayOnly,
2431 IN BOOLEAN AllowShortcuts
2436 DEVICE_PATH_TO_TEXT ToText;
2437 EFI_DEVICE_PATH_PROTOCOL *Node;
2439 if (DeviceNode == NULL) {
2443 ZeroMem (&Str, sizeof (Str));
2446 // Process the device path node
2447 // If not found, use a generic function
2449 Node = __DECONST(EFI_DEVICE_PATH_PROTOCOL *, DeviceNode);
2450 ToText = DevPathToTextNodeGeneric;
2451 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index++) {
2452 if ((DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type) &&
2453 (DevicePathSubType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].SubType)
2456 ToText = mUefiDevicePathLibToTextTable[Index].Function;
2464 ToText (&Str, (VOID *)Node, DisplayOnly, AllowShortcuts);
2466 ASSERT (Str.Str != NULL);
2471 Converts a device path to its text representation.
2473 @param DevicePath A Pointer to the device to be converted.
2474 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
2475 of the display node is used, where applicable. If DisplayOnly
2476 is FALSE, then the longer text representation of the display node
2478 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
2479 representation for a device node can be used, where applicable.
2481 @return A pointer to the allocated text representation of the device path or
2482 NULL if DeviceNode is NULL or there was insufficient memory.
2487 UefiDevicePathLibConvertDevicePathToText (
2488 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
2489 IN BOOLEAN DisplayOnly,
2490 IN BOOLEAN AllowShortcuts
2494 EFI_DEVICE_PATH_PROTOCOL *Node;
2495 EFI_DEVICE_PATH_PROTOCOL *AlignedNode;
2497 DEVICE_PATH_TO_TEXT ToText;
2499 if (DevicePath == NULL) {
2503 ZeroMem (&Str, sizeof (Str));
2506 // Process each device path node
2508 Node = __DECONST(EFI_DEVICE_PATH_PROTOCOL *, DevicePath);
2509 while (!IsDevicePathEnd (Node)) {
2511 // Find the handler to dump this device path node
2512 // If not found, use a generic function
2514 ToText = DevPathToTextNodeGeneric;
2515 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index += 1) {
2516 if ((DevicePathType (Node) == mUefiDevicePathLibToTextTable[Index].Type) &&
2517 (DevicePathSubType (Node) == mUefiDevicePathLibToTextTable[Index].SubType)
2520 ToText = mUefiDevicePathLibToTextTable[Index].Function;
2526 // Put a path separator in if needed
2528 if ((Str.Count != 0) && (ToText != DevPathToTextEndInstance)) {
2529 if (Str.Str[Str.Count] != ',') {
2530 UefiDevicePathLibCatPrint (&Str, "/");
2534 AlignedNode = AllocateCopyPool (DevicePathNodeLength (Node), Node);
2536 // Print this node of the device path
2538 ToText (&Str, AlignedNode, DisplayOnly, AllowShortcuts);
2539 FreePool (AlignedNode);
2542 // Next device path node
2544 Node = NextDevicePathNode (Node);
2547 if (Str.Str == NULL) {
2548 return AllocateZeroPool (sizeof (CHAR16));
2555 efidp_format_device_path(char *buf, size_t len, const_efidp dp, ssize_t max)
2561 * Basic sanity check on the device path.
2563 if (!IsDevicePathValid((CONST EFI_DEVICE_PATH_PROTOCOL *) dp, max)) {
2568 str = UefiDevicePathLibConvertDevicePathToText (
2569 __DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp), FALSE, TRUE);
2572 strlcpy(buf, str, len);
2573 retval = strlen(str);
2580 efidp_format_device_path_node(char *buf, size_t len, const_efidp dp)
2585 str = UefiDevicePathLibConvertDeviceNodeToText (
2586 __DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp), FALSE, TRUE);
2589 strlcpy(buf, str, len);
2590 retval = strlen(str);
2597 efidp_size(const_efidp dp)
2600 return GetDevicePathSize(__DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp));
2604 efidp_extract_file_path(const_efidp dp)
2606 const FILEPATH_DEVICE_PATH *fp;
2609 fp = (const void *)dp;
2610 ucs2_to_utf8(fp->PathName, &name);