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