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