Update DevicePathLib to reflect the update of UEFI device utility protocol
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePathToText.c
CommitLineData
95276127 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 DevicePathToText.c\r
15\r
16Abstract:\r
17\r
18 DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
19\r
20--*/\r
21\r
95276127 22#include "DevicePath.h"\r
23\r
24STATIC\r
25EFI_DEVICE_PATH_PROTOCOL *\r
26UnpackDevicePath (\r
27 IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
28 )\r
29/*++\r
30\r
31 Routine Description:\r
32 Function unpacks a device path data structure so that all the nodes of a device path \r
33 are naturally aligned.\r
34\r
35 Arguments:\r
36 DevPath - A pointer to a device path data structure\r
37\r
38 Returns:\r
39 If the memory for the device path is successfully allocated, then a pointer to the \r
40 new device path is returned. Otherwise, NULL is returned.\r
41\r
42--*/\r
43{\r
44 EFI_DEVICE_PATH_PROTOCOL *Src;\r
45 EFI_DEVICE_PATH_PROTOCOL *Dest;\r
46 EFI_DEVICE_PATH_PROTOCOL *NewPath;\r
47 UINTN Size;\r
48\r
49 if (DevPath == NULL) {\r
50 return NULL;\r
51 }\r
52 //\r
53 // Walk device path and round sizes to valid boundries\r
54 //\r
55 Src = DevPath;\r
56 Size = 0;\r
57 for (;;) {\r
58 Size += DevicePathNodeLength (Src);\r
59 Size += ALIGN_SIZE (Size);\r
60\r
61 if (IsDevicePathEnd (Src)) {\r
62 break;\r
63 }\r
64\r
65 Src = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (Src);\r
66 }\r
67 //\r
68 // Allocate space for the unpacked path\r
69 //\r
70 NewPath = AllocateZeroPool (Size);\r
71 if (NewPath != NULL) {\r
72\r
73 ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0);\r
74\r
75 //\r
76 // Copy each node\r
77 //\r
78 Src = DevPath;\r
79 Dest = NewPath;\r
80 for (;;) {\r
81 Size = DevicePathNodeLength (Src);\r
82 CopyMem (Dest, Src, Size);\r
83 Size += ALIGN_SIZE (Size);\r
84 SetDevicePathNodeLength (Dest, Size);\r
85 Dest->Type |= EFI_DP_TYPE_UNPACKED;\r
86 Dest = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) Dest) + Size);\r
87\r
88 if (IsDevicePathEnd (Src)) {\r
89 break;\r
90 }\r
91\r
92 Src = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (Src);\r
93 }\r
94 }\r
95\r
96 return NewPath;\r
97}\r
98\r
99STATIC\r
100VOID *\r
101ReallocatePool (\r
102 IN VOID *OldPool,\r
103 IN UINTN OldSize,\r
104 IN UINTN NewSize\r
105 )\r
106/*++\r
107\r
108 Routine Description:\r
109 Adjusts the size of a previously allocated buffer.\r
110\r
111 Arguments:\r
112 OldPool - A pointer to the buffer whose size is being adjusted.\r
113 OldSize - The size of the current buffer.\r
114 NewSize - The size of the new buffer.\r
115\r
116 Returns:\r
117 EFI_SUCEESS - The requested number of bytes were allocated.\r
118 EFI_OUT_OF_RESOURCES - The pool requested could not be allocated.\r
119 EFI_INVALID_PARAMETER - The buffer was invalid.\r
120\r
121--*/\r
122{\r
123 VOID *NewPool;\r
124\r
125 NewPool = NULL;\r
126 if (NewSize) {\r
127 NewPool = AllocateZeroPool (NewSize);\r
128 }\r
129\r
130 if (OldPool) {\r
131 if (NewPool) {\r
132 CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
133 }\r
134\r
135 FreePool (OldPool);\r
136 }\r
137\r
138 return NewPool;\r
139}\r
140\r
141STATIC\r
142CHAR16 *\r
143CatPrint (\r
144 IN OUT POOL_PRINT *Str,\r
145 IN CHAR16 *Fmt,\r
146 ...\r
147 )\r
148/*++\r
149\r
150 Routine Description:\r
151 Concatenates a formatted unicode string to allocated pool. \r
152 The caller must free the resulting buffer.\r
153\r
154 Arguments:\r
155 Str - Tracks the allocated pool, size in use, and \r
156 amount of pool allocated.\r
157 Fmt - The format string\r
158\r
159 Returns:\r
160 Allocated buffer with the formatted string printed in it. \r
161 The caller must free the allocated buffer. The buffer\r
162 allocation is not packed.\r
163\r
164--*/\r
165{\r
166 UINT16 *AppendStr;\r
167 VA_LIST Args;\r
168 UINTN Size;\r
169\r
170 AppendStr = AllocateZeroPool (0x1000);\r
171 if (AppendStr == NULL) {\r
172 return Str->Str;\r
173 }\r
174\r
175 VA_START (Args, Fmt);\r
176 UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);\r
177 VA_END (Args);\r
178 if (NULL == Str->Str) {\r
179 Size = StrSize (AppendStr);\r
180 Str->Str = AllocateZeroPool (Size);\r
181 ASSERT (Str->Str != NULL);\r
182 } else {\r
183 Size = StrSize (AppendStr) - sizeof (UINT16);\r
184 Size = Size + StrSize (Str->Str);\r
185 Str->Str = ReallocatePool (\r
186 Str->Str,\r
187 StrSize (Str->Str),\r
188 Size\r
189 );\r
190 ASSERT (Str->Str != NULL);\r
191 }\r
192\r
193 Str->MaxLen = MAX_CHAR * sizeof (UINT16);\r
194 if (Size < Str->MaxLen) {\r
195 StrCat (Str->Str, AppendStr);\r
196 Str->Len = Size - sizeof (UINT16);\r
197 }\r
198\r
199 FreePool (AppendStr);\r
200 return Str->Str;\r
201}\r
202\r
203STATIC\r
204VOID\r
205DevPathToTextPci (\r
206 IN OUT POOL_PRINT *Str,\r
207 IN VOID *DevPath,\r
208 IN BOOLEAN DisplayOnly,\r
209 IN BOOLEAN AllowShortcuts\r
210 )\r
211{\r
212 PCI_DEVICE_PATH *Pci;\r
213\r
214 Pci = DevPath;\r
215 CatPrint (Str, L"Pci(%x,%x)", Pci->Function, Pci->Device);\r
216}\r
217\r
218STATIC\r
219VOID\r
220DevPathToTextPccard (\r
221 IN OUT POOL_PRINT *Str,\r
222 IN VOID *DevPath,\r
223 IN BOOLEAN DisplayOnly,\r
224 IN BOOLEAN AllowShortcuts\r
225 )\r
226{\r
227 PCCARD_DEVICE_PATH *Pccard;\r
228\r
229 Pccard = DevPath;\r
230 CatPrint (Str, L"PcCard(%x)", Pccard->FunctionNumber);\r
231}\r
232\r
233STATIC\r
234VOID\r
235DevPathToTextMemMap (\r
236 IN OUT POOL_PRINT *Str,\r
237 IN VOID *DevPath,\r
238 IN BOOLEAN DisplayOnly,\r
239 IN BOOLEAN AllowShortcuts\r
240 )\r
241{\r
242 MEMMAP_DEVICE_PATH *MemMap;\r
243\r
244 MemMap = DevPath;\r
245 CatPrint (\r
246 Str,\r
247 L"MemoryMapped(%lx,%lx)",\r
248 MemMap->StartingAddress,\r
249 MemMap->EndingAddress\r
250 );\r
251}\r
252\r
253STATIC\r
254VOID\r
255DevPathToTextVendor (\r
256 IN OUT POOL_PRINT *Str,\r
257 IN VOID *DevPath,\r
258 IN BOOLEAN DisplayOnly,\r
259 IN BOOLEAN AllowShortcuts\r
260 )\r
261{\r
262 VENDOR_DEVICE_PATH *Vendor;\r
263 CHAR16 *Type;\r
264 UINTN Index;\r
265 UINT32 FlowControlMap;\r
266 UINT16 Info;\r
267\r
268 Vendor = (VENDOR_DEVICE_PATH *) DevPath;\r
269 switch (DevicePathType (&Vendor->Header)) {\r
270 case HARDWARE_DEVICE_PATH:\r
271 Type = L"Hw";\r
272 break;\r
273\r
274 case MESSAGING_DEVICE_PATH:\r
275 Type = L"Msg";\r
276 if (AllowShortcuts) {\r
277 if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {\r
278 CatPrint (Str, L"VenPcAnsi()");\r
279 return ;\r
280 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {\r
281 CatPrint (Str, L"VenVt100()");\r
282 return ;\r
283 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {\r
284 CatPrint (Str, L"VenVt100Plus()");\r
285 return ;\r
286 } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {\r
287 CatPrint (Str, L"VenUft8()");\r
288 return ;\r
289 } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingUartFlowControlGuid)) {\r
290 FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);\r
291 switch (FlowControlMap & 0x00000003) {\r
292 case 0:\r
293 CatPrint (Str, L"UartFlowCtrl(%s)", L"None");\r
294 break;\r
295\r
296 case 1:\r
297 CatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware");\r
298 break;\r
299\r
300 case 2:\r
301 CatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff");\r
302 break;\r
303\r
304 default:\r
305 break;\r
306 }\r
307\r
308 return ;\r
309 } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingSASGuid)) {\r
310 CatPrint (\r
311 Str,\r
312 L"SAS(%lx,%lx,%x,",\r
313 ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r
314 ((SAS_DEVICE_PATH *) Vendor)->Lun,\r
315 ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
316 );\r
317 Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);\r
318 if ((Info & 0x0f) == 0) {\r
319 CatPrint (Str, L"NoTopology,0,0,0,");\r
320 } else if (((Info & 0x0f) == 1) || ((Info & 0x0f) == 2)) {\r
321 CatPrint (\r
322 Str,\r
323 L"%s,%s,%s,",\r
324 (Info & (0x1 << 4)) ? L"SATA" : L"SAS",\r
325 (Info & (0x1 << 5)) ? L"External" : L"Internal",\r
326 (Info & (0x1 << 6)) ? L"Expanded" : L"Direct"\r
327 );\r
328 if ((Info & 0x0f) == 1) {\r
329 CatPrint (Str, L"0,");\r
330 } else {\r
331 CatPrint (Str, L"%x,", (Info >> 8) & 0xff);\r
332 }\r
333 } else {\r
334 CatPrint (Str, L"0,0,0,0,");\r
335 }\r
336\r
337 CatPrint (Str, L"%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
338 return ;\r
339 } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r
340 CatPrint (Str, L"DebugPort()");\r
341 return ;\r
342 } else {\r
343 return ;\r
344 //\r
345 // reserved\r
346 //\r
347 }\r
348 }\r
349 break;\r
350\r
351 case MEDIA_DEVICE_PATH:\r
352 Type = L"Media";\r
353 break;\r
354\r
355 default:\r
356 Type = L"?";\r
357 break;\r
358 }\r
359\r
360 CatPrint (Str, L"Ven%s(%g,", Type, &Vendor->Guid);\r
361 for (Index = 0; Index < DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH); Index++) {\r
362 CatPrint (Str, L"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r
363 }\r
364\r
365 CatPrint (Str, L")");\r
366}\r
367\r
368STATIC\r
369VOID\r
370DevPathToTextController (\r
371 IN OUT POOL_PRINT *Str,\r
372 IN VOID *DevPath,\r
373 IN BOOLEAN DisplayOnly,\r
374 IN BOOLEAN AllowShortcuts\r
375 )\r
376{\r
377 CONTROLLER_DEVICE_PATH *Controller;\r
378\r
379 Controller = DevPath;\r
380 CatPrint (\r
381 Str,\r
382 L"Ctrl(%x)",\r
383 Controller->ControllerNumber\r
384 );\r
385}\r
386\r
387STATIC\r
388VOID\r
389DevPathToTextAcpi (\r
390 IN OUT POOL_PRINT *Str,\r
391 IN VOID *DevPath,\r
392 IN BOOLEAN DisplayOnly,\r
393 IN BOOLEAN AllowShortcuts\r
394 )\r
395{\r
396 ACPI_HID_DEVICE_PATH *Acpi;\r
397\r
398 Acpi = DevPath;\r
399 if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
400 if (AllowShortcuts) {\r
401 switch (EISA_ID_TO_NUM (Acpi->HID)) {\r
402 case 0x0a03:\r
403 CatPrint (Str, L"PciRoot(%x)", Acpi->UID);\r
404 break;\r
405\r
406 case 0x0604:\r
407 CatPrint (Str, L"Floppy(%x)", Acpi->UID);\r
408 break;\r
409\r
410 case 0x0301:\r
411 CatPrint (Str, L"Keyboard(%x)", Acpi->UID);\r
412 break;\r
413\r
414 case 0x0501:\r
415 CatPrint (Str, L"Serial(%x)", Acpi->UID);\r
416 break;\r
417\r
418 case 0x0401:\r
419 CatPrint (Str, L"ParallelPort(%x)", Acpi->UID);\r
420 break;\r
421\r
422 default:\r
423 break;\r
424 }\r
425\r
426 return ;\r
427 }\r
428\r
429 CatPrint (Str, L"Acpi(PNP%04x,%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);\r
430 } else {\r
431 CatPrint (Str, L"Acpi(%08x,%x)", Acpi->HID, Acpi->UID);\r
432 }\r
433}\r
434\r
435#define NextStrA(a) ((UINT8 *) (((UINT8 *) (a)) + AsciiStrLen ((CHAR8 *) (a)) + 1))\r
436\r
437STATIC\r
438VOID\r
439DevPathToTextExtAcpi (\r
440 IN OUT POOL_PRINT *Str,\r
441 IN VOID *DevPath,\r
442 IN BOOLEAN DisplayOnly,\r
443 IN BOOLEAN AllowShortcuts\r
444 )\r
445{\r
446 ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *AcpiExt;\r
447 UINT8 *NextString;\r
448\r
449 AcpiExt = DevPath;\r
450\r
451 if (AllowShortcuts) {\r
452 NextString = NextStrA (AcpiExt->HidUidCidStr);\r
453 if ((*(AcpiExt->HidUidCidStr) == '\0') &&\r
454 (*(NextStrA (NextString)) == '\0') &&\r
455 (AcpiExt->UID == 0)\r
456 ) {\r
457 if ((AcpiExt->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
458 CatPrint (\r
459 Str,\r
460 L"AcpiExp(PNP%04x,%x,%a)",\r
461 EISA_ID_TO_NUM (AcpiExt->HID),\r
462 AcpiExt->CID,\r
463 NextStrA (AcpiExt->HidUidCidStr)\r
464 );\r
465 } else {\r
466 CatPrint (\r
467 Str,\r
468 L"AcpiExp(%08x,%x,%a)",\r
469 AcpiExt->HID,\r
470 AcpiExt->CID,\r
471 NextStrA (AcpiExt->HidUidCidStr)\r
472 );\r
473 }\r
474 }\r
475 return ;\r
476 }\r
477\r
478 NextString = NextStrA (AcpiExt->HidUidCidStr);\r
479 NextString = NextStrA (NextString);\r
480 if ((AcpiExt->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
481 CatPrint (\r
482 Str,\r
483 L"AcpiEx(PNP%04x,%x,%x,%a,%a,%a)",\r
484 EISA_ID_TO_NUM (AcpiExt->HID),\r
485 AcpiExt->CID,\r
486 AcpiExt->UID,\r
487 AcpiExt->HidUidCidStr,\r
488 NextString,\r
489 NextStrA (AcpiExt->HidUidCidStr)\r
490 );\r
491 } else {\r
492 CatPrint (\r
493 Str,\r
494 L"AcpiEx(%08x,%x,%x,%a,%a,%a)",\r
495 AcpiExt->HID,\r
496 AcpiExt->CID,\r
497 AcpiExt->UID,\r
498 AcpiExt->HidUidCidStr,\r
499 NextString,\r
500 NextStrA (AcpiExt->HidUidCidStr)\r
501 );\r
502 }\r
503}\r
504\r
505STATIC\r
506VOID\r
507DevPathToTextAtapi (\r
508 IN OUT POOL_PRINT *Str,\r
509 IN VOID *DevPath,\r
510 IN BOOLEAN DisplayOnly,\r
511 IN BOOLEAN AllowShortcuts\r
512 )\r
513{\r
514 ATAPI_DEVICE_PATH *Atapi;\r
515\r
516 Atapi = DevPath;\r
517\r
518 if (DisplayOnly) {\r
519 CatPrint (Str, L"Ata(%x)", Atapi->Lun);\r
520 } else {\r
521 CatPrint (\r
522 Str,\r
523 L"Ata(%s,%s,%x)",\r
524 Atapi->PrimarySecondary ? L"Secondary" : L"Primary",\r
525 Atapi->SlaveMaster ? L"Slave" : L"Master",\r
526 Atapi->Lun\r
527 );\r
528 }\r
529}\r
530\r
531STATIC\r
532VOID\r
533DevPathToTextScsi (\r
534 IN OUT POOL_PRINT *Str,\r
535 IN VOID *DevPath,\r
536 IN BOOLEAN DisplayOnly,\r
537 IN BOOLEAN AllowShortcuts\r
538 )\r
539{\r
540 SCSI_DEVICE_PATH *Scsi;\r
541\r
542 Scsi = DevPath;\r
543 CatPrint (Str, L"Scsi(%x,%x)", Scsi->Pun, Scsi->Lun);\r
544}\r
545\r
546STATIC\r
547VOID\r
548DevPathToTextFibre (\r
549 IN OUT POOL_PRINT *Str,\r
550 IN VOID *DevPath,\r
551 IN BOOLEAN DisplayOnly,\r
552 IN BOOLEAN AllowShortcuts\r
553 )\r
554{\r
555 FIBRECHANNEL_DEVICE_PATH *Fibre;\r
556\r
557 Fibre = DevPath;\r
558 CatPrint (Str, L"Fibre(%lx,%lx)", Fibre->WWN, Fibre->Lun);\r
559}\r
560\r
561STATIC\r
562VOID\r
563DevPathToText1394 (\r
564 IN OUT POOL_PRINT *Str,\r
565 IN VOID *DevPath,\r
566 IN BOOLEAN DisplayOnly,\r
567 IN BOOLEAN AllowShortcuts\r
568 )\r
569{\r
570 F1394_DEVICE_PATH *F1394;\r
571\r
572 F1394 = DevPath;\r
573 CatPrint (Str, L"I1394(%lx)", F1394->Guid);\r
574}\r
575\r
576STATIC\r
577VOID\r
578DevPathToTextUsb (\r
579 IN OUT POOL_PRINT *Str,\r
580 IN VOID *DevPath,\r
581 IN BOOLEAN DisplayOnly,\r
582 IN BOOLEAN AllowShortcuts\r
583 )\r
584{\r
585 USB_DEVICE_PATH *Usb;\r
586\r
587 Usb = DevPath;\r
588 CatPrint (Str, L"USB(%x,%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);\r
589}\r
590\r
591STATIC\r
592VOID\r
593DevPathToTextUsbWWID (\r
594 IN OUT POOL_PRINT *Str,\r
595 IN VOID *DevPath,\r
596 IN BOOLEAN DisplayOnly,\r
597 IN BOOLEAN AllowShortcuts\r
598 )\r
599{\r
600 USB_WWID_DEVICE_PATH *UsbWWId;\r
601\r
602 UsbWWId = DevPath;\r
603 CatPrint (\r
604 Str,\r
605 L"UsbWwid(%x,%x,%x,\"WWID\")",\r
606 UsbWWId->VendorId,\r
607 UsbWWId->ProductId,\r
608 UsbWWId->InterfaceNumber\r
609 );\r
610}\r
611\r
612STATIC\r
613VOID\r
614DevPathToTextLogicalUnit (\r
615 IN OUT POOL_PRINT *Str,\r
616 IN VOID *DevPath,\r
617 IN BOOLEAN DisplayOnly,\r
618 IN BOOLEAN AllowShortcuts\r
619 )\r
620{\r
621 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
622\r
623 LogicalUnit = DevPath;\r
624 CatPrint (Str, L"Unit(%x)", LogicalUnit->Lun);\r
625}\r
626\r
627STATIC\r
628VOID\r
629DevPathToTextUsbClass (\r
630 IN OUT POOL_PRINT *Str,\r
631 IN VOID *DevPath,\r
632 IN BOOLEAN DisplayOnly,\r
633 IN BOOLEAN AllowShortcuts\r
634 )\r
635{\r
636 USB_CLASS_DEVICE_PATH *UsbClass;\r
637\r
638 UsbClass = DevPath;\r
639\r
640 if (AllowShortcuts == TRUE) {\r
641 switch (UsbClass->DeviceClass) {\r
642 case 1:\r
643 CatPrint (\r
644 Str,\r
645 L"UsbAudio(%x,%x,%x,%x)",\r
646 UsbClass->VendorId,\r
647 UsbClass->ProductId,\r
648 UsbClass->DeviceSubClass,\r
649 UsbClass->DeviceProtocol\r
650 );\r
651 break;\r
652\r
653 case 2:\r
654 CatPrint (\r
655 Str,\r
656 L"UsbCDCControl(%x,%x,%x,%x)",\r
657 UsbClass->VendorId,\r
658 UsbClass->ProductId,\r
659 UsbClass->DeviceSubClass,\r
660 UsbClass->DeviceProtocol\r
661 );\r
662 break;\r
663\r
664 case 3:\r
665 CatPrint (\r
666 Str,\r
667 L"UsbHID(%x,%x,%x,%x)",\r
668 UsbClass->VendorId,\r
669 UsbClass->ProductId,\r
670 UsbClass->DeviceSubClass,\r
671 UsbClass->DeviceProtocol\r
672 );\r
673 break;\r
674\r
675 case 6:\r
676 CatPrint (\r
677 Str,\r
678 L"UsbImage(%x,%x,%x,%x)",\r
679 UsbClass->VendorId,\r
680 UsbClass->ProductId,\r
681 UsbClass->DeviceSubClass,\r
682 UsbClass->DeviceProtocol\r
683 );\r
684 break;\r
685\r
686 case 7:\r
687 CatPrint (\r
688 Str,\r
689 L"UsbPrinter(%x,%x,%x,%x)",\r
690 UsbClass->VendorId,\r
691 UsbClass->ProductId,\r
692 UsbClass->DeviceSubClass,\r
693 UsbClass->DeviceProtocol\r
694 );\r
695 break;\r
696\r
697 case 8:\r
698 CatPrint (\r
699 Str,\r
700 L"UsbMassStorage(%x,%x,%x,%x)",\r
701 UsbClass->VendorId,\r
702 UsbClass->ProductId,\r
703 UsbClass->DeviceSubClass,\r
704 UsbClass->DeviceProtocol\r
705 );\r
706 break;\r
707\r
708 case 9:\r
709 CatPrint (\r
710 Str,\r
711 L"UsbHub(%x,%x,%x,%x)",\r
712 UsbClass->VendorId,\r
713 UsbClass->ProductId,\r
714 UsbClass->DeviceSubClass,\r
715 UsbClass->DeviceProtocol\r
716 );\r
717 break;\r
718\r
719 case 10:\r
720 CatPrint (\r
721 Str,\r
722 L"UsbCDCData(%x,%x,%x,%x)",\r
723 UsbClass->VendorId,\r
724 UsbClass->ProductId,\r
725 UsbClass->DeviceSubClass,\r
726 UsbClass->DeviceProtocol\r
727 );\r
728 break;\r
729\r
730 case 11:\r
731 CatPrint (\r
732 Str,\r
733 L"UsbSmartCard(%x,%x,%x,%x)",\r
734 UsbClass->VendorId,\r
735 UsbClass->ProductId,\r
736 UsbClass->DeviceSubClass,\r
737 UsbClass->DeviceProtocol\r
738 );\r
739 break;\r
740\r
741 case 14:\r
742 CatPrint (\r
743 Str,\r
744 L"UsbVideo(%x,%x,%x,%x)",\r
745 UsbClass->VendorId,\r
746 UsbClass->ProductId,\r
747 UsbClass->DeviceSubClass,\r
748 UsbClass->DeviceProtocol\r
749 );\r
750 break;\r
751\r
752 case 220:\r
753 CatPrint (\r
754 Str,\r
755 L"UsbDiagnostic(%x,%x,%x,%x)",\r
756 UsbClass->VendorId,\r
757 UsbClass->ProductId,\r
758 UsbClass->DeviceSubClass,\r
759 UsbClass->DeviceProtocol\r
760 );\r
761 break;\r
762\r
763 case 224:\r
764 CatPrint (\r
765 Str,\r
766 L"UsbWireless(%x,%x,%x,%x)",\r
767 UsbClass->VendorId,\r
768 UsbClass->ProductId,\r
769 UsbClass->DeviceSubClass,\r
770 UsbClass->DeviceProtocol\r
771 );\r
772 break;\r
773\r
774 case 254:\r
775 if (UsbClass->DeviceSubClass == 1) {\r
776 CatPrint (\r
777 Str,\r
778 L"UsbDeviceFirmwareUpdate(%x,%x,%x)",\r
779 UsbClass->VendorId,\r
780 UsbClass->ProductId,\r
781 UsbClass->DeviceProtocol\r
782 );\r
783 } else if (UsbClass->DeviceSubClass == 2) {\r
784 CatPrint (\r
785 Str,\r
786 L"UsbIrdaBridge(%x,%x,%x)",\r
787 UsbClass->VendorId,\r
788 UsbClass->ProductId,\r
789 UsbClass->DeviceProtocol\r
790 );\r
791 } else if (UsbClass->DeviceSubClass == 3) {\r
792 CatPrint (\r
793 Str,\r
794 L"UsbTestAndMeasurement(%x,%x,%x)",\r
795 UsbClass->VendorId,\r
796 UsbClass->ProductId,\r
797 UsbClass->DeviceProtocol\r
798 );\r
799 }\r
800 break;\r
801\r
802 default:\r
803 break;\r
804 }\r
805\r
806 return ;\r
807 }\r
808\r
809 CatPrint (\r
810 Str,\r
811 L"UsbClass(%x,%x,%x,%x,%x)",\r
812 UsbClass->VendorId,\r
813 UsbClass->ProductId,\r
814 UsbClass->DeviceClass,\r
815 UsbClass->DeviceSubClass,\r
816 UsbClass->DeviceProtocol\r
817 );\r
818}\r
819\r
820STATIC\r
821VOID\r
822DevPathToTextI2O (\r
823 IN OUT POOL_PRINT *Str,\r
824 IN VOID *DevPath,\r
825 IN BOOLEAN DisplayOnly,\r
826 IN BOOLEAN AllowShortcuts\r
827 )\r
828{\r
829 I2O_DEVICE_PATH *I2O;\r
830\r
831 I2O = DevPath;\r
832 CatPrint (Str, L"I2O(%x)", I2O->Tid);\r
833}\r
834\r
835STATIC\r
836VOID\r
837DevPathToTextMacAddr (\r
838 IN OUT POOL_PRINT *Str,\r
839 IN VOID *DevPath,\r
840 IN BOOLEAN DisplayOnly,\r
841 IN BOOLEAN AllowShortcuts\r
842 )\r
843{\r
844 MAC_ADDR_DEVICE_PATH *MAC;\r
845 UINTN HwAddressSize;\r
846 UINTN Index;\r
847\r
848 MAC = DevPath;\r
849\r
850 HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
851 if (MAC->IfType == 0x01 || MAC->IfType == 0x00) {\r
852 HwAddressSize = 6;\r
853 }\r
854\r
855 CatPrint (Str, L"MAC(");\r
856\r
857 for (Index = 0; Index < HwAddressSize; Index++) {\r
858 CatPrint (Str, L"%02x", MAC->MacAddress.Addr[Index]);\r
859 }\r
860\r
861 CatPrint (Str, L",%x)", MAC->IfType);\r
862}\r
863\r
864STATIC\r
865VOID\r
866DevPathToTextIPv4 (\r
867 IN OUT POOL_PRINT *Str,\r
868 IN VOID *DevPath,\r
869 IN BOOLEAN DisplayOnly,\r
870 IN BOOLEAN AllowShortcuts\r
871 )\r
872{\r
873 IPv4_DEVICE_PATH *IP;\r
874\r
875 IP = DevPath;\r
876 if (DisplayOnly == TRUE) {\r
877 CatPrint (\r
878 Str,\r
879 L"IPv4(%d.%d.%d.%d)",\r
880 IP->RemoteIpAddress.Addr[0],\r
881 IP->RemoteIpAddress.Addr[1],\r
882 IP->RemoteIpAddress.Addr[2],\r
883 IP->RemoteIpAddress.Addr[3]\r
884 );\r
885 return ;\r
886 }\r
887\r
888 CatPrint (\r
889 Str,\r
890 L"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",\r
891 IP->RemoteIpAddress.Addr[0],\r
892 IP->RemoteIpAddress.Addr[1],\r
893 IP->RemoteIpAddress.Addr[2],\r
894 IP->RemoteIpAddress.Addr[3],\r
895 IP->Protocol ? L"TCP" : L"UDP",\r
896 (IP->StaticIpAddress == TRUE) ? L"Static" : L"DHCP",\r
897 IP->LocalIpAddress.Addr[0],\r
898 IP->LocalIpAddress.Addr[1],\r
899 IP->LocalIpAddress.Addr[2],\r
900 IP->LocalIpAddress.Addr[3]\r
901 );\r
902}\r
903\r
904STATIC\r
905VOID\r
906DevPathToTextIPv6 (\r
907 IN OUT POOL_PRINT *Str,\r
908 IN VOID *DevPath,\r
909 IN BOOLEAN DisplayOnly,\r
910 IN BOOLEAN AllowShortcuts\r
911 )\r
912{\r
913 IPv6_DEVICE_PATH *IP;\r
914\r
915 IP = DevPath;\r
916 if (DisplayOnly == TRUE) {\r
917 CatPrint (\r
918 Str,\r
919 L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
920 IP->RemoteIpAddress.Addr[0],\r
921 IP->RemoteIpAddress.Addr[1],\r
922 IP->RemoteIpAddress.Addr[2],\r
923 IP->RemoteIpAddress.Addr[3],\r
924 IP->RemoteIpAddress.Addr[4],\r
925 IP->RemoteIpAddress.Addr[5],\r
926 IP->RemoteIpAddress.Addr[6],\r
927 IP->RemoteIpAddress.Addr[7],\r
928 IP->RemoteIpAddress.Addr[8],\r
929 IP->RemoteIpAddress.Addr[9],\r
930 IP->RemoteIpAddress.Addr[10],\r
931 IP->RemoteIpAddress.Addr[11],\r
932 IP->RemoteIpAddress.Addr[12],\r
933 IP->RemoteIpAddress.Addr[13],\r
934 IP->RemoteIpAddress.Addr[14],\r
935 IP->RemoteIpAddress.Addr[15]\r
936 );\r
937 return ;\r
938 }\r
939\r
940 CatPrint (\r
941 Str,\r
942 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
943 IP->RemoteIpAddress.Addr[0],\r
944 IP->RemoteIpAddress.Addr[1],\r
945 IP->RemoteIpAddress.Addr[2],\r
946 IP->RemoteIpAddress.Addr[3],\r
947 IP->RemoteIpAddress.Addr[4],\r
948 IP->RemoteIpAddress.Addr[5],\r
949 IP->RemoteIpAddress.Addr[6],\r
950 IP->RemoteIpAddress.Addr[7],\r
951 IP->RemoteIpAddress.Addr[8],\r
952 IP->RemoteIpAddress.Addr[9],\r
953 IP->RemoteIpAddress.Addr[10],\r
954 IP->RemoteIpAddress.Addr[11],\r
955 IP->RemoteIpAddress.Addr[12],\r
956 IP->RemoteIpAddress.Addr[13],\r
957 IP->RemoteIpAddress.Addr[14],\r
958 IP->RemoteIpAddress.Addr[15],\r
959 IP->Protocol ? L"TCP" : L"UDP",\r
960 (IP->StaticIpAddress == TRUE) ? L"Static" : L"DHCP",\r
961 IP->LocalIpAddress.Addr[0],\r
962 IP->LocalIpAddress.Addr[1],\r
963 IP->LocalIpAddress.Addr[2],\r
964 IP->LocalIpAddress.Addr[3],\r
965 IP->LocalIpAddress.Addr[4],\r
966 IP->LocalIpAddress.Addr[5],\r
967 IP->LocalIpAddress.Addr[6],\r
968 IP->LocalIpAddress.Addr[7],\r
969 IP->LocalIpAddress.Addr[8],\r
970 IP->LocalIpAddress.Addr[9],\r
971 IP->LocalIpAddress.Addr[10],\r
972 IP->LocalIpAddress.Addr[11],\r
973 IP->LocalIpAddress.Addr[12],\r
974 IP->LocalIpAddress.Addr[13],\r
975 IP->LocalIpAddress.Addr[14],\r
976 IP->LocalIpAddress.Addr[15]\r
977 );\r
978}\r
979\r
980STATIC\r
981VOID\r
982DevPathToTextInfiniBand (\r
983 IN OUT POOL_PRINT *Str,\r
984 IN VOID *DevPath,\r
985 IN BOOLEAN DisplayOnly,\r
986 IN BOOLEAN AllowShortcuts\r
987 )\r
988{\r
989 INFINIBAND_DEVICE_PATH *InfiniBand;\r
990\r
991 InfiniBand = DevPath;\r
992 CatPrint (\r
993 Str,\r
994 L"Infiniband(%x,%g,%lx,%lx,%lx)",\r
995 InfiniBand->ResourceFlags,\r
996 InfiniBand->PortGid,\r
997 InfiniBand->ServiceId,\r
998 InfiniBand->TargetPortId,\r
999 InfiniBand->DeviceId\r
1000 );\r
1001}\r
1002\r
1003STATIC\r
1004VOID\r
1005DevPathToTextUart (\r
1006 IN OUT POOL_PRINT *Str,\r
1007 IN VOID *DevPath,\r
1008 IN BOOLEAN DisplayOnly,\r
1009 IN BOOLEAN AllowShortcuts\r
1010 )\r
1011{\r
1012 UART_DEVICE_PATH *Uart;\r
1013 CHAR8 Parity;\r
1014\r
1015 Uart = DevPath;\r
1016 switch (Uart->Parity) {\r
1017 case 0:\r
1018 Parity = 'D';\r
1019 break;\r
1020\r
1021 case 1:\r
1022 Parity = 'N';\r
1023 break;\r
1024\r
1025 case 2:\r
1026 Parity = 'E';\r
1027 break;\r
1028\r
1029 case 3:\r
1030 Parity = 'O';\r
1031 break;\r
1032\r
1033 case 4:\r
1034 Parity = 'M';\r
1035 break;\r
1036\r
1037 case 5:\r
1038 Parity = 'S';\r
1039 break;\r
1040\r
1041 default:\r
1042 Parity = 'x';\r
1043 break;\r
1044 }\r
1045\r
1046 if (Uart->BaudRate == 0) {\r
1047 CatPrint (Str, L"Uart(DEFAULT,");\r
1048 } else {\r
1049 CatPrint (Str, L"Uart(%ld,", Uart->BaudRate);\r
1050 }\r
1051\r
1052 if (Uart->DataBits == 0) {\r
1053 CatPrint (Str, L"DEFAULT,");\r
1054 } else {\r
1055 CatPrint (Str, L"%d,", Uart->DataBits);\r
1056 }\r
1057\r
1058 CatPrint (Str, L"%c,", Parity);\r
1059\r
1060 switch (Uart->StopBits) {\r
1061 case 0:\r
1062 CatPrint (Str, L"D)");\r
1063 break;\r
1064\r
1065 case 1:\r
1066 CatPrint (Str, L"1)");\r
1067 break;\r
1068\r
1069 case 2:\r
1070 CatPrint (Str, L"1.5)");\r
1071 break;\r
1072\r
1073 case 3:\r
1074 CatPrint (Str, L"2)");\r
1075 break;\r
1076\r
1077 default:\r
1078 CatPrint (Str, L"x)");\r
1079 break;\r
1080 }\r
1081}\r
1082\r
1083STATIC\r
1084VOID\r
1085DevPathToTextiSCSI (\r
1086 IN OUT POOL_PRINT *Str,\r
1087 IN VOID *DevPath,\r
1088 IN BOOLEAN DisplayOnly,\r
1089 IN BOOLEAN AllowShortcuts\r
1090 )\r
1091{\r
1092 ISCSI_DEVICE_PATH_WITH_NAME *iSCSI;\r
1093 UINT16 Options;\r
1094\r
1095 iSCSI = DevPath;\r
1096 CatPrint (\r
1097 Str,\r
1098 L"iSCSI(%s,%x,%lx,",\r
1099 iSCSI->iSCSITargetName,\r
1100 iSCSI->TargetPortalGroupTag,\r
1101 iSCSI->Lun\r
1102 );\r
1103\r
1104 Options = iSCSI->LoginOption;\r
1105 CatPrint (Str, L"%s,", ((Options >> 1) & 0x0001) ? L"CRC32C" : L"None");\r
1106 CatPrint (Str, L"%s,", ((Options >> 3) & 0x0001) ? L"CRC32C" : L"None");\r
1107 if ((Options >> 11) & 0x0001) {\r
1108 CatPrint (Str, L"%s,", L"None");\r
1109 } else if ((Options >> 12) & 0x0001) {\r
1110 CatPrint (Str, L"%s,", L"CHAP_UNI");\r
1111 } else {\r
1112 CatPrint (Str, L"%s,", L"CHAP_BI");\r
1113\r
1114 }\r
1115\r
1116 CatPrint (Str, L"%s)", (iSCSI->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
1117}\r
1118\r
1119STATIC\r
1120VOID\r
1121DevPathToTextHardDrive (\r
1122 IN OUT POOL_PRINT *Str,\r
1123 IN VOID *DevPath,\r
1124 IN BOOLEAN DisplayOnly,\r
1125 IN BOOLEAN AllowShortcuts\r
1126 )\r
1127{\r
1128 HARDDRIVE_DEVICE_PATH *Hd;\r
1129\r
1130 Hd = DevPath;\r
1131 switch (Hd->SignatureType) {\r
1132 case 0:\r
1133 CatPrint (\r
1134 Str,\r
1135 L"HD(%d,%s,0,",\r
1136 Hd->PartitionNumber,\r
1137 L"None"\r
1138 );\r
1139 break;\r
1140\r
1141 case SIGNATURE_TYPE_MBR:\r
1142 CatPrint (\r
1143 Str,\r
1144 L"HD(%d,%s,%08x,",\r
1145 Hd->PartitionNumber,\r
1146 L"MBR",\r
1147 *((UINT32 *) (&(Hd->Signature[0])))\r
1148 );\r
1149 break;\r
1150\r
1151 case SIGNATURE_TYPE_GUID:\r
1152 CatPrint (\r
1153 Str,\r
1154 L"HD(%d,%s,%g,",\r
1155 Hd->PartitionNumber,\r
1156 L"GUID",\r
1157 (EFI_GUID *) &(Hd->Signature[0])\r
1158 );\r
1159 break;\r
1160\r
1161 default:\r
1162 break;\r
1163 }\r
1164\r
1165 CatPrint (Str, L"%lx,%lx)", Hd->PartitionStart, Hd->PartitionSize);\r
1166}\r
1167\r
1168STATIC\r
1169VOID\r
1170DevPathToTextCDROM (\r
1171 IN OUT POOL_PRINT *Str,\r
1172 IN VOID *DevPath,\r
1173 IN BOOLEAN DisplayOnly,\r
1174 IN BOOLEAN AllowShortcuts\r
1175 )\r
1176{\r
1177 CDROM_DEVICE_PATH *Cd;\r
1178\r
1179 Cd = DevPath;\r
1180 if (DisplayOnly == TRUE) {\r
1181 CatPrint (Str, L"CDROM(%x)", Cd->BootEntry);\r
1182 return ;\r
1183 }\r
1184\r
1185 CatPrint (Str, L"CDROM(%x,%lx,%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
1186}\r
1187\r
1188STATIC\r
1189VOID\r
1190DevPathToTextFilePath (\r
1191 IN OUT POOL_PRINT *Str,\r
1192 IN VOID *DevPath,\r
1193 IN BOOLEAN DisplayOnly,\r
1194 IN BOOLEAN AllowShortcuts\r
1195 )\r
1196{\r
1197 FILEPATH_DEVICE_PATH *Fp;\r
1198\r
1199 Fp = DevPath;\r
1200 CatPrint (Str, L"%s", Fp->PathName);\r
1201}\r
1202\r
1203STATIC\r
1204VOID\r
1205DevPathToTextMediaProtocol (\r
1206 IN OUT POOL_PRINT *Str,\r
1207 IN VOID *DevPath,\r
1208 IN BOOLEAN DisplayOnly,\r
1209 IN BOOLEAN AllowShortcuts\r
1210 )\r
1211{\r
1212 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;\r
1213\r
1214 MediaProt = DevPath;\r
1215 CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
1216}\r
1217\r
1218STATIC\r
1219VOID\r
1220DevPathToTextBBS (\r
1221 IN OUT POOL_PRINT *Str,\r
1222 IN VOID *DevPath,\r
1223 IN BOOLEAN DisplayOnly,\r
1224 IN BOOLEAN AllowShortcuts\r
1225 )\r
1226{\r
1227 BBS_BBS_DEVICE_PATH *Bbs;\r
1228 CHAR16 *Type;\r
1229\r
1230 Bbs = DevPath;\r
1231 switch (Bbs->DeviceType) {\r
1232 case BBS_TYPE_FLOPPY:\r
1233 Type = L"Floppy";\r
1234 break;\r
1235\r
1236 case BBS_TYPE_HARDDRIVE:\r
1237 Type = L"HD";\r
1238 break;\r
1239\r
1240 case BBS_TYPE_CDROM:\r
1241 Type = L"CDROM";\r
1242 break;\r
1243\r
1244 case BBS_TYPE_PCMCIA:\r
1245 Type = L"PCMCIA";\r
1246 break;\r
1247\r
1248 case BBS_TYPE_USB:\r
1249 Type = L"USB";\r
1250 break;\r
1251\r
1252 case BBS_TYPE_EMBEDDED_NETWORK:\r
1253 Type = L"Network";\r
1254 break;\r
1255\r
1256 default:\r
1257 Type = L"?";\r
1258 break;\r
1259 }\r
1260\r
1261 CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r
1262\r
1263 if (DisplayOnly == TRUE) {\r
1264 CatPrint (Str, L")");\r
1265 return ;\r
1266 }\r
1267\r
1268 CatPrint (Str, L",%x)", Bbs->StatusFlag);\r
1269}\r
1270\r
1271STATIC\r
1272VOID\r
1273DevPathToTextEndInstance (\r
1274 IN OUT POOL_PRINT *Str,\r
1275 IN VOID *DevPath,\r
1276 IN BOOLEAN DisplayOnly,\r
1277 IN BOOLEAN AllowShortcuts\r
1278 )\r
1279{\r
1280 CatPrint (Str, L",");\r
1281}\r
1282\r
1283STATIC\r
1284VOID\r
1285DevPathToTextNodeUnknown (\r
1286 IN OUT POOL_PRINT *Str,\r
1287 IN VOID *DevPath,\r
1288 IN BOOLEAN DisplayOnly,\r
1289 IN BOOLEAN AllowShortcuts\r
1290 )\r
1291{\r
1292 CatPrint (Str, L"?");\r
1293}\r
1294\r
1295GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable[] = {\r
1296 {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci},\r
1297 {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard},\r
1298 {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap},\r
1299 {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor},\r
1300 {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController},\r
1301 {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi},\r
1302 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextExtAcpi},\r
1303 {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi},\r
1304 {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi},\r
1305 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre},\r
1306 {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394},\r
1307 {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb},\r
1308 {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID},\r
1309 {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit},\r
1310 {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass},\r
1311 {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O},\r
1312 {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr},\r
1313 {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4},\r
1314 {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6},\r
1315 {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand},\r
1316 {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart},\r
1317 {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor},\r
1318 {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI},\r
1319 {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive},\r
1320 {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM},\r
1321 {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor},\r
1322 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r
1323 {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol},\r
1324 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r
1325 {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS},\r
1326 {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance},\r
1327 {0, 0, NULL}\r
1328};\r
1329\r
1330CHAR16 *\r
1331ConvertDeviceNodeToText (\r
1332 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
1333 IN BOOLEAN DisplayOnly,\r
1334 IN BOOLEAN AllowShortcuts\r
1335 )\r
1336/*++\r
1337\r
1338 Routine Description:\r
1339 Convert a device node to its text representation.\r
1340\r
1341 Arguments:\r
1342 DeviceNode - Points to the device node to be converted.\r
1343 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation\r
1344 of the display node is used, where applicable. If DisplayOnly\r
1345 is FALSE, then the longer text representation of the display node\r
1346 is used.\r
1347 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text\r
1348 representation for a device node can be used, where applicable.\r
1349\r
1350 Returns:\r
1351 A pointer - a pointer to the allocated text representation of the device node.\r
1352 NULL - if DeviceNode is NULL or there was insufficient memory.\r
1353\r
1354--*/\r
1355{\r
1356 POOL_PRINT Str;\r
1357 UINTN Index;\r
1358 UINTN NewSize;\r
1359 VOID (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
1360\r
1361 if (DeviceNode == NULL) {\r
1362 return NULL;\r
1363 }\r
1364\r
1365 ZeroMem (&Str, sizeof (Str));\r
1366\r
1367 //\r
1368 // Process the device path node\r
1369 //\r
1370 DumpNode = NULL;\r
1371 for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index++) {\r
1372 if (DevicePathType (DeviceNode) == DevPathToTextTable[Index].Type &&\r
1373 DevicePathSubType (DeviceNode) == DevPathToTextTable[Index].SubType\r
1374 ) {\r
1375 DumpNode = DevPathToTextTable[Index].Function;\r
1376 break;\r
1377 }\r
1378 }\r
1379 //\r
1380 // If not found, use a generic function\r
1381 //\r
1382 if (DumpNode == NULL) {\r
1383 DumpNode = DevPathToTextNodeUnknown;\r
1384 }\r
1385\r
1386 //\r
1387 // Print this node\r
1388 //\r
1389 DumpNode (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r
1390\r
1391 //\r
1392 // Shrink pool used for string allocation\r
1393 //\r
1394 NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
1395 Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);\r
1396 ASSERT (Str.Str != NULL);\r
1397 Str.Str[Str.Len] = 0;\r
1398 return Str.Str;\r
1399}\r
1400\r
1401CHAR16 *\r
1402ConvertDevicePathToText (\r
1403 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
1404 IN BOOLEAN DisplayOnly,\r
1405 IN BOOLEAN AllowShortcuts\r
1406 )\r
1407/*++\r
1408\r
1409 Routine Description:\r
1410 Convert a device path to its text representation.\r
1411\r
1412 Arguments:\r
1413 DeviceNode - Points to the device path to be converted.\r
1414 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation\r
1415 of the display node is used, where applicable. If DisplayOnly\r
1416 is FALSE, then the longer text representation of the display node\r
1417 is used.\r
1418 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text\r
1419 representation for a device node can be used, where applicable.\r
1420\r
1421 Returns:\r
1422 A pointer - a pointer to the allocated text representation of the device path.\r
1423 NULL - if DeviceNode is NULL or there was insufficient memory.\r
1424\r
1425--*/\r
1426{\r
1427 POOL_PRINT Str;\r
1428 EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r
1429 EFI_DEVICE_PATH_PROTOCOL *UnpackDevPath;\r
1430 UINTN Index;\r
1431 UINTN NewSize;\r
1432 VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
1433\r
1434 if (DevicePath == NULL) {\r
1435 return NULL;\r
1436 }\r
1437\r
1438 ZeroMem (&Str, sizeof (Str));\r
1439\r
1440 //\r
1441 // Unpacked the device path\r
1442 //\r
1443 UnpackDevPath = UnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) DevicePath);\r
1444 ASSERT (UnpackDevPath != NULL);\r
1445\r
1446 //\r
1447 // Process each device path node\r
1448 //\r
1449 DevPathNode = UnpackDevPath;\r
1450 while (!IsDevicePathEnd (DevPathNode)) {\r
1451 //\r
1452 // Find the handler to dump this device path node\r
1453 //\r
1454 DumpNode = NULL;\r
1455 for (Index = 0; DevPathToTextTable[Index].Function; Index += 1) {\r
1456\r
1457 if (DevicePathType (DevPathNode) == DevPathToTextTable[Index].Type &&\r
1458 DevicePathSubType (DevPathNode) == DevPathToTextTable[Index].SubType\r
1459 ) {\r
1460 DumpNode = DevPathToTextTable[Index].Function;\r
1461 break;\r
1462 }\r
1463 }\r
1464 //\r
1465 // If not found, use a generic function\r
1466 //\r
1467 if (!DumpNode) {\r
1468 DumpNode = DevPathToTextNodeUnknown;\r
1469 }\r
1470 //\r
1471 // Put a path seperator in if needed\r
1472 //\r
1473 if (Str.Len && DumpNode != DevPathToTextEndInstance) {\r
1474 if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') { \r
1475 CatPrint (&Str, L"/");\r
1476 } \r
1477 }\r
1478 //\r
1479 // Print this node of the device path\r
1480 //\r
1481 DumpNode (&Str, DevPathNode, DisplayOnly, AllowShortcuts);\r
1482\r
1483 //\r
1484 // Next device path node\r
1485 //\r
1486 DevPathNode = NextDevicePathNode (DevPathNode);\r
1487 }\r
1488 //\r
1489 // Shrink pool used for string allocation\r
1490 //\r
1491 FreePool (UnpackDevPath);\r
1492\r
1493 NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
1494 Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);\r
1495 ASSERT (Str.Str != NULL);\r
1496 Str.Str[Str.Len] = 0;\r
1497 return Str.Str;\r
1498}\r