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