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