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