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