]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
Removing IsaSerailDxe driver instead of removing the TerminalDxe driver when source...
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePathToText.c
... / ...
CommitLineData
1/** @file\r
2 DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
3\r
4Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
5This 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
9\r
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
12\r
13**/\r
14\r
15#include "DevicePath.h"\r
16\r
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
31CHAR16 *\r
32EFIAPI\r
33CatPrint (\r
34 IN OUT POOL_PRINT *Str,\r
35 IN CHAR16 *Fmt,\r
36 ...\r
37 )\r
38{\r
39 UINT16 *AppendStr;\r
40 UINTN AppendCount;\r
41 VA_LIST Args;\r
42\r
43 AppendStr = AllocateZeroPool (0x1000);\r
44 ASSERT (AppendStr != NULL);\r
45\r
46 VA_START (Args, Fmt);\r
47 AppendCount = UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);\r
48 VA_END (Args);\r
49\r
50 if (Str->Length + AppendCount * sizeof (CHAR16) > Str->Capacity) {\r
51 Str->Capacity = Str->Length + (AppendCount + 1) * sizeof (CHAR16) * 2;\r
52 Str->Str = ReallocatePool (\r
53 Str->Length,\r
54 Str->Capacity,\r
55 Str->Str\r
56 );\r
57 ASSERT (Str->Str != NULL);\r
58 }\r
59\r
60 if (Str->Length == 0) {\r
61 StrCpy (Str->Str, AppendStr);\r
62 Str->Length = (AppendCount + 1) * sizeof (CHAR16);\r
63 } else {\r
64 StrCat (Str->Str, AppendStr);\r
65 Str->Length += AppendCount * sizeof (CHAR16);\r
66 }\r
67\r
68 FreePool (AppendStr);\r
69 return Str->Str;\r
70}\r
71\r
72/**\r
73 Converts a PCI device path structure to its string representative.\r
74\r
75 @param Str The string representative of input device.\r
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
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
96 CatPrint (Str, L"Pci(0x%x,0x%x)", Pci->Device, Pci->Function);\r
97}\r
98\r
99/**\r
100 Converts a PC Card device path structure to its string representative.\r
101\r
102 @param Str The string representative of input device.\r
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
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
123 CatPrint (Str, L"PcCard(0x%x)", Pccard->FunctionNumber);\r
124}\r
125\r
126/**\r
127 Converts a Memory Map device path structure to its string representative.\r
128\r
129 @param Str The string representative of input device.\r
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
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
152 L"MemoryMapped(0x%x,0x%lx,0x%lx)",\r
153 MemMap->MemoryType,\r
154 MemMap->StartingAddress,\r
155 MemMap->EndingAddress\r
156 );\r
157}\r
158\r
159/**\r
160 Converts a Vendor device path structure to its string representative.\r
161\r
162 @param Str The string representative of input device.\r
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
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
183 UINTN DataLength;\r
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
208 } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) {\r
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
228 } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {\r
229 CatPrint (\r
230 Str,\r
231 L"SAS(0x%lx,0x%lx,0x%x,",\r
232 ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r
233 ((SAS_DEVICE_PATH *) Vendor)->Lun,\r
234 ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
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
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
246 );\r
247 if ((Info & 0x0f) == 1) {\r
248 CatPrint (Str, L"0,");\r
249 } else {\r
250 CatPrint (Str, L"0x%x,", (Info >> 8) & 0xff);\r
251 }\r
252 } else {\r
253 CatPrint (Str, L"0,0,0,0,");\r
254 }\r
255\r
256 CatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
257 return ;\r
258 } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r
259 CatPrint (Str, L"DebugPort()");\r
260 return ;\r
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
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
279 CatPrint (Str, L"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r
280 }\r
281 }\r
282\r
283 CatPrint (Str, L")");\r
284}\r
285\r
286/**\r
287 Converts a Controller device path structure to its string representative.\r
288\r
289 @param Str The string representative of input device.\r
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
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
312 L"Ctrl(0x%x)",\r
313 Controller->ControllerNumber\r
314 );\r
315}\r
316\r
317/**\r
318 Converts a ACPI device path structure to its string representative.\r
319\r
320 @param Str The string representative of input device.\r
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
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
342 switch (EISA_ID_TO_NUM (Acpi->HID)) {\r
343 case 0x0a03:\r
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
349 break;\r
350\r
351 case 0x0604:\r
352 CatPrint (Str, L"Floppy(0x%x)", Acpi->UID);\r
353 break;\r
354\r
355 case 0x0301:\r
356 CatPrint (Str, L"Keyboard(0x%x)", Acpi->UID);\r
357 break;\r
358\r
359 case 0x0501:\r
360 CatPrint (Str, L"Serial(0x%x)", Acpi->UID);\r
361 break;\r
362\r
363 case 0x0401:\r
364 CatPrint (Str, L"ParallelPort(0x%x)", Acpi->UID);\r
365 break;\r
366\r
367 default:\r
368 CatPrint (Str, L"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);\r
369 break;\r
370 }\r
371 } else {\r
372 CatPrint (Str, L"Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID);\r
373 }\r
374}\r
375\r
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
383VOID\r
384EisaIdToText (\r
385 IN UINT32 EisaId,\r
386 IN OUT CHAR16 *Text\r
387 )\r
388{\r
389 CHAR16 PnpIdStr[17];\r
390\r
391 //\r
392 //UnicodeSPrint ("%X", 0x0a03) => "0000000000000A03"\r
393 //\r
394 UnicodeSPrint (PnpIdStr, 17 * 2, L"%16X", EisaId >> 16);\r
395\r
396 UnicodeSPrint (\r
397 Text,\r
398 sizeof (CHAR16) + sizeof (CHAR16) + sizeof (CHAR16) + sizeof (PnpIdStr),\r
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
406\r
407/**\r
408 Converts a ACPI extended HID device path structure to its string representative.\r
409\r
410 @param Str The string representative of input device.\r
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
420VOID\r
421DevPathToTextAcpiEx (\r
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
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
464\r
465 if (AcpiEx->UID == 0) {\r
466 CatPrint (Str, L"%a,", UIDStr);\r
467 } else {\r
468 CatPrint (Str, L"0x%x,", AcpiEx->UID);\r
469 }\r
470\r
471 if (AcpiEx->CID == 0) {\r
472 CatPrint (Str, L"%a)", CIDStr);\r
473 } else {\r
474 CatPrint (Str, L"%s)", CIDText);\r
475 }\r
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
482 AcpiEx->UID,\r
483 HIDStr,\r
484 CIDStr,\r
485 UIDStr\r
486 );\r
487 }\r
488 }\r
489}\r
490\r
491/**\r
492 Converts a ACPI address device path structure to its string representative.\r
493\r
494 @param Str The string representative of input device.\r
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
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
521 CatPrint (Str, L"AcpiAdr(0x%x", AcpiAdr->ADR);\r
522 for (Index = 0; Index < AdditionalAdrCount; Index++) {\r
523 CatPrint (Str, L",0x%x", *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r
524 }\r
525 CatPrint (Str, L")");\r
526}\r
527\r
528/**\r
529 Converts a ATAPI device path structure to its string representative.\r
530\r
531 @param Str The string representative of input device.\r
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
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
554 CatPrint (Str, L"Ata(0x%x)", Atapi->Lun);\r
555 } else {\r
556 CatPrint (\r
557 Str,\r
558 L"Ata(%s,%s,0x%x)",\r
559 (Atapi->PrimarySecondary == 1) ? L"Secondary" : L"Primary",\r
560 (Atapi->SlaveMaster == 1) ? L"Slave" : L"Master",\r
561 Atapi->Lun\r
562 );\r
563 }\r
564}\r
565\r
566/**\r
567 Converts a SCSI device path structure to its string representative.\r
568\r
569 @param Str The string representative of input device.\r
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
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
590 CatPrint (Str, L"Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun);\r
591}\r
592\r
593/**\r
594 Converts a Fibre device path structure to its string representative.\r
595\r
596 @param Str The string representative of input device.\r
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
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
617 CatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);\r
618}\r
619\r
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
656/**\r
657 Converts a 1394 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
670DevPathToText1394 (\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 F1394_DEVICE_PATH *F1394DevPath;\r
678\r
679 F1394DevPath = DevPath;\r
680 //\r
681 // Guid has format of IEEE-EUI64\r
682 //\r
683 CatPrint (Str, L"I1394(%016lx)", F1394DevPath->Guid);\r
684}\r
685\r
686/**\r
687 Converts a USB device path structure to its string representative.\r
688\r
689 @param Str The string representative of input device.\r
690 @param DevPath The input device path structure.\r
691 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
692 of the display node is used, where applicable. If DisplayOnly\r
693 is FALSE, then the longer text representation of the display node\r
694 is used.\r
695 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
696 representation for a device node can be used, where applicable.\r
697\r
698**/\r
699VOID\r
700DevPathToTextUsb (\r
701 IN OUT POOL_PRINT *Str,\r
702 IN VOID *DevPath,\r
703 IN BOOLEAN DisplayOnly,\r
704 IN BOOLEAN AllowShortcuts\r
705 )\r
706{\r
707 USB_DEVICE_PATH *Usb;\r
708\r
709 Usb = DevPath;\r
710 CatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);\r
711}\r
712\r
713/**\r
714 Converts a USB WWID device path structure to its string representative.\r
715\r
716 @param Str The string representative of input device.\r
717 @param DevPath The input device path structure.\r
718 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
719 of the display node is used, where applicable. If DisplayOnly\r
720 is FALSE, then the longer text representation of the display node\r
721 is used.\r
722 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
723 representation for a device node can be used, where applicable.\r
724\r
725**/\r
726VOID\r
727DevPathToTextUsbWWID (\r
728 IN OUT POOL_PRINT *Str,\r
729 IN VOID *DevPath,\r
730 IN BOOLEAN DisplayOnly,\r
731 IN BOOLEAN AllowShortcuts\r
732 )\r
733{\r
734 USB_WWID_DEVICE_PATH *UsbWWId;\r
735 CHAR16 *SerialNumberStr;\r
736 CHAR16 *NewStr;\r
737 UINT16 Length;\r
738\r
739 UsbWWId = DevPath;\r
740\r
741 SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof (USB_WWID_DEVICE_PATH));\r
742 Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));\r
743 if (SerialNumberStr [Length - 1] != 0) {\r
744 //\r
745 // In case no NULL terminator in SerialNumber, create a new one with NULL terminator\r
746 //\r
747 NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);\r
748 ASSERT (NewStr != NULL);\r
749 NewStr [Length] = 0;\r
750 SerialNumberStr = NewStr;\r
751 }\r
752\r
753 CatPrint (\r
754 Str,\r
755 L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",\r
756 UsbWWId->VendorId,\r
757 UsbWWId->ProductId,\r
758 UsbWWId->InterfaceNumber,\r
759 SerialNumberStr\r
760 );\r
761}\r
762\r
763/**\r
764 Converts a Logic Unit device path structure to its string representative.\r
765\r
766 @param Str The string representative of input device.\r
767 @param DevPath The input device path structure.\r
768 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
769 of the display node is used, where applicable. If DisplayOnly\r
770 is FALSE, then the longer text representation of the display node\r
771 is used.\r
772 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
773 representation for a device node can be used, where applicable.\r
774\r
775**/\r
776VOID\r
777DevPathToTextLogicalUnit (\r
778 IN OUT POOL_PRINT *Str,\r
779 IN VOID *DevPath,\r
780 IN BOOLEAN DisplayOnly,\r
781 IN BOOLEAN AllowShortcuts\r
782 )\r
783{\r
784 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
785\r
786 LogicalUnit = DevPath;\r
787 CatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun);\r
788}\r
789\r
790/**\r
791 Converts a USB class device path structure to its string representative.\r
792\r
793 @param Str The string representative of input device.\r
794 @param DevPath The input device path structure.\r
795 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
796 of the display node is used, where applicable. If DisplayOnly\r
797 is FALSE, then the longer text representation of the display node\r
798 is used.\r
799 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
800 representation for a device node can be used, where applicable.\r
801\r
802**/\r
803VOID\r
804DevPathToTextUsbClass (\r
805 IN OUT POOL_PRINT *Str,\r
806 IN VOID *DevPath,\r
807 IN BOOLEAN DisplayOnly,\r
808 IN BOOLEAN AllowShortcuts\r
809 )\r
810{\r
811 USB_CLASS_DEVICE_PATH *UsbClass;\r
812 BOOLEAN IsKnownSubClass;\r
813\r
814\r
815 UsbClass = DevPath;\r
816\r
817 IsKnownSubClass = TRUE;\r
818 switch (UsbClass->DeviceClass) {\r
819 case USB_CLASS_AUDIO:\r
820 CatPrint (Str, L"UsbAudio");\r
821 break;\r
822\r
823 case USB_CLASS_CDCCONTROL:\r
824 CatPrint (Str, L"UsbCDCControl");\r
825 break;\r
826\r
827 case USB_CLASS_HID:\r
828 CatPrint (Str, L"UsbHID");\r
829 break;\r
830\r
831 case USB_CLASS_IMAGE:\r
832 CatPrint (Str, L"UsbImage");\r
833 break;\r
834\r
835 case USB_CLASS_PRINTER:\r
836 CatPrint (Str, L"UsbPrinter");\r
837 break;\r
838\r
839 case USB_CLASS_MASS_STORAGE:\r
840 CatPrint (Str, L"UsbMassStorage");\r
841 break;\r
842\r
843 case USB_CLASS_HUB:\r
844 CatPrint (Str, L"UsbHub");\r
845 break;\r
846\r
847 case USB_CLASS_CDCDATA:\r
848 CatPrint (Str, L"UsbCDCData");\r
849 break;\r
850\r
851 case USB_CLASS_SMART_CARD:\r
852 CatPrint (Str, L"UsbSmartCard");\r
853 break;\r
854\r
855 case USB_CLASS_VIDEO:\r
856 CatPrint (Str, L"UsbVideo");\r
857 break;\r
858\r
859 case USB_CLASS_DIAGNOSTIC:\r
860 CatPrint (Str, L"UsbDiagnostic");\r
861 break;\r
862\r
863 case USB_CLASS_WIRELESS:\r
864 CatPrint (Str, L"UsbWireless");\r
865 break;\r
866\r
867 default:\r
868 IsKnownSubClass = FALSE;\r
869 break;\r
870 }\r
871\r
872 if (IsKnownSubClass) {\r
873 CatPrint (\r
874 Str,\r
875 L"(0x%x,0x%x,0x%x,0x%x)",\r
876 UsbClass->VendorId,\r
877 UsbClass->ProductId,\r
878 UsbClass->DeviceSubClass,\r
879 UsbClass->DeviceProtocol\r
880 );\r
881 return;\r
882 }\r
883\r
884 if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {\r
885 if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {\r
886 CatPrint (\r
887 Str,\r
888 L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",\r
889 UsbClass->VendorId,\r
890 UsbClass->ProductId,\r
891 UsbClass->DeviceProtocol\r
892 );\r
893 return;\r
894 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {\r
895 CatPrint (\r
896 Str,\r
897 L"UsbIrdaBridge(0x%x,0x%x,0x%x)",\r
898 UsbClass->VendorId,\r
899 UsbClass->ProductId,\r
900 UsbClass->DeviceProtocol\r
901 );\r
902 return;\r
903 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {\r
904 CatPrint (\r
905 Str,\r
906 L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",\r
907 UsbClass->VendorId,\r
908 UsbClass->ProductId,\r
909 UsbClass->DeviceProtocol\r
910 );\r
911 return;\r
912 }\r
913 }\r
914\r
915 CatPrint (\r
916 Str,\r
917 L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",\r
918 UsbClass->VendorId,\r
919 UsbClass->ProductId,\r
920 UsbClass->DeviceClass,\r
921 UsbClass->DeviceSubClass,\r
922 UsbClass->DeviceProtocol\r
923 );\r
924}\r
925\r
926/**\r
927 Converts a SATA device path structure to its string representative.\r
928\r
929 @param Str The string representative of input device.\r
930 @param DevPath The input device path structure.\r
931 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
932 of the display node is used, where applicable. If DisplayOnly\r
933 is FALSE, then the longer text representation of the display node\r
934 is used.\r
935 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
936 representation for a device node can be used, where applicable.\r
937\r
938**/\r
939VOID\r
940DevPathToTextSata (\r
941 IN OUT POOL_PRINT *Str,\r
942 IN VOID *DevPath,\r
943 IN BOOLEAN DisplayOnly,\r
944 IN BOOLEAN AllowShortcuts\r
945 )\r
946{\r
947 SATA_DEVICE_PATH *Sata;\r
948\r
949 Sata = DevPath;\r
950 if ((Sata->PortMultiplierPortNumber & SATA_HBA_DIRECT_CONNECT_FLAG) != 0) {\r
951 CatPrint (\r
952 Str,\r
953 L"Sata(0x%x,0x%x)",\r
954 Sata->HBAPortNumber,\r
955 Sata->Lun\r
956 );\r
957 } else {\r
958 CatPrint (\r
959 Str,\r
960 L"Sata(0x%x,0x%x,0x%x)",\r
961 Sata->HBAPortNumber,\r
962 Sata->PortMultiplierPortNumber,\r
963 Sata->Lun\r
964 );\r
965 }\r
966}\r
967\r
968/**\r
969 Converts a I20 device path structure to its string representative.\r
970\r
971 @param Str The string representative of input device.\r
972 @param DevPath The input device path structure.\r
973 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
974 of the display node is used, where applicable. If DisplayOnly\r
975 is FALSE, then the longer text representation of the display node\r
976 is used.\r
977 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
978 representation for a device node can be used, where applicable.\r
979\r
980**/\r
981VOID\r
982DevPathToTextI2O (\r
983 IN OUT POOL_PRINT *Str,\r
984 IN VOID *DevPath,\r
985 IN BOOLEAN DisplayOnly,\r
986 IN BOOLEAN AllowShortcuts\r
987 )\r
988{\r
989 I2O_DEVICE_PATH *I2ODevPath;\r
990\r
991 I2ODevPath = DevPath;\r
992 CatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid);\r
993}\r
994\r
995/**\r
996 Converts a MAC address device path structure to its string representative.\r
997\r
998 @param Str The string representative of input device.\r
999 @param DevPath The input device path structure.\r
1000 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1001 of the display node is used, where applicable. If DisplayOnly\r
1002 is FALSE, then the longer text representation of the display node\r
1003 is used.\r
1004 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1005 representation for a device node can be used, where applicable.\r
1006\r
1007**/\r
1008VOID\r
1009DevPathToTextMacAddr (\r
1010 IN OUT POOL_PRINT *Str,\r
1011 IN VOID *DevPath,\r
1012 IN BOOLEAN DisplayOnly,\r
1013 IN BOOLEAN AllowShortcuts\r
1014 )\r
1015{\r
1016 MAC_ADDR_DEVICE_PATH *MacDevPath;\r
1017 UINTN HwAddressSize;\r
1018 UINTN Index;\r
1019\r
1020 MacDevPath = DevPath;\r
1021\r
1022 HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
1023 if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {\r
1024 HwAddressSize = 6;\r
1025 }\r
1026\r
1027 CatPrint (Str, L"MAC(");\r
1028\r
1029 for (Index = 0; Index < HwAddressSize; Index++) {\r
1030 CatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]);\r
1031 }\r
1032\r
1033 CatPrint (Str, L",0x%x)", MacDevPath->IfType);\r
1034}\r
1035\r
1036/**\r
1037 Converts network protocol string to its text representation.\r
1038\r
1039 @param Str The string representative of input device.\r
1040 @param Protocol The network protocol ID.\r
1041\r
1042**/\r
1043VOID\r
1044CatNetworkProtocol (\r
1045 IN OUT POOL_PRINT *Str,\r
1046 IN UINT16 Protocol\r
1047 )\r
1048{\r
1049 if (Protocol == RFC_1700_TCP_PROTOCOL) {\r
1050 CatPrint (Str, L"TCP");\r
1051 } else if (Protocol == RFC_1700_UDP_PROTOCOL) {\r
1052 CatPrint (Str, L"UDP");\r
1053 } else {\r
1054 CatPrint (Str, L"0x%x", Protocol);\r
1055 }\r
1056}\r
1057\r
1058/**\r
1059 Converts a IPv4 device path structure to its string representative.\r
1060\r
1061 @param Str The string representative of input device.\r
1062 @param DevPath The input device path structure.\r
1063 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1064 of the display node is used, where applicable. If DisplayOnly\r
1065 is FALSE, then the longer text representation of the display node\r
1066 is used.\r
1067 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1068 representation for a device node can be used, where applicable.\r
1069\r
1070**/\r
1071VOID\r
1072DevPathToTextIPv4 (\r
1073 IN OUT POOL_PRINT *Str,\r
1074 IN VOID *DevPath,\r
1075 IN BOOLEAN DisplayOnly,\r
1076 IN BOOLEAN AllowShortcuts\r
1077 )\r
1078{\r
1079 IPv4_DEVICE_PATH *IPDevPath;\r
1080\r
1081 IPDevPath = DevPath;\r
1082 if (DisplayOnly) {\r
1083 CatPrint (\r
1084 Str,\r
1085 L"IPv4(%d.%d.%d.%d)",\r
1086 IPDevPath->RemoteIpAddress.Addr[0],\r
1087 IPDevPath->RemoteIpAddress.Addr[1],\r
1088 IPDevPath->RemoteIpAddress.Addr[2],\r
1089 IPDevPath->RemoteIpAddress.Addr[3]\r
1090 );\r
1091 return ;\r
1092 }\r
1093\r
1094 CatPrint (\r
1095 Str,\r
1096 L"IPv4(%d.%d.%d.%d,",\r
1097 IPDevPath->RemoteIpAddress.Addr[0],\r
1098 IPDevPath->RemoteIpAddress.Addr[1],\r
1099 IPDevPath->RemoteIpAddress.Addr[2],\r
1100 IPDevPath->RemoteIpAddress.Addr[3]\r
1101 );\r
1102\r
1103 CatNetworkProtocol (\r
1104 Str,\r
1105 IPDevPath->Protocol\r
1106 );\r
1107\r
1108 CatPrint (\r
1109 Str,\r
1110 L",%s,%d.%d.%d.%d",\r
1111 IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r
1112 IPDevPath->LocalIpAddress.Addr[0],\r
1113 IPDevPath->LocalIpAddress.Addr[1],\r
1114 IPDevPath->LocalIpAddress.Addr[2],\r
1115 IPDevPath->LocalIpAddress.Addr[3]\r
1116 );\r
1117 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv4_DEVICE_PATH)) {\r
1118 CatPrint (\r
1119 Str,\r
1120 L",%d.%d.%d.%d,%d.%d.%d.%d",\r
1121 IPDevPath->GatewayIpAddress.Addr[0],\r
1122 IPDevPath->GatewayIpAddress.Addr[1],\r
1123 IPDevPath->GatewayIpAddress.Addr[2],\r
1124 IPDevPath->GatewayIpAddress.Addr[3],\r
1125 IPDevPath->SubnetMask.Addr[0],\r
1126 IPDevPath->SubnetMask.Addr[1],\r
1127 IPDevPath->SubnetMask.Addr[2],\r
1128 IPDevPath->SubnetMask.Addr[3]\r
1129 );\r
1130 }\r
1131 CatPrint (Str, L")");\r
1132}\r
1133\r
1134/**\r
1135 Converts a IPv6 device path structure to its string representative.\r
1136\r
1137 @param Str The string representative of input device.\r
1138 @param DevPath The input device path structure.\r
1139 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1140 of the display node is used, where applicable. If DisplayOnly\r
1141 is FALSE, then the longer text representation of the display node\r
1142 is used.\r
1143 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1144 representation for a device node can be used, where applicable.\r
1145\r
1146**/\r
1147VOID\r
1148DevPathToTextIPv6 (\r
1149 IN OUT POOL_PRINT *Str,\r
1150 IN VOID *DevPath,\r
1151 IN BOOLEAN DisplayOnly,\r
1152 IN BOOLEAN AllowShortcuts\r
1153 )\r
1154{\r
1155 IPv6_DEVICE_PATH *IPDevPath;\r
1156\r
1157 IPDevPath = DevPath;\r
1158 if (DisplayOnly) {\r
1159 CatPrint (\r
1160 Str,\r
1161 L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
1162 IPDevPath->RemoteIpAddress.Addr[0],\r
1163 IPDevPath->RemoteIpAddress.Addr[1],\r
1164 IPDevPath->RemoteIpAddress.Addr[2],\r
1165 IPDevPath->RemoteIpAddress.Addr[3],\r
1166 IPDevPath->RemoteIpAddress.Addr[4],\r
1167 IPDevPath->RemoteIpAddress.Addr[5],\r
1168 IPDevPath->RemoteIpAddress.Addr[6],\r
1169 IPDevPath->RemoteIpAddress.Addr[7],\r
1170 IPDevPath->RemoteIpAddress.Addr[8],\r
1171 IPDevPath->RemoteIpAddress.Addr[9],\r
1172 IPDevPath->RemoteIpAddress.Addr[10],\r
1173 IPDevPath->RemoteIpAddress.Addr[11],\r
1174 IPDevPath->RemoteIpAddress.Addr[12],\r
1175 IPDevPath->RemoteIpAddress.Addr[13],\r
1176 IPDevPath->RemoteIpAddress.Addr[14],\r
1177 IPDevPath->RemoteIpAddress.Addr[15]\r
1178 );\r
1179 return ;\r
1180 }\r
1181\r
1182 CatPrint (\r
1183 Str,\r
1184 L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,",\r
1185 IPDevPath->RemoteIpAddress.Addr[0],\r
1186 IPDevPath->RemoteIpAddress.Addr[1],\r
1187 IPDevPath->RemoteIpAddress.Addr[2],\r
1188 IPDevPath->RemoteIpAddress.Addr[3],\r
1189 IPDevPath->RemoteIpAddress.Addr[4],\r
1190 IPDevPath->RemoteIpAddress.Addr[5],\r
1191 IPDevPath->RemoteIpAddress.Addr[6],\r
1192 IPDevPath->RemoteIpAddress.Addr[7],\r
1193 IPDevPath->RemoteIpAddress.Addr[8],\r
1194 IPDevPath->RemoteIpAddress.Addr[9],\r
1195 IPDevPath->RemoteIpAddress.Addr[10],\r
1196 IPDevPath->RemoteIpAddress.Addr[11],\r
1197 IPDevPath->RemoteIpAddress.Addr[12],\r
1198 IPDevPath->RemoteIpAddress.Addr[13],\r
1199 IPDevPath->RemoteIpAddress.Addr[14],\r
1200 IPDevPath->RemoteIpAddress.Addr[15]\r
1201 );\r
1202 \r
1203 CatNetworkProtocol (\r
1204 Str,\r
1205 IPDevPath->Protocol\r
1206 );\r
1207\r
1208 CatPrint (\r
1209 Str,\r
1210 L",%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
1211 IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r
1212 IPDevPath->LocalIpAddress.Addr[0],\r
1213 IPDevPath->LocalIpAddress.Addr[1],\r
1214 IPDevPath->LocalIpAddress.Addr[2],\r
1215 IPDevPath->LocalIpAddress.Addr[3],\r
1216 IPDevPath->LocalIpAddress.Addr[4],\r
1217 IPDevPath->LocalIpAddress.Addr[5],\r
1218 IPDevPath->LocalIpAddress.Addr[6],\r
1219 IPDevPath->LocalIpAddress.Addr[7],\r
1220 IPDevPath->LocalIpAddress.Addr[8],\r
1221 IPDevPath->LocalIpAddress.Addr[9],\r
1222 IPDevPath->LocalIpAddress.Addr[10],\r
1223 IPDevPath->LocalIpAddress.Addr[11],\r
1224 IPDevPath->LocalIpAddress.Addr[12],\r
1225 IPDevPath->LocalIpAddress.Addr[13],\r
1226 IPDevPath->LocalIpAddress.Addr[14],\r
1227 IPDevPath->LocalIpAddress.Addr[15]\r
1228 );\r
1229}\r
1230\r
1231/**\r
1232 Converts an Infini Band device path structure to its string representative.\r
1233\r
1234 @param Str The string representative of input device.\r
1235 @param DevPath The input device path structure.\r
1236 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1237 of the display node is used, where applicable. If DisplayOnly\r
1238 is FALSE, then the longer text representation of the display node\r
1239 is used.\r
1240 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1241 representation for a device node can be used, where applicable.\r
1242\r
1243**/\r
1244VOID\r
1245DevPathToTextInfiniBand (\r
1246 IN OUT POOL_PRINT *Str,\r
1247 IN VOID *DevPath,\r
1248 IN BOOLEAN DisplayOnly,\r
1249 IN BOOLEAN AllowShortcuts\r
1250 )\r
1251{\r
1252 INFINIBAND_DEVICE_PATH *InfiniBand;\r
1253\r
1254 InfiniBand = DevPath;\r
1255 CatPrint (\r
1256 Str,\r
1257 L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",\r
1258 InfiniBand->ResourceFlags,\r
1259 InfiniBand->PortGid,\r
1260 InfiniBand->ServiceId,\r
1261 InfiniBand->TargetPortId,\r
1262 InfiniBand->DeviceId\r
1263 );\r
1264}\r
1265\r
1266/**\r
1267 Converts a UART device path structure to its string representative.\r
1268\r
1269 @param Str The string representative of input device.\r
1270 @param DevPath The input device path structure.\r
1271 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1272 of the display node is used, where applicable. If DisplayOnly\r
1273 is FALSE, then the longer text representation of the display node\r
1274 is used.\r
1275 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1276 representation for a device node can be used, where applicable.\r
1277\r
1278**/\r
1279VOID\r
1280DevPathToTextUart (\r
1281 IN OUT POOL_PRINT *Str,\r
1282 IN VOID *DevPath,\r
1283 IN BOOLEAN DisplayOnly,\r
1284 IN BOOLEAN AllowShortcuts\r
1285 )\r
1286{\r
1287 UART_DEVICE_PATH *Uart;\r
1288 CHAR8 Parity;\r
1289\r
1290 Uart = DevPath;\r
1291 switch (Uart->Parity) {\r
1292 case 0:\r
1293 Parity = 'D';\r
1294 break;\r
1295\r
1296 case 1:\r
1297 Parity = 'N';\r
1298 break;\r
1299\r
1300 case 2:\r
1301 Parity = 'E';\r
1302 break;\r
1303\r
1304 case 3:\r
1305 Parity = 'O';\r
1306 break;\r
1307\r
1308 case 4:\r
1309 Parity = 'M';\r
1310 break;\r
1311\r
1312 case 5:\r
1313 Parity = 'S';\r
1314 break;\r
1315\r
1316 default:\r
1317 Parity = 'x';\r
1318 break;\r
1319 }\r
1320\r
1321 if (Uart->BaudRate == 0) {\r
1322 CatPrint (Str, L"Uart(DEFAULT,");\r
1323 } else {\r
1324 CatPrint (Str, L"Uart(%ld,", Uart->BaudRate);\r
1325 }\r
1326\r
1327 if (Uart->DataBits == 0) {\r
1328 CatPrint (Str, L"DEFAULT,");\r
1329 } else {\r
1330 CatPrint (Str, L"%d,", Uart->DataBits);\r
1331 }\r
1332\r
1333 CatPrint (Str, L"%c,", Parity);\r
1334\r
1335 switch (Uart->StopBits) {\r
1336 case 0:\r
1337 CatPrint (Str, L"D)");\r
1338 break;\r
1339\r
1340 case 1:\r
1341 CatPrint (Str, L"1)");\r
1342 break;\r
1343\r
1344 case 2:\r
1345 CatPrint (Str, L"1.5)");\r
1346 break;\r
1347\r
1348 case 3:\r
1349 CatPrint (Str, L"2)");\r
1350 break;\r
1351\r
1352 default:\r
1353 CatPrint (Str, L"x)");\r
1354 break;\r
1355 }\r
1356}\r
1357\r
1358/**\r
1359 Converts an iSCSI device path structure to its string representative.\r
1360\r
1361 @param Str The string representative of input device.\r
1362 @param DevPath The input device path structure.\r
1363 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1364 of the display node is used, where applicable. If DisplayOnly\r
1365 is FALSE, then the longer text representation of the display node\r
1366 is used.\r
1367 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1368 representation for a device node can be used, where applicable.\r
1369\r
1370**/\r
1371VOID\r
1372DevPathToTextiSCSI (\r
1373 IN OUT POOL_PRINT *Str,\r
1374 IN VOID *DevPath,\r
1375 IN BOOLEAN DisplayOnly,\r
1376 IN BOOLEAN AllowShortcuts\r
1377 )\r
1378{\r
1379 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
1380 UINT16 Options;\r
1381\r
1382 ISCSIDevPath = DevPath;\r
1383 CatPrint (\r
1384 Str,\r
1385 L"iSCSI(%a,0x%x,0x%lx,",\r
1386 ISCSIDevPath->TargetName,\r
1387 ISCSIDevPath->TargetPortalGroupTag,\r
1388 ISCSIDevPath->Lun\r
1389 );\r
1390\r
1391 Options = ISCSIDevPath->LoginOption;\r
1392 CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
1393 CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
1394 if (((Options >> 11) & 0x0001) != 0) {\r
1395 CatPrint (Str, L"%s,", L"None");\r
1396 } else if (((Options >> 12) & 0x0001) != 0) {\r
1397 CatPrint (Str, L"%s,", L"CHAP_UNI");\r
1398 } else {\r
1399 CatPrint (Str, L"%s,", L"CHAP_BI");\r
1400\r
1401 }\r
1402\r
1403 CatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
1404}\r
1405\r
1406/**\r
1407 Converts a VLAN device path structure to its string representative.\r
1408\r
1409 @param Str The string representative of input device.\r
1410 @param DevPath The input device path structure.\r
1411 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1412 of the display node is used, where applicable. If DisplayOnly\r
1413 is FALSE, then the longer text representation of the display node\r
1414 is used.\r
1415 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1416 representation for a device node can be used, where applicable.\r
1417\r
1418**/\r
1419VOID\r
1420DevPathToTextVlan (\r
1421 IN OUT POOL_PRINT *Str,\r
1422 IN VOID *DevPath,\r
1423 IN BOOLEAN DisplayOnly,\r
1424 IN BOOLEAN AllowShortcuts\r
1425 )\r
1426{\r
1427 VLAN_DEVICE_PATH *Vlan;\r
1428\r
1429 Vlan = DevPath;\r
1430 CatPrint (Str, L"Vlan(%d)", Vlan->VlanId);\r
1431}\r
1432\r
1433/**\r
1434 Converts a Hard drive device path structure to its string representative.\r
1435\r
1436 @param Str The string representative of input device.\r
1437 @param DevPath The input device path structure.\r
1438 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1439 of the display node is used, where applicable. If DisplayOnly\r
1440 is FALSE, then the longer text representation of the display node\r
1441 is used.\r
1442 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1443 representation for a device node can be used, where applicable.\r
1444\r
1445**/\r
1446VOID\r
1447DevPathToTextHardDrive (\r
1448 IN OUT POOL_PRINT *Str,\r
1449 IN VOID *DevPath,\r
1450 IN BOOLEAN DisplayOnly,\r
1451 IN BOOLEAN AllowShortcuts\r
1452 )\r
1453{\r
1454 HARDDRIVE_DEVICE_PATH *Hd;\r
1455\r
1456 Hd = DevPath;\r
1457 switch (Hd->SignatureType) {\r
1458 case SIGNATURE_TYPE_MBR:\r
1459 CatPrint (\r
1460 Str,\r
1461 L"HD(%d,%s,0x%08x,",\r
1462 Hd->PartitionNumber,\r
1463 L"MBR",\r
1464 *((UINT32 *) (&(Hd->Signature[0])))\r
1465 );\r
1466 break;\r
1467\r
1468 case SIGNATURE_TYPE_GUID:\r
1469 CatPrint (\r
1470 Str,\r
1471 L"HD(%d,%s,%g,",\r
1472 Hd->PartitionNumber,\r
1473 L"GPT",\r
1474 (EFI_GUID *) &(Hd->Signature[0])\r
1475 );\r
1476 break;\r
1477\r
1478 default:\r
1479 CatPrint (\r
1480 Str,\r
1481 L"HD(%d,%d,0,",\r
1482 Hd->PartitionNumber,\r
1483 Hd->SignatureType\r
1484 );\r
1485 break;\r
1486 }\r
1487\r
1488 CatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);\r
1489}\r
1490\r
1491/**\r
1492 Converts a CDROM device path structure to its string representative.\r
1493\r
1494 @param Str The string representative of input device.\r
1495 @param DevPath The input device path structure.\r
1496 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1497 of the display node is used, where applicable. If DisplayOnly\r
1498 is FALSE, then the longer text representation of the display node\r
1499 is used.\r
1500 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1501 representation for a device node can be used, where applicable.\r
1502\r
1503**/\r
1504VOID\r
1505DevPathToTextCDROM (\r
1506 IN OUT POOL_PRINT *Str,\r
1507 IN VOID *DevPath,\r
1508 IN BOOLEAN DisplayOnly,\r
1509 IN BOOLEAN AllowShortcuts\r
1510 )\r
1511{\r
1512 CDROM_DEVICE_PATH *Cd;\r
1513\r
1514 Cd = DevPath;\r
1515 if (DisplayOnly) {\r
1516 CatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);\r
1517 return ;\r
1518 }\r
1519\r
1520 CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
1521}\r
1522\r
1523/**\r
1524 Converts a File device path structure to its string representative.\r
1525\r
1526 @param Str The string representative of input device.\r
1527 @param DevPath The input device path structure.\r
1528 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1529 of the display node is used, where applicable. If DisplayOnly\r
1530 is FALSE, then the longer text representation of the display node\r
1531 is used.\r
1532 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1533 representation for a device node can be used, where applicable.\r
1534\r
1535**/\r
1536VOID\r
1537DevPathToTextFilePath (\r
1538 IN OUT POOL_PRINT *Str,\r
1539 IN VOID *DevPath,\r
1540 IN BOOLEAN DisplayOnly,\r
1541 IN BOOLEAN AllowShortcuts\r
1542 )\r
1543{\r
1544 FILEPATH_DEVICE_PATH *Fp;\r
1545\r
1546 Fp = DevPath;\r
1547 CatPrint (Str, L"%s", Fp->PathName);\r
1548}\r
1549\r
1550/**\r
1551 Converts a Media protocol device path structure to its string representative.\r
1552\r
1553 @param Str The string representative of input device.\r
1554 @param DevPath The input device path structure.\r
1555 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1556 of the display node is used, where applicable. If DisplayOnly\r
1557 is FALSE, then the longer text representation of the display node\r
1558 is used.\r
1559 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1560 representation for a device node can be used, where applicable.\r
1561\r
1562**/\r
1563VOID\r
1564DevPathToTextMediaProtocol (\r
1565 IN OUT POOL_PRINT *Str,\r
1566 IN VOID *DevPath,\r
1567 IN BOOLEAN DisplayOnly,\r
1568 IN BOOLEAN AllowShortcuts\r
1569 )\r
1570{\r
1571 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;\r
1572\r
1573 MediaProt = DevPath;\r
1574 CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
1575}\r
1576\r
1577/**\r
1578 Converts a Firmware Volume device path structure to its string representative.\r
1579\r
1580 @param Str The string representative of input device.\r
1581 @param DevPath The input device path structure.\r
1582 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1583 of the display node is used, where applicable. If DisplayOnly\r
1584 is FALSE, then the longer text representation of the display node\r
1585 is used.\r
1586 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1587 representation for a device node can be used, where applicable.\r
1588\r
1589**/\r
1590VOID\r
1591DevPathToTextFv (\r
1592 IN OUT POOL_PRINT *Str,\r
1593 IN VOID *DevPath,\r
1594 IN BOOLEAN DisplayOnly,\r
1595 IN BOOLEAN AllowShortcuts\r
1596 )\r
1597{\r
1598 MEDIA_FW_VOL_DEVICE_PATH *Fv;\r
1599\r
1600 Fv = DevPath;\r
1601 CatPrint (Str, L"Fv(%g)", &Fv->FvName);\r
1602}\r
1603\r
1604/**\r
1605 Converts a Firmware Volume File device path structure to its string representative.\r
1606\r
1607 @param Str The string representative of input device.\r
1608 @param DevPath The input device path structure.\r
1609 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1610 of the display node is used, where applicable. If DisplayOnly\r
1611 is FALSE, then the longer text representation of the display node\r
1612 is used.\r
1613 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1614 representation for a device node can be used, where applicable.\r
1615\r
1616**/\r
1617VOID\r
1618DevPathToTextFvFile (\r
1619 IN OUT POOL_PRINT *Str,\r
1620 IN VOID *DevPath,\r
1621 IN BOOLEAN DisplayOnly,\r
1622 IN BOOLEAN AllowShortcuts\r
1623 )\r
1624{\r
1625 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;\r
1626\r
1627 FvFile = DevPath;\r
1628 CatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);\r
1629}\r
1630\r
1631/**\r
1632 Converts a Relative Offset device path structure to its string representative.\r
1633\r
1634 @param Str The string representative of input device.\r
1635 @param DevPath The input device path structure.\r
1636 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1637 of the display node is used, where applicable. If DisplayOnly\r
1638 is FALSE, then the longer text representation of the display node\r
1639 is used.\r
1640 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1641 representation for a device node can be used, where applicable.\r
1642\r
1643**/\r
1644VOID\r
1645DevPathRelativeOffsetRange (\r
1646 IN OUT POOL_PRINT *Str,\r
1647 IN VOID *DevPath,\r
1648 IN BOOLEAN DisplayOnly,\r
1649 IN BOOLEAN AllowShortcuts\r
1650 )\r
1651{\r
1652 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
1653\r
1654 Offset = DevPath;\r
1655 CatPrint (\r
1656 Str,\r
1657 L"Offset(0x%lx,0x%lx)",\r
1658 Offset->StartingOffset,\r
1659 Offset->EndingOffset\r
1660 );\r
1661}\r
1662\r
1663/**\r
1664 Converts a BIOS Boot Specification device path structure to its string representative.\r
1665\r
1666 @param Str The string representative of input device.\r
1667 @param DevPath The input device path structure.\r
1668 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1669 of the display node is used, where applicable. If DisplayOnly\r
1670 is FALSE, then the longer text representation of the display node\r
1671 is used.\r
1672 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1673 representation for a device node can be used, where applicable.\r
1674\r
1675**/\r
1676VOID\r
1677DevPathToTextBBS (\r
1678 IN OUT POOL_PRINT *Str,\r
1679 IN VOID *DevPath,\r
1680 IN BOOLEAN DisplayOnly,\r
1681 IN BOOLEAN AllowShortcuts\r
1682 )\r
1683{\r
1684 BBS_BBS_DEVICE_PATH *Bbs;\r
1685 CHAR16 *Type;\r
1686\r
1687 Bbs = DevPath;\r
1688 switch (Bbs->DeviceType) {\r
1689 case BBS_TYPE_FLOPPY:\r
1690 Type = L"Floppy";\r
1691 break;\r
1692\r
1693 case BBS_TYPE_HARDDRIVE:\r
1694 Type = L"HD";\r
1695 break;\r
1696\r
1697 case BBS_TYPE_CDROM:\r
1698 Type = L"CDROM";\r
1699 break;\r
1700\r
1701 case BBS_TYPE_PCMCIA:\r
1702 Type = L"PCMCIA";\r
1703 break;\r
1704\r
1705 case BBS_TYPE_USB:\r
1706 Type = L"USB";\r
1707 break;\r
1708\r
1709 case BBS_TYPE_EMBEDDED_NETWORK:\r
1710 Type = L"Network";\r
1711 break;\r
1712\r
1713 default:\r
1714 Type = NULL;\r
1715 break;\r
1716 }\r
1717\r
1718 if (Type != NULL) {\r
1719 CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r
1720 } else {\r
1721 CatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String);\r
1722 }\r
1723\r
1724 if (DisplayOnly) {\r
1725 CatPrint (Str, L")");\r
1726 return ;\r
1727 }\r
1728\r
1729 CatPrint (Str, L",0x%x)", Bbs->StatusFlag);\r
1730}\r
1731\r
1732/**\r
1733 Converts an End-of-Device-Path structure to its string representative.\r
1734\r
1735 @param Str The string representative of input device.\r
1736 @param DevPath The input device path structure.\r
1737 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1738 of the display node is used, where applicable. If DisplayOnly\r
1739 is FALSE, then the longer text representation of the display node\r
1740 is used.\r
1741 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1742 representation for a device node can be used, where applicable.\r
1743\r
1744**/\r
1745VOID\r
1746DevPathToTextEndInstance (\r
1747 IN OUT POOL_PRINT *Str,\r
1748 IN VOID *DevPath,\r
1749 IN BOOLEAN DisplayOnly,\r
1750 IN BOOLEAN AllowShortcuts\r
1751 )\r
1752{\r
1753 CatPrint (Str, L",");\r
1754}\r
1755\r
1756/**\r
1757 Converts an unknown device path structure to its string representative.\r
1758\r
1759 @param Str The string representative of input device.\r
1760 @param DevPath The input device path structure.\r
1761 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1762 of the display node is used, where applicable. If DisplayOnly\r
1763 is FALSE, then the longer text representation of the display node\r
1764 is used.\r
1765 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1766 representation for a device node can be used, where applicable.\r
1767\r
1768**/\r
1769VOID\r
1770DevPathToTextNodeUnknown (\r
1771 IN OUT POOL_PRINT *Str,\r
1772 IN VOID *DevPath,\r
1773 IN BOOLEAN DisplayOnly,\r
1774 IN BOOLEAN AllowShortcuts\r
1775 )\r
1776{\r
1777 CatPrint (Str, L"?");\r
1778}\r
1779\r
1780GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable[] = {\r
1781 {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci},\r
1782 {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard},\r
1783 {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap},\r
1784 {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor},\r
1785 {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController},\r
1786 {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi},\r
1787 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx},\r
1788 {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr},\r
1789 {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi},\r
1790 {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi},\r
1791 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre},\r
1792 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx},\r
1793 {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394},\r
1794 {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb},\r
1795 {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID},\r
1796 {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit},\r
1797 {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass},\r
1798 {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata},\r
1799 {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O},\r
1800 {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr},\r
1801 {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4},\r
1802 {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6},\r
1803 {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand},\r
1804 {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart},\r
1805 {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor},\r
1806 {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI},\r
1807 {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan},\r
1808 {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive},\r
1809 {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM},\r
1810 {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor},\r
1811 {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol},\r
1812 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r
1813 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv},\r
1814 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile},\r
1815 {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange},\r
1816 {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS},\r
1817 {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance},\r
1818 {0, 0, NULL}\r
1819};\r
1820\r
1821/**\r
1822 Converts a device node to its string representation.\r
1823\r
1824 @param DeviceNode A Pointer to the device node to be converted.\r
1825 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1826 of the display node is used, where applicable. If DisplayOnly\r
1827 is FALSE, then the longer text representation of the display node\r
1828 is used.\r
1829 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1830 representation for a device node can be used, where applicable.\r
1831\r
1832 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
1833 is NULL or there was insufficient memory.\r
1834\r
1835**/\r
1836CHAR16 *\r
1837EFIAPI\r
1838ConvertDeviceNodeToText (\r
1839 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
1840 IN BOOLEAN DisplayOnly,\r
1841 IN BOOLEAN AllowShortcuts\r
1842 )\r
1843{\r
1844 POOL_PRINT Str;\r
1845 UINTN Index;\r
1846 VOID (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
1847\r
1848 if (DeviceNode == NULL) {\r
1849 return NULL;\r
1850 }\r
1851\r
1852 ZeroMem (&Str, sizeof (Str));\r
1853\r
1854 //\r
1855 // Process the device path node\r
1856 //\r
1857 DumpNode = NULL;\r
1858 for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index++) {\r
1859 if (DevicePathType (DeviceNode) == DevPathToTextTable[Index].Type &&\r
1860 DevicePathSubType (DeviceNode) == DevPathToTextTable[Index].SubType\r
1861 ) {\r
1862 DumpNode = DevPathToTextTable[Index].Function;\r
1863 break;\r
1864 }\r
1865 }\r
1866 //\r
1867 // If not found, use a generic function\r
1868 //\r
1869 if (DumpNode == NULL) {\r
1870 DumpNode = DevPathToTextNodeUnknown;\r
1871 }\r
1872\r
1873 //\r
1874 // Print this node\r
1875 //\r
1876 DumpNode (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r
1877\r
1878 ASSERT (Str.Str != NULL);\r
1879 return Str.Str;\r
1880}\r
1881\r
1882/**\r
1883 Converts a device path to its text representation.\r
1884\r
1885 @param DevicePath A Pointer to the device to be converted.\r
1886 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
1887 of the display node is used, where applicable. If DisplayOnly\r
1888 is FALSE, then the longer text representation of the display node\r
1889 is used.\r
1890 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
1891 representation for a device node can be used, where applicable.\r
1892\r
1893 @return A pointer to the allocated text representation of the device path or\r
1894 NULL if DeviceNode is NULL or there was insufficient memory.\r
1895\r
1896**/\r
1897CHAR16 *\r
1898EFIAPI\r
1899ConvertDevicePathToText (\r
1900 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
1901 IN BOOLEAN DisplayOnly,\r
1902 IN BOOLEAN AllowShortcuts\r
1903 )\r
1904{\r
1905 POOL_PRINT Str;\r
1906 EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r
1907 EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode;\r
1908 UINTN Index;\r
1909 VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
1910\r
1911 if (DevicePath == NULL) {\r
1912 return NULL;\r
1913 }\r
1914\r
1915 ZeroMem (&Str, sizeof (Str));\r
1916\r
1917 //\r
1918 // Process each device path node\r
1919 //\r
1920 DevPathNode = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;\r
1921 while (!IsDevicePathEnd (DevPathNode)) {\r
1922 //\r
1923 // Find the handler to dump this device path node\r
1924 //\r
1925 DumpNode = NULL;\r
1926 for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index += 1) {\r
1927\r
1928 if (DevicePathType (DevPathNode) == DevPathToTextTable[Index].Type &&\r
1929 DevicePathSubType (DevPathNode) == DevPathToTextTable[Index].SubType\r
1930 ) {\r
1931 DumpNode = DevPathToTextTable[Index].Function;\r
1932 break;\r
1933 }\r
1934 }\r
1935 //\r
1936 // If not found, use a generic function\r
1937 //\r
1938 if (!DumpNode) {\r
1939 DumpNode = DevPathToTextNodeUnknown;\r
1940 }\r
1941 //\r
1942 // Put a path separator in if needed\r
1943 //\r
1944 if ((Str.Length != 0) && (DumpNode != DevPathToTextEndInstance)) {\r
1945 if (*(Str.Str + Str.Length / sizeof (CHAR16) - 1) != L',') {\r
1946 CatPrint (&Str, L"/");\r
1947 }\r
1948 }\r
1949 \r
1950 AlignedDevPathNode = AllocateCopyPool (DevicePathNodeLength (DevPathNode), DevPathNode);\r
1951 //\r
1952 // Print this node of the device path\r
1953 //\r
1954 DumpNode (&Str, AlignedDevPathNode, DisplayOnly, AllowShortcuts);\r
1955 FreePool (AlignedDevPathNode);\r
1956 \r
1957 //\r
1958 // Next device path node\r
1959 //\r
1960 DevPathNode = NextDevicePathNode (DevPathNode);\r
1961 }\r
1962\r
1963 if (Str.Str == NULL) {\r
1964 return AllocateZeroPool (sizeof (CHAR16));\r
1965 } else {\r
1966 return Str.Str;\r
1967 }\r
1968}\r