]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
MdePkg/DevicePath.h: Add DNS Device Path definition
[mirror_edk2.git] / MdePkg / Library / UefiDevicePathLib / DevicePathToText.c
CommitLineData
13d40edd 1/** @file\r
2 DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
95276127 3\r
a3bc432a 4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
4fc82771 5Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 6This program and the accompanying materials\r
13d40edd 7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
95276127 10\r
13d40edd 11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
95276127 13\r
13d40edd 14**/\r
95276127 15\r
4d0a30a4 16#include "UefiDevicePathLib.h"\r
95276127 17\r
572f5d8a 18/**\r
19 Concatenates a formatted unicode string to allocated pool. The caller must\r
20 free the resulting buffer.\r
21\r
22 @param Str Tracks the allocated pool, size in use, and\r
23 amount of pool allocated.\r
24 @param Fmt The format string\r
25 @param ... Variable arguments based on the format string.\r
26\r
27 @return Allocated buffer with the formatted string printed in it.\r
28 The caller must free the allocated buffer. The buffer\r
29 allocation is not packed.\r
30\r
31**/\r
95276127 32CHAR16 *\r
eed8d676 33EFIAPI\r
4d0a30a4 34UefiDevicePathLibCatPrint (\r
95276127 35 IN OUT POOL_PRINT *Str,\r
36 IN CHAR16 *Fmt,\r
37 ...\r
38 )\r
95276127 39{\r
4d0a30a4 40 UINTN Count;\r
95276127 41 VA_LIST Args;\r
95276127 42\r
95276127 43 VA_START (Args, Fmt);\r
4d0a30a4 44 Count = SPrintLength (Fmt, Args);\r
b9899358 45 VA_END(Args);\r
e9b3cd55 46\r
4d0a30a4
RN
47 if ((Str->Count + (Count + 1)) * sizeof (CHAR16) > Str->Capacity) {\r
48 Str->Capacity = (Str->Count + (Count + 1) * 2) * sizeof (CHAR16);\r
95276127 49 Str->Str = ReallocatePool (\r
4d0a30a4 50 Str->Count * sizeof (CHAR16),\r
e9b3cd55 51 Str->Capacity,\r
48557c65 52 Str->Str\r
53 );\r
95276127 54 ASSERT (Str->Str != NULL);\r
55 }\r
b9899358 56 VA_START (Args, Fmt);\r
4d0a30a4
RN
57 UnicodeVSPrint (&Str->Str[Str->Count], Str->Capacity - Str->Count * sizeof (CHAR16), Fmt, Args);\r
58 Str->Count += Count;\r
59 \r
60 VA_END (Args);\r
95276127 61 return Str->Str;\r
62}\r
63\r
572f5d8a 64/**\r
48557c65 65 Converts a PCI device path structure to its string representative.\r
572f5d8a 66\r
48557c65 67 @param Str The string representative of input device.\r
572f5d8a 68 @param DevPath The input device path structure.\r
69 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
70 of the display node is used, where applicable. If DisplayOnly\r
71 is FALSE, then the longer text representation of the display node\r
72 is used.\r
73 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
74 representation for a device node can be used, where applicable.\r
75\r
76**/\r
95276127 77VOID\r
78DevPathToTextPci (\r
79 IN OUT POOL_PRINT *Str,\r
80 IN VOID *DevPath,\r
81 IN BOOLEAN DisplayOnly,\r
82 IN BOOLEAN AllowShortcuts\r
83 )\r
84{\r
85 PCI_DEVICE_PATH *Pci;\r
86\r
87 Pci = DevPath;\r
4d0a30a4 88 UefiDevicePathLibCatPrint (Str, L"Pci(0x%x,0x%x)", Pci->Device, Pci->Function);\r
95276127 89}\r
90\r
572f5d8a 91/**\r
48557c65 92 Converts a PC Card device path structure to its string representative.\r
572f5d8a 93\r
48557c65 94 @param Str The string representative of input device.\r
572f5d8a 95 @param DevPath The input device path structure.\r
96 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
97 of the display node is used, where applicable. If DisplayOnly\r
98 is FALSE, then the longer text representation of the display node\r
99 is used.\r
100 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
101 representation for a device node can be used, where applicable.\r
102\r
103**/\r
95276127 104VOID\r
105DevPathToTextPccard (\r
106 IN OUT POOL_PRINT *Str,\r
107 IN VOID *DevPath,\r
108 IN BOOLEAN DisplayOnly,\r
109 IN BOOLEAN AllowShortcuts\r
110 )\r
111{\r
112 PCCARD_DEVICE_PATH *Pccard;\r
113\r
114 Pccard = DevPath;\r
4d0a30a4 115 UefiDevicePathLibCatPrint (Str, L"PcCard(0x%x)", Pccard->FunctionNumber);\r
95276127 116}\r
117\r
572f5d8a 118/**\r
48557c65 119 Converts a Memory Map device path structure to its string representative.\r
572f5d8a 120\r
48557c65 121 @param Str The string representative of input device.\r
572f5d8a 122 @param DevPath The input device path structure.\r
123 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
124 of the display node is used, where applicable. If DisplayOnly\r
125 is FALSE, then the longer text representation of the display node\r
126 is used.\r
127 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
128 representation for a device node can be used, where applicable.\r
129\r
130**/\r
95276127 131VOID\r
132DevPathToTextMemMap (\r
133 IN OUT POOL_PRINT *Str,\r
134 IN VOID *DevPath,\r
135 IN BOOLEAN DisplayOnly,\r
136 IN BOOLEAN AllowShortcuts\r
137 )\r
138{\r
139 MEMMAP_DEVICE_PATH *MemMap;\r
140\r
141 MemMap = DevPath;\r
4d0a30a4 142 UefiDevicePathLibCatPrint (\r
95276127 143 Str,\r
cf40f28a 144 L"MemoryMapped(0x%x,0x%lx,0x%lx)",\r
e9b3cd55 145 MemMap->MemoryType,\r
95276127 146 MemMap->StartingAddress,\r
147 MemMap->EndingAddress\r
148 );\r
149}\r
150\r
572f5d8a 151/**\r
48557c65 152 Converts a Vendor device path structure to its string representative.\r
572f5d8a 153\r
48557c65 154 @param Str The string representative of input device.\r
572f5d8a 155 @param DevPath The input device path structure.\r
156 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
157 of the display node is used, where applicable. If DisplayOnly\r
158 is FALSE, then the longer text representation of the display node\r
159 is used.\r
160 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
161 representation for a device node can be used, where applicable.\r
162\r
163**/\r
95276127 164VOID\r
165DevPathToTextVendor (\r
166 IN OUT POOL_PRINT *Str,\r
167 IN VOID *DevPath,\r
168 IN BOOLEAN DisplayOnly,\r
169 IN BOOLEAN AllowShortcuts\r
170 )\r
171{\r
172 VENDOR_DEVICE_PATH *Vendor;\r
173 CHAR16 *Type;\r
174 UINTN Index;\r
cf40f28a 175 UINTN DataLength;\r
95276127 176 UINT32 FlowControlMap;\r
177 UINT16 Info;\r
178\r
179 Vendor = (VENDOR_DEVICE_PATH *) DevPath;\r
180 switch (DevicePathType (&Vendor->Header)) {\r
181 case HARDWARE_DEVICE_PATH:\r
182 Type = L"Hw";\r
183 break;\r
184\r
185 case MESSAGING_DEVICE_PATH:\r
186 Type = L"Msg";\r
187 if (AllowShortcuts) {\r
188 if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {\r
4d0a30a4 189 UefiDevicePathLibCatPrint (Str, L"VenPcAnsi()");\r
95276127 190 return ;\r
191 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {\r
4d0a30a4 192 UefiDevicePathLibCatPrint (Str, L"VenVt100()");\r
95276127 193 return ;\r
194 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {\r
4d0a30a4 195 UefiDevicePathLibCatPrint (Str, L"VenVt100Plus()");\r
95276127 196 return ;\r
197 } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {\r
4d0a30a4 198 UefiDevicePathLibCatPrint (Str, L"VenUft8()");\r
95276127 199 return ;\r
48557c65 200 } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) {\r
95276127 201 FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);\r
202 switch (FlowControlMap & 0x00000003) {\r
203 case 0:\r
4d0a30a4 204 UefiDevicePathLibCatPrint (Str, L"UartFlowCtrl(%s)", L"None");\r
95276127 205 break;\r
206\r
207 case 1:\r
4d0a30a4 208 UefiDevicePathLibCatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware");\r
95276127 209 break;\r
210\r
211 case 2:\r
4d0a30a4 212 UefiDevicePathLibCatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff");\r
95276127 213 break;\r
214\r
215 default:\r
216 break;\r
217 }\r
218\r
219 return ;\r
48557c65 220 } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {\r
4d0a30a4 221 UefiDevicePathLibCatPrint (\r
95276127 222 Str,\r
cf40f28a 223 L"SAS(0x%lx,0x%lx,0x%x,",\r
95276127 224 ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r
225 ((SAS_DEVICE_PATH *) Vendor)->Lun,\r
e9b3cd55 226 ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
95276127 227 );\r
228 Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);\r
562fce0b 229 if (((Info & 0x0f) == 0) && ((Info & BIT7) == 0)) {\r
4d0a30a4 230 UefiDevicePathLibCatPrint (Str, L"NoTopology,0,0,0,");\r
562fce0b 231 } else if (((Info & 0x0f) <= 2) && ((Info & BIT7) == 0)) {\r
4d0a30a4 232 UefiDevicePathLibCatPrint (\r
95276127 233 Str,\r
234 L"%s,%s,%s,",\r
562fce0b
RN
235 ((Info & BIT4) != 0) ? L"SATA" : L"SAS",\r
236 ((Info & BIT5) != 0) ? L"External" : L"Internal",\r
237 ((Info & BIT6) != 0) ? L"Expanded" : L"Direct"\r
95276127 238 );\r
239 if ((Info & 0x0f) == 1) {\r
4d0a30a4 240 UefiDevicePathLibCatPrint (Str, L"0,");\r
95276127 241 } else {\r
562fce0b
RN
242 //\r
243 // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256\r
244 //\r
4d0a30a4 245 UefiDevicePathLibCatPrint (Str, L"0x%x,", ((Info >> 8) & 0xff) + 1);\r
95276127 246 }\r
247 } else {\r
4d0a30a4 248 UefiDevicePathLibCatPrint (Str, L"0x%x,0,0,0,", Info);\r
95276127 249 }\r
250\r
4d0a30a4 251 UefiDevicePathLibCatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
95276127 252 return ;\r
253 } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r
4d0a30a4 254 UefiDevicePathLibCatPrint (Str, L"DebugPort()");\r
95276127 255 return ;\r
95276127 256 }\r
257 }\r
258 break;\r
259\r
260 case MEDIA_DEVICE_PATH:\r
261 Type = L"Media";\r
262 break;\r
263\r
264 default:\r
265 Type = L"?";\r
266 break;\r
267 }\r
268\r
cf40f28a 269 DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);\r
4d0a30a4 270 UefiDevicePathLibCatPrint (Str, L"Ven%s(%g", Type, &Vendor->Guid);\r
cf40f28a 271 if (DataLength != 0) {\r
4d0a30a4 272 UefiDevicePathLibCatPrint (Str, L",");\r
cf40f28a 273 for (Index = 0; Index < DataLength; Index++) {\r
4d0a30a4 274 UefiDevicePathLibCatPrint (Str, L"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r
cf40f28a 275 }\r
95276127 276 }\r
277\r
4d0a30a4 278 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 279}\r
280\r
572f5d8a 281/**\r
48557c65 282 Converts a Controller device path structure to its string representative.\r
572f5d8a 283\r
48557c65 284 @param Str The string representative of input device.\r
572f5d8a 285 @param DevPath The input device path structure.\r
286 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
287 of the display node is used, where applicable. If DisplayOnly\r
288 is FALSE, then the longer text representation of the display node\r
289 is used.\r
290 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
291 representation for a device node can be used, where applicable.\r
292\r
293**/\r
95276127 294VOID\r
295DevPathToTextController (\r
296 IN OUT POOL_PRINT *Str,\r
297 IN VOID *DevPath,\r
298 IN BOOLEAN DisplayOnly,\r
299 IN BOOLEAN AllowShortcuts\r
300 )\r
301{\r
302 CONTROLLER_DEVICE_PATH *Controller;\r
303\r
304 Controller = DevPath;\r
4d0a30a4 305 UefiDevicePathLibCatPrint (\r
95276127 306 Str,\r
cf40f28a 307 L"Ctrl(0x%x)",\r
e9b3cd55 308 Controller->ControllerNumber\r
95276127 309 );\r
310}\r
311\r
624f017e
HW
312/**\r
313 Converts a BMC device path structure to its string representative.\r
314\r
315 @param Str The string representative of input device.\r
316 @param DevPath The input device path structure.\r
317 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
318 of the display node is used, where applicable. If DisplayOnly\r
319 is FALSE, then the longer text representation of the display node\r
320 is used.\r
321 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
322 representation for a device node can be used, where applicable.\r
323\r
324**/\r
325VOID\r
326DevPathToTextBmc (\r
327 IN OUT POOL_PRINT *Str,\r
328 IN VOID *DevPath,\r
329 IN BOOLEAN DisplayOnly,\r
330 IN BOOLEAN AllowShortcuts\r
331 )\r
332{\r
333 BMC_DEVICE_PATH *Bmc;\r
334\r
335 Bmc = DevPath;\r
336 UefiDevicePathLibCatPrint (\r
337 Str,\r
678226f6 338 L"BMC(0x%x,0x%lx)",\r
624f017e
HW
339 Bmc->InterfaceType,\r
340 ReadUnaligned64 ((UINT64 *) (&Bmc->BaseAddress))\r
341 );\r
342}\r
343\r
572f5d8a 344/**\r
48557c65 345 Converts a ACPI device path structure to its string representative.\r
572f5d8a 346\r
48557c65 347 @param Str The string representative of input device.\r
572f5d8a 348 @param DevPath The input device path structure.\r
349 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
350 of the display node is used, where applicable. If DisplayOnly\r
351 is FALSE, then the longer text representation of the display node\r
352 is used.\r
353 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
354 representation for a device node can be used, where applicable.\r
355\r
356**/\r
95276127 357VOID\r
358DevPathToTextAcpi (\r
359 IN OUT POOL_PRINT *Str,\r
360 IN VOID *DevPath,\r
361 IN BOOLEAN DisplayOnly,\r
362 IN BOOLEAN AllowShortcuts\r
363 )\r
364{\r
365 ACPI_HID_DEVICE_PATH *Acpi;\r
366\r
367 Acpi = DevPath;\r
368 if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
cf40f28a 369 switch (EISA_ID_TO_NUM (Acpi->HID)) {\r
370 case 0x0a03:\r
4d0a30a4 371 UefiDevicePathLibCatPrint (Str, L"PciRoot(0x%x)", Acpi->UID);\r
e9b3cd55
RN
372 break;\r
373\r
374 case 0x0a08:\r
4d0a30a4 375 UefiDevicePathLibCatPrint (Str, L"PcieRoot(0x%x)", Acpi->UID);\r
cf40f28a 376 break;\r
95276127 377\r
cf40f28a 378 case 0x0604:\r
4d0a30a4 379 UefiDevicePathLibCatPrint (Str, L"Floppy(0x%x)", Acpi->UID);\r
cf40f28a 380 break;\r
95276127 381\r
cf40f28a 382 case 0x0301:\r
4d0a30a4 383 UefiDevicePathLibCatPrint (Str, L"Keyboard(0x%x)", Acpi->UID);\r
cf40f28a 384 break;\r
95276127 385\r
cf40f28a 386 case 0x0501:\r
4d0a30a4 387 UefiDevicePathLibCatPrint (Str, L"Serial(0x%x)", Acpi->UID);\r
cf40f28a 388 break;\r
95276127 389\r
cf40f28a 390 case 0x0401:\r
4d0a30a4 391 UefiDevicePathLibCatPrint (Str, L"ParallelPort(0x%x)", Acpi->UID);\r
cf40f28a 392 break;\r
95276127 393\r
cf40f28a 394 default:\r
4d0a30a4 395 UefiDevicePathLibCatPrint (Str, L"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);\r
cf40f28a 396 break;\r
95276127 397 }\r
95276127 398 } else {\r
4d0a30a4 399 UefiDevicePathLibCatPrint (Str, L"Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID);\r
95276127 400 }\r
401}\r
402\r
572f5d8a 403/**\r
48557c65 404 Converts a ACPI extended HID device path structure to its string representative.\r
572f5d8a 405\r
48557c65 406 @param Str The string representative of input device.\r
572f5d8a 407 @param DevPath The input device path structure.\r
408 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
409 of the display node is used, where applicable. If DisplayOnly\r
410 is FALSE, then the longer text representation of the display node\r
411 is used.\r
412 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
413 representation for a device node can be used, where applicable.\r
414\r
415**/\r
95276127 416VOID\r
cf40f28a 417DevPathToTextAcpiEx (\r
95276127 418 IN OUT POOL_PRINT *Str,\r
419 IN VOID *DevPath,\r
420 IN BOOLEAN DisplayOnly,\r
421 IN BOOLEAN AllowShortcuts\r
422 )\r
423{\r
cf40f28a 424 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r
425 CHAR8 *HIDStr;\r
426 CHAR8 *UIDStr;\r
427 CHAR8 *CIDStr;\r
428 CHAR16 HIDText[11];\r
429 CHAR16 CIDText[11];\r
430\r
431 AcpiEx = DevPath;\r
432 HIDStr = (CHAR8 *) (((UINT8 *) AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
433 UIDStr = HIDStr + AsciiStrLen (HIDStr) + 1;\r
434 CIDStr = UIDStr + AsciiStrLen (UIDStr) + 1;\r
435\r
4d0a30a4
RN
436 //\r
437 // Converts EISA identification to string.\r
438 // \r
439 UnicodeSPrint (\r
440 HIDText,\r
441 sizeof (HIDText),\r
442 L"%c%c%c%04X",\r
443 ((AcpiEx->HID >> 10) & 0x1f) + 'A' - 1,\r
444 ((AcpiEx->HID >> 5) & 0x1f) + 'A' - 1,\r
445 ((AcpiEx->HID >> 0) & 0x1f) + 'A' - 1,\r
446 (AcpiEx->HID >> 16) & 0xFFFF\r
447 );\r
448 UnicodeSPrint (\r
449 CIDText,\r
450 sizeof (CIDText),\r
451 L"%c%c%c%04X",\r
452 ((AcpiEx->CID >> 10) & 0x1f) + 'A' - 1,\r
453 ((AcpiEx->CID >> 5) & 0x1f) + 'A' - 1,\r
454 ((AcpiEx->CID >> 0) & 0x1f) + 'A' - 1,\r
455 (AcpiEx->CID >> 16) & 0xFFFF\r
456 );\r
cf40f28a 457\r
458 if ((*HIDStr == '\0') && (*CIDStr == '\0') && (AcpiEx->UID == 0)) {\r
459 //\r
460 // use AcpiExp()\r
461 //\r
4d0a30a4 462 UefiDevicePathLibCatPrint (\r
cf40f28a 463 Str,\r
464 L"AcpiExp(%s,%s,%a)",\r
465 HIDText,\r
466 CIDText,\r
467 UIDStr\r
468 );\r
469 } else {\r
470 if (AllowShortcuts) {\r
471 //\r
472 // display only\r
473 //\r
474 if (AcpiEx->HID == 0) {\r
4d0a30a4 475 UefiDevicePathLibCatPrint (Str, L"AcpiEx(%a,", HIDStr);\r
cf40f28a 476 } else {\r
4d0a30a4 477 UefiDevicePathLibCatPrint (Str, L"AcpiEx(%s,", HIDText);\r
cf40f28a 478 }\r
95276127 479\r
cf40f28a 480 if (AcpiEx->UID == 0) {\r
4d0a30a4 481 UefiDevicePathLibCatPrint (Str, L"%a,", UIDStr);\r
cf40f28a 482 } else {\r
4d0a30a4 483 UefiDevicePathLibCatPrint (Str, L"0x%x,", AcpiEx->UID);\r
cf40f28a 484 }\r
95276127 485\r
cf40f28a 486 if (AcpiEx->CID == 0) {\r
4d0a30a4 487 UefiDevicePathLibCatPrint (Str, L"%a)", CIDStr);\r
95276127 488 } else {\r
4d0a30a4 489 UefiDevicePathLibCatPrint (Str, L"%s)", CIDText);\r
95276127 490 }\r
cf40f28a 491 } else {\r
4d0a30a4 492 UefiDevicePathLibCatPrint (\r
cf40f28a 493 Str,\r
494 L"AcpiEx(%s,%s,0x%x,%a,%a,%a)",\r
495 HIDText,\r
496 CIDText,\r
e9b3cd55 497 AcpiEx->UID,\r
cf40f28a 498 HIDStr,\r
499 CIDStr,\r
500 UIDStr\r
501 );\r
95276127 502 }\r
95276127 503 }\r
cf40f28a 504}\r
95276127 505\r
572f5d8a 506/**\r
48557c65 507 Converts a ACPI address device path structure to its string representative.\r
572f5d8a 508\r
48557c65 509 @param Str The string representative of input device.\r
572f5d8a 510 @param DevPath The input device path structure.\r
511 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
512 of the display node is used, where applicable. If DisplayOnly\r
513 is FALSE, then the longer text representation of the display node\r
514 is used.\r
515 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
516 representation for a device node can be used, where applicable.\r
517\r
518**/\r
cf40f28a 519VOID\r
520DevPathToTextAcpiAdr (\r
521 IN OUT POOL_PRINT *Str,\r
522 IN VOID *DevPath,\r
523 IN BOOLEAN DisplayOnly,\r
524 IN BOOLEAN AllowShortcuts\r
525 )\r
526{\r
527 ACPI_ADR_DEVICE_PATH *AcpiAdr;\r
528 UINT16 Index;\r
529 UINT16 Length;\r
530 UINT16 AdditionalAdrCount;\r
531\r
532 AcpiAdr = DevPath;\r
533 Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);\r
534 AdditionalAdrCount = (UINT16) ((Length - 8) / 4);\r
535\r
4d0a30a4 536 UefiDevicePathLibCatPrint (Str, L"AcpiAdr(0x%x", AcpiAdr->ADR);\r
cf40f28a 537 for (Index = 0; Index < AdditionalAdrCount; Index++) {\r
4d0a30a4 538 UefiDevicePathLibCatPrint (Str, L",0x%x", *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r
95276127 539 }\r
4d0a30a4 540 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 541}\r
542\r
572f5d8a 543/**\r
48557c65 544 Converts a ATAPI device path structure to its string representative.\r
572f5d8a 545\r
48557c65 546 @param Str The string representative of input device.\r
572f5d8a 547 @param DevPath The input device path structure.\r
548 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
549 of the display node is used, where applicable. If DisplayOnly\r
550 is FALSE, then the longer text representation of the display node\r
551 is used.\r
552 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
553 representation for a device node can be used, where applicable.\r
554\r
555**/\r
95276127 556VOID\r
557DevPathToTextAtapi (\r
558 IN OUT POOL_PRINT *Str,\r
559 IN VOID *DevPath,\r
560 IN BOOLEAN DisplayOnly,\r
561 IN BOOLEAN AllowShortcuts\r
562 )\r
563{\r
564 ATAPI_DEVICE_PATH *Atapi;\r
565\r
566 Atapi = DevPath;\r
567\r
568 if (DisplayOnly) {\r
4d0a30a4 569 UefiDevicePathLibCatPrint (Str, L"Ata(0x%x)", Atapi->Lun);\r
95276127 570 } else {\r
4d0a30a4 571 UefiDevicePathLibCatPrint (\r
95276127 572 Str,\r
cf40f28a 573 L"Ata(%s,%s,0x%x)",\r
7ae9c1ce 574 (Atapi->PrimarySecondary == 1) ? L"Secondary" : L"Primary",\r
575 (Atapi->SlaveMaster == 1) ? L"Slave" : L"Master",\r
e9b3cd55 576 Atapi->Lun\r
95276127 577 );\r
578 }\r
579}\r
580\r
572f5d8a 581/**\r
48557c65 582 Converts a SCSI device path structure to its string representative.\r
572f5d8a 583\r
48557c65 584 @param Str The string representative of input device.\r
572f5d8a 585 @param DevPath The input device path structure.\r
586 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
587 of the display node is used, where applicable. If DisplayOnly\r
588 is FALSE, then the longer text representation of the display node\r
589 is used.\r
590 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
591 representation for a device node can be used, where applicable.\r
592\r
593**/\r
95276127 594VOID\r
595DevPathToTextScsi (\r
596 IN OUT POOL_PRINT *Str,\r
597 IN VOID *DevPath,\r
598 IN BOOLEAN DisplayOnly,\r
599 IN BOOLEAN AllowShortcuts\r
600 )\r
601{\r
602 SCSI_DEVICE_PATH *Scsi;\r
603\r
604 Scsi = DevPath;\r
4d0a30a4 605 UefiDevicePathLibCatPrint (Str, L"Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun);\r
95276127 606}\r
607\r
572f5d8a 608/**\r
48557c65 609 Converts a Fibre device path structure to its string representative.\r
572f5d8a 610\r
48557c65 611 @param Str The string representative of input device.\r
572f5d8a 612 @param DevPath The input device path structure.\r
613 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
614 of the display node is used, where applicable. If DisplayOnly\r
615 is FALSE, then the longer text representation of the display node\r
616 is used.\r
617 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
618 representation for a device node can be used, where applicable.\r
619\r
620**/\r
95276127 621VOID\r
622DevPathToTextFibre (\r
623 IN OUT POOL_PRINT *Str,\r
624 IN VOID *DevPath,\r
625 IN BOOLEAN DisplayOnly,\r
626 IN BOOLEAN AllowShortcuts\r
627 )\r
628{\r
629 FIBRECHANNEL_DEVICE_PATH *Fibre;\r
630\r
631 Fibre = DevPath;\r
4d0a30a4 632 UefiDevicePathLibCatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);\r
95276127 633}\r
634\r
e9b3cd55
RN
635/**\r
636 Converts a FibreEx device path structure to its string representative.\r
637\r
638 @param Str The string representative of input device.\r
639 @param DevPath The input device path structure.\r
640 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
641 of the display node is used, where applicable. If DisplayOnly\r
642 is FALSE, then the longer text representation of the display node\r
643 is used.\r
644 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
645 representation for a device node can be used, where applicable.\r
646\r
647**/\r
648VOID\r
649DevPathToTextFibreEx (\r
650 IN OUT POOL_PRINT *Str,\r
651 IN VOID *DevPath,\r
652 IN BOOLEAN DisplayOnly,\r
653 IN BOOLEAN AllowShortcuts\r
654 )\r
655{\r
656 FIBRECHANNELEX_DEVICE_PATH *FibreEx;\r
657 UINTN Index;\r
658\r
659 FibreEx = DevPath;\r
4d0a30a4 660 UefiDevicePathLibCatPrint (Str, L"FibreEx(0x");\r
e9b3cd55 661 for (Index = 0; Index < sizeof (FibreEx->WWN) / sizeof (FibreEx->WWN[0]); Index++) {\r
4d0a30a4 662 UefiDevicePathLibCatPrint (Str, L"%02x", FibreEx->WWN[Index]);\r
e9b3cd55 663 }\r
4d0a30a4 664 UefiDevicePathLibCatPrint (Str, L",0x");\r
e9b3cd55 665 for (Index = 0; Index < sizeof (FibreEx->Lun) / sizeof (FibreEx->Lun[0]); Index++) {\r
4d0a30a4 666 UefiDevicePathLibCatPrint (Str, L"%02x", FibreEx->Lun[Index]);\r
e9b3cd55 667 }\r
4d0a30a4 668 UefiDevicePathLibCatPrint (Str, L")");\r
e9b3cd55
RN
669}\r
670\r
501793fa
RN
671/**\r
672 Converts a Sas Ex device path structure to its string representative.\r
673\r
674 @param Str The string representative of input device.\r
675 @param DevPath The input device path structure.\r
676 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
677 of the display node is used, where applicable. If DisplayOnly\r
678 is FALSE, then the longer text representation of the display node\r
679 is used.\r
680 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
681 representation for a device node can be used, where applicable.\r
682\r
683**/\r
684VOID\r
685DevPathToTextSasEx (\r
686 IN OUT POOL_PRINT *Str,\r
687 IN VOID *DevPath,\r
688 IN BOOLEAN DisplayOnly,\r
689 IN BOOLEAN AllowShortcuts\r
690 )\r
691{\r
692 SASEX_DEVICE_PATH *SasEx;\r
693 UINTN Index;\r
694\r
695 SasEx = DevPath;\r
4d0a30a4 696 UefiDevicePathLibCatPrint (Str, L"SasEx(0x");\r
501793fa
RN
697\r
698 for (Index = 0; Index < sizeof (SasEx->SasAddress) / sizeof (SasEx->SasAddress[0]); Index++) {\r
4d0a30a4 699 UefiDevicePathLibCatPrint (Str, L"%02x", SasEx->SasAddress[Index]);\r
501793fa 700 }\r
4d0a30a4 701 UefiDevicePathLibCatPrint (Str, L",0x");\r
501793fa 702 for (Index = 0; Index < sizeof (SasEx->Lun) / sizeof (SasEx->Lun[0]); Index++) {\r
4d0a30a4 703 UefiDevicePathLibCatPrint (Str, L"%02x", SasEx->Lun[Index]);\r
501793fa 704 }\r
4d0a30a4 705 UefiDevicePathLibCatPrint (Str, L",0x%x,", SasEx->RelativeTargetPort);\r
501793fa 706\r
562fce0b 707 if (((SasEx->DeviceTopology & 0x0f) == 0) && ((SasEx->DeviceTopology & BIT7) == 0)) {\r
4d0a30a4 708 UefiDevicePathLibCatPrint (Str, L"NoTopology,0,0,0");\r
562fce0b 709 } else if (((SasEx->DeviceTopology & 0x0f) <= 2) && ((SasEx->DeviceTopology & BIT7) == 0)) {\r
4d0a30a4 710 UefiDevicePathLibCatPrint (\r
501793fa
RN
711 Str,\r
712 L"%s,%s,%s,",\r
562fce0b
RN
713 ((SasEx->DeviceTopology & BIT4) != 0) ? L"SATA" : L"SAS",\r
714 ((SasEx->DeviceTopology & BIT5) != 0) ? L"External" : L"Internal",\r
715 ((SasEx->DeviceTopology & BIT6) != 0) ? L"Expanded" : L"Direct"\r
501793fa
RN
716 );\r
717 if ((SasEx->DeviceTopology & 0x0f) == 1) {\r
4d0a30a4 718 UefiDevicePathLibCatPrint (Str, L"0");\r
501793fa 719 } else {\r
562fce0b
RN
720 //\r
721 // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256\r
722 //\r
4d0a30a4 723 UefiDevicePathLibCatPrint (Str, L"0x%x", ((SasEx->DeviceTopology >> 8) & 0xff) + 1);\r
501793fa
RN
724 }\r
725 } else {\r
4d0a30a4 726 UefiDevicePathLibCatPrint (Str, L"0x%x,0,0,0", SasEx->DeviceTopology);\r
501793fa
RN
727 }\r
728\r
4d0a30a4 729 UefiDevicePathLibCatPrint (Str, L")");\r
501793fa
RN
730 return ;\r
731\r
732}\r
733\r
a06ec3e2
RN
734/**\r
735 Converts a NVM Express Namespace device path structure to its string representative.\r
736\r
737 @param Str The string representative of input device.\r
738 @param DevPath The input device path structure.\r
739 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
740 of the display node is used, where applicable. If DisplayOnly\r
741 is FALSE, then the longer text representation of the display node\r
742 is used.\r
743 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
744 representation for a device node can be used, where applicable.\r
745\r
746**/\r
747VOID\r
748DevPathToTextNVMe (\r
749 IN OUT POOL_PRINT *Str,\r
750 IN VOID *DevPath,\r
751 IN BOOLEAN DisplayOnly,\r
752 IN BOOLEAN AllowShortcuts\r
753 )\r
754{\r
755 NVME_NAMESPACE_DEVICE_PATH *Nvme;\r
756 UINT8 *Uuid;\r
757\r
758 Nvme = DevPath;\r
759 Uuid = (UINT8 *) &Nvme->NamespaceUuid;\r
760 UefiDevicePathLibCatPrint (\r
761 Str,\r
762 L"NVMe(0x%x,%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x)",\r
763 Nvme->NamespaceId,\r
764 Uuid[7], Uuid[6], Uuid[5], Uuid[4],\r
765 Uuid[3], Uuid[2], Uuid[1], Uuid[0]\r
766 );\r
767}\r
768\r
52306166
FT
769/**\r
770 Converts a UFS device path structure to its string representative.\r
771\r
772 @param Str The string representative of input device.\r
773 @param DevPath The input device path structure.\r
774 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
775 of the display node is used, where applicable. If DisplayOnly\r
776 is FALSE, then the longer text representation of the display node\r
777 is used.\r
778 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
779 representation for a device node can be used, where applicable.\r
780\r
781**/\r
782VOID\r
783DevPathToTextUfs (\r
784 IN OUT POOL_PRINT *Str,\r
785 IN VOID *DevPath,\r
786 IN BOOLEAN DisplayOnly,\r
787 IN BOOLEAN AllowShortcuts\r
788 )\r
789{\r
790 UFS_DEVICE_PATH *Ufs;\r
791\r
792 Ufs = DevPath;\r
793 UefiDevicePathLibCatPrint (Str, L"UFS(0x%x,0x%x)", Ufs->Pun, Ufs->Lun);\r
794}\r
795\r
ab8686b8
FT
796/**\r
797 Converts a SD (Secure Digital) device path structure to its string representative.\r
798\r
799 @param Str The string representative of input device.\r
800 @param DevPath The input device path structure.\r
801 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
802 of the display node is used, where applicable. If DisplayOnly\r
803 is FALSE, then the longer text representation of the display node\r
804 is used.\r
805 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
806 representation for a device node can be used, where applicable.\r
807\r
808**/\r
809VOID\r
810DevPathToTextSd (\r
811 IN OUT POOL_PRINT *Str,\r
812 IN VOID *DevPath,\r
813 IN BOOLEAN DisplayOnly,\r
814 IN BOOLEAN AllowShortcuts\r
815 )\r
816{\r
817 SD_DEVICE_PATH *Sd;\r
818\r
819 Sd = DevPath;\r
820 UefiDevicePathLibCatPrint (\r
821 Str,\r
822 L"SD(0x%x)",\r
823 Sd->SlotNumber\r
824 );\r
825}\r
826\r
5c67fb2f
FT
827/**\r
828 Converts a EMMC (Embedded MMC) device path structure to its string representative.\r
829\r
830 @param Str The string representative of input device.\r
831 @param DevPath The input device path structure.\r
832 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
833 of the display node is used, where applicable. If DisplayOnly\r
834 is FALSE, then the longer text representation of the display node\r
835 is used.\r
836 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
837 representation for a device node can be used, where applicable.\r
838\r
839**/\r
840VOID\r
841DevPathToTextEmmc (\r
842 IN OUT POOL_PRINT *Str,\r
843 IN VOID *DevPath,\r
844 IN BOOLEAN DisplayOnly,\r
845 IN BOOLEAN AllowShortcuts\r
846 )\r
847{\r
848 EMMC_DEVICE_PATH *Emmc;\r
849\r
850 Emmc = DevPath;\r
851 UefiDevicePathLibCatPrint (\r
852 Str,\r
d18f9699 853 L"eMMC(0x%x)",\r
5c67fb2f
FT
854 Emmc->SlotNumber\r
855 );\r
856}\r
857\r
572f5d8a 858/**\r
48557c65 859 Converts a 1394 device path structure to its string representative.\r
572f5d8a 860\r
48557c65 861 @param Str The string representative of input device.\r
572f5d8a 862 @param DevPath The input device path structure.\r
863 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
864 of the display node is used, where applicable. If DisplayOnly\r
865 is FALSE, then the longer text representation of the display node\r
866 is used.\r
867 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
868 representation for a device node can be used, where applicable.\r
869\r
870**/\r
95276127 871VOID\r
872DevPathToText1394 (\r
873 IN OUT POOL_PRINT *Str,\r
874 IN VOID *DevPath,\r
875 IN BOOLEAN DisplayOnly,\r
876 IN BOOLEAN AllowShortcuts\r
877 )\r
878{\r
572f5d8a 879 F1394_DEVICE_PATH *F1394DevPath;\r
95276127 880\r
572f5d8a 881 F1394DevPath = DevPath;\r
cf40f28a 882 //\r
883 // Guid has format of IEEE-EUI64\r
884 //\r
4d0a30a4 885 UefiDevicePathLibCatPrint (Str, L"I1394(%016lx)", F1394DevPath->Guid);\r
95276127 886}\r
887\r
572f5d8a 888/**\r
48557c65 889 Converts a USB device path structure to its string representative.\r
572f5d8a 890\r
48557c65 891 @param Str The string representative of input device.\r
572f5d8a 892 @param DevPath The input device path structure.\r
893 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
894 of the display node is used, where applicable. If DisplayOnly\r
895 is FALSE, then the longer text representation of the display node\r
896 is used.\r
897 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
898 representation for a device node can be used, where applicable.\r
899\r
900**/\r
95276127 901VOID\r
902DevPathToTextUsb (\r
903 IN OUT POOL_PRINT *Str,\r
904 IN VOID *DevPath,\r
905 IN BOOLEAN DisplayOnly,\r
906 IN BOOLEAN AllowShortcuts\r
907 )\r
908{\r
909 USB_DEVICE_PATH *Usb;\r
910\r
911 Usb = DevPath;\r
4d0a30a4 912 UefiDevicePathLibCatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);\r
95276127 913}\r
914\r
572f5d8a 915/**\r
48557c65 916 Converts a USB WWID device path structure to its string representative.\r
572f5d8a 917\r
48557c65 918 @param Str The string representative of input device.\r
572f5d8a 919 @param DevPath The input device path structure.\r
920 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
921 of the display node is used, where applicable. If DisplayOnly\r
922 is FALSE, then the longer text representation of the display node\r
923 is used.\r
924 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
925 representation for a device node can be used, where applicable.\r
926\r
927**/\r
95276127 928VOID\r
929DevPathToTextUsbWWID (\r
930 IN OUT POOL_PRINT *Str,\r
931 IN VOID *DevPath,\r
932 IN BOOLEAN DisplayOnly,\r
933 IN BOOLEAN AllowShortcuts\r
934 )\r
935{\r
936 USB_WWID_DEVICE_PATH *UsbWWId;\r
cf40f28a 937 CHAR16 *SerialNumberStr;\r
938 CHAR16 *NewStr;\r
939 UINT16 Length;\r
95276127 940\r
941 UsbWWId = DevPath;\r
cf40f28a 942\r
943 SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof (USB_WWID_DEVICE_PATH));\r
944 Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));\r
945 if (SerialNumberStr [Length - 1] != 0) {\r
946 //\r
947 // In case no NULL terminator in SerialNumber, create a new one with NULL terminator\r
948 //\r
949 NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);\r
3069bc19 950 ASSERT (NewStr != NULL);\r
cf40f28a 951 NewStr [Length] = 0;\r
952 SerialNumberStr = NewStr;\r
953 }\r
954\r
4d0a30a4 955 UefiDevicePathLibCatPrint (\r
95276127 956 Str,\r
cf40f28a 957 L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",\r
e9b3cd55
RN
958 UsbWWId->VendorId,\r
959 UsbWWId->ProductId,\r
960 UsbWWId->InterfaceNumber,\r
cf40f28a 961 SerialNumberStr\r
95276127 962 );\r
963}\r
964\r
572f5d8a 965/**\r
48557c65 966 Converts a Logic Unit device path structure to its string representative.\r
572f5d8a 967\r
48557c65 968 @param Str The string representative of input device.\r
572f5d8a 969 @param DevPath The input device path structure.\r
970 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
971 of the display node is used, where applicable. If DisplayOnly\r
972 is FALSE, then the longer text representation of the display node\r
973 is used.\r
974 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
975 representation for a device node can be used, where applicable.\r
976\r
977**/\r
95276127 978VOID\r
979DevPathToTextLogicalUnit (\r
980 IN OUT POOL_PRINT *Str,\r
981 IN VOID *DevPath,\r
982 IN BOOLEAN DisplayOnly,\r
983 IN BOOLEAN AllowShortcuts\r
984 )\r
985{\r
986 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
987\r
988 LogicalUnit = DevPath;\r
4d0a30a4 989 UefiDevicePathLibCatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun);\r
95276127 990}\r
991\r
572f5d8a 992/**\r
48557c65 993 Converts a USB class device path structure to its string representative.\r
572f5d8a 994\r
48557c65 995 @param Str The string representative of input device.\r
572f5d8a 996 @param DevPath The input device path structure.\r
997 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
998 of the display node is used, where applicable. If DisplayOnly\r
999 is FALSE, then the longer text representation of the display node\r
1000 is used.\r
1001 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1002 representation for a device node can be used, where applicable.\r
1003\r
1004**/\r
95276127 1005VOID\r
1006DevPathToTextUsbClass (\r
1007 IN OUT POOL_PRINT *Str,\r
1008 IN VOID *DevPath,\r
1009 IN BOOLEAN DisplayOnly,\r
1010 IN BOOLEAN AllowShortcuts\r
1011 )\r
1012{\r
1013 USB_CLASS_DEVICE_PATH *UsbClass;\r
cf40f28a 1014 BOOLEAN IsKnownSubClass;\r
1015\r
95276127 1016\r
1017 UsbClass = DevPath;\r
1018\r
cf40f28a 1019 IsKnownSubClass = TRUE;\r
1020 switch (UsbClass->DeviceClass) {\r
1021 case USB_CLASS_AUDIO:\r
4d0a30a4 1022 UefiDevicePathLibCatPrint (Str, L"UsbAudio");\r
cf40f28a 1023 break;\r
95276127 1024\r
cf40f28a 1025 case USB_CLASS_CDCCONTROL:\r
4d0a30a4 1026 UefiDevicePathLibCatPrint (Str, L"UsbCDCControl");\r
cf40f28a 1027 break;\r
95276127 1028\r
cf40f28a 1029 case USB_CLASS_HID:\r
4d0a30a4 1030 UefiDevicePathLibCatPrint (Str, L"UsbHID");\r
cf40f28a 1031 break;\r
95276127 1032\r
cf40f28a 1033 case USB_CLASS_IMAGE:\r
4d0a30a4 1034 UefiDevicePathLibCatPrint (Str, L"UsbImage");\r
cf40f28a 1035 break;\r
95276127 1036\r
cf40f28a 1037 case USB_CLASS_PRINTER:\r
4d0a30a4 1038 UefiDevicePathLibCatPrint (Str, L"UsbPrinter");\r
cf40f28a 1039 break;\r
95276127 1040\r
cf40f28a 1041 case USB_CLASS_MASS_STORAGE:\r
4d0a30a4 1042 UefiDevicePathLibCatPrint (Str, L"UsbMassStorage");\r
cf40f28a 1043 break;\r
95276127 1044\r
cf40f28a 1045 case USB_CLASS_HUB:\r
4d0a30a4 1046 UefiDevicePathLibCatPrint (Str, L"UsbHub");\r
cf40f28a 1047 break;\r
95276127 1048\r
cf40f28a 1049 case USB_CLASS_CDCDATA:\r
4d0a30a4 1050 UefiDevicePathLibCatPrint (Str, L"UsbCDCData");\r
cf40f28a 1051 break;\r
95276127 1052\r
cf40f28a 1053 case USB_CLASS_SMART_CARD:\r
4d0a30a4 1054 UefiDevicePathLibCatPrint (Str, L"UsbSmartCard");\r
cf40f28a 1055 break;\r
95276127 1056\r
cf40f28a 1057 case USB_CLASS_VIDEO:\r
4d0a30a4 1058 UefiDevicePathLibCatPrint (Str, L"UsbVideo");\r
cf40f28a 1059 break;\r
1060\r
1061 case USB_CLASS_DIAGNOSTIC:\r
4d0a30a4 1062 UefiDevicePathLibCatPrint (Str, L"UsbDiagnostic");\r
cf40f28a 1063 break;\r
1064\r
1065 case USB_CLASS_WIRELESS:\r
4d0a30a4 1066 UefiDevicePathLibCatPrint (Str, L"UsbWireless");\r
cf40f28a 1067 break;\r
1068\r
1069 default:\r
1070 IsKnownSubClass = FALSE;\r
1071 break;\r
1072 }\r
1073\r
1074 if (IsKnownSubClass) {\r
4d0a30a4 1075 UefiDevicePathLibCatPrint (\r
cf40f28a 1076 Str,\r
1077 L"(0x%x,0x%x,0x%x,0x%x)",\r
e9b3cd55
RN
1078 UsbClass->VendorId,\r
1079 UsbClass->ProductId,\r
1080 UsbClass->DeviceSubClass,\r
1081 UsbClass->DeviceProtocol\r
cf40f28a 1082 );\r
1083 return;\r
1084 }\r
1085\r
1086 if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {\r
1087 if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {\r
4d0a30a4 1088 UefiDevicePathLibCatPrint (\r
95276127 1089 Str,\r
cf40f28a 1090 L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",\r
e9b3cd55
RN
1091 UsbClass->VendorId,\r
1092 UsbClass->ProductId,\r
1093 UsbClass->DeviceProtocol\r
95276127 1094 );\r
cf40f28a 1095 return;\r
1096 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {\r
4d0a30a4 1097 UefiDevicePathLibCatPrint (\r
95276127 1098 Str,\r
cf40f28a 1099 L"UsbIrdaBridge(0x%x,0x%x,0x%x)",\r
e9b3cd55
RN
1100 UsbClass->VendorId,\r
1101 UsbClass->ProductId,\r
1102 UsbClass->DeviceProtocol\r
95276127 1103 );\r
cf40f28a 1104 return;\r
1105 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {\r
4d0a30a4 1106 UefiDevicePathLibCatPrint (\r
95276127 1107 Str,\r
cf40f28a 1108 L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",\r
e9b3cd55
RN
1109 UsbClass->VendorId,\r
1110 UsbClass->ProductId,\r
1111 UsbClass->DeviceProtocol\r
95276127 1112 );\r
cf40f28a 1113 return;\r
95276127 1114 }\r
95276127 1115 }\r
1116\r
4d0a30a4 1117 UefiDevicePathLibCatPrint (\r
95276127 1118 Str,\r
cf40f28a 1119 L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",\r
e9b3cd55
RN
1120 UsbClass->VendorId,\r
1121 UsbClass->ProductId,\r
1122 UsbClass->DeviceClass,\r
1123 UsbClass->DeviceSubClass,\r
1124 UsbClass->DeviceProtocol\r
95276127 1125 );\r
1126}\r
1127\r
572f5d8a 1128/**\r
48557c65 1129 Converts a SATA device path structure to its string representative.\r
572f5d8a 1130\r
48557c65 1131 @param Str The string representative of input device.\r
572f5d8a 1132 @param DevPath The input device path structure.\r
1133 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1134 of the display node is used, where applicable. If DisplayOnly\r
1135 is FALSE, then the longer text representation of the display node\r
1136 is used.\r
1137 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1138 representation for a device node can be used, where applicable.\r
1139\r
1140**/\r
cf40f28a 1141VOID\r
1142DevPathToTextSata (\r
1143 IN OUT POOL_PRINT *Str,\r
1144 IN VOID *DevPath,\r
1145 IN BOOLEAN DisplayOnly,\r
1146 IN BOOLEAN AllowShortcuts\r
1147 )\r
1148{\r
1149 SATA_DEVICE_PATH *Sata;\r
1150\r
1151 Sata = DevPath;\r
9da38884
RN
1152 UefiDevicePathLibCatPrint (\r
1153 Str,\r
1154 L"Sata(0x%x,0x%x,0x%x)",\r
1155 Sata->HBAPortNumber,\r
1156 Sata->PortMultiplierPortNumber,\r
1157 Sata->Lun\r
1158 );\r
cf40f28a 1159}\r
1160\r
572f5d8a 1161/**\r
48557c65 1162 Converts a I20 device path structure to its string representative.\r
572f5d8a 1163\r
48557c65 1164 @param Str The string representative of input device.\r
572f5d8a 1165 @param DevPath The input device path structure.\r
1166 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1167 of the display node is used, where applicable. If DisplayOnly\r
1168 is FALSE, then the longer text representation of the display node\r
1169 is used.\r
1170 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1171 representation for a device node can be used, where applicable.\r
1172\r
1173**/\r
95276127 1174VOID\r
1175DevPathToTextI2O (\r
1176 IN OUT POOL_PRINT *Str,\r
1177 IN VOID *DevPath,\r
1178 IN BOOLEAN DisplayOnly,\r
1179 IN BOOLEAN AllowShortcuts\r
1180 )\r
1181{\r
572f5d8a 1182 I2O_DEVICE_PATH *I2ODevPath;\r
95276127 1183\r
572f5d8a 1184 I2ODevPath = DevPath;\r
4d0a30a4 1185 UefiDevicePathLibCatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid);\r
95276127 1186}\r
1187\r
572f5d8a 1188/**\r
48557c65 1189 Converts a MAC address device path structure to its string representative.\r
572f5d8a 1190\r
48557c65 1191 @param Str The string representative of input device.\r
572f5d8a 1192 @param DevPath The input device path structure.\r
1193 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1194 of the display node is used, where applicable. If DisplayOnly\r
1195 is FALSE, then the longer text representation of the display node\r
1196 is used.\r
1197 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1198 representation for a device node can be used, where applicable.\r
1199\r
1200**/\r
95276127 1201VOID\r
1202DevPathToTextMacAddr (\r
1203 IN OUT POOL_PRINT *Str,\r
1204 IN VOID *DevPath,\r
1205 IN BOOLEAN DisplayOnly,\r
1206 IN BOOLEAN AllowShortcuts\r
1207 )\r
1208{\r
572f5d8a 1209 MAC_ADDR_DEVICE_PATH *MacDevPath;\r
95276127 1210 UINTN HwAddressSize;\r
1211 UINTN Index;\r
1212\r
572f5d8a 1213 MacDevPath = DevPath;\r
95276127 1214\r
1215 HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
572f5d8a 1216 if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {\r
95276127 1217 HwAddressSize = 6;\r
1218 }\r
1219\r
4d0a30a4 1220 UefiDevicePathLibCatPrint (Str, L"MAC(");\r
95276127 1221\r
1222 for (Index = 0; Index < HwAddressSize; Index++) {\r
4d0a30a4 1223 UefiDevicePathLibCatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]);\r
95276127 1224 }\r
1225\r
4d0a30a4 1226 UefiDevicePathLibCatPrint (Str, L",0x%x)", MacDevPath->IfType);\r
95276127 1227}\r
1228\r
052019e1 1229/**\r
1230 Converts network protocol string to its text representation.\r
1231\r
1232 @param Str The string representative of input device.\r
1233 @param Protocol The network protocol ID.\r
1234\r
1235**/\r
1236VOID\r
1237CatNetworkProtocol (\r
1238 IN OUT POOL_PRINT *Str,\r
1239 IN UINT16 Protocol\r
1240 )\r
1241{\r
1242 if (Protocol == RFC_1700_TCP_PROTOCOL) {\r
4d0a30a4 1243 UefiDevicePathLibCatPrint (Str, L"TCP");\r
052019e1 1244 } else if (Protocol == RFC_1700_UDP_PROTOCOL) {\r
4d0a30a4 1245 UefiDevicePathLibCatPrint (Str, L"UDP");\r
052019e1 1246 } else {\r
4d0a30a4 1247 UefiDevicePathLibCatPrint (Str, L"0x%x", Protocol);\r
052019e1 1248 }\r
1249}\r
1250\r
4d0a30a4
RN
1251/**\r
1252 Converts IP v4 address to its text representation.\r
1253\r
1254 @param Str The string representative of input device.\r
1255 @param Address The IP v4 address.\r
1256**/\r
1257VOID\r
1258CatIPv4Address (\r
1259 IN OUT POOL_PRINT *Str,\r
1260 IN EFI_IPv4_ADDRESS *Address\r
1261 )\r
1262{\r
1263 UefiDevicePathLibCatPrint (Str, L"%d.%d.%d.%d", Address->Addr[0], Address->Addr[1], Address->Addr[2], Address->Addr[3]);\r
1264}\r
1265\r
1266/**\r
1267 Converts IP v6 address to its text representation.\r
1268\r
1269 @param Str The string representative of input device.\r
1270 @param Address The IP v6 address.\r
1271**/\r
1272VOID\r
1273CatIPv6Address (\r
1274 IN OUT POOL_PRINT *Str,\r
1275 IN EFI_IPv6_ADDRESS *Address\r
1276 )\r
1277{\r
1278 UefiDevicePathLibCatPrint (\r
1279 Str, L"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",\r
1280 Address->Addr[0], Address->Addr[1],\r
1281 Address->Addr[2], Address->Addr[3],\r
1282 Address->Addr[4], Address->Addr[5],\r
1283 Address->Addr[6], Address->Addr[7],\r
1284 Address->Addr[8], Address->Addr[9],\r
1285 Address->Addr[10], Address->Addr[11],\r
1286 Address->Addr[12], Address->Addr[13],\r
1287 Address->Addr[14], Address->Addr[15]\r
1288 );\r
1289}\r
1290\r
572f5d8a 1291/**\r
48557c65 1292 Converts a IPv4 device path structure to its string representative.\r
572f5d8a 1293\r
48557c65 1294 @param Str The string representative of input device.\r
572f5d8a 1295 @param DevPath The input device path structure.\r
1296 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1297 of the display node is used, where applicable. If DisplayOnly\r
1298 is FALSE, then the longer text representation of the display node\r
1299 is used.\r
1300 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1301 representation for a device node can be used, where applicable.\r
1302\r
1303**/\r
95276127 1304VOID\r
1305DevPathToTextIPv4 (\r
1306 IN OUT POOL_PRINT *Str,\r
1307 IN VOID *DevPath,\r
1308 IN BOOLEAN DisplayOnly,\r
1309 IN BOOLEAN AllowShortcuts\r
1310 )\r
1311{\r
572f5d8a 1312 IPv4_DEVICE_PATH *IPDevPath;\r
95276127 1313\r
572f5d8a 1314 IPDevPath = DevPath;\r
4d0a30a4
RN
1315 UefiDevicePathLibCatPrint (Str, L"IPv4(");\r
1316 CatIPv4Address (Str, &IPDevPath->RemoteIpAddress);\r
1317\r
572f5d8a 1318 if (DisplayOnly) {\r
4d0a30a4 1319 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 1320 return ;\r
1321 }\r
1322\r
4d0a30a4
RN
1323 UefiDevicePathLibCatPrint (Str, L",");\r
1324 CatNetworkProtocol (Str, IPDevPath->Protocol);\r
052019e1 1325\r
4d0a30a4
RN
1326 UefiDevicePathLibCatPrint (Str, L",%s,", IPDevPath->StaticIpAddress ? L"Static" : L"DHCP");\r
1327 CatIPv4Address (Str, &IPDevPath->LocalIpAddress);\r
e9b3cd55 1328 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv4_DEVICE_PATH)) {\r
4d0a30a4
RN
1329 UefiDevicePathLibCatPrint (Str, L",");\r
1330 CatIPv4Address (Str, &IPDevPath->GatewayIpAddress);\r
1331 UefiDevicePathLibCatPrint (Str, L",");\r
1332 CatIPv4Address (Str, &IPDevPath->SubnetMask);\r
e9b3cd55 1333 }\r
4d0a30a4 1334 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 1335}\r
1336\r
572f5d8a 1337/**\r
48557c65 1338 Converts a IPv6 device path structure to its string representative.\r
572f5d8a 1339\r
48557c65 1340 @param Str The string representative of input device.\r
572f5d8a 1341 @param DevPath The input device path structure.\r
1342 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1343 of the display node is used, where applicable. If DisplayOnly\r
1344 is FALSE, then the longer text representation of the display node\r
1345 is used.\r
1346 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1347 representation for a device node can be used, where applicable.\r
1348\r
1349**/\r
95276127 1350VOID\r
1351DevPathToTextIPv6 (\r
1352 IN OUT POOL_PRINT *Str,\r
1353 IN VOID *DevPath,\r
1354 IN BOOLEAN DisplayOnly,\r
1355 IN BOOLEAN AllowShortcuts\r
1356 )\r
1357{\r
572f5d8a 1358 IPv6_DEVICE_PATH *IPDevPath;\r
95276127 1359\r
572f5d8a 1360 IPDevPath = DevPath;\r
4d0a30a4
RN
1361 UefiDevicePathLibCatPrint (Str, L"IPv6(");\r
1362 CatIPv6Address (Str, &IPDevPath->RemoteIpAddress);\r
572f5d8a 1363 if (DisplayOnly) {\r
4d0a30a4 1364 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 1365 return ;\r
1366 }\r
4d0a30a4
RN
1367 \r
1368 UefiDevicePathLibCatPrint (Str, L",");\r
1369 CatNetworkProtocol (Str, IPDevPath->Protocol);\r
052019e1 1370\r
501793fa
RN
1371 switch (IPDevPath->IpAddressOrigin) {\r
1372 case 0:\r
4d0a30a4 1373 UefiDevicePathLibCatPrint (Str, L",Static,");\r
501793fa
RN
1374 break;\r
1375 case 1:\r
4d0a30a4 1376 UefiDevicePathLibCatPrint (Str, L",StatelessAutoConfigure,");\r
501793fa
RN
1377 break;\r
1378 default:\r
4d0a30a4 1379 UefiDevicePathLibCatPrint (Str, L",StatefulAutoConfigure,");\r
501793fa
RN
1380 break;\r
1381 }\r
1382\r
4d0a30a4 1383 CatIPv6Address (Str, &IPDevPath->LocalIpAddress);\r
501793fa
RN
1384\r
1385 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv6_DEVICE_PATH)) {\r
4d0a30a4
RN
1386 UefiDevicePathLibCatPrint (Str, L",0x%x,", IPDevPath->PrefixLength);\r
1387 CatIPv6Address (Str, &IPDevPath->GatewayIpAddress);\r
501793fa 1388 }\r
4d0a30a4 1389 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 1390}\r
1391\r
572f5d8a 1392/**\r
48557c65 1393 Converts an Infini Band device path structure to its string representative.\r
572f5d8a 1394\r
48557c65 1395 @param Str The string representative of input device.\r
572f5d8a 1396 @param DevPath The input device path structure.\r
1397 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1398 of the display node is used, where applicable. If DisplayOnly\r
1399 is FALSE, then the longer text representation of the display node\r
1400 is used.\r
1401 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1402 representation for a device node can be used, where applicable.\r
1403\r
1404**/\r
95276127 1405VOID\r
1406DevPathToTextInfiniBand (\r
1407 IN OUT POOL_PRINT *Str,\r
1408 IN VOID *DevPath,\r
1409 IN BOOLEAN DisplayOnly,\r
1410 IN BOOLEAN AllowShortcuts\r
1411 )\r
1412{\r
1413 INFINIBAND_DEVICE_PATH *InfiniBand;\r
1414\r
1415 InfiniBand = DevPath;\r
4d0a30a4 1416 UefiDevicePathLibCatPrint (\r
95276127 1417 Str,\r
cf40f28a 1418 L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",\r
e9b3cd55 1419 InfiniBand->ResourceFlags,\r
95276127 1420 InfiniBand->PortGid,\r
1421 InfiniBand->ServiceId,\r
1422 InfiniBand->TargetPortId,\r
1423 InfiniBand->DeviceId\r
1424 );\r
1425}\r
1426\r
572f5d8a 1427/**\r
48557c65 1428 Converts a UART device path structure to its string representative.\r
572f5d8a 1429\r
48557c65 1430 @param Str The string representative of input device.\r
572f5d8a 1431 @param DevPath The input device path structure.\r
1432 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1433 of the display node is used, where applicable. If DisplayOnly\r
1434 is FALSE, then the longer text representation of the display node\r
1435 is used.\r
1436 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1437 representation for a device node can be used, where applicable.\r
1438\r
1439**/\r
95276127 1440VOID\r
1441DevPathToTextUart (\r
1442 IN OUT POOL_PRINT *Str,\r
1443 IN VOID *DevPath,\r
1444 IN BOOLEAN DisplayOnly,\r
1445 IN BOOLEAN AllowShortcuts\r
1446 )\r
1447{\r
1448 UART_DEVICE_PATH *Uart;\r
1449 CHAR8 Parity;\r
1450\r
1451 Uart = DevPath;\r
1452 switch (Uart->Parity) {\r
1453 case 0:\r
1454 Parity = 'D';\r
1455 break;\r
1456\r
1457 case 1:\r
1458 Parity = 'N';\r
1459 break;\r
1460\r
1461 case 2:\r
1462 Parity = 'E';\r
1463 break;\r
1464\r
1465 case 3:\r
1466 Parity = 'O';\r
1467 break;\r
1468\r
1469 case 4:\r
1470 Parity = 'M';\r
1471 break;\r
1472\r
1473 case 5:\r
1474 Parity = 'S';\r
1475 break;\r
1476\r
1477 default:\r
1478 Parity = 'x';\r
1479 break;\r
1480 }\r
1481\r
1482 if (Uart->BaudRate == 0) {\r
4d0a30a4 1483 UefiDevicePathLibCatPrint (Str, L"Uart(DEFAULT,");\r
95276127 1484 } else {\r
4d0a30a4 1485 UefiDevicePathLibCatPrint (Str, L"Uart(%ld,", Uart->BaudRate);\r
95276127 1486 }\r
1487\r
1488 if (Uart->DataBits == 0) {\r
4d0a30a4 1489 UefiDevicePathLibCatPrint (Str, L"DEFAULT,");\r
95276127 1490 } else {\r
4d0a30a4 1491 UefiDevicePathLibCatPrint (Str, L"%d,", Uart->DataBits);\r
95276127 1492 }\r
1493\r
4d0a30a4 1494 UefiDevicePathLibCatPrint (Str, L"%c,", Parity);\r
95276127 1495\r
1496 switch (Uart->StopBits) {\r
1497 case 0:\r
4d0a30a4 1498 UefiDevicePathLibCatPrint (Str, L"D)");\r
95276127 1499 break;\r
1500\r
1501 case 1:\r
4d0a30a4 1502 UefiDevicePathLibCatPrint (Str, L"1)");\r
95276127 1503 break;\r
1504\r
1505 case 2:\r
4d0a30a4 1506 UefiDevicePathLibCatPrint (Str, L"1.5)");\r
95276127 1507 break;\r
1508\r
1509 case 3:\r
4d0a30a4 1510 UefiDevicePathLibCatPrint (Str, L"2)");\r
95276127 1511 break;\r
1512\r
1513 default:\r
4d0a30a4 1514 UefiDevicePathLibCatPrint (Str, L"x)");\r
95276127 1515 break;\r
1516 }\r
1517}\r
1518\r
572f5d8a 1519/**\r
48557c65 1520 Converts an iSCSI device path structure to its string representative.\r
572f5d8a 1521\r
48557c65 1522 @param Str The string representative of input device.\r
572f5d8a 1523 @param DevPath The input device path structure.\r
1524 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1525 of the display node is used, where applicable. If DisplayOnly\r
1526 is FALSE, then the longer text representation of the display node\r
1527 is used.\r
1528 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1529 representation for a device node can be used, where applicable.\r
1530\r
1531**/\r
95276127 1532VOID\r
1533DevPathToTextiSCSI (\r
1534 IN OUT POOL_PRINT *Str,\r
1535 IN VOID *DevPath,\r
1536 IN BOOLEAN DisplayOnly,\r
1537 IN BOOLEAN AllowShortcuts\r
1538 )\r
1539{\r
572f5d8a 1540 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
95276127 1541 UINT16 Options;\r
1542\r
572f5d8a 1543 ISCSIDevPath = DevPath;\r
4d0a30a4 1544 UefiDevicePathLibCatPrint (\r
95276127 1545 Str,\r
cf40f28a 1546 L"iSCSI(%a,0x%x,0x%lx,",\r
184f7d83 1547 ISCSIDevPath->TargetName,\r
e9b3cd55 1548 ISCSIDevPath->TargetPortalGroupTag,\r
572f5d8a 1549 ISCSIDevPath->Lun\r
95276127 1550 );\r
1551\r
572f5d8a 1552 Options = ISCSIDevPath->LoginOption;\r
4d0a30a4
RN
1553 UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
1554 UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
572f5d8a 1555 if (((Options >> 11) & 0x0001) != 0) {\r
4d0a30a4 1556 UefiDevicePathLibCatPrint (Str, L"%s,", L"None");\r
572f5d8a 1557 } else if (((Options >> 12) & 0x0001) != 0) {\r
4d0a30a4 1558 UefiDevicePathLibCatPrint (Str, L"%s,", L"CHAP_UNI");\r
95276127 1559 } else {\r
4d0a30a4 1560 UefiDevicePathLibCatPrint (Str, L"%s,", L"CHAP_BI");\r
95276127 1561\r
1562 }\r
1563\r
4d0a30a4 1564 UefiDevicePathLibCatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
95276127 1565}\r
1566\r
8f97f911 1567/**\r
1568 Converts a VLAN device path structure to its string representative.\r
1569\r
1570 @param Str The string representative of input device.\r
1571 @param DevPath The input device path structure.\r
1572 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1573 of the display node is used, where applicable. If DisplayOnly\r
1574 is FALSE, then the longer text representation of the display node\r
1575 is used.\r
1576 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1577 representation for a device node can be used, where applicable.\r
1578\r
1579**/\r
1580VOID\r
1581DevPathToTextVlan (\r
1582 IN OUT POOL_PRINT *Str,\r
1583 IN VOID *DevPath,\r
1584 IN BOOLEAN DisplayOnly,\r
1585 IN BOOLEAN AllowShortcuts\r
1586 )\r
1587{\r
1588 VLAN_DEVICE_PATH *Vlan;\r
1589\r
1590 Vlan = DevPath;\r
4d0a30a4 1591 UefiDevicePathLibCatPrint (Str, L"Vlan(%d)", Vlan->VlanId);\r
8f97f911 1592}\r
1593\r
7795c8f9
QS
1594/**\r
1595 Converts a Bluetooth device path structure to its string representative.\r
1596\r
1597 @param Str The string representative of input device.\r
1598 @param DevPath The input device path structure.\r
1599 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1600 of the display node is used, where applicable. If DisplayOnly\r
1601 is FALSE, then the longer text representation of the display node\r
1602 is used.\r
1603 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1604 representation for a device node can be used, where applicable.\r
1605\r
1606**/\r
1607VOID\r
1608DevPathToTextBluetooth (\r
1609 IN OUT POOL_PRINT *Str,\r
1610 IN VOID *DevPath,\r
1611 IN BOOLEAN DisplayOnly,\r
1612 IN BOOLEAN AllowShortcuts\r
1613 )\r
1614{\r
1615 BLUETOOTH_DEVICE_PATH *Bluetooth;\r
1616\r
1617 Bluetooth = DevPath;\r
1618 UefiDevicePathLibCatPrint (\r
1619 Str,\r
6252f271 1620 L"Bluetooth(%02x%02x%02x%02x%02x%02x)",\r
4fc82771 1621 Bluetooth->BD_ADDR.Address[0],\r
7795c8f9 1622 Bluetooth->BD_ADDR.Address[1],\r
4fc82771
HW
1623 Bluetooth->BD_ADDR.Address[2],\r
1624 Bluetooth->BD_ADDR.Address[3],\r
1625 Bluetooth->BD_ADDR.Address[4],\r
1626 Bluetooth->BD_ADDR.Address[5]\r
7795c8f9
QS
1627 );\r
1628}\r
1629\r
3bafd562
HW
1630/**\r
1631 Converts a Wi-Fi device path structure to its string representative.\r
1632\r
1633 @param Str The string representative of input device.\r
1634 @param DevPath The input device path structure.\r
1635 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1636 of the display node is used, where applicable. If DisplayOnly\r
1637 is FALSE, then the longer text representation of the display node\r
1638 is used.\r
1639 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1640 representation for a device node can be used, where applicable.\r
1641\r
1642**/\r
1643VOID\r
1644DevPathToTextWiFi (\r
1645 IN OUT POOL_PRINT *Str,\r
1646 IN VOID *DevPath,\r
1647 IN BOOLEAN DisplayOnly,\r
1648 IN BOOLEAN AllowShortcuts\r
1649 )\r
1650{\r
1651 WIFI_DEVICE_PATH *WiFi;\r
0cd35d73 1652 UINT8 SSId[33];\r
3bafd562
HW
1653\r
1654 WiFi = DevPath;\r
0cd35d73
HW
1655\r
1656 SSId[32] = '\0';\r
1657 CopyMem (SSId, WiFi->SSId, 32);\r
1658\r
1659 UefiDevicePathLibCatPrint (Str, L"Wi-Fi(%a)", SSId);\r
3bafd562
HW
1660}\r
1661\r
ff5623e9
RN
1662/**\r
1663 Converts a Bluetooth device path structure to its string representative.\r
1664\r
1665 @param Str The string representative of input device.\r
1666 @param DevPath The input device path structure.\r
1667 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1668 of the display node is used, where applicable. If DisplayOnly\r
1669 is FALSE, then the longer text representation of the display node\r
1670 is used.\r
1671 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1672 representation for a device node can be used, where applicable.\r
1673\r
1674**/\r
1675VOID\r
1676DevPathToTextBluetoothLE (\r
1677 IN OUT POOL_PRINT *Str,\r
1678 IN VOID *DevPath,\r
1679 IN BOOLEAN DisplayOnly,\r
1680 IN BOOLEAN AllowShortcuts\r
1681 )\r
1682{\r
1683 BLUETOOTH_LE_DEVICE_PATH *BluetoothLE;\r
1684\r
1685 BluetoothLE = DevPath;\r
1686 UefiDevicePathLibCatPrint (\r
1687 Str,\r
1688 L"BluetoothLE(%02x%02x%02x%02x%02x%02x,0x%02x)",\r
1689 BluetoothLE->Address.Address[0],\r
1690 BluetoothLE->Address.Address[1],\r
1691 BluetoothLE->Address.Address[2],\r
1692 BluetoothLE->Address.Address[3],\r
1693 BluetoothLE->Address.Address[4],\r
1694 BluetoothLE->Address.Address[5],\r
1695 BluetoothLE->Address.Type\r
1696 );\r
1697}\r
1698\r
c808ac7b
RN
1699/**\r
1700 Converts a URI device path structure to its string representative.\r
1701\r
1702 @param Str The string representative of input device.\r
1703 @param DevPath The input device path structure.\r
1704 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1705 of the display node is used, where applicable. If DisplayOnly\r
1706 is FALSE, then the longer text representation of the display node\r
1707 is used.\r
1708 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1709 representation for a device node can be used, where applicable.\r
1710\r
1711**/\r
1712VOID\r
1713DevPathToTextUri (\r
1714 IN OUT POOL_PRINT *Str,\r
1715 IN VOID *DevPath,\r
1716 IN BOOLEAN DisplayOnly,\r
1717 IN BOOLEAN AllowShortcuts\r
1718 )\r
1719{\r
1720 URI_DEVICE_PATH *Uri;\r
1721 UINTN UriLength;\r
1722 CHAR8 *UriStr;\r
1723\r
1724 //\r
1725 // Uri in the device path may not be null terminated.\r
1726 //\r
1727 Uri = DevPath;\r
1728 UriLength = DevicePathNodeLength (Uri) - sizeof (URI_DEVICE_PATH);\r
1729 UriStr = AllocatePool (UriLength + 1);\r
1730 ASSERT (UriStr != NULL);\r
1731\r
1732 CopyMem (UriStr, Uri->Uri, UriLength);\r
1733 UriStr[UriLength] = '\0';\r
1734 UefiDevicePathLibCatPrint (Str, L"Uri(%a)", UriStr);\r
1735 FreePool (UriStr);\r
1736}\r
1737\r
572f5d8a 1738/**\r
48557c65 1739 Converts a Hard drive device path structure to its string representative.\r
572f5d8a 1740\r
48557c65 1741 @param Str The string representative of input device.\r
572f5d8a 1742 @param DevPath The input device path structure.\r
1743 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1744 of the display node is used, where applicable. If DisplayOnly\r
1745 is FALSE, then the longer text representation of the display node\r
1746 is used.\r
1747 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1748 representation for a device node can be used, where applicable.\r
1749\r
1750**/\r
95276127 1751VOID\r
1752DevPathToTextHardDrive (\r
1753 IN OUT POOL_PRINT *Str,\r
1754 IN VOID *DevPath,\r
1755 IN BOOLEAN DisplayOnly,\r
1756 IN BOOLEAN AllowShortcuts\r
1757 )\r
1758{\r
1759 HARDDRIVE_DEVICE_PATH *Hd;\r
1760\r
1761 Hd = DevPath;\r
1762 switch (Hd->SignatureType) {\r
95276127 1763 case SIGNATURE_TYPE_MBR:\r
4d0a30a4 1764 UefiDevicePathLibCatPrint (\r
95276127 1765 Str,\r
cf40f28a 1766 L"HD(%d,%s,0x%08x,",\r
e9b3cd55 1767 Hd->PartitionNumber,\r
95276127 1768 L"MBR",\r
e9b3cd55 1769 *((UINT32 *) (&(Hd->Signature[0])))\r
95276127 1770 );\r
1771 break;\r
1772\r
1773 case SIGNATURE_TYPE_GUID:\r
4d0a30a4 1774 UefiDevicePathLibCatPrint (\r
95276127 1775 Str,\r
1776 L"HD(%d,%s,%g,",\r
e9b3cd55 1777 Hd->PartitionNumber,\r
cf40f28a 1778 L"GPT",\r
95276127 1779 (EFI_GUID *) &(Hd->Signature[0])\r
1780 );\r
1781 break;\r
1782\r
1783 default:\r
4d0a30a4 1784 UefiDevicePathLibCatPrint (\r
cf40f28a 1785 Str,\r
1786 L"HD(%d,%d,0,",\r
e9b3cd55
RN
1787 Hd->PartitionNumber,\r
1788 Hd->SignatureType\r
cf40f28a 1789 );\r
95276127 1790 break;\r
1791 }\r
1792\r
4d0a30a4 1793 UefiDevicePathLibCatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);\r
95276127 1794}\r
1795\r
572f5d8a 1796/**\r
48557c65 1797 Converts a CDROM device path structure to its string representative.\r
572f5d8a 1798\r
48557c65 1799 @param Str The string representative of input device.\r
572f5d8a 1800 @param DevPath The input device path structure.\r
1801 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1802 of the display node is used, where applicable. If DisplayOnly\r
1803 is FALSE, then the longer text representation of the display node\r
1804 is used.\r
1805 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1806 representation for a device node can be used, where applicable.\r
1807\r
1808**/\r
95276127 1809VOID\r
1810DevPathToTextCDROM (\r
1811 IN OUT POOL_PRINT *Str,\r
1812 IN VOID *DevPath,\r
1813 IN BOOLEAN DisplayOnly,\r
1814 IN BOOLEAN AllowShortcuts\r
1815 )\r
1816{\r
1817 CDROM_DEVICE_PATH *Cd;\r
1818\r
1819 Cd = DevPath;\r
572f5d8a 1820 if (DisplayOnly) {\r
4d0a30a4 1821 UefiDevicePathLibCatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);\r
95276127 1822 return ;\r
1823 }\r
1824\r
4d0a30a4 1825 UefiDevicePathLibCatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
95276127 1826}\r
1827\r
572f5d8a 1828/**\r
48557c65 1829 Converts a File device path structure to its string representative.\r
572f5d8a 1830\r
48557c65 1831 @param Str The string representative of input device.\r
572f5d8a 1832 @param DevPath The input device path structure.\r
1833 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1834 of the display node is used, where applicable. If DisplayOnly\r
1835 is FALSE, then the longer text representation of the display node\r
1836 is used.\r
1837 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1838 representation for a device node can be used, where applicable.\r
1839\r
1840**/\r
95276127 1841VOID\r
1842DevPathToTextFilePath (\r
1843 IN OUT POOL_PRINT *Str,\r
1844 IN VOID *DevPath,\r
1845 IN BOOLEAN DisplayOnly,\r
1846 IN BOOLEAN AllowShortcuts\r
1847 )\r
1848{\r
1849 FILEPATH_DEVICE_PATH *Fp;\r
1850\r
1851 Fp = DevPath;\r
4d0a30a4 1852 UefiDevicePathLibCatPrint (Str, L"%s", Fp->PathName);\r
95276127 1853}\r
1854\r
572f5d8a 1855/**\r
48557c65 1856 Converts a Media protocol device path structure to its string representative.\r
572f5d8a 1857\r
48557c65 1858 @param Str The string representative of input device.\r
572f5d8a 1859 @param DevPath The input device path structure.\r
1860 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1861 of the display node is used, where applicable. If DisplayOnly\r
1862 is FALSE, then the longer text representation of the display node\r
1863 is used.\r
1864 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1865 representation for a device node can be used, where applicable.\r
1866\r
1867**/\r
95276127 1868VOID\r
1869DevPathToTextMediaProtocol (\r
1870 IN OUT POOL_PRINT *Str,\r
1871 IN VOID *DevPath,\r
1872 IN BOOLEAN DisplayOnly,\r
1873 IN BOOLEAN AllowShortcuts\r
1874 )\r
1875{\r
1876 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;\r
1877\r
1878 MediaProt = DevPath;\r
4d0a30a4 1879 UefiDevicePathLibCatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
95276127 1880}\r
1881\r
572f5d8a 1882/**\r
48557c65 1883 Converts a Firmware Volume device path structure to its string representative.\r
572f5d8a 1884\r
48557c65 1885 @param Str The string representative of input device.\r
572f5d8a 1886 @param DevPath The input device path structure.\r
1887 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1888 of the display node is used, where applicable. If DisplayOnly\r
1889 is FALSE, then the longer text representation of the display node\r
1890 is used.\r
1891 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1892 representation for a device node can be used, where applicable.\r
1893\r
1894**/\r
cf40f28a 1895VOID\r
1896DevPathToTextFv (\r
1897 IN OUT POOL_PRINT *Str,\r
1898 IN VOID *DevPath,\r
1899 IN BOOLEAN DisplayOnly,\r
1900 IN BOOLEAN AllowShortcuts\r
1901 )\r
1902{\r
1903 MEDIA_FW_VOL_DEVICE_PATH *Fv;\r
1904\r
1905 Fv = DevPath;\r
4d0a30a4 1906 UefiDevicePathLibCatPrint (Str, L"Fv(%g)", &Fv->FvName);\r
cf40f28a 1907}\r
1908\r
572f5d8a 1909/**\r
48557c65 1910 Converts a Firmware Volume File device path structure to its string representative.\r
572f5d8a 1911\r
48557c65 1912 @param Str The string representative of input device.\r
572f5d8a 1913 @param DevPath The input device path structure.\r
1914 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1915 of the display node is used, where applicable. If DisplayOnly\r
1916 is FALSE, then the longer text representation of the display node\r
1917 is used.\r
1918 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1919 representation for a device node can be used, where applicable.\r
1920\r
1921**/\r
cf40f28a 1922VOID\r
1923DevPathToTextFvFile (\r
1924 IN OUT POOL_PRINT *Str,\r
1925 IN VOID *DevPath,\r
1926 IN BOOLEAN DisplayOnly,\r
1927 IN BOOLEAN AllowShortcuts\r
1928 )\r
1929{\r
1930 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;\r
1931\r
1932 FvFile = DevPath;\r
4d0a30a4 1933 UefiDevicePathLibCatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);\r
cf40f28a 1934}\r
1935\r
09e15613 1936/**\r
1937 Converts a Relative Offset device path structure to its string representative.\r
1938\r
1939 @param Str The string representative of input device.\r
1940 @param DevPath The input device path structure.\r
1941 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1942 of the display node is used, where applicable. If DisplayOnly\r
1943 is FALSE, then the longer text representation of the display node\r
1944 is used.\r
1945 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1946 representation for a device node can be used, where applicable.\r
1947\r
1948**/\r
1949VOID\r
1950DevPathRelativeOffsetRange (\r
1951 IN OUT POOL_PRINT *Str,\r
1952 IN VOID *DevPath,\r
1953 IN BOOLEAN DisplayOnly,\r
1954 IN BOOLEAN AllowShortcuts\r
1955 )\r
1956{\r
1957 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
1958\r
1959 Offset = DevPath;\r
4d0a30a4 1960 UefiDevicePathLibCatPrint (\r
09e15613 1961 Str,\r
7748eb28 1962 L"Offset(0x%lx,0x%lx)",\r
09e15613 1963 Offset->StartingOffset,\r
1964 Offset->EndingOffset\r
1965 );\r
1966}\r
1967\r
6a46c1a2
FT
1968/**\r
1969 Converts a Ram Disk device path structure to its string representative.\r
1970\r
1971 @param Str The string representative of input device.\r
1972 @param DevPath The input device path structure.\r
1973 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1974 of the display node is used, where applicable. If DisplayOnly\r
1975 is FALSE, then the longer text representation of the display node\r
1976 is used.\r
1977 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1978 representation for a device node can be used, where applicable.\r
1979\r
1980**/\r
1981VOID\r
1982DevPathToTextRamDisk (\r
1983 IN OUT POOL_PRINT *Str,\r
1984 IN VOID *DevPath,\r
1985 IN BOOLEAN DisplayOnly,\r
1986 IN BOOLEAN AllowShortcuts\r
1987 )\r
1988{\r
1989 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;\r
1990\r
1991 RamDisk = DevPath;\r
1992\r
1993 if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid)) {\r
1994 UefiDevicePathLibCatPrint (\r
1995 Str,\r
1996 L"VirtualDisk(0x%lx,0x%lx,%d)",\r
a3bc432a
TS
1997 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
1998 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
1999 RamDisk->Instance\r
2000 );\r
2001 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid)) {\r
2002 UefiDevicePathLibCatPrint (\r
2003 Str,\r
2004 L"VirtualCD(0x%lx,0x%lx,%d)",\r
a3bc432a
TS
2005 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
2006 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
2007 RamDisk->Instance\r
2008 );\r
2009 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid)) {\r
2010 UefiDevicePathLibCatPrint (\r
2011 Str,\r
2012 L"PersistentVirtualDisk(0x%lx,0x%lx,%d)",\r
a3bc432a
TS
2013 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
2014 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
2015 RamDisk->Instance\r
2016 );\r
2017 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid)) {\r
2018 UefiDevicePathLibCatPrint (\r
2019 Str,\r
2020 L"PersistentVirtualCD(0x%lx,0x%lx,%d)",\r
a3bc432a
TS
2021 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
2022 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
2023 RamDisk->Instance\r
2024 );\r
2025 } else {\r
2026 UefiDevicePathLibCatPrint (\r
2027 Str,\r
2028 L"RamDisk(0x%lx,0x%lx,%d,%g)",\r
a3bc432a
TS
2029 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
2030 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
2031 RamDisk->Instance,\r
2032 &RamDisk->TypeGuid\r
2033 );\r
2034 }\r
2035}\r
2036\r
572f5d8a 2037/**\r
48557c65 2038 Converts a BIOS Boot Specification device path structure to its string representative.\r
572f5d8a 2039\r
48557c65 2040 @param Str The string representative of input device.\r
572f5d8a 2041 @param DevPath The input device path structure.\r
2042 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2043 of the display node is used, where applicable. If DisplayOnly\r
2044 is FALSE, then the longer text representation of the display node\r
2045 is used.\r
2046 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2047 representation for a device node can be used, where applicable.\r
2048\r
2049**/\r
95276127 2050VOID\r
2051DevPathToTextBBS (\r
2052 IN OUT POOL_PRINT *Str,\r
2053 IN VOID *DevPath,\r
2054 IN BOOLEAN DisplayOnly,\r
2055 IN BOOLEAN AllowShortcuts\r
2056 )\r
2057{\r
2058 BBS_BBS_DEVICE_PATH *Bbs;\r
2059 CHAR16 *Type;\r
2060\r
2061 Bbs = DevPath;\r
2062 switch (Bbs->DeviceType) {\r
2063 case BBS_TYPE_FLOPPY:\r
2064 Type = L"Floppy";\r
2065 break;\r
2066\r
2067 case BBS_TYPE_HARDDRIVE:\r
2068 Type = L"HD";\r
2069 break;\r
2070\r
2071 case BBS_TYPE_CDROM:\r
2072 Type = L"CDROM";\r
2073 break;\r
2074\r
2075 case BBS_TYPE_PCMCIA:\r
2076 Type = L"PCMCIA";\r
2077 break;\r
2078\r
2079 case BBS_TYPE_USB:\r
2080 Type = L"USB";\r
2081 break;\r
2082\r
2083 case BBS_TYPE_EMBEDDED_NETWORK:\r
2084 Type = L"Network";\r
2085 break;\r
2086\r
2087 default:\r
cf40f28a 2088 Type = NULL;\r
95276127 2089 break;\r
2090 }\r
2091\r
cf40f28a 2092 if (Type != NULL) {\r
4d0a30a4 2093 UefiDevicePathLibCatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r
cf40f28a 2094 } else {\r
4d0a30a4 2095 UefiDevicePathLibCatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String);\r
cf40f28a 2096 }\r
95276127 2097\r
572f5d8a 2098 if (DisplayOnly) {\r
4d0a30a4 2099 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 2100 return ;\r
2101 }\r
2102\r
4d0a30a4 2103 UefiDevicePathLibCatPrint (Str, L",0x%x)", Bbs->StatusFlag);\r
95276127 2104}\r
2105\r
572f5d8a 2106/**\r
48557c65 2107 Converts an End-of-Device-Path structure to its string representative.\r
572f5d8a 2108\r
48557c65 2109 @param Str The string representative of input device.\r
572f5d8a 2110 @param DevPath The input device path structure.\r
2111 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2112 of the display node is used, where applicable. If DisplayOnly\r
2113 is FALSE, then the longer text representation of the display node\r
2114 is used.\r
2115 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2116 representation for a device node can be used, where applicable.\r
2117\r
2118**/\r
95276127 2119VOID\r
2120DevPathToTextEndInstance (\r
2121 IN OUT POOL_PRINT *Str,\r
2122 IN VOID *DevPath,\r
2123 IN BOOLEAN DisplayOnly,\r
2124 IN BOOLEAN AllowShortcuts\r
2125 )\r
2126{\r
4d0a30a4 2127 UefiDevicePathLibCatPrint (Str, L",");\r
95276127 2128}\r
2129\r
5d6a5aee
RN
2130GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_GENERIC_TABLE mUefiDevicePathLibToTextTableGeneric[] = {\r
2131 {HARDWARE_DEVICE_PATH, L"HardwarePath" },\r
2132 {ACPI_DEVICE_PATH, L"AcpiPath" },\r
2133 {MESSAGING_DEVICE_PATH, L"Msg" },\r
2134 {MEDIA_DEVICE_PATH, L"MediaPath" },\r
2135 {BBS_DEVICE_PATH, L"BbsPath" },\r
2136 {0, NULL}\r
2137};\r
2138\r
572f5d8a 2139/**\r
48557c65 2140 Converts an unknown device path structure to its string representative.\r
572f5d8a 2141\r
48557c65 2142 @param Str The string representative of input device.\r
572f5d8a 2143 @param DevPath The input device path structure.\r
2144 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2145 of the display node is used, where applicable. If DisplayOnly\r
2146 is FALSE, then the longer text representation of the display node\r
2147 is used.\r
2148 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2149 representation for a device node can be used, where applicable.\r
2150\r
2151**/\r
95276127 2152VOID\r
5d6a5aee 2153DevPathToTextNodeGeneric (\r
95276127 2154 IN OUT POOL_PRINT *Str,\r
2155 IN VOID *DevPath,\r
2156 IN BOOLEAN DisplayOnly,\r
2157 IN BOOLEAN AllowShortcuts\r
2158 )\r
2159{\r
5d6a5aee
RN
2160 EFI_DEVICE_PATH_PROTOCOL *Node;\r
2161 UINTN Index;\r
2162\r
2163 Node = DevPath;\r
2164\r
2165 for (Index = 0; mUefiDevicePathLibToTextTableGeneric[Index].Text != NULL; Index++) {\r
2166 if (DevicePathType (Node) == mUefiDevicePathLibToTextTableGeneric[Index].Type) {\r
2167 break;\r
2168 }\r
2169 }\r
2170\r
2171 if (mUefiDevicePathLibToTextTableGeneric[Index].Text == NULL) {\r
2172 //\r
2173 // It's a node whose type cannot be recognized\r
2174 //\r
2175 UefiDevicePathLibCatPrint (Str, L"Path(%d,%d", DevicePathType (Node), DevicePathSubType (Node));\r
2176 } else {\r
2177 //\r
2178 // It's a node whose type can be recognized\r
2179 //\r
2180 UefiDevicePathLibCatPrint (Str, L"%s(%d", mUefiDevicePathLibToTextTableGeneric[Index].Text, DevicePathSubType (Node));\r
2181 }\r
2182\r
2183 Index = sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
2184 if (Index < DevicePathNodeLength (Node)) {\r
2185 UefiDevicePathLibCatPrint (Str, L",");\r
2186 for (; Index < DevicePathNodeLength (Node); Index++) {\r
2187 UefiDevicePathLibCatPrint (Str, L"%02x", ((UINT8 *) Node)[Index]);\r
2188 }\r
2189 }\r
2190\r
2191 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 2192}\r
2193\r
5d6a5aee 2194GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = {\r
4d0a30a4
RN
2195 {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci },\r
2196 {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard },\r
2197 {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap },\r
2198 {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor },\r
2199 {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController },\r
624f017e 2200 {HARDWARE_DEVICE_PATH, HW_BMC_DP, DevPathToTextBmc },\r
4d0a30a4
RN
2201 {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi },\r
2202 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx },\r
2203 {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr },\r
2204 {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi },\r
2205 {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi },\r
2206 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre },\r
2207 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx },\r
2208 {MESSAGING_DEVICE_PATH, MSG_SASEX_DP, DevPathToTextSasEx },\r
a06ec3e2 2209 {MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP, DevPathToTextNVMe },\r
52306166 2210 {MESSAGING_DEVICE_PATH, MSG_UFS_DP, DevPathToTextUfs },\r
ab8686b8 2211 {MESSAGING_DEVICE_PATH, MSG_SD_DP, DevPathToTextSd },\r
5c67fb2f 2212 {MESSAGING_DEVICE_PATH, MSG_EMMC_DP, DevPathToTextEmmc },\r
4d0a30a4
RN
2213 {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394 },\r
2214 {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb },\r
2215 {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID },\r
2216 {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit },\r
2217 {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass },\r
2218 {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata },\r
2219 {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O },\r
2220 {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr },\r
2221 {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4 },\r
2222 {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6 },\r
2223 {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand },\r
2224 {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart },\r
2225 {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor },\r
2226 {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI },\r
2227 {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan },\r
c808ac7b 2228 {MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextUri },\r
7795c8f9 2229 {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextBluetooth },\r
3bafd562 2230 {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextWiFi },\r
ff5623e9 2231 {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, DevPathToTextBluetoothLE },\r
4d0a30a4
RN
2232 {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive },\r
2233 {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM },\r
2234 {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor },\r
2235 {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol },\r
2236 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath },\r
2237 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv },\r
2238 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile },\r
2239 {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange },\r
6a46c1a2 2240 {MEDIA_DEVICE_PATH, MEDIA_RAM_DISK_DP, DevPathToTextRamDisk },\r
4d0a30a4
RN
2241 {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS },\r
2242 {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance },\r
95276127 2243 {0, 0, NULL}\r
2244};\r
2245\r
572f5d8a 2246/**\r
2247 Converts a device node to its string representation.\r
2248\r
2249 @param DeviceNode A Pointer to the device node to be converted.\r
2250 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2251 of the display node is used, where applicable. If DisplayOnly\r
2252 is FALSE, then the longer text representation of the display node\r
2253 is used.\r
2254 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2255 representation for a device node can be used, where applicable.\r
2256\r
2257 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
2258 is NULL or there was insufficient memory.\r
2259\r
2260**/\r
95276127 2261CHAR16 *\r
572f5d8a 2262EFIAPI\r
4d0a30a4 2263UefiDevicePathLibConvertDeviceNodeToText (\r
95276127 2264 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
2265 IN BOOLEAN DisplayOnly,\r
2266 IN BOOLEAN AllowShortcuts\r
2267 )\r
95276127 2268{\r
4d0a30a4
RN
2269 POOL_PRINT Str;\r
2270 UINTN Index;\r
2271 DEVICE_PATH_TO_TEXT ToText;\r
95276127 2272\r
2273 if (DeviceNode == NULL) {\r
2274 return NULL;\r
2275 }\r
2276\r
2277 ZeroMem (&Str, sizeof (Str));\r
2278\r
2279 //\r
2280 // Process the device path node\r
4d0a30a4 2281 // If not found, use a generic function\r
95276127 2282 //\r
5d6a5aee
RN
2283 ToText = DevPathToTextNodeGeneric;\r
2284 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index++) {\r
2285 if (DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type &&\r
2286 DevicePathSubType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].SubType\r
95276127 2287 ) {\r
5d6a5aee 2288 ToText = mUefiDevicePathLibToTextTable[Index].Function;\r
95276127 2289 break;\r
2290 }\r
2291 }\r
95276127 2292\r
2293 //\r
2294 // Print this node\r
2295 //\r
4d0a30a4 2296 ToText (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r
95276127 2297\r
9d4af8fc 2298 ASSERT (Str.Str != NULL);\r
95276127 2299 return Str.Str;\r
2300}\r
2301\r
572f5d8a 2302/**\r
2303 Converts a device path to its text representation.\r
95276127 2304\r
572f5d8a 2305 @param DevicePath A Pointer to the device to be converted.\r
2306 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
95276127 2307 of the display node is used, where applicable. If DisplayOnly\r
2308 is FALSE, then the longer text representation of the display node\r
2309 is used.\r
572f5d8a 2310 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
95276127 2311 representation for a device node can be used, where applicable.\r
2312\r
572f5d8a 2313 @return A pointer to the allocated text representation of the device path or\r
2314 NULL if DeviceNode is NULL or there was insufficient memory.\r
95276127 2315\r
572f5d8a 2316**/\r
2317CHAR16 *\r
2318EFIAPI\r
4d0a30a4 2319UefiDevicePathLibConvertDevicePathToText (\r
572f5d8a 2320 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
2321 IN BOOLEAN DisplayOnly,\r
2322 IN BOOLEAN AllowShortcuts\r
2323 )\r
95276127 2324{\r
4d0a30a4
RN
2325 POOL_PRINT Str;\r
2326 EFI_DEVICE_PATH_PROTOCOL *Node;\r
2327 EFI_DEVICE_PATH_PROTOCOL *AlignedNode;\r
2328 UINTN Index;\r
2329 DEVICE_PATH_TO_TEXT ToText;\r
95276127 2330\r
2331 if (DevicePath == NULL) {\r
2332 return NULL;\r
2333 }\r
2334\r
2335 ZeroMem (&Str, sizeof (Str));\r
2336\r
95276127 2337 //\r
2338 // Process each device path node\r
2339 //\r
4d0a30a4
RN
2340 Node = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;\r
2341 while (!IsDevicePathEnd (Node)) {\r
95276127 2342 //\r
2343 // Find the handler to dump this device path node\r
4d0a30a4 2344 // If not found, use a generic function\r
95276127 2345 //\r
5d6a5aee
RN
2346 ToText = DevPathToTextNodeGeneric;\r
2347 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index += 1) {\r
95276127 2348\r
5d6a5aee
RN
2349 if (DevicePathType (Node) == mUefiDevicePathLibToTextTable[Index].Type &&\r
2350 DevicePathSubType (Node) == mUefiDevicePathLibToTextTable[Index].SubType\r
95276127 2351 ) {\r
5d6a5aee 2352 ToText = mUefiDevicePathLibToTextTable[Index].Function;\r
95276127 2353 break;\r
2354 }\r
2355 }\r
2356 //\r
5755841f 2357 // Put a path separator in if needed\r
95276127 2358 //\r
4d0a30a4
RN
2359 if ((Str.Count != 0) && (ToText != DevPathToTextEndInstance)) {\r
2360 if (Str.Str[Str.Count] != L',') {\r
2361 UefiDevicePathLibCatPrint (&Str, L"/");\r
cf40f28a 2362 }\r
95276127 2363 }\r
1232b214 2364 \r
4d0a30a4 2365 AlignedNode = AllocateCopyPool (DevicePathNodeLength (Node), Node);\r
95276127 2366 //\r
2367 // Print this node of the device path\r
2368 //\r
4d0a30a4
RN
2369 ToText (&Str, AlignedNode, DisplayOnly, AllowShortcuts);\r
2370 FreePool (AlignedNode);\r
1232b214 2371 \r
95276127 2372 //\r
2373 // Next device path node\r
2374 //\r
4d0a30a4 2375 Node = NextDevicePathNode (Node);\r
95276127 2376 }\r
95276127 2377\r
9d4af8fc
RN
2378 if (Str.Str == NULL) {\r
2379 return AllocateZeroPool (sizeof (CHAR16));\r
2380 } else {\r
2381 return Str.Str;\r
2382 }\r
95276127 2383}\r