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