]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
BaseTools: remove unused MigrationUtilities.py
[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
9b9d0655
JW
1699/**\r
1700 Converts a DNS 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
1713DevPathToTextDns (\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 DNS_DEVICE_PATH *DnsDevPath;\r
1721 UINT32 DnsServerIpCount;\r
1722 UINT32 DnsServerIpIndex;\r
1723\r
1724 DnsDevPath = DevPath;\r
1725 DnsServerIpCount = (UINT32) (DevicePathNodeLength(DnsDevPath) - sizeof (EFI_DEVICE_PATH_PROTOCOL) - sizeof (DnsDevPath->IsIPv6)) / sizeof (EFI_IP_ADDRESS);\r
1726\r
1727 UefiDevicePathLibCatPrint (Str, L"Dns(");\r
1728 \r
1729 for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; DnsServerIpIndex++) {\r
1730 if (DnsDevPath->IsIPv6 == 0x00) {\r
1731 CatIPv4Address (Str, &(DnsDevPath->DnsServerIp[DnsServerIpIndex].v4));\r
1732 } else {\r
1733 CatIPv6Address (Str, &(DnsDevPath->DnsServerIp[DnsServerIpIndex].v6));\r
1734 }\r
1735\r
1736 if (DnsServerIpIndex < DnsServerIpCount - 1) {\r
1737 UefiDevicePathLibCatPrint (Str, L",");\r
1738 }\r
1739 }\r
1740\r
1741 UefiDevicePathLibCatPrint (Str, L")");\r
1742}\r
1743\r
c808ac7b
RN
1744/**\r
1745 Converts a URI device path structure to its string representative.\r
1746\r
1747 @param Str The string representative of input device.\r
1748 @param DevPath The input device path structure.\r
1749 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1750 of the display node is used, where applicable. If DisplayOnly\r
1751 is FALSE, then the longer text representation of the display node\r
1752 is used.\r
1753 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1754 representation for a device node can be used, where applicable.\r
1755\r
1756**/\r
1757VOID\r
1758DevPathToTextUri (\r
1759 IN OUT POOL_PRINT *Str,\r
1760 IN VOID *DevPath,\r
1761 IN BOOLEAN DisplayOnly,\r
1762 IN BOOLEAN AllowShortcuts\r
1763 )\r
1764{\r
1765 URI_DEVICE_PATH *Uri;\r
1766 UINTN UriLength;\r
1767 CHAR8 *UriStr;\r
1768\r
1769 //\r
1770 // Uri in the device path may not be null terminated.\r
1771 //\r
1772 Uri = DevPath;\r
1773 UriLength = DevicePathNodeLength (Uri) - sizeof (URI_DEVICE_PATH);\r
1774 UriStr = AllocatePool (UriLength + 1);\r
1775 ASSERT (UriStr != NULL);\r
1776\r
1777 CopyMem (UriStr, Uri->Uri, UriLength);\r
1778 UriStr[UriLength] = '\0';\r
1779 UefiDevicePathLibCatPrint (Str, L"Uri(%a)", UriStr);\r
1780 FreePool (UriStr);\r
1781}\r
1782\r
572f5d8a 1783/**\r
48557c65 1784 Converts a Hard drive device path structure to its string representative.\r
572f5d8a 1785\r
48557c65 1786 @param Str The string representative of input device.\r
572f5d8a 1787 @param DevPath The input device path structure.\r
1788 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1789 of the display node is used, where applicable. If DisplayOnly\r
1790 is FALSE, then the longer text representation of the display node\r
1791 is used.\r
1792 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1793 representation for a device node can be used, where applicable.\r
1794\r
1795**/\r
95276127 1796VOID\r
1797DevPathToTextHardDrive (\r
1798 IN OUT POOL_PRINT *Str,\r
1799 IN VOID *DevPath,\r
1800 IN BOOLEAN DisplayOnly,\r
1801 IN BOOLEAN AllowShortcuts\r
1802 )\r
1803{\r
1804 HARDDRIVE_DEVICE_PATH *Hd;\r
1805\r
1806 Hd = DevPath;\r
1807 switch (Hd->SignatureType) {\r
95276127 1808 case SIGNATURE_TYPE_MBR:\r
4d0a30a4 1809 UefiDevicePathLibCatPrint (\r
95276127 1810 Str,\r
cf40f28a 1811 L"HD(%d,%s,0x%08x,",\r
e9b3cd55 1812 Hd->PartitionNumber,\r
95276127 1813 L"MBR",\r
e9b3cd55 1814 *((UINT32 *) (&(Hd->Signature[0])))\r
95276127 1815 );\r
1816 break;\r
1817\r
1818 case SIGNATURE_TYPE_GUID:\r
4d0a30a4 1819 UefiDevicePathLibCatPrint (\r
95276127 1820 Str,\r
1821 L"HD(%d,%s,%g,",\r
e9b3cd55 1822 Hd->PartitionNumber,\r
cf40f28a 1823 L"GPT",\r
95276127 1824 (EFI_GUID *) &(Hd->Signature[0])\r
1825 );\r
1826 break;\r
1827\r
1828 default:\r
4d0a30a4 1829 UefiDevicePathLibCatPrint (\r
cf40f28a 1830 Str,\r
1831 L"HD(%d,%d,0,",\r
e9b3cd55
RN
1832 Hd->PartitionNumber,\r
1833 Hd->SignatureType\r
cf40f28a 1834 );\r
95276127 1835 break;\r
1836 }\r
1837\r
4d0a30a4 1838 UefiDevicePathLibCatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);\r
95276127 1839}\r
1840\r
572f5d8a 1841/**\r
48557c65 1842 Converts a CDROM device path structure to its string representative.\r
572f5d8a 1843\r
48557c65 1844 @param Str The string representative of input device.\r
572f5d8a 1845 @param DevPath The input device path structure.\r
1846 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1847 of the display node is used, where applicable. If DisplayOnly\r
1848 is FALSE, then the longer text representation of the display node\r
1849 is used.\r
1850 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1851 representation for a device node can be used, where applicable.\r
1852\r
1853**/\r
95276127 1854VOID\r
1855DevPathToTextCDROM (\r
1856 IN OUT POOL_PRINT *Str,\r
1857 IN VOID *DevPath,\r
1858 IN BOOLEAN DisplayOnly,\r
1859 IN BOOLEAN AllowShortcuts\r
1860 )\r
1861{\r
1862 CDROM_DEVICE_PATH *Cd;\r
1863\r
1864 Cd = DevPath;\r
572f5d8a 1865 if (DisplayOnly) {\r
4d0a30a4 1866 UefiDevicePathLibCatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);\r
95276127 1867 return ;\r
1868 }\r
1869\r
4d0a30a4 1870 UefiDevicePathLibCatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
95276127 1871}\r
1872\r
572f5d8a 1873/**\r
48557c65 1874 Converts a File device path structure to its string representative.\r
572f5d8a 1875\r
48557c65 1876 @param Str The string representative of input device.\r
572f5d8a 1877 @param DevPath The input device path structure.\r
1878 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1879 of the display node is used, where applicable. If DisplayOnly\r
1880 is FALSE, then the longer text representation of the display node\r
1881 is used.\r
1882 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1883 representation for a device node can be used, where applicable.\r
1884\r
1885**/\r
95276127 1886VOID\r
1887DevPathToTextFilePath (\r
1888 IN OUT POOL_PRINT *Str,\r
1889 IN VOID *DevPath,\r
1890 IN BOOLEAN DisplayOnly,\r
1891 IN BOOLEAN AllowShortcuts\r
1892 )\r
1893{\r
1894 FILEPATH_DEVICE_PATH *Fp;\r
1895\r
1896 Fp = DevPath;\r
4d0a30a4 1897 UefiDevicePathLibCatPrint (Str, L"%s", Fp->PathName);\r
95276127 1898}\r
1899\r
572f5d8a 1900/**\r
48557c65 1901 Converts a Media protocol device path structure to its string representative.\r
572f5d8a 1902\r
48557c65 1903 @param Str The string representative of input device.\r
572f5d8a 1904 @param DevPath The input device path structure.\r
1905 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1906 of the display node is used, where applicable. If DisplayOnly\r
1907 is FALSE, then the longer text representation of the display node\r
1908 is used.\r
1909 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1910 representation for a device node can be used, where applicable.\r
1911\r
1912**/\r
95276127 1913VOID\r
1914DevPathToTextMediaProtocol (\r
1915 IN OUT POOL_PRINT *Str,\r
1916 IN VOID *DevPath,\r
1917 IN BOOLEAN DisplayOnly,\r
1918 IN BOOLEAN AllowShortcuts\r
1919 )\r
1920{\r
1921 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;\r
1922\r
1923 MediaProt = DevPath;\r
4d0a30a4 1924 UefiDevicePathLibCatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
95276127 1925}\r
1926\r
572f5d8a 1927/**\r
48557c65 1928 Converts a Firmware Volume device path structure to its string representative.\r
572f5d8a 1929\r
48557c65 1930 @param Str The string representative of input device.\r
572f5d8a 1931 @param DevPath The input device path structure.\r
1932 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1933 of the display node is used, where applicable. If DisplayOnly\r
1934 is FALSE, then the longer text representation of the display node\r
1935 is used.\r
1936 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1937 representation for a device node can be used, where applicable.\r
1938\r
1939**/\r
cf40f28a 1940VOID\r
1941DevPathToTextFv (\r
1942 IN OUT POOL_PRINT *Str,\r
1943 IN VOID *DevPath,\r
1944 IN BOOLEAN DisplayOnly,\r
1945 IN BOOLEAN AllowShortcuts\r
1946 )\r
1947{\r
1948 MEDIA_FW_VOL_DEVICE_PATH *Fv;\r
1949\r
1950 Fv = DevPath;\r
4d0a30a4 1951 UefiDevicePathLibCatPrint (Str, L"Fv(%g)", &Fv->FvName);\r
cf40f28a 1952}\r
1953\r
572f5d8a 1954/**\r
48557c65 1955 Converts a Firmware Volume File device path structure to its string representative.\r
572f5d8a 1956\r
48557c65 1957 @param Str The string representative of input device.\r
572f5d8a 1958 @param DevPath The input device path structure.\r
1959 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1960 of the display node is used, where applicable. If DisplayOnly\r
1961 is FALSE, then the longer text representation of the display node\r
1962 is used.\r
1963 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1964 representation for a device node can be used, where applicable.\r
1965\r
1966**/\r
cf40f28a 1967VOID\r
1968DevPathToTextFvFile (\r
1969 IN OUT POOL_PRINT *Str,\r
1970 IN VOID *DevPath,\r
1971 IN BOOLEAN DisplayOnly,\r
1972 IN BOOLEAN AllowShortcuts\r
1973 )\r
1974{\r
1975 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;\r
1976\r
1977 FvFile = DevPath;\r
4d0a30a4 1978 UefiDevicePathLibCatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);\r
cf40f28a 1979}\r
1980\r
09e15613 1981/**\r
1982 Converts a Relative Offset device path structure to its string representative.\r
1983\r
1984 @param Str The string representative of input device.\r
1985 @param DevPath The input device path structure.\r
1986 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1987 of the display node is used, where applicable. If DisplayOnly\r
1988 is FALSE, then the longer text representation of the display node\r
1989 is used.\r
1990 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1991 representation for a device node can be used, where applicable.\r
1992\r
1993**/\r
1994VOID\r
1995DevPathRelativeOffsetRange (\r
1996 IN OUT POOL_PRINT *Str,\r
1997 IN VOID *DevPath,\r
1998 IN BOOLEAN DisplayOnly,\r
1999 IN BOOLEAN AllowShortcuts\r
2000 )\r
2001{\r
2002 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
2003\r
2004 Offset = DevPath;\r
4d0a30a4 2005 UefiDevicePathLibCatPrint (\r
09e15613 2006 Str,\r
7748eb28 2007 L"Offset(0x%lx,0x%lx)",\r
09e15613 2008 Offset->StartingOffset,\r
2009 Offset->EndingOffset\r
2010 );\r
2011}\r
2012\r
6a46c1a2
FT
2013/**\r
2014 Converts a Ram Disk device path structure to its string representative.\r
2015\r
2016 @param Str The string representative of input device.\r
2017 @param DevPath The input device path structure.\r
2018 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2019 of the display node is used, where applicable. If DisplayOnly\r
2020 is FALSE, then the longer text representation of the display node\r
2021 is used.\r
2022 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2023 representation for a device node can be used, where applicable.\r
2024\r
2025**/\r
2026VOID\r
2027DevPathToTextRamDisk (\r
2028 IN OUT POOL_PRINT *Str,\r
2029 IN VOID *DevPath,\r
2030 IN BOOLEAN DisplayOnly,\r
2031 IN BOOLEAN AllowShortcuts\r
2032 )\r
2033{\r
2034 MEDIA_RAM_DISK_DEVICE_PATH *RamDisk;\r
2035\r
2036 RamDisk = DevPath;\r
2037\r
2038 if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid)) {\r
2039 UefiDevicePathLibCatPrint (\r
2040 Str,\r
2041 L"VirtualDisk(0x%lx,0x%lx,%d)",\r
a3bc432a
TS
2042 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
2043 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
2044 RamDisk->Instance\r
2045 );\r
2046 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid)) {\r
2047 UefiDevicePathLibCatPrint (\r
2048 Str,\r
2049 L"VirtualCD(0x%lx,0x%lx,%d)",\r
a3bc432a
TS
2050 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
2051 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
2052 RamDisk->Instance\r
2053 );\r
2054 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid)) {\r
2055 UefiDevicePathLibCatPrint (\r
2056 Str,\r
2057 L"PersistentVirtualDisk(0x%lx,0x%lx,%d)",\r
a3bc432a
TS
2058 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
2059 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
2060 RamDisk->Instance\r
2061 );\r
2062 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid)) {\r
2063 UefiDevicePathLibCatPrint (\r
2064 Str,\r
2065 L"PersistentVirtualCD(0x%lx,0x%lx,%d)",\r
a3bc432a
TS
2066 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
2067 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
2068 RamDisk->Instance\r
2069 );\r
2070 } else {\r
2071 UefiDevicePathLibCatPrint (\r
2072 Str,\r
2073 L"RamDisk(0x%lx,0x%lx,%d,%g)",\r
a3bc432a
TS
2074 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
2075 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
2076 RamDisk->Instance,\r
2077 &RamDisk->TypeGuid\r
2078 );\r
2079 }\r
2080}\r
2081\r
572f5d8a 2082/**\r
48557c65 2083 Converts a BIOS Boot Specification device path structure to its string representative.\r
572f5d8a 2084\r
48557c65 2085 @param Str The string representative of input device.\r
572f5d8a 2086 @param DevPath The input device path structure.\r
2087 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2088 of the display node is used, where applicable. If DisplayOnly\r
2089 is FALSE, then the longer text representation of the display node\r
2090 is used.\r
2091 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2092 representation for a device node can be used, where applicable.\r
2093\r
2094**/\r
95276127 2095VOID\r
2096DevPathToTextBBS (\r
2097 IN OUT POOL_PRINT *Str,\r
2098 IN VOID *DevPath,\r
2099 IN BOOLEAN DisplayOnly,\r
2100 IN BOOLEAN AllowShortcuts\r
2101 )\r
2102{\r
2103 BBS_BBS_DEVICE_PATH *Bbs;\r
2104 CHAR16 *Type;\r
2105\r
2106 Bbs = DevPath;\r
2107 switch (Bbs->DeviceType) {\r
2108 case BBS_TYPE_FLOPPY:\r
2109 Type = L"Floppy";\r
2110 break;\r
2111\r
2112 case BBS_TYPE_HARDDRIVE:\r
2113 Type = L"HD";\r
2114 break;\r
2115\r
2116 case BBS_TYPE_CDROM:\r
2117 Type = L"CDROM";\r
2118 break;\r
2119\r
2120 case BBS_TYPE_PCMCIA:\r
2121 Type = L"PCMCIA";\r
2122 break;\r
2123\r
2124 case BBS_TYPE_USB:\r
2125 Type = L"USB";\r
2126 break;\r
2127\r
2128 case BBS_TYPE_EMBEDDED_NETWORK:\r
2129 Type = L"Network";\r
2130 break;\r
2131\r
2132 default:\r
cf40f28a 2133 Type = NULL;\r
95276127 2134 break;\r
2135 }\r
2136\r
cf40f28a 2137 if (Type != NULL) {\r
4d0a30a4 2138 UefiDevicePathLibCatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r
cf40f28a 2139 } else {\r
4d0a30a4 2140 UefiDevicePathLibCatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String);\r
cf40f28a 2141 }\r
95276127 2142\r
572f5d8a 2143 if (DisplayOnly) {\r
4d0a30a4 2144 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 2145 return ;\r
2146 }\r
2147\r
4d0a30a4 2148 UefiDevicePathLibCatPrint (Str, L",0x%x)", Bbs->StatusFlag);\r
95276127 2149}\r
2150\r
572f5d8a 2151/**\r
48557c65 2152 Converts an End-of-Device-Path structure to its string representative.\r
572f5d8a 2153\r
48557c65 2154 @param Str The string representative of input device.\r
572f5d8a 2155 @param DevPath The input device path structure.\r
2156 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2157 of the display node is used, where applicable. If DisplayOnly\r
2158 is FALSE, then the longer text representation of the display node\r
2159 is used.\r
2160 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2161 representation for a device node can be used, where applicable.\r
2162\r
2163**/\r
95276127 2164VOID\r
2165DevPathToTextEndInstance (\r
2166 IN OUT POOL_PRINT *Str,\r
2167 IN VOID *DevPath,\r
2168 IN BOOLEAN DisplayOnly,\r
2169 IN BOOLEAN AllowShortcuts\r
2170 )\r
2171{\r
4d0a30a4 2172 UefiDevicePathLibCatPrint (Str, L",");\r
95276127 2173}\r
2174\r
5d6a5aee
RN
2175GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_GENERIC_TABLE mUefiDevicePathLibToTextTableGeneric[] = {\r
2176 {HARDWARE_DEVICE_PATH, L"HardwarePath" },\r
2177 {ACPI_DEVICE_PATH, L"AcpiPath" },\r
2178 {MESSAGING_DEVICE_PATH, L"Msg" },\r
2179 {MEDIA_DEVICE_PATH, L"MediaPath" },\r
2180 {BBS_DEVICE_PATH, L"BbsPath" },\r
2181 {0, NULL}\r
2182};\r
2183\r
572f5d8a 2184/**\r
48557c65 2185 Converts an unknown device path structure to its string representative.\r
572f5d8a 2186\r
48557c65 2187 @param Str The string representative of input device.\r
572f5d8a 2188 @param DevPath The input device path structure.\r
2189 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2190 of the display node is used, where applicable. If DisplayOnly\r
2191 is FALSE, then the longer text representation of the display node\r
2192 is used.\r
2193 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2194 representation for a device node can be used, where applicable.\r
2195\r
2196**/\r
95276127 2197VOID\r
5d6a5aee 2198DevPathToTextNodeGeneric (\r
95276127 2199 IN OUT POOL_PRINT *Str,\r
2200 IN VOID *DevPath,\r
2201 IN BOOLEAN DisplayOnly,\r
2202 IN BOOLEAN AllowShortcuts\r
2203 )\r
2204{\r
5d6a5aee
RN
2205 EFI_DEVICE_PATH_PROTOCOL *Node;\r
2206 UINTN Index;\r
2207\r
2208 Node = DevPath;\r
2209\r
2210 for (Index = 0; mUefiDevicePathLibToTextTableGeneric[Index].Text != NULL; Index++) {\r
2211 if (DevicePathType (Node) == mUefiDevicePathLibToTextTableGeneric[Index].Type) {\r
2212 break;\r
2213 }\r
2214 }\r
2215\r
2216 if (mUefiDevicePathLibToTextTableGeneric[Index].Text == NULL) {\r
2217 //\r
2218 // It's a node whose type cannot be recognized\r
2219 //\r
2220 UefiDevicePathLibCatPrint (Str, L"Path(%d,%d", DevicePathType (Node), DevicePathSubType (Node));\r
2221 } else {\r
2222 //\r
2223 // It's a node whose type can be recognized\r
2224 //\r
2225 UefiDevicePathLibCatPrint (Str, L"%s(%d", mUefiDevicePathLibToTextTableGeneric[Index].Text, DevicePathSubType (Node));\r
2226 }\r
2227\r
2228 Index = sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
2229 if (Index < DevicePathNodeLength (Node)) {\r
2230 UefiDevicePathLibCatPrint (Str, L",");\r
2231 for (; Index < DevicePathNodeLength (Node); Index++) {\r
2232 UefiDevicePathLibCatPrint (Str, L"%02x", ((UINT8 *) Node)[Index]);\r
2233 }\r
2234 }\r
2235\r
2236 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 2237}\r
2238\r
5d6a5aee 2239GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = {\r
4d0a30a4
RN
2240 {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci },\r
2241 {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard },\r
2242 {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap },\r
2243 {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor },\r
2244 {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController },\r
624f017e 2245 {HARDWARE_DEVICE_PATH, HW_BMC_DP, DevPathToTextBmc },\r
4d0a30a4
RN
2246 {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi },\r
2247 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx },\r
2248 {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr },\r
2249 {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi },\r
2250 {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi },\r
2251 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre },\r
2252 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx },\r
2253 {MESSAGING_DEVICE_PATH, MSG_SASEX_DP, DevPathToTextSasEx },\r
a06ec3e2 2254 {MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP, DevPathToTextNVMe },\r
52306166 2255 {MESSAGING_DEVICE_PATH, MSG_UFS_DP, DevPathToTextUfs },\r
ab8686b8 2256 {MESSAGING_DEVICE_PATH, MSG_SD_DP, DevPathToTextSd },\r
5c67fb2f 2257 {MESSAGING_DEVICE_PATH, MSG_EMMC_DP, DevPathToTextEmmc },\r
4d0a30a4
RN
2258 {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394 },\r
2259 {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb },\r
2260 {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID },\r
2261 {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit },\r
2262 {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass },\r
2263 {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata },\r
2264 {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O },\r
2265 {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr },\r
2266 {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4 },\r
2267 {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6 },\r
2268 {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand },\r
2269 {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart },\r
2270 {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor },\r
2271 {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI },\r
2272 {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan },\r
9b9d0655 2273 {MESSAGING_DEVICE_PATH, MSG_DNS_DP, DevPathToTextDns },\r
c808ac7b 2274 {MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextUri },\r
7795c8f9 2275 {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextBluetooth },\r
3bafd562 2276 {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextWiFi },\r
ff5623e9 2277 {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, DevPathToTextBluetoothLE },\r
4d0a30a4
RN
2278 {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive },\r
2279 {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM },\r
2280 {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor },\r
2281 {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol },\r
2282 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath },\r
2283 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv },\r
2284 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile },\r
2285 {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange },\r
6a46c1a2 2286 {MEDIA_DEVICE_PATH, MEDIA_RAM_DISK_DP, DevPathToTextRamDisk },\r
4d0a30a4
RN
2287 {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS },\r
2288 {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance },\r
95276127 2289 {0, 0, NULL}\r
2290};\r
2291\r
572f5d8a 2292/**\r
2293 Converts a device node to its string representation.\r
2294\r
2295 @param DeviceNode A Pointer to the device node to be converted.\r
2296 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2297 of the display node is used, where applicable. If DisplayOnly\r
2298 is FALSE, then the longer text representation of the display node\r
2299 is used.\r
2300 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2301 representation for a device node can be used, where applicable.\r
2302\r
2303 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
2304 is NULL or there was insufficient memory.\r
2305\r
2306**/\r
95276127 2307CHAR16 *\r
572f5d8a 2308EFIAPI\r
4d0a30a4 2309UefiDevicePathLibConvertDeviceNodeToText (\r
95276127 2310 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
2311 IN BOOLEAN DisplayOnly,\r
2312 IN BOOLEAN AllowShortcuts\r
2313 )\r
95276127 2314{\r
4d0a30a4
RN
2315 POOL_PRINT Str;\r
2316 UINTN Index;\r
2317 DEVICE_PATH_TO_TEXT ToText;\r
95276127 2318\r
2319 if (DeviceNode == NULL) {\r
2320 return NULL;\r
2321 }\r
2322\r
2323 ZeroMem (&Str, sizeof (Str));\r
2324\r
2325 //\r
2326 // Process the device path node\r
4d0a30a4 2327 // If not found, use a generic function\r
95276127 2328 //\r
5d6a5aee
RN
2329 ToText = DevPathToTextNodeGeneric;\r
2330 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index++) {\r
2331 if (DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type &&\r
2332 DevicePathSubType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].SubType\r
95276127 2333 ) {\r
5d6a5aee 2334 ToText = mUefiDevicePathLibToTextTable[Index].Function;\r
95276127 2335 break;\r
2336 }\r
2337 }\r
95276127 2338\r
2339 //\r
2340 // Print this node\r
2341 //\r
4d0a30a4 2342 ToText (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r
95276127 2343\r
9d4af8fc 2344 ASSERT (Str.Str != NULL);\r
95276127 2345 return Str.Str;\r
2346}\r
2347\r
572f5d8a 2348/**\r
2349 Converts a device path to its text representation.\r
95276127 2350\r
572f5d8a 2351 @param DevicePath A Pointer to the device to be converted.\r
2352 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
95276127 2353 of the display node is used, where applicable. If DisplayOnly\r
2354 is FALSE, then the longer text representation of the display node\r
2355 is used.\r
572f5d8a 2356 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
95276127 2357 representation for a device node can be used, where applicable.\r
2358\r
572f5d8a 2359 @return A pointer to the allocated text representation of the device path or\r
2360 NULL if DeviceNode is NULL or there was insufficient memory.\r
95276127 2361\r
572f5d8a 2362**/\r
2363CHAR16 *\r
2364EFIAPI\r
4d0a30a4 2365UefiDevicePathLibConvertDevicePathToText (\r
572f5d8a 2366 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
2367 IN BOOLEAN DisplayOnly,\r
2368 IN BOOLEAN AllowShortcuts\r
2369 )\r
95276127 2370{\r
4d0a30a4
RN
2371 POOL_PRINT Str;\r
2372 EFI_DEVICE_PATH_PROTOCOL *Node;\r
2373 EFI_DEVICE_PATH_PROTOCOL *AlignedNode;\r
2374 UINTN Index;\r
2375 DEVICE_PATH_TO_TEXT ToText;\r
95276127 2376\r
2377 if (DevicePath == NULL) {\r
2378 return NULL;\r
2379 }\r
2380\r
2381 ZeroMem (&Str, sizeof (Str));\r
2382\r
95276127 2383 //\r
2384 // Process each device path node\r
2385 //\r
4d0a30a4
RN
2386 Node = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;\r
2387 while (!IsDevicePathEnd (Node)) {\r
95276127 2388 //\r
2389 // Find the handler to dump this device path node\r
4d0a30a4 2390 // If not found, use a generic function\r
95276127 2391 //\r
5d6a5aee
RN
2392 ToText = DevPathToTextNodeGeneric;\r
2393 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index += 1) {\r
95276127 2394\r
5d6a5aee
RN
2395 if (DevicePathType (Node) == mUefiDevicePathLibToTextTable[Index].Type &&\r
2396 DevicePathSubType (Node) == mUefiDevicePathLibToTextTable[Index].SubType\r
95276127 2397 ) {\r
5d6a5aee 2398 ToText = mUefiDevicePathLibToTextTable[Index].Function;\r
95276127 2399 break;\r
2400 }\r
2401 }\r
2402 //\r
5755841f 2403 // Put a path separator in if needed\r
95276127 2404 //\r
4d0a30a4
RN
2405 if ((Str.Count != 0) && (ToText != DevPathToTextEndInstance)) {\r
2406 if (Str.Str[Str.Count] != L',') {\r
2407 UefiDevicePathLibCatPrint (&Str, L"/");\r
cf40f28a 2408 }\r
95276127 2409 }\r
1232b214 2410 \r
4d0a30a4 2411 AlignedNode = AllocateCopyPool (DevicePathNodeLength (Node), Node);\r
95276127 2412 //\r
2413 // Print this node of the device path\r
2414 //\r
4d0a30a4
RN
2415 ToText (&Str, AlignedNode, DisplayOnly, AllowShortcuts);\r
2416 FreePool (AlignedNode);\r
1232b214 2417 \r
95276127 2418 //\r
2419 // Next device path node\r
2420 //\r
4d0a30a4 2421 Node = NextDevicePathNode (Node);\r
95276127 2422 }\r
95276127 2423\r
9d4af8fc
RN
2424 if (Str.Str == NULL) {\r
2425 return AllocateZeroPool (sizeof (CHAR16));\r
2426 } else {\r
2427 return Str.Str;\r
2428 }\r
95276127 2429}\r