2 DevicePathToText protocol as defined in the UEFI 2.0 specification.
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "DevicePath.h"
18 EFI_DEVICE_PATH_PROTOCOL
*
20 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevPath
25 Function unpacks a device path data structure so that all the nodes of a device path
26 are naturally aligned.
29 DevPath - A pointer to a device path data structure
32 If the memory for the device path is successfully allocated, then a pointer to the
33 new device path is returned. Otherwise, NULL is returned.
37 CONST EFI_DEVICE_PATH_PROTOCOL
*Src
;
38 EFI_DEVICE_PATH_PROTOCOL
*Dest
;
39 EFI_DEVICE_PATH_PROTOCOL
*NewPath
;
42 if (DevPath
== NULL
) {
46 // Walk device path and round sizes to valid boundries
51 Size
+= DevicePathNodeLength (Src
);
52 Size
+= ALIGN_SIZE (Size
);
54 if (IsDevicePathEnd (Src
)) {
58 Src
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (Src
);
61 // Allocate space for the unpacked path
63 NewPath
= AllocateZeroPool (Size
);
64 if (NewPath
!= NULL
) {
66 ASSERT (((UINTN
) NewPath
) % MIN_ALIGNMENT_SIZE
== 0);
74 Size
= DevicePathNodeLength (Src
);
75 CopyMem (Dest
, Src
, Size
);
76 Size
+= ALIGN_SIZE (Size
);
77 SetDevicePathNodeLength (Dest
, Size
);
78 Dest
->Type
|= EFI_DP_TYPE_UNPACKED
;
79 Dest
= (EFI_DEVICE_PATH_PROTOCOL
*) (((UINT8
*) Dest
) + Size
);
81 if (IsDevicePathEnd (Src
)) {
85 Src
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (Src
);
102 Adjusts the size of a previously allocated buffer.
105 OldPool - A pointer to the buffer whose size is being adjusted.
106 OldSize - The size of the current buffer.
107 NewSize - The size of the new buffer.
110 EFI_SUCEESS - The requested number of bytes were allocated.
111 EFI_OUT_OF_RESOURCES - The pool requested could not be allocated.
112 EFI_INVALID_PARAMETER - The buffer was invalid.
120 NewPool
= AllocateZeroPool (NewSize
);
125 CopyMem (NewPool
, OldPool
, OldSize
< NewSize
? OldSize
: NewSize
);
137 IN OUT POOL_PRINT
*Str
,
144 Concatenates a formatted unicode string to allocated pool.
145 The caller must free the resulting buffer.
148 Str - Tracks the allocated pool, size in use, and
149 amount of pool allocated.
150 Fmt - The format string
153 Allocated buffer with the formatted string printed in it.
154 The caller must free the allocated buffer. The buffer
155 allocation is not packed.
163 AppendStr
= AllocateZeroPool (0x1000);
164 if (AppendStr
== NULL
) {
168 VA_START (Args
, Fmt
);
169 UnicodeVSPrint (AppendStr
, 0x1000, Fmt
, Args
);
171 if (NULL
== Str
->Str
) {
172 Size
= StrSize (AppendStr
);
173 Str
->Str
= AllocateZeroPool (Size
);
174 ASSERT (Str
->Str
!= NULL
);
176 Size
= StrSize (AppendStr
) - sizeof (UINT16
);
177 Size
= Size
+ StrSize (Str
->Str
);
178 Str
->Str
= ReallocatePool (
183 ASSERT (Str
->Str
!= NULL
);
186 Str
->MaxLen
= MAX_CHAR
* sizeof (UINT16
);
187 if (Size
< Str
->MaxLen
) {
188 StrCat (Str
->Str
, AppendStr
);
189 Str
->Len
= Size
- sizeof (UINT16
);
192 FreePool (AppendStr
);
199 IN OUT POOL_PRINT
*Str
,
201 IN BOOLEAN DisplayOnly
,
202 IN BOOLEAN AllowShortcuts
205 PCI_DEVICE_PATH
*Pci
;
208 CatPrint (Str
, L
"Pci(0x%x,0x%x)", Pci
->Device
, Pci
->Function
);
213 DevPathToTextPccard (
214 IN OUT POOL_PRINT
*Str
,
216 IN BOOLEAN DisplayOnly
,
217 IN BOOLEAN AllowShortcuts
220 PCCARD_DEVICE_PATH
*Pccard
;
223 CatPrint (Str
, L
"PcCard(0x%x)", Pccard
->FunctionNumber
);
228 DevPathToTextMemMap (
229 IN OUT POOL_PRINT
*Str
,
231 IN BOOLEAN DisplayOnly
,
232 IN BOOLEAN AllowShortcuts
235 MEMMAP_DEVICE_PATH
*MemMap
;
240 L
"MemoryMapped(0x%x,0x%lx,0x%lx)",
242 MemMap
->StartingAddress
,
243 MemMap
->EndingAddress
249 DevPathToTextVendor (
250 IN OUT POOL_PRINT
*Str
,
252 IN BOOLEAN DisplayOnly
,
253 IN BOOLEAN AllowShortcuts
256 VENDOR_DEVICE_PATH
*Vendor
;
260 UINT32 FlowControlMap
;
263 Vendor
= (VENDOR_DEVICE_PATH
*) DevPath
;
264 switch (DevicePathType (&Vendor
->Header
)) {
265 case HARDWARE_DEVICE_PATH
:
269 case MESSAGING_DEVICE_PATH
:
271 if (AllowShortcuts
) {
272 if (CompareGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
)) {
273 CatPrint (Str
, L
"VenPcAnsi()");
275 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100Guid
)) {
276 CatPrint (Str
, L
"VenVt100()");
278 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
)) {
279 CatPrint (Str
, L
"VenVt100Plus()");
281 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
)) {
282 CatPrint (Str
, L
"VenUft8()");
284 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingUartFlowControlGuid
)) {
285 FlowControlMap
= (((UART_FLOW_CONTROL_DEVICE_PATH
*) Vendor
)->FlowControlMap
);
286 switch (FlowControlMap
& 0x00000003) {
288 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"None");
292 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"Hardware");
296 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"XonXoff");
304 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingSASGuid
)) {
307 L
"SAS(0x%lx,0x%lx,0x%x,",
308 ((SAS_DEVICE_PATH
*) Vendor
)->SasAddress
,
309 ((SAS_DEVICE_PATH
*) Vendor
)->Lun
,
310 ((SAS_DEVICE_PATH
*) Vendor
)->RelativeTargetPort
312 Info
= (((SAS_DEVICE_PATH
*) Vendor
)->DeviceTopology
);
313 if ((Info
& 0x0f) == 0) {
314 CatPrint (Str
, L
"NoTopology,0,0,0,");
315 } else if (((Info
& 0x0f) == 1) || ((Info
& 0x0f) == 2)) {
319 (Info
& (0x1 << 4)) ? L
"SATA" : L
"SAS",
320 (Info
& (0x1 << 5)) ? L
"External" : L
"Internal",
321 (Info
& (0x1 << 6)) ? L
"Expanded" : L
"Direct"
323 if ((Info
& 0x0f) == 1) {
324 CatPrint (Str
, L
"0,");
326 CatPrint (Str
, L
"0x%x,", (Info
>> 8) & 0xff);
329 CatPrint (Str
, L
"0,0,0,0,");
332 CatPrint (Str
, L
"0x%x)", ((SAS_DEVICE_PATH
*) Vendor
)->Reserved
);
334 } else if (CompareGuid (&Vendor
->Guid
, &gEfiDebugPortProtocolGuid
)) {
335 CatPrint (Str
, L
"DebugPort()");
341 case MEDIA_DEVICE_PATH
:
350 DataLength
= DevicePathNodeLength (&Vendor
->Header
) - sizeof (VENDOR_DEVICE_PATH
);
351 CatPrint (Str
, L
"Ven%s(%g", Type
, &Vendor
->Guid
);
352 if (DataLength
!= 0) {
353 CatPrint (Str
, L
",");
354 for (Index
= 0; Index
< DataLength
; Index
++) {
355 CatPrint (Str
, L
"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA
*) Vendor
)->VendorDefinedData
[Index
]);
359 CatPrint (Str
, L
")");
364 DevPathToTextController (
365 IN OUT POOL_PRINT
*Str
,
367 IN BOOLEAN DisplayOnly
,
368 IN BOOLEAN AllowShortcuts
371 CONTROLLER_DEVICE_PATH
*Controller
;
373 Controller
= DevPath
;
377 Controller
->ControllerNumber
384 IN OUT POOL_PRINT
*Str
,
386 IN BOOLEAN DisplayOnly
,
387 IN BOOLEAN AllowShortcuts
390 ACPI_HID_DEVICE_PATH
*Acpi
;
393 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
394 switch (EISA_ID_TO_NUM (Acpi
->HID
)) {
396 CatPrint (Str
, L
"PciRoot(0x%x)", Acpi
->UID
);
400 CatPrint (Str
, L
"Floppy(0x%x)", Acpi
->UID
);
404 CatPrint (Str
, L
"Keyboard(0x%x)", Acpi
->UID
);
408 CatPrint (Str
, L
"Serial(0x%x)", Acpi
->UID
);
412 CatPrint (Str
, L
"ParallelPort(0x%x)", Acpi
->UID
);
416 CatPrint (Str
, L
"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi
->HID
), Acpi
->UID
);
420 CatPrint (Str
, L
"Acpi(0x%08x,0x%x)", Acpi
->HID
, Acpi
->UID
);
434 //UnicodeSPrint ("%X", 0x0a03) => "0000000000000A03"
436 UnicodeSPrint (PnpIdStr
, 17 * 2, L
"%16X", EisaId
>> 16);
440 sizeof (CHAR16
) + sizeof (CHAR16
) + sizeof (CHAR16
) + sizeof (PnpIdStr
),
442 '@' + ((EisaId
>> 10) & 0x1f),
443 '@' + ((EisaId
>> 5) & 0x1f),
444 '@' + ((EisaId
>> 0) & 0x1f),
451 DevPathToTextAcpiEx (
452 IN OUT POOL_PRINT
*Str
,
454 IN BOOLEAN DisplayOnly
,
455 IN BOOLEAN AllowShortcuts
458 ACPI_EXTENDED_HID_DEVICE_PATH
*AcpiEx
;
466 HIDStr
= (CHAR8
*) (((UINT8
*) AcpiEx
) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH
));
467 UIDStr
= HIDStr
+ AsciiStrLen (HIDStr
) + 1;
468 CIDStr
= UIDStr
+ AsciiStrLen (UIDStr
) + 1;
470 EisaIdToText (AcpiEx
->HID
, HIDText
);
471 EisaIdToText (AcpiEx
->CID
, CIDText
);
473 if ((*HIDStr
== '\0') && (*CIDStr
== '\0') && (AcpiEx
->UID
== 0)) {
479 L
"AcpiExp(%s,%s,%a)",
485 if (AllowShortcuts
) {
489 if (AcpiEx
->HID
== 0) {
490 CatPrint (Str
, L
"AcpiEx(%a,", HIDStr
);
492 CatPrint (Str
, L
"AcpiEx(%s,", HIDText
);
495 if (AcpiEx
->UID
== 0) {
496 CatPrint (Str
, L
"%a,", UIDStr
);
498 CatPrint (Str
, L
"0x%x,", AcpiEx
->UID
);
501 if (AcpiEx
->CID
== 0) {
502 CatPrint (Str
, L
"%a)", CIDStr
);
504 CatPrint (Str
, L
"%s)", CIDText
);
509 L
"AcpiEx(%s,%s,0x%x,%a,%a,%a)",
523 DevPathToTextAcpiAdr (
524 IN OUT POOL_PRINT
*Str
,
526 IN BOOLEAN DisplayOnly
,
527 IN BOOLEAN AllowShortcuts
530 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
533 UINT16 AdditionalAdrCount
;
536 Length
= (UINT16
) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
);
537 AdditionalAdrCount
= (UINT16
) ((Length
- 8) / 4);
539 CatPrint (Str
, L
"AcpiAdr(0x%x", AcpiAdr
->ADR
);
540 for (Index
= 0; Index
< AdditionalAdrCount
; Index
++) {
541 CatPrint (Str
, L
",0x%x", *(UINT32
*) ((UINT8
*) AcpiAdr
+ 8 + Index
* 4));
543 CatPrint (Str
, L
")");
549 IN OUT POOL_PRINT
*Str
,
551 IN BOOLEAN DisplayOnly
,
552 IN BOOLEAN AllowShortcuts
555 ATAPI_DEVICE_PATH
*Atapi
;
560 CatPrint (Str
, L
"Ata(0x%x)", Atapi
->Lun
);
565 Atapi
->PrimarySecondary
? L
"Secondary" : L
"Primary",
566 Atapi
->SlaveMaster
? L
"Slave" : L
"Master",
575 IN OUT POOL_PRINT
*Str
,
577 IN BOOLEAN DisplayOnly
,
578 IN BOOLEAN AllowShortcuts
581 SCSI_DEVICE_PATH
*Scsi
;
584 CatPrint (Str
, L
"Scsi(0x%x,0x%x)", Scsi
->Pun
, Scsi
->Lun
);
590 IN OUT POOL_PRINT
*Str
,
592 IN BOOLEAN DisplayOnly
,
593 IN BOOLEAN AllowShortcuts
596 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
599 CatPrint (Str
, L
"Fibre(0x%lx,0x%lx)", Fibre
->WWN
, Fibre
->Lun
);
605 IN OUT POOL_PRINT
*Str
,
607 IN BOOLEAN DisplayOnly
,
608 IN BOOLEAN AllowShortcuts
611 F1394_DEVICE_PATH
*F1394
;
615 // Guid has format of IEEE-EUI64
617 CatPrint (Str
, L
"I1394(%016lx)", F1394
->Guid
);
623 IN OUT POOL_PRINT
*Str
,
625 IN BOOLEAN DisplayOnly
,
626 IN BOOLEAN AllowShortcuts
629 USB_DEVICE_PATH
*Usb
;
632 CatPrint (Str
, L
"USB(0x%x,0x%x)", Usb
->ParentPortNumber
, Usb
->InterfaceNumber
);
637 DevPathToTextUsbWWID (
638 IN OUT POOL_PRINT
*Str
,
640 IN BOOLEAN DisplayOnly
,
641 IN BOOLEAN AllowShortcuts
644 USB_WWID_DEVICE_PATH
*UsbWWId
;
645 CHAR16
*SerialNumberStr
;
651 SerialNumberStr
= (CHAR16
*) ((UINT8
*) UsbWWId
+ sizeof (USB_WWID_DEVICE_PATH
));
652 Length
= (UINT16
) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) UsbWWId
) - sizeof (USB_WWID_DEVICE_PATH
)) / sizeof (CHAR16
));
653 if (SerialNumberStr
[Length
- 1] != 0) {
655 // In case no NULL terminator in SerialNumber, create a new one with NULL terminator
657 NewStr
= AllocateCopyPool ((Length
+ 1) * sizeof (CHAR16
), SerialNumberStr
);
659 SerialNumberStr
= NewStr
;
664 L
"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",
667 UsbWWId
->InterfaceNumber
,
674 DevPathToTextLogicalUnit (
675 IN OUT POOL_PRINT
*Str
,
677 IN BOOLEAN DisplayOnly
,
678 IN BOOLEAN AllowShortcuts
681 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
683 LogicalUnit
= DevPath
;
684 CatPrint (Str
, L
"Unit(0x%x)", LogicalUnit
->Lun
);
689 DevPathToTextUsbClass (
690 IN OUT POOL_PRINT
*Str
,
692 IN BOOLEAN DisplayOnly
,
693 IN BOOLEAN AllowShortcuts
696 USB_CLASS_DEVICE_PATH
*UsbClass
;
697 BOOLEAN IsKnownSubClass
;
702 IsKnownSubClass
= TRUE
;
703 switch (UsbClass
->DeviceClass
) {
704 case USB_CLASS_AUDIO
:
705 CatPrint (Str
, L
"UsbAudio");
708 case USB_CLASS_CDCCONTROL
:
709 CatPrint (Str
, L
"UsbCDCControl");
713 CatPrint (Str
, L
"UsbHID");
716 case USB_CLASS_IMAGE
:
717 CatPrint (Str
, L
"UsbImage");
720 case USB_CLASS_PRINTER
:
721 CatPrint (Str
, L
"UsbPrinter");
724 case USB_CLASS_MASS_STORAGE
:
725 CatPrint (Str
, L
"UsbMassStorage");
729 CatPrint (Str
, L
"UsbHub");
732 case USB_CLASS_CDCDATA
:
733 CatPrint (Str
, L
"UsbCDCData");
736 case USB_CLASS_SMART_CARD
:
737 CatPrint (Str
, L
"UsbSmartCard");
740 case USB_CLASS_VIDEO
:
741 CatPrint (Str
, L
"UsbVideo");
744 case USB_CLASS_DIAGNOSTIC
:
745 CatPrint (Str
, L
"UsbDiagnostic");
748 case USB_CLASS_WIRELESS
:
749 CatPrint (Str
, L
"UsbWireless");
753 IsKnownSubClass
= FALSE
;
757 if (IsKnownSubClass
) {
760 L
"(0x%x,0x%x,0x%x,0x%x)",
763 UsbClass
->DeviceSubClass
,
764 UsbClass
->DeviceProtocol
769 if (UsbClass
->DeviceClass
== USB_CLASS_RESERVE
) {
770 if (UsbClass
->DeviceSubClass
== USB_SUBCLASS_FW_UPDATE
) {
773 L
"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",
776 UsbClass
->DeviceProtocol
779 } else if (UsbClass
->DeviceSubClass
== USB_SUBCLASS_IRDA_BRIDGE
) {
782 L
"UsbIrdaBridge(0x%x,0x%x,0x%x)",
785 UsbClass
->DeviceProtocol
788 } else if (UsbClass
->DeviceSubClass
== USB_SUBCLASS_TEST
) {
791 L
"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",
794 UsbClass
->DeviceProtocol
802 L
"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",
805 UsbClass
->DeviceClass
,
806 UsbClass
->DeviceSubClass
,
807 UsbClass
->DeviceProtocol
814 IN OUT POOL_PRINT
*Str
,
816 IN BOOLEAN DisplayOnly
,
817 IN BOOLEAN AllowShortcuts
820 SATA_DEVICE_PATH
*Sata
;
825 L
"Sata(0x%x,0x%x,0x%x)",
826 (UINTN
) Sata
->HBAPortNumber
,
827 (UINTN
) Sata
->PortMultiplierPortNumber
,
835 IN OUT POOL_PRINT
*Str
,
837 IN BOOLEAN DisplayOnly
,
838 IN BOOLEAN AllowShortcuts
841 I2O_DEVICE_PATH
*I2O
;
844 CatPrint (Str
, L
"I2O(0x%x)", I2O
->Tid
);
849 DevPathToTextMacAddr (
850 IN OUT POOL_PRINT
*Str
,
852 IN BOOLEAN DisplayOnly
,
853 IN BOOLEAN AllowShortcuts
856 MAC_ADDR_DEVICE_PATH
*MAC
;
862 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
863 if (MAC
->IfType
== 0x01 || MAC
->IfType
== 0x00) {
867 CatPrint (Str
, L
"MAC(");
869 for (Index
= 0; Index
< HwAddressSize
; Index
++) {
870 CatPrint (Str
, L
"%02x", MAC
->MacAddress
.Addr
[Index
]);
873 CatPrint (Str
, L
",0x%x)", MAC
->IfType
);
879 IN OUT POOL_PRINT
*Str
,
881 IN BOOLEAN DisplayOnly
,
882 IN BOOLEAN AllowShortcuts
885 IPv4_DEVICE_PATH
*IP
;
888 if (DisplayOnly
== TRUE
) {
891 L
"IPv4(%d.%d.%d.%d)",
892 IP
->RemoteIpAddress
.Addr
[0],
893 IP
->RemoteIpAddress
.Addr
[1],
894 IP
->RemoteIpAddress
.Addr
[2],
895 IP
->RemoteIpAddress
.Addr
[3]
902 L
"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",
903 IP
->RemoteIpAddress
.Addr
[0],
904 IP
->RemoteIpAddress
.Addr
[1],
905 IP
->RemoteIpAddress
.Addr
[2],
906 IP
->RemoteIpAddress
.Addr
[3],
907 IP
->Protocol
? L
"TCP" : L
"UDP",
908 (IP
->StaticIpAddress
== TRUE
) ? L
"Static" : L
"DHCP",
909 IP
->LocalIpAddress
.Addr
[0],
910 IP
->LocalIpAddress
.Addr
[1],
911 IP
->LocalIpAddress
.Addr
[2],
912 IP
->LocalIpAddress
.Addr
[3]
919 IN OUT POOL_PRINT
*Str
,
921 IN BOOLEAN DisplayOnly
,
922 IN BOOLEAN AllowShortcuts
925 IPv6_DEVICE_PATH
*IP
;
928 if (DisplayOnly
== TRUE
) {
931 L
"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
932 IP
->RemoteIpAddress
.Addr
[0],
933 IP
->RemoteIpAddress
.Addr
[1],
934 IP
->RemoteIpAddress
.Addr
[2],
935 IP
->RemoteIpAddress
.Addr
[3],
936 IP
->RemoteIpAddress
.Addr
[4],
937 IP
->RemoteIpAddress
.Addr
[5],
938 IP
->RemoteIpAddress
.Addr
[6],
939 IP
->RemoteIpAddress
.Addr
[7],
940 IP
->RemoteIpAddress
.Addr
[8],
941 IP
->RemoteIpAddress
.Addr
[9],
942 IP
->RemoteIpAddress
.Addr
[10],
943 IP
->RemoteIpAddress
.Addr
[11],
944 IP
->RemoteIpAddress
.Addr
[12],
945 IP
->RemoteIpAddress
.Addr
[13],
946 IP
->RemoteIpAddress
.Addr
[14],
947 IP
->RemoteIpAddress
.Addr
[15]
954 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)",
955 IP
->RemoteIpAddress
.Addr
[0],
956 IP
->RemoteIpAddress
.Addr
[1],
957 IP
->RemoteIpAddress
.Addr
[2],
958 IP
->RemoteIpAddress
.Addr
[3],
959 IP
->RemoteIpAddress
.Addr
[4],
960 IP
->RemoteIpAddress
.Addr
[5],
961 IP
->RemoteIpAddress
.Addr
[6],
962 IP
->RemoteIpAddress
.Addr
[7],
963 IP
->RemoteIpAddress
.Addr
[8],
964 IP
->RemoteIpAddress
.Addr
[9],
965 IP
->RemoteIpAddress
.Addr
[10],
966 IP
->RemoteIpAddress
.Addr
[11],
967 IP
->RemoteIpAddress
.Addr
[12],
968 IP
->RemoteIpAddress
.Addr
[13],
969 IP
->RemoteIpAddress
.Addr
[14],
970 IP
->RemoteIpAddress
.Addr
[15],
971 IP
->Protocol
? L
"TCP" : L
"UDP",
972 (IP
->StaticIpAddress
== TRUE
) ? L
"Static" : L
"DHCP",
973 IP
->LocalIpAddress
.Addr
[0],
974 IP
->LocalIpAddress
.Addr
[1],
975 IP
->LocalIpAddress
.Addr
[2],
976 IP
->LocalIpAddress
.Addr
[3],
977 IP
->LocalIpAddress
.Addr
[4],
978 IP
->LocalIpAddress
.Addr
[5],
979 IP
->LocalIpAddress
.Addr
[6],
980 IP
->LocalIpAddress
.Addr
[7],
981 IP
->LocalIpAddress
.Addr
[8],
982 IP
->LocalIpAddress
.Addr
[9],
983 IP
->LocalIpAddress
.Addr
[10],
984 IP
->LocalIpAddress
.Addr
[11],
985 IP
->LocalIpAddress
.Addr
[12],
986 IP
->LocalIpAddress
.Addr
[13],
987 IP
->LocalIpAddress
.Addr
[14],
988 IP
->LocalIpAddress
.Addr
[15]
994 DevPathToTextInfiniBand (
995 IN OUT POOL_PRINT
*Str
,
997 IN BOOLEAN DisplayOnly
,
998 IN BOOLEAN AllowShortcuts
1001 INFINIBAND_DEVICE_PATH
*InfiniBand
;
1003 InfiniBand
= DevPath
;
1006 L
"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",
1007 InfiniBand
->ResourceFlags
,
1008 InfiniBand
->PortGid
,
1009 InfiniBand
->ServiceId
,
1010 InfiniBand
->TargetPortId
,
1011 InfiniBand
->DeviceId
1018 IN OUT POOL_PRINT
*Str
,
1020 IN BOOLEAN DisplayOnly
,
1021 IN BOOLEAN AllowShortcuts
1024 UART_DEVICE_PATH
*Uart
;
1028 switch (Uart
->Parity
) {
1058 if (Uart
->BaudRate
== 0) {
1059 CatPrint (Str
, L
"Uart(DEFAULT,");
1061 CatPrint (Str
, L
"Uart(%ld,", Uart
->BaudRate
);
1064 if (Uart
->DataBits
== 0) {
1065 CatPrint (Str
, L
"DEFAULT,");
1067 CatPrint (Str
, L
"%d,", Uart
->DataBits
);
1070 CatPrint (Str
, L
"%c,", Parity
);
1072 switch (Uart
->StopBits
) {
1074 CatPrint (Str
, L
"D)");
1078 CatPrint (Str
, L
"1)");
1082 CatPrint (Str
, L
"1.5)");
1086 CatPrint (Str
, L
"2)");
1090 CatPrint (Str
, L
"x)");
1097 DevPathToTextiSCSI (
1098 IN OUT POOL_PRINT
*Str
,
1100 IN BOOLEAN DisplayOnly
,
1101 IN BOOLEAN AllowShortcuts
1104 ISCSI_DEVICE_PATH_WITH_NAME
*iSCSI
;
1110 L
"iSCSI(%a,0x%x,0x%lx,",
1111 iSCSI
->iSCSITargetName
,
1112 iSCSI
->TargetPortalGroupTag
,
1116 Options
= iSCSI
->LoginOption
;
1117 CatPrint (Str
, L
"%s,", ((Options
>> 1) & 0x0001) ? L
"CRC32C" : L
"None");
1118 CatPrint (Str
, L
"%s,", ((Options
>> 3) & 0x0001) ? L
"CRC32C" : L
"None");
1119 if ((Options
>> 11) & 0x0001) {
1120 CatPrint (Str
, L
"%s,", L
"None");
1121 } else if ((Options
>> 12) & 0x0001) {
1122 CatPrint (Str
, L
"%s,", L
"CHAP_UNI");
1124 CatPrint (Str
, L
"%s,", L
"CHAP_BI");
1128 CatPrint (Str
, L
"%s)", (iSCSI
->NetworkProtocol
== 0) ? L
"TCP" : L
"reserved");
1133 DevPathToTextHardDrive (
1134 IN OUT POOL_PRINT
*Str
,
1136 IN BOOLEAN DisplayOnly
,
1137 IN BOOLEAN AllowShortcuts
1140 HARDDRIVE_DEVICE_PATH
*Hd
;
1143 switch (Hd
->SignatureType
) {
1144 case SIGNATURE_TYPE_MBR
:
1147 L
"HD(%d,%s,0x%08x,",
1148 Hd
->PartitionNumber
,
1150 *((UINT32
*) (&(Hd
->Signature
[0])))
1154 case SIGNATURE_TYPE_GUID
:
1158 Hd
->PartitionNumber
,
1160 (EFI_GUID
*) &(Hd
->Signature
[0])
1168 Hd
->PartitionNumber
,
1174 CatPrint (Str
, L
"0x%lx,0x%lx)", Hd
->PartitionStart
, Hd
->PartitionSize
);
1179 DevPathToTextCDROM (
1180 IN OUT POOL_PRINT
*Str
,
1182 IN BOOLEAN DisplayOnly
,
1183 IN BOOLEAN AllowShortcuts
1186 CDROM_DEVICE_PATH
*Cd
;
1189 if (DisplayOnly
== TRUE
) {
1190 CatPrint (Str
, L
"CDROM(0x%x)", Cd
->BootEntry
);
1194 CatPrint (Str
, L
"CDROM(0x%x,0x%lx,0x%lx)", Cd
->BootEntry
, Cd
->PartitionStart
, Cd
->PartitionSize
);
1199 DevPathToTextFilePath (
1200 IN OUT POOL_PRINT
*Str
,
1202 IN BOOLEAN DisplayOnly
,
1203 IN BOOLEAN AllowShortcuts
1206 FILEPATH_DEVICE_PATH
*Fp
;
1209 CatPrint (Str
, L
"%s", Fp
->PathName
);
1214 DevPathToTextMediaProtocol (
1215 IN OUT POOL_PRINT
*Str
,
1217 IN BOOLEAN DisplayOnly
,
1218 IN BOOLEAN AllowShortcuts
1221 MEDIA_PROTOCOL_DEVICE_PATH
*MediaProt
;
1223 MediaProt
= DevPath
;
1224 CatPrint (Str
, L
"Media(%g)", &MediaProt
->Protocol
);
1230 IN OUT POOL_PRINT
*Str
,
1232 IN BOOLEAN DisplayOnly
,
1233 IN BOOLEAN AllowShortcuts
1236 MEDIA_FW_VOL_DEVICE_PATH
*Fv
;
1239 CatPrint (Str
, L
"Fv(%g)", &Fv
->FvName
);
1244 DevPathToTextFvFile (
1245 IN OUT POOL_PRINT
*Str
,
1247 IN BOOLEAN DisplayOnly
,
1248 IN BOOLEAN AllowShortcuts
1251 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFile
;
1254 CatPrint (Str
, L
"FvFile(%g)", &FvFile
->FvFileName
);
1260 IN OUT POOL_PRINT
*Str
,
1262 IN BOOLEAN DisplayOnly
,
1263 IN BOOLEAN AllowShortcuts
1266 BBS_BBS_DEVICE_PATH
*Bbs
;
1270 switch (Bbs
->DeviceType
) {
1271 case BBS_TYPE_FLOPPY
:
1275 case BBS_TYPE_HARDDRIVE
:
1279 case BBS_TYPE_CDROM
:
1283 case BBS_TYPE_PCMCIA
:
1291 case BBS_TYPE_EMBEDDED_NETWORK
:
1301 CatPrint (Str
, L
"BBS(%s,%a", Type
, Bbs
->String
);
1303 CatPrint (Str
, L
"BBS(0x%x,%a", Bbs
->DeviceType
, Bbs
->String
);
1306 if (DisplayOnly
== TRUE
) {
1307 CatPrint (Str
, L
")");
1311 CatPrint (Str
, L
",0x%x)", Bbs
->StatusFlag
);
1316 DevPathToTextEndInstance (
1317 IN OUT POOL_PRINT
*Str
,
1319 IN BOOLEAN DisplayOnly
,
1320 IN BOOLEAN AllowShortcuts
1323 CatPrint (Str
, L
",");
1328 DevPathToTextNodeUnknown (
1329 IN OUT POOL_PRINT
*Str
,
1331 IN BOOLEAN DisplayOnly
,
1332 IN BOOLEAN AllowShortcuts
1335 CatPrint (Str
, L
"?");
1338 GLOBAL_REMOVE_IF_UNREFERENCED
const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable
[] = {
1339 {HARDWARE_DEVICE_PATH
, HW_PCI_DP
, DevPathToTextPci
},
1340 {HARDWARE_DEVICE_PATH
, HW_PCCARD_DP
, DevPathToTextPccard
},
1341 {HARDWARE_DEVICE_PATH
, HW_MEMMAP_DP
, DevPathToTextMemMap
},
1342 {HARDWARE_DEVICE_PATH
, HW_VENDOR_DP
, DevPathToTextVendor
},
1343 {HARDWARE_DEVICE_PATH
, HW_CONTROLLER_DP
, DevPathToTextController
},
1344 {ACPI_DEVICE_PATH
, ACPI_DP
, DevPathToTextAcpi
},
1345 {ACPI_DEVICE_PATH
, ACPI_EXTENDED_DP
, DevPathToTextAcpiEx
},
1346 {ACPI_DEVICE_PATH
, ACPI_ADR_DP
, DevPathToTextAcpiAdr
},
1347 {MESSAGING_DEVICE_PATH
, MSG_ATAPI_DP
, DevPathToTextAtapi
},
1348 {MESSAGING_DEVICE_PATH
, MSG_SCSI_DP
, DevPathToTextScsi
},
1349 {MESSAGING_DEVICE_PATH
, MSG_FIBRECHANNEL_DP
, DevPathToTextFibre
},
1350 {MESSAGING_DEVICE_PATH
, MSG_1394_DP
, DevPathToText1394
},
1351 {MESSAGING_DEVICE_PATH
, MSG_USB_DP
, DevPathToTextUsb
},
1352 {MESSAGING_DEVICE_PATH
, MSG_USB_WWID_DP
, DevPathToTextUsbWWID
},
1353 {MESSAGING_DEVICE_PATH
, MSG_DEVICE_LOGICAL_UNIT_DP
, DevPathToTextLogicalUnit
},
1354 {MESSAGING_DEVICE_PATH
, MSG_USB_CLASS_DP
, DevPathToTextUsbClass
},
1355 {MESSAGING_DEVICE_PATH
, MSG_SATA_DP
, DevPathToTextSata
},
1356 {MESSAGING_DEVICE_PATH
, MSG_I2O_DP
, DevPathToTextI2O
},
1357 {MESSAGING_DEVICE_PATH
, MSG_MAC_ADDR_DP
, DevPathToTextMacAddr
},
1358 {MESSAGING_DEVICE_PATH
, MSG_IPv4_DP
, DevPathToTextIPv4
},
1359 {MESSAGING_DEVICE_PATH
, MSG_IPv6_DP
, DevPathToTextIPv6
},
1360 {MESSAGING_DEVICE_PATH
, MSG_INFINIBAND_DP
, DevPathToTextInfiniBand
},
1361 {MESSAGING_DEVICE_PATH
, MSG_UART_DP
, DevPathToTextUart
},
1362 {MESSAGING_DEVICE_PATH
, MSG_VENDOR_DP
, DevPathToTextVendor
},
1363 {MESSAGING_DEVICE_PATH
, MSG_ISCSI_DP
, DevPathToTextiSCSI
},
1364 {MEDIA_DEVICE_PATH
, MEDIA_HARDDRIVE_DP
, DevPathToTextHardDrive
},
1365 {MEDIA_DEVICE_PATH
, MEDIA_CDROM_DP
, DevPathToTextCDROM
},
1366 {MEDIA_DEVICE_PATH
, MEDIA_VENDOR_DP
, DevPathToTextVendor
},
1367 {MEDIA_DEVICE_PATH
, MEDIA_FILEPATH_DP
, DevPathToTextFilePath
},
1368 {MEDIA_DEVICE_PATH
, MEDIA_PROTOCOL_DP
, DevPathToTextMediaProtocol
},
1369 {MEDIA_DEVICE_PATH
, MEDIA_FILEPATH_DP
, DevPathToTextFilePath
},
1370 {MEDIA_DEVICE_PATH
, MEDIA_PIWG_FW_VOL_DP
, DevPathToTextFv
},
1371 {MEDIA_DEVICE_PATH
, MEDIA_PIWG_FW_FILE_DP
, DevPathToTextFvFile
},
1372 {BBS_DEVICE_PATH
, BBS_BBS_DP
, DevPathToTextBBS
},
1373 {END_DEVICE_PATH_TYPE
, END_INSTANCE_DEVICE_PATH_SUBTYPE
, DevPathToTextEndInstance
},
1378 ConvertDeviceNodeToText (
1379 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
1380 IN BOOLEAN DisplayOnly
,
1381 IN BOOLEAN AllowShortcuts
1385 Routine Description:
1386 Convert a device node to its text representation.
1389 DeviceNode - Points to the device node to be converted.
1390 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
1391 of the display node is used, where applicable. If DisplayOnly
1392 is FALSE, then the longer text representation of the display node
1394 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
1395 representation for a device node can be used, where applicable.
1398 A pointer - a pointer to the allocated text representation of the device node.
1399 NULL - if DeviceNode is NULL or there was insufficient memory.
1406 VOID (*DumpNode
)(POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
1408 if (DeviceNode
== NULL
) {
1412 ZeroMem (&Str
, sizeof (Str
));
1415 // Process the device path node
1418 for (Index
= 0; DevPathToTextTable
[Index
].Function
!= NULL
; Index
++) {
1419 if (DevicePathType (DeviceNode
) == DevPathToTextTable
[Index
].Type
&&
1420 DevicePathSubType (DeviceNode
) == DevPathToTextTable
[Index
].SubType
1422 DumpNode
= DevPathToTextTable
[Index
].Function
;
1427 // If not found, use a generic function
1429 if (DumpNode
== NULL
) {
1430 DumpNode
= DevPathToTextNodeUnknown
;
1436 DumpNode (&Str
, (VOID
*) DeviceNode
, DisplayOnly
, AllowShortcuts
);
1439 // Shrink pool used for string allocation
1441 NewSize
= (Str
.Len
+ 1) * sizeof (CHAR16
);
1442 Str
.Str
= ReallocatePool (Str
.Str
, NewSize
, NewSize
);
1443 ASSERT (Str
.Str
!= NULL
);
1444 Str
.Str
[Str
.Len
] = 0;
1449 ConvertDevicePathToText (
1450 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1451 IN BOOLEAN DisplayOnly
,
1452 IN BOOLEAN AllowShortcuts
1456 Routine Description:
1457 Convert a device path to its text representation.
1460 DeviceNode - Points to the device path to be converted.
1461 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
1462 of the display node is used, where applicable. If DisplayOnly
1463 is FALSE, then the longer text representation of the display node
1465 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
1466 representation for a device node can be used, where applicable.
1469 A pointer - a pointer to the allocated text representation of the device path.
1470 NULL - if DeviceNode is NULL or there was insufficient memory.
1475 EFI_DEVICE_PATH_PROTOCOL
*DevPathNode
;
1476 EFI_DEVICE_PATH_PROTOCOL
*UnpackDevPath
;
1479 VOID (*DumpNode
) (POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
1481 if (DevicePath
== NULL
) {
1485 ZeroMem (&Str
, sizeof (Str
));
1488 // Unpacked the device path
1490 UnpackDevPath
= UnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL
*) DevicePath
);
1491 ASSERT (UnpackDevPath
!= NULL
);
1494 // Process each device path node
1496 DevPathNode
= UnpackDevPath
;
1497 while (!IsDevicePathEnd (DevPathNode
)) {
1499 // Find the handler to dump this device path node
1502 for (Index
= 0; DevPathToTextTable
[Index
].Function
; Index
+= 1) {
1504 if (DevicePathType (DevPathNode
) == DevPathToTextTable
[Index
].Type
&&
1505 DevicePathSubType (DevPathNode
) == DevPathToTextTable
[Index
].SubType
1507 DumpNode
= DevPathToTextTable
[Index
].Function
;
1512 // If not found, use a generic function
1515 DumpNode
= DevPathToTextNodeUnknown
;
1518 // Put a path seperator in if needed
1520 if (Str
.Len
&& DumpNode
!= DevPathToTextEndInstance
) {
1521 if (*(Str
.Str
+ Str
.Len
/ sizeof (CHAR16
) - 1) != L
',') {
1522 CatPrint (&Str
, L
"/");
1526 // Print this node of the device path
1528 DumpNode (&Str
, DevPathNode
, DisplayOnly
, AllowShortcuts
);
1531 // Next device path node
1533 DevPathNode
= NextDevicePathNode (DevPathNode
);
1536 // Shrink pool used for string allocation
1538 FreePool (UnpackDevPath
);
1540 NewSize
= (Str
.Len
+ 1) * sizeof (CHAR16
);
1541 Str
.Str
= ReallocatePool (Str
.Str
, NewSize
, NewSize
);
1542 ASSERT (Str
.Str
!= NULL
);
1543 Str
.Str
[Str
.Len
] = 0;