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