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