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