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(%x,%x)", Pci
->Function
, Pci
->Device
);
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(%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(%lx,%lx)",
248 MemMap
->StartingAddress
,
249 MemMap
->EndingAddress
255 DevPathToTextVendor (
256 IN OUT POOL_PRINT
*Str
,
258 IN BOOLEAN DisplayOnly
,
259 IN BOOLEAN AllowShortcuts
262 VENDOR_DEVICE_PATH
*Vendor
;
265 UINT32 FlowControlMap
;
268 Vendor
= (VENDOR_DEVICE_PATH
*) DevPath
;
269 switch (DevicePathType (&Vendor
->Header
)) {
270 case HARDWARE_DEVICE_PATH
:
274 case MESSAGING_DEVICE_PATH
:
276 if (AllowShortcuts
) {
277 if (CompareGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
)) {
278 CatPrint (Str
, L
"VenPcAnsi()");
280 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100Guid
)) {
281 CatPrint (Str
, L
"VenVt100()");
283 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
)) {
284 CatPrint (Str
, L
"VenVt100Plus()");
286 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
)) {
287 CatPrint (Str
, L
"VenUft8()");
289 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingUartFlowControlGuid
)) {
290 FlowControlMap
= (((UART_FLOW_CONTROL_DEVICE_PATH
*) Vendor
)->FlowControlMap
);
291 switch (FlowControlMap
& 0x00000003) {
293 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"None");
297 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"Hardware");
301 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"XonXoff");
309 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingSASGuid
)) {
313 ((SAS_DEVICE_PATH
*) Vendor
)->SasAddress
,
314 ((SAS_DEVICE_PATH
*) Vendor
)->Lun
,
315 ((SAS_DEVICE_PATH
*) Vendor
)->RelativeTargetPort
317 Info
= (((SAS_DEVICE_PATH
*) Vendor
)->DeviceTopology
);
318 if ((Info
& 0x0f) == 0) {
319 CatPrint (Str
, L
"NoTopology,0,0,0,");
320 } else if (((Info
& 0x0f) == 1) || ((Info
& 0x0f) == 2)) {
324 (Info
& (0x1 << 4)) ? L
"SATA" : L
"SAS",
325 (Info
& (0x1 << 5)) ? L
"External" : L
"Internal",
326 (Info
& (0x1 << 6)) ? L
"Expanded" : L
"Direct"
328 if ((Info
& 0x0f) == 1) {
329 CatPrint (Str
, L
"0,");
331 CatPrint (Str
, L
"%x,", (Info
>> 8) & 0xff);
334 CatPrint (Str
, L
"0,0,0,0,");
337 CatPrint (Str
, L
"%x)", ((SAS_DEVICE_PATH
*) Vendor
)->Reserved
);
339 } else if (CompareGuid (&Vendor
->Guid
, &gEfiDebugPortProtocolGuid
)) {
340 CatPrint (Str
, L
"DebugPort()");
351 case MEDIA_DEVICE_PATH
:
360 CatPrint (Str
, L
"Ven%s(%g,", Type
, &Vendor
->Guid
);
361 for (Index
= 0; Index
< DevicePathNodeLength (&Vendor
->Header
) - sizeof (VENDOR_DEVICE_PATH
); Index
++) {
362 CatPrint (Str
, L
"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA
*) Vendor
)->VendorDefinedData
[Index
]);
365 CatPrint (Str
, L
")");
370 DevPathToTextController (
371 IN OUT POOL_PRINT
*Str
,
373 IN BOOLEAN DisplayOnly
,
374 IN BOOLEAN AllowShortcuts
377 CONTROLLER_DEVICE_PATH
*Controller
;
379 Controller
= DevPath
;
383 Controller
->ControllerNumber
390 IN OUT POOL_PRINT
*Str
,
392 IN BOOLEAN DisplayOnly
,
393 IN BOOLEAN AllowShortcuts
396 ACPI_HID_DEVICE_PATH
*Acpi
;
399 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
400 if (AllowShortcuts
) {
401 switch (EISA_ID_TO_NUM (Acpi
->HID
)) {
403 CatPrint (Str
, L
"PciRoot(%x)", Acpi
->UID
);
407 CatPrint (Str
, L
"Floppy(%x)", Acpi
->UID
);
411 CatPrint (Str
, L
"Keyboard(%x)", Acpi
->UID
);
415 CatPrint (Str
, L
"Serial(%x)", Acpi
->UID
);
419 CatPrint (Str
, L
"ParallelPort(%x)", Acpi
->UID
);
429 CatPrint (Str
, L
"Acpi(PNP%04x,%x)", EISA_ID_TO_NUM (Acpi
->HID
), Acpi
->UID
);
431 CatPrint (Str
, L
"Acpi(%08x,%x)", Acpi
->HID
, Acpi
->UID
);
435 #define NextStrA(a) ((UINT8 *) (((UINT8 *) (a)) + AsciiStrLen ((CHAR8 *) (a)) + 1))
439 DevPathToTextExtAcpi (
440 IN OUT POOL_PRINT
*Str
,
442 IN BOOLEAN DisplayOnly
,
443 IN BOOLEAN AllowShortcuts
446 ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR
*AcpiExt
;
451 if (AllowShortcuts
) {
452 NextString
= NextStrA (AcpiExt
->HidUidCidStr
);
453 if ((*(AcpiExt
->HidUidCidStr
) == '\0') &&
454 (*(NextStrA (NextString
)) == '\0') &&
457 if ((AcpiExt
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
460 L
"AcpiExp(PNP%04x,%x,%a)",
461 EISA_ID_TO_NUM (AcpiExt
->HID
),
463 NextStrA (AcpiExt
->HidUidCidStr
)
468 L
"AcpiExp(%08x,%x,%a)",
471 NextStrA (AcpiExt
->HidUidCidStr
)
478 NextString
= NextStrA (AcpiExt
->HidUidCidStr
);
479 NextString
= NextStrA (NextString
);
480 if ((AcpiExt
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
483 L
"AcpiEx(PNP%04x,%x,%x,%a,%a,%a)",
484 EISA_ID_TO_NUM (AcpiExt
->HID
),
487 AcpiExt
->HidUidCidStr
,
489 NextStrA (AcpiExt
->HidUidCidStr
)
494 L
"AcpiEx(%08x,%x,%x,%a,%a,%a)",
498 AcpiExt
->HidUidCidStr
,
500 NextStrA (AcpiExt
->HidUidCidStr
)
508 IN OUT POOL_PRINT
*Str
,
510 IN BOOLEAN DisplayOnly
,
511 IN BOOLEAN AllowShortcuts
514 ATAPI_DEVICE_PATH
*Atapi
;
519 CatPrint (Str
, L
"Ata(%x)", Atapi
->Lun
);
524 Atapi
->PrimarySecondary
? L
"Secondary" : L
"Primary",
525 Atapi
->SlaveMaster
? L
"Slave" : L
"Master",
534 IN OUT POOL_PRINT
*Str
,
536 IN BOOLEAN DisplayOnly
,
537 IN BOOLEAN AllowShortcuts
540 SCSI_DEVICE_PATH
*Scsi
;
543 CatPrint (Str
, L
"Scsi(%x,%x)", Scsi
->Pun
, Scsi
->Lun
);
549 IN OUT POOL_PRINT
*Str
,
551 IN BOOLEAN DisplayOnly
,
552 IN BOOLEAN AllowShortcuts
555 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
558 CatPrint (Str
, L
"Fibre(%lx,%lx)", Fibre
->WWN
, Fibre
->Lun
);
564 IN OUT POOL_PRINT
*Str
,
566 IN BOOLEAN DisplayOnly
,
567 IN BOOLEAN AllowShortcuts
570 F1394_DEVICE_PATH
*F1394
;
573 CatPrint (Str
, L
"I1394(%lx)", F1394
->Guid
);
579 IN OUT POOL_PRINT
*Str
,
581 IN BOOLEAN DisplayOnly
,
582 IN BOOLEAN AllowShortcuts
585 USB_DEVICE_PATH
*Usb
;
588 CatPrint (Str
, L
"USB(%x,%x)", Usb
->ParentPortNumber
, Usb
->InterfaceNumber
);
593 DevPathToTextUsbWWID (
594 IN OUT POOL_PRINT
*Str
,
596 IN BOOLEAN DisplayOnly
,
597 IN BOOLEAN AllowShortcuts
600 USB_WWID_DEVICE_PATH
*UsbWWId
;
605 L
"UsbWwid(%x,%x,%x,\"WWID\")",
608 UsbWWId
->InterfaceNumber
614 DevPathToTextLogicalUnit (
615 IN OUT POOL_PRINT
*Str
,
617 IN BOOLEAN DisplayOnly
,
618 IN BOOLEAN AllowShortcuts
621 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
623 LogicalUnit
= DevPath
;
624 CatPrint (Str
, L
"Unit(%x)", LogicalUnit
->Lun
);
629 DevPathToTextUsbClass (
630 IN OUT POOL_PRINT
*Str
,
632 IN BOOLEAN DisplayOnly
,
633 IN BOOLEAN AllowShortcuts
636 USB_CLASS_DEVICE_PATH
*UsbClass
;
640 if (AllowShortcuts
== TRUE
) {
641 switch (UsbClass
->DeviceClass
) {
645 L
"UsbAudio(%x,%x,%x,%x)",
648 UsbClass
->DeviceSubClass
,
649 UsbClass
->DeviceProtocol
656 L
"UsbCDCControl(%x,%x,%x,%x)",
659 UsbClass
->DeviceSubClass
,
660 UsbClass
->DeviceProtocol
667 L
"UsbHID(%x,%x,%x,%x)",
670 UsbClass
->DeviceSubClass
,
671 UsbClass
->DeviceProtocol
678 L
"UsbImage(%x,%x,%x,%x)",
681 UsbClass
->DeviceSubClass
,
682 UsbClass
->DeviceProtocol
689 L
"UsbPrinter(%x,%x,%x,%x)",
692 UsbClass
->DeviceSubClass
,
693 UsbClass
->DeviceProtocol
700 L
"UsbMassStorage(%x,%x,%x,%x)",
703 UsbClass
->DeviceSubClass
,
704 UsbClass
->DeviceProtocol
711 L
"UsbHub(%x,%x,%x,%x)",
714 UsbClass
->DeviceSubClass
,
715 UsbClass
->DeviceProtocol
722 L
"UsbCDCData(%x,%x,%x,%x)",
725 UsbClass
->DeviceSubClass
,
726 UsbClass
->DeviceProtocol
733 L
"UsbSmartCard(%x,%x,%x,%x)",
736 UsbClass
->DeviceSubClass
,
737 UsbClass
->DeviceProtocol
744 L
"UsbVideo(%x,%x,%x,%x)",
747 UsbClass
->DeviceSubClass
,
748 UsbClass
->DeviceProtocol
755 L
"UsbDiagnostic(%x,%x,%x,%x)",
758 UsbClass
->DeviceSubClass
,
759 UsbClass
->DeviceProtocol
766 L
"UsbWireless(%x,%x,%x,%x)",
769 UsbClass
->DeviceSubClass
,
770 UsbClass
->DeviceProtocol
775 if (UsbClass
->DeviceSubClass
== 1) {
778 L
"UsbDeviceFirmwareUpdate(%x,%x,%x)",
781 UsbClass
->DeviceProtocol
783 } else if (UsbClass
->DeviceSubClass
== 2) {
786 L
"UsbIrdaBridge(%x,%x,%x)",
789 UsbClass
->DeviceProtocol
791 } else if (UsbClass
->DeviceSubClass
== 3) {
794 L
"UsbTestAndMeasurement(%x,%x,%x)",
797 UsbClass
->DeviceProtocol
811 L
"UsbClass(%x,%x,%x,%x,%x)",
814 UsbClass
->DeviceClass
,
815 UsbClass
->DeviceSubClass
,
816 UsbClass
->DeviceProtocol
823 IN OUT POOL_PRINT
*Str
,
825 IN BOOLEAN DisplayOnly
,
826 IN BOOLEAN AllowShortcuts
829 I2O_DEVICE_PATH
*I2O
;
832 CatPrint (Str
, L
"I2O(%x)", I2O
->Tid
);
837 DevPathToTextMacAddr (
838 IN OUT POOL_PRINT
*Str
,
840 IN BOOLEAN DisplayOnly
,
841 IN BOOLEAN AllowShortcuts
844 MAC_ADDR_DEVICE_PATH
*MAC
;
850 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
851 if (MAC
->IfType
== 0x01 || MAC
->IfType
== 0x00) {
855 CatPrint (Str
, L
"MAC(");
857 for (Index
= 0; Index
< HwAddressSize
; Index
++) {
858 CatPrint (Str
, L
"%02x", MAC
->MacAddress
.Addr
[Index
]);
861 CatPrint (Str
, L
",%x)", MAC
->IfType
);
867 IN OUT POOL_PRINT
*Str
,
869 IN BOOLEAN DisplayOnly
,
870 IN BOOLEAN AllowShortcuts
873 IPv4_DEVICE_PATH
*IP
;
876 if (DisplayOnly
== TRUE
) {
879 L
"IPv4(%d.%d.%d.%d)",
880 IP
->RemoteIpAddress
.Addr
[0],
881 IP
->RemoteIpAddress
.Addr
[1],
882 IP
->RemoteIpAddress
.Addr
[2],
883 IP
->RemoteIpAddress
.Addr
[3]
890 L
"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",
891 IP
->RemoteIpAddress
.Addr
[0],
892 IP
->RemoteIpAddress
.Addr
[1],
893 IP
->RemoteIpAddress
.Addr
[2],
894 IP
->RemoteIpAddress
.Addr
[3],
895 IP
->Protocol
? L
"TCP" : L
"UDP",
896 (IP
->StaticIpAddress
== TRUE
) ? L
"Static" : L
"DHCP",
897 IP
->LocalIpAddress
.Addr
[0],
898 IP
->LocalIpAddress
.Addr
[1],
899 IP
->LocalIpAddress
.Addr
[2],
900 IP
->LocalIpAddress
.Addr
[3]
907 IN OUT POOL_PRINT
*Str
,
909 IN BOOLEAN DisplayOnly
,
910 IN BOOLEAN AllowShortcuts
913 IPv6_DEVICE_PATH
*IP
;
916 if (DisplayOnly
== TRUE
) {
919 L
"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
920 IP
->RemoteIpAddress
.Addr
[0],
921 IP
->RemoteIpAddress
.Addr
[1],
922 IP
->RemoteIpAddress
.Addr
[2],
923 IP
->RemoteIpAddress
.Addr
[3],
924 IP
->RemoteIpAddress
.Addr
[4],
925 IP
->RemoteIpAddress
.Addr
[5],
926 IP
->RemoteIpAddress
.Addr
[6],
927 IP
->RemoteIpAddress
.Addr
[7],
928 IP
->RemoteIpAddress
.Addr
[8],
929 IP
->RemoteIpAddress
.Addr
[9],
930 IP
->RemoteIpAddress
.Addr
[10],
931 IP
->RemoteIpAddress
.Addr
[11],
932 IP
->RemoteIpAddress
.Addr
[12],
933 IP
->RemoteIpAddress
.Addr
[13],
934 IP
->RemoteIpAddress
.Addr
[14],
935 IP
->RemoteIpAddress
.Addr
[15]
942 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)",
943 IP
->RemoteIpAddress
.Addr
[0],
944 IP
->RemoteIpAddress
.Addr
[1],
945 IP
->RemoteIpAddress
.Addr
[2],
946 IP
->RemoteIpAddress
.Addr
[3],
947 IP
->RemoteIpAddress
.Addr
[4],
948 IP
->RemoteIpAddress
.Addr
[5],
949 IP
->RemoteIpAddress
.Addr
[6],
950 IP
->RemoteIpAddress
.Addr
[7],
951 IP
->RemoteIpAddress
.Addr
[8],
952 IP
->RemoteIpAddress
.Addr
[9],
953 IP
->RemoteIpAddress
.Addr
[10],
954 IP
->RemoteIpAddress
.Addr
[11],
955 IP
->RemoteIpAddress
.Addr
[12],
956 IP
->RemoteIpAddress
.Addr
[13],
957 IP
->RemoteIpAddress
.Addr
[14],
958 IP
->RemoteIpAddress
.Addr
[15],
959 IP
->Protocol
? L
"TCP" : L
"UDP",
960 (IP
->StaticIpAddress
== TRUE
) ? L
"Static" : L
"DHCP",
961 IP
->LocalIpAddress
.Addr
[0],
962 IP
->LocalIpAddress
.Addr
[1],
963 IP
->LocalIpAddress
.Addr
[2],
964 IP
->LocalIpAddress
.Addr
[3],
965 IP
->LocalIpAddress
.Addr
[4],
966 IP
->LocalIpAddress
.Addr
[5],
967 IP
->LocalIpAddress
.Addr
[6],
968 IP
->LocalIpAddress
.Addr
[7],
969 IP
->LocalIpAddress
.Addr
[8],
970 IP
->LocalIpAddress
.Addr
[9],
971 IP
->LocalIpAddress
.Addr
[10],
972 IP
->LocalIpAddress
.Addr
[11],
973 IP
->LocalIpAddress
.Addr
[12],
974 IP
->LocalIpAddress
.Addr
[13],
975 IP
->LocalIpAddress
.Addr
[14],
976 IP
->LocalIpAddress
.Addr
[15]
982 DevPathToTextInfiniBand (
983 IN OUT POOL_PRINT
*Str
,
985 IN BOOLEAN DisplayOnly
,
986 IN BOOLEAN AllowShortcuts
989 INFINIBAND_DEVICE_PATH
*InfiniBand
;
991 InfiniBand
= DevPath
;
994 L
"Infiniband(%x,%g,%lx,%lx,%lx)",
995 InfiniBand
->ResourceFlags
,
997 InfiniBand
->ServiceId
,
998 InfiniBand
->TargetPortId
,
1006 IN OUT POOL_PRINT
*Str
,
1008 IN BOOLEAN DisplayOnly
,
1009 IN BOOLEAN AllowShortcuts
1012 UART_DEVICE_PATH
*Uart
;
1016 switch (Uart
->Parity
) {
1046 if (Uart
->BaudRate
== 0) {
1047 CatPrint (Str
, L
"Uart(DEFAULT,");
1049 CatPrint (Str
, L
"Uart(%ld,", Uart
->BaudRate
);
1052 if (Uart
->DataBits
== 0) {
1053 CatPrint (Str
, L
"DEFAULT,");
1055 CatPrint (Str
, L
"%d,", Uart
->DataBits
);
1058 CatPrint (Str
, L
"%c,", Parity
);
1060 switch (Uart
->StopBits
) {
1062 CatPrint (Str
, L
"D)");
1066 CatPrint (Str
, L
"1)");
1070 CatPrint (Str
, L
"1.5)");
1074 CatPrint (Str
, L
"2)");
1078 CatPrint (Str
, L
"x)");
1085 DevPathToTextiSCSI (
1086 IN OUT POOL_PRINT
*Str
,
1088 IN BOOLEAN DisplayOnly
,
1089 IN BOOLEAN AllowShortcuts
1092 ISCSI_DEVICE_PATH_WITH_NAME
*iSCSI
;
1098 L
"iSCSI(%s,%x,%lx,",
1099 iSCSI
->iSCSITargetName
,
1100 iSCSI
->TargetPortalGroupTag
,
1104 Options
= iSCSI
->LoginOption
;
1105 CatPrint (Str
, L
"%s,", ((Options
>> 1) & 0x0001) ? L
"CRC32C" : L
"None");
1106 CatPrint (Str
, L
"%s,", ((Options
>> 3) & 0x0001) ? L
"CRC32C" : L
"None");
1107 if ((Options
>> 11) & 0x0001) {
1108 CatPrint (Str
, L
"%s,", L
"None");
1109 } else if ((Options
>> 12) & 0x0001) {
1110 CatPrint (Str
, L
"%s,", L
"CHAP_UNI");
1112 CatPrint (Str
, L
"%s,", L
"CHAP_BI");
1116 CatPrint (Str
, L
"%s)", (iSCSI
->NetworkProtocol
== 0) ? L
"TCP" : L
"reserved");
1121 DevPathToTextHardDrive (
1122 IN OUT POOL_PRINT
*Str
,
1124 IN BOOLEAN DisplayOnly
,
1125 IN BOOLEAN AllowShortcuts
1128 HARDDRIVE_DEVICE_PATH
*Hd
;
1131 switch (Hd
->SignatureType
) {
1136 Hd
->PartitionNumber
,
1141 case SIGNATURE_TYPE_MBR
:
1145 Hd
->PartitionNumber
,
1147 *((UINT32
*) (&(Hd
->Signature
[0])))
1151 case SIGNATURE_TYPE_GUID
:
1155 Hd
->PartitionNumber
,
1157 (EFI_GUID
*) &(Hd
->Signature
[0])
1165 CatPrint (Str
, L
"%lx,%lx)", Hd
->PartitionStart
, Hd
->PartitionSize
);
1170 DevPathToTextCDROM (
1171 IN OUT POOL_PRINT
*Str
,
1173 IN BOOLEAN DisplayOnly
,
1174 IN BOOLEAN AllowShortcuts
1177 CDROM_DEVICE_PATH
*Cd
;
1180 if (DisplayOnly
== TRUE
) {
1181 CatPrint (Str
, L
"CDROM(%x)", Cd
->BootEntry
);
1185 CatPrint (Str
, L
"CDROM(%x,%lx,%lx)", Cd
->BootEntry
, Cd
->PartitionStart
, Cd
->PartitionSize
);
1190 DevPathToTextFilePath (
1191 IN OUT POOL_PRINT
*Str
,
1193 IN BOOLEAN DisplayOnly
,
1194 IN BOOLEAN AllowShortcuts
1197 FILEPATH_DEVICE_PATH
*Fp
;
1200 CatPrint (Str
, L
"%s", Fp
->PathName
);
1205 DevPathToTextMediaProtocol (
1206 IN OUT POOL_PRINT
*Str
,
1208 IN BOOLEAN DisplayOnly
,
1209 IN BOOLEAN AllowShortcuts
1212 MEDIA_PROTOCOL_DEVICE_PATH
*MediaProt
;
1214 MediaProt
= DevPath
;
1215 CatPrint (Str
, L
"Media(%g)", &MediaProt
->Protocol
);
1221 IN OUT POOL_PRINT
*Str
,
1223 IN BOOLEAN DisplayOnly
,
1224 IN BOOLEAN AllowShortcuts
1227 BBS_BBS_DEVICE_PATH
*Bbs
;
1231 switch (Bbs
->DeviceType
) {
1232 case BBS_TYPE_FLOPPY
:
1236 case BBS_TYPE_HARDDRIVE
:
1240 case BBS_TYPE_CDROM
:
1244 case BBS_TYPE_PCMCIA
:
1252 case BBS_TYPE_EMBEDDED_NETWORK
:
1261 CatPrint (Str
, L
"BBS(%s,%a", Type
, Bbs
->String
);
1263 if (DisplayOnly
== TRUE
) {
1264 CatPrint (Str
, L
")");
1268 CatPrint (Str
, L
",%x)", Bbs
->StatusFlag
);
1273 DevPathToTextEndInstance (
1274 IN OUT POOL_PRINT
*Str
,
1276 IN BOOLEAN DisplayOnly
,
1277 IN BOOLEAN AllowShortcuts
1280 CatPrint (Str
, L
",");
1285 DevPathToTextNodeUnknown (
1286 IN OUT POOL_PRINT
*Str
,
1288 IN BOOLEAN DisplayOnly
,
1289 IN BOOLEAN AllowShortcuts
1292 CatPrint (Str
, L
"?");
1295 GLOBAL_REMOVE_IF_UNREFERENCED
const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable
[] = {
1296 {HARDWARE_DEVICE_PATH
, HW_PCI_DP
, DevPathToTextPci
},
1297 {HARDWARE_DEVICE_PATH
, HW_PCCARD_DP
, DevPathToTextPccard
},
1298 {HARDWARE_DEVICE_PATH
, HW_MEMMAP_DP
, DevPathToTextMemMap
},
1299 {HARDWARE_DEVICE_PATH
, HW_VENDOR_DP
, DevPathToTextVendor
},
1300 {HARDWARE_DEVICE_PATH
, HW_CONTROLLER_DP
, DevPathToTextController
},
1301 {ACPI_DEVICE_PATH
, ACPI_DP
, DevPathToTextAcpi
},
1302 {ACPI_DEVICE_PATH
, ACPI_EXTENDED_DP
, DevPathToTextExtAcpi
},
1303 {MESSAGING_DEVICE_PATH
, MSG_ATAPI_DP
, DevPathToTextAtapi
},
1304 {MESSAGING_DEVICE_PATH
, MSG_SCSI_DP
, DevPathToTextScsi
},
1305 {MESSAGING_DEVICE_PATH
, MSG_FIBRECHANNEL_DP
, DevPathToTextFibre
},
1306 {MESSAGING_DEVICE_PATH
, MSG_1394_DP
, DevPathToText1394
},
1307 {MESSAGING_DEVICE_PATH
, MSG_USB_DP
, DevPathToTextUsb
},
1308 {MESSAGING_DEVICE_PATH
, MSG_USB_WWID_DP
, DevPathToTextUsbWWID
},
1309 {MESSAGING_DEVICE_PATH
, MSG_DEVICE_LOGICAL_UNIT_DP
, DevPathToTextLogicalUnit
},
1310 {MESSAGING_DEVICE_PATH
, MSG_USB_CLASS_DP
, DevPathToTextUsbClass
},
1311 {MESSAGING_DEVICE_PATH
, MSG_I2O_DP
, DevPathToTextI2O
},
1312 {MESSAGING_DEVICE_PATH
, MSG_MAC_ADDR_DP
, DevPathToTextMacAddr
},
1313 {MESSAGING_DEVICE_PATH
, MSG_IPv4_DP
, DevPathToTextIPv4
},
1314 {MESSAGING_DEVICE_PATH
, MSG_IPv6_DP
, DevPathToTextIPv6
},
1315 {MESSAGING_DEVICE_PATH
, MSG_INFINIBAND_DP
, DevPathToTextInfiniBand
},
1316 {MESSAGING_DEVICE_PATH
, MSG_UART_DP
, DevPathToTextUart
},
1317 {MESSAGING_DEVICE_PATH
, MSG_VENDOR_DP
, DevPathToTextVendor
},
1318 {MESSAGING_DEVICE_PATH
, MSG_ISCSI_DP
, DevPathToTextiSCSI
},
1319 {MEDIA_DEVICE_PATH
, MEDIA_HARDDRIVE_DP
, DevPathToTextHardDrive
},
1320 {MEDIA_DEVICE_PATH
, MEDIA_CDROM_DP
, DevPathToTextCDROM
},
1321 {MEDIA_DEVICE_PATH
, MEDIA_VENDOR_DP
, DevPathToTextVendor
},
1322 {MEDIA_DEVICE_PATH
, MEDIA_FILEPATH_DP
, DevPathToTextFilePath
},
1323 {MEDIA_DEVICE_PATH
, MEDIA_PROTOCOL_DP
, DevPathToTextMediaProtocol
},
1324 {MEDIA_DEVICE_PATH
, MEDIA_FILEPATH_DP
, DevPathToTextFilePath
},
1325 {BBS_DEVICE_PATH
, BBS_BBS_DP
, DevPathToTextBBS
},
1326 {END_DEVICE_PATH_TYPE
, END_INSTANCE_DEVICE_PATH_SUBTYPE
, DevPathToTextEndInstance
},
1331 ConvertDeviceNodeToText (
1332 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
1333 IN BOOLEAN DisplayOnly
,
1334 IN BOOLEAN AllowShortcuts
1338 Routine Description:
1339 Convert a device node to its text representation.
1342 DeviceNode - Points to the device node to be converted.
1343 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
1344 of the display node is used, where applicable. If DisplayOnly
1345 is FALSE, then the longer text representation of the display node
1347 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
1348 representation for a device node can be used, where applicable.
1351 A pointer - a pointer to the allocated text representation of the device node.
1352 NULL - if DeviceNode is NULL or there was insufficient memory.
1359 VOID (*DumpNode
)(POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
1361 if (DeviceNode
== NULL
) {
1365 ZeroMem (&Str
, sizeof (Str
));
1368 // Process the device path node
1371 for (Index
= 0; DevPathToTextTable
[Index
].Function
!= NULL
; Index
++) {
1372 if (DevicePathType (DeviceNode
) == DevPathToTextTable
[Index
].Type
&&
1373 DevicePathSubType (DeviceNode
) == DevPathToTextTable
[Index
].SubType
1375 DumpNode
= DevPathToTextTable
[Index
].Function
;
1380 // If not found, use a generic function
1382 if (DumpNode
== NULL
) {
1383 DumpNode
= DevPathToTextNodeUnknown
;
1389 DumpNode (&Str
, (VOID
*) DeviceNode
, DisplayOnly
, AllowShortcuts
);
1392 // Shrink pool used for string allocation
1394 NewSize
= (Str
.Len
+ 1) * sizeof (CHAR16
);
1395 Str
.Str
= ReallocatePool (Str
.Str
, NewSize
, NewSize
);
1396 ASSERT (Str
.Str
!= NULL
);
1397 Str
.Str
[Str
.Len
] = 0;
1402 ConvertDevicePathToText (
1403 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1404 IN BOOLEAN DisplayOnly
,
1405 IN BOOLEAN AllowShortcuts
1409 Routine Description:
1410 Convert a device path to its text representation.
1413 DeviceNode - Points to the device path to be converted.
1414 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
1415 of the display node is used, where applicable. If DisplayOnly
1416 is FALSE, then the longer text representation of the display node
1418 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
1419 representation for a device node can be used, where applicable.
1422 A pointer - a pointer to the allocated text representation of the device path.
1423 NULL - if DeviceNode is NULL or there was insufficient memory.
1428 EFI_DEVICE_PATH_PROTOCOL
*DevPathNode
;
1429 EFI_DEVICE_PATH_PROTOCOL
*UnpackDevPath
;
1432 VOID (*DumpNode
) (POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
1434 if (DevicePath
== NULL
) {
1438 ZeroMem (&Str
, sizeof (Str
));
1441 // Unpacked the device path
1443 UnpackDevPath
= UnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL
*) DevicePath
);
1444 ASSERT (UnpackDevPath
!= NULL
);
1447 // Process each device path node
1449 DevPathNode
= UnpackDevPath
;
1450 while (!IsDevicePathEnd (DevPathNode
)) {
1452 // Find the handler to dump this device path node
1455 for (Index
= 0; DevPathToTextTable
[Index
].Function
; Index
+= 1) {
1457 if (DevicePathType (DevPathNode
) == DevPathToTextTable
[Index
].Type
&&
1458 DevicePathSubType (DevPathNode
) == DevPathToTextTable
[Index
].SubType
1460 DumpNode
= DevPathToTextTable
[Index
].Function
;
1465 // If not found, use a generic function
1468 DumpNode
= DevPathToTextNodeUnknown
;
1471 // Put a path seperator in if needed
1473 if (Str
.Len
&& DumpNode
!= DevPathToTextEndInstance
) {
1474 if (*(Str
.Str
+ Str
.Len
/ sizeof (CHAR16
) - 1) != L
',') {
1475 CatPrint (&Str
, L
"/");
1479 // Print this node of the device path
1481 DumpNode (&Str
, DevPathNode
, DisplayOnly
, AllowShortcuts
);
1484 // Next device path node
1486 DevPathNode
= NextDevicePathNode (DevPathNode
);
1489 // Shrink pool used for string allocation
1491 FreePool (UnpackDevPath
);
1493 NewSize
= (Str
.Len
+ 1) * sizeof (CHAR16
);
1494 Str
.Str
= ReallocatePool (Str
.Str
, NewSize
, NewSize
);
1495 ASSERT (Str
.Str
!= NULL
);
1496 Str
.Str
[Str
.Len
] = 0;