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