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