3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 DevicePathToText protocol as defined in the UEFI 2.0 specification.
22 #include "DevicePath.h"
25 EFI_DEVICE_PATH_PROTOCOL
*
27 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
32 Function unpacks a device path data structure so that all the nodes of a device path
33 are naturally aligned.
36 DevPath - A pointer to a device path data structure
39 If the memory for the device path is successfully allocated, then a pointer to the
40 new device path is returned. Otherwise, NULL is returned.
44 EFI_DEVICE_PATH_PROTOCOL
*Src
;
45 EFI_DEVICE_PATH_PROTOCOL
*Dest
;
46 EFI_DEVICE_PATH_PROTOCOL
*NewPath
;
49 if (DevPath
== NULL
) {
53 // Walk device path and round sizes to valid boundries
58 Size
+= DevicePathNodeLength (Src
);
59 Size
+= ALIGN_SIZE (Size
);
61 if (IsDevicePathEnd (Src
)) {
65 Src
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (Src
);
68 // Allocate space for the unpacked path
70 NewPath
= AllocateZeroPool (Size
);
71 if (NewPath
!= NULL
) {
73 ASSERT (((UINTN
) NewPath
) % MIN_ALIGNMENT_SIZE
== 0);
81 Size
= DevicePathNodeLength (Src
);
82 CopyMem (Dest
, Src
, Size
);
83 Size
+= ALIGN_SIZE (Size
);
84 SetDevicePathNodeLength (Dest
, Size
);
85 Dest
->Type
|= EFI_DP_TYPE_UNPACKED
;
86 Dest
= (EFI_DEVICE_PATH_PROTOCOL
*) (((UINT8
*) Dest
) + Size
);
88 if (IsDevicePathEnd (Src
)) {
92 Src
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (Src
);
109 Adjusts the size of a previously allocated buffer.
112 OldPool - A pointer to the buffer whose size is being adjusted.
113 OldSize - The size of the current buffer.
114 NewSize - The size of the new buffer.
117 EFI_SUCEESS - The requested number of bytes were allocated.
118 EFI_OUT_OF_RESOURCES - The pool requested could not be allocated.
119 EFI_INVALID_PARAMETER - The buffer was invalid.
127 NewPool
= AllocateZeroPool (NewSize
);
132 CopyMem (NewPool
, OldPool
, OldSize
< NewSize
? OldSize
: NewSize
);
144 IN OUT POOL_PRINT
*Str
,
151 Concatenates a formatted unicode string to allocated pool.
152 The caller must free the resulting buffer.
155 Str - Tracks the allocated pool, size in use, and
156 amount of pool allocated.
157 Fmt - The format string
160 Allocated buffer with the formatted string printed in it.
161 The caller must free the allocated buffer. The buffer
162 allocation is not packed.
170 AppendStr
= AllocateZeroPool (0x1000);
171 if (AppendStr
== NULL
) {
175 VA_START (Args
, Fmt
);
176 UnicodeVSPrint (AppendStr
, 0x1000, Fmt
, Args
);
178 if (NULL
== Str
->Str
) {
179 Size
= StrSize (AppendStr
);
180 Str
->Str
= AllocateZeroPool (Size
);
181 ASSERT (Str
->Str
!= NULL
);
183 Size
= StrSize (AppendStr
) - sizeof (UINT16
);
184 Size
= Size
+ StrSize (Str
->Str
);
185 Str
->Str
= ReallocatePool (
190 ASSERT (Str
->Str
!= NULL
);
193 Str
->MaxLen
= MAX_CHAR
* sizeof (UINT16
);
194 if (Size
< Str
->MaxLen
) {
195 StrCat (Str
->Str
, AppendStr
);
196 Str
->Len
= Size
- sizeof (UINT16
);
199 FreePool (AppendStr
);
206 IN OUT POOL_PRINT
*Str
,
208 IN BOOLEAN DisplayOnly
,
209 IN BOOLEAN AllowShortcuts
212 PCI_DEVICE_PATH
*Pci
;
215 CatPrint (Str
, L
"Pci(0x%x,0x%x)", Pci
->Device
, Pci
->Function
);
220 DevPathToTextPccard (
221 IN OUT POOL_PRINT
*Str
,
223 IN BOOLEAN DisplayOnly
,
224 IN BOOLEAN AllowShortcuts
227 PCCARD_DEVICE_PATH
*Pccard
;
230 CatPrint (Str
, L
"PcCard(0x%x)", Pccard
->FunctionNumber
);
235 DevPathToTextMemMap (
236 IN OUT POOL_PRINT
*Str
,
238 IN BOOLEAN DisplayOnly
,
239 IN BOOLEAN AllowShortcuts
242 MEMMAP_DEVICE_PATH
*MemMap
;
247 L
"MemoryMapped(0x%x,0x%lx,0x%lx)",
249 MemMap
->StartingAddress
,
250 MemMap
->EndingAddress
256 DevPathToTextVendor (
257 IN OUT POOL_PRINT
*Str
,
259 IN BOOLEAN DisplayOnly
,
260 IN BOOLEAN AllowShortcuts
263 VENDOR_DEVICE_PATH
*Vendor
;
267 UINT32 FlowControlMap
;
270 Vendor
= (VENDOR_DEVICE_PATH
*) DevPath
;
271 switch (DevicePathType (&Vendor
->Header
)) {
272 case HARDWARE_DEVICE_PATH
:
276 case MESSAGING_DEVICE_PATH
:
278 if (AllowShortcuts
) {
279 if (CompareGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
)) {
280 CatPrint (Str
, L
"VenPcAnsi()");
282 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100Guid
)) {
283 CatPrint (Str
, L
"VenVt100()");
285 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
)) {
286 CatPrint (Str
, L
"VenVt100Plus()");
288 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
)) {
289 CatPrint (Str
, L
"VenUft8()");
291 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingUartFlowControlGuid
)) {
292 FlowControlMap
= (((UART_FLOW_CONTROL_DEVICE_PATH
*) Vendor
)->FlowControlMap
);
293 switch (FlowControlMap
& 0x00000003) {
295 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"None");
299 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"Hardware");
303 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"XonXoff");
311 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingSASGuid
)) {
314 L
"SAS(0x%lx,0x%lx,0x%x,",
315 ((SAS_DEVICE_PATH
*) Vendor
)->SasAddress
,
316 ((SAS_DEVICE_PATH
*) Vendor
)->Lun
,
317 ((SAS_DEVICE_PATH
*) Vendor
)->RelativeTargetPort
319 Info
= (((SAS_DEVICE_PATH
*) Vendor
)->DeviceTopology
);
320 if ((Info
& 0x0f) == 0) {
321 CatPrint (Str
, L
"NoTopology,0,0,0,");
322 } else if (((Info
& 0x0f) == 1) || ((Info
& 0x0f) == 2)) {
326 (Info
& (0x1 << 4)) ? L
"SATA" : L
"SAS",
327 (Info
& (0x1 << 5)) ? L
"External" : L
"Internal",
328 (Info
& (0x1 << 6)) ? L
"Expanded" : L
"Direct"
330 if ((Info
& 0x0f) == 1) {
331 CatPrint (Str
, L
"0,");
333 CatPrint (Str
, L
"0x%x,", (Info
>> 8) & 0xff);
336 CatPrint (Str
, L
"0,0,0,0,");
339 CatPrint (Str
, L
"0x%x)", ((SAS_DEVICE_PATH
*) Vendor
)->Reserved
);
341 } else if (CompareGuid (&Vendor
->Guid
, &gEfiDebugPortProtocolGuid
)) {
342 CatPrint (Str
, L
"DebugPort()");
348 case MEDIA_DEVICE_PATH
:
357 DataLength
= DevicePathNodeLength (&Vendor
->Header
) - sizeof (VENDOR_DEVICE_PATH
);
358 CatPrint (Str
, L
"Ven%s(%g", Type
, &Vendor
->Guid
);
359 if (DataLength
!= 0) {
360 CatPrint (Str
, L
",");
361 for (Index
= 0; Index
< DataLength
; Index
++) {
362 CatPrint (Str
, L
"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA
*) Vendor
)->VendorDefinedData
[Index
]);
366 CatPrint (Str
, L
")");
371 DevPathToTextController (
372 IN OUT POOL_PRINT
*Str
,
374 IN BOOLEAN DisplayOnly
,
375 IN BOOLEAN AllowShortcuts
378 CONTROLLER_DEVICE_PATH
*Controller
;
380 Controller
= DevPath
;
384 Controller
->ControllerNumber
391 IN OUT POOL_PRINT
*Str
,
393 IN BOOLEAN DisplayOnly
,
394 IN BOOLEAN AllowShortcuts
397 ACPI_HID_DEVICE_PATH
*Acpi
;
400 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
401 switch (EISA_ID_TO_NUM (Acpi
->HID
)) {
403 CatPrint (Str
, L
"PciRoot(0x%x)", Acpi
->UID
);
407 CatPrint (Str
, L
"Floppy(0x%x)", Acpi
->UID
);
411 CatPrint (Str
, L
"Keyboard(0x%x)", Acpi
->UID
);
415 CatPrint (Str
, L
"Serial(0x%x)", Acpi
->UID
);
419 CatPrint (Str
, L
"ParallelPort(0x%x)", Acpi
->UID
);
423 CatPrint (Str
, L
"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi
->HID
), Acpi
->UID
);
427 CatPrint (Str
, L
"Acpi(0x%08x,0x%x)", Acpi
->HID
, Acpi
->UID
);
441 //UnicodeSPrint ("%X", 0x0a03) => "0000000000000A03"
443 UnicodeSPrint (PnpIdStr
, 17 * 2, L
"%X", EisaId
>> 16);
449 '@' + ((EisaId
>> 10) & 0x1f),
450 '@' + ((EisaId
>> 5) & 0x1f),
451 '@' + ((EisaId
>> 0) & 0x1f),
458 DevPathToTextAcpiEx (
459 IN OUT POOL_PRINT
*Str
,
461 IN BOOLEAN DisplayOnly
,
462 IN BOOLEAN AllowShortcuts
465 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
473 HIDStr
= (CHAR8
*) (((UINT8
*) AcpiEx
) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
474 UIDStr
= HIDStr
+ AsciiStrLen (HIDStr
) + 1;
475 CIDStr
= UIDStr
+ AsciiStrLen (UIDStr
) + 1;
477 EisaIdToText (AcpiEx
->HID
, HIDText
);
478 EisaIdToText (AcpiEx
->CID
, CIDText
);
480 if ((*HIDStr
== '\0') && (*CIDStr
== '\0') && (AcpiEx
->UID
== 0)) {
486 L
"AcpiExp(%s,%s,%a)",
492 if (AllowShortcuts
) {
496 if (AcpiEx
->HID
== 0) {
497 CatPrint (Str
, L
"AcpiEx(%a,", HIDStr
);
499 CatPrint (Str
, L
"AcpiEx(%s,", HIDText
);
502 if (AcpiEx
->UID
== 0) {
503 CatPrint (Str
, L
"%a,", UIDStr
);
505 CatPrint (Str
, L
"0x%x,", AcpiEx
->UID
);
508 if (AcpiEx
->CID
== 0) {
509 CatPrint (Str
, L
"%a)", CIDStr
);
511 CatPrint (Str
, L
"%s)", CIDText
);
516 L
"AcpiEx(%s,%s,0x%x,%a,%a,%a)",
530 DevPathToTextAcpiAdr (
531 IN OUT POOL_PRINT
*Str
,
533 IN BOOLEAN DisplayOnly
,
534 IN BOOLEAN AllowShortcuts
537 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
540 UINT16 AdditionalAdrCount
;
543 Length
= (UINT16
) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
);
544 AdditionalAdrCount
= (UINT16
) ((Length
- 8) / 4);
546 CatPrint (Str
, L
"AcpiAdr(0x%x", AcpiAdr
->ADR
);
547 for (Index
= 0; Index
< AdditionalAdrCount
; Index
++) {
548 CatPrint (Str
, L
",0x%x", *(UINT32
*) ((UINT8
*) AcpiAdr
+ 8 + Index
* 4));
550 CatPrint (Str
, L
")");
556 IN OUT POOL_PRINT
*Str
,
558 IN BOOLEAN DisplayOnly
,
559 IN BOOLEAN AllowShortcuts
562 ATAPI_DEVICE_PATH
*Atapi
;
567 CatPrint (Str
, L
"Ata(0x%x)", Atapi
->Lun
);
572 Atapi
->PrimarySecondary
? L
"Secondary" : L
"Primary",
573 Atapi
->SlaveMaster
? L
"Slave" : L
"Master",
582 IN OUT POOL_PRINT
*Str
,
584 IN BOOLEAN DisplayOnly
,
585 IN BOOLEAN AllowShortcuts
588 SCSI_DEVICE_PATH
*Scsi
;
591 CatPrint (Str
, L
"Scsi(0x%x,0x%x)", Scsi
->Pun
, Scsi
->Lun
);
597 IN OUT POOL_PRINT
*Str
,
599 IN BOOLEAN DisplayOnly
,
600 IN BOOLEAN AllowShortcuts
603 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
606 CatPrint (Str
, L
"Fibre(0x%lx,0x%lx)", Fibre
->WWN
, Fibre
->Lun
);
612 IN OUT POOL_PRINT
*Str
,
614 IN BOOLEAN DisplayOnly
,
615 IN BOOLEAN AllowShortcuts
618 F1394_DEVICE_PATH
*F1394
;
622 // Guid has format of IEEE-EUI64
624 CatPrint (Str
, L
"I1394(%016lx)", F1394
->Guid
);
630 IN OUT POOL_PRINT
*Str
,
632 IN BOOLEAN DisplayOnly
,
633 IN BOOLEAN AllowShortcuts
636 USB_DEVICE_PATH
*Usb
;
639 CatPrint (Str
, L
"USB(0x%x,0x%x)", Usb
->ParentPortNumber
, Usb
->InterfaceNumber
);
644 DevPathToTextUsbWWID (
645 IN OUT POOL_PRINT
*Str
,
647 IN BOOLEAN DisplayOnly
,
648 IN BOOLEAN AllowShortcuts
651 USB_WWID_DEVICE_PATH
*UsbWWId
;
652 CHAR16
*SerialNumberStr
;
658 SerialNumberStr
= (CHAR16
*) ((UINT8
*) UsbWWId
+ sizeof (USB_WWID_DEVICE_PATH
));
659 Length
= (UINT16
) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) UsbWWId
) - sizeof (USB_WWID_DEVICE_PATH
)) / sizeof (CHAR16
));
660 if (SerialNumberStr
[Length
- 1] != 0) {
662 // In case no NULL terminator in SerialNumber, create a new one with NULL terminator
664 NewStr
= AllocateCopyPool ((Length
+ 1) * sizeof (CHAR16
), SerialNumberStr
);
666 SerialNumberStr
= NewStr
;
671 L
"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",
674 UsbWWId
->InterfaceNumber
,
681 DevPathToTextLogicalUnit (
682 IN OUT POOL_PRINT
*Str
,
684 IN BOOLEAN DisplayOnly
,
685 IN BOOLEAN AllowShortcuts
688 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
690 LogicalUnit
= DevPath
;
691 CatPrint (Str
, L
"Unit(0x%x)", LogicalUnit
->Lun
);
696 DevPathToTextUsbClass (
697 IN OUT POOL_PRINT
*Str
,
699 IN BOOLEAN DisplayOnly
,
700 IN BOOLEAN AllowShortcuts
703 USB_CLASS_DEVICE_PATH
*UsbClass
;
704 BOOLEAN IsKnownSubClass
;
709 IsKnownSubClass
= TRUE
;
710 switch (UsbClass
->DeviceClass
) {
711 case USB_CLASS_AUDIO
:
712 CatPrint (Str
, L
"UsbAudio");
715 case USB_CLASS_CDCCONTROL
:
716 CatPrint (Str
, L
"UsbCDCControl");
720 CatPrint (Str
, L
"UsbHID");
723 case USB_CLASS_IMAGE
:
724 CatPrint (Str
, L
"UsbImage");
727 case USB_CLASS_PRINTER
:
728 CatPrint (Str
, L
"UsbPrinter");
731 case USB_CLASS_MASS_STORAGE
:
732 CatPrint (Str
, L
"UsbMassStorage");
736 CatPrint (Str
, L
"UsbHub");
739 case USB_CLASS_CDCDATA
:
740 CatPrint (Str
, L
"UsbCDCData");
743 case USB_CLASS_SMART_CARD
:
744 CatPrint (Str
, L
"UsbSmartCard");
747 case USB_CLASS_VIDEO
:
748 CatPrint (Str
, L
"UsbVideo");
751 case USB_CLASS_DIAGNOSTIC
:
752 CatPrint (Str
, L
"UsbDiagnostic");
755 case USB_CLASS_WIRELESS
:
756 CatPrint (Str
, L
"UsbWireless");
760 IsKnownSubClass
= FALSE
;
764 if (IsKnownSubClass
) {
767 L
"(0x%x,0x%x,0x%x,0x%x)",
770 UsbClass
->DeviceSubClass
,
771 UsbClass
->DeviceProtocol
776 if (UsbClass
->DeviceClass
== USB_CLASS_RESERVE
) {
777 if (UsbClass
->DeviceSubClass
== USB_SUBCLASS_FW_UPDATE
) {
780 L
"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",
783 UsbClass
->DeviceProtocol
786 } else if (UsbClass
->DeviceSubClass
== USB_SUBCLASS_IRDA_BRIDGE
) {
789 L
"UsbIrdaBridge(0x%x,0x%x,0x%x)",
792 UsbClass
->DeviceProtocol
795 } else if (UsbClass
->DeviceSubClass
== USB_SUBCLASS_TEST
) {
798 L
"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",
801 UsbClass
->DeviceProtocol
809 L
"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",
812 UsbClass
->DeviceClass
,
813 UsbClass
->DeviceSubClass
,
814 UsbClass
->DeviceProtocol
821 IN OUT POOL_PRINT
*Str
,
823 IN BOOLEAN DisplayOnly
,
824 IN BOOLEAN AllowShortcuts
827 SATA_DEVICE_PATH
*Sata
;
832 L
"Sata(0x%x,0x%x,0x%x)",
833 (UINTN
) Sata
->HBAPortNumber
,
834 (UINTN
) Sata
->PortMultiplierPortNumber
,
842 IN OUT POOL_PRINT
*Str
,
844 IN BOOLEAN DisplayOnly
,
845 IN BOOLEAN AllowShortcuts
848 I2O_DEVICE_PATH
*I2O
;
851 CatPrint (Str
, L
"I2O(0x%x)", I2O
->Tid
);
856 DevPathToTextMacAddr (
857 IN OUT POOL_PRINT
*Str
,
859 IN BOOLEAN DisplayOnly
,
860 IN BOOLEAN AllowShortcuts
863 MAC_ADDR_DEVICE_PATH
*MAC
;
869 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
870 if (MAC
->IfType
== 0x01 || MAC
->IfType
== 0x00) {
874 CatPrint (Str
, L
"MAC(");
876 for (Index
= 0; Index
< HwAddressSize
; Index
++) {
877 CatPrint (Str
, L
"%02x", MAC
->MacAddress
.Addr
[Index
]);
880 CatPrint (Str
, L
",0x%x)", MAC
->IfType
);
886 IN OUT POOL_PRINT
*Str
,
888 IN BOOLEAN DisplayOnly
,
889 IN BOOLEAN AllowShortcuts
892 IPv4_DEVICE_PATH
*IP
;
895 if (DisplayOnly
== TRUE
) {
898 L
"IPv4(%d.%d.%d.%d)",
899 IP
->RemoteIpAddress
.Addr
[0],
900 IP
->RemoteIpAddress
.Addr
[1],
901 IP
->RemoteIpAddress
.Addr
[2],
902 IP
->RemoteIpAddress
.Addr
[3]
909 L
"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",
910 IP
->RemoteIpAddress
.Addr
[0],
911 IP
->RemoteIpAddress
.Addr
[1],
912 IP
->RemoteIpAddress
.Addr
[2],
913 IP
->RemoteIpAddress
.Addr
[3],
914 IP
->Protocol
? L
"TCP" : L
"UDP",
915 (IP
->StaticIpAddress
== TRUE
) ? L
"Static" : L
"DHCP",
916 IP
->LocalIpAddress
.Addr
[0],
917 IP
->LocalIpAddress
.Addr
[1],
918 IP
->LocalIpAddress
.Addr
[2],
919 IP
->LocalIpAddress
.Addr
[3]
926 IN OUT POOL_PRINT
*Str
,
928 IN BOOLEAN DisplayOnly
,
929 IN BOOLEAN AllowShortcuts
932 IPv6_DEVICE_PATH
*IP
;
935 if (DisplayOnly
== TRUE
) {
938 L
"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
939 IP
->RemoteIpAddress
.Addr
[0],
940 IP
->RemoteIpAddress
.Addr
[1],
941 IP
->RemoteIpAddress
.Addr
[2],
942 IP
->RemoteIpAddress
.Addr
[3],
943 IP
->RemoteIpAddress
.Addr
[4],
944 IP
->RemoteIpAddress
.Addr
[5],
945 IP
->RemoteIpAddress
.Addr
[6],
946 IP
->RemoteIpAddress
.Addr
[7],
947 IP
->RemoteIpAddress
.Addr
[8],
948 IP
->RemoteIpAddress
.Addr
[9],
949 IP
->RemoteIpAddress
.Addr
[10],
950 IP
->RemoteIpAddress
.Addr
[11],
951 IP
->RemoteIpAddress
.Addr
[12],
952 IP
->RemoteIpAddress
.Addr
[13],
953 IP
->RemoteIpAddress
.Addr
[14],
954 IP
->RemoteIpAddress
.Addr
[15]
961 L
"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,%s,%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
962 IP
->RemoteIpAddress
.Addr
[0],
963 IP
->RemoteIpAddress
.Addr
[1],
964 IP
->RemoteIpAddress
.Addr
[2],
965 IP
->RemoteIpAddress
.Addr
[3],
966 IP
->RemoteIpAddress
.Addr
[4],
967 IP
->RemoteIpAddress
.Addr
[5],
968 IP
->RemoteIpAddress
.Addr
[6],
969 IP
->RemoteIpAddress
.Addr
[7],
970 IP
->RemoteIpAddress
.Addr
[8],
971 IP
->RemoteIpAddress
.Addr
[9],
972 IP
->RemoteIpAddress
.Addr
[10],
973 IP
->RemoteIpAddress
.Addr
[11],
974 IP
->RemoteIpAddress
.Addr
[12],
975 IP
->RemoteIpAddress
.Addr
[13],
976 IP
->RemoteIpAddress
.Addr
[14],
977 IP
->RemoteIpAddress
.Addr
[15],
978 IP
->Protocol
? L
"TCP" : L
"UDP",
979 (IP
->StaticIpAddress
== TRUE
) ? L
"Static" : L
"DHCP",
980 IP
->LocalIpAddress
.Addr
[0],
981 IP
->LocalIpAddress
.Addr
[1],
982 IP
->LocalIpAddress
.Addr
[2],
983 IP
->LocalIpAddress
.Addr
[3],
984 IP
->LocalIpAddress
.Addr
[4],
985 IP
->LocalIpAddress
.Addr
[5],
986 IP
->LocalIpAddress
.Addr
[6],
987 IP
->LocalIpAddress
.Addr
[7],
988 IP
->LocalIpAddress
.Addr
[8],
989 IP
->LocalIpAddress
.Addr
[9],
990 IP
->LocalIpAddress
.Addr
[10],
991 IP
->LocalIpAddress
.Addr
[11],
992 IP
->LocalIpAddress
.Addr
[12],
993 IP
->LocalIpAddress
.Addr
[13],
994 IP
->LocalIpAddress
.Addr
[14],
995 IP
->LocalIpAddress
.Addr
[15]
1001 DevPathToTextInfiniBand (
1002 IN OUT POOL_PRINT
*Str
,
1004 IN BOOLEAN DisplayOnly
,
1005 IN BOOLEAN AllowShortcuts
1008 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1010 InfiniBand
= DevPath
;
1013 L
"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",
1014 InfiniBand
->ResourceFlags
,
1015 InfiniBand
->PortGid
,
1016 InfiniBand
->ServiceId
,
1017 InfiniBand
->TargetPortId
,
1018 InfiniBand
->DeviceId
1025 IN OUT POOL_PRINT
*Str
,
1027 IN BOOLEAN DisplayOnly
,
1028 IN BOOLEAN AllowShortcuts
1031 UART_DEVICE_PATH
*Uart
;
1035 switch (Uart
->Parity
) {
1065 if (Uart
->BaudRate
== 0) {
1066 CatPrint (Str
, L
"Uart(DEFAULT,");
1068 CatPrint (Str
, L
"Uart(%ld,", Uart
->BaudRate
);
1071 if (Uart
->DataBits
== 0) {
1072 CatPrint (Str
, L
"DEFAULT,");
1074 CatPrint (Str
, L
"%d,", Uart
->DataBits
);
1077 CatPrint (Str
, L
"%c,", Parity
);
1079 switch (Uart
->StopBits
) {
1081 CatPrint (Str
, L
"D)");
1085 CatPrint (Str
, L
"1)");
1089 CatPrint (Str
, L
"1.5)");
1093 CatPrint (Str
, L
"2)");
1097 CatPrint (Str
, L
"x)");
1104 DevPathToTextiSCSI (
1105 IN OUT POOL_PRINT
*Str
,
1107 IN BOOLEAN DisplayOnly
,
1108 IN BOOLEAN AllowShortcuts
1111 ISCSI_DEVICE_PATH_WITH_NAME
*iSCSI
;
1117 L
"iSCSI(%a,0x%x,0x%lx,",
1118 iSCSI
->iSCSITargetName
,
1119 iSCSI
->TargetPortalGroupTag
,
1123 Options
= iSCSI
->LoginOption
;
1124 CatPrint (Str
, L
"%s,", ((Options
>> 1) & 0x0001) ? L
"CRC32C" : L
"None");
1125 CatPrint (Str
, L
"%s,", ((Options
>> 3) & 0x0001) ? L
"CRC32C" : L
"None");
1126 if ((Options
>> 11) & 0x0001) {
1127 CatPrint (Str
, L
"%s,", L
"None");
1128 } else if ((Options
>> 12) & 0x0001) {
1129 CatPrint (Str
, L
"%s,", L
"CHAP_UNI");
1131 CatPrint (Str
, L
"%s,", L
"CHAP_BI");
1135 CatPrint (Str
, L
"%s)", (iSCSI
->NetworkProtocol
== 0) ? L
"TCP" : L
"reserved");
1140 DevPathToTextHardDrive (
1141 IN OUT POOL_PRINT
*Str
,
1143 IN BOOLEAN DisplayOnly
,
1144 IN BOOLEAN AllowShortcuts
1147 HARDDRIVE_DEVICE_PATH
*Hd
;
1150 switch (Hd
->SignatureType
) {
1151 case SIGNATURE_TYPE_MBR
:
1154 L
"HD(%d,%s,0x%08x,",
1155 Hd
->PartitionNumber
,
1157 *((UINT32
*) (&(Hd
->Signature
[0])))
1161 case SIGNATURE_TYPE_GUID
:
1165 Hd
->PartitionNumber
,
1167 (EFI_GUID
*) &(Hd
->Signature
[0])
1175 Hd
->PartitionNumber
,
1181 CatPrint (Str
, L
"0x%lx,0x%lx)", Hd
->PartitionStart
, Hd
->PartitionSize
);
1186 DevPathToTextCDROM (
1187 IN OUT POOL_PRINT
*Str
,
1189 IN BOOLEAN DisplayOnly
,
1190 IN BOOLEAN AllowShortcuts
1193 CDROM_DEVICE_PATH
*Cd
;
1196 if (DisplayOnly
== TRUE
) {
1197 CatPrint (Str
, L
"CDROM(0x%x)", Cd
->BootEntry
);
1201 CatPrint (Str
, L
"CDROM(0x%x,0x%lx,0x%lx)", Cd
->BootEntry
, Cd
->PartitionStart
, Cd
->PartitionSize
);
1206 DevPathToTextFilePath (
1207 IN OUT POOL_PRINT
*Str
,
1209 IN BOOLEAN DisplayOnly
,
1210 IN BOOLEAN AllowShortcuts
1213 FILEPATH_DEVICE_PATH
*Fp
;
1216 CatPrint (Str
, L
"%s", Fp
->PathName
);
1221 DevPathToTextMediaProtocol (
1222 IN OUT POOL_PRINT
*Str
,
1224 IN BOOLEAN DisplayOnly
,
1225 IN BOOLEAN AllowShortcuts
1228 MEDIA_PROTOCOL_DEVICE_PATH
*MediaProt
;
1230 MediaProt
= DevPath
;
1231 CatPrint (Str
, L
"Media(%g)", &MediaProt
->Protocol
);
1237 IN OUT POOL_PRINT
*Str
,
1239 IN BOOLEAN DisplayOnly
,
1240 IN BOOLEAN AllowShortcuts
1243 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
1246 CatPrint (Str
, L
"Fv(%g)", &Fv
->FvName
);
1251 DevPathToTextFvFile (
1252 IN OUT POOL_PRINT
*Str
,
1254 IN BOOLEAN DisplayOnly
,
1255 IN BOOLEAN AllowShortcuts
1258 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
1261 CatPrint (Str
, L
"FvFile(%g)", &FvFile
->FvFileName
);
1267 IN OUT POOL_PRINT
*Str
,
1269 IN BOOLEAN DisplayOnly
,
1270 IN BOOLEAN AllowShortcuts
1273 BBS_BBS_DEVICE_PATH
*Bbs
;
1277 switch (Bbs
->DeviceType
) {
1278 case BBS_TYPE_FLOPPY
:
1282 case BBS_TYPE_HARDDRIVE
:
1286 case BBS_TYPE_CDROM
:
1290 case BBS_TYPE_PCMCIA
:
1298 case BBS_TYPE_EMBEDDED_NETWORK
:
1308 CatPrint (Str
, L
"BBS(%s,%a", Type
, Bbs
->String
);
1310 CatPrint (Str
, L
"BBS(0x%x,%a", Bbs
->DeviceType
, Bbs
->String
);
1313 if (DisplayOnly
== TRUE
) {
1314 CatPrint (Str
, L
")");
1318 CatPrint (Str
, L
",0x%x)", Bbs
->StatusFlag
);
1323 DevPathToTextEndInstance (
1324 IN OUT POOL_PRINT
*Str
,
1326 IN BOOLEAN DisplayOnly
,
1327 IN BOOLEAN AllowShortcuts
1330 CatPrint (Str
, L
",");
1335 DevPathToTextNodeUnknown (
1336 IN OUT POOL_PRINT
*Str
,
1338 IN BOOLEAN DisplayOnly
,
1339 IN BOOLEAN AllowShortcuts
1342 CatPrint (Str
, L
"?");
1345 GLOBAL_REMOVE_IF_UNREFERENCED
const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable
[] = {
1346 {HARDWARE_DEVICE_PATH
, HW_PCI_DP
, DevPathToTextPci
},
1347 {HARDWARE_DEVICE_PATH
, HW_PCCARD_DP
, DevPathToTextPccard
},
1348 {HARDWARE_DEVICE_PATH
, HW_MEMMAP_DP
, DevPathToTextMemMap
},
1349 {HARDWARE_DEVICE_PATH
, HW_VENDOR_DP
, DevPathToTextVendor
},
1350 {HARDWARE_DEVICE_PATH
, HW_CONTROLLER_DP
, DevPathToTextController
},
1351 {ACPI_DEVICE_PATH
, ACPI_DP
, DevPathToTextAcpi
},
1352 {ACPI_DEVICE_PATH
, ACPI_EXTENDED_DP
, DevPathToTextAcpiEx
},
1353 {ACPI_DEVICE_PATH
, ACPI_ADR_DP
, DevPathToTextAcpiAdr
},
1354 {MESSAGING_DEVICE_PATH
, MSG_ATAPI_DP
, DevPathToTextAtapi
},
1355 {MESSAGING_DEVICE_PATH
, MSG_SCSI_DP
, DevPathToTextScsi
},
1356 {MESSAGING_DEVICE_PATH
, MSG_FIBRECHANNEL_DP
, DevPathToTextFibre
},
1357 {MESSAGING_DEVICE_PATH
, MSG_1394_DP
, DevPathToText1394
},
1358 {MESSAGING_DEVICE_PATH
, MSG_USB_DP
, DevPathToTextUsb
},
1359 {MESSAGING_DEVICE_PATH
, MSG_USB_WWID_DP
, DevPathToTextUsbWWID
},
1360 {MESSAGING_DEVICE_PATH
, MSG_DEVICE_LOGICAL_UNIT_DP
, DevPathToTextLogicalUnit
},
1361 {MESSAGING_DEVICE_PATH
, MSG_USB_CLASS_DP
, DevPathToTextUsbClass
},
1362 {MESSAGING_DEVICE_PATH
, MSG_SATA_DP
, DevPathToTextSata
},
1363 {MESSAGING_DEVICE_PATH
, MSG_I2O_DP
, DevPathToTextI2O
},
1364 {MESSAGING_DEVICE_PATH
, MSG_MAC_ADDR_DP
, DevPathToTextMacAddr
},
1365 {MESSAGING_DEVICE_PATH
, MSG_IPv4_DP
, DevPathToTextIPv4
},
1366 {MESSAGING_DEVICE_PATH
, MSG_IPv6_DP
, DevPathToTextIPv6
},
1367 {MESSAGING_DEVICE_PATH
, MSG_INFINIBAND_DP
, DevPathToTextInfiniBand
},
1368 {MESSAGING_DEVICE_PATH
, MSG_UART_DP
, DevPathToTextUart
},
1369 {MESSAGING_DEVICE_PATH
, MSG_VENDOR_DP
, DevPathToTextVendor
},
1370 {MESSAGING_DEVICE_PATH
, MSG_ISCSI_DP
, DevPathToTextiSCSI
},
1371 {MEDIA_DEVICE_PATH
, MEDIA_HARDDRIVE_DP
, DevPathToTextHardDrive
},
1372 {MEDIA_DEVICE_PATH
, MEDIA_CDROM_DP
, DevPathToTextCDROM
},
1373 {MEDIA_DEVICE_PATH
, MEDIA_VENDOR_DP
, DevPathToTextVendor
},
1374 {MEDIA_DEVICE_PATH
, MEDIA_FILEPATH_DP
, DevPathToTextFilePath
},
1375 {MEDIA_DEVICE_PATH
, MEDIA_PROTOCOL_DP
, DevPathToTextMediaProtocol
},
1376 {MEDIA_DEVICE_PATH
, MEDIA_FILEPATH_DP
, DevPathToTextFilePath
},
1377 {MEDIA_DEVICE_PATH
, MEDIA_PIWG_FW_VOL_DP
, DevPathToTextFv
},
1378 {MEDIA_DEVICE_PATH
, MEDIA_PIWG_FW_FILE_DP
, DevPathToTextFvFile
},
1379 {BBS_DEVICE_PATH
, BBS_BBS_DP
, DevPathToTextBBS
},
1380 {END_DEVICE_PATH_TYPE
, END_INSTANCE_DEVICE_PATH_SUBTYPE
, DevPathToTextEndInstance
},
1385 ConvertDeviceNodeToText (
1386 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
1387 IN BOOLEAN DisplayOnly
,
1388 IN BOOLEAN AllowShortcuts
1392 Routine Description:
1393 Convert a device node to its text representation.
1396 DeviceNode - Points to the device node to be converted.
1397 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
1398 of the display node is used, where applicable. If DisplayOnly
1399 is FALSE, then the longer text representation of the display node
1401 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
1402 representation for a device node can be used, where applicable.
1405 A pointer - a pointer to the allocated text representation of the device node.
1406 NULL - if DeviceNode is NULL or there was insufficient memory.
1413 VOID (*DumpNode
)(POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
1415 if (DeviceNode
== NULL
) {
1419 ZeroMem (&Str
, sizeof (Str
));
1422 // Process the device path node
1425 for (Index
= 0; DevPathToTextTable
[Index
].Function
!= NULL
; Index
++) {
1426 if (DevicePathType (DeviceNode
) == DevPathToTextTable
[Index
].Type
&&
1427 DevicePathSubType (DeviceNode
) == DevPathToTextTable
[Index
].SubType
1429 DumpNode
= DevPathToTextTable
[Index
].Function
;
1434 // If not found, use a generic function
1436 if (DumpNode
== NULL
) {
1437 DumpNode
= DevPathToTextNodeUnknown
;
1443 DumpNode (&Str
, (VOID
*) DeviceNode
, DisplayOnly
, AllowShortcuts
);
1446 // Shrink pool used for string allocation
1448 NewSize
= (Str
.Len
+ 1) * sizeof (CHAR16
);
1449 Str
.Str
= ReallocatePool (Str
.Str
, NewSize
, NewSize
);
1450 ASSERT (Str
.Str
!= NULL
);
1451 Str
.Str
[Str
.Len
] = 0;
1456 ConvertDevicePathToText (
1457 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1458 IN BOOLEAN DisplayOnly
,
1459 IN BOOLEAN AllowShortcuts
1463 Routine Description:
1464 Convert a device path to its text representation.
1467 DeviceNode - Points to the device path to be converted.
1468 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
1469 of the display node is used, where applicable. If DisplayOnly
1470 is FALSE, then the longer text representation of the display node
1472 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
1473 representation for a device node can be used, where applicable.
1476 A pointer - a pointer to the allocated text representation of the device path.
1477 NULL - if DeviceNode is NULL or there was insufficient memory.
1482 EFI_DEVICE_PATH_PROTOCOL
*DevPathNode
;
1483 EFI_DEVICE_PATH_PROTOCOL
*UnpackDevPath
;
1486 VOID (*DumpNode
) (POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
1488 if (DevicePath
== NULL
) {
1492 ZeroMem (&Str
, sizeof (Str
));
1495 // Unpacked the device path
1497 UnpackDevPath
= UnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL
*) DevicePath
);
1498 ASSERT (UnpackDevPath
!= NULL
);
1501 // Process each device path node
1503 DevPathNode
= UnpackDevPath
;
1504 while (!IsDevicePathEnd (DevPathNode
)) {
1506 // Find the handler to dump this device path node
1509 for (Index
= 0; DevPathToTextTable
[Index
].Function
; Index
+= 1) {
1511 if (DevicePathType (DevPathNode
) == DevPathToTextTable
[Index
].Type
&&
1512 DevicePathSubType (DevPathNode
) == DevPathToTextTable
[Index
].SubType
1514 DumpNode
= DevPathToTextTable
[Index
].Function
;
1519 // If not found, use a generic function
1522 DumpNode
= DevPathToTextNodeUnknown
;
1525 // Put a path seperator in if needed
1527 if (Str
.Len
&& DumpNode
!= DevPathToTextEndInstance
) {
1528 if (*(Str
.Str
+ Str
.Len
/ sizeof (CHAR16
) - 1) != L
',') {
1529 CatPrint (&Str
, L
"/");
1533 // Print this node of the device path
1535 DumpNode (&Str
, DevPathNode
, DisplayOnly
, AllowShortcuts
);
1538 // Next device path node
1540 DevPathNode
= NextDevicePathNode (DevPathNode
);
1543 // Shrink pool used for string allocation
1545 FreePool (UnpackDevPath
);
1547 NewSize
= (Str
.Len
+ 1) * sizeof (CHAR16
);
1548 Str
.Str
= ReallocatePool (Str
.Str
, NewSize
, NewSize
);
1549 ASSERT (Str
.Str
!= NULL
);
1550 Str
.Str
[Str
.Len
] = 0;