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