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"
24 EFI_DEVICE_PATH_PROTOCOL
*
26 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
31 Function unpacks a device path data structure so that all the nodes of a device path
32 are naturally aligned.
35 DevPath - A pointer to a device path data structure
38 If the memory for the device path is successfully allocated, then a pointer to the
39 new device path is returned. Otherwise, NULL is returned.
43 EFI_DEVICE_PATH_PROTOCOL
*Src
;
44 EFI_DEVICE_PATH_PROTOCOL
*Dest
;
45 EFI_DEVICE_PATH_PROTOCOL
*NewPath
;
48 if (DevPath
== NULL
) {
52 // Walk device path and round sizes to valid boundries
57 Size
+= DevicePathNodeLength (Src
);
58 Size
+= ALIGN_SIZE (Size
);
60 if (IsDevicePathEnd (Src
)) {
64 Src
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (Src
);
67 // Allocate space for the unpacked path
69 NewPath
= AllocateZeroPool (Size
);
70 if (NewPath
!= NULL
) {
72 ASSERT (((UINTN
) NewPath
) % MIN_ALIGNMENT_SIZE
== 0);
80 Size
= DevicePathNodeLength (Src
);
81 CopyMem (Dest
, Src
, Size
);
82 Size
+= ALIGN_SIZE (Size
);
83 SetDevicePathNodeLength (Dest
, Size
);
84 Dest
->Type
|= EFI_DP_TYPE_UNPACKED
;
85 Dest
= (EFI_DEVICE_PATH_PROTOCOL
*) (((UINT8
*) Dest
) + Size
);
87 if (IsDevicePathEnd (Src
)) {
91 Src
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (Src
);
107 Adjusts the size of a previously allocated buffer.
110 OldPool - A pointer to the buffer whose size is being adjusted.
111 OldSize - The size of the current buffer.
112 NewSize - The size of the new buffer.
115 EFI_SUCEESS - The requested number of bytes were allocated.
116 EFI_OUT_OF_RESOURCES - The pool requested could not be allocated.
117 EFI_INVALID_PARAMETER - The buffer was invalid.
125 NewPool
= AllocateZeroPool (NewSize
);
130 CopyMem (NewPool
, OldPool
, OldSize
< NewSize
? OldSize
: NewSize
);
133 gBS
->FreePool (OldPool
);
141 IN OUT POOL_PRINT
*Str
,
148 Concatenates a formatted unicode string to allocated pool.
149 The caller must free the resulting buffer.
152 Str - Tracks the allocated pool, size in use, and
153 amount of pool allocated.
154 Fmt - The format string
157 Allocated buffer with the formatted string printed in it.
158 The caller must free the allocated buffer. The buffer
159 allocation is not packed.
167 AppendStr
= AllocateZeroPool (0x1000);
168 if (AppendStr
== NULL
) {
172 VA_START (Args
, Fmt
);
173 UnicodeVSPrint (AppendStr
, 0x1000, Fmt
, Args
);
175 if (NULL
== Str
->Str
) {
176 Size
= StrSize (AppendStr
);
177 Str
->Str
= AllocateZeroPool (Size
);
178 ASSERT (Str
->Str
!= NULL
);
180 Size
= StrSize (AppendStr
) + StrSize (Str
->Str
) - sizeof (UINT16
);
181 Str
->Str
= ReallocatePool (
186 ASSERT (Str
->Str
!= NULL
);
189 Str
->MaxLen
= MAX_CHAR
* sizeof (UINT16
);
190 if (Size
< Str
->MaxLen
) {
191 StrCat (Str
->Str
, AppendStr
);
192 Str
->Len
= Size
- sizeof (UINT16
);
195 gBS
->FreePool (AppendStr
);
201 IN OUT POOL_PRINT
*Str
,
203 IN BOOLEAN DisplayOnly
,
204 IN BOOLEAN AllowShortcuts
207 PCI_DEVICE_PATH
*Pci
;
210 CatPrint (Str
, L
"Pci(%x,%x)", Pci
->Function
, Pci
->Device
);
214 DevPathToTextPccard (
215 IN OUT POOL_PRINT
*Str
,
217 IN BOOLEAN DisplayOnly
,
218 IN BOOLEAN AllowShortcuts
221 PCCARD_DEVICE_PATH
*Pccard
;
224 CatPrint (Str
, L
"PcCard(%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(%lx,%lx)",
241 MemMap
->StartingAddress
,
242 MemMap
->EndingAddress
247 DevPathToTextVendor (
248 IN OUT POOL_PRINT
*Str
,
250 IN BOOLEAN DisplayOnly
,
251 IN BOOLEAN AllowShortcuts
254 VENDOR_DEVICE_PATH
*Vendor
;
257 UINT32 FlowControlMap
;
260 Vendor
= (VENDOR_DEVICE_PATH
*) DevPath
;
261 switch (DevicePathType (&Vendor
->Header
)) {
262 case HARDWARE_DEVICE_PATH
:
266 case MESSAGING_DEVICE_PATH
:
268 if (AllowShortcuts
) {
269 if (CompareGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
)) {
270 CatPrint (Str
, L
"VenPcAnsi()");
272 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100Guid
)) {
273 CatPrint (Str
, L
"VenVt100()");
275 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
)) {
276 CatPrint (Str
, L
"VenVt100Plus()");
278 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
)) {
279 CatPrint (Str
, L
"VenUft8()");
281 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingUartFlowControlGuid
)) {
282 FlowControlMap
= (((UART_FLOW_CONTROL_DEVICE_PATH
*) Vendor
)->FlowControlMap
);
283 switch (FlowControlMap
& 0x00000003) {
285 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"None");
289 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"Hardware");
293 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"XonXoff");
301 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingSASGuid
)) {
305 ((SAS_DEVICE_PATH
*) Vendor
)->SasAddress
,
306 ((SAS_DEVICE_PATH
*) Vendor
)->Lun
,
307 ((SAS_DEVICE_PATH
*) Vendor
)->RelativeTargetPort
309 Info
= (((SAS_DEVICE_PATH
*) Vendor
)->DeviceTopology
);
310 if ((Info
& 0x0f) == 0) {
311 CatPrint (Str
, L
"NoTopology,0,0,0,");
312 } else if (((Info
& 0x0f) == 1) || ((Info
& 0x0f) == 2)) {
316 (Info
& (0x1 << 4)) ? L
"SATA" : L
"SAS",
317 (Info
& (0x1 << 5)) ? L
"External" : L
"Internal",
318 (Info
& (0x1 << 6)) ? L
"Expanded" : L
"Direct"
320 if ((Info
& 0x0f) == 1) {
321 CatPrint (Str
, L
"0,");
323 CatPrint (Str
, L
"%x,", (Info
>> 8) & 0xff);
326 CatPrint (Str
, L
"0,0,0,0,");
329 CatPrint (Str
, L
"%x)", ((SAS_DEVICE_PATH
*) Vendor
)->Reserved
);
331 } else if (CompareGuid (&Vendor
->Guid
, &gEfiDebugPortProtocolGuid
)) {
332 CatPrint (Str
, L
"DebugPort()");
343 case MEDIA_DEVICE_PATH
:
352 CatPrint (Str
, L
"Ven%s(%g,", Type
, &Vendor
->Guid
);
353 for (Index
= 0; Index
< DevicePathNodeLength (&Vendor
->Header
) - sizeof (VENDOR_DEVICE_PATH
); Index
++) {
354 CatPrint (Str
, L
"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA
*) Vendor
)->VendorDefinedData
[Index
]);
357 CatPrint (Str
, L
")");
361 DevPathToTextController (
362 IN OUT POOL_PRINT
*Str
,
364 IN BOOLEAN DisplayOnly
,
365 IN BOOLEAN AllowShortcuts
368 CONTROLLER_DEVICE_PATH
*Controller
;
370 Controller
= DevPath
;
374 Controller
->ControllerNumber
380 IN OUT POOL_PRINT
*Str
,
382 IN BOOLEAN DisplayOnly
,
383 IN BOOLEAN AllowShortcuts
386 ACPI_HID_DEVICE_PATH
*Acpi
;
389 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
390 if (AllowShortcuts
) {
391 switch (EISA_ID_TO_NUM (Acpi
->HID
)) {
393 CatPrint (Str
, L
"PciRoot(%x)", Acpi
->UID
);
397 CatPrint (Str
, L
"Floppy(%x)", Acpi
->UID
);
401 CatPrint (Str
, L
"Keyboard(%x)", Acpi
->UID
);
405 CatPrint (Str
, L
"Serial(%x)", Acpi
->UID
);
409 CatPrint (Str
, L
"ParallelPort(%x)", Acpi
->UID
);
419 CatPrint (Str
, L
"Acpi(PNP%04x,%x)", EISA_ID_TO_NUM (Acpi
->HID
), Acpi
->UID
);
421 CatPrint (Str
, L
"Acpi(%08x,%x)", Acpi
->HID
, Acpi
->UID
);
425 #define NextStrA(a) ((UINT8 *) (((UINT8 *) (a)) + AsciiStrLen ((CHAR8 *) (a)) + 1))
428 DevPathToTextExtAcpi (
429 IN OUT POOL_PRINT
*Str
,
431 IN BOOLEAN DisplayOnly
,
432 IN BOOLEAN AllowShortcuts
435 ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR
*AcpiExt
;
439 if (AllowShortcuts
) {
440 if ((*(AcpiExt
->HidUidCidStr
) == '\0') &&
441 (*(NextStrA (NextStrA (AcpiExt
->HidUidCidStr
))) == '\0') &&
444 if ((AcpiExt
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
447 L
"AcpiExp(PNP%04x,%x,%a)",
448 EISA_ID_TO_NUM (AcpiExt
->HID
),
450 NextStrA (AcpiExt
->HidUidCidStr
)
455 L
"AcpiExp(%08x,%x,%a)",
458 NextStrA (AcpiExt
->HidUidCidStr
)
465 if ((AcpiExt
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
468 L
"AcpiEx(PNP%04x,%x,%x,%a,%a,%a)",
469 EISA_ID_TO_NUM (AcpiExt
->HID
),
472 AcpiExt
->HidUidCidStr
,
473 NextStrA (NextStrA (AcpiExt
->HidUidCidStr
)),
474 NextStrA (AcpiExt
->HidUidCidStr
)
479 L
"AcpiEx(%08x,%x,%x,%a,%a,%a)",
483 AcpiExt
->HidUidCidStr
,
484 NextStrA (NextStrA (AcpiExt
->HidUidCidStr
)),
485 NextStrA (AcpiExt
->HidUidCidStr
)
492 IN OUT POOL_PRINT
*Str
,
494 IN BOOLEAN DisplayOnly
,
495 IN BOOLEAN AllowShortcuts
498 ATAPI_DEVICE_PATH
*Atapi
;
503 CatPrint (Str
, L
"Ata(%x)", Atapi
->Lun
);
508 Atapi
->PrimarySecondary
? L
"Secondary" : L
"Primary",
509 Atapi
->SlaveMaster
? L
"Slave" : L
"Master",
517 IN OUT POOL_PRINT
*Str
,
519 IN BOOLEAN DisplayOnly
,
520 IN BOOLEAN AllowShortcuts
523 SCSI_DEVICE_PATH
*Scsi
;
526 CatPrint (Str
, L
"Scsi(%x,%x)", Scsi
->Pun
, Scsi
->Lun
);
531 IN OUT POOL_PRINT
*Str
,
533 IN BOOLEAN DisplayOnly
,
534 IN BOOLEAN AllowShortcuts
537 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
540 CatPrint (Str
, L
"Fibre(%lx,%lx)", Fibre
->WWN
, Fibre
->Lun
);
545 IN OUT POOL_PRINT
*Str
,
547 IN BOOLEAN DisplayOnly
,
548 IN BOOLEAN AllowShortcuts
551 F1394_DEVICE_PATH
*F1394
;
554 CatPrint (Str
, L
"I1394(%lx)", F1394
->Guid
);
559 IN OUT POOL_PRINT
*Str
,
561 IN BOOLEAN DisplayOnly
,
562 IN BOOLEAN AllowShortcuts
565 USB_DEVICE_PATH
*Usb
;
568 CatPrint (Str
, L
"USB(%x,%x)", Usb
->ParentPortNumber
, Usb
->InterfaceNumber
);
572 DevPathToTextUsbWWID (
573 IN OUT POOL_PRINT
*Str
,
575 IN BOOLEAN DisplayOnly
,
576 IN BOOLEAN AllowShortcuts
579 USB_WWID_DEVICE_PATH
*UsbWWId
;
584 L
"UsbWwid(%x,%x,%x,\"WWID\")",
587 UsbWWId
->InterfaceNumber
592 DevPathToTextLogicalUnit (
593 IN OUT POOL_PRINT
*Str
,
595 IN BOOLEAN DisplayOnly
,
596 IN BOOLEAN AllowShortcuts
599 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
601 LogicalUnit
= DevPath
;
602 CatPrint (Str
, L
"Unit(%x)", LogicalUnit
->Lun
);
606 DevPathToTextUsbClass (
607 IN OUT POOL_PRINT
*Str
,
609 IN BOOLEAN DisplayOnly
,
610 IN BOOLEAN AllowShortcuts
613 USB_CLASS_DEVICE_PATH
*UsbClass
;
617 if (AllowShortcuts
== TRUE
) {
618 switch (UsbClass
->DeviceClass
) {
622 L
"UsbAudio(%x,%x,%x,%x)",
625 UsbClass
->DeviceSubClass
,
626 UsbClass
->DeviceProtocol
633 L
"UsbCDCControl(%x,%x,%x,%x)",
636 UsbClass
->DeviceSubClass
,
637 UsbClass
->DeviceProtocol
644 L
"UsbHID(%x,%x,%x,%x)",
647 UsbClass
->DeviceSubClass
,
648 UsbClass
->DeviceProtocol
655 L
"UsbImage(%x,%x,%x,%x)",
658 UsbClass
->DeviceSubClass
,
659 UsbClass
->DeviceProtocol
666 L
"UsbPrinter(%x,%x,%x,%x)",
669 UsbClass
->DeviceSubClass
,
670 UsbClass
->DeviceProtocol
677 L
"UsbMassStorage(%x,%x,%x,%x)",
680 UsbClass
->DeviceSubClass
,
681 UsbClass
->DeviceProtocol
688 L
"UsbHub(%x,%x,%x,%x)",
691 UsbClass
->DeviceSubClass
,
692 UsbClass
->DeviceProtocol
699 L
"UsbCDCData(%x,%x,%x,%x)",
702 UsbClass
->DeviceSubClass
,
703 UsbClass
->DeviceProtocol
710 L
"UsbSmartCard(%x,%x,%x,%x)",
713 UsbClass
->DeviceSubClass
,
714 UsbClass
->DeviceProtocol
721 L
"UsbVideo(%x,%x,%x,%x)",
724 UsbClass
->DeviceSubClass
,
725 UsbClass
->DeviceProtocol
732 L
"UsbDiagnostic(%x,%x,%x,%x)",
735 UsbClass
->DeviceSubClass
,
736 UsbClass
->DeviceProtocol
743 L
"UsbWireless(%x,%x,%x,%x)",
746 UsbClass
->DeviceSubClass
,
747 UsbClass
->DeviceProtocol
752 if (UsbClass
->DeviceSubClass
== 1) {
755 L
"UsbDeviceFirmwareUpdate(%x,%x,%x)",
758 UsbClass
->DeviceProtocol
760 } else if (UsbClass
->DeviceSubClass
== 2) {
763 L
"UsbIrdaBridge(%x,%x,%x)",
766 UsbClass
->DeviceProtocol
768 } else if (UsbClass
->DeviceSubClass
== 3) {
771 L
"UsbTestAndMeasurement(%x,%x,%x)",
774 UsbClass
->DeviceProtocol
788 L
"UsbClass(%x,%x,%x,%x,%x)",
791 UsbClass
->DeviceClass
,
792 UsbClass
->DeviceSubClass
,
793 UsbClass
->DeviceProtocol
799 IN OUT POOL_PRINT
*Str
,
801 IN BOOLEAN DisplayOnly
,
802 IN BOOLEAN AllowShortcuts
805 I2O_DEVICE_PATH
*I2O
;
808 CatPrint (Str
, L
"I2O(%x)", I2O
->Tid
);
812 DevPathToTextMacAddr (
813 IN OUT POOL_PRINT
*Str
,
815 IN BOOLEAN DisplayOnly
,
816 IN BOOLEAN AllowShortcuts
819 MAC_ADDR_DEVICE_PATH
*MAC
;
825 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
826 if (MAC
->IfType
== 0x01 || MAC
->IfType
== 0x00) {
830 CatPrint (Str
, L
"MAC(");
832 for (Index
= 0; Index
< HwAddressSize
; Index
++) {
833 CatPrint (Str
, L
"%02x", MAC
->MacAddress
.Addr
[Index
]);
836 CatPrint (Str
, L
",%x)", MAC
->IfType
);
841 IN OUT POOL_PRINT
*Str
,
843 IN BOOLEAN DisplayOnly
,
844 IN BOOLEAN AllowShortcuts
847 IPv4_DEVICE_PATH
*IP
;
850 if (DisplayOnly
== TRUE
) {
853 L
"IPv4(%d.%d.%d.%d)",
854 IP
->RemoteIpAddress
.Addr
[0],
855 IP
->RemoteIpAddress
.Addr
[1],
856 IP
->RemoteIpAddress
.Addr
[2],
857 IP
->RemoteIpAddress
.Addr
[3]
864 L
"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",
865 IP
->RemoteIpAddress
.Addr
[0],
866 IP
->RemoteIpAddress
.Addr
[1],
867 IP
->RemoteIpAddress
.Addr
[2],
868 IP
->RemoteIpAddress
.Addr
[3],
869 IP
->Protocol
? L
"TCP" : L
"UDP",
870 (IP
->StaticIpAddress
== TRUE
) ? L
"Static" : L
"DHCP",
871 IP
->LocalIpAddress
.Addr
[0],
872 IP
->LocalIpAddress
.Addr
[1],
873 IP
->LocalIpAddress
.Addr
[2],
874 IP
->LocalIpAddress
.Addr
[3]
880 IN OUT POOL_PRINT
*Str
,
882 IN BOOLEAN DisplayOnly
,
883 IN BOOLEAN AllowShortcuts
886 IPv6_DEVICE_PATH
*IP
;
889 if (DisplayOnly
== TRUE
) {
892 L
"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
893 IP
->RemoteIpAddress
.Addr
[0],
894 IP
->RemoteIpAddress
.Addr
[1],
895 IP
->RemoteIpAddress
.Addr
[2],
896 IP
->RemoteIpAddress
.Addr
[3],
897 IP
->RemoteIpAddress
.Addr
[4],
898 IP
->RemoteIpAddress
.Addr
[5],
899 IP
->RemoteIpAddress
.Addr
[6],
900 IP
->RemoteIpAddress
.Addr
[7],
901 IP
->RemoteIpAddress
.Addr
[8],
902 IP
->RemoteIpAddress
.Addr
[9],
903 IP
->RemoteIpAddress
.Addr
[10],
904 IP
->RemoteIpAddress
.Addr
[11],
905 IP
->RemoteIpAddress
.Addr
[12],
906 IP
->RemoteIpAddress
.Addr
[13],
907 IP
->RemoteIpAddress
.Addr
[14],
908 IP
->RemoteIpAddress
.Addr
[15]
915 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)",
916 IP
->RemoteIpAddress
.Addr
[0],
917 IP
->RemoteIpAddress
.Addr
[1],
918 IP
->RemoteIpAddress
.Addr
[2],
919 IP
->RemoteIpAddress
.Addr
[3],
920 IP
->RemoteIpAddress
.Addr
[4],
921 IP
->RemoteIpAddress
.Addr
[5],
922 IP
->RemoteIpAddress
.Addr
[6],
923 IP
->RemoteIpAddress
.Addr
[7],
924 IP
->RemoteIpAddress
.Addr
[8],
925 IP
->RemoteIpAddress
.Addr
[9],
926 IP
->RemoteIpAddress
.Addr
[10],
927 IP
->RemoteIpAddress
.Addr
[11],
928 IP
->RemoteIpAddress
.Addr
[12],
929 IP
->RemoteIpAddress
.Addr
[13],
930 IP
->RemoteIpAddress
.Addr
[14],
931 IP
->RemoteIpAddress
.Addr
[15],
932 IP
->Protocol
? L
"TCP" : L
"UDP",
933 (IP
->StaticIpAddress
== TRUE
) ? L
"Static" : L
"DHCP",
934 IP
->LocalIpAddress
.Addr
[0],
935 IP
->LocalIpAddress
.Addr
[1],
936 IP
->LocalIpAddress
.Addr
[2],
937 IP
->LocalIpAddress
.Addr
[3],
938 IP
->LocalIpAddress
.Addr
[4],
939 IP
->LocalIpAddress
.Addr
[5],
940 IP
->LocalIpAddress
.Addr
[6],
941 IP
->LocalIpAddress
.Addr
[7],
942 IP
->LocalIpAddress
.Addr
[8],
943 IP
->LocalIpAddress
.Addr
[9],
944 IP
->LocalIpAddress
.Addr
[10],
945 IP
->LocalIpAddress
.Addr
[11],
946 IP
->LocalIpAddress
.Addr
[12],
947 IP
->LocalIpAddress
.Addr
[13],
948 IP
->LocalIpAddress
.Addr
[14],
949 IP
->LocalIpAddress
.Addr
[15]
954 DevPathToTextInfiniBand (
955 IN OUT POOL_PRINT
*Str
,
957 IN BOOLEAN DisplayOnly
,
958 IN BOOLEAN AllowShortcuts
961 INFINIBAND_DEVICE_PATH
*InfiniBand
;
963 InfiniBand
= DevPath
;
966 L
"Infiniband(%x,%g,%lx,%lx,%lx)",
967 InfiniBand
->ResourceFlags
,
969 InfiniBand
->ServiceId
,
970 InfiniBand
->TargetPortId
,
977 IN OUT POOL_PRINT
*Str
,
979 IN BOOLEAN DisplayOnly
,
980 IN BOOLEAN AllowShortcuts
983 UART_DEVICE_PATH
*Uart
;
987 switch (Uart
->Parity
) {
1017 if (Uart
->BaudRate
== 0) {
1018 CatPrint (Str
, L
"Uart(DEFAULT,");
1020 CatPrint (Str
, L
"Uart(%ld,", Uart
->BaudRate
);
1023 if (Uart
->DataBits
== 0) {
1024 CatPrint (Str
, L
"DEFAULT,");
1026 CatPrint (Str
, L
"%d,", Uart
->DataBits
);
1029 CatPrint (Str
, L
"%c,", Parity
);
1031 switch (Uart
->StopBits
) {
1033 CatPrint (Str
, L
"D)");
1037 CatPrint (Str
, L
"1)");
1041 CatPrint (Str
, L
"1.5)");
1045 CatPrint (Str
, L
"2)");
1049 CatPrint (Str
, L
"x)");
1055 DevPathToTextiSCSI (
1056 IN OUT POOL_PRINT
*Str
,
1058 IN BOOLEAN DisplayOnly
,
1059 IN BOOLEAN AllowShortcuts
1062 ISCSI_DEVICE_PATH_WITH_NAME
*iSCSI
;
1068 L
"iSCSI(%s,%x,%lx,",
1069 iSCSI
->iSCSITargetName
,
1070 iSCSI
->TargetPortalGroupTag
,
1074 Options
= iSCSI
->LoginOption
;
1075 CatPrint (Str
, L
"%s,", ((Options
>> 1) & 0x0001) ? L
"CRC32C" : L
"None");
1076 CatPrint (Str
, L
"%s,", ((Options
>> 3) & 0x0001) ? L
"CRC32C" : L
"None");
1077 if ((Options
>> 11) & 0x0001) {
1078 CatPrint (Str
, L
"%s,", L
"None");
1079 } else if ((Options
>> 12) & 0x0001) {
1080 CatPrint (Str
, L
"%s,", L
"CHAP_UNI");
1082 CatPrint (Str
, L
"%s,", L
"CHAP_BI");
1086 CatPrint (Str
, L
"%s)", (iSCSI
->NetworkProtocol
== 0) ? L
"TCP" : L
"reserved");
1090 DevPathToTextHardDrive (
1091 IN OUT POOL_PRINT
*Str
,
1093 IN BOOLEAN DisplayOnly
,
1094 IN BOOLEAN AllowShortcuts
1097 HARDDRIVE_DEVICE_PATH
*Hd
;
1100 switch (Hd
->SignatureType
) {
1105 Hd
->PartitionNumber
,
1110 case SIGNATURE_TYPE_MBR
:
1114 Hd
->PartitionNumber
,
1116 *((UINT32
*) (&(Hd
->Signature
[0])))
1120 case SIGNATURE_TYPE_GUID
:
1124 Hd
->PartitionNumber
,
1126 (EFI_GUID
*) &(Hd
->Signature
[0])
1134 CatPrint (Str
, L
"%lx,%lx)", Hd
->PartitionStart
, Hd
->PartitionSize
);
1138 DevPathToTextCDROM (
1139 IN OUT POOL_PRINT
*Str
,
1141 IN BOOLEAN DisplayOnly
,
1142 IN BOOLEAN AllowShortcuts
1145 CDROM_DEVICE_PATH
*Cd
;
1148 if (DisplayOnly
== TRUE
) {
1149 CatPrint (Str
, L
"CDROM(%x)", Cd
->BootEntry
);
1153 CatPrint (Str
, L
"CDROM(%x,%lx,%lx)", Cd
->BootEntry
, Cd
->PartitionStart
, Cd
->PartitionSize
);
1157 DevPathToTextFilePath (
1158 IN OUT POOL_PRINT
*Str
,
1160 IN BOOLEAN DisplayOnly
,
1161 IN BOOLEAN AllowShortcuts
1164 FILEPATH_DEVICE_PATH
*Fp
;
1167 CatPrint (Str
, L
"%s", Fp
->PathName
);
1171 DevPathToTextMediaProtocol (
1172 IN OUT POOL_PRINT
*Str
,
1174 IN BOOLEAN DisplayOnly
,
1175 IN BOOLEAN AllowShortcuts
1178 MEDIA_PROTOCOL_DEVICE_PATH
*MediaProt
;
1180 MediaProt
= DevPath
;
1181 CatPrint (Str
, L
"Media(%g)", &MediaProt
->Protocol
);
1186 IN OUT POOL_PRINT
*Str
,
1188 IN BOOLEAN DisplayOnly
,
1189 IN BOOLEAN AllowShortcuts
1192 BBS_BBS_DEVICE_PATH
*Bbs
;
1196 switch (Bbs
->DeviceType
) {
1197 case BBS_TYPE_FLOPPY
:
1201 case BBS_TYPE_HARDDRIVE
:
1205 case BBS_TYPE_CDROM
:
1209 case BBS_TYPE_PCMCIA
:
1217 case BBS_TYPE_EMBEDDED_NETWORK
:
1226 CatPrint (Str
, L
"BBS(%s,%a", Type
, Bbs
->String
);
1228 if (DisplayOnly
== TRUE
) {
1229 CatPrint (Str
, L
")");
1233 CatPrint (Str
, L
",%x)", Bbs
->StatusFlag
);
1237 DevPathToTextEndInstance (
1238 IN OUT POOL_PRINT
*Str
,
1240 IN BOOLEAN DisplayOnly
,
1241 IN BOOLEAN AllowShortcuts
1244 CatPrint (Str
, L
",");
1248 DevPathToTextNodeUnknown (
1249 IN OUT POOL_PRINT
*Str
,
1251 IN BOOLEAN DisplayOnly
,
1252 IN BOOLEAN AllowShortcuts
1255 CatPrint (Str
, L
"?");
1258 DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable
[] = {
1259 {HARDWARE_DEVICE_PATH
, HW_PCI_DP
, DevPathToTextPci
},
1260 {HARDWARE_DEVICE_PATH
, HW_PCCARD_DP
, DevPathToTextPccard
},
1261 {HARDWARE_DEVICE_PATH
, HW_MEMMAP_DP
, DevPathToTextMemMap
},
1262 {HARDWARE_DEVICE_PATH
, HW_VENDOR_DP
, DevPathToTextVendor
},
1263 {HARDWARE_DEVICE_PATH
, HW_CONTROLLER_DP
, DevPathToTextController
},
1264 {ACPI_DEVICE_PATH
, ACPI_DP
, DevPathToTextAcpi
},
1265 {ACPI_DEVICE_PATH
, ACPI_EXTENDED_DP
, DevPathToTextExtAcpi
},
1266 {MESSAGING_DEVICE_PATH
, MSG_ATAPI_DP
, DevPathToTextAtapi
},
1267 {MESSAGING_DEVICE_PATH
, MSG_SCSI_DP
, DevPathToTextScsi
},
1268 {MESSAGING_DEVICE_PATH
, MSG_FIBRECHANNEL_DP
, DevPathToTextFibre
},
1269 {MESSAGING_DEVICE_PATH
, MSG_1394_DP
, DevPathToText1394
},
1270 {MESSAGING_DEVICE_PATH
, MSG_USB_DP
, DevPathToTextUsb
},
1271 {MESSAGING_DEVICE_PATH
, MSG_USB_WWID_DP
, DevPathToTextUsbWWID
},
1272 {MESSAGING_DEVICE_PATH
, MSG_DEVICE_LOGICAL_UNIT_DP
, DevPathToTextLogicalUnit
},
1273 {MESSAGING_DEVICE_PATH
, MSG_USB_CLASS_DP
, DevPathToTextUsbClass
},
1274 {MESSAGING_DEVICE_PATH
, MSG_I2O_DP
, DevPathToTextI2O
},
1275 {MESSAGING_DEVICE_PATH
, MSG_MAC_ADDR_DP
, DevPathToTextMacAddr
},
1276 {MESSAGING_DEVICE_PATH
, MSG_IPv4_DP
, DevPathToTextIPv4
},
1277 {MESSAGING_DEVICE_PATH
, MSG_IPv6_DP
, DevPathToTextIPv6
},
1278 {MESSAGING_DEVICE_PATH
, MSG_INFINIBAND_DP
, DevPathToTextInfiniBand
},
1279 {MESSAGING_DEVICE_PATH
, MSG_UART_DP
, DevPathToTextUart
},
1280 {MESSAGING_DEVICE_PATH
, MSG_VENDOR_DP
, DevPathToTextVendor
},
1281 {MESSAGING_DEVICE_PATH
, MSG_ISCSI_DP
, DevPathToTextiSCSI
},
1282 {MEDIA_DEVICE_PATH
, MEDIA_HARDDRIVE_DP
, DevPathToTextHardDrive
},
1283 {MEDIA_DEVICE_PATH
, MEDIA_CDROM_DP
, DevPathToTextCDROM
},
1284 {MEDIA_DEVICE_PATH
, MEDIA_VENDOR_DP
, DevPathToTextVendor
},
1285 {MEDIA_DEVICE_PATH
, MEDIA_FILEPATH_DP
, DevPathToTextFilePath
},
1286 {MEDIA_DEVICE_PATH
, MEDIA_PROTOCOL_DP
, DevPathToTextMediaProtocol
},
1287 {MEDIA_DEVICE_PATH
, MEDIA_FILEPATH_DP
, DevPathToTextFilePath
},
1288 {BBS_DEVICE_PATH
, BBS_BBS_DP
, DevPathToTextBBS
},
1289 {END_DEVICE_PATH_TYPE
, END_INSTANCE_DEVICE_PATH_SUBTYPE
, DevPathToTextEndInstance
},
1294 ConvertDeviceNodeToText (
1295 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
1296 IN BOOLEAN DisplayOnly
,
1297 IN BOOLEAN AllowShortcuts
1301 Routine Description:
1302 Convert a device node to its text representation.
1305 DeviceNode - Points to the device node to be converted.
1306 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
1307 of the display node is used, where applicable. If DisplayOnly
1308 is FALSE, then the longer text representation of the display node
1310 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
1311 representation for a device node can be used, where applicable.
1314 A pointer - a pointer to the allocated text representation of the device node.
1315 NULL - if DeviceNode is NULL or there was insufficient memory.
1322 VOID (*DumpNode
)(POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
1324 if (DeviceNode
== NULL
) {
1328 ZeroMem (&Str
, sizeof (Str
));
1331 // Process the device path node
1334 for (Index
= 0; DevPathToTextTable
[Index
].Function
!= NULL
; Index
++) {
1335 if (DevicePathType (DeviceNode
) == DevPathToTextTable
[Index
].Type
&&
1336 DevicePathSubType (DeviceNode
) == DevPathToTextTable
[Index
].SubType
1338 DumpNode
= DevPathToTextTable
[Index
].Function
;
1343 // If not found, use a generic function
1345 if (DumpNode
== NULL
) {
1346 DumpNode
= DevPathToTextNodeUnknown
;
1352 DumpNode (&Str
, (VOID
*) DeviceNode
, DisplayOnly
, AllowShortcuts
);
1355 // Shrink pool used for string allocation
1357 NewSize
= (Str
.Len
+ 1) * sizeof (CHAR16
);
1358 Str
.Str
= ReallocatePool (Str
.Str
, NewSize
, NewSize
);
1359 ASSERT (Str
.Str
!= NULL
);
1360 Str
.Str
[Str
.Len
] = 0;
1365 ConvertDevicePathToText (
1366 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1367 IN BOOLEAN DisplayOnly
,
1368 IN BOOLEAN AllowShortcuts
1372 Routine Description:
1373 Convert a device path to its text representation.
1376 DeviceNode - Points to the device path to be converted.
1377 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
1378 of the display node is used, where applicable. If DisplayOnly
1379 is FALSE, then the longer text representation of the display node
1381 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
1382 representation for a device node can be used, where applicable.
1385 A pointer - a pointer to the allocated text representation of the device path.
1386 NULL - if DeviceNode is NULL or there was insufficient memory.
1391 EFI_DEVICE_PATH_PROTOCOL
*DevPathNode
;
1392 EFI_DEVICE_PATH_PROTOCOL
*UnpackDevPath
;
1395 VOID (*DumpNode
) (POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
1397 if (DevicePath
== NULL
) {
1401 ZeroMem (&Str
, sizeof (Str
));
1404 // Unpacked the device path
1406 UnpackDevPath
= UnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL
*) DevicePath
);
1407 ASSERT (UnpackDevPath
!= NULL
);
1410 // Process each device path node
1412 DevPathNode
= UnpackDevPath
;
1413 while (!IsDevicePathEnd (DevPathNode
)) {
1415 // Find the handler to dump this device path node
1418 for (Index
= 0; DevPathToTextTable
[Index
].Function
; Index
+= 1) {
1420 if (DevicePathType (DevPathNode
) == DevPathToTextTable
[Index
].Type
&&
1421 DevicePathSubType (DevPathNode
) == DevPathToTextTable
[Index
].SubType
1423 DumpNode
= DevPathToTextTable
[Index
].Function
;
1428 // If not found, use a generic function
1431 DumpNode
= DevPathToTextNodeUnknown
;
1434 // Put a path seperator in if needed
1436 if (Str
.Len
&& DumpNode
!= DevPathToTextEndInstance
) {
1437 if (*(Str
.Str
+ Str
.Len
/ sizeof (CHAR16
) - 1) != L
',') {
1438 CatPrint (&Str
, L
"/");
1442 // Print this node of the device path
1444 DumpNode (&Str
, DevPathNode
, DisplayOnly
, AllowShortcuts
);
1447 // Next device path node
1449 DevPathNode
= NextDevicePathNode (DevPathNode
);
1452 // Shrink pool used for string allocation
1454 gBS
->FreePool (UnpackDevPath
);
1456 NewSize
= (Str
.Len
+ 1) * sizeof (CHAR16
);
1457 Str
.Str
= ReallocatePool (Str
.Str
, NewSize
, NewSize
);
1458 ASSERT (Str
.Str
!= NULL
);
1459 Str
.Str
[Str
.Len
] = 0;