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