]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
Function AtaEnableLongPhysicalSector () added for Long physical sector process.
[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
7ae9c1ce 558 (Atapi->PrimarySecondary == 1) ? L"Secondary" : L"Primary",\r
559 (Atapi->SlaveMaster == 1) ? L"Slave" : L"Master",\r
95276127 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
3069bc19 711 ASSERT (NewStr != NULL);\r
cf40f28a 712 NewStr [Length] = 0;\r
713 SerialNumberStr = NewStr;\r
714 }\r
715\r
95276127 716 CatPrint (\r
717 Str,\r
cf40f28a 718 L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",\r
95276127 719 UsbWWId->VendorId,\r
720 UsbWWId->ProductId,\r
cf40f28a 721 UsbWWId->InterfaceNumber,\r
722 SerialNumberStr\r
95276127 723 );\r
724}\r
725\r
572f5d8a 726/**\r
48557c65 727 Converts a Logic Unit device path structure to its string representative.\r
572f5d8a 728\r
48557c65 729 @param Str The string representative of input device.\r
572f5d8a 730 @param DevPath The input device path structure.\r
731 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
732 of the display node is used, where applicable. If DisplayOnly\r
733 is FALSE, then the longer text representation of the display node\r
734 is used.\r
735 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
736 representation for a device node can be used, where applicable.\r
737\r
738**/\r
95276127 739VOID\r
740DevPathToTextLogicalUnit (\r
741 IN OUT POOL_PRINT *Str,\r
742 IN VOID *DevPath,\r
743 IN BOOLEAN DisplayOnly,\r
744 IN BOOLEAN AllowShortcuts\r
745 )\r
746{\r
747 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
748\r
749 LogicalUnit = DevPath;\r
cf40f28a 750 CatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun);\r
95276127 751}\r
752\r
572f5d8a 753/**\r
48557c65 754 Converts a USB class device path structure to its string representative.\r
572f5d8a 755\r
48557c65 756 @param Str The string representative of input device.\r
572f5d8a 757 @param DevPath The input device path structure.\r
758 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
759 of the display node is used, where applicable. If DisplayOnly\r
760 is FALSE, then the longer text representation of the display node\r
761 is used.\r
762 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
763 representation for a device node can be used, where applicable.\r
764\r
765**/\r
95276127 766VOID\r
767DevPathToTextUsbClass (\r
768 IN OUT POOL_PRINT *Str,\r
769 IN VOID *DevPath,\r
770 IN BOOLEAN DisplayOnly,\r
771 IN BOOLEAN AllowShortcuts\r
772 )\r
773{\r
774 USB_CLASS_DEVICE_PATH *UsbClass;\r
cf40f28a 775 BOOLEAN IsKnownSubClass;\r
776\r
95276127 777\r
778 UsbClass = DevPath;\r
779\r
cf40f28a 780 IsKnownSubClass = TRUE;\r
781 switch (UsbClass->DeviceClass) {\r
782 case USB_CLASS_AUDIO:\r
783 CatPrint (Str, L"UsbAudio");\r
784 break;\r
95276127 785\r
cf40f28a 786 case USB_CLASS_CDCCONTROL:\r
787 CatPrint (Str, L"UsbCDCControl");\r
788 break;\r
95276127 789\r
cf40f28a 790 case USB_CLASS_HID:\r
791 CatPrint (Str, L"UsbHID");\r
792 break;\r
95276127 793\r
cf40f28a 794 case USB_CLASS_IMAGE:\r
795 CatPrint (Str, L"UsbImage");\r
796 break;\r
95276127 797\r
cf40f28a 798 case USB_CLASS_PRINTER:\r
799 CatPrint (Str, L"UsbPrinter");\r
800 break;\r
95276127 801\r
cf40f28a 802 case USB_CLASS_MASS_STORAGE:\r
803 CatPrint (Str, L"UsbMassStorage");\r
804 break;\r
95276127 805\r
cf40f28a 806 case USB_CLASS_HUB:\r
807 CatPrint (Str, L"UsbHub");\r
808 break;\r
95276127 809\r
cf40f28a 810 case USB_CLASS_CDCDATA:\r
811 CatPrint (Str, L"UsbCDCData");\r
812 break;\r
95276127 813\r
cf40f28a 814 case USB_CLASS_SMART_CARD:\r
815 CatPrint (Str, L"UsbSmartCard");\r
816 break;\r
95276127 817\r
cf40f28a 818 case USB_CLASS_VIDEO:\r
819 CatPrint (Str, L"UsbVideo");\r
820 break;\r
821\r
822 case USB_CLASS_DIAGNOSTIC:\r
823 CatPrint (Str, L"UsbDiagnostic");\r
824 break;\r
825\r
826 case USB_CLASS_WIRELESS:\r
827 CatPrint (Str, L"UsbWireless");\r
828 break;\r
829\r
830 default:\r
831 IsKnownSubClass = FALSE;\r
832 break;\r
833 }\r
834\r
835 if (IsKnownSubClass) {\r
836 CatPrint (\r
837 Str,\r
838 L"(0x%x,0x%x,0x%x,0x%x)",\r
839 UsbClass->VendorId,\r
840 UsbClass->ProductId,\r
841 UsbClass->DeviceSubClass,\r
842 UsbClass->DeviceProtocol\r
843 );\r
844 return;\r
845 }\r
846\r
847 if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {\r
848 if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {\r
95276127 849 CatPrint (\r
850 Str,\r
cf40f28a 851 L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",\r
95276127 852 UsbClass->VendorId,\r
853 UsbClass->ProductId,\r
95276127 854 UsbClass->DeviceProtocol\r
855 );\r
cf40f28a 856 return;\r
857 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {\r
95276127 858 CatPrint (\r
859 Str,\r
cf40f28a 860 L"UsbIrdaBridge(0x%x,0x%x,0x%x)",\r
95276127 861 UsbClass->VendorId,\r
862 UsbClass->ProductId,\r
95276127 863 UsbClass->DeviceProtocol\r
864 );\r
cf40f28a 865 return;\r
866 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {\r
95276127 867 CatPrint (\r
868 Str,\r
cf40f28a 869 L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",\r
95276127 870 UsbClass->VendorId,\r
871 UsbClass->ProductId,\r
95276127 872 UsbClass->DeviceProtocol\r
873 );\r
cf40f28a 874 return;\r
95276127 875 }\r
95276127 876 }\r
877\r
878 CatPrint (\r
879 Str,\r
cf40f28a 880 L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",\r
95276127 881 UsbClass->VendorId,\r
882 UsbClass->ProductId,\r
883 UsbClass->DeviceClass,\r
884 UsbClass->DeviceSubClass,\r
885 UsbClass->DeviceProtocol\r
886 );\r
887}\r
888\r
572f5d8a 889/**\r
48557c65 890 Converts a SATA device path structure to its string representative.\r
572f5d8a 891\r
48557c65 892 @param Str The string representative of input device.\r
572f5d8a 893 @param DevPath The input device path structure.\r
894 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
895 of the display node is used, where applicable. If DisplayOnly\r
896 is FALSE, then the longer text representation of the display node\r
897 is used.\r
898 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
899 representation for a device node can be used, where applicable.\r
900\r
901**/\r
cf40f28a 902VOID\r
903DevPathToTextSata (\r
904 IN OUT POOL_PRINT *Str,\r
905 IN VOID *DevPath,\r
906 IN BOOLEAN DisplayOnly,\r
907 IN BOOLEAN AllowShortcuts\r
908 )\r
909{\r
910 SATA_DEVICE_PATH *Sata;\r
911\r
912 Sata = DevPath;\r
913 CatPrint (\r
914 Str,\r
915 L"Sata(0x%x,0x%x,0x%x)",\r
93e3992d 916 (UINTN) Sata->HBAPortNumber,\r
917 (UINTN) Sata->PortMultiplierPortNumber,\r
918 (UINTN) Sata->Lun\r
cf40f28a 919 );\r
920}\r
921\r
572f5d8a 922/**\r
48557c65 923 Converts a I20 device path structure to its string representative.\r
572f5d8a 924\r
48557c65 925 @param Str The string representative of input device.\r
572f5d8a 926 @param DevPath The input device path structure.\r
927 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
928 of the display node is used, where applicable. If DisplayOnly\r
929 is FALSE, then the longer text representation of the display node\r
930 is used.\r
931 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
932 representation for a device node can be used, where applicable.\r
933\r
934**/\r
95276127 935VOID\r
936DevPathToTextI2O (\r
937 IN OUT POOL_PRINT *Str,\r
938 IN VOID *DevPath,\r
939 IN BOOLEAN DisplayOnly,\r
940 IN BOOLEAN AllowShortcuts\r
941 )\r
942{\r
572f5d8a 943 I2O_DEVICE_PATH *I2ODevPath;\r
95276127 944\r
572f5d8a 945 I2ODevPath = DevPath;\r
946 CatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid);\r
95276127 947}\r
948\r
572f5d8a 949/**\r
48557c65 950 Converts a MAC address device path structure to its string representative.\r
572f5d8a 951\r
48557c65 952 @param Str The string representative of input device.\r
572f5d8a 953 @param DevPath The input device path structure.\r
954 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
955 of the display node is used, where applicable. If DisplayOnly\r
956 is FALSE, then the longer text representation of the display node\r
957 is used.\r
958 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
959 representation for a device node can be used, where applicable.\r
960\r
961**/\r
95276127 962VOID\r
963DevPathToTextMacAddr (\r
964 IN OUT POOL_PRINT *Str,\r
965 IN VOID *DevPath,\r
966 IN BOOLEAN DisplayOnly,\r
967 IN BOOLEAN AllowShortcuts\r
968 )\r
969{\r
572f5d8a 970 MAC_ADDR_DEVICE_PATH *MacDevPath;\r
95276127 971 UINTN HwAddressSize;\r
972 UINTN Index;\r
973\r
572f5d8a 974 MacDevPath = DevPath;\r
95276127 975\r
976 HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
572f5d8a 977 if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {\r
95276127 978 HwAddressSize = 6;\r
979 }\r
980\r
981 CatPrint (Str, L"MAC(");\r
982\r
983 for (Index = 0; Index < HwAddressSize; Index++) {\r
572f5d8a 984 CatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]);\r
95276127 985 }\r
986\r
572f5d8a 987 CatPrint (Str, L",0x%x)", MacDevPath->IfType);\r
95276127 988}\r
989\r
572f5d8a 990/**\r
48557c65 991 Converts a IPv4 device path structure to its string representative.\r
572f5d8a 992\r
48557c65 993 @param Str The string representative of input device.\r
572f5d8a 994 @param DevPath The input device path structure.\r
995 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
996 of the display node is used, where applicable. If DisplayOnly\r
997 is FALSE, then the longer text representation of the display node\r
998 is used.\r
999 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1000 representation for a device node can be used, where applicable.\r
1001\r
1002**/\r
95276127 1003VOID\r
1004DevPathToTextIPv4 (\r
1005 IN OUT POOL_PRINT *Str,\r
1006 IN VOID *DevPath,\r
1007 IN BOOLEAN DisplayOnly,\r
1008 IN BOOLEAN AllowShortcuts\r
1009 )\r
1010{\r
572f5d8a 1011 IPv4_DEVICE_PATH *IPDevPath;\r
95276127 1012\r
572f5d8a 1013 IPDevPath = DevPath;\r
1014 if (DisplayOnly) {\r
95276127 1015 CatPrint (\r
1016 Str,\r
1017 L"IPv4(%d.%d.%d.%d)",\r
572f5d8a 1018 IPDevPath->RemoteIpAddress.Addr[0],\r
1019 IPDevPath->RemoteIpAddress.Addr[1],\r
1020 IPDevPath->RemoteIpAddress.Addr[2],\r
1021 IPDevPath->RemoteIpAddress.Addr[3]\r
95276127 1022 );\r
1023 return ;\r
1024 }\r
1025\r
1026 CatPrint (\r
1027 Str,\r
1028 L"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",\r
572f5d8a 1029 IPDevPath->RemoteIpAddress.Addr[0],\r
1030 IPDevPath->RemoteIpAddress.Addr[1],\r
1031 IPDevPath->RemoteIpAddress.Addr[2],\r
1032 IPDevPath->RemoteIpAddress.Addr[3],\r
7ae9c1ce 1033 (IPDevPath->Protocol == 1) ? L"TCP" : L"UDP",\r
1034 IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r
572f5d8a 1035 IPDevPath->LocalIpAddress.Addr[0],\r
1036 IPDevPath->LocalIpAddress.Addr[1],\r
1037 IPDevPath->LocalIpAddress.Addr[2],\r
1038 IPDevPath->LocalIpAddress.Addr[3]\r
95276127 1039 );\r
1040}\r
1041\r
572f5d8a 1042/**\r
48557c65 1043 Converts a IPv6 device path structure to its string representative.\r
572f5d8a 1044\r
48557c65 1045 @param Str The string representative of input device.\r
572f5d8a 1046 @param DevPath The input device path structure.\r
1047 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1048 of the display node is used, where applicable. If DisplayOnly\r
1049 is FALSE, then the longer text representation of the display node\r
1050 is used.\r
1051 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1052 representation for a device node can be used, where applicable.\r
1053\r
1054**/\r
95276127 1055VOID\r
1056DevPathToTextIPv6 (\r
1057 IN OUT POOL_PRINT *Str,\r
1058 IN VOID *DevPath,\r
1059 IN BOOLEAN DisplayOnly,\r
1060 IN BOOLEAN AllowShortcuts\r
1061 )\r
1062{\r
572f5d8a 1063 IPv6_DEVICE_PATH *IPDevPath;\r
95276127 1064\r
572f5d8a 1065 IPDevPath = DevPath;\r
1066 if (DisplayOnly) {\r
95276127 1067 CatPrint (\r
1068 Str,\r
1069 L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
572f5d8a 1070 IPDevPath->RemoteIpAddress.Addr[0],\r
1071 IPDevPath->RemoteIpAddress.Addr[1],\r
1072 IPDevPath->RemoteIpAddress.Addr[2],\r
1073 IPDevPath->RemoteIpAddress.Addr[3],\r
1074 IPDevPath->RemoteIpAddress.Addr[4],\r
1075 IPDevPath->RemoteIpAddress.Addr[5],\r
1076 IPDevPath->RemoteIpAddress.Addr[6],\r
1077 IPDevPath->RemoteIpAddress.Addr[7],\r
1078 IPDevPath->RemoteIpAddress.Addr[8],\r
1079 IPDevPath->RemoteIpAddress.Addr[9],\r
1080 IPDevPath->RemoteIpAddress.Addr[10],\r
1081 IPDevPath->RemoteIpAddress.Addr[11],\r
1082 IPDevPath->RemoteIpAddress.Addr[12],\r
1083 IPDevPath->RemoteIpAddress.Addr[13],\r
1084 IPDevPath->RemoteIpAddress.Addr[14],\r
1085 IPDevPath->RemoteIpAddress.Addr[15]\r
95276127 1086 );\r
1087 return ;\r
1088 }\r
1089\r
1090 CatPrint (\r
1091 Str,\r
1092 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 1093 IPDevPath->RemoteIpAddress.Addr[0],\r
1094 IPDevPath->RemoteIpAddress.Addr[1],\r
1095 IPDevPath->RemoteIpAddress.Addr[2],\r
1096 IPDevPath->RemoteIpAddress.Addr[3],\r
1097 IPDevPath->RemoteIpAddress.Addr[4],\r
1098 IPDevPath->RemoteIpAddress.Addr[5],\r
1099 IPDevPath->RemoteIpAddress.Addr[6],\r
1100 IPDevPath->RemoteIpAddress.Addr[7],\r
1101 IPDevPath->RemoteIpAddress.Addr[8],\r
1102 IPDevPath->RemoteIpAddress.Addr[9],\r
1103 IPDevPath->RemoteIpAddress.Addr[10],\r
1104 IPDevPath->RemoteIpAddress.Addr[11],\r
1105 IPDevPath->RemoteIpAddress.Addr[12],\r
1106 IPDevPath->RemoteIpAddress.Addr[13],\r
1107 IPDevPath->RemoteIpAddress.Addr[14],\r
1108 IPDevPath->RemoteIpAddress.Addr[15],\r
7ae9c1ce 1109 (IPDevPath->Protocol == 1) ? L"TCP" : L"UDP",\r
1110 IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r
572f5d8a 1111 IPDevPath->LocalIpAddress.Addr[0],\r
1112 IPDevPath->LocalIpAddress.Addr[1],\r
1113 IPDevPath->LocalIpAddress.Addr[2],\r
1114 IPDevPath->LocalIpAddress.Addr[3],\r
1115 IPDevPath->LocalIpAddress.Addr[4],\r
1116 IPDevPath->LocalIpAddress.Addr[5],\r
1117 IPDevPath->LocalIpAddress.Addr[6],\r
1118 IPDevPath->LocalIpAddress.Addr[7],\r
1119 IPDevPath->LocalIpAddress.Addr[8],\r
1120 IPDevPath->LocalIpAddress.Addr[9],\r
1121 IPDevPath->LocalIpAddress.Addr[10],\r
1122 IPDevPath->LocalIpAddress.Addr[11],\r
1123 IPDevPath->LocalIpAddress.Addr[12],\r
1124 IPDevPath->LocalIpAddress.Addr[13],\r
1125 IPDevPath->LocalIpAddress.Addr[14],\r
1126 IPDevPath->LocalIpAddress.Addr[15]\r
95276127 1127 );\r
1128}\r
1129\r
572f5d8a 1130/**\r
48557c65 1131 Converts an Infini Band device path structure to its string representative.\r
572f5d8a 1132\r
48557c65 1133 @param Str The string representative of input device.\r
572f5d8a 1134 @param DevPath The input device path structure.\r
1135 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1136 of the display node is used, where applicable. If DisplayOnly\r
1137 is FALSE, then the longer text representation of the display node\r
1138 is used.\r
1139 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1140 representation for a device node can be used, where applicable.\r
1141\r
1142**/\r
95276127 1143VOID\r
1144DevPathToTextInfiniBand (\r
1145 IN OUT POOL_PRINT *Str,\r
1146 IN VOID *DevPath,\r
1147 IN BOOLEAN DisplayOnly,\r
1148 IN BOOLEAN AllowShortcuts\r
1149 )\r
1150{\r
1151 INFINIBAND_DEVICE_PATH *InfiniBand;\r
1152\r
1153 InfiniBand = DevPath;\r
1154 CatPrint (\r
1155 Str,\r
cf40f28a 1156 L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",\r
95276127 1157 InfiniBand->ResourceFlags,\r
1158 InfiniBand->PortGid,\r
1159 InfiniBand->ServiceId,\r
1160 InfiniBand->TargetPortId,\r
1161 InfiniBand->DeviceId\r
1162 );\r
1163}\r
1164\r
572f5d8a 1165/**\r
48557c65 1166 Converts a UART device path structure to its string representative.\r
572f5d8a 1167\r
48557c65 1168 @param Str The string representative of input device.\r
572f5d8a 1169 @param DevPath The input device path structure.\r
1170 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1171 of the display node is used, where applicable. If DisplayOnly\r
1172 is FALSE, then the longer text representation of the display node\r
1173 is used.\r
1174 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1175 representation for a device node can be used, where applicable.\r
1176\r
1177**/\r
95276127 1178VOID\r
1179DevPathToTextUart (\r
1180 IN OUT POOL_PRINT *Str,\r
1181 IN VOID *DevPath,\r
1182 IN BOOLEAN DisplayOnly,\r
1183 IN BOOLEAN AllowShortcuts\r
1184 )\r
1185{\r
1186 UART_DEVICE_PATH *Uart;\r
1187 CHAR8 Parity;\r
1188\r
1189 Uart = DevPath;\r
1190 switch (Uart->Parity) {\r
1191 case 0:\r
1192 Parity = 'D';\r
1193 break;\r
1194\r
1195 case 1:\r
1196 Parity = 'N';\r
1197 break;\r
1198\r
1199 case 2:\r
1200 Parity = 'E';\r
1201 break;\r
1202\r
1203 case 3:\r
1204 Parity = 'O';\r
1205 break;\r
1206\r
1207 case 4:\r
1208 Parity = 'M';\r
1209 break;\r
1210\r
1211 case 5:\r
1212 Parity = 'S';\r
1213 break;\r
1214\r
1215 default:\r
1216 Parity = 'x';\r
1217 break;\r
1218 }\r
1219\r
1220 if (Uart->BaudRate == 0) {\r
1221 CatPrint (Str, L"Uart(DEFAULT,");\r
1222 } else {\r
1223 CatPrint (Str, L"Uart(%ld,", Uart->BaudRate);\r
1224 }\r
1225\r
1226 if (Uart->DataBits == 0) {\r
1227 CatPrint (Str, L"DEFAULT,");\r
1228 } else {\r
1229 CatPrint (Str, L"%d,", Uart->DataBits);\r
1230 }\r
1231\r
1232 CatPrint (Str, L"%c,", Parity);\r
1233\r
1234 switch (Uart->StopBits) {\r
1235 case 0:\r
1236 CatPrint (Str, L"D)");\r
1237 break;\r
1238\r
1239 case 1:\r
1240 CatPrint (Str, L"1)");\r
1241 break;\r
1242\r
1243 case 2:\r
1244 CatPrint (Str, L"1.5)");\r
1245 break;\r
1246\r
1247 case 3:\r
1248 CatPrint (Str, L"2)");\r
1249 break;\r
1250\r
1251 default:\r
1252 CatPrint (Str, L"x)");\r
1253 break;\r
1254 }\r
1255}\r
1256\r
572f5d8a 1257/**\r
48557c65 1258 Converts an iSCSI device path structure to its string representative.\r
572f5d8a 1259\r
48557c65 1260 @param Str The string representative of input device.\r
572f5d8a 1261 @param DevPath The input device path structure.\r
1262 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1263 of the display node is used, where applicable. If DisplayOnly\r
1264 is FALSE, then the longer text representation of the display node\r
1265 is used.\r
1266 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1267 representation for a device node can be used, where applicable.\r
1268\r
1269**/\r
95276127 1270VOID\r
1271DevPathToTextiSCSI (\r
1272 IN OUT POOL_PRINT *Str,\r
1273 IN VOID *DevPath,\r
1274 IN BOOLEAN DisplayOnly,\r
1275 IN BOOLEAN AllowShortcuts\r
1276 )\r
1277{\r
572f5d8a 1278 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
95276127 1279 UINT16 Options;\r
1280\r
572f5d8a 1281 ISCSIDevPath = DevPath;\r
95276127 1282 CatPrint (\r
1283 Str,\r
cf40f28a 1284 L"iSCSI(%a,0x%x,0x%lx,",\r
572f5d8a 1285 ISCSIDevPath->iSCSITargetName,\r
1286 ISCSIDevPath->TargetPortalGroupTag,\r
1287 ISCSIDevPath->Lun\r
95276127 1288 );\r
1289\r
572f5d8a 1290 Options = ISCSIDevPath->LoginOption;\r
1291 CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
1292 CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
1293 if (((Options >> 11) & 0x0001) != 0) {\r
95276127 1294 CatPrint (Str, L"%s,", L"None");\r
572f5d8a 1295 } else if (((Options >> 12) & 0x0001) != 0) {\r
95276127 1296 CatPrint (Str, L"%s,", L"CHAP_UNI");\r
1297 } else {\r
1298 CatPrint (Str, L"%s,", L"CHAP_BI");\r
1299\r
1300 }\r
1301\r
572f5d8a 1302 CatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
95276127 1303}\r
1304\r
572f5d8a 1305/**\r
48557c65 1306 Converts a Hard drive device path structure to its string representative.\r
572f5d8a 1307\r
48557c65 1308 @param Str The string representative of input device.\r
572f5d8a 1309 @param DevPath The input device path structure.\r
1310 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1311 of the display node is used, where applicable. If DisplayOnly\r
1312 is FALSE, then the longer text representation of the display node\r
1313 is used.\r
1314 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1315 representation for a device node can be used, where applicable.\r
1316\r
1317**/\r
95276127 1318VOID\r
1319DevPathToTextHardDrive (\r
1320 IN OUT POOL_PRINT *Str,\r
1321 IN VOID *DevPath,\r
1322 IN BOOLEAN DisplayOnly,\r
1323 IN BOOLEAN AllowShortcuts\r
1324 )\r
1325{\r
1326 HARDDRIVE_DEVICE_PATH *Hd;\r
1327\r
1328 Hd = DevPath;\r
1329 switch (Hd->SignatureType) {\r
95276127 1330 case SIGNATURE_TYPE_MBR:\r
1331 CatPrint (\r
1332 Str,\r
cf40f28a 1333 L"HD(%d,%s,0x%08x,",\r
95276127 1334 Hd->PartitionNumber,\r
1335 L"MBR",\r
1336 *((UINT32 *) (&(Hd->Signature[0])))\r
1337 );\r
1338 break;\r
1339\r
1340 case SIGNATURE_TYPE_GUID:\r
1341 CatPrint (\r
1342 Str,\r
1343 L"HD(%d,%s,%g,",\r
1344 Hd->PartitionNumber,\r
cf40f28a 1345 L"GPT",\r
95276127 1346 (EFI_GUID *) &(Hd->Signature[0])\r
1347 );\r
1348 break;\r
1349\r
1350 default:\r
cf40f28a 1351 CatPrint (\r
1352 Str,\r
1353 L"HD(%d,%d,0,",\r
1354 Hd->PartitionNumber,\r
1355 Hd->SignatureType\r
1356 );\r
95276127 1357 break;\r
1358 }\r
1359\r
cf40f28a 1360 CatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);\r
95276127 1361}\r
1362\r
572f5d8a 1363/**\r
48557c65 1364 Converts a CDROM device path structure to its string representative.\r
572f5d8a 1365\r
48557c65 1366 @param Str The string representative of input device.\r
572f5d8a 1367 @param DevPath The input device path structure.\r
1368 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1369 of the display node is used, where applicable. If DisplayOnly\r
1370 is FALSE, then the longer text representation of the display node\r
1371 is used.\r
1372 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1373 representation for a device node can be used, where applicable.\r
1374\r
1375**/\r
95276127 1376VOID\r
1377DevPathToTextCDROM (\r
1378 IN OUT POOL_PRINT *Str,\r
1379 IN VOID *DevPath,\r
1380 IN BOOLEAN DisplayOnly,\r
1381 IN BOOLEAN AllowShortcuts\r
1382 )\r
1383{\r
1384 CDROM_DEVICE_PATH *Cd;\r
1385\r
1386 Cd = DevPath;\r
572f5d8a 1387 if (DisplayOnly) {\r
cf40f28a 1388 CatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);\r
95276127 1389 return ;\r
1390 }\r
1391\r
cf40f28a 1392 CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
95276127 1393}\r
1394\r
572f5d8a 1395/**\r
48557c65 1396 Converts a File device path structure to its string representative.\r
572f5d8a 1397\r
48557c65 1398 @param Str The string representative of input device.\r
572f5d8a 1399 @param DevPath The input device path structure.\r
1400 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1401 of the display node is used, where applicable. If DisplayOnly\r
1402 is FALSE, then the longer text representation of the display node\r
1403 is used.\r
1404 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1405 representation for a device node can be used, where applicable.\r
1406\r
1407**/\r
95276127 1408VOID\r
1409DevPathToTextFilePath (\r
1410 IN OUT POOL_PRINT *Str,\r
1411 IN VOID *DevPath,\r
1412 IN BOOLEAN DisplayOnly,\r
1413 IN BOOLEAN AllowShortcuts\r
1414 )\r
1415{\r
1416 FILEPATH_DEVICE_PATH *Fp;\r
1417\r
1418 Fp = DevPath;\r
1419 CatPrint (Str, L"%s", Fp->PathName);\r
1420}\r
1421\r
572f5d8a 1422/**\r
48557c65 1423 Converts a Media protocol device path structure to its string representative.\r
572f5d8a 1424\r
48557c65 1425 @param Str The string representative of input device.\r
572f5d8a 1426 @param DevPath The input device path structure.\r
1427 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1428 of the display node is used, where applicable. If DisplayOnly\r
1429 is FALSE, then the longer text representation of the display node\r
1430 is used.\r
1431 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1432 representation for a device node can be used, where applicable.\r
1433\r
1434**/\r
95276127 1435VOID\r
1436DevPathToTextMediaProtocol (\r
1437 IN OUT POOL_PRINT *Str,\r
1438 IN VOID *DevPath,\r
1439 IN BOOLEAN DisplayOnly,\r
1440 IN BOOLEAN AllowShortcuts\r
1441 )\r
1442{\r
1443 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;\r
1444\r
1445 MediaProt = DevPath;\r
1446 CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
1447}\r
1448\r
572f5d8a 1449/**\r
48557c65 1450 Converts a Firmware Volume device path structure to its string representative.\r
572f5d8a 1451\r
48557c65 1452 @param Str The string representative of input device.\r
572f5d8a 1453 @param DevPath The input device path structure.\r
1454 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1455 of the display node is used, where applicable. If DisplayOnly\r
1456 is FALSE, then the longer text representation of the display node\r
1457 is used.\r
1458 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1459 representation for a device node can be used, where applicable.\r
1460\r
1461**/\r
cf40f28a 1462VOID\r
1463DevPathToTextFv (\r
1464 IN OUT POOL_PRINT *Str,\r
1465 IN VOID *DevPath,\r
1466 IN BOOLEAN DisplayOnly,\r
1467 IN BOOLEAN AllowShortcuts\r
1468 )\r
1469{\r
1470 MEDIA_FW_VOL_DEVICE_PATH *Fv;\r
1471\r
1472 Fv = DevPath;\r
1473 CatPrint (Str, L"Fv(%g)", &Fv->FvName);\r
1474}\r
1475\r
572f5d8a 1476/**\r
48557c65 1477 Converts a Firmware Volume File device path structure to its string representative.\r
572f5d8a 1478\r
48557c65 1479 @param Str The string representative of input device.\r
572f5d8a 1480 @param DevPath The input device path structure.\r
1481 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1482 of the display node is used, where applicable. If DisplayOnly\r
1483 is FALSE, then the longer text representation of the display node\r
1484 is used.\r
1485 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1486 representation for a device node can be used, where applicable.\r
1487\r
1488**/\r
cf40f28a 1489VOID\r
1490DevPathToTextFvFile (\r
1491 IN OUT POOL_PRINT *Str,\r
1492 IN VOID *DevPath,\r
1493 IN BOOLEAN DisplayOnly,\r
1494 IN BOOLEAN AllowShortcuts\r
1495 )\r
1496{\r
1497 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;\r
1498\r
1499 FvFile = DevPath;\r
1500 CatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);\r
1501}\r
1502\r
572f5d8a 1503/**\r
48557c65 1504 Converts a BIOS Boot Specification device path structure to its string representative.\r
572f5d8a 1505\r
48557c65 1506 @param Str The string representative of input device.\r
572f5d8a 1507 @param DevPath The input device path structure.\r
1508 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1509 of the display node is used, where applicable. If DisplayOnly\r
1510 is FALSE, then the longer text representation of the display node\r
1511 is used.\r
1512 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1513 representation for a device node can be used, where applicable.\r
1514\r
1515**/\r
95276127 1516VOID\r
1517DevPathToTextBBS (\r
1518 IN OUT POOL_PRINT *Str,\r
1519 IN VOID *DevPath,\r
1520 IN BOOLEAN DisplayOnly,\r
1521 IN BOOLEAN AllowShortcuts\r
1522 )\r
1523{\r
1524 BBS_BBS_DEVICE_PATH *Bbs;\r
1525 CHAR16 *Type;\r
1526\r
1527 Bbs = DevPath;\r
1528 switch (Bbs->DeviceType) {\r
1529 case BBS_TYPE_FLOPPY:\r
1530 Type = L"Floppy";\r
1531 break;\r
1532\r
1533 case BBS_TYPE_HARDDRIVE:\r
1534 Type = L"HD";\r
1535 break;\r
1536\r
1537 case BBS_TYPE_CDROM:\r
1538 Type = L"CDROM";\r
1539 break;\r
1540\r
1541 case BBS_TYPE_PCMCIA:\r
1542 Type = L"PCMCIA";\r
1543 break;\r
1544\r
1545 case BBS_TYPE_USB:\r
1546 Type = L"USB";\r
1547 break;\r
1548\r
1549 case BBS_TYPE_EMBEDDED_NETWORK:\r
1550 Type = L"Network";\r
1551 break;\r
1552\r
1553 default:\r
cf40f28a 1554 Type = NULL;\r
95276127 1555 break;\r
1556 }\r
1557\r
cf40f28a 1558 if (Type != NULL) {\r
1559 CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r
1560 } else {\r
1561 CatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String);\r
1562 }\r
95276127 1563\r
572f5d8a 1564 if (DisplayOnly) {\r
95276127 1565 CatPrint (Str, L")");\r
1566 return ;\r
1567 }\r
1568\r
cf40f28a 1569 CatPrint (Str, L",0x%x)", Bbs->StatusFlag);\r
95276127 1570}\r
1571\r
572f5d8a 1572/**\r
48557c65 1573 Converts an End-of-Device-Path structure to its string representative.\r
572f5d8a 1574\r
48557c65 1575 @param Str The string representative of input device.\r
572f5d8a 1576 @param DevPath The input device path structure.\r
1577 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1578 of the display node is used, where applicable. If DisplayOnly\r
1579 is FALSE, then the longer text representation of the display node\r
1580 is used.\r
1581 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1582 representation for a device node can be used, where applicable.\r
1583\r
1584**/\r
95276127 1585VOID\r
1586DevPathToTextEndInstance (\r
1587 IN OUT POOL_PRINT *Str,\r
1588 IN VOID *DevPath,\r
1589 IN BOOLEAN DisplayOnly,\r
1590 IN BOOLEAN AllowShortcuts\r
1591 )\r
1592{\r
1593 CatPrint (Str, L",");\r
1594}\r
1595\r
572f5d8a 1596/**\r
48557c65 1597 Converts an unknown device path structure to its string representative.\r
572f5d8a 1598\r
48557c65 1599 @param Str The string representative of input device.\r
572f5d8a 1600 @param DevPath The input device path structure.\r
1601 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1602 of the display node is used, where applicable. If DisplayOnly\r
1603 is FALSE, then the longer text representation of the display node\r
1604 is used.\r
1605 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1606 representation for a device node can be used, where applicable.\r
1607\r
1608**/\r
95276127 1609VOID\r
1610DevPathToTextNodeUnknown (\r
1611 IN OUT POOL_PRINT *Str,\r
1612 IN VOID *DevPath,\r
1613 IN BOOLEAN DisplayOnly,\r
1614 IN BOOLEAN AllowShortcuts\r
1615 )\r
1616{\r
1617 CatPrint (Str, L"?");\r
1618}\r
1619\r
1620GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable[] = {\r
1621 {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci},\r
1622 {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard},\r
1623 {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap},\r
1624 {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor},\r
1625 {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController},\r
1626 {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi},\r
cf40f28a 1627 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx},\r
1628 {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr},\r
95276127 1629 {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi},\r
1630 {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi},\r
1631 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre},\r
1632 {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394},\r
1633 {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb},\r
1634 {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID},\r
1635 {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit},\r
1636 {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass},\r
cf40f28a 1637 {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata},\r
95276127 1638 {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O},\r
1639 {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr},\r
1640 {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4},\r
1641 {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6},\r
1642 {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand},\r
1643 {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart},\r
1644 {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor},\r
1645 {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI},\r
1646 {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive},\r
1647 {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM},\r
1648 {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor},\r
1649 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r
1650 {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol},\r
1651 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r
cf40f28a 1652 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv},\r
1653 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile},\r
95276127 1654 {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS},\r
1655 {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance},\r
1656 {0, 0, NULL}\r
1657};\r
1658\r
572f5d8a 1659/**\r
1660 Converts a device node to its string representation.\r
1661\r
1662 @param DeviceNode A Pointer to the device node to be converted.\r
1663 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1664 of the display node is used, where applicable. If DisplayOnly\r
1665 is FALSE, then the longer text representation of the display node\r
1666 is used.\r
1667 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1668 representation for a device node can be used, where applicable.\r
1669\r
1670 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
1671 is NULL or there was insufficient memory.\r
1672\r
1673**/\r
95276127 1674CHAR16 *\r
572f5d8a 1675EFIAPI\r
95276127 1676ConvertDeviceNodeToText (\r
1677 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
1678 IN BOOLEAN DisplayOnly,\r
1679 IN BOOLEAN AllowShortcuts\r
1680 )\r
95276127 1681{\r
1682 POOL_PRINT Str;\r
1683 UINTN Index;\r
1684 UINTN NewSize;\r
1685 VOID (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
1686\r
1687 if (DeviceNode == NULL) {\r
1688 return NULL;\r
1689 }\r
1690\r
1691 ZeroMem (&Str, sizeof (Str));\r
1692\r
1693 //\r
1694 // Process the device path node\r
1695 //\r
1696 DumpNode = NULL;\r
1697 for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index++) {\r
1698 if (DevicePathType (DeviceNode) == DevPathToTextTable[Index].Type &&\r
1699 DevicePathSubType (DeviceNode) == DevPathToTextTable[Index].SubType\r
1700 ) {\r
1701 DumpNode = DevPathToTextTable[Index].Function;\r
1702 break;\r
1703 }\r
1704 }\r
1705 //\r
1706 // If not found, use a generic function\r
1707 //\r
1708 if (DumpNode == NULL) {\r
1709 DumpNode = DevPathToTextNodeUnknown;\r
1710 }\r
1711\r
1712 //\r
1713 // Print this node\r
1714 //\r
1715 DumpNode (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r
1716\r
1717 //\r
1718 // Shrink pool used for string allocation\r
1719 //\r
1720 NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
c4648495 1721 Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r
95276127 1722 ASSERT (Str.Str != NULL);\r
1723 Str.Str[Str.Len] = 0;\r
1724 return Str.Str;\r
1725}\r
1726\r
572f5d8a 1727/**\r
1728 Converts a device path to its text representation.\r
95276127 1729\r
572f5d8a 1730 @param DevicePath A Pointer to the device to be converted.\r
1731 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
95276127 1732 of the display node is used, where applicable. If DisplayOnly\r
1733 is FALSE, then the longer text representation of the display node\r
1734 is used.\r
572f5d8a 1735 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
95276127 1736 representation for a device node can be used, where applicable.\r
1737\r
572f5d8a 1738 @return A pointer to the allocated text representation of the device path or\r
1739 NULL if DeviceNode is NULL or there was insufficient memory.\r
95276127 1740\r
572f5d8a 1741**/\r
1742CHAR16 *\r
1743EFIAPI\r
1744ConvertDevicePathToText (\r
1745 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
1746 IN BOOLEAN DisplayOnly,\r
1747 IN BOOLEAN AllowShortcuts\r
1748 )\r
95276127 1749{\r
1750 POOL_PRINT Str;\r
1751 EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r
1232b214 1752 EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode;\r
95276127 1753 UINTN Index;\r
1754 UINTN NewSize;\r
1755 VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
1756\r
1757 if (DevicePath == NULL) {\r
1758 return NULL;\r
1759 }\r
1760\r
1761 ZeroMem (&Str, sizeof (Str));\r
1762\r
95276127 1763 //\r
1764 // Process each device path node\r
1765 //\r
1232b214 1766 DevPathNode = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;\r
95276127 1767 while (!IsDevicePathEnd (DevPathNode)) {\r
1768 //\r
1769 // Find the handler to dump this device path node\r
1770 //\r
1771 DumpNode = NULL;\r
7ae9c1ce 1772 for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index += 1) {\r
95276127 1773\r
1774 if (DevicePathType (DevPathNode) == DevPathToTextTable[Index].Type &&\r
1775 DevicePathSubType (DevPathNode) == DevPathToTextTable[Index].SubType\r
1776 ) {\r
1777 DumpNode = DevPathToTextTable[Index].Function;\r
1778 break;\r
1779 }\r
1780 }\r
1781 //\r
1782 // If not found, use a generic function\r
1783 //\r
1784 if (!DumpNode) {\r
1785 DumpNode = DevPathToTextNodeUnknown;\r
1786 }\r
1787 //\r
1788 // Put a path seperator in if needed\r
1789 //\r
572f5d8a 1790 if ((Str.Len != 0) && DumpNode != DevPathToTextEndInstance) {\r
cf40f28a 1791 if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') {\r
95276127 1792 CatPrint (&Str, L"/");\r
cf40f28a 1793 }\r
95276127 1794 }\r
1232b214 1795 \r
1796 AlignedDevPathNode = AllocateCopyPool (DevicePathNodeLength (DevPathNode), DevPathNode);\r
95276127 1797 //\r
1798 // Print this node of the device path\r
1799 //\r
1232b214 1800 DumpNode (&Str, AlignedDevPathNode, DisplayOnly, AllowShortcuts);\r
1801 FreePool (AlignedDevPathNode);\r
1802 \r
95276127 1803 //\r
1804 // Next device path node\r
1805 //\r
1806 DevPathNode = NextDevicePathNode (DevPathNode);\r
1807 }\r
95276127 1808\r
1809 NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
c4648495 1810 Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r
95276127 1811 ASSERT (Str.Str != NULL);\r
1812 Str.Str[Str.Len] = 0;\r
1813 return Str.Str;\r
1814}\r