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