]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
MdeModulePkg: Terminate two unterminated VA_COPYs in CheckRemainingSpaceForConsistenc...
[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
5c67fb2f
FT
825/**\r
826 Converts a EMMC (Embedded MMC) device path structure to its string representative.\r
827\r
828 @param Str The string representative of input device.\r
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
838VOID\r
839DevPathToTextEmmc (\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
846 EMMC_DEVICE_PATH *Emmc;\r
847\r
848 Emmc = DevPath;\r
849 UefiDevicePathLibCatPrint (\r
850 Str,\r
851 L"Emmc(0x%x)",\r
852 Emmc->SlotNumber\r
853 );\r
854}\r
855\r
572f5d8a 856/**\r
48557c65 857 Converts a 1394 device path structure to its string representative.\r
572f5d8a 858\r
48557c65 859 @param Str The string representative of input device.\r
572f5d8a 860 @param DevPath The input device path structure.\r
861 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
862 of the display node is used, where applicable. If DisplayOnly\r
863 is FALSE, then the longer text representation of the display node\r
864 is used.\r
865 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
866 representation for a device node can be used, where applicable.\r
867\r
868**/\r
95276127 869VOID\r
870DevPathToText1394 (\r
871 IN OUT POOL_PRINT *Str,\r
872 IN VOID *DevPath,\r
873 IN BOOLEAN DisplayOnly,\r
874 IN BOOLEAN AllowShortcuts\r
875 )\r
876{\r
572f5d8a 877 F1394_DEVICE_PATH *F1394DevPath;\r
95276127 878\r
572f5d8a 879 F1394DevPath = DevPath;\r
cf40f28a 880 //\r
881 // Guid has format of IEEE-EUI64\r
882 //\r
4d0a30a4 883 UefiDevicePathLibCatPrint (Str, L"I1394(%016lx)", F1394DevPath->Guid);\r
95276127 884}\r
885\r
572f5d8a 886/**\r
48557c65 887 Converts a USB device path structure to its string representative.\r
572f5d8a 888\r
48557c65 889 @param Str The string representative of input device.\r
572f5d8a 890 @param DevPath The input device path structure.\r
891 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
892 of the display node is used, where applicable. If DisplayOnly\r
893 is FALSE, then the longer text representation of the display node\r
894 is used.\r
895 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
896 representation for a device node can be used, where applicable.\r
897\r
898**/\r
95276127 899VOID\r
900DevPathToTextUsb (\r
901 IN OUT POOL_PRINT *Str,\r
902 IN VOID *DevPath,\r
903 IN BOOLEAN DisplayOnly,\r
904 IN BOOLEAN AllowShortcuts\r
905 )\r
906{\r
907 USB_DEVICE_PATH *Usb;\r
908\r
909 Usb = DevPath;\r
4d0a30a4 910 UefiDevicePathLibCatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);\r
95276127 911}\r
912\r
572f5d8a 913/**\r
48557c65 914 Converts a USB WWID device path structure to its string representative.\r
572f5d8a 915\r
48557c65 916 @param Str The string representative of input device.\r
572f5d8a 917 @param DevPath The input device path structure.\r
918 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
919 of the display node is used, where applicable. If DisplayOnly\r
920 is FALSE, then the longer text representation of the display node\r
921 is used.\r
922 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
923 representation for a device node can be used, where applicable.\r
924\r
925**/\r
95276127 926VOID\r
927DevPathToTextUsbWWID (\r
928 IN OUT POOL_PRINT *Str,\r
929 IN VOID *DevPath,\r
930 IN BOOLEAN DisplayOnly,\r
931 IN BOOLEAN AllowShortcuts\r
932 )\r
933{\r
934 USB_WWID_DEVICE_PATH *UsbWWId;\r
cf40f28a 935 CHAR16 *SerialNumberStr;\r
936 CHAR16 *NewStr;\r
937 UINT16 Length;\r
95276127 938\r
939 UsbWWId = DevPath;\r
cf40f28a 940\r
941 SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof (USB_WWID_DEVICE_PATH));\r
942 Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));\r
943 if (SerialNumberStr [Length - 1] != 0) {\r
944 //\r
945 // In case no NULL terminator in SerialNumber, create a new one with NULL terminator\r
946 //\r
947 NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);\r
3069bc19 948 ASSERT (NewStr != NULL);\r
cf40f28a 949 NewStr [Length] = 0;\r
950 SerialNumberStr = NewStr;\r
951 }\r
952\r
4d0a30a4 953 UefiDevicePathLibCatPrint (\r
95276127 954 Str,\r
cf40f28a 955 L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",\r
e9b3cd55
RN
956 UsbWWId->VendorId,\r
957 UsbWWId->ProductId,\r
958 UsbWWId->InterfaceNumber,\r
cf40f28a 959 SerialNumberStr\r
95276127 960 );\r
961}\r
962\r
572f5d8a 963/**\r
48557c65 964 Converts a Logic Unit device path structure to its string representative.\r
572f5d8a 965\r
48557c65 966 @param Str The string representative of input device.\r
572f5d8a 967 @param DevPath The input device path structure.\r
968 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
969 of the display node is used, where applicable. If DisplayOnly\r
970 is FALSE, then the longer text representation of the display node\r
971 is used.\r
972 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
973 representation for a device node can be used, where applicable.\r
974\r
975**/\r
95276127 976VOID\r
977DevPathToTextLogicalUnit (\r
978 IN OUT POOL_PRINT *Str,\r
979 IN VOID *DevPath,\r
980 IN BOOLEAN DisplayOnly,\r
981 IN BOOLEAN AllowShortcuts\r
982 )\r
983{\r
984 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
985\r
986 LogicalUnit = DevPath;\r
4d0a30a4 987 UefiDevicePathLibCatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun);\r
95276127 988}\r
989\r
572f5d8a 990/**\r
48557c65 991 Converts a USB class device path structure to its string representative.\r
572f5d8a 992\r
48557c65 993 @param Str The string representative of input device.\r
572f5d8a 994 @param DevPath The input device path structure.\r
995 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
996 of the display node is used, where applicable. If DisplayOnly\r
997 is FALSE, then the longer text representation of the display node\r
998 is used.\r
999 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1000 representation for a device node can be used, where applicable.\r
1001\r
1002**/\r
95276127 1003VOID\r
1004DevPathToTextUsbClass (\r
1005 IN OUT POOL_PRINT *Str,\r
1006 IN VOID *DevPath,\r
1007 IN BOOLEAN DisplayOnly,\r
1008 IN BOOLEAN AllowShortcuts\r
1009 )\r
1010{\r
1011 USB_CLASS_DEVICE_PATH *UsbClass;\r
cf40f28a 1012 BOOLEAN IsKnownSubClass;\r
1013\r
95276127 1014\r
1015 UsbClass = DevPath;\r
1016\r
cf40f28a 1017 IsKnownSubClass = TRUE;\r
1018 switch (UsbClass->DeviceClass) {\r
1019 case USB_CLASS_AUDIO:\r
4d0a30a4 1020 UefiDevicePathLibCatPrint (Str, L"UsbAudio");\r
cf40f28a 1021 break;\r
95276127 1022\r
cf40f28a 1023 case USB_CLASS_CDCCONTROL:\r
4d0a30a4 1024 UefiDevicePathLibCatPrint (Str, L"UsbCDCControl");\r
cf40f28a 1025 break;\r
95276127 1026\r
cf40f28a 1027 case USB_CLASS_HID:\r
4d0a30a4 1028 UefiDevicePathLibCatPrint (Str, L"UsbHID");\r
cf40f28a 1029 break;\r
95276127 1030\r
cf40f28a 1031 case USB_CLASS_IMAGE:\r
4d0a30a4 1032 UefiDevicePathLibCatPrint (Str, L"UsbImage");\r
cf40f28a 1033 break;\r
95276127 1034\r
cf40f28a 1035 case USB_CLASS_PRINTER:\r
4d0a30a4 1036 UefiDevicePathLibCatPrint (Str, L"UsbPrinter");\r
cf40f28a 1037 break;\r
95276127 1038\r
cf40f28a 1039 case USB_CLASS_MASS_STORAGE:\r
4d0a30a4 1040 UefiDevicePathLibCatPrint (Str, L"UsbMassStorage");\r
cf40f28a 1041 break;\r
95276127 1042\r
cf40f28a 1043 case USB_CLASS_HUB:\r
4d0a30a4 1044 UefiDevicePathLibCatPrint (Str, L"UsbHub");\r
cf40f28a 1045 break;\r
95276127 1046\r
cf40f28a 1047 case USB_CLASS_CDCDATA:\r
4d0a30a4 1048 UefiDevicePathLibCatPrint (Str, L"UsbCDCData");\r
cf40f28a 1049 break;\r
95276127 1050\r
cf40f28a 1051 case USB_CLASS_SMART_CARD:\r
4d0a30a4 1052 UefiDevicePathLibCatPrint (Str, L"UsbSmartCard");\r
cf40f28a 1053 break;\r
95276127 1054\r
cf40f28a 1055 case USB_CLASS_VIDEO:\r
4d0a30a4 1056 UefiDevicePathLibCatPrint (Str, L"UsbVideo");\r
cf40f28a 1057 break;\r
1058\r
1059 case USB_CLASS_DIAGNOSTIC:\r
4d0a30a4 1060 UefiDevicePathLibCatPrint (Str, L"UsbDiagnostic");\r
cf40f28a 1061 break;\r
1062\r
1063 case USB_CLASS_WIRELESS:\r
4d0a30a4 1064 UefiDevicePathLibCatPrint (Str, L"UsbWireless");\r
cf40f28a 1065 break;\r
1066\r
1067 default:\r
1068 IsKnownSubClass = FALSE;\r
1069 break;\r
1070 }\r
1071\r
1072 if (IsKnownSubClass) {\r
4d0a30a4 1073 UefiDevicePathLibCatPrint (\r
cf40f28a 1074 Str,\r
1075 L"(0x%x,0x%x,0x%x,0x%x)",\r
e9b3cd55
RN
1076 UsbClass->VendorId,\r
1077 UsbClass->ProductId,\r
1078 UsbClass->DeviceSubClass,\r
1079 UsbClass->DeviceProtocol\r
cf40f28a 1080 );\r
1081 return;\r
1082 }\r
1083\r
1084 if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {\r
1085 if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {\r
4d0a30a4 1086 UefiDevicePathLibCatPrint (\r
95276127 1087 Str,\r
cf40f28a 1088 L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",\r
e9b3cd55
RN
1089 UsbClass->VendorId,\r
1090 UsbClass->ProductId,\r
1091 UsbClass->DeviceProtocol\r
95276127 1092 );\r
cf40f28a 1093 return;\r
1094 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {\r
4d0a30a4 1095 UefiDevicePathLibCatPrint (\r
95276127 1096 Str,\r
cf40f28a 1097 L"UsbIrdaBridge(0x%x,0x%x,0x%x)",\r
e9b3cd55
RN
1098 UsbClass->VendorId,\r
1099 UsbClass->ProductId,\r
1100 UsbClass->DeviceProtocol\r
95276127 1101 );\r
cf40f28a 1102 return;\r
1103 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {\r
4d0a30a4 1104 UefiDevicePathLibCatPrint (\r
95276127 1105 Str,\r
cf40f28a 1106 L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",\r
e9b3cd55
RN
1107 UsbClass->VendorId,\r
1108 UsbClass->ProductId,\r
1109 UsbClass->DeviceProtocol\r
95276127 1110 );\r
cf40f28a 1111 return;\r
95276127 1112 }\r
95276127 1113 }\r
1114\r
4d0a30a4 1115 UefiDevicePathLibCatPrint (\r
95276127 1116 Str,\r
cf40f28a 1117 L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",\r
e9b3cd55
RN
1118 UsbClass->VendorId,\r
1119 UsbClass->ProductId,\r
1120 UsbClass->DeviceClass,\r
1121 UsbClass->DeviceSubClass,\r
1122 UsbClass->DeviceProtocol\r
95276127 1123 );\r
1124}\r
1125\r
572f5d8a 1126/**\r
48557c65 1127 Converts a SATA device path structure to its string representative.\r
572f5d8a 1128\r
48557c65 1129 @param Str The string representative of input device.\r
572f5d8a 1130 @param DevPath The input device path structure.\r
1131 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1132 of the display node is used, where applicable. If DisplayOnly\r
1133 is FALSE, then the longer text representation of the display node\r
1134 is used.\r
1135 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1136 representation for a device node can be used, where applicable.\r
1137\r
1138**/\r
cf40f28a 1139VOID\r
1140DevPathToTextSata (\r
1141 IN OUT POOL_PRINT *Str,\r
1142 IN VOID *DevPath,\r
1143 IN BOOLEAN DisplayOnly,\r
1144 IN BOOLEAN AllowShortcuts\r
1145 )\r
1146{\r
1147 SATA_DEVICE_PATH *Sata;\r
1148\r
1149 Sata = DevPath;\r
9da38884
RN
1150 UefiDevicePathLibCatPrint (\r
1151 Str,\r
1152 L"Sata(0x%x,0x%x,0x%x)",\r
1153 Sata->HBAPortNumber,\r
1154 Sata->PortMultiplierPortNumber,\r
1155 Sata->Lun\r
1156 );\r
cf40f28a 1157}\r
1158\r
572f5d8a 1159/**\r
48557c65 1160 Converts a I20 device path structure to its string representative.\r
572f5d8a 1161\r
48557c65 1162 @param Str The string representative of input device.\r
572f5d8a 1163 @param DevPath The input device path structure.\r
1164 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1165 of the display node is used, where applicable. If DisplayOnly\r
1166 is FALSE, then the longer text representation of the display node\r
1167 is used.\r
1168 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1169 representation for a device node can be used, where applicable.\r
1170\r
1171**/\r
95276127 1172VOID\r
1173DevPathToTextI2O (\r
1174 IN OUT POOL_PRINT *Str,\r
1175 IN VOID *DevPath,\r
1176 IN BOOLEAN DisplayOnly,\r
1177 IN BOOLEAN AllowShortcuts\r
1178 )\r
1179{\r
572f5d8a 1180 I2O_DEVICE_PATH *I2ODevPath;\r
95276127 1181\r
572f5d8a 1182 I2ODevPath = DevPath;\r
4d0a30a4 1183 UefiDevicePathLibCatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid);\r
95276127 1184}\r
1185\r
572f5d8a 1186/**\r
48557c65 1187 Converts a MAC address device path structure to its string representative.\r
572f5d8a 1188\r
48557c65 1189 @param Str The string representative of input device.\r
572f5d8a 1190 @param DevPath The input device path structure.\r
1191 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1192 of the display node is used, where applicable. If DisplayOnly\r
1193 is FALSE, then the longer text representation of the display node\r
1194 is used.\r
1195 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1196 representation for a device node can be used, where applicable.\r
1197\r
1198**/\r
95276127 1199VOID\r
1200DevPathToTextMacAddr (\r
1201 IN OUT POOL_PRINT *Str,\r
1202 IN VOID *DevPath,\r
1203 IN BOOLEAN DisplayOnly,\r
1204 IN BOOLEAN AllowShortcuts\r
1205 )\r
1206{\r
572f5d8a 1207 MAC_ADDR_DEVICE_PATH *MacDevPath;\r
95276127 1208 UINTN HwAddressSize;\r
1209 UINTN Index;\r
1210\r
572f5d8a 1211 MacDevPath = DevPath;\r
95276127 1212\r
1213 HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
572f5d8a 1214 if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {\r
95276127 1215 HwAddressSize = 6;\r
1216 }\r
1217\r
4d0a30a4 1218 UefiDevicePathLibCatPrint (Str, L"MAC(");\r
95276127 1219\r
1220 for (Index = 0; Index < HwAddressSize; Index++) {\r
4d0a30a4 1221 UefiDevicePathLibCatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]);\r
95276127 1222 }\r
1223\r
4d0a30a4 1224 UefiDevicePathLibCatPrint (Str, L",0x%x)", MacDevPath->IfType);\r
95276127 1225}\r
1226\r
052019e1 1227/**\r
1228 Converts network protocol string to its text representation.\r
1229\r
1230 @param Str The string representative of input device.\r
1231 @param Protocol The network protocol ID.\r
1232\r
1233**/\r
1234VOID\r
1235CatNetworkProtocol (\r
1236 IN OUT POOL_PRINT *Str,\r
1237 IN UINT16 Protocol\r
1238 )\r
1239{\r
1240 if (Protocol == RFC_1700_TCP_PROTOCOL) {\r
4d0a30a4 1241 UefiDevicePathLibCatPrint (Str, L"TCP");\r
052019e1 1242 } else if (Protocol == RFC_1700_UDP_PROTOCOL) {\r
4d0a30a4 1243 UefiDevicePathLibCatPrint (Str, L"UDP");\r
052019e1 1244 } else {\r
4d0a30a4 1245 UefiDevicePathLibCatPrint (Str, L"0x%x", Protocol);\r
052019e1 1246 }\r
1247}\r
1248\r
4d0a30a4
RN
1249/**\r
1250 Converts IP v4 address to its text representation.\r
1251\r
1252 @param Str The string representative of input device.\r
1253 @param Address The IP v4 address.\r
1254**/\r
1255VOID\r
1256CatIPv4Address (\r
1257 IN OUT POOL_PRINT *Str,\r
1258 IN EFI_IPv4_ADDRESS *Address\r
1259 )\r
1260{\r
1261 UefiDevicePathLibCatPrint (Str, L"%d.%d.%d.%d", Address->Addr[0], Address->Addr[1], Address->Addr[2], Address->Addr[3]);\r
1262}\r
1263\r
1264/**\r
1265 Converts IP v6 address to its text representation.\r
1266\r
1267 @param Str The string representative of input device.\r
1268 @param Address The IP v6 address.\r
1269**/\r
1270VOID\r
1271CatIPv6Address (\r
1272 IN OUT POOL_PRINT *Str,\r
1273 IN EFI_IPv6_ADDRESS *Address\r
1274 )\r
1275{\r
1276 UefiDevicePathLibCatPrint (\r
1277 Str, L"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",\r
1278 Address->Addr[0], Address->Addr[1],\r
1279 Address->Addr[2], Address->Addr[3],\r
1280 Address->Addr[4], Address->Addr[5],\r
1281 Address->Addr[6], Address->Addr[7],\r
1282 Address->Addr[8], Address->Addr[9],\r
1283 Address->Addr[10], Address->Addr[11],\r
1284 Address->Addr[12], Address->Addr[13],\r
1285 Address->Addr[14], Address->Addr[15]\r
1286 );\r
1287}\r
1288\r
572f5d8a 1289/**\r
48557c65 1290 Converts a IPv4 device path structure to its string representative.\r
572f5d8a 1291\r
48557c65 1292 @param Str The string representative of input device.\r
572f5d8a 1293 @param DevPath The input device path structure.\r
1294 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1295 of the display node is used, where applicable. If DisplayOnly\r
1296 is FALSE, then the longer text representation of the display node\r
1297 is used.\r
1298 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1299 representation for a device node can be used, where applicable.\r
1300\r
1301**/\r
95276127 1302VOID\r
1303DevPathToTextIPv4 (\r
1304 IN OUT POOL_PRINT *Str,\r
1305 IN VOID *DevPath,\r
1306 IN BOOLEAN DisplayOnly,\r
1307 IN BOOLEAN AllowShortcuts\r
1308 )\r
1309{\r
572f5d8a 1310 IPv4_DEVICE_PATH *IPDevPath;\r
95276127 1311\r
572f5d8a 1312 IPDevPath = DevPath;\r
4d0a30a4
RN
1313 UefiDevicePathLibCatPrint (Str, L"IPv4(");\r
1314 CatIPv4Address (Str, &IPDevPath->RemoteIpAddress);\r
1315\r
572f5d8a 1316 if (DisplayOnly) {\r
4d0a30a4 1317 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 1318 return ;\r
1319 }\r
1320\r
4d0a30a4
RN
1321 UefiDevicePathLibCatPrint (Str, L",");\r
1322 CatNetworkProtocol (Str, IPDevPath->Protocol);\r
052019e1 1323\r
4d0a30a4
RN
1324 UefiDevicePathLibCatPrint (Str, L",%s,", IPDevPath->StaticIpAddress ? L"Static" : L"DHCP");\r
1325 CatIPv4Address (Str, &IPDevPath->LocalIpAddress);\r
e9b3cd55 1326 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv4_DEVICE_PATH)) {\r
4d0a30a4
RN
1327 UefiDevicePathLibCatPrint (Str, L",");\r
1328 CatIPv4Address (Str, &IPDevPath->GatewayIpAddress);\r
1329 UefiDevicePathLibCatPrint (Str, L",");\r
1330 CatIPv4Address (Str, &IPDevPath->SubnetMask);\r
e9b3cd55 1331 }\r
4d0a30a4 1332 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 1333}\r
1334\r
572f5d8a 1335/**\r
48557c65 1336 Converts a IPv6 device path structure to its string representative.\r
572f5d8a 1337\r
48557c65 1338 @param Str The string representative of input device.\r
572f5d8a 1339 @param DevPath The input device path structure.\r
1340 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1341 of the display node is used, where applicable. If DisplayOnly\r
1342 is FALSE, then the longer text representation of the display node\r
1343 is used.\r
1344 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1345 representation for a device node can be used, where applicable.\r
1346\r
1347**/\r
95276127 1348VOID\r
1349DevPathToTextIPv6 (\r
1350 IN OUT POOL_PRINT *Str,\r
1351 IN VOID *DevPath,\r
1352 IN BOOLEAN DisplayOnly,\r
1353 IN BOOLEAN AllowShortcuts\r
1354 )\r
1355{\r
572f5d8a 1356 IPv6_DEVICE_PATH *IPDevPath;\r
95276127 1357\r
572f5d8a 1358 IPDevPath = DevPath;\r
4d0a30a4
RN
1359 UefiDevicePathLibCatPrint (Str, L"IPv6(");\r
1360 CatIPv6Address (Str, &IPDevPath->RemoteIpAddress);\r
572f5d8a 1361 if (DisplayOnly) {\r
4d0a30a4 1362 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 1363 return ;\r
1364 }\r
4d0a30a4
RN
1365 \r
1366 UefiDevicePathLibCatPrint (Str, L",");\r
1367 CatNetworkProtocol (Str, IPDevPath->Protocol);\r
052019e1 1368\r
501793fa
RN
1369 switch (IPDevPath->IpAddressOrigin) {\r
1370 case 0:\r
4d0a30a4 1371 UefiDevicePathLibCatPrint (Str, L",Static,");\r
501793fa
RN
1372 break;\r
1373 case 1:\r
4d0a30a4 1374 UefiDevicePathLibCatPrint (Str, L",StatelessAutoConfigure,");\r
501793fa
RN
1375 break;\r
1376 default:\r
4d0a30a4 1377 UefiDevicePathLibCatPrint (Str, L",StatefulAutoConfigure,");\r
501793fa
RN
1378 break;\r
1379 }\r
1380\r
4d0a30a4 1381 CatIPv6Address (Str, &IPDevPath->LocalIpAddress);\r
501793fa
RN
1382\r
1383 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv6_DEVICE_PATH)) {\r
4d0a30a4
RN
1384 UefiDevicePathLibCatPrint (Str, L",0x%x,", IPDevPath->PrefixLength);\r
1385 CatIPv6Address (Str, &IPDevPath->GatewayIpAddress);\r
501793fa 1386 }\r
4d0a30a4 1387 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 1388}\r
1389\r
572f5d8a 1390/**\r
48557c65 1391 Converts an Infini Band device path structure to its string representative.\r
572f5d8a 1392\r
48557c65 1393 @param Str The string representative of input device.\r
572f5d8a 1394 @param DevPath The input device path structure.\r
1395 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1396 of the display node is used, where applicable. If DisplayOnly\r
1397 is FALSE, then the longer text representation of the display node\r
1398 is used.\r
1399 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1400 representation for a device node can be used, where applicable.\r
1401\r
1402**/\r
95276127 1403VOID\r
1404DevPathToTextInfiniBand (\r
1405 IN OUT POOL_PRINT *Str,\r
1406 IN VOID *DevPath,\r
1407 IN BOOLEAN DisplayOnly,\r
1408 IN BOOLEAN AllowShortcuts\r
1409 )\r
1410{\r
1411 INFINIBAND_DEVICE_PATH *InfiniBand;\r
1412\r
1413 InfiniBand = DevPath;\r
4d0a30a4 1414 UefiDevicePathLibCatPrint (\r
95276127 1415 Str,\r
cf40f28a 1416 L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",\r
e9b3cd55 1417 InfiniBand->ResourceFlags,\r
95276127 1418 InfiniBand->PortGid,\r
1419 InfiniBand->ServiceId,\r
1420 InfiniBand->TargetPortId,\r
1421 InfiniBand->DeviceId\r
1422 );\r
1423}\r
1424\r
572f5d8a 1425/**\r
48557c65 1426 Converts a UART device path structure to its string representative.\r
572f5d8a 1427\r
48557c65 1428 @param Str The string representative of input device.\r
572f5d8a 1429 @param DevPath The input device path structure.\r
1430 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1431 of the display node is used, where applicable. If DisplayOnly\r
1432 is FALSE, then the longer text representation of the display node\r
1433 is used.\r
1434 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1435 representation for a device node can be used, where applicable.\r
1436\r
1437**/\r
95276127 1438VOID\r
1439DevPathToTextUart (\r
1440 IN OUT POOL_PRINT *Str,\r
1441 IN VOID *DevPath,\r
1442 IN BOOLEAN DisplayOnly,\r
1443 IN BOOLEAN AllowShortcuts\r
1444 )\r
1445{\r
1446 UART_DEVICE_PATH *Uart;\r
1447 CHAR8 Parity;\r
1448\r
1449 Uart = DevPath;\r
1450 switch (Uart->Parity) {\r
1451 case 0:\r
1452 Parity = 'D';\r
1453 break;\r
1454\r
1455 case 1:\r
1456 Parity = 'N';\r
1457 break;\r
1458\r
1459 case 2:\r
1460 Parity = 'E';\r
1461 break;\r
1462\r
1463 case 3:\r
1464 Parity = 'O';\r
1465 break;\r
1466\r
1467 case 4:\r
1468 Parity = 'M';\r
1469 break;\r
1470\r
1471 case 5:\r
1472 Parity = 'S';\r
1473 break;\r
1474\r
1475 default:\r
1476 Parity = 'x';\r
1477 break;\r
1478 }\r
1479\r
1480 if (Uart->BaudRate == 0) {\r
4d0a30a4 1481 UefiDevicePathLibCatPrint (Str, L"Uart(DEFAULT,");\r
95276127 1482 } else {\r
4d0a30a4 1483 UefiDevicePathLibCatPrint (Str, L"Uart(%ld,", Uart->BaudRate);\r
95276127 1484 }\r
1485\r
1486 if (Uart->DataBits == 0) {\r
4d0a30a4 1487 UefiDevicePathLibCatPrint (Str, L"DEFAULT,");\r
95276127 1488 } else {\r
4d0a30a4 1489 UefiDevicePathLibCatPrint (Str, L"%d,", Uart->DataBits);\r
95276127 1490 }\r
1491\r
4d0a30a4 1492 UefiDevicePathLibCatPrint (Str, L"%c,", Parity);\r
95276127 1493\r
1494 switch (Uart->StopBits) {\r
1495 case 0:\r
4d0a30a4 1496 UefiDevicePathLibCatPrint (Str, L"D)");\r
95276127 1497 break;\r
1498\r
1499 case 1:\r
4d0a30a4 1500 UefiDevicePathLibCatPrint (Str, L"1)");\r
95276127 1501 break;\r
1502\r
1503 case 2:\r
4d0a30a4 1504 UefiDevicePathLibCatPrint (Str, L"1.5)");\r
95276127 1505 break;\r
1506\r
1507 case 3:\r
4d0a30a4 1508 UefiDevicePathLibCatPrint (Str, L"2)");\r
95276127 1509 break;\r
1510\r
1511 default:\r
4d0a30a4 1512 UefiDevicePathLibCatPrint (Str, L"x)");\r
95276127 1513 break;\r
1514 }\r
1515}\r
1516\r
572f5d8a 1517/**\r
48557c65 1518 Converts an iSCSI device path structure to its string representative.\r
572f5d8a 1519\r
48557c65 1520 @param Str The string representative of input device.\r
572f5d8a 1521 @param DevPath The input device path structure.\r
1522 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1523 of the display node is used, where applicable. If DisplayOnly\r
1524 is FALSE, then the longer text representation of the display node\r
1525 is used.\r
1526 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1527 representation for a device node can be used, where applicable.\r
1528\r
1529**/\r
95276127 1530VOID\r
1531DevPathToTextiSCSI (\r
1532 IN OUT POOL_PRINT *Str,\r
1533 IN VOID *DevPath,\r
1534 IN BOOLEAN DisplayOnly,\r
1535 IN BOOLEAN AllowShortcuts\r
1536 )\r
1537{\r
572f5d8a 1538 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
95276127 1539 UINT16 Options;\r
1540\r
572f5d8a 1541 ISCSIDevPath = DevPath;\r
4d0a30a4 1542 UefiDevicePathLibCatPrint (\r
95276127 1543 Str,\r
cf40f28a 1544 L"iSCSI(%a,0x%x,0x%lx,",\r
184f7d83 1545 ISCSIDevPath->TargetName,\r
e9b3cd55 1546 ISCSIDevPath->TargetPortalGroupTag,\r
572f5d8a 1547 ISCSIDevPath->Lun\r
95276127 1548 );\r
1549\r
572f5d8a 1550 Options = ISCSIDevPath->LoginOption;\r
4d0a30a4
RN
1551 UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
1552 UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
572f5d8a 1553 if (((Options >> 11) & 0x0001) != 0) {\r
4d0a30a4 1554 UefiDevicePathLibCatPrint (Str, L"%s,", L"None");\r
572f5d8a 1555 } else if (((Options >> 12) & 0x0001) != 0) {\r
4d0a30a4 1556 UefiDevicePathLibCatPrint (Str, L"%s,", L"CHAP_UNI");\r
95276127 1557 } else {\r
4d0a30a4 1558 UefiDevicePathLibCatPrint (Str, L"%s,", L"CHAP_BI");\r
95276127 1559\r
1560 }\r
1561\r
4d0a30a4 1562 UefiDevicePathLibCatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
95276127 1563}\r
1564\r
8f97f911 1565/**\r
1566 Converts a VLAN device path structure to its string representative.\r
1567\r
1568 @param Str The string representative of input device.\r
1569 @param DevPath The input device path structure.\r
1570 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1571 of the display node is used, where applicable. If DisplayOnly\r
1572 is FALSE, then the longer text representation of the display node\r
1573 is used.\r
1574 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1575 representation for a device node can be used, where applicable.\r
1576\r
1577**/\r
1578VOID\r
1579DevPathToTextVlan (\r
1580 IN OUT POOL_PRINT *Str,\r
1581 IN VOID *DevPath,\r
1582 IN BOOLEAN DisplayOnly,\r
1583 IN BOOLEAN AllowShortcuts\r
1584 )\r
1585{\r
1586 VLAN_DEVICE_PATH *Vlan;\r
1587\r
1588 Vlan = DevPath;\r
4d0a30a4 1589 UefiDevicePathLibCatPrint (Str, L"Vlan(%d)", Vlan->VlanId);\r
8f97f911 1590}\r
1591\r
7795c8f9
QS
1592/**\r
1593 Converts a Bluetooth device path structure to its string representative.\r
1594\r
1595 @param Str The string representative of input device.\r
1596 @param DevPath The input device path structure.\r
1597 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1598 of the display node is used, where applicable. If DisplayOnly\r
1599 is FALSE, then the longer text representation of the display node\r
1600 is used.\r
1601 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1602 representation for a device node can be used, where applicable.\r
1603\r
1604**/\r
1605VOID\r
1606DevPathToTextBluetooth (\r
1607 IN OUT POOL_PRINT *Str,\r
1608 IN VOID *DevPath,\r
1609 IN BOOLEAN DisplayOnly,\r
1610 IN BOOLEAN AllowShortcuts\r
1611 )\r
1612{\r
1613 BLUETOOTH_DEVICE_PATH *Bluetooth;\r
1614\r
1615 Bluetooth = DevPath;\r
1616 UefiDevicePathLibCatPrint (\r
1617 Str,\r
6252f271 1618 L"Bluetooth(%02x%02x%02x%02x%02x%02x)",\r
7795c8f9
QS
1619 Bluetooth->BD_ADDR.Address[5],\r
1620 Bluetooth->BD_ADDR.Address[4],\r
1621 Bluetooth->BD_ADDR.Address[3],\r
1622 Bluetooth->BD_ADDR.Address[2],\r
1623 Bluetooth->BD_ADDR.Address[1],\r
1624 Bluetooth->BD_ADDR.Address[0]\r
1625 );\r
1626}\r
1627\r
3bafd562
HW
1628/**\r
1629 Converts a Wi-Fi device path structure to its string representative.\r
1630\r
1631 @param Str The string representative of input device.\r
1632 @param DevPath The input device path structure.\r
1633 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1634 of the display node is used, where applicable. If DisplayOnly\r
1635 is FALSE, then the longer text representation of the display node\r
1636 is used.\r
1637 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1638 representation for a device node can be used, where applicable.\r
1639\r
1640**/\r
1641VOID\r
1642DevPathToTextWiFi (\r
1643 IN OUT POOL_PRINT *Str,\r
1644 IN VOID *DevPath,\r
1645 IN BOOLEAN DisplayOnly,\r
1646 IN BOOLEAN AllowShortcuts\r
1647 )\r
1648{\r
1649 WIFI_DEVICE_PATH *WiFi;\r
0cd35d73 1650 UINT8 SSId[33];\r
3bafd562
HW
1651\r
1652 WiFi = DevPath;\r
0cd35d73
HW
1653\r
1654 SSId[32] = '\0';\r
1655 CopyMem (SSId, WiFi->SSId, 32);\r
1656\r
1657 UefiDevicePathLibCatPrint (Str, L"Wi-Fi(%a)", SSId);\r
3bafd562
HW
1658}\r
1659\r
c808ac7b
RN
1660/**\r
1661 Converts a URI device path structure to its string representative.\r
1662\r
1663 @param Str The string representative of input device.\r
1664 @param DevPath The input device path structure.\r
1665 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1666 of the display node is used, where applicable. If DisplayOnly\r
1667 is FALSE, then the longer text representation of the display node\r
1668 is used.\r
1669 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1670 representation for a device node can be used, where applicable.\r
1671\r
1672**/\r
1673VOID\r
1674DevPathToTextUri (\r
1675 IN OUT POOL_PRINT *Str,\r
1676 IN VOID *DevPath,\r
1677 IN BOOLEAN DisplayOnly,\r
1678 IN BOOLEAN AllowShortcuts\r
1679 )\r
1680{\r
1681 URI_DEVICE_PATH *Uri;\r
1682 UINTN UriLength;\r
1683 CHAR8 *UriStr;\r
1684\r
1685 //\r
1686 // Uri in the device path may not be null terminated.\r
1687 //\r
1688 Uri = DevPath;\r
1689 UriLength = DevicePathNodeLength (Uri) - sizeof (URI_DEVICE_PATH);\r
1690 UriStr = AllocatePool (UriLength + 1);\r
1691 ASSERT (UriStr != NULL);\r
1692\r
1693 CopyMem (UriStr, Uri->Uri, UriLength);\r
1694 UriStr[UriLength] = '\0';\r
1695 UefiDevicePathLibCatPrint (Str, L"Uri(%a)", UriStr);\r
1696 FreePool (UriStr);\r
1697}\r
1698\r
572f5d8a 1699/**\r
48557c65 1700 Converts a Hard drive device path structure to its string representative.\r
572f5d8a 1701\r
48557c65 1702 @param Str The string representative of input device.\r
572f5d8a 1703 @param DevPath The input device path structure.\r
1704 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1705 of the display node is used, where applicable. If DisplayOnly\r
1706 is FALSE, then the longer text representation of the display node\r
1707 is used.\r
1708 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1709 representation for a device node can be used, where applicable.\r
1710\r
1711**/\r
95276127 1712VOID\r
1713DevPathToTextHardDrive (\r
1714 IN OUT POOL_PRINT *Str,\r
1715 IN VOID *DevPath,\r
1716 IN BOOLEAN DisplayOnly,\r
1717 IN BOOLEAN AllowShortcuts\r
1718 )\r
1719{\r
1720 HARDDRIVE_DEVICE_PATH *Hd;\r
1721\r
1722 Hd = DevPath;\r
1723 switch (Hd->SignatureType) {\r
95276127 1724 case SIGNATURE_TYPE_MBR:\r
4d0a30a4 1725 UefiDevicePathLibCatPrint (\r
95276127 1726 Str,\r
cf40f28a 1727 L"HD(%d,%s,0x%08x,",\r
e9b3cd55 1728 Hd->PartitionNumber,\r
95276127 1729 L"MBR",\r
e9b3cd55 1730 *((UINT32 *) (&(Hd->Signature[0])))\r
95276127 1731 );\r
1732 break;\r
1733\r
1734 case SIGNATURE_TYPE_GUID:\r
4d0a30a4 1735 UefiDevicePathLibCatPrint (\r
95276127 1736 Str,\r
1737 L"HD(%d,%s,%g,",\r
e9b3cd55 1738 Hd->PartitionNumber,\r
cf40f28a 1739 L"GPT",\r
95276127 1740 (EFI_GUID *) &(Hd->Signature[0])\r
1741 );\r
1742 break;\r
1743\r
1744 default:\r
4d0a30a4 1745 UefiDevicePathLibCatPrint (\r
cf40f28a 1746 Str,\r
1747 L"HD(%d,%d,0,",\r
e9b3cd55
RN
1748 Hd->PartitionNumber,\r
1749 Hd->SignatureType\r
cf40f28a 1750 );\r
95276127 1751 break;\r
1752 }\r
1753\r
4d0a30a4 1754 UefiDevicePathLibCatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);\r
95276127 1755}\r
1756\r
572f5d8a 1757/**\r
48557c65 1758 Converts a CDROM device path structure to its string representative.\r
572f5d8a 1759\r
48557c65 1760 @param Str The string representative of input device.\r
572f5d8a 1761 @param DevPath The input device path structure.\r
1762 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1763 of the display node is used, where applicable. If DisplayOnly\r
1764 is FALSE, then the longer text representation of the display node\r
1765 is used.\r
1766 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1767 representation for a device node can be used, where applicable.\r
1768\r
1769**/\r
95276127 1770VOID\r
1771DevPathToTextCDROM (\r
1772 IN OUT POOL_PRINT *Str,\r
1773 IN VOID *DevPath,\r
1774 IN BOOLEAN DisplayOnly,\r
1775 IN BOOLEAN AllowShortcuts\r
1776 )\r
1777{\r
1778 CDROM_DEVICE_PATH *Cd;\r
1779\r
1780 Cd = DevPath;\r
572f5d8a 1781 if (DisplayOnly) {\r
4d0a30a4 1782 UefiDevicePathLibCatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);\r
95276127 1783 return ;\r
1784 }\r
1785\r
4d0a30a4 1786 UefiDevicePathLibCatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
95276127 1787}\r
1788\r
572f5d8a 1789/**\r
48557c65 1790 Converts a File device path structure to its string representative.\r
572f5d8a 1791\r
48557c65 1792 @param Str The string representative of input device.\r
572f5d8a 1793 @param DevPath The input device path structure.\r
1794 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1795 of the display node is used, where applicable. If DisplayOnly\r
1796 is FALSE, then the longer text representation of the display node\r
1797 is used.\r
1798 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1799 representation for a device node can be used, where applicable.\r
1800\r
1801**/\r
95276127 1802VOID\r
1803DevPathToTextFilePath (\r
1804 IN OUT POOL_PRINT *Str,\r
1805 IN VOID *DevPath,\r
1806 IN BOOLEAN DisplayOnly,\r
1807 IN BOOLEAN AllowShortcuts\r
1808 )\r
1809{\r
1810 FILEPATH_DEVICE_PATH *Fp;\r
1811\r
1812 Fp = DevPath;\r
4d0a30a4 1813 UefiDevicePathLibCatPrint (Str, L"%s", Fp->PathName);\r
95276127 1814}\r
1815\r
572f5d8a 1816/**\r
48557c65 1817 Converts a Media protocol device path structure to its string representative.\r
572f5d8a 1818\r
48557c65 1819 @param Str The string representative of input device.\r
572f5d8a 1820 @param DevPath The input device path structure.\r
1821 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1822 of the display node is used, where applicable. If DisplayOnly\r
1823 is FALSE, then the longer text representation of the display node\r
1824 is used.\r
1825 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1826 representation for a device node can be used, where applicable.\r
1827\r
1828**/\r
95276127 1829VOID\r
1830DevPathToTextMediaProtocol (\r
1831 IN OUT POOL_PRINT *Str,\r
1832 IN VOID *DevPath,\r
1833 IN BOOLEAN DisplayOnly,\r
1834 IN BOOLEAN AllowShortcuts\r
1835 )\r
1836{\r
1837 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;\r
1838\r
1839 MediaProt = DevPath;\r
4d0a30a4 1840 UefiDevicePathLibCatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
95276127 1841}\r
1842\r
572f5d8a 1843/**\r
48557c65 1844 Converts a Firmware Volume 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
cf40f28a 1856VOID\r
1857DevPathToTextFv (\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 MEDIA_FW_VOL_DEVICE_PATH *Fv;\r
1865\r
1866 Fv = DevPath;\r
4d0a30a4 1867 UefiDevicePathLibCatPrint (Str, L"Fv(%g)", &Fv->FvName);\r
cf40f28a 1868}\r
1869\r
572f5d8a 1870/**\r
48557c65 1871 Converts a Firmware Volume File device path structure to its string representative.\r
572f5d8a 1872\r
48557c65 1873 @param Str The string representative of input device.\r
572f5d8a 1874 @param DevPath The input device path structure.\r
1875 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1876 of the display node is used, where applicable. If DisplayOnly\r
1877 is FALSE, then the longer text representation of the display node\r
1878 is used.\r
1879 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1880 representation for a device node can be used, where applicable.\r
1881\r
1882**/\r
cf40f28a 1883VOID\r
1884DevPathToTextFvFile (\r
1885 IN OUT POOL_PRINT *Str,\r
1886 IN VOID *DevPath,\r
1887 IN BOOLEAN DisplayOnly,\r
1888 IN BOOLEAN AllowShortcuts\r
1889 )\r
1890{\r
1891 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;\r
1892\r
1893 FvFile = DevPath;\r
4d0a30a4 1894 UefiDevicePathLibCatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);\r
cf40f28a 1895}\r
1896\r
09e15613 1897/**\r
1898 Converts a Relative Offset device path structure to its string representative.\r
1899\r
1900 @param Str The string representative of input device.\r
1901 @param DevPath The input device path structure.\r
1902 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1903 of the display node is used, where applicable. If DisplayOnly\r
1904 is FALSE, then the longer text representation of the display node\r
1905 is used.\r
1906 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1907 representation for a device node can be used, where applicable.\r
1908\r
1909**/\r
1910VOID\r
1911DevPathRelativeOffsetRange (\r
1912 IN OUT POOL_PRINT *Str,\r
1913 IN VOID *DevPath,\r
1914 IN BOOLEAN DisplayOnly,\r
1915 IN BOOLEAN AllowShortcuts\r
1916 )\r
1917{\r
1918 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
1919\r
1920 Offset = DevPath;\r
4d0a30a4 1921 UefiDevicePathLibCatPrint (\r
09e15613 1922 Str,\r
7748eb28 1923 L"Offset(0x%lx,0x%lx)",\r
09e15613 1924 Offset->StartingOffset,\r
1925 Offset->EndingOffset\r
1926 );\r
1927}\r
1928\r
6a46c1a2
FT
1929/**\r
1930 Converts a Ram Disk device path structure to its string representative.\r
1931\r
1932 @param Str The string representative of input device.\r
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
1942VOID\r
1943DevPathToTextRamDisk (\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_RAM_DISK_DEVICE_PATH *RamDisk;\r
1951\r
1952 RamDisk = DevPath;\r
1953\r
1954 if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid)) {\r
1955 UefiDevicePathLibCatPrint (\r
1956 Str,\r
1957 L"VirtualDisk(0x%lx,0x%lx,%d)",\r
a3bc432a
TS
1958 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
1959 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
1960 RamDisk->Instance\r
1961 );\r
1962 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid)) {\r
1963 UefiDevicePathLibCatPrint (\r
1964 Str,\r
1965 L"VirtualCD(0x%lx,0x%lx,%d)",\r
a3bc432a
TS
1966 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
1967 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
1968 RamDisk->Instance\r
1969 );\r
1970 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid)) {\r
1971 UefiDevicePathLibCatPrint (\r
1972 Str,\r
1973 L"PersistentVirtualDisk(0x%lx,0x%lx,%d)",\r
a3bc432a
TS
1974 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
1975 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
1976 RamDisk->Instance\r
1977 );\r
1978 } else if (CompareGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid)) {\r
1979 UefiDevicePathLibCatPrint (\r
1980 Str,\r
1981 L"PersistentVirtualCD(0x%lx,0x%lx,%d)",\r
a3bc432a
TS
1982 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
1983 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
1984 RamDisk->Instance\r
1985 );\r
1986 } else {\r
1987 UefiDevicePathLibCatPrint (\r
1988 Str,\r
1989 L"RamDisk(0x%lx,0x%lx,%d,%g)",\r
a3bc432a
TS
1990 LShiftU64 ((UINT64)RamDisk->StartingAddr[1], 32) | RamDisk->StartingAddr[0],\r
1991 LShiftU64 ((UINT64)RamDisk->EndingAddr[1], 32) | RamDisk->EndingAddr[0],\r
6a46c1a2
FT
1992 RamDisk->Instance,\r
1993 &RamDisk->TypeGuid\r
1994 );\r
1995 }\r
1996}\r
1997\r
572f5d8a 1998/**\r
48557c65 1999 Converts a BIOS Boot Specification device path structure to its string representative.\r
572f5d8a 2000\r
48557c65 2001 @param Str The string representative of input device.\r
572f5d8a 2002 @param DevPath The input device path structure.\r
2003 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2004 of the display node is used, where applicable. If DisplayOnly\r
2005 is FALSE, then the longer text representation of the display node\r
2006 is used.\r
2007 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2008 representation for a device node can be used, where applicable.\r
2009\r
2010**/\r
95276127 2011VOID\r
2012DevPathToTextBBS (\r
2013 IN OUT POOL_PRINT *Str,\r
2014 IN VOID *DevPath,\r
2015 IN BOOLEAN DisplayOnly,\r
2016 IN BOOLEAN AllowShortcuts\r
2017 )\r
2018{\r
2019 BBS_BBS_DEVICE_PATH *Bbs;\r
2020 CHAR16 *Type;\r
2021\r
2022 Bbs = DevPath;\r
2023 switch (Bbs->DeviceType) {\r
2024 case BBS_TYPE_FLOPPY:\r
2025 Type = L"Floppy";\r
2026 break;\r
2027\r
2028 case BBS_TYPE_HARDDRIVE:\r
2029 Type = L"HD";\r
2030 break;\r
2031\r
2032 case BBS_TYPE_CDROM:\r
2033 Type = L"CDROM";\r
2034 break;\r
2035\r
2036 case BBS_TYPE_PCMCIA:\r
2037 Type = L"PCMCIA";\r
2038 break;\r
2039\r
2040 case BBS_TYPE_USB:\r
2041 Type = L"USB";\r
2042 break;\r
2043\r
2044 case BBS_TYPE_EMBEDDED_NETWORK:\r
2045 Type = L"Network";\r
2046 break;\r
2047\r
2048 default:\r
cf40f28a 2049 Type = NULL;\r
95276127 2050 break;\r
2051 }\r
2052\r
cf40f28a 2053 if (Type != NULL) {\r
4d0a30a4 2054 UefiDevicePathLibCatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r
cf40f28a 2055 } else {\r
4d0a30a4 2056 UefiDevicePathLibCatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String);\r
cf40f28a 2057 }\r
95276127 2058\r
572f5d8a 2059 if (DisplayOnly) {\r
4d0a30a4 2060 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 2061 return ;\r
2062 }\r
2063\r
4d0a30a4 2064 UefiDevicePathLibCatPrint (Str, L",0x%x)", Bbs->StatusFlag);\r
95276127 2065}\r
2066\r
572f5d8a 2067/**\r
48557c65 2068 Converts an End-of-Device-Path structure to its string representative.\r
572f5d8a 2069\r
48557c65 2070 @param Str The string representative of input device.\r
572f5d8a 2071 @param DevPath The input device path structure.\r
2072 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2073 of the display node is used, where applicable. If DisplayOnly\r
2074 is FALSE, then the longer text representation of the display node\r
2075 is used.\r
2076 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2077 representation for a device node can be used, where applicable.\r
2078\r
2079**/\r
95276127 2080VOID\r
2081DevPathToTextEndInstance (\r
2082 IN OUT POOL_PRINT *Str,\r
2083 IN VOID *DevPath,\r
2084 IN BOOLEAN DisplayOnly,\r
2085 IN BOOLEAN AllowShortcuts\r
2086 )\r
2087{\r
4d0a30a4 2088 UefiDevicePathLibCatPrint (Str, L",");\r
95276127 2089}\r
2090\r
5d6a5aee
RN
2091GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_GENERIC_TABLE mUefiDevicePathLibToTextTableGeneric[] = {\r
2092 {HARDWARE_DEVICE_PATH, L"HardwarePath" },\r
2093 {ACPI_DEVICE_PATH, L"AcpiPath" },\r
2094 {MESSAGING_DEVICE_PATH, L"Msg" },\r
2095 {MEDIA_DEVICE_PATH, L"MediaPath" },\r
2096 {BBS_DEVICE_PATH, L"BbsPath" },\r
2097 {0, NULL}\r
2098};\r
2099\r
572f5d8a 2100/**\r
48557c65 2101 Converts an unknown device path structure to its string representative.\r
572f5d8a 2102\r
48557c65 2103 @param Str The string representative of input device.\r
572f5d8a 2104 @param DevPath The input device path structure.\r
2105 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2106 of the display node is used, where applicable. If DisplayOnly\r
2107 is FALSE, then the longer text representation of the display node\r
2108 is used.\r
2109 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2110 representation for a device node can be used, where applicable.\r
2111\r
2112**/\r
95276127 2113VOID\r
5d6a5aee 2114DevPathToTextNodeGeneric (\r
95276127 2115 IN OUT POOL_PRINT *Str,\r
2116 IN VOID *DevPath,\r
2117 IN BOOLEAN DisplayOnly,\r
2118 IN BOOLEAN AllowShortcuts\r
2119 )\r
2120{\r
5d6a5aee
RN
2121 EFI_DEVICE_PATH_PROTOCOL *Node;\r
2122 UINTN Index;\r
2123\r
2124 Node = DevPath;\r
2125\r
2126 for (Index = 0; mUefiDevicePathLibToTextTableGeneric[Index].Text != NULL; Index++) {\r
2127 if (DevicePathType (Node) == mUefiDevicePathLibToTextTableGeneric[Index].Type) {\r
2128 break;\r
2129 }\r
2130 }\r
2131\r
2132 if (mUefiDevicePathLibToTextTableGeneric[Index].Text == NULL) {\r
2133 //\r
2134 // It's a node whose type cannot be recognized\r
2135 //\r
2136 UefiDevicePathLibCatPrint (Str, L"Path(%d,%d", DevicePathType (Node), DevicePathSubType (Node));\r
2137 } else {\r
2138 //\r
2139 // It's a node whose type can be recognized\r
2140 //\r
2141 UefiDevicePathLibCatPrint (Str, L"%s(%d", mUefiDevicePathLibToTextTableGeneric[Index].Text, DevicePathSubType (Node));\r
2142 }\r
2143\r
2144 Index = sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
2145 if (Index < DevicePathNodeLength (Node)) {\r
2146 UefiDevicePathLibCatPrint (Str, L",");\r
2147 for (; Index < DevicePathNodeLength (Node); Index++) {\r
2148 UefiDevicePathLibCatPrint (Str, L"%02x", ((UINT8 *) Node)[Index]);\r
2149 }\r
2150 }\r
2151\r
2152 UefiDevicePathLibCatPrint (Str, L")");\r
95276127 2153}\r
2154\r
5d6a5aee 2155GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = {\r
4d0a30a4
RN
2156 {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci },\r
2157 {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard },\r
2158 {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap },\r
2159 {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor },\r
2160 {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController },\r
624f017e 2161 {HARDWARE_DEVICE_PATH, HW_BMC_DP, DevPathToTextBmc },\r
4d0a30a4
RN
2162 {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi },\r
2163 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx },\r
2164 {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr },\r
2165 {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi },\r
2166 {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi },\r
2167 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre },\r
2168 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx },\r
2169 {MESSAGING_DEVICE_PATH, MSG_SASEX_DP, DevPathToTextSasEx },\r
a06ec3e2 2170 {MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP, DevPathToTextNVMe },\r
52306166 2171 {MESSAGING_DEVICE_PATH, MSG_UFS_DP, DevPathToTextUfs },\r
ab8686b8 2172 {MESSAGING_DEVICE_PATH, MSG_SD_DP, DevPathToTextSd },\r
5c67fb2f 2173 {MESSAGING_DEVICE_PATH, MSG_EMMC_DP, DevPathToTextEmmc },\r
4d0a30a4
RN
2174 {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394 },\r
2175 {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb },\r
2176 {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID },\r
2177 {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit },\r
2178 {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass },\r
2179 {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata },\r
2180 {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O },\r
2181 {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr },\r
2182 {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4 },\r
2183 {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6 },\r
2184 {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand },\r
2185 {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart },\r
2186 {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor },\r
2187 {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI },\r
2188 {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan },\r
c808ac7b 2189 {MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextUri },\r
7795c8f9 2190 {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextBluetooth },\r
3bafd562 2191 {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextWiFi },\r
4d0a30a4
RN
2192 {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive },\r
2193 {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM },\r
2194 {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor },\r
2195 {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol },\r
2196 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath },\r
2197 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv },\r
2198 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile },\r
2199 {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange },\r
6a46c1a2 2200 {MEDIA_DEVICE_PATH, MEDIA_RAM_DISK_DP, DevPathToTextRamDisk },\r
4d0a30a4
RN
2201 {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS },\r
2202 {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance },\r
95276127 2203 {0, 0, NULL}\r
2204};\r
2205\r
572f5d8a 2206/**\r
2207 Converts a device node to its string representation.\r
2208\r
2209 @param DeviceNode A Pointer to the device node to be converted.\r
2210 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
2211 of the display node is used, where applicable. If DisplayOnly\r
2212 is FALSE, then the longer text representation of the display node\r
2213 is used.\r
2214 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
2215 representation for a device node can be used, where applicable.\r
2216\r
2217 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
2218 is NULL or there was insufficient memory.\r
2219\r
2220**/\r
95276127 2221CHAR16 *\r
572f5d8a 2222EFIAPI\r
4d0a30a4 2223UefiDevicePathLibConvertDeviceNodeToText (\r
95276127 2224 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
2225 IN BOOLEAN DisplayOnly,\r
2226 IN BOOLEAN AllowShortcuts\r
2227 )\r
95276127 2228{\r
4d0a30a4
RN
2229 POOL_PRINT Str;\r
2230 UINTN Index;\r
2231 DEVICE_PATH_TO_TEXT ToText;\r
95276127 2232\r
2233 if (DeviceNode == NULL) {\r
2234 return NULL;\r
2235 }\r
2236\r
2237 ZeroMem (&Str, sizeof (Str));\r
2238\r
2239 //\r
2240 // Process the device path node\r
4d0a30a4 2241 // If not found, use a generic function\r
95276127 2242 //\r
5d6a5aee
RN
2243 ToText = DevPathToTextNodeGeneric;\r
2244 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index++) {\r
2245 if (DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type &&\r
2246 DevicePathSubType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].SubType\r
95276127 2247 ) {\r
5d6a5aee 2248 ToText = mUefiDevicePathLibToTextTable[Index].Function;\r
95276127 2249 break;\r
2250 }\r
2251 }\r
95276127 2252\r
2253 //\r
2254 // Print this node\r
2255 //\r
4d0a30a4 2256 ToText (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r
95276127 2257\r
9d4af8fc 2258 ASSERT (Str.Str != NULL);\r
95276127 2259 return Str.Str;\r
2260}\r
2261\r
572f5d8a 2262/**\r
2263 Converts a device path to its text representation.\r
95276127 2264\r
572f5d8a 2265 @param DevicePath A Pointer to the device to be converted.\r
2266 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
95276127 2267 of the display node is used, where applicable. If DisplayOnly\r
2268 is FALSE, then the longer text representation of the display node\r
2269 is used.\r
572f5d8a 2270 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
95276127 2271 representation for a device node can be used, where applicable.\r
2272\r
572f5d8a 2273 @return A pointer to the allocated text representation of the device path or\r
2274 NULL if DeviceNode is NULL or there was insufficient memory.\r
95276127 2275\r
572f5d8a 2276**/\r
2277CHAR16 *\r
2278EFIAPI\r
4d0a30a4 2279UefiDevicePathLibConvertDevicePathToText (\r
572f5d8a 2280 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
2281 IN BOOLEAN DisplayOnly,\r
2282 IN BOOLEAN AllowShortcuts\r
2283 )\r
95276127 2284{\r
4d0a30a4
RN
2285 POOL_PRINT Str;\r
2286 EFI_DEVICE_PATH_PROTOCOL *Node;\r
2287 EFI_DEVICE_PATH_PROTOCOL *AlignedNode;\r
2288 UINTN Index;\r
2289 DEVICE_PATH_TO_TEXT ToText;\r
95276127 2290\r
2291 if (DevicePath == NULL) {\r
2292 return NULL;\r
2293 }\r
2294\r
2295 ZeroMem (&Str, sizeof (Str));\r
2296\r
95276127 2297 //\r
2298 // Process each device path node\r
2299 //\r
4d0a30a4
RN
2300 Node = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;\r
2301 while (!IsDevicePathEnd (Node)) {\r
95276127 2302 //\r
2303 // Find the handler to dump this device path node\r
4d0a30a4 2304 // If not found, use a generic function\r
95276127 2305 //\r
5d6a5aee
RN
2306 ToText = DevPathToTextNodeGeneric;\r
2307 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index += 1) {\r
95276127 2308\r
5d6a5aee
RN
2309 if (DevicePathType (Node) == mUefiDevicePathLibToTextTable[Index].Type &&\r
2310 DevicePathSubType (Node) == mUefiDevicePathLibToTextTable[Index].SubType\r
95276127 2311 ) {\r
5d6a5aee 2312 ToText = mUefiDevicePathLibToTextTable[Index].Function;\r
95276127 2313 break;\r
2314 }\r
2315 }\r
2316 //\r
5755841f 2317 // Put a path separator in if needed\r
95276127 2318 //\r
4d0a30a4
RN
2319 if ((Str.Count != 0) && (ToText != DevPathToTextEndInstance)) {\r
2320 if (Str.Str[Str.Count] != L',') {\r
2321 UefiDevicePathLibCatPrint (&Str, L"/");\r
cf40f28a 2322 }\r
95276127 2323 }\r
1232b214 2324 \r
4d0a30a4 2325 AlignedNode = AllocateCopyPool (DevicePathNodeLength (Node), Node);\r
95276127 2326 //\r
2327 // Print this node of the device path\r
2328 //\r
4d0a30a4
RN
2329 ToText (&Str, AlignedNode, DisplayOnly, AllowShortcuts);\r
2330 FreePool (AlignedNode);\r
1232b214 2331 \r
95276127 2332 //\r
2333 // Next device path node\r
2334 //\r
4d0a30a4 2335 Node = NextDevicePathNode (Node);\r
95276127 2336 }\r
95276127 2337\r
9d4af8fc
RN
2338 if (Str.Str == NULL) {\r
2339 return AllocateZeroPool (sizeof (CHAR16));\r
2340 } else {\r
2341 return Str.Str;\r
2342 }\r
95276127 2343}\r