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