]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
fixed the wrong format.
[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)", (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) {\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 a IPv4 device path structure to its string representative.\r
1001\r
1002 @param Str The string representative of input device.\r
1003 @param DevPath The input device path structure.\r
1004 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1005 of the display node is used, where applicable. If DisplayOnly\r
1006 is FALSE, then the longer text representation of the display node\r
1007 is used.\r
1008 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1009 representation for a device node can be used, where applicable.\r
1010\r
1011**/\r
1012VOID\r
1013DevPathToTextIPv4 (\r
1014 IN OUT POOL_PRINT *Str,\r
1015 IN VOID *DevPath,\r
1016 IN BOOLEAN DisplayOnly,\r
1017 IN BOOLEAN AllowShortcuts\r
1018 )\r
1019{\r
1020 IPv4_DEVICE_PATH *IPDevPath;\r
1021\r
1022 IPDevPath = DevPath;\r
1023 if (DisplayOnly) {\r
1024 CatPrint (\r
1025 Str,\r
1026 L"IPv4(%d.%d.%d.%d)",\r
1027 (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
1028 (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
1029 (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
1030 (UINTN) IPDevPath->RemoteIpAddress.Addr[3]\r
1031 );\r
1032 return ;\r
1033 }\r
1034\r
1035 CatPrint (\r
1036 Str,\r
1037 L"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",\r
1038 (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
1039 (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
1040 (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
1041 (UINTN) IPDevPath->RemoteIpAddress.Addr[3],\r
1042 (IPDevPath->Protocol == 1) ? L"TCP" : L"UDP",\r
1043 IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r
1044 (UINTN) IPDevPath->LocalIpAddress.Addr[0],\r
1045 (UINTN) IPDevPath->LocalIpAddress.Addr[1],\r
1046 (UINTN) IPDevPath->LocalIpAddress.Addr[2],\r
1047 (UINTN) IPDevPath->LocalIpAddress.Addr[3]\r
1048 );\r
1049}\r
1050\r
1051/**\r
1052 Converts a IPv6 device path structure to its string representative.\r
1053\r
1054 @param Str The string representative of input device.\r
1055 @param DevPath The input device path structure.\r
1056 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1057 of the display node is used, where applicable. If DisplayOnly\r
1058 is FALSE, then the longer text representation of the display node\r
1059 is used.\r
1060 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1061 representation for a device node can be used, where applicable.\r
1062\r
1063**/\r
1064VOID\r
1065DevPathToTextIPv6 (\r
1066 IN OUT POOL_PRINT *Str,\r
1067 IN VOID *DevPath,\r
1068 IN BOOLEAN DisplayOnly,\r
1069 IN BOOLEAN AllowShortcuts\r
1070 )\r
1071{\r
1072 IPv6_DEVICE_PATH *IPDevPath;\r
1073\r
1074 IPDevPath = DevPath;\r
1075 if (DisplayOnly) {\r
1076 CatPrint (\r
1077 Str,\r
1078 L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
1079 (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
1080 (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
1081 (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
1082 (UINTN) IPDevPath->RemoteIpAddress.Addr[3],\r
1083 (UINTN) IPDevPath->RemoteIpAddress.Addr[4],\r
1084 (UINTN) IPDevPath->RemoteIpAddress.Addr[5],\r
1085 (UINTN) IPDevPath->RemoteIpAddress.Addr[6],\r
1086 (UINTN) IPDevPath->RemoteIpAddress.Addr[7],\r
1087 (UINTN) IPDevPath->RemoteIpAddress.Addr[8],\r
1088 (UINTN) IPDevPath->RemoteIpAddress.Addr[9],\r
1089 (UINTN) IPDevPath->RemoteIpAddress.Addr[10],\r
1090 (UINTN) IPDevPath->RemoteIpAddress.Addr[11],\r
1091 (UINTN) IPDevPath->RemoteIpAddress.Addr[12],\r
1092 (UINTN) IPDevPath->RemoteIpAddress.Addr[13],\r
1093 (UINTN) IPDevPath->RemoteIpAddress.Addr[14],\r
1094 (UINTN) IPDevPath->RemoteIpAddress.Addr[15]\r
1095 );\r
1096 return ;\r
1097 }\r
1098\r
1099 CatPrint (\r
1100 Str,\r
1101 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
1102 (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
1103 (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
1104 (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
1105 (UINTN) IPDevPath->RemoteIpAddress.Addr[3],\r
1106 (UINTN) IPDevPath->RemoteIpAddress.Addr[4],\r
1107 (UINTN) IPDevPath->RemoteIpAddress.Addr[5],\r
1108 (UINTN) IPDevPath->RemoteIpAddress.Addr[6],\r
1109 (UINTN) IPDevPath->RemoteIpAddress.Addr[7],\r
1110 (UINTN) IPDevPath->RemoteIpAddress.Addr[8],\r
1111 (UINTN) IPDevPath->RemoteIpAddress.Addr[9],\r
1112 (UINTN) IPDevPath->RemoteIpAddress.Addr[10],\r
1113 (UINTN) IPDevPath->RemoteIpAddress.Addr[11],\r
1114 (UINTN) IPDevPath->RemoteIpAddress.Addr[12],\r
1115 (UINTN) IPDevPath->RemoteIpAddress.Addr[13],\r
1116 (UINTN) IPDevPath->RemoteIpAddress.Addr[14],\r
1117 (UINTN) IPDevPath->RemoteIpAddress.Addr[15],\r
1118 (IPDevPath->Protocol == 1) ? L"TCP" : L"UDP",\r
1119 IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r
1120 (UINTN) IPDevPath->LocalIpAddress.Addr[0],\r
1121 (UINTN) IPDevPath->LocalIpAddress.Addr[1],\r
1122 (UINTN) IPDevPath->LocalIpAddress.Addr[2],\r
1123 (UINTN) IPDevPath->LocalIpAddress.Addr[3],\r
1124 (UINTN) IPDevPath->LocalIpAddress.Addr[4],\r
1125 (UINTN) IPDevPath->LocalIpAddress.Addr[5],\r
1126 (UINTN) IPDevPath->LocalIpAddress.Addr[6],\r
1127 (UINTN) IPDevPath->LocalIpAddress.Addr[7],\r
1128 (UINTN) IPDevPath->LocalIpAddress.Addr[8],\r
1129 (UINTN) IPDevPath->LocalIpAddress.Addr[9],\r
1130 (UINTN) IPDevPath->LocalIpAddress.Addr[10],\r
1131 (UINTN) IPDevPath->LocalIpAddress.Addr[11],\r
1132 (UINTN) IPDevPath->LocalIpAddress.Addr[12],\r
1133 (UINTN) IPDevPath->LocalIpAddress.Addr[13],\r
1134 (UINTN) IPDevPath->LocalIpAddress.Addr[14],\r
1135 (UINTN) IPDevPath->LocalIpAddress.Addr[15]\r
1136 );\r
1137}\r
1138\r
1139/**\r
1140 Converts an Infini Band device path structure to its string representative.\r
1141\r
1142 @param Str The string representative of input device.\r
1143 @param DevPath The input device path structure.\r
1144 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1145 of the display node is used, where applicable. If DisplayOnly\r
1146 is FALSE, then the longer text representation of the display node\r
1147 is used.\r
1148 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1149 representation for a device node can be used, where applicable.\r
1150\r
1151**/\r
1152VOID\r
1153DevPathToTextInfiniBand (\r
1154 IN OUT POOL_PRINT *Str,\r
1155 IN VOID *DevPath,\r
1156 IN BOOLEAN DisplayOnly,\r
1157 IN BOOLEAN AllowShortcuts\r
1158 )\r
1159{\r
1160 INFINIBAND_DEVICE_PATH *InfiniBand;\r
1161\r
1162 InfiniBand = DevPath;\r
1163 CatPrint (\r
1164 Str,\r
1165 L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",\r
1166 (UINTN) InfiniBand->ResourceFlags,\r
1167 InfiniBand->PortGid,\r
1168 InfiniBand->ServiceId,\r
1169 InfiniBand->TargetPortId,\r
1170 InfiniBand->DeviceId\r
1171 );\r
1172}\r
1173\r
1174/**\r
1175 Converts a UART device path structure to its string representative.\r
1176\r
1177 @param Str The string representative of input device.\r
1178 @param DevPath The input device path structure.\r
1179 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1180 of the display node is used, where applicable. If DisplayOnly\r
1181 is FALSE, then the longer text representation of the display node\r
1182 is used.\r
1183 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1184 representation for a device node can be used, where applicable.\r
1185\r
1186**/\r
1187VOID\r
1188DevPathToTextUart (\r
1189 IN OUT POOL_PRINT *Str,\r
1190 IN VOID *DevPath,\r
1191 IN BOOLEAN DisplayOnly,\r
1192 IN BOOLEAN AllowShortcuts\r
1193 )\r
1194{\r
1195 UART_DEVICE_PATH *Uart;\r
1196 CHAR8 Parity;\r
1197\r
1198 Uart = DevPath;\r
1199 switch (Uart->Parity) {\r
1200 case 0:\r
1201 Parity = 'D';\r
1202 break;\r
1203\r
1204 case 1:\r
1205 Parity = 'N';\r
1206 break;\r
1207\r
1208 case 2:\r
1209 Parity = 'E';\r
1210 break;\r
1211\r
1212 case 3:\r
1213 Parity = 'O';\r
1214 break;\r
1215\r
1216 case 4:\r
1217 Parity = 'M';\r
1218 break;\r
1219\r
1220 case 5:\r
1221 Parity = 'S';\r
1222 break;\r
1223\r
1224 default:\r
1225 Parity = 'x';\r
1226 break;\r
1227 }\r
1228\r
1229 if (Uart->BaudRate == 0) {\r
1230 CatPrint (Str, L"Uart(DEFAULT,");\r
1231 } else {\r
1232 CatPrint (Str, L"Uart(%ld,", Uart->BaudRate);\r
1233 }\r
1234\r
1235 if (Uart->DataBits == 0) {\r
1236 CatPrint (Str, L"DEFAULT,");\r
1237 } else {\r
1238 CatPrint (Str, L"%d,", (UINTN) Uart->DataBits);\r
1239 }\r
1240\r
1241 CatPrint (Str, L"%c,", Parity);\r
1242\r
1243 switch (Uart->StopBits) {\r
1244 case 0:\r
1245 CatPrint (Str, L"D)");\r
1246 break;\r
1247\r
1248 case 1:\r
1249 CatPrint (Str, L"1)");\r
1250 break;\r
1251\r
1252 case 2:\r
1253 CatPrint (Str, L"1.5)");\r
1254 break;\r
1255\r
1256 case 3:\r
1257 CatPrint (Str, L"2)");\r
1258 break;\r
1259\r
1260 default:\r
1261 CatPrint (Str, L"x)");\r
1262 break;\r
1263 }\r
1264}\r
1265\r
1266/**\r
1267 Converts an iSCSI device path structure to its string representative.\r
1268\r
1269 @param Str The string representative of input device.\r
1270 @param DevPath The input device path structure.\r
1271 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1272 of the display node is used, where applicable. If DisplayOnly\r
1273 is FALSE, then the longer text representation of the display node\r
1274 is used.\r
1275 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1276 representation for a device node can be used, where applicable.\r
1277\r
1278**/\r
1279VOID\r
1280DevPathToTextiSCSI (\r
1281 IN OUT POOL_PRINT *Str,\r
1282 IN VOID *DevPath,\r
1283 IN BOOLEAN DisplayOnly,\r
1284 IN BOOLEAN AllowShortcuts\r
1285 )\r
1286{\r
1287 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
1288 UINT16 Options;\r
1289\r
1290 ISCSIDevPath = DevPath;\r
1291 CatPrint (\r
1292 Str,\r
1293 L"iSCSI(%a,0x%x,0x%lx,",\r
1294 ISCSIDevPath->TargetName,\r
1295 (UINTN) ISCSIDevPath->TargetPortalGroupTag,\r
1296 ISCSIDevPath->Lun\r
1297 );\r
1298\r
1299 Options = ISCSIDevPath->LoginOption;\r
1300 CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
1301 CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
1302 if (((Options >> 11) & 0x0001) != 0) {\r
1303 CatPrint (Str, L"%s,", L"None");\r
1304 } else if (((Options >> 12) & 0x0001) != 0) {\r
1305 CatPrint (Str, L"%s,", L"CHAP_UNI");\r
1306 } else {\r
1307 CatPrint (Str, L"%s,", L"CHAP_BI");\r
1308\r
1309 }\r
1310\r
1311 CatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
1312}\r
1313\r
1314/**\r
1315 Converts a Hard drive device path structure to its string representative.\r
1316\r
1317 @param Str The string representative of input device.\r
1318 @param DevPath The input device path structure.\r
1319 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1320 of the display node is used, where applicable. If DisplayOnly\r
1321 is FALSE, then the longer text representation of the display node\r
1322 is used.\r
1323 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1324 representation for a device node can be used, where applicable.\r
1325\r
1326**/\r
1327VOID\r
1328DevPathToTextHardDrive (\r
1329 IN OUT POOL_PRINT *Str,\r
1330 IN VOID *DevPath,\r
1331 IN BOOLEAN DisplayOnly,\r
1332 IN BOOLEAN AllowShortcuts\r
1333 )\r
1334{\r
1335 HARDDRIVE_DEVICE_PATH *Hd;\r
1336\r
1337 Hd = DevPath;\r
1338 switch (Hd->SignatureType) {\r
1339 case SIGNATURE_TYPE_MBR:\r
1340 CatPrint (\r
1341 Str,\r
1342 L"HD(%d,%s,0x%08x,",\r
1343 (UINTN) Hd->PartitionNumber,\r
1344 L"MBR",\r
1345 (UINTN) *((UINT32 *) (&(Hd->Signature[0])))\r
1346 );\r
1347 break;\r
1348\r
1349 case SIGNATURE_TYPE_GUID:\r
1350 CatPrint (\r
1351 Str,\r
1352 L"HD(%d,%s,%g,",\r
1353 (UINTN) Hd->PartitionNumber,\r
1354 L"GPT",\r
1355 (EFI_GUID *) &(Hd->Signature[0])\r
1356 );\r
1357 break;\r
1358\r
1359 default:\r
1360 CatPrint (\r
1361 Str,\r
1362 L"HD(%d,%d,0,",\r
1363 (UINTN) Hd->PartitionNumber,\r
1364 (UINTN) Hd->SignatureType\r
1365 );\r
1366 break;\r
1367 }\r
1368\r
1369 CatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);\r
1370}\r
1371\r
1372/**\r
1373 Converts a CDROM device path structure to its string representative.\r
1374\r
1375 @param Str The string representative of input device.\r
1376 @param DevPath The input device path structure.\r
1377 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1378 of the display node is used, where applicable. If DisplayOnly\r
1379 is FALSE, then the longer text representation of the display node\r
1380 is used.\r
1381 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1382 representation for a device node can be used, where applicable.\r
1383\r
1384**/\r
1385VOID\r
1386DevPathToTextCDROM (\r
1387 IN OUT POOL_PRINT *Str,\r
1388 IN VOID *DevPath,\r
1389 IN BOOLEAN DisplayOnly,\r
1390 IN BOOLEAN AllowShortcuts\r
1391 )\r
1392{\r
1393 CDROM_DEVICE_PATH *Cd;\r
1394\r
1395 Cd = DevPath;\r
1396 if (DisplayOnly) {\r
1397 CatPrint (Str, L"CDROM(0x%x)", (UINTN) Cd->BootEntry);\r
1398 return ;\r
1399 }\r
1400\r
1401 CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", (UINTN) Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
1402}\r
1403\r
1404/**\r
1405 Converts a File device path structure to its string representative.\r
1406\r
1407 @param Str The string representative of input device.\r
1408 @param DevPath The input device path structure.\r
1409 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1410 of the display node is used, where applicable. If DisplayOnly\r
1411 is FALSE, then the longer text representation of the display node\r
1412 is used.\r
1413 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1414 representation for a device node can be used, where applicable.\r
1415\r
1416**/\r
1417VOID\r
1418DevPathToTextFilePath (\r
1419 IN OUT POOL_PRINT *Str,\r
1420 IN VOID *DevPath,\r
1421 IN BOOLEAN DisplayOnly,\r
1422 IN BOOLEAN AllowShortcuts\r
1423 )\r
1424{\r
1425 FILEPATH_DEVICE_PATH *Fp;\r
1426\r
1427 Fp = DevPath;\r
1428 CatPrint (Str, L"%s", Fp->PathName);\r
1429}\r
1430\r
1431/**\r
1432 Converts a Media protocol device path structure to its string representative.\r
1433\r
1434 @param Str The string representative of input device.\r
1435 @param DevPath The input device path structure.\r
1436 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1437 of the display node is used, where applicable. If DisplayOnly\r
1438 is FALSE, then the longer text representation of the display node\r
1439 is used.\r
1440 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1441 representation for a device node can be used, where applicable.\r
1442\r
1443**/\r
1444VOID\r
1445DevPathToTextMediaProtocol (\r
1446 IN OUT POOL_PRINT *Str,\r
1447 IN VOID *DevPath,\r
1448 IN BOOLEAN DisplayOnly,\r
1449 IN BOOLEAN AllowShortcuts\r
1450 )\r
1451{\r
1452 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;\r
1453\r
1454 MediaProt = DevPath;\r
1455 CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
1456}\r
1457\r
1458/**\r
1459 Converts a Firmware Volume device path structure to its string representative.\r
1460\r
1461 @param Str The string representative of input device.\r
1462 @param DevPath The input device path structure.\r
1463 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1464 of the display node is used, where applicable. If DisplayOnly\r
1465 is FALSE, then the longer text representation of the display node\r
1466 is used.\r
1467 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1468 representation for a device node can be used, where applicable.\r
1469\r
1470**/\r
1471VOID\r
1472DevPathToTextFv (\r
1473 IN OUT POOL_PRINT *Str,\r
1474 IN VOID *DevPath,\r
1475 IN BOOLEAN DisplayOnly,\r
1476 IN BOOLEAN AllowShortcuts\r
1477 )\r
1478{\r
1479 MEDIA_FW_VOL_DEVICE_PATH *Fv;\r
1480\r
1481 Fv = DevPath;\r
1482 CatPrint (Str, L"Fv(%g)", &Fv->FvName);\r
1483}\r
1484\r
1485/**\r
1486 Converts a Firmware Volume File device path structure to its string representative.\r
1487\r
1488 @param Str The string representative of input device.\r
1489 @param DevPath The input device path structure.\r
1490 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1491 of the display node is used, where applicable. If DisplayOnly\r
1492 is FALSE, then the longer text representation of the display node\r
1493 is used.\r
1494 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1495 representation for a device node can be used, where applicable.\r
1496\r
1497**/\r
1498VOID\r
1499DevPathToTextFvFile (\r
1500 IN OUT POOL_PRINT *Str,\r
1501 IN VOID *DevPath,\r
1502 IN BOOLEAN DisplayOnly,\r
1503 IN BOOLEAN AllowShortcuts\r
1504 )\r
1505{\r
1506 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;\r
1507\r
1508 FvFile = DevPath;\r
1509 CatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);\r
1510}\r
1511\r
1512/**\r
1513 Converts a Relative Offset device path structure to its string representative.\r
1514\r
1515 @param Str The string representative of input device.\r
1516 @param DevPath The input device path structure.\r
1517 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1518 of the display node is used, where applicable. If DisplayOnly\r
1519 is FALSE, then the longer text representation of the display node\r
1520 is used.\r
1521 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1522 representation for a device node can be used, where applicable.\r
1523\r
1524**/\r
1525VOID\r
1526DevPathRelativeOffsetRange (\r
1527 IN OUT POOL_PRINT *Str,\r
1528 IN VOID *DevPath,\r
1529 IN BOOLEAN DisplayOnly,\r
1530 IN BOOLEAN AllowShortcuts\r
1531 )\r
1532{\r
1533 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
1534\r
1535 Offset = DevPath;\r
1536 CatPrint (\r
1537 Str,\r
1538 L"Offset(%lx,%lx)",\r
1539 Offset->StartingOffset,\r
1540 Offset->EndingOffset\r
1541 );\r
1542}\r
1543\r
1544/**\r
1545 Converts a BIOS Boot Specification device path structure to its string representative.\r
1546\r
1547 @param Str The string representative of input device.\r
1548 @param DevPath The input device path structure.\r
1549 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1550 of the display node is used, where applicable. If DisplayOnly\r
1551 is FALSE, then the longer text representation of the display node\r
1552 is used.\r
1553 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1554 representation for a device node can be used, where applicable.\r
1555\r
1556**/\r
1557VOID\r
1558DevPathToTextBBS (\r
1559 IN OUT POOL_PRINT *Str,\r
1560 IN VOID *DevPath,\r
1561 IN BOOLEAN DisplayOnly,\r
1562 IN BOOLEAN AllowShortcuts\r
1563 )\r
1564{\r
1565 BBS_BBS_DEVICE_PATH *Bbs;\r
1566 CHAR16 *Type;\r
1567\r
1568 Bbs = DevPath;\r
1569 switch (Bbs->DeviceType) {\r
1570 case BBS_TYPE_FLOPPY:\r
1571 Type = L"Floppy";\r
1572 break;\r
1573\r
1574 case BBS_TYPE_HARDDRIVE:\r
1575 Type = L"HD";\r
1576 break;\r
1577\r
1578 case BBS_TYPE_CDROM:\r
1579 Type = L"CDROM";\r
1580 break;\r
1581\r
1582 case BBS_TYPE_PCMCIA:\r
1583 Type = L"PCMCIA";\r
1584 break;\r
1585\r
1586 case BBS_TYPE_USB:\r
1587 Type = L"USB";\r
1588 break;\r
1589\r
1590 case BBS_TYPE_EMBEDDED_NETWORK:\r
1591 Type = L"Network";\r
1592 break;\r
1593\r
1594 default:\r
1595 Type = NULL;\r
1596 break;\r
1597 }\r
1598\r
1599 if (Type != NULL) {\r
1600 CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r
1601 } else {\r
1602 CatPrint (Str, L"BBS(0x%x,%a", (UINTN) Bbs->DeviceType, Bbs->String);\r
1603 }\r
1604\r
1605 if (DisplayOnly) {\r
1606 CatPrint (Str, L")");\r
1607 return ;\r
1608 }\r
1609\r
1610 CatPrint (Str, L",0x%x)", (UINTN) Bbs->StatusFlag);\r
1611}\r
1612\r
1613/**\r
1614 Converts an End-of-Device-Path structure to its string representative.\r
1615\r
1616 @param Str The string representative of input device.\r
1617 @param DevPath The input device path structure.\r
1618 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1619 of the display node is used, where applicable. If DisplayOnly\r
1620 is FALSE, then the longer text representation of the display node\r
1621 is used.\r
1622 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1623 representation for a device node can be used, where applicable.\r
1624\r
1625**/\r
1626VOID\r
1627DevPathToTextEndInstance (\r
1628 IN OUT POOL_PRINT *Str,\r
1629 IN VOID *DevPath,\r
1630 IN BOOLEAN DisplayOnly,\r
1631 IN BOOLEAN AllowShortcuts\r
1632 )\r
1633{\r
1634 CatPrint (Str, L",");\r
1635}\r
1636\r
1637/**\r
1638 Converts an unknown device path structure to its string representative.\r
1639\r
1640 @param Str The string representative of input device.\r
1641 @param DevPath The input device path structure.\r
1642 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1643 of the display node is used, where applicable. If DisplayOnly\r
1644 is FALSE, then the longer text representation of the display node\r
1645 is used.\r
1646 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1647 representation for a device node can be used, where applicable.\r
1648\r
1649**/\r
1650VOID\r
1651DevPathToTextNodeUnknown (\r
1652 IN OUT POOL_PRINT *Str,\r
1653 IN VOID *DevPath,\r
1654 IN BOOLEAN DisplayOnly,\r
1655 IN BOOLEAN AllowShortcuts\r
1656 )\r
1657{\r
1658 CatPrint (Str, L"?");\r
1659}\r
1660\r
1661GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable[] = {\r
1662 {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci},\r
1663 {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard},\r
1664 {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap},\r
1665 {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor},\r
1666 {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController},\r
1667 {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi},\r
1668 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx},\r
1669 {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr},\r
1670 {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi},\r
1671 {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi},\r
1672 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre},\r
1673 {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394},\r
1674 {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb},\r
1675 {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID},\r
1676 {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit},\r
1677 {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass},\r
1678 {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata},\r
1679 {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O},\r
1680 {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr},\r
1681 {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4},\r
1682 {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6},\r
1683 {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand},\r
1684 {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart},\r
1685 {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor},\r
1686 {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI},\r
1687 {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive},\r
1688 {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM},\r
1689 {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor},\r
1690 {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol},\r
1691 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r
1692 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv},\r
1693 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile},\r
1694 {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange},\r
1695 {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS},\r
1696 {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance},\r
1697 {0, 0, NULL}\r
1698};\r
1699\r
1700/**\r
1701 Converts a device node to its string representation.\r
1702\r
1703 @param DeviceNode A Pointer to the device node to be converted.\r
1704 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1705 of the display node is used, where applicable. If DisplayOnly\r
1706 is FALSE, then the longer text representation of the display node\r
1707 is used.\r
1708 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1709 representation for a device node can be used, where applicable.\r
1710\r
1711 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
1712 is NULL or there was insufficient memory.\r
1713\r
1714**/\r
1715CHAR16 *\r
1716EFIAPI\r
1717ConvertDeviceNodeToText (\r
1718 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
1719 IN BOOLEAN DisplayOnly,\r
1720 IN BOOLEAN AllowShortcuts\r
1721 )\r
1722{\r
1723 POOL_PRINT Str;\r
1724 UINTN Index;\r
1725 UINTN NewSize;\r
1726 VOID (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
1727\r
1728 if (DeviceNode == NULL) {\r
1729 return NULL;\r
1730 }\r
1731\r
1732 ZeroMem (&Str, sizeof (Str));\r
1733\r
1734 //\r
1735 // Process the device path node\r
1736 //\r
1737 DumpNode = NULL;\r
1738 for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index++) {\r
1739 if (DevicePathType (DeviceNode) == DevPathToTextTable[Index].Type &&\r
1740 DevicePathSubType (DeviceNode) == DevPathToTextTable[Index].SubType\r
1741 ) {\r
1742 DumpNode = DevPathToTextTable[Index].Function;\r
1743 break;\r
1744 }\r
1745 }\r
1746 //\r
1747 // If not found, use a generic function\r
1748 //\r
1749 if (DumpNode == NULL) {\r
1750 DumpNode = DevPathToTextNodeUnknown;\r
1751 }\r
1752\r
1753 //\r
1754 // Print this node\r
1755 //\r
1756 DumpNode (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r
1757\r
1758 //\r
1759 // Shrink pool used for string allocation\r
1760 //\r
1761 NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
1762 Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r
1763 ASSERT (Str.Str != NULL);\r
1764 Str.Str[Str.Len] = 0;\r
1765 return Str.Str;\r
1766}\r
1767\r
1768/**\r
1769 Converts a device path to its text representation.\r
1770\r
1771 @param DevicePath A Pointer to the device 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 path or\r
1780 NULL if DeviceNode is NULL or there was insufficient memory.\r
1781\r
1782**/\r
1783CHAR16 *\r
1784EFIAPI\r
1785ConvertDevicePathToText (\r
1786 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
1787 IN BOOLEAN DisplayOnly,\r
1788 IN BOOLEAN AllowShortcuts\r
1789 )\r
1790{\r
1791 POOL_PRINT Str;\r
1792 EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r
1793 EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode;\r
1794 UINTN Index;\r
1795 UINTN NewSize;\r
1796 VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
1797\r
1798 if (DevicePath == NULL) {\r
1799 return NULL;\r
1800 }\r
1801\r
1802 ZeroMem (&Str, sizeof (Str));\r
1803\r
1804 //\r
1805 // Process each device path node\r
1806 //\r
1807 DevPathNode = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;\r
1808 while (!IsDevicePathEnd (DevPathNode)) {\r
1809 //\r
1810 // Find the handler to dump this device path node\r
1811 //\r
1812 DumpNode = NULL;\r
1813 for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index += 1) {\r
1814\r
1815 if (DevicePathType (DevPathNode) == DevPathToTextTable[Index].Type &&\r
1816 DevicePathSubType (DevPathNode) == DevPathToTextTable[Index].SubType\r
1817 ) {\r
1818 DumpNode = DevPathToTextTable[Index].Function;\r
1819 break;\r
1820 }\r
1821 }\r
1822 //\r
1823 // If not found, use a generic function\r
1824 //\r
1825 if (!DumpNode) {\r
1826 DumpNode = DevPathToTextNodeUnknown;\r
1827 }\r
1828 //\r
1829 // Put a path separator in if needed\r
1830 //\r
1831 if ((Str.Len != 0) && DumpNode != DevPathToTextEndInstance) {\r
1832 if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') {\r
1833 CatPrint (&Str, L"/");\r
1834 }\r
1835 }\r
1836 \r
1837 AlignedDevPathNode = AllocateCopyPool (DevicePathNodeLength (DevPathNode), DevPathNode);\r
1838 //\r
1839 // Print this node of the device path\r
1840 //\r
1841 DumpNode (&Str, AlignedDevPathNode, DisplayOnly, AllowShortcuts);\r
1842 FreePool (AlignedDevPathNode);\r
1843 \r
1844 //\r
1845 // Next device path node\r
1846 //\r
1847 DevPathNode = NextDevicePathNode (DevPathNode);\r
1848 }\r
1849\r
1850 NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
1851 Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r
1852 ASSERT (Str.Str != NULL);\r
1853 Str.Str[Str.Len] = 0;\r
1854 return Str.Str;\r
1855}\r