]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
1, Move device path utility macros from protocol's header file to DevicePathLib libra...
[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
572f5d8a 17/**\r
18 Function unpacks a device path data structure so that all the nodes of a device path\r
19 are naturally aligned.\r
20\r
21 @param DevPath A pointer to a device path data structure\r
22\r
23 @return If the memory for the device path is successfully allocated, then a pointer to the\r
24 new device path is returned. Otherwise, NULL is returned.\r
25\r
26**/\r
95276127 27EFI_DEVICE_PATH_PROTOCOL *\r
28UnpackDevicePath (\r
9ef1a3ca 29 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath\r
95276127 30 )\r
95276127 31{\r
9ef1a3ca 32 CONST EFI_DEVICE_PATH_PROTOCOL *Src;\r
95276127 33 EFI_DEVICE_PATH_PROTOCOL *Dest;\r
34 EFI_DEVICE_PATH_PROTOCOL *NewPath;\r
35 UINTN Size;\r
36\r
37 if (DevPath == NULL) {\r
38 return NULL;\r
39 }\r
40 //\r
41 // Walk device path and round sizes to valid boundries\r
42 //\r
43 Src = DevPath;\r
44 Size = 0;\r
45 for (;;) {\r
46 Size += DevicePathNodeLength (Src);\r
47 Size += ALIGN_SIZE (Size);\r
48\r
49 if (IsDevicePathEnd (Src)) {\r
50 break;\r
51 }\r
52\r
53 Src = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (Src);\r
54 }\r
55 //\r
56 // Allocate space for the unpacked path\r
57 //\r
58 NewPath = AllocateZeroPool (Size);\r
59 if (NewPath != NULL) {\r
60\r
61 ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0);\r
62\r
63 //\r
64 // Copy each node\r
65 //\r
66 Src = DevPath;\r
67 Dest = NewPath;\r
68 for (;;) {\r
69 Size = DevicePathNodeLength (Src);\r
70 CopyMem (Dest, Src, Size);\r
71 Size += ALIGN_SIZE (Size);\r
72 SetDevicePathNodeLength (Dest, Size);\r
73 Dest->Type |= EFI_DP_TYPE_UNPACKED;\r
74 Dest = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) Dest) + Size);\r
75\r
76 if (IsDevicePathEnd (Src)) {\r
77 break;\r
78 }\r
79\r
80 Src = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (Src);\r
81 }\r
82 }\r
83\r
84 return NewPath;\r
85}\r
86\r
572f5d8a 87/**\r
88 Adjusts the size of a previously allocated buffer.\r
89\r
90 @param OldPool A pointer to the buffer whose size is being adjusted.\r
91 @param OldSize The size of the current buffer.\r
92 @param NewSize The size of the new buffer.\r
93\r
94 @return A pointer to the new buffer or NULL if allocation fails.\r
95\r
96**/\r
95276127 97VOID *\r
98ReallocatePool (\r
99 IN VOID *OldPool,\r
100 IN UINTN OldSize,\r
101 IN UINTN NewSize\r
102 )\r
95276127 103{\r
104 VOID *NewPool;\r
105\r
106 NewPool = NULL;\r
572f5d8a 107 if (NewSize != 0) {\r
95276127 108 NewPool = AllocateZeroPool (NewSize);\r
109 }\r
110\r
572f5d8a 111 if (OldPool != NULL) {\r
112 if (NewPool != NULL) {\r
95276127 113 CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
114 }\r
115\r
116 FreePool (OldPool);\r
117 }\r
118\r
119 return NewPool;\r
120}\r
121\r
572f5d8a 122/**\r
123 Concatenates a formatted unicode string to allocated pool. The caller must\r
124 free the resulting buffer.\r
125\r
126 @param Str Tracks the allocated pool, size in use, and\r
127 amount of pool allocated.\r
128 @param Fmt The format string\r
129 @param ... Variable arguments based on the format string.\r
130\r
131 @return Allocated buffer with the formatted string printed in it.\r
132 The caller must free the allocated buffer. The buffer\r
133 allocation is not packed.\r
134\r
135**/\r
95276127 136CHAR16 *\r
137CatPrint (\r
138 IN OUT POOL_PRINT *Str,\r
139 IN CHAR16 *Fmt,\r
140 ...\r
141 )\r
95276127 142{\r
143 UINT16 *AppendStr;\r
144 VA_LIST Args;\r
145 UINTN Size;\r
146\r
147 AppendStr = AllocateZeroPool (0x1000);\r
148 if (AppendStr == NULL) {\r
149 return Str->Str;\r
150 }\r
151\r
152 VA_START (Args, Fmt);\r
153 UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);\r
154 VA_END (Args);\r
155 if (NULL == Str->Str) {\r
156 Size = StrSize (AppendStr);\r
157 Str->Str = AllocateZeroPool (Size);\r
158 ASSERT (Str->Str != NULL);\r
159 } else {\r
572f5d8a 160 Size = StrSize (AppendStr) - sizeof (UINT16);\r
95276127 161 Size = Size + StrSize (Str->Str);\r
162 Str->Str = ReallocatePool (\r
163 Str->Str,\r
164 StrSize (Str->Str),\r
165 Size\r
166 );\r
167 ASSERT (Str->Str != NULL);\r
168 }\r
169\r
170 Str->MaxLen = MAX_CHAR * sizeof (UINT16);\r
171 if (Size < Str->MaxLen) {\r
172 StrCat (Str->Str, AppendStr);\r
173 Str->Len = Size - sizeof (UINT16);\r
174 }\r
175\r
176 FreePool (AppendStr);\r
177 return Str->Str;\r
178}\r
179\r
572f5d8a 180/**\r
181 Converts a PCI device path structure to its string representive.\r
182\r
183 @param Str The string representive of input device.\r
184 @param DevPath The input device path structure.\r
185 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
186 of the display node is used, where applicable. If DisplayOnly\r
187 is FALSE, then the longer text representation of the display node\r
188 is used.\r
189 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
190 representation for a device node can be used, where applicable.\r
191\r
192**/\r
95276127 193VOID\r
194DevPathToTextPci (\r
195 IN OUT POOL_PRINT *Str,\r
196 IN VOID *DevPath,\r
197 IN BOOLEAN DisplayOnly,\r
198 IN BOOLEAN AllowShortcuts\r
199 )\r
200{\r
201 PCI_DEVICE_PATH *Pci;\r
202\r
203 Pci = DevPath;\r
cf40f28a 204 CatPrint (Str, L"Pci(0x%x,0x%x)", Pci->Device, Pci->Function);\r
95276127 205}\r
206\r
572f5d8a 207/**\r
208 Converts a PC Card device path structure to its string representive.\r
209\r
210 @param Str The string representive of input device.\r
211 @param DevPath The input device path structure.\r
212 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
213 of the display node is used, where applicable. If DisplayOnly\r
214 is FALSE, then the longer text representation of the display node\r
215 is used.\r
216 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
217 representation for a device node can be used, where applicable.\r
218\r
219**/\r
95276127 220VOID\r
221DevPathToTextPccard (\r
222 IN OUT POOL_PRINT *Str,\r
223 IN VOID *DevPath,\r
224 IN BOOLEAN DisplayOnly,\r
225 IN BOOLEAN AllowShortcuts\r
226 )\r
227{\r
228 PCCARD_DEVICE_PATH *Pccard;\r
229\r
230 Pccard = DevPath;\r
cf40f28a 231 CatPrint (Str, L"PcCard(0x%x)", Pccard->FunctionNumber);\r
95276127 232}\r
233\r
572f5d8a 234/**\r
235 Converts a Memory Map device path structure to its string representive.\r
236\r
237 @param Str The string representive of input device.\r
238 @param DevPath The input device path structure.\r
239 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
240 of the display node is used, where applicable. If DisplayOnly\r
241 is FALSE, then the longer text representation of the display node\r
242 is used.\r
243 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
244 representation for a device node can be used, where applicable.\r
245\r
246**/\r
95276127 247VOID\r
248DevPathToTextMemMap (\r
249 IN OUT POOL_PRINT *Str,\r
250 IN VOID *DevPath,\r
251 IN BOOLEAN DisplayOnly,\r
252 IN BOOLEAN AllowShortcuts\r
253 )\r
254{\r
255 MEMMAP_DEVICE_PATH *MemMap;\r
256\r
257 MemMap = DevPath;\r
258 CatPrint (\r
259 Str,\r
cf40f28a 260 L"MemoryMapped(0x%x,0x%lx,0x%lx)",\r
261 MemMap->MemoryType,\r
95276127 262 MemMap->StartingAddress,\r
263 MemMap->EndingAddress\r
264 );\r
265}\r
266\r
572f5d8a 267/**\r
268 Converts a Vendor device path structure to its string representive.\r
269\r
270 @param Str The string representive of input device.\r
271 @param DevPath The input device path structure.\r
272 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
273 of the display node is used, where applicable. If DisplayOnly\r
274 is FALSE, then the longer text representation of the display node\r
275 is used.\r
276 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
277 representation for a device node can be used, where applicable.\r
278\r
279**/\r
95276127 280VOID\r
281DevPathToTextVendor (\r
282 IN OUT POOL_PRINT *Str,\r
283 IN VOID *DevPath,\r
284 IN BOOLEAN DisplayOnly,\r
285 IN BOOLEAN AllowShortcuts\r
286 )\r
287{\r
288 VENDOR_DEVICE_PATH *Vendor;\r
289 CHAR16 *Type;\r
290 UINTN Index;\r
cf40f28a 291 UINTN DataLength;\r
95276127 292 UINT32 FlowControlMap;\r
293 UINT16 Info;\r
294\r
295 Vendor = (VENDOR_DEVICE_PATH *) DevPath;\r
296 switch (DevicePathType (&Vendor->Header)) {\r
297 case HARDWARE_DEVICE_PATH:\r
298 Type = L"Hw";\r
299 break;\r
300\r
301 case MESSAGING_DEVICE_PATH:\r
302 Type = L"Msg";\r
303 if (AllowShortcuts) {\r
304 if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {\r
305 CatPrint (Str, L"VenPcAnsi()");\r
306 return ;\r
307 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {\r
308 CatPrint (Str, L"VenVt100()");\r
309 return ;\r
310 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {\r
311 CatPrint (Str, L"VenVt100Plus()");\r
312 return ;\r
313 } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {\r
314 CatPrint (Str, L"VenUft8()");\r
315 return ;\r
316 } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingUartFlowControlGuid)) {\r
317 FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);\r
318 switch (FlowControlMap & 0x00000003) {\r
319 case 0:\r
320 CatPrint (Str, L"UartFlowCtrl(%s)", L"None");\r
321 break;\r
322\r
323 case 1:\r
324 CatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware");\r
325 break;\r
326\r
327 case 2:\r
328 CatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff");\r
329 break;\r
330\r
331 default:\r
332 break;\r
333 }\r
334\r
335 return ;\r
336 } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingSASGuid)) {\r
337 CatPrint (\r
338 Str,\r
cf40f28a 339 L"SAS(0x%lx,0x%lx,0x%x,",\r
95276127 340 ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r
341 ((SAS_DEVICE_PATH *) Vendor)->Lun,\r
342 ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
343 );\r
344 Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);\r
345 if ((Info & 0x0f) == 0) {\r
346 CatPrint (Str, L"NoTopology,0,0,0,");\r
347 } else if (((Info & 0x0f) == 1) || ((Info & 0x0f) == 2)) {\r
348 CatPrint (\r
349 Str,\r
350 L"%s,%s,%s,",\r
572f5d8a 351 ((Info & (0x1 << 4)) != 0) ? L"SATA" : L"SAS",\r
352 ((Info & (0x1 << 5)) != 0) ? L"External" : L"Internal",\r
353 ((Info & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct"\r
95276127 354 );\r
355 if ((Info & 0x0f) == 1) {\r
356 CatPrint (Str, L"0,");\r
357 } else {\r
cf40f28a 358 CatPrint (Str, L"0x%x,", (Info >> 8) & 0xff);\r
95276127 359 }\r
360 } else {\r
361 CatPrint (Str, L"0,0,0,0,");\r
362 }\r
363\r
cf40f28a 364 CatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
95276127 365 return ;\r
366 } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r
367 CatPrint (Str, L"DebugPort()");\r
368 return ;\r
95276127 369 }\r
370 }\r
371 break;\r
372\r
373 case MEDIA_DEVICE_PATH:\r
374 Type = L"Media";\r
375 break;\r
376\r
377 default:\r
378 Type = L"?";\r
379 break;\r
380 }\r
381\r
cf40f28a 382 DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);\r
383 CatPrint (Str, L"Ven%s(%g", Type, &Vendor->Guid);\r
384 if (DataLength != 0) {\r
385 CatPrint (Str, L",");\r
386 for (Index = 0; Index < DataLength; Index++) {\r
387 CatPrint (Str, L"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r
388 }\r
95276127 389 }\r
390\r
391 CatPrint (Str, L")");\r
392}\r
393\r
572f5d8a 394/**\r
395 Converts a Controller device path structure to its string representive.\r
396\r
397 @param Str The string representive of input device.\r
398 @param DevPath The input device path structure.\r
399 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
400 of the display node is used, where applicable. If DisplayOnly\r
401 is FALSE, then the longer text representation of the display node\r
402 is used.\r
403 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
404 representation for a device node can be used, where applicable.\r
405\r
406**/\r
95276127 407VOID\r
408DevPathToTextController (\r
409 IN OUT POOL_PRINT *Str,\r
410 IN VOID *DevPath,\r
411 IN BOOLEAN DisplayOnly,\r
412 IN BOOLEAN AllowShortcuts\r
413 )\r
414{\r
415 CONTROLLER_DEVICE_PATH *Controller;\r
416\r
417 Controller = DevPath;\r
418 CatPrint (\r
419 Str,\r
cf40f28a 420 L"Ctrl(0x%x)",\r
95276127 421 Controller->ControllerNumber\r
422 );\r
423}\r
424\r
572f5d8a 425/**\r
426 Converts a ACPI device path structure to its string representive.\r
427\r
428 @param Str The string representive of input device.\r
429 @param DevPath The input device path structure.\r
430 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
431 of the display node is used, where applicable. If DisplayOnly\r
432 is FALSE, then the longer text representation of the display node\r
433 is used.\r
434 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
435 representation for a device node can be used, where applicable.\r
436\r
437**/\r
95276127 438VOID\r
439DevPathToTextAcpi (\r
440 IN OUT POOL_PRINT *Str,\r
441 IN VOID *DevPath,\r
442 IN BOOLEAN DisplayOnly,\r
443 IN BOOLEAN AllowShortcuts\r
444 )\r
445{\r
446 ACPI_HID_DEVICE_PATH *Acpi;\r
447\r
448 Acpi = DevPath;\r
449 if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
cf40f28a 450 switch (EISA_ID_TO_NUM (Acpi->HID)) {\r
451 case 0x0a03:\r
452 CatPrint (Str, L"PciRoot(0x%x)", Acpi->UID);\r
453 break;\r
95276127 454\r
cf40f28a 455 case 0x0604:\r
456 CatPrint (Str, L"Floppy(0x%x)", Acpi->UID);\r
457 break;\r
95276127 458\r
cf40f28a 459 case 0x0301:\r
460 CatPrint (Str, L"Keyboard(0x%x)", Acpi->UID);\r
461 break;\r
95276127 462\r
cf40f28a 463 case 0x0501:\r
464 CatPrint (Str, L"Serial(0x%x)", Acpi->UID);\r
465 break;\r
95276127 466\r
cf40f28a 467 case 0x0401:\r
468 CatPrint (Str, L"ParallelPort(0x%x)", Acpi->UID);\r
469 break;\r
95276127 470\r
cf40f28a 471 default:\r
472 CatPrint (Str, L"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);\r
473 break;\r
95276127 474 }\r
95276127 475 } else {\r
cf40f28a 476 CatPrint (Str, L"Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID);\r
95276127 477 }\r
478}\r
479\r
572f5d8a 480/**\r
481 Converts EISA identification to string.\r
482\r
483 @param EisaId The input EISA identification.\r
484 @param Text A pointer to the output string.\r
485\r
486**/\r
cf40f28a 487VOID\r
488EisaIdToText (\r
489 IN UINT32 EisaId,\r
572f5d8a 490 IN OUT CHAR16 *Text\r
cf40f28a 491 )\r
492{\r
493 CHAR16 PnpIdStr[17];\r
494\r
495 //\r
496 //UnicodeSPrint ("%X", 0x0a03) => "0000000000000A03"\r
497 //\r
372285d1 498 UnicodeSPrint (PnpIdStr, 17 * 2, L"%16X", EisaId >> 16);\r
cf40f28a 499\r
500 UnicodeSPrint (\r
501 Text,\r
372285d1 502 sizeof (CHAR16) + sizeof (CHAR16) + sizeof (CHAR16) + sizeof (PnpIdStr),\r
cf40f28a 503 L"%c%c%c%s",\r
504 '@' + ((EisaId >> 10) & 0x1f),\r
505 '@' + ((EisaId >> 5) & 0x1f),\r
506 '@' + ((EisaId >> 0) & 0x1f),\r
507 PnpIdStr + (16 - 4)\r
508 );\r
509}\r
95276127 510\r
572f5d8a 511/**\r
512 Converts a ACPI extended HID device path structure to its string representive.\r
513\r
514 @param Str The string representive of input device.\r
515 @param DevPath The input device path structure.\r
516 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
517 of the display node is used, where applicable. If DisplayOnly\r
518 is FALSE, then the longer text representation of the display node\r
519 is used.\r
520 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
521 representation for a device node can be used, where applicable.\r
522\r
523**/\r
95276127 524VOID\r
cf40f28a 525DevPathToTextAcpiEx (\r
95276127 526 IN OUT POOL_PRINT *Str,\r
527 IN VOID *DevPath,\r
528 IN BOOLEAN DisplayOnly,\r
529 IN BOOLEAN AllowShortcuts\r
530 )\r
531{\r
cf40f28a 532 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r
533 CHAR8 *HIDStr;\r
534 CHAR8 *UIDStr;\r
535 CHAR8 *CIDStr;\r
536 CHAR16 HIDText[11];\r
537 CHAR16 CIDText[11];\r
538\r
539 AcpiEx = DevPath;\r
540 HIDStr = (CHAR8 *) (((UINT8 *) AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
541 UIDStr = HIDStr + AsciiStrLen (HIDStr) + 1;\r
542 CIDStr = UIDStr + AsciiStrLen (UIDStr) + 1;\r
543\r
544 EisaIdToText (AcpiEx->HID, HIDText);\r
545 EisaIdToText (AcpiEx->CID, CIDText);\r
546\r
547 if ((*HIDStr == '\0') && (*CIDStr == '\0') && (AcpiEx->UID == 0)) {\r
548 //\r
549 // use AcpiExp()\r
550 //\r
551 CatPrint (\r
552 Str,\r
553 L"AcpiExp(%s,%s,%a)",\r
554 HIDText,\r
555 CIDText,\r
556 UIDStr\r
557 );\r
558 } else {\r
559 if (AllowShortcuts) {\r
560 //\r
561 // display only\r
562 //\r
563 if (AcpiEx->HID == 0) {\r
564 CatPrint (Str, L"AcpiEx(%a,", HIDStr);\r
565 } else {\r
566 CatPrint (Str, L"AcpiEx(%s,", HIDText);\r
567 }\r
95276127 568\r
cf40f28a 569 if (AcpiEx->UID == 0) {\r
570 CatPrint (Str, L"%a,", UIDStr);\r
571 } else {\r
572 CatPrint (Str, L"0x%x,", AcpiEx->UID);\r
573 }\r
95276127 574\r
cf40f28a 575 if (AcpiEx->CID == 0) {\r
576 CatPrint (Str, L"%a)", CIDStr);\r
95276127 577 } else {\r
cf40f28a 578 CatPrint (Str, L"%s)", CIDText);\r
95276127 579 }\r
cf40f28a 580 } else {\r
581 CatPrint (\r
582 Str,\r
583 L"AcpiEx(%s,%s,0x%x,%a,%a,%a)",\r
584 HIDText,\r
585 CIDText,\r
586 AcpiEx->UID,\r
587 HIDStr,\r
588 CIDStr,\r
589 UIDStr\r
590 );\r
95276127 591 }\r
95276127 592 }\r
cf40f28a 593}\r
95276127 594\r
572f5d8a 595/**\r
596 Converts a ACPI address device path structure to its string representive.\r
597\r
598 @param Str The string representive of input device.\r
599 @param DevPath The input device path structure.\r
600 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
601 of the display node is used, where applicable. If DisplayOnly\r
602 is FALSE, then the longer text representation of the display node\r
603 is used.\r
604 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
605 representation for a device node can be used, where applicable.\r
606\r
607**/\r
cf40f28a 608VOID\r
609DevPathToTextAcpiAdr (\r
610 IN OUT POOL_PRINT *Str,\r
611 IN VOID *DevPath,\r
612 IN BOOLEAN DisplayOnly,\r
613 IN BOOLEAN AllowShortcuts\r
614 )\r
615{\r
616 ACPI_ADR_DEVICE_PATH *AcpiAdr;\r
617 UINT16 Index;\r
618 UINT16 Length;\r
619 UINT16 AdditionalAdrCount;\r
620\r
621 AcpiAdr = DevPath;\r
622 Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);\r
623 AdditionalAdrCount = (UINT16) ((Length - 8) / 4);\r
624\r
625 CatPrint (Str, L"AcpiAdr(0x%x", AcpiAdr->ADR);\r
626 for (Index = 0; Index < AdditionalAdrCount; Index++) {\r
627 CatPrint (Str, L",0x%x", *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r
95276127 628 }\r
cf40f28a 629 CatPrint (Str, L")");\r
95276127 630}\r
631\r
572f5d8a 632/**\r
633 Converts a ATAPI device path structure to its string representive.\r
634\r
635 @param Str The string representive of input device.\r
636 @param DevPath The input device path structure.\r
637 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
638 of the display node is used, where applicable. If DisplayOnly\r
639 is FALSE, then the longer text representation of the display node\r
640 is used.\r
641 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
642 representation for a device node can be used, where applicable.\r
643\r
644**/\r
95276127 645VOID\r
646DevPathToTextAtapi (\r
647 IN OUT POOL_PRINT *Str,\r
648 IN VOID *DevPath,\r
649 IN BOOLEAN DisplayOnly,\r
650 IN BOOLEAN AllowShortcuts\r
651 )\r
652{\r
653 ATAPI_DEVICE_PATH *Atapi;\r
654\r
655 Atapi = DevPath;\r
656\r
657 if (DisplayOnly) {\r
cf40f28a 658 CatPrint (Str, L"Ata(0x%x)", Atapi->Lun);\r
95276127 659 } else {\r
660 CatPrint (\r
661 Str,\r
cf40f28a 662 L"Ata(%s,%s,0x%x)",\r
95276127 663 Atapi->PrimarySecondary ? L"Secondary" : L"Primary",\r
664 Atapi->SlaveMaster ? L"Slave" : L"Master",\r
665 Atapi->Lun\r
666 );\r
667 }\r
668}\r
669\r
572f5d8a 670/**\r
671 Converts a SCSI device path structure to its string representive.\r
672\r
673 @param Str The string representive of input device.\r
674 @param DevPath The input device path structure.\r
675 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
676 of the display node is used, where applicable. If DisplayOnly\r
677 is FALSE, then the longer text representation of the display node\r
678 is used.\r
679 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
680 representation for a device node can be used, where applicable.\r
681\r
682**/\r
95276127 683VOID\r
684DevPathToTextScsi (\r
685 IN OUT POOL_PRINT *Str,\r
686 IN VOID *DevPath,\r
687 IN BOOLEAN DisplayOnly,\r
688 IN BOOLEAN AllowShortcuts\r
689 )\r
690{\r
691 SCSI_DEVICE_PATH *Scsi;\r
692\r
693 Scsi = DevPath;\r
cf40f28a 694 CatPrint (Str, L"Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun);\r
95276127 695}\r
696\r
572f5d8a 697/**\r
698 Converts a Fibre device path structure to its string representive.\r
699\r
700 @param Str The string representive of input device.\r
701 @param DevPath The input device path structure.\r
702 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
703 of the display node is used, where applicable. If DisplayOnly\r
704 is FALSE, then the longer text representation of the display node\r
705 is used.\r
706 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
707 representation for a device node can be used, where applicable.\r
708\r
709**/\r
95276127 710VOID\r
711DevPathToTextFibre (\r
712 IN OUT POOL_PRINT *Str,\r
713 IN VOID *DevPath,\r
714 IN BOOLEAN DisplayOnly,\r
715 IN BOOLEAN AllowShortcuts\r
716 )\r
717{\r
718 FIBRECHANNEL_DEVICE_PATH *Fibre;\r
719\r
720 Fibre = DevPath;\r
cf40f28a 721 CatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);\r
95276127 722}\r
723\r
572f5d8a 724/**\r
725 Converts a 1394 device path structure to its string representive.\r
726\r
727 @param Str The string representive of input device.\r
728 @param DevPath The input device path structure.\r
729 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
730 of the display node is used, where applicable. If DisplayOnly\r
731 is FALSE, then the longer text representation of the display node\r
732 is used.\r
733 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
734 representation for a device node can be used, where applicable.\r
735\r
736**/\r
95276127 737VOID\r
738DevPathToText1394 (\r
739 IN OUT POOL_PRINT *Str,\r
740 IN VOID *DevPath,\r
741 IN BOOLEAN DisplayOnly,\r
742 IN BOOLEAN AllowShortcuts\r
743 )\r
744{\r
572f5d8a 745 F1394_DEVICE_PATH *F1394DevPath;\r
95276127 746\r
572f5d8a 747 F1394DevPath = DevPath;\r
cf40f28a 748 //\r
749 // Guid has format of IEEE-EUI64\r
750 //\r
572f5d8a 751 CatPrint (Str, L"I1394(%016lx)", F1394DevPath->Guid);\r
95276127 752}\r
753\r
572f5d8a 754/**\r
755 Converts a USB device path structure to its string representive.\r
756\r
757 @param Str The string representive of input device.\r
758 @param DevPath The input device path structure.\r
759 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
760 of the display node is used, where applicable. If DisplayOnly\r
761 is FALSE, then the longer text representation of the display node\r
762 is used.\r
763 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
764 representation for a device node can be used, where applicable.\r
765\r
766**/\r
95276127 767VOID\r
768DevPathToTextUsb (\r
769 IN OUT POOL_PRINT *Str,\r
770 IN VOID *DevPath,\r
771 IN BOOLEAN DisplayOnly,\r
772 IN BOOLEAN AllowShortcuts\r
773 )\r
774{\r
775 USB_DEVICE_PATH *Usb;\r
776\r
777 Usb = DevPath;\r
cf40f28a 778 CatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);\r
95276127 779}\r
780\r
572f5d8a 781/**\r
782 Converts a USB WWID device path structure to its string representive.\r
783\r
784 @param Str The string representive of input device.\r
785 @param DevPath The input device path structure.\r
786 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
787 of the display node is used, where applicable. If DisplayOnly\r
788 is FALSE, then the longer text representation of the display node\r
789 is used.\r
790 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
791 representation for a device node can be used, where applicable.\r
792\r
793**/\r
95276127 794VOID\r
795DevPathToTextUsbWWID (\r
796 IN OUT POOL_PRINT *Str,\r
797 IN VOID *DevPath,\r
798 IN BOOLEAN DisplayOnly,\r
799 IN BOOLEAN AllowShortcuts\r
800 )\r
801{\r
802 USB_WWID_DEVICE_PATH *UsbWWId;\r
cf40f28a 803 CHAR16 *SerialNumberStr;\r
804 CHAR16 *NewStr;\r
805 UINT16 Length;\r
95276127 806\r
807 UsbWWId = DevPath;\r
cf40f28a 808\r
809 SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof (USB_WWID_DEVICE_PATH));\r
810 Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));\r
811 if (SerialNumberStr [Length - 1] != 0) {\r
812 //\r
813 // In case no NULL terminator in SerialNumber, create a new one with NULL terminator\r
814 //\r
815 NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);\r
816 NewStr [Length] = 0;\r
817 SerialNumberStr = NewStr;\r
818 }\r
819\r
95276127 820 CatPrint (\r
821 Str,\r
cf40f28a 822 L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",\r
95276127 823 UsbWWId->VendorId,\r
824 UsbWWId->ProductId,\r
cf40f28a 825 UsbWWId->InterfaceNumber,\r
826 SerialNumberStr\r
95276127 827 );\r
828}\r
829\r
572f5d8a 830/**\r
831 Converts a Logic Unit device path structure to its string representive.\r
832\r
833 @param Str The string representive of input device.\r
834 @param DevPath The input device path structure.\r
835 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
836 of the display node is used, where applicable. If DisplayOnly\r
837 is FALSE, then the longer text representation of the display node\r
838 is used.\r
839 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
840 representation for a device node can be used, where applicable.\r
841\r
842**/\r
95276127 843VOID\r
844DevPathToTextLogicalUnit (\r
845 IN OUT POOL_PRINT *Str,\r
846 IN VOID *DevPath,\r
847 IN BOOLEAN DisplayOnly,\r
848 IN BOOLEAN AllowShortcuts\r
849 )\r
850{\r
851 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
852\r
853 LogicalUnit = DevPath;\r
cf40f28a 854 CatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun);\r
95276127 855}\r
856\r
572f5d8a 857/**\r
858 Converts a USB class device path structure to its string representive.\r
859\r
860 @param Str The string representive of input device.\r
861 @param DevPath The input device path structure.\r
862 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
863 of the display node is used, where applicable. If DisplayOnly\r
864 is FALSE, then the longer text representation of the display node\r
865 is used.\r
866 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
867 representation for a device node can be used, where applicable.\r
868\r
869**/\r
95276127 870VOID\r
871DevPathToTextUsbClass (\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 USB_CLASS_DEVICE_PATH *UsbClass;\r
cf40f28a 879 BOOLEAN IsKnownSubClass;\r
880\r
95276127 881\r
882 UsbClass = DevPath;\r
883\r
cf40f28a 884 IsKnownSubClass = TRUE;\r
885 switch (UsbClass->DeviceClass) {\r
886 case USB_CLASS_AUDIO:\r
887 CatPrint (Str, L"UsbAudio");\r
888 break;\r
95276127 889\r
cf40f28a 890 case USB_CLASS_CDCCONTROL:\r
891 CatPrint (Str, L"UsbCDCControl");\r
892 break;\r
95276127 893\r
cf40f28a 894 case USB_CLASS_HID:\r
895 CatPrint (Str, L"UsbHID");\r
896 break;\r
95276127 897\r
cf40f28a 898 case USB_CLASS_IMAGE:\r
899 CatPrint (Str, L"UsbImage");\r
900 break;\r
95276127 901\r
cf40f28a 902 case USB_CLASS_PRINTER:\r
903 CatPrint (Str, L"UsbPrinter");\r
904 break;\r
95276127 905\r
cf40f28a 906 case USB_CLASS_MASS_STORAGE:\r
907 CatPrint (Str, L"UsbMassStorage");\r
908 break;\r
95276127 909\r
cf40f28a 910 case USB_CLASS_HUB:\r
911 CatPrint (Str, L"UsbHub");\r
912 break;\r
95276127 913\r
cf40f28a 914 case USB_CLASS_CDCDATA:\r
915 CatPrint (Str, L"UsbCDCData");\r
916 break;\r
95276127 917\r
cf40f28a 918 case USB_CLASS_SMART_CARD:\r
919 CatPrint (Str, L"UsbSmartCard");\r
920 break;\r
95276127 921\r
cf40f28a 922 case USB_CLASS_VIDEO:\r
923 CatPrint (Str, L"UsbVideo");\r
924 break;\r
925\r
926 case USB_CLASS_DIAGNOSTIC:\r
927 CatPrint (Str, L"UsbDiagnostic");\r
928 break;\r
929\r
930 case USB_CLASS_WIRELESS:\r
931 CatPrint (Str, L"UsbWireless");\r
932 break;\r
933\r
934 default:\r
935 IsKnownSubClass = FALSE;\r
936 break;\r
937 }\r
938\r
939 if (IsKnownSubClass) {\r
940 CatPrint (\r
941 Str,\r
942 L"(0x%x,0x%x,0x%x,0x%x)",\r
943 UsbClass->VendorId,\r
944 UsbClass->ProductId,\r
945 UsbClass->DeviceSubClass,\r
946 UsbClass->DeviceProtocol\r
947 );\r
948 return;\r
949 }\r
950\r
951 if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {\r
952 if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {\r
95276127 953 CatPrint (\r
954 Str,\r
cf40f28a 955 L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",\r
95276127 956 UsbClass->VendorId,\r
957 UsbClass->ProductId,\r
95276127 958 UsbClass->DeviceProtocol\r
959 );\r
cf40f28a 960 return;\r
961 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {\r
95276127 962 CatPrint (\r
963 Str,\r
cf40f28a 964 L"UsbIrdaBridge(0x%x,0x%x,0x%x)",\r
95276127 965 UsbClass->VendorId,\r
966 UsbClass->ProductId,\r
95276127 967 UsbClass->DeviceProtocol\r
968 );\r
cf40f28a 969 return;\r
970 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {\r
95276127 971 CatPrint (\r
972 Str,\r
cf40f28a 973 L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",\r
95276127 974 UsbClass->VendorId,\r
975 UsbClass->ProductId,\r
95276127 976 UsbClass->DeviceProtocol\r
977 );\r
cf40f28a 978 return;\r
95276127 979 }\r
95276127 980 }\r
981\r
982 CatPrint (\r
983 Str,\r
cf40f28a 984 L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",\r
95276127 985 UsbClass->VendorId,\r
986 UsbClass->ProductId,\r
987 UsbClass->DeviceClass,\r
988 UsbClass->DeviceSubClass,\r
989 UsbClass->DeviceProtocol\r
990 );\r
991}\r
992\r
572f5d8a 993/**\r
994 Converts a SATA device path structure to its string representive.\r
995\r
996 @param Str The string representive of input device.\r
997 @param DevPath The input device path structure.\r
998 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
999 of the display node is used, where applicable. If DisplayOnly\r
1000 is FALSE, then the longer text representation of the display node\r
1001 is used.\r
1002 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1003 representation for a device node can be used, where applicable.\r
1004\r
1005**/\r
cf40f28a 1006VOID\r
1007DevPathToTextSata (\r
1008 IN OUT POOL_PRINT *Str,\r
1009 IN VOID *DevPath,\r
1010 IN BOOLEAN DisplayOnly,\r
1011 IN BOOLEAN AllowShortcuts\r
1012 )\r
1013{\r
1014 SATA_DEVICE_PATH *Sata;\r
1015\r
1016 Sata = DevPath;\r
1017 CatPrint (\r
1018 Str,\r
1019 L"Sata(0x%x,0x%x,0x%x)",\r
93e3992d 1020 (UINTN) Sata->HBAPortNumber,\r
1021 (UINTN) Sata->PortMultiplierPortNumber,\r
1022 (UINTN) Sata->Lun\r
cf40f28a 1023 );\r
1024}\r
1025\r
572f5d8a 1026/**\r
1027 Converts a I20 device path structure to its string representive.\r
1028\r
1029 @param Str The string representive of input device.\r
1030 @param DevPath The input device path structure.\r
1031 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1032 of the display node is used, where applicable. If DisplayOnly\r
1033 is FALSE, then the longer text representation of the display node\r
1034 is used.\r
1035 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1036 representation for a device node can be used, where applicable.\r
1037\r
1038**/\r
95276127 1039VOID\r
1040DevPathToTextI2O (\r
1041 IN OUT POOL_PRINT *Str,\r
1042 IN VOID *DevPath,\r
1043 IN BOOLEAN DisplayOnly,\r
1044 IN BOOLEAN AllowShortcuts\r
1045 )\r
1046{\r
572f5d8a 1047 I2O_DEVICE_PATH *I2ODevPath;\r
95276127 1048\r
572f5d8a 1049 I2ODevPath = DevPath;\r
1050 CatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid);\r
95276127 1051}\r
1052\r
572f5d8a 1053/**\r
1054 Converts a MAC address device path structure to its string representive.\r
1055\r
1056 @param Str The string representive of input device.\r
1057 @param DevPath The input device path structure.\r
1058 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1059 of the display node is used, where applicable. If DisplayOnly\r
1060 is FALSE, then the longer text representation of the display node\r
1061 is used.\r
1062 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1063 representation for a device node can be used, where applicable.\r
1064\r
1065**/\r
95276127 1066VOID\r
1067DevPathToTextMacAddr (\r
1068 IN OUT POOL_PRINT *Str,\r
1069 IN VOID *DevPath,\r
1070 IN BOOLEAN DisplayOnly,\r
1071 IN BOOLEAN AllowShortcuts\r
1072 )\r
1073{\r
572f5d8a 1074 MAC_ADDR_DEVICE_PATH *MacDevPath;\r
95276127 1075 UINTN HwAddressSize;\r
1076 UINTN Index;\r
1077\r
572f5d8a 1078 MacDevPath = DevPath;\r
95276127 1079\r
1080 HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
572f5d8a 1081 if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {\r
95276127 1082 HwAddressSize = 6;\r
1083 }\r
1084\r
1085 CatPrint (Str, L"MAC(");\r
1086\r
1087 for (Index = 0; Index < HwAddressSize; Index++) {\r
572f5d8a 1088 CatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]);\r
95276127 1089 }\r
1090\r
572f5d8a 1091 CatPrint (Str, L",0x%x)", MacDevPath->IfType);\r
95276127 1092}\r
1093\r
572f5d8a 1094/**\r
1095 Converts a IPv4 device path structure to its string representive.\r
1096\r
1097 @param Str The string representive of input device.\r
1098 @param DevPath The input device path structure.\r
1099 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1100 of the display node is used, where applicable. If DisplayOnly\r
1101 is FALSE, then the longer text representation of the display node\r
1102 is used.\r
1103 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1104 representation for a device node can be used, where applicable.\r
1105\r
1106**/\r
95276127 1107VOID\r
1108DevPathToTextIPv4 (\r
1109 IN OUT POOL_PRINT *Str,\r
1110 IN VOID *DevPath,\r
1111 IN BOOLEAN DisplayOnly,\r
1112 IN BOOLEAN AllowShortcuts\r
1113 )\r
1114{\r
572f5d8a 1115 IPv4_DEVICE_PATH *IPDevPath;\r
95276127 1116\r
572f5d8a 1117 IPDevPath = DevPath;\r
1118 if (DisplayOnly) {\r
95276127 1119 CatPrint (\r
1120 Str,\r
1121 L"IPv4(%d.%d.%d.%d)",\r
572f5d8a 1122 IPDevPath->RemoteIpAddress.Addr[0],\r
1123 IPDevPath->RemoteIpAddress.Addr[1],\r
1124 IPDevPath->RemoteIpAddress.Addr[2],\r
1125 IPDevPath->RemoteIpAddress.Addr[3]\r
95276127 1126 );\r
1127 return ;\r
1128 }\r
1129\r
1130 CatPrint (\r
1131 Str,\r
1132 L"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",\r
572f5d8a 1133 IPDevPath->RemoteIpAddress.Addr[0],\r
1134 IPDevPath->RemoteIpAddress.Addr[1],\r
1135 IPDevPath->RemoteIpAddress.Addr[2],\r
1136 IPDevPath->RemoteIpAddress.Addr[3],\r
1137 IPDevPath->Protocol ? L"TCP" : L"UDP",\r
1138 (IPDevPath->StaticIpAddress == TRUE) ? L"Static" : L"DHCP",\r
1139 IPDevPath->LocalIpAddress.Addr[0],\r
1140 IPDevPath->LocalIpAddress.Addr[1],\r
1141 IPDevPath->LocalIpAddress.Addr[2],\r
1142 IPDevPath->LocalIpAddress.Addr[3]\r
95276127 1143 );\r
1144}\r
1145\r
572f5d8a 1146/**\r
1147 Converts a IPv6 device path structure to its string representive.\r
1148\r
1149 @param Str The string representive of input device.\r
1150 @param DevPath The input device path structure.\r
1151 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1152 of the display node is used, where applicable. If DisplayOnly\r
1153 is FALSE, then the longer text representation of the display node\r
1154 is used.\r
1155 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1156 representation for a device node can be used, where applicable.\r
1157\r
1158**/\r
95276127 1159VOID\r
1160DevPathToTextIPv6 (\r
1161 IN OUT POOL_PRINT *Str,\r
1162 IN VOID *DevPath,\r
1163 IN BOOLEAN DisplayOnly,\r
1164 IN BOOLEAN AllowShortcuts\r
1165 )\r
1166{\r
572f5d8a 1167 IPv6_DEVICE_PATH *IPDevPath;\r
95276127 1168\r
572f5d8a 1169 IPDevPath = DevPath;\r
1170 if (DisplayOnly) {\r
95276127 1171 CatPrint (\r
1172 Str,\r
1173 L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
572f5d8a 1174 IPDevPath->RemoteIpAddress.Addr[0],\r
1175 IPDevPath->RemoteIpAddress.Addr[1],\r
1176 IPDevPath->RemoteIpAddress.Addr[2],\r
1177 IPDevPath->RemoteIpAddress.Addr[3],\r
1178 IPDevPath->RemoteIpAddress.Addr[4],\r
1179 IPDevPath->RemoteIpAddress.Addr[5],\r
1180 IPDevPath->RemoteIpAddress.Addr[6],\r
1181 IPDevPath->RemoteIpAddress.Addr[7],\r
1182 IPDevPath->RemoteIpAddress.Addr[8],\r
1183 IPDevPath->RemoteIpAddress.Addr[9],\r
1184 IPDevPath->RemoteIpAddress.Addr[10],\r
1185 IPDevPath->RemoteIpAddress.Addr[11],\r
1186 IPDevPath->RemoteIpAddress.Addr[12],\r
1187 IPDevPath->RemoteIpAddress.Addr[13],\r
1188 IPDevPath->RemoteIpAddress.Addr[14],\r
1189 IPDevPath->RemoteIpAddress.Addr[15]\r
95276127 1190 );\r
1191 return ;\r
1192 }\r
1193\r
1194 CatPrint (\r
1195 Str,\r
1196 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
572f5d8a 1197 IPDevPath->RemoteIpAddress.Addr[0],\r
1198 IPDevPath->RemoteIpAddress.Addr[1],\r
1199 IPDevPath->RemoteIpAddress.Addr[2],\r
1200 IPDevPath->RemoteIpAddress.Addr[3],\r
1201 IPDevPath->RemoteIpAddress.Addr[4],\r
1202 IPDevPath->RemoteIpAddress.Addr[5],\r
1203 IPDevPath->RemoteIpAddress.Addr[6],\r
1204 IPDevPath->RemoteIpAddress.Addr[7],\r
1205 IPDevPath->RemoteIpAddress.Addr[8],\r
1206 IPDevPath->RemoteIpAddress.Addr[9],\r
1207 IPDevPath->RemoteIpAddress.Addr[10],\r
1208 IPDevPath->RemoteIpAddress.Addr[11],\r
1209 IPDevPath->RemoteIpAddress.Addr[12],\r
1210 IPDevPath->RemoteIpAddress.Addr[13],\r
1211 IPDevPath->RemoteIpAddress.Addr[14],\r
1212 IPDevPath->RemoteIpAddress.Addr[15],\r
1213 IPDevPath->Protocol ? L"TCP" : L"UDP",\r
1214 (IPDevPath->StaticIpAddress == TRUE) ? L"Static" : L"DHCP",\r
1215 IPDevPath->LocalIpAddress.Addr[0],\r
1216 IPDevPath->LocalIpAddress.Addr[1],\r
1217 IPDevPath->LocalIpAddress.Addr[2],\r
1218 IPDevPath->LocalIpAddress.Addr[3],\r
1219 IPDevPath->LocalIpAddress.Addr[4],\r
1220 IPDevPath->LocalIpAddress.Addr[5],\r
1221 IPDevPath->LocalIpAddress.Addr[6],\r
1222 IPDevPath->LocalIpAddress.Addr[7],\r
1223 IPDevPath->LocalIpAddress.Addr[8],\r
1224 IPDevPath->LocalIpAddress.Addr[9],\r
1225 IPDevPath->LocalIpAddress.Addr[10],\r
1226 IPDevPath->LocalIpAddress.Addr[11],\r
1227 IPDevPath->LocalIpAddress.Addr[12],\r
1228 IPDevPath->LocalIpAddress.Addr[13],\r
1229 IPDevPath->LocalIpAddress.Addr[14],\r
1230 IPDevPath->LocalIpAddress.Addr[15]\r
95276127 1231 );\r
1232}\r
1233\r
572f5d8a 1234/**\r
1235 Converts an Infini Band device path structure to its string representive.\r
1236\r
1237 @param Str The string representive of input device.\r
1238 @param DevPath The input device path structure.\r
1239 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1240 of the display node is used, where applicable. If DisplayOnly\r
1241 is FALSE, then the longer text representation of the display node\r
1242 is used.\r
1243 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1244 representation for a device node can be used, where applicable.\r
1245\r
1246**/\r
95276127 1247VOID\r
1248DevPathToTextInfiniBand (\r
1249 IN OUT POOL_PRINT *Str,\r
1250 IN VOID *DevPath,\r
1251 IN BOOLEAN DisplayOnly,\r
1252 IN BOOLEAN AllowShortcuts\r
1253 )\r
1254{\r
1255 INFINIBAND_DEVICE_PATH *InfiniBand;\r
1256\r
1257 InfiniBand = DevPath;\r
1258 CatPrint (\r
1259 Str,\r
cf40f28a 1260 L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",\r
95276127 1261 InfiniBand->ResourceFlags,\r
1262 InfiniBand->PortGid,\r
1263 InfiniBand->ServiceId,\r
1264 InfiniBand->TargetPortId,\r
1265 InfiniBand->DeviceId\r
1266 );\r
1267}\r
1268\r
572f5d8a 1269/**\r
1270 Converts a UART device path structure to its string representive.\r
1271\r
1272 @param Str The string representive of input device.\r
1273 @param DevPath The input device path structure.\r
1274 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1275 of the display node is used, where applicable. If DisplayOnly\r
1276 is FALSE, then the longer text representation of the display node\r
1277 is used.\r
1278 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1279 representation for a device node can be used, where applicable.\r
1280\r
1281**/\r
95276127 1282VOID\r
1283DevPathToTextUart (\r
1284 IN OUT POOL_PRINT *Str,\r
1285 IN VOID *DevPath,\r
1286 IN BOOLEAN DisplayOnly,\r
1287 IN BOOLEAN AllowShortcuts\r
1288 )\r
1289{\r
1290 UART_DEVICE_PATH *Uart;\r
1291 CHAR8 Parity;\r
1292\r
1293 Uart = DevPath;\r
1294 switch (Uart->Parity) {\r
1295 case 0:\r
1296 Parity = 'D';\r
1297 break;\r
1298\r
1299 case 1:\r
1300 Parity = 'N';\r
1301 break;\r
1302\r
1303 case 2:\r
1304 Parity = 'E';\r
1305 break;\r
1306\r
1307 case 3:\r
1308 Parity = 'O';\r
1309 break;\r
1310\r
1311 case 4:\r
1312 Parity = 'M';\r
1313 break;\r
1314\r
1315 case 5:\r
1316 Parity = 'S';\r
1317 break;\r
1318\r
1319 default:\r
1320 Parity = 'x';\r
1321 break;\r
1322 }\r
1323\r
1324 if (Uart->BaudRate == 0) {\r
1325 CatPrint (Str, L"Uart(DEFAULT,");\r
1326 } else {\r
1327 CatPrint (Str, L"Uart(%ld,", Uart->BaudRate);\r
1328 }\r
1329\r
1330 if (Uart->DataBits == 0) {\r
1331 CatPrint (Str, L"DEFAULT,");\r
1332 } else {\r
1333 CatPrint (Str, L"%d,", Uart->DataBits);\r
1334 }\r
1335\r
1336 CatPrint (Str, L"%c,", Parity);\r
1337\r
1338 switch (Uart->StopBits) {\r
1339 case 0:\r
1340 CatPrint (Str, L"D)");\r
1341 break;\r
1342\r
1343 case 1:\r
1344 CatPrint (Str, L"1)");\r
1345 break;\r
1346\r
1347 case 2:\r
1348 CatPrint (Str, L"1.5)");\r
1349 break;\r
1350\r
1351 case 3:\r
1352 CatPrint (Str, L"2)");\r
1353 break;\r
1354\r
1355 default:\r
1356 CatPrint (Str, L"x)");\r
1357 break;\r
1358 }\r
1359}\r
1360\r
572f5d8a 1361/**\r
1362 Converts an iSCSI device path structure to its string representive.\r
1363\r
1364 @param Str The string representive of input device.\r
1365 @param DevPath The input device path structure.\r
1366 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1367 of the display node is used, where applicable. If DisplayOnly\r
1368 is FALSE, then the longer text representation of the display node\r
1369 is used.\r
1370 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1371 representation for a device node can be used, where applicable.\r
1372\r
1373**/\r
95276127 1374VOID\r
1375DevPathToTextiSCSI (\r
1376 IN OUT POOL_PRINT *Str,\r
1377 IN VOID *DevPath,\r
1378 IN BOOLEAN DisplayOnly,\r
1379 IN BOOLEAN AllowShortcuts\r
1380 )\r
1381{\r
572f5d8a 1382 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
95276127 1383 UINT16 Options;\r
1384\r
572f5d8a 1385 ISCSIDevPath = DevPath;\r
95276127 1386 CatPrint (\r
1387 Str,\r
cf40f28a 1388 L"iSCSI(%a,0x%x,0x%lx,",\r
572f5d8a 1389 ISCSIDevPath->iSCSITargetName,\r
1390 ISCSIDevPath->TargetPortalGroupTag,\r
1391 ISCSIDevPath->Lun\r
95276127 1392 );\r
1393\r
572f5d8a 1394 Options = ISCSIDevPath->LoginOption;\r
1395 CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
1396 CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
1397 if (((Options >> 11) & 0x0001) != 0) {\r
95276127 1398 CatPrint (Str, L"%s,", L"None");\r
572f5d8a 1399 } else if (((Options >> 12) & 0x0001) != 0) {\r
95276127 1400 CatPrint (Str, L"%s,", L"CHAP_UNI");\r
1401 } else {\r
1402 CatPrint (Str, L"%s,", L"CHAP_BI");\r
1403\r
1404 }\r
1405\r
572f5d8a 1406 CatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
95276127 1407}\r
1408\r
572f5d8a 1409/**\r
1410 Converts a Hard drive device path structure to its string representive.\r
1411\r
1412 @param Str The string representive of input device.\r
1413 @param DevPath The input device path structure.\r
1414 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1415 of the display node is used, where applicable. If DisplayOnly\r
1416 is FALSE, then the longer text representation of the display node\r
1417 is used.\r
1418 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1419 representation for a device node can be used, where applicable.\r
1420\r
1421**/\r
95276127 1422VOID\r
1423DevPathToTextHardDrive (\r
1424 IN OUT POOL_PRINT *Str,\r
1425 IN VOID *DevPath,\r
1426 IN BOOLEAN DisplayOnly,\r
1427 IN BOOLEAN AllowShortcuts\r
1428 )\r
1429{\r
1430 HARDDRIVE_DEVICE_PATH *Hd;\r
1431\r
1432 Hd = DevPath;\r
1433 switch (Hd->SignatureType) {\r
95276127 1434 case SIGNATURE_TYPE_MBR:\r
1435 CatPrint (\r
1436 Str,\r
cf40f28a 1437 L"HD(%d,%s,0x%08x,",\r
95276127 1438 Hd->PartitionNumber,\r
1439 L"MBR",\r
1440 *((UINT32 *) (&(Hd->Signature[0])))\r
1441 );\r
1442 break;\r
1443\r
1444 case SIGNATURE_TYPE_GUID:\r
1445 CatPrint (\r
1446 Str,\r
1447 L"HD(%d,%s,%g,",\r
1448 Hd->PartitionNumber,\r
cf40f28a 1449 L"GPT",\r
95276127 1450 (EFI_GUID *) &(Hd->Signature[0])\r
1451 );\r
1452 break;\r
1453\r
1454 default:\r
cf40f28a 1455 CatPrint (\r
1456 Str,\r
1457 L"HD(%d,%d,0,",\r
1458 Hd->PartitionNumber,\r
1459 Hd->SignatureType\r
1460 );\r
95276127 1461 break;\r
1462 }\r
1463\r
cf40f28a 1464 CatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);\r
95276127 1465}\r
1466\r
572f5d8a 1467/**\r
1468 Converts a CDROM device path structure to its string representive.\r
1469\r
1470 @param Str The string representive of input device.\r
1471 @param DevPath The input device path structure.\r
1472 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1473 of the display node is used, where applicable. If DisplayOnly\r
1474 is FALSE, then the longer text representation of the display node\r
1475 is used.\r
1476 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1477 representation for a device node can be used, where applicable.\r
1478\r
1479**/\r
95276127 1480VOID\r
1481DevPathToTextCDROM (\r
1482 IN OUT POOL_PRINT *Str,\r
1483 IN VOID *DevPath,\r
1484 IN BOOLEAN DisplayOnly,\r
1485 IN BOOLEAN AllowShortcuts\r
1486 )\r
1487{\r
1488 CDROM_DEVICE_PATH *Cd;\r
1489\r
1490 Cd = DevPath;\r
572f5d8a 1491 if (DisplayOnly) {\r
cf40f28a 1492 CatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);\r
95276127 1493 return ;\r
1494 }\r
1495\r
cf40f28a 1496 CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
95276127 1497}\r
1498\r
572f5d8a 1499/**\r
1500 Converts a File device path structure to its string representive.\r
1501\r
1502 @param Str The string representive of input device.\r
1503 @param DevPath The input device path structure.\r
1504 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1505 of the display node is used, where applicable. If DisplayOnly\r
1506 is FALSE, then the longer text representation of the display node\r
1507 is used.\r
1508 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1509 representation for a device node can be used, where applicable.\r
1510\r
1511**/\r
95276127 1512VOID\r
1513DevPathToTextFilePath (\r
1514 IN OUT POOL_PRINT *Str,\r
1515 IN VOID *DevPath,\r
1516 IN BOOLEAN DisplayOnly,\r
1517 IN BOOLEAN AllowShortcuts\r
1518 )\r
1519{\r
1520 FILEPATH_DEVICE_PATH *Fp;\r
1521\r
1522 Fp = DevPath;\r
1523 CatPrint (Str, L"%s", Fp->PathName);\r
1524}\r
1525\r
572f5d8a 1526/**\r
1527 Converts a Media protocol device path structure to its string representive.\r
1528\r
1529 @param Str The string representive of input device.\r
1530 @param DevPath The input device path structure.\r
1531 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1532 of the display node is used, where applicable. If DisplayOnly\r
1533 is FALSE, then the longer text representation of the display node\r
1534 is used.\r
1535 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1536 representation for a device node can be used, where applicable.\r
1537\r
1538**/\r
95276127 1539VOID\r
1540DevPathToTextMediaProtocol (\r
1541 IN OUT POOL_PRINT *Str,\r
1542 IN VOID *DevPath,\r
1543 IN BOOLEAN DisplayOnly,\r
1544 IN BOOLEAN AllowShortcuts\r
1545 )\r
1546{\r
1547 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;\r
1548\r
1549 MediaProt = DevPath;\r
1550 CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
1551}\r
1552\r
572f5d8a 1553/**\r
1554 Converts a Firmware Volume device path structure to its string representive.\r
1555\r
1556 @param Str The string representive of input device.\r
1557 @param DevPath The input device path structure.\r
1558 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1559 of the display node is used, where applicable. If DisplayOnly\r
1560 is FALSE, then the longer text representation of the display node\r
1561 is used.\r
1562 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1563 representation for a device node can be used, where applicable.\r
1564\r
1565**/\r
cf40f28a 1566VOID\r
1567DevPathToTextFv (\r
1568 IN OUT POOL_PRINT *Str,\r
1569 IN VOID *DevPath,\r
1570 IN BOOLEAN DisplayOnly,\r
1571 IN BOOLEAN AllowShortcuts\r
1572 )\r
1573{\r
1574 MEDIA_FW_VOL_DEVICE_PATH *Fv;\r
1575\r
1576 Fv = DevPath;\r
1577 CatPrint (Str, L"Fv(%g)", &Fv->FvName);\r
1578}\r
1579\r
572f5d8a 1580/**\r
1581 Converts a Firmware Volume File device path structure to its string representive.\r
1582\r
1583 @param Str The string representive of input device.\r
1584 @param DevPath The input device path structure.\r
1585 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1586 of the display node is used, where applicable. If DisplayOnly\r
1587 is FALSE, then the longer text representation of the display node\r
1588 is used.\r
1589 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1590 representation for a device node can be used, where applicable.\r
1591\r
1592**/\r
cf40f28a 1593VOID\r
1594DevPathToTextFvFile (\r
1595 IN OUT POOL_PRINT *Str,\r
1596 IN VOID *DevPath,\r
1597 IN BOOLEAN DisplayOnly,\r
1598 IN BOOLEAN AllowShortcuts\r
1599 )\r
1600{\r
1601 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;\r
1602\r
1603 FvFile = DevPath;\r
1604 CatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);\r
1605}\r
1606\r
572f5d8a 1607/**\r
1608 Converts a BIOS Boot Specification device path structure to its string representive.\r
1609\r
1610 @param Str The string representive of input device.\r
1611 @param DevPath The input device path structure.\r
1612 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1613 of the display node is used, where applicable. If DisplayOnly\r
1614 is FALSE, then the longer text representation of the display node\r
1615 is used.\r
1616 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1617 representation for a device node can be used, where applicable.\r
1618\r
1619**/\r
95276127 1620VOID\r
1621DevPathToTextBBS (\r
1622 IN OUT POOL_PRINT *Str,\r
1623 IN VOID *DevPath,\r
1624 IN BOOLEAN DisplayOnly,\r
1625 IN BOOLEAN AllowShortcuts\r
1626 )\r
1627{\r
1628 BBS_BBS_DEVICE_PATH *Bbs;\r
1629 CHAR16 *Type;\r
1630\r
1631 Bbs = DevPath;\r
1632 switch (Bbs->DeviceType) {\r
1633 case BBS_TYPE_FLOPPY:\r
1634 Type = L"Floppy";\r
1635 break;\r
1636\r
1637 case BBS_TYPE_HARDDRIVE:\r
1638 Type = L"HD";\r
1639 break;\r
1640\r
1641 case BBS_TYPE_CDROM:\r
1642 Type = L"CDROM";\r
1643 break;\r
1644\r
1645 case BBS_TYPE_PCMCIA:\r
1646 Type = L"PCMCIA";\r
1647 break;\r
1648\r
1649 case BBS_TYPE_USB:\r
1650 Type = L"USB";\r
1651 break;\r
1652\r
1653 case BBS_TYPE_EMBEDDED_NETWORK:\r
1654 Type = L"Network";\r
1655 break;\r
1656\r
1657 default:\r
cf40f28a 1658 Type = NULL;\r
95276127 1659 break;\r
1660 }\r
1661\r
cf40f28a 1662 if (Type != NULL) {\r
1663 CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r
1664 } else {\r
1665 CatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String);\r
1666 }\r
95276127 1667\r
572f5d8a 1668 if (DisplayOnly) {\r
95276127 1669 CatPrint (Str, L")");\r
1670 return ;\r
1671 }\r
1672\r
cf40f28a 1673 CatPrint (Str, L",0x%x)", Bbs->StatusFlag);\r
95276127 1674}\r
1675\r
572f5d8a 1676/**\r
1677 Converts an End-of-Device-Path structure to its string representive.\r
1678\r
1679 @param Str The string representive of input device.\r
1680 @param DevPath The input device path structure.\r
1681 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1682 of the display node is used, where applicable. If DisplayOnly\r
1683 is FALSE, then the longer text representation of the display node\r
1684 is used.\r
1685 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1686 representation for a device node can be used, where applicable.\r
1687\r
1688**/\r
95276127 1689VOID\r
1690DevPathToTextEndInstance (\r
1691 IN OUT POOL_PRINT *Str,\r
1692 IN VOID *DevPath,\r
1693 IN BOOLEAN DisplayOnly,\r
1694 IN BOOLEAN AllowShortcuts\r
1695 )\r
1696{\r
1697 CatPrint (Str, L",");\r
1698}\r
1699\r
572f5d8a 1700/**\r
1701 Converts an unknown device path structure to its string representive.\r
1702\r
1703 @param Str The string representive of input device.\r
1704 @param DevPath The input device path structure.\r
1705 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1706 of the display node is used, where applicable. If DisplayOnly\r
1707 is FALSE, then the longer text representation of the display node\r
1708 is used.\r
1709 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1710 representation for a device node can be used, where applicable.\r
1711\r
1712**/\r
95276127 1713VOID\r
1714DevPathToTextNodeUnknown (\r
1715 IN OUT POOL_PRINT *Str,\r
1716 IN VOID *DevPath,\r
1717 IN BOOLEAN DisplayOnly,\r
1718 IN BOOLEAN AllowShortcuts\r
1719 )\r
1720{\r
1721 CatPrint (Str, L"?");\r
1722}\r
1723\r
1724GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable[] = {\r
1725 {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci},\r
1726 {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard},\r
1727 {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap},\r
1728 {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor},\r
1729 {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController},\r
1730 {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi},\r
cf40f28a 1731 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx},\r
1732 {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr},\r
95276127 1733 {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi},\r
1734 {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi},\r
1735 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre},\r
1736 {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394},\r
1737 {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb},\r
1738 {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID},\r
1739 {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit},\r
1740 {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass},\r
cf40f28a 1741 {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata},\r
95276127 1742 {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O},\r
1743 {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr},\r
1744 {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4},\r
1745 {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6},\r
1746 {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand},\r
1747 {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart},\r
1748 {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor},\r
1749 {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI},\r
1750 {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive},\r
1751 {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM},\r
1752 {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor},\r
1753 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r
1754 {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol},\r
1755 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r
cf40f28a 1756 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv},\r
1757 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile},\r
95276127 1758 {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS},\r
1759 {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance},\r
1760 {0, 0, NULL}\r
1761};\r
1762\r
572f5d8a 1763/**\r
1764 Converts a device node to its string representation.\r
1765\r
1766 @param DeviceNode A Pointer to the device node to be converted.\r
1767 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1768 of the display node is used, where applicable. If DisplayOnly\r
1769 is FALSE, then the longer text representation of the display node\r
1770 is used.\r
1771 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1772 representation for a device node can be used, where applicable.\r
1773\r
1774 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
1775 is NULL or there was insufficient memory.\r
1776\r
1777**/\r
95276127 1778CHAR16 *\r
572f5d8a 1779EFIAPI\r
95276127 1780ConvertDeviceNodeToText (\r
1781 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
1782 IN BOOLEAN DisplayOnly,\r
1783 IN BOOLEAN AllowShortcuts\r
1784 )\r
95276127 1785{\r
1786 POOL_PRINT Str;\r
1787 UINTN Index;\r
1788 UINTN NewSize;\r
1789 VOID (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
1790\r
1791 if (DeviceNode == NULL) {\r
1792 return NULL;\r
1793 }\r
1794\r
1795 ZeroMem (&Str, sizeof (Str));\r
1796\r
1797 //\r
1798 // Process the device path node\r
1799 //\r
1800 DumpNode = NULL;\r
1801 for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index++) {\r
1802 if (DevicePathType (DeviceNode) == DevPathToTextTable[Index].Type &&\r
1803 DevicePathSubType (DeviceNode) == DevPathToTextTable[Index].SubType\r
1804 ) {\r
1805 DumpNode = DevPathToTextTable[Index].Function;\r
1806 break;\r
1807 }\r
1808 }\r
1809 //\r
1810 // If not found, use a generic function\r
1811 //\r
1812 if (DumpNode == NULL) {\r
1813 DumpNode = DevPathToTextNodeUnknown;\r
1814 }\r
1815\r
1816 //\r
1817 // Print this node\r
1818 //\r
1819 DumpNode (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r
1820\r
1821 //\r
1822 // Shrink pool used for string allocation\r
1823 //\r
1824 NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
1825 Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);\r
1826 ASSERT (Str.Str != NULL);\r
1827 Str.Str[Str.Len] = 0;\r
1828 return Str.Str;\r
1829}\r
1830\r
572f5d8a 1831/**\r
1832 Converts a device path to its text representation.\r
95276127 1833\r
572f5d8a 1834 @param DevicePath A Pointer to the device to be converted.\r
1835 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
95276127 1836 of the display node is used, where applicable. If DisplayOnly\r
1837 is FALSE, then the longer text representation of the display node\r
1838 is used.\r
572f5d8a 1839 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
95276127 1840 representation for a device node can be used, where applicable.\r
1841\r
572f5d8a 1842 @return A pointer to the allocated text representation of the device path or\r
1843 NULL if DeviceNode is NULL or there was insufficient memory.\r
95276127 1844\r
572f5d8a 1845**/\r
1846CHAR16 *\r
1847EFIAPI\r
1848ConvertDevicePathToText (\r
1849 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
1850 IN BOOLEAN DisplayOnly,\r
1851 IN BOOLEAN AllowShortcuts\r
1852 )\r
95276127 1853{\r
1854 POOL_PRINT Str;\r
1855 EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r
1856 EFI_DEVICE_PATH_PROTOCOL *UnpackDevPath;\r
1857 UINTN Index;\r
1858 UINTN NewSize;\r
1859 VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
1860\r
1861 if (DevicePath == NULL) {\r
1862 return NULL;\r
1863 }\r
1864\r
1865 ZeroMem (&Str, sizeof (Str));\r
1866\r
1867 //\r
1868 // Unpacked the device path\r
1869 //\r
1870 UnpackDevPath = UnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) DevicePath);\r
1871 ASSERT (UnpackDevPath != NULL);\r
1872\r
1873 //\r
1874 // Process each device path node\r
1875 //\r
1876 DevPathNode = UnpackDevPath;\r
1877 while (!IsDevicePathEnd (DevPathNode)) {\r
1878 //\r
1879 // Find the handler to dump this device path node\r
1880 //\r
1881 DumpNode = NULL;\r
1882 for (Index = 0; DevPathToTextTable[Index].Function; Index += 1) {\r
1883\r
1884 if (DevicePathType (DevPathNode) == DevPathToTextTable[Index].Type &&\r
1885 DevicePathSubType (DevPathNode) == DevPathToTextTable[Index].SubType\r
1886 ) {\r
1887 DumpNode = DevPathToTextTable[Index].Function;\r
1888 break;\r
1889 }\r
1890 }\r
1891 //\r
1892 // If not found, use a generic function\r
1893 //\r
1894 if (!DumpNode) {\r
1895 DumpNode = DevPathToTextNodeUnknown;\r
1896 }\r
1897 //\r
1898 // Put a path seperator in if needed\r
1899 //\r
572f5d8a 1900 if ((Str.Len != 0) && DumpNode != DevPathToTextEndInstance) {\r
cf40f28a 1901 if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') {\r
95276127 1902 CatPrint (&Str, L"/");\r
cf40f28a 1903 }\r
95276127 1904 }\r
1905 //\r
1906 // Print this node of the device path\r
1907 //\r
1908 DumpNode (&Str, DevPathNode, DisplayOnly, AllowShortcuts);\r
1909\r
1910 //\r
1911 // Next device path node\r
1912 //\r
1913 DevPathNode = NextDevicePathNode (DevPathNode);\r
1914 }\r
1915 //\r
1916 // Shrink pool used for string allocation\r
1917 //\r
1918 FreePool (UnpackDevPath);\r
1919\r
1920 NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
1921 Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);\r
1922 ASSERT (Str.Str != NULL);\r
1923 Str.Str[Str.Len] = 0;\r
1924 return Str.Str;\r
1925}\r