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