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