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