]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
Code scrub DxeIpl, Runtime, DevicePath, FvbServicesLib, DiskIo, Partition, English...
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePathToText.c
... / ...
CommitLineData
1/** @file\r
2 DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
3\r
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
9\r
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
12\r
13**/\r
14\r
15#include "DevicePath.h"\r
16\r
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
31CHAR16 *\r
32CatPrint (\r
33 IN OUT POOL_PRINT *Str,\r
34 IN CHAR16 *Fmt,\r
35 ...\r
36 )\r
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
55 Size = StrSize (AppendStr) - sizeof (UINT16);\r
56 Size = Size + StrSize (Str->Str);\r
57 Str->Str = ReallocatePool (\r
58 StrSize (Str->Str),\r
59 Size,\r
60 Str->Str\r
61 );\r
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
75/**\r
76 Converts a PCI device path structure to its string representative.\r
77\r
78 @param Str The string representative of input device.\r
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
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
99 CatPrint (Str, L"Pci(0x%x,0x%x)", Pci->Device, Pci->Function);\r
100}\r
101\r
102/**\r
103 Converts a PC Card device path structure to its string representative.\r
104\r
105 @param Str The string representative of input device.\r
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
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
126 CatPrint (Str, L"PcCard(0x%x)", Pccard->FunctionNumber);\r
127}\r
128\r
129/**\r
130 Converts a Memory Map device path structure to its string representative.\r
131\r
132 @param Str The string representative of input device.\r
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
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
155 L"MemoryMapped(0x%x,0x%lx,0x%lx)",\r
156 MemMap->MemoryType,\r
157 MemMap->StartingAddress,\r
158 MemMap->EndingAddress\r
159 );\r
160}\r
161\r
162/**\r
163 Converts a Vendor device path structure to its string representative.\r
164\r
165 @param Str The string representative of input device.\r
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
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
186 UINTN DataLength;\r
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
211 } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) {\r
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
231 } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {\r
232 CatPrint (\r
233 Str,\r
234 L"SAS(0x%lx,0x%lx,0x%x,",\r
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
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
249 );\r
250 if ((Info & 0x0f) == 1) {\r
251 CatPrint (Str, L"0,");\r
252 } else {\r
253 CatPrint (Str, L"0x%x,", (Info >> 8) & 0xff);\r
254 }\r
255 } else {\r
256 CatPrint (Str, L"0,0,0,0,");\r
257 }\r
258\r
259 CatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
260 return ;\r
261 } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r
262 CatPrint (Str, L"DebugPort()");\r
263 return ;\r
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
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
284 }\r
285\r
286 CatPrint (Str, L")");\r
287}\r
288\r
289/**\r
290 Converts a Controller device path structure to its string representative.\r
291\r
292 @param Str The string representative of input device.\r
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
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
315 L"Ctrl(0x%x)",\r
316 Controller->ControllerNumber\r
317 );\r
318}\r
319\r
320/**\r
321 Converts a ACPI device path structure to its string representative.\r
322\r
323 @param Str The string representative of input device.\r
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
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
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
349\r
350 case 0x0604:\r
351 CatPrint (Str, L"Floppy(0x%x)", Acpi->UID);\r
352 break;\r
353\r
354 case 0x0301:\r
355 CatPrint (Str, L"Keyboard(0x%x)", Acpi->UID);\r
356 break;\r
357\r
358 case 0x0501:\r
359 CatPrint (Str, L"Serial(0x%x)", Acpi->UID);\r
360 break;\r
361\r
362 case 0x0401:\r
363 CatPrint (Str, L"ParallelPort(0x%x)", Acpi->UID);\r
364 break;\r
365\r
366 default:\r
367 CatPrint (Str, L"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);\r
368 break;\r
369 }\r
370 } else {\r
371 CatPrint (Str, L"Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID);\r
372 }\r
373}\r
374\r
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
382VOID\r
383EisaIdToText (\r
384 IN UINT32 EisaId,\r
385 IN OUT CHAR16 *Text\r
386 )\r
387{\r
388 CHAR16 PnpIdStr[17];\r
389\r
390 //\r
391 //UnicodeSPrint ("%X", 0x0a03) => "0000000000000A03"\r
392 //\r
393 UnicodeSPrint (PnpIdStr, 17 * 2, L"%16X", EisaId >> 16);\r
394\r
395 UnicodeSPrint (\r
396 Text,\r
397 sizeof (CHAR16) + sizeof (CHAR16) + sizeof (CHAR16) + sizeof (PnpIdStr),\r
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
405\r
406/**\r
407 Converts a ACPI extended HID device path structure to its string representative.\r
408\r
409 @param Str The string representative of input device.\r
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
419VOID\r
420DevPathToTextAcpiEx (\r
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
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
463\r
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
469\r
470 if (AcpiEx->CID == 0) {\r
471 CatPrint (Str, L"%a)", CIDStr);\r
472 } else {\r
473 CatPrint (Str, L"%s)", CIDText);\r
474 }\r
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
486 }\r
487 }\r
488}\r
489\r
490/**\r
491 Converts a ACPI address device path structure to its string representative.\r
492\r
493 @param Str The string representative of input device.\r
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
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
523 }\r
524 CatPrint (Str, L")");\r
525}\r
526\r
527/**\r
528 Converts a ATAPI device path structure to its string representative.\r
529\r
530 @param Str The string representative of input device.\r
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
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
553 CatPrint (Str, L"Ata(0x%x)", Atapi->Lun);\r
554 } else {\r
555 CatPrint (\r
556 Str,\r
557 L"Ata(%s,%s,0x%x)",\r
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
565/**\r
566 Converts a SCSI device path structure to its string representative.\r
567\r
568 @param Str The string representative of input device.\r
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
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
589 CatPrint (Str, L"Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun);\r
590}\r
591\r
592/**\r
593 Converts a Fibre device path structure to its string representative.\r
594\r
595 @param Str The string representative of input device.\r
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
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
616 CatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);\r
617}\r
618\r
619/**\r
620 Converts a 1394 device path structure to its string representative.\r
621\r
622 @param Str The string representative of input device.\r
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
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
640 F1394_DEVICE_PATH *F1394DevPath;\r
641\r
642 F1394DevPath = DevPath;\r
643 //\r
644 // Guid has format of IEEE-EUI64\r
645 //\r
646 CatPrint (Str, L"I1394(%016lx)", F1394DevPath->Guid);\r
647}\r
648\r
649/**\r
650 Converts a USB device path structure to its string representative.\r
651\r
652 @param Str The string representative of input device.\r
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
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
673 CatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);\r
674}\r
675\r
676/**\r
677 Converts a USB WWID device path structure to its string representative.\r
678\r
679 @param Str The string representative of input device.\r
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
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
698 CHAR16 *SerialNumberStr;\r
699 CHAR16 *NewStr;\r
700 UINT16 Length;\r
701\r
702 UsbWWId = DevPath;\r
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
715 CatPrint (\r
716 Str,\r
717 L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",\r
718 UsbWWId->VendorId,\r
719 UsbWWId->ProductId,\r
720 UsbWWId->InterfaceNumber,\r
721 SerialNumberStr\r
722 );\r
723}\r
724\r
725/**\r
726 Converts a Logic Unit device path structure to its string representative.\r
727\r
728 @param Str The string representative of input device.\r
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
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
749 CatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun);\r
750}\r
751\r
752/**\r
753 Converts a USB class device path structure to its string representative.\r
754\r
755 @param Str The string representative of input device.\r
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
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
774 BOOLEAN IsKnownSubClass;\r
775\r
776\r
777 UsbClass = DevPath;\r
778\r
779 IsKnownSubClass = TRUE;\r
780 switch (UsbClass->DeviceClass) {\r
781 case USB_CLASS_AUDIO:\r
782 CatPrint (Str, L"UsbAudio");\r
783 break;\r
784\r
785 case USB_CLASS_CDCCONTROL:\r
786 CatPrint (Str, L"UsbCDCControl");\r
787 break;\r
788\r
789 case USB_CLASS_HID:\r
790 CatPrint (Str, L"UsbHID");\r
791 break;\r
792\r
793 case USB_CLASS_IMAGE:\r
794 CatPrint (Str, L"UsbImage");\r
795 break;\r
796\r
797 case USB_CLASS_PRINTER:\r
798 CatPrint (Str, L"UsbPrinter");\r
799 break;\r
800\r
801 case USB_CLASS_MASS_STORAGE:\r
802 CatPrint (Str, L"UsbMassStorage");\r
803 break;\r
804\r
805 case USB_CLASS_HUB:\r
806 CatPrint (Str, L"UsbHub");\r
807 break;\r
808\r
809 case USB_CLASS_CDCDATA:\r
810 CatPrint (Str, L"UsbCDCData");\r
811 break;\r
812\r
813 case USB_CLASS_SMART_CARD:\r
814 CatPrint (Str, L"UsbSmartCard");\r
815 break;\r
816\r
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
848 CatPrint (\r
849 Str,\r
850 L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",\r
851 UsbClass->VendorId,\r
852 UsbClass->ProductId,\r
853 UsbClass->DeviceProtocol\r
854 );\r
855 return;\r
856 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {\r
857 CatPrint (\r
858 Str,\r
859 L"UsbIrdaBridge(0x%x,0x%x,0x%x)",\r
860 UsbClass->VendorId,\r
861 UsbClass->ProductId,\r
862 UsbClass->DeviceProtocol\r
863 );\r
864 return;\r
865 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {\r
866 CatPrint (\r
867 Str,\r
868 L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",\r
869 UsbClass->VendorId,\r
870 UsbClass->ProductId,\r
871 UsbClass->DeviceProtocol\r
872 );\r
873 return;\r
874 }\r
875 }\r
876\r
877 CatPrint (\r
878 Str,\r
879 L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",\r
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
888/**\r
889 Converts a SATA device path structure to its string representative.\r
890\r
891 @param Str The string representative of input device.\r
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
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
915 (UINTN) Sata->HBAPortNumber,\r
916 (UINTN) Sata->PortMultiplierPortNumber,\r
917 (UINTN) Sata->Lun\r
918 );\r
919}\r
920\r
921/**\r
922 Converts a I20 device path structure to its string representative.\r
923\r
924 @param Str The string representative of input device.\r
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
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
942 I2O_DEVICE_PATH *I2ODevPath;\r
943\r
944 I2ODevPath = DevPath;\r
945 CatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid);\r
946}\r
947\r
948/**\r
949 Converts a MAC address device path structure to its string representative.\r
950\r
951 @param Str The string representative of input device.\r
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
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
969 MAC_ADDR_DEVICE_PATH *MacDevPath;\r
970 UINTN HwAddressSize;\r
971 UINTN Index;\r
972\r
973 MacDevPath = DevPath;\r
974\r
975 HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
976 if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {\r
977 HwAddressSize = 6;\r
978 }\r
979\r
980 CatPrint (Str, L"MAC(");\r
981\r
982 for (Index = 0; Index < HwAddressSize; Index++) {\r
983 CatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]);\r
984 }\r
985\r
986 CatPrint (Str, L",0x%x)", MacDevPath->IfType);\r
987}\r
988\r
989/**\r
990 Converts a IPv4 device path structure to its string representative.\r
991\r
992 @param Str The string representative of input device.\r
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
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
1010 IPv4_DEVICE_PATH *IPDevPath;\r
1011\r
1012 IPDevPath = DevPath;\r
1013 if (DisplayOnly) {\r
1014 CatPrint (\r
1015 Str,\r
1016 L"IPv4(%d.%d.%d.%d)",\r
1017 IPDevPath->RemoteIpAddress.Addr[0],\r
1018 IPDevPath->RemoteIpAddress.Addr[1],\r
1019 IPDevPath->RemoteIpAddress.Addr[2],\r
1020 IPDevPath->RemoteIpAddress.Addr[3]\r
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
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
1038 );\r
1039}\r
1040\r
1041/**\r
1042 Converts a IPv6 device path structure to its string representative.\r
1043\r
1044 @param Str The string representative of input device.\r
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
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
1062 IPv6_DEVICE_PATH *IPDevPath;\r
1063\r
1064 IPDevPath = DevPath;\r
1065 if (DisplayOnly) {\r
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
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
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
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
1126 );\r
1127}\r
1128\r
1129/**\r
1130 Converts an Infini Band device path structure to its string representative.\r
1131\r
1132 @param Str The string representative of input device.\r
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
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
1155 L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",\r
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
1164/**\r
1165 Converts a UART device path structure to its string representative.\r
1166\r
1167 @param Str The string representative of input device.\r
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
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
1256/**\r
1257 Converts an iSCSI device path structure to its string representative.\r
1258\r
1259 @param Str The string representative of input device.\r
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
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
1277 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
1278 UINT16 Options;\r
1279\r
1280 ISCSIDevPath = DevPath;\r
1281 CatPrint (\r
1282 Str,\r
1283 L"iSCSI(%a,0x%x,0x%lx,",\r
1284 ISCSIDevPath->iSCSITargetName,\r
1285 ISCSIDevPath->TargetPortalGroupTag,\r
1286 ISCSIDevPath->Lun\r
1287 );\r
1288\r
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
1293 CatPrint (Str, L"%s,", L"None");\r
1294 } else if (((Options >> 12) & 0x0001) != 0) {\r
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
1301 CatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
1302}\r
1303\r
1304/**\r
1305 Converts a Hard drive device path structure to its string representative.\r
1306\r
1307 @param Str The string representative of input device.\r
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
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
1329 case SIGNATURE_TYPE_MBR:\r
1330 CatPrint (\r
1331 Str,\r
1332 L"HD(%d,%s,0x%08x,",\r
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
1344 L"GPT",\r
1345 (EFI_GUID *) &(Hd->Signature[0])\r
1346 );\r
1347 break;\r
1348\r
1349 default:\r
1350 CatPrint (\r
1351 Str,\r
1352 L"HD(%d,%d,0,",\r
1353 Hd->PartitionNumber,\r
1354 Hd->SignatureType\r
1355 );\r
1356 break;\r
1357 }\r
1358\r
1359 CatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);\r
1360}\r
1361\r
1362/**\r
1363 Converts a CDROM device path structure to its string representative.\r
1364\r
1365 @param Str The string representative of input device.\r
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
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
1386 if (DisplayOnly) {\r
1387 CatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);\r
1388 return ;\r
1389 }\r
1390\r
1391 CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
1392}\r
1393\r
1394/**\r
1395 Converts a File device path structure to its string representative.\r
1396\r
1397 @param Str The string representative of input device.\r
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
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
1421/**\r
1422 Converts a Media protocol device path structure to its string representative.\r
1423\r
1424 @param Str The string representative of input device.\r
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
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
1448/**\r
1449 Converts a Firmware Volume device path structure to its string representative.\r
1450\r
1451 @param Str The string representative of input device.\r
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
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
1475/**\r
1476 Converts a Firmware Volume File device path structure to its string representative.\r
1477\r
1478 @param Str The string representative of input device.\r
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
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
1502/**\r
1503 Converts a BIOS Boot Specification device path structure to its string representative.\r
1504\r
1505 @param Str The string representative of input device.\r
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
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
1553 Type = NULL;\r
1554 break;\r
1555 }\r
1556\r
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
1562\r
1563 if (DisplayOnly) {\r
1564 CatPrint (Str, L")");\r
1565 return ;\r
1566 }\r
1567\r
1568 CatPrint (Str, L",0x%x)", Bbs->StatusFlag);\r
1569}\r
1570\r
1571/**\r
1572 Converts an End-of-Device-Path structure to its string representative.\r
1573\r
1574 @param Str The string representative of input device.\r
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
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
1595/**\r
1596 Converts an unknown device path structure to its string representative.\r
1597\r
1598 @param Str The string representative of input device.\r
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
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
1626 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx},\r
1627 {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr},\r
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
1636 {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata},\r
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
1651 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv},\r
1652 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile},\r
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
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
1673CHAR16 *\r
1674EFIAPI\r
1675ConvertDeviceNodeToText (\r
1676 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
1677 IN BOOLEAN DisplayOnly,\r
1678 IN BOOLEAN AllowShortcuts\r
1679 )\r
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
1720 Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r
1721 ASSERT (Str.Str != NULL);\r
1722 Str.Str[Str.Len] = 0;\r
1723 return Str.Str;\r
1724}\r
1725\r
1726/**\r
1727 Converts a device path to its text representation.\r
1728\r
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
1731 of the display node is used, where applicable. If DisplayOnly\r
1732 is FALSE, then the longer text representation of the display node\r
1733 is used.\r
1734 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1735 representation for a device node can be used, where applicable.\r
1736\r
1737 @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
1739\r
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
1748{\r
1749 POOL_PRINT Str;\r
1750 EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r
1751 EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode;\r
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
1762 //\r
1763 // Process each device path node\r
1764 //\r
1765 DevPathNode = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;\r
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
1789 if ((Str.Len != 0) && DumpNode != DevPathToTextEndInstance) {\r
1790 if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') {\r
1791 CatPrint (&Str, L"/");\r
1792 }\r
1793 }\r
1794 \r
1795 AlignedDevPathNode = AllocateCopyPool (DevicePathNodeLength (DevPathNode), DevPathNode);\r
1796 //\r
1797 // Print this node of the device path\r
1798 //\r
1799 DumpNode (&Str, AlignedDevPathNode, DisplayOnly, AllowShortcuts);\r
1800 FreePool (AlignedDevPathNode);\r
1801 \r
1802 //\r
1803 // Next device path node\r
1804 //\r
1805 DevPathNode = NextDevicePathNode (DevPathNode);\r
1806 }\r
1807\r
1808 NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
1809 Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r
1810 ASSERT (Str.Str != NULL);\r
1811 Str.Str[Str.Len] = 0;\r
1812 return Str.Str;\r
1813}\r