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.
23 // Include common header file for this module.
25 #include "CommonHeader.h"
27 #include "DevicePath.h"
30 EFI_DEVICE_PATH_PROTOCOL
*
32 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
37 Function unpacks a device path data structure so that all the nodes of a device path
38 are naturally aligned.
41 DevPath - A pointer to a device path data structure
44 If the memory for the device path is successfully allocated, then a pointer to the
45 new device path is returned. Otherwise, NULL is returned.
49 EFI_DEVICE_PATH_PROTOCOL
*Src
;
50 EFI_DEVICE_PATH_PROTOCOL
*Dest
;
51 EFI_DEVICE_PATH_PROTOCOL
*NewPath
;
54 if (DevPath
== NULL
) {
58 // Walk device path and round sizes to valid boundries
63 Size
+= DevicePathNodeLength (Src
);
64 Size
+= ALIGN_SIZE (Size
);
66 if (IsDevicePathEnd (Src
)) {
70 Src
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (Src
);
73 // Allocate space for the unpacked path
75 NewPath
= AllocateZeroPool (Size
);
76 if (NewPath
!= NULL
) {
78 ASSERT (((UINTN
) NewPath
) % MIN_ALIGNMENT_SIZE
== 0);
86 Size
= DevicePathNodeLength (Src
);
87 CopyMem (Dest
, Src
, Size
);
88 Size
+= ALIGN_SIZE (Size
);
89 SetDevicePathNodeLength (Dest
, Size
);
90 Dest
->Type
|= EFI_DP_TYPE_UNPACKED
;
91 Dest
= (EFI_DEVICE_PATH_PROTOCOL
*) (((UINT8
*) Dest
) + Size
);
93 if (IsDevicePathEnd (Src
)) {
97 Src
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (Src
);
114 Adjusts the size of a previously allocated buffer.
117 OldPool - A pointer to the buffer whose size is being adjusted.
118 OldSize - The size of the current buffer.
119 NewSize - The size of the new buffer.
122 EFI_SUCEESS - The requested number of bytes were allocated.
123 EFI_OUT_OF_RESOURCES - The pool requested could not be allocated.
124 EFI_INVALID_PARAMETER - The buffer was invalid.
132 NewPool
= AllocateZeroPool (NewSize
);
137 CopyMem (NewPool
, OldPool
, OldSize
< NewSize
? OldSize
: NewSize
);
149 IN OUT POOL_PRINT
*Str
,
156 Concatenates a formatted unicode string to allocated pool.
157 The caller must free the resulting buffer.
160 Str - Tracks the allocated pool, size in use, and
161 amount of pool allocated.
162 Fmt - The format string
165 Allocated buffer with the formatted string printed in it.
166 The caller must free the allocated buffer. The buffer
167 allocation is not packed.
175 AppendStr
= AllocateZeroPool (0x1000);
176 if (AppendStr
== NULL
) {
180 VA_START (Args
, Fmt
);
181 UnicodeVSPrint (AppendStr
, 0x1000, Fmt
, Args
);
183 if (NULL
== Str
->Str
) {
184 Size
= StrSize (AppendStr
);
185 Str
->Str
= AllocateZeroPool (Size
);
186 ASSERT (Str
->Str
!= NULL
);
188 Size
= StrSize (AppendStr
) - sizeof (UINT16
);
189 Size
= Size
+ StrSize (Str
->Str
);
190 Str
->Str
= ReallocatePool (
195 ASSERT (Str
->Str
!= NULL
);
198 Str
->MaxLen
= MAX_CHAR
* sizeof (UINT16
);
199 if (Size
< Str
->MaxLen
) {
200 StrCat (Str
->Str
, AppendStr
);
201 Str
->Len
= Size
- sizeof (UINT16
);
204 FreePool (AppendStr
);
211 IN OUT POOL_PRINT
*Str
,
213 IN BOOLEAN DisplayOnly
,
214 IN BOOLEAN AllowShortcuts
217 PCI_DEVICE_PATH
*Pci
;
220 CatPrint (Str
, L
"Pci(%x,%x)", Pci
->Function
, Pci
->Device
);
225 DevPathToTextPccard (
226 IN OUT POOL_PRINT
*Str
,
228 IN BOOLEAN DisplayOnly
,
229 IN BOOLEAN AllowShortcuts
232 PCCARD_DEVICE_PATH
*Pccard
;
235 CatPrint (Str
, L
"PcCard(%x)", Pccard
->FunctionNumber
);
240 DevPathToTextMemMap (
241 IN OUT POOL_PRINT
*Str
,
243 IN BOOLEAN DisplayOnly
,
244 IN BOOLEAN AllowShortcuts
247 MEMMAP_DEVICE_PATH
*MemMap
;
252 L
"MemoryMapped(%lx,%lx)",
253 MemMap
->StartingAddress
,
254 MemMap
->EndingAddress
260 DevPathToTextVendor (
261 IN OUT POOL_PRINT
*Str
,
263 IN BOOLEAN DisplayOnly
,
264 IN BOOLEAN AllowShortcuts
267 VENDOR_DEVICE_PATH
*Vendor
;
270 UINT32 FlowControlMap
;
273 Vendor
= (VENDOR_DEVICE_PATH
*) DevPath
;
274 switch (DevicePathType (&Vendor
->Header
)) {
275 case HARDWARE_DEVICE_PATH
:
279 case MESSAGING_DEVICE_PATH
:
281 if (AllowShortcuts
) {
282 if (CompareGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
)) {
283 CatPrint (Str
, L
"VenPcAnsi()");
285 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100Guid
)) {
286 CatPrint (Str
, L
"VenVt100()");
288 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
)) {
289 CatPrint (Str
, L
"VenVt100Plus()");
291 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
)) {
292 CatPrint (Str
, L
"VenUft8()");
294 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingUartFlowControlGuid
)) {
295 FlowControlMap
= (((UART_FLOW_CONTROL_DEVICE_PATH
*) Vendor
)->FlowControlMap
);
296 switch (FlowControlMap
& 0x00000003) {
298 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"None");
302 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"Hardware");
306 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"XonXoff");
314 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingSASGuid
)) {
318 ((SAS_DEVICE_PATH
*) Vendor
)->SasAddress
,
319 ((SAS_DEVICE_PATH
*) Vendor
)->Lun
,
320 ((SAS_DEVICE_PATH
*) Vendor
)->RelativeTargetPort
322 Info
= (((SAS_DEVICE_PATH
*) Vendor
)->DeviceTopology
);
323 if ((Info
& 0x0f) == 0) {
324 CatPrint (Str
, L
"NoTopology,0,0,0,");
325 } else if (((Info
& 0x0f) == 1) || ((Info
& 0x0f) == 2)) {
329 (Info
& (0x1 << 4)) ? L
"SATA" : L
"SAS",
330 (Info
& (0x1 << 5)) ? L
"External" : L
"Internal",
331 (Info
& (0x1 << 6)) ? L
"Expanded" : L
"Direct"
333 if ((Info
& 0x0f) == 1) {
334 CatPrint (Str
, L
"0,");
336 CatPrint (Str
, L
"%x,", (Info
>> 8) & 0xff);
339 CatPrint (Str
, L
"0,0,0,0,");
342 CatPrint (Str
, L
"%x)", ((SAS_DEVICE_PATH
*) Vendor
)->Reserved
);
344 } else if (CompareGuid (&Vendor
->Guid
, &gEfiDebugPortProtocolGuid
)) {
345 CatPrint (Str
, L
"DebugPort()");
356 case MEDIA_DEVICE_PATH
:
365 CatPrint (Str
, L
"Ven%s(%g,", Type
, &Vendor
->Guid
);
366 for (Index
= 0; Index
< DevicePathNodeLength (&Vendor
->Header
) - sizeof (VENDOR_DEVICE_PATH
); Index
++) {
367 CatPrint (Str
, L
"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA
*) Vendor
)->VendorDefinedData
[Index
]);
370 CatPrint (Str
, L
")");
375 DevPathToTextController (
376 IN OUT POOL_PRINT
*Str
,
378 IN BOOLEAN DisplayOnly
,
379 IN BOOLEAN AllowShortcuts
382 CONTROLLER_DEVICE_PATH
*Controller
;
384 Controller
= DevPath
;
388 Controller
->ControllerNumber
395 IN OUT POOL_PRINT
*Str
,
397 IN BOOLEAN DisplayOnly
,
398 IN BOOLEAN AllowShortcuts
401 ACPI_HID_DEVICE_PATH
*Acpi
;
404 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
405 if (AllowShortcuts
) {
406 switch (EISA_ID_TO_NUM (Acpi
->HID
)) {
408 CatPrint (Str
, L
"PciRoot(%x)", Acpi
->UID
);
412 CatPrint (Str
, L
"Floppy(%x)", Acpi
->UID
);
416 CatPrint (Str
, L
"Keyboard(%x)", Acpi
->UID
);
420 CatPrint (Str
, L
"Serial(%x)", Acpi
->UID
);
424 CatPrint (Str
, L
"ParallelPort(%x)", Acpi
->UID
);
434 CatPrint (Str
, L
"Acpi(PNP%04x,%x)", EISA_ID_TO_NUM (Acpi
->HID
), Acpi
->UID
);
436 CatPrint (Str
, L
"Acpi(%08x,%x)", Acpi
->HID
, Acpi
->UID
);
440 #define NextStrA(a) ((UINT8 *) (((UINT8 *) (a)) + AsciiStrLen ((CHAR8 *) (a)) + 1))
444 DevPathToTextExtAcpi (
445 IN OUT POOL_PRINT
*Str
,
447 IN BOOLEAN DisplayOnly
,
448 IN BOOLEAN AllowShortcuts
451 ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR
*AcpiExt
;
456 if (AllowShortcuts
) {
457 NextString
= NextStrA (AcpiExt
->HidUidCidStr
);
458 if ((*(AcpiExt
->HidUidCidStr
) == '\0') &&
459 (*(NextStrA (NextString
)) == '\0') &&
462 if ((AcpiExt
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
465 L
"AcpiExp(PNP%04x,%x,%a)",
466 EISA_ID_TO_NUM (AcpiExt
->HID
),
468 NextStrA (AcpiExt
->HidUidCidStr
)
473 L
"AcpiExp(%08x,%x,%a)",
476 NextStrA (AcpiExt
->HidUidCidStr
)
483 NextString
= NextStrA (AcpiExt
->HidUidCidStr
);
484 NextString
= NextStrA (NextString
);
485 if ((AcpiExt
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
488 L
"AcpiEx(PNP%04x,%x,%x,%a,%a,%a)",
489 EISA_ID_TO_NUM (AcpiExt
->HID
),
492 AcpiExt
->HidUidCidStr
,
494 NextStrA (AcpiExt
->HidUidCidStr
)
499 L
"AcpiEx(%08x,%x,%x,%a,%a,%a)",
503 AcpiExt
->HidUidCidStr
,
505 NextStrA (AcpiExt
->HidUidCidStr
)
513 IN OUT POOL_PRINT
*Str
,
515 IN BOOLEAN DisplayOnly
,
516 IN BOOLEAN AllowShortcuts
519 ATAPI_DEVICE_PATH
*Atapi
;
524 CatPrint (Str
, L
"Ata(%x)", Atapi
->Lun
);
529 Atapi
->PrimarySecondary
? L
"Secondary" : L
"Primary",
530 Atapi
->SlaveMaster
? L
"Slave" : L
"Master",
539 IN OUT POOL_PRINT
*Str
,
541 IN BOOLEAN DisplayOnly
,
542 IN BOOLEAN AllowShortcuts
545 SCSI_DEVICE_PATH
*Scsi
;
548 CatPrint (Str
, L
"Scsi(%x,%x)", Scsi
->Pun
, Scsi
->Lun
);
554 IN OUT POOL_PRINT
*Str
,
556 IN BOOLEAN DisplayOnly
,
557 IN BOOLEAN AllowShortcuts
560 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
563 CatPrint (Str
, L
"Fibre(%lx,%lx)", Fibre
->WWN
, Fibre
->Lun
);
569 IN OUT POOL_PRINT
*Str
,
571 IN BOOLEAN DisplayOnly
,
572 IN BOOLEAN AllowShortcuts
575 F1394_DEVICE_PATH
*F1394
;
578 CatPrint (Str
, L
"I1394(%lx)", F1394
->Guid
);
584 IN OUT POOL_PRINT
*Str
,
586 IN BOOLEAN DisplayOnly
,
587 IN BOOLEAN AllowShortcuts
590 USB_DEVICE_PATH
*Usb
;
593 CatPrint (Str
, L
"USB(%x,%x)", Usb
->ParentPortNumber
, Usb
->InterfaceNumber
);
598 DevPathToTextUsbWWID (
599 IN OUT POOL_PRINT
*Str
,
601 IN BOOLEAN DisplayOnly
,
602 IN BOOLEAN AllowShortcuts
605 USB_WWID_DEVICE_PATH
*UsbWWId
;
610 L
"UsbWwid(%x,%x,%x,\"WWID\")",
613 UsbWWId
->InterfaceNumber
619 DevPathToTextLogicalUnit (
620 IN OUT POOL_PRINT
*Str
,
622 IN BOOLEAN DisplayOnly
,
623 IN BOOLEAN AllowShortcuts
626 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
628 LogicalUnit
= DevPath
;
629 CatPrint (Str
, L
"Unit(%x)", LogicalUnit
->Lun
);
634 DevPathToTextUsbClass (
635 IN OUT POOL_PRINT
*Str
,
637 IN BOOLEAN DisplayOnly
,
638 IN BOOLEAN AllowShortcuts
641 USB_CLASS_DEVICE_PATH
*UsbClass
;
645 if (AllowShortcuts
== TRUE
) {
646 switch (UsbClass
->DeviceClass
) {
650 L
"UsbAudio(%x,%x,%x,%x)",
653 UsbClass
->DeviceSubClass
,
654 UsbClass
->DeviceProtocol
661 L
"UsbCDCControl(%x,%x,%x,%x)",
664 UsbClass
->DeviceSubClass
,
665 UsbClass
->DeviceProtocol
672 L
"UsbHID(%x,%x,%x,%x)",
675 UsbClass
->DeviceSubClass
,
676 UsbClass
->DeviceProtocol
683 L
"UsbImage(%x,%x,%x,%x)",
686 UsbClass
->DeviceSubClass
,
687 UsbClass
->DeviceProtocol
694 L
"UsbPrinter(%x,%x,%x,%x)",
697 UsbClass
->DeviceSubClass
,
698 UsbClass
->DeviceProtocol
705 L
"UsbMassStorage(%x,%x,%x,%x)",
708 UsbClass
->DeviceSubClass
,
709 UsbClass
->DeviceProtocol
716 L
"UsbHub(%x,%x,%x,%x)",
719 UsbClass
->DeviceSubClass
,
720 UsbClass
->DeviceProtocol
727 L
"UsbCDCData(%x,%x,%x,%x)",
730 UsbClass
->DeviceSubClass
,
731 UsbClass
->DeviceProtocol
738 L
"UsbSmartCard(%x,%x,%x,%x)",
741 UsbClass
->DeviceSubClass
,
742 UsbClass
->DeviceProtocol
749 L
"UsbVideo(%x,%x,%x,%x)",
752 UsbClass
->DeviceSubClass
,
753 UsbClass
->DeviceProtocol
760 L
"UsbDiagnostic(%x,%x,%x,%x)",
763 UsbClass
->DeviceSubClass
,
764 UsbClass
->DeviceProtocol
771 L
"UsbWireless(%x,%x,%x,%x)",
774 UsbClass
->DeviceSubClass
,
775 UsbClass
->DeviceProtocol
780 if (UsbClass
->DeviceSubClass
== 1) {
783 L
"UsbDeviceFirmwareUpdate(%x,%x,%x)",
786 UsbClass
->DeviceProtocol
788 } else if (UsbClass
->DeviceSubClass
== 2) {
791 L
"UsbIrdaBridge(%x,%x,%x)",
794 UsbClass
->DeviceProtocol
796 } else if (UsbClass
->DeviceSubClass
== 3) {
799 L
"UsbTestAndMeasurement(%x,%x,%x)",
802 UsbClass
->DeviceProtocol
816 L
"UsbClass(%x,%x,%x,%x,%x)",
819 UsbClass
->DeviceClass
,
820 UsbClass
->DeviceSubClass
,
821 UsbClass
->DeviceProtocol
828 IN OUT POOL_PRINT
*Str
,
830 IN BOOLEAN DisplayOnly
,
831 IN BOOLEAN AllowShortcuts
834 I2O_DEVICE_PATH
*I2O
;
837 CatPrint (Str
, L
"I2O(%x)", I2O
->Tid
);
842 DevPathToTextMacAddr (
843 IN OUT POOL_PRINT
*Str
,
845 IN BOOLEAN DisplayOnly
,
846 IN BOOLEAN AllowShortcuts
849 MAC_ADDR_DEVICE_PATH
*MAC
;
855 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
856 if (MAC
->IfType
== 0x01 || MAC
->IfType
== 0x00) {
860 CatPrint (Str
, L
"MAC(");
862 for (Index
= 0; Index
< HwAddressSize
; Index
++) {
863 CatPrint (Str
, L
"%02x", MAC
->MacAddress
.Addr
[Index
]);
866 CatPrint (Str
, L
",%x)", MAC
->IfType
);
872 IN OUT POOL_PRINT
*Str
,
874 IN BOOLEAN DisplayOnly
,
875 IN BOOLEAN AllowShortcuts
878 IPv4_DEVICE_PATH
*IP
;
881 if (DisplayOnly
== TRUE
) {
884 L
"IPv4(%d.%d.%d.%d)",
885 IP
->RemoteIpAddress
.Addr
[0],
886 IP
->RemoteIpAddress
.Addr
[1],
887 IP
->RemoteIpAddress
.Addr
[2],
888 IP
->RemoteIpAddress
.Addr
[3]
895 L
"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",
896 IP
->RemoteIpAddress
.Addr
[0],
897 IP
->RemoteIpAddress
.Addr
[1],
898 IP
->RemoteIpAddress
.Addr
[2],
899 IP
->RemoteIpAddress
.Addr
[3],
900 IP
->Protocol
? L
"TCP" : L
"UDP",
901 (IP
->StaticIpAddress
== TRUE
) ? L
"Static" : L
"DHCP",
902 IP
->LocalIpAddress
.Addr
[0],
903 IP
->LocalIpAddress
.Addr
[1],
904 IP
->LocalIpAddress
.Addr
[2],
905 IP
->LocalIpAddress
.Addr
[3]
912 IN OUT POOL_PRINT
*Str
,
914 IN BOOLEAN DisplayOnly
,
915 IN BOOLEAN AllowShortcuts
918 IPv6_DEVICE_PATH
*IP
;
921 if (DisplayOnly
== TRUE
) {
924 L
"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
925 IP
->RemoteIpAddress
.Addr
[0],
926 IP
->RemoteIpAddress
.Addr
[1],
927 IP
->RemoteIpAddress
.Addr
[2],
928 IP
->RemoteIpAddress
.Addr
[3],
929 IP
->RemoteIpAddress
.Addr
[4],
930 IP
->RemoteIpAddress
.Addr
[5],
931 IP
->RemoteIpAddress
.Addr
[6],
932 IP
->RemoteIpAddress
.Addr
[7],
933 IP
->RemoteIpAddress
.Addr
[8],
934 IP
->RemoteIpAddress
.Addr
[9],
935 IP
->RemoteIpAddress
.Addr
[10],
936 IP
->RemoteIpAddress
.Addr
[11],
937 IP
->RemoteIpAddress
.Addr
[12],
938 IP
->RemoteIpAddress
.Addr
[13],
939 IP
->RemoteIpAddress
.Addr
[14],
940 IP
->RemoteIpAddress
.Addr
[15]
947 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)",
948 IP
->RemoteIpAddress
.Addr
[0],
949 IP
->RemoteIpAddress
.Addr
[1],
950 IP
->RemoteIpAddress
.Addr
[2],
951 IP
->RemoteIpAddress
.Addr
[3],
952 IP
->RemoteIpAddress
.Addr
[4],
953 IP
->RemoteIpAddress
.Addr
[5],
954 IP
->RemoteIpAddress
.Addr
[6],
955 IP
->RemoteIpAddress
.Addr
[7],
956 IP
->RemoteIpAddress
.Addr
[8],
957 IP
->RemoteIpAddress
.Addr
[9],
958 IP
->RemoteIpAddress
.Addr
[10],
959 IP
->RemoteIpAddress
.Addr
[11],
960 IP
->RemoteIpAddress
.Addr
[12],
961 IP
->RemoteIpAddress
.Addr
[13],
962 IP
->RemoteIpAddress
.Addr
[14],
963 IP
->RemoteIpAddress
.Addr
[15],
964 IP
->Protocol
? L
"TCP" : L
"UDP",
965 (IP
->StaticIpAddress
== TRUE
) ? L
"Static" : L
"DHCP",
966 IP
->LocalIpAddress
.Addr
[0],
967 IP
->LocalIpAddress
.Addr
[1],
968 IP
->LocalIpAddress
.Addr
[2],
969 IP
->LocalIpAddress
.Addr
[3],
970 IP
->LocalIpAddress
.Addr
[4],
971 IP
->LocalIpAddress
.Addr
[5],
972 IP
->LocalIpAddress
.Addr
[6],
973 IP
->LocalIpAddress
.Addr
[7],
974 IP
->LocalIpAddress
.Addr
[8],
975 IP
->LocalIpAddress
.Addr
[9],
976 IP
->LocalIpAddress
.Addr
[10],
977 IP
->LocalIpAddress
.Addr
[11],
978 IP
->LocalIpAddress
.Addr
[12],
979 IP
->LocalIpAddress
.Addr
[13],
980 IP
->LocalIpAddress
.Addr
[14],
981 IP
->LocalIpAddress
.Addr
[15]
987 DevPathToTextInfiniBand (
988 IN OUT POOL_PRINT
*Str
,
990 IN BOOLEAN DisplayOnly
,
991 IN BOOLEAN AllowShortcuts
994 INFINIBAND_DEVICE_PATH
*InfiniBand
;
996 InfiniBand
= DevPath
;
999 L
"Infiniband(%x,%g,%lx,%lx,%lx)",
1000 InfiniBand
->ResourceFlags
,
1001 InfiniBand
->PortGid
,
1002 InfiniBand
->ServiceId
,
1003 InfiniBand
->TargetPortId
,
1004 InfiniBand
->DeviceId
1011 IN OUT POOL_PRINT
*Str
,
1013 IN BOOLEAN DisplayOnly
,
1014 IN BOOLEAN AllowShortcuts
1017 UART_DEVICE_PATH
*Uart
;
1021 switch (Uart
->Parity
) {
1051 if (Uart
->BaudRate
== 0) {
1052 CatPrint (Str
, L
"Uart(DEFAULT,");
1054 CatPrint (Str
, L
"Uart(%ld,", Uart
->BaudRate
);
1057 if (Uart
->DataBits
== 0) {
1058 CatPrint (Str
, L
"DEFAULT,");
1060 CatPrint (Str
, L
"%d,", Uart
->DataBits
);
1063 CatPrint (Str
, L
"%c,", Parity
);
1065 switch (Uart
->StopBits
) {
1067 CatPrint (Str
, L
"D)");
1071 CatPrint (Str
, L
"1)");
1075 CatPrint (Str
, L
"1.5)");
1079 CatPrint (Str
, L
"2)");
1083 CatPrint (Str
, L
"x)");
1090 DevPathToTextiSCSI (
1091 IN OUT POOL_PRINT
*Str
,
1093 IN BOOLEAN DisplayOnly
,
1094 IN BOOLEAN AllowShortcuts
1097 ISCSI_DEVICE_PATH_WITH_NAME
*iSCSI
;
1103 L
"iSCSI(%s,%x,%lx,",
1104 iSCSI
->iSCSITargetName
,
1105 iSCSI
->TargetPortalGroupTag
,
1109 Options
= iSCSI
->LoginOption
;
1110 CatPrint (Str
, L
"%s,", ((Options
>> 1) & 0x0001) ? L
"CRC32C" : L
"None");
1111 CatPrint (Str
, L
"%s,", ((Options
>> 3) & 0x0001) ? L
"CRC32C" : L
"None");
1112 if ((Options
>> 11) & 0x0001) {
1113 CatPrint (Str
, L
"%s,", L
"None");
1114 } else if ((Options
>> 12) & 0x0001) {
1115 CatPrint (Str
, L
"%s,", L
"CHAP_UNI");
1117 CatPrint (Str
, L
"%s,", L
"CHAP_BI");
1121 CatPrint (Str
, L
"%s)", (iSCSI
->NetworkProtocol
== 0) ? L
"TCP" : L
"reserved");
1126 DevPathToTextHardDrive (
1127 IN OUT POOL_PRINT
*Str
,
1129 IN BOOLEAN DisplayOnly
,
1130 IN BOOLEAN AllowShortcuts
1133 HARDDRIVE_DEVICE_PATH
*Hd
;
1136 switch (Hd
->SignatureType
) {
1141 Hd
->PartitionNumber
,
1146 case SIGNATURE_TYPE_MBR
:
1150 Hd
->PartitionNumber
,
1152 *((UINT32
*) (&(Hd
->Signature
[0])))
1156 case SIGNATURE_TYPE_GUID
:
1160 Hd
->PartitionNumber
,
1162 (EFI_GUID
*) &(Hd
->Signature
[0])
1170 CatPrint (Str
, L
"%lx,%lx)", Hd
->PartitionStart
, Hd
->PartitionSize
);
1175 DevPathToTextCDROM (
1176 IN OUT POOL_PRINT
*Str
,
1178 IN BOOLEAN DisplayOnly
,
1179 IN BOOLEAN AllowShortcuts
1182 CDROM_DEVICE_PATH
*Cd
;
1185 if (DisplayOnly
== TRUE
) {
1186 CatPrint (Str
, L
"CDROM(%x)", Cd
->BootEntry
);
1190 CatPrint (Str
, L
"CDROM(%x,%lx,%lx)", Cd
->BootEntry
, Cd
->PartitionStart
, Cd
->PartitionSize
);
1195 DevPathToTextFilePath (
1196 IN OUT POOL_PRINT
*Str
,
1198 IN BOOLEAN DisplayOnly
,
1199 IN BOOLEAN AllowShortcuts
1202 FILEPATH_DEVICE_PATH
*Fp
;
1205 CatPrint (Str
, L
"%s", Fp
->PathName
);
1210 DevPathToTextMediaProtocol (
1211 IN OUT POOL_PRINT
*Str
,
1213 IN BOOLEAN DisplayOnly
,
1214 IN BOOLEAN AllowShortcuts
1217 MEDIA_PROTOCOL_DEVICE_PATH
*MediaProt
;
1219 MediaProt
= DevPath
;
1220 CatPrint (Str
, L
"Media(%g)", &MediaProt
->Protocol
);
1226 IN OUT POOL_PRINT
*Str
,
1228 IN BOOLEAN DisplayOnly
,
1229 IN BOOLEAN AllowShortcuts
1232 BBS_BBS_DEVICE_PATH
*Bbs
;
1236 switch (Bbs
->DeviceType
) {
1237 case BBS_TYPE_FLOPPY
:
1241 case BBS_TYPE_HARDDRIVE
:
1245 case BBS_TYPE_CDROM
:
1249 case BBS_TYPE_PCMCIA
:
1257 case BBS_TYPE_EMBEDDED_NETWORK
:
1266 CatPrint (Str
, L
"BBS(%s,%a", Type
, Bbs
->String
);
1268 if (DisplayOnly
== TRUE
) {
1269 CatPrint (Str
, L
")");
1273 CatPrint (Str
, L
",%x)", Bbs
->StatusFlag
);
1278 DevPathToTextEndInstance (
1279 IN OUT POOL_PRINT
*Str
,
1281 IN BOOLEAN DisplayOnly
,
1282 IN BOOLEAN AllowShortcuts
1285 CatPrint (Str
, L
",");
1290 DevPathToTextNodeUnknown (
1291 IN OUT POOL_PRINT
*Str
,
1293 IN BOOLEAN DisplayOnly
,
1294 IN BOOLEAN AllowShortcuts
1297 CatPrint (Str
, L
"?");
1300 GLOBAL_REMOVE_IF_UNREFERENCED
const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable
[] = {
1301 {HARDWARE_DEVICE_PATH
, HW_PCI_DP
, DevPathToTextPci
},
1302 {HARDWARE_DEVICE_PATH
, HW_PCCARD_DP
, DevPathToTextPccard
},
1303 {HARDWARE_DEVICE_PATH
, HW_MEMMAP_DP
, DevPathToTextMemMap
},
1304 {HARDWARE_DEVICE_PATH
, HW_VENDOR_DP
, DevPathToTextVendor
},
1305 {HARDWARE_DEVICE_PATH
, HW_CONTROLLER_DP
, DevPathToTextController
},
1306 {ACPI_DEVICE_PATH
, ACPI_DP
, DevPathToTextAcpi
},
1307 {ACPI_DEVICE_PATH
, ACPI_EXTENDED_DP
, DevPathToTextExtAcpi
},
1308 {MESSAGING_DEVICE_PATH
, MSG_ATAPI_DP
, DevPathToTextAtapi
},
1309 {MESSAGING_DEVICE_PATH
, MSG_SCSI_DP
, DevPathToTextScsi
},
1310 {MESSAGING_DEVICE_PATH
, MSG_FIBRECHANNEL_DP
, DevPathToTextFibre
},
1311 {MESSAGING_DEVICE_PATH
, MSG_1394_DP
, DevPathToText1394
},
1312 {MESSAGING_DEVICE_PATH
, MSG_USB_DP
, DevPathToTextUsb
},
1313 {MESSAGING_DEVICE_PATH
, MSG_USB_WWID_DP
, DevPathToTextUsbWWID
},
1314 {MESSAGING_DEVICE_PATH
, MSG_DEVICE_LOGICAL_UNIT_DP
, DevPathToTextLogicalUnit
},
1315 {MESSAGING_DEVICE_PATH
, MSG_USB_CLASS_DP
, DevPathToTextUsbClass
},
1316 {MESSAGING_DEVICE_PATH
, MSG_I2O_DP
, DevPathToTextI2O
},
1317 {MESSAGING_DEVICE_PATH
, MSG_MAC_ADDR_DP
, DevPathToTextMacAddr
},
1318 {MESSAGING_DEVICE_PATH
, MSG_IPv4_DP
, DevPathToTextIPv4
},
1319 {MESSAGING_DEVICE_PATH
, MSG_IPv6_DP
, DevPathToTextIPv6
},
1320 {MESSAGING_DEVICE_PATH
, MSG_INFINIBAND_DP
, DevPathToTextInfiniBand
},
1321 {MESSAGING_DEVICE_PATH
, MSG_UART_DP
, DevPathToTextUart
},
1322 {MESSAGING_DEVICE_PATH
, MSG_VENDOR_DP
, DevPathToTextVendor
},
1323 {MESSAGING_DEVICE_PATH
, MSG_ISCSI_DP
, DevPathToTextiSCSI
},
1324 {MEDIA_DEVICE_PATH
, MEDIA_HARDDRIVE_DP
, DevPathToTextHardDrive
},
1325 {MEDIA_DEVICE_PATH
, MEDIA_CDROM_DP
, DevPathToTextCDROM
},
1326 {MEDIA_DEVICE_PATH
, MEDIA_VENDOR_DP
, DevPathToTextVendor
},
1327 {MEDIA_DEVICE_PATH
, MEDIA_FILEPATH_DP
, DevPathToTextFilePath
},
1328 {MEDIA_DEVICE_PATH
, MEDIA_PROTOCOL_DP
, DevPathToTextMediaProtocol
},
1329 {MEDIA_DEVICE_PATH
, MEDIA_FILEPATH_DP
, DevPathToTextFilePath
},
1330 {BBS_DEVICE_PATH
, BBS_BBS_DP
, DevPathToTextBBS
},
1331 {END_DEVICE_PATH_TYPE
, END_INSTANCE_DEVICE_PATH_SUBTYPE
, DevPathToTextEndInstance
},
1336 ConvertDeviceNodeToText (
1337 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
1338 IN BOOLEAN DisplayOnly
,
1339 IN BOOLEAN AllowShortcuts
1343 Routine Description:
1344 Convert a device node to its text representation.
1347 DeviceNode - Points to the device node to be converted.
1348 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
1349 of the display node is used, where applicable. If DisplayOnly
1350 is FALSE, then the longer text representation of the display node
1352 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
1353 representation for a device node can be used, where applicable.
1356 A pointer - a pointer to the allocated text representation of the device node.
1357 NULL - if DeviceNode is NULL or there was insufficient memory.
1364 VOID (*DumpNode
)(POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
1366 if (DeviceNode
== NULL
) {
1370 ZeroMem (&Str
, sizeof (Str
));
1373 // Process the device path node
1376 for (Index
= 0; DevPathToTextTable
[Index
].Function
!= NULL
; Index
++) {
1377 if (DevicePathType (DeviceNode
) == DevPathToTextTable
[Index
].Type
&&
1378 DevicePathSubType (DeviceNode
) == DevPathToTextTable
[Index
].SubType
1380 DumpNode
= DevPathToTextTable
[Index
].Function
;
1385 // If not found, use a generic function
1387 if (DumpNode
== NULL
) {
1388 DumpNode
= DevPathToTextNodeUnknown
;
1394 DumpNode (&Str
, (VOID
*) DeviceNode
, DisplayOnly
, AllowShortcuts
);
1397 // Shrink pool used for string allocation
1399 NewSize
= (Str
.Len
+ 1) * sizeof (CHAR16
);
1400 Str
.Str
= ReallocatePool (Str
.Str
, NewSize
, NewSize
);
1401 ASSERT (Str
.Str
!= NULL
);
1402 Str
.Str
[Str
.Len
] = 0;
1407 ConvertDevicePathToText (
1408 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1409 IN BOOLEAN DisplayOnly
,
1410 IN BOOLEAN AllowShortcuts
1414 Routine Description:
1415 Convert a device path to its text representation.
1418 DeviceNode - Points to the device path to be converted.
1419 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
1420 of the display node is used, where applicable. If DisplayOnly
1421 is FALSE, then the longer text representation of the display node
1423 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
1424 representation for a device node can be used, where applicable.
1427 A pointer - a pointer to the allocated text representation of the device path.
1428 NULL - if DeviceNode is NULL or there was insufficient memory.
1433 EFI_DEVICE_PATH_PROTOCOL
*DevPathNode
;
1434 EFI_DEVICE_PATH_PROTOCOL
*UnpackDevPath
;
1437 VOID (*DumpNode
) (POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
1439 if (DevicePath
== NULL
) {
1443 ZeroMem (&Str
, sizeof (Str
));
1446 // Unpacked the device path
1448 UnpackDevPath
= UnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL
*) DevicePath
);
1449 ASSERT (UnpackDevPath
!= NULL
);
1452 // Process each device path node
1454 DevPathNode
= UnpackDevPath
;
1455 while (!IsDevicePathEnd (DevPathNode
)) {
1457 // Find the handler to dump this device path node
1460 for (Index
= 0; DevPathToTextTable
[Index
].Function
; Index
+= 1) {
1462 if (DevicePathType (DevPathNode
) == DevPathToTextTable
[Index
].Type
&&
1463 DevicePathSubType (DevPathNode
) == DevPathToTextTable
[Index
].SubType
1465 DumpNode
= DevPathToTextTable
[Index
].Function
;
1470 // If not found, use a generic function
1473 DumpNode
= DevPathToTextNodeUnknown
;
1476 // Put a path seperator in if needed
1478 if (Str
.Len
&& DumpNode
!= DevPathToTextEndInstance
) {
1479 if (*(Str
.Str
+ Str
.Len
/ sizeof (CHAR16
) - 1) != L
',') {
1480 CatPrint (&Str
, L
"/");
1484 // Print this node of the device path
1486 DumpNode (&Str
, DevPathNode
, DisplayOnly
, AllowShortcuts
);
1489 // Next device path node
1491 DevPathNode
= NextDevicePathNode (DevPathNode
);
1494 // Shrink pool used for string allocation
1496 FreePool (UnpackDevPath
);
1498 NewSize
= (Str
.Len
+ 1) * sizeof (CHAR16
);
1499 Str
.Str
= ReallocatePool (Str
.Str
, NewSize
, NewSize
);
1500 ASSERT (Str
.Str
!= NULL
);
1501 Str
.Str
[Str
.Len
] = 0;