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