]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
Add device path node/text conversion for NVMe device path node.
[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 - 2014, 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 1394 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 DevPathToText1394 (
749 IN OUT POOL_PRINT *Str,
750 IN VOID *DevPath,
751 IN BOOLEAN DisplayOnly,
752 IN BOOLEAN AllowShortcuts
753 )
754 {
755 F1394_DEVICE_PATH *F1394DevPath;
756
757 F1394DevPath = DevPath;
758 //
759 // Guid has format of IEEE-EUI64
760 //
761 UefiDevicePathLibCatPrint (Str, L"I1394(%016lx)", F1394DevPath->Guid);
762 }
763
764 /**
765 Converts a USB device path structure to its string representative.
766
767 @param Str The string representative of input device.
768 @param DevPath The input device path structure.
769 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
770 of the display node is used, where applicable. If DisplayOnly
771 is FALSE, then the longer text representation of the display node
772 is used.
773 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
774 representation for a device node can be used, where applicable.
775
776 **/
777 VOID
778 DevPathToTextUsb (
779 IN OUT POOL_PRINT *Str,
780 IN VOID *DevPath,
781 IN BOOLEAN DisplayOnly,
782 IN BOOLEAN AllowShortcuts
783 )
784 {
785 USB_DEVICE_PATH *Usb;
786
787 Usb = DevPath;
788 UefiDevicePathLibCatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);
789 }
790
791 /**
792 Converts a USB WWID device path structure to its string representative.
793
794 @param Str The string representative of input device.
795 @param DevPath The input device path structure.
796 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
797 of the display node is used, where applicable. If DisplayOnly
798 is FALSE, then the longer text representation of the display node
799 is used.
800 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
801 representation for a device node can be used, where applicable.
802
803 **/
804 VOID
805 DevPathToTextUsbWWID (
806 IN OUT POOL_PRINT *Str,
807 IN VOID *DevPath,
808 IN BOOLEAN DisplayOnly,
809 IN BOOLEAN AllowShortcuts
810 )
811 {
812 USB_WWID_DEVICE_PATH *UsbWWId;
813 CHAR16 *SerialNumberStr;
814 CHAR16 *NewStr;
815 UINT16 Length;
816
817 UsbWWId = DevPath;
818
819 SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof (USB_WWID_DEVICE_PATH));
820 Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));
821 if (SerialNumberStr [Length - 1] != 0) {
822 //
823 // In case no NULL terminator in SerialNumber, create a new one with NULL terminator
824 //
825 NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);
826 ASSERT (NewStr != NULL);
827 NewStr [Length] = 0;
828 SerialNumberStr = NewStr;
829 }
830
831 UefiDevicePathLibCatPrint (
832 Str,
833 L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",
834 UsbWWId->VendorId,
835 UsbWWId->ProductId,
836 UsbWWId->InterfaceNumber,
837 SerialNumberStr
838 );
839 }
840
841 /**
842 Converts a Logic Unit device path structure to its string representative.
843
844 @param Str The string representative of input device.
845 @param DevPath The input device path structure.
846 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
847 of the display node is used, where applicable. If DisplayOnly
848 is FALSE, then the longer text representation of the display node
849 is used.
850 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
851 representation for a device node can be used, where applicable.
852
853 **/
854 VOID
855 DevPathToTextLogicalUnit (
856 IN OUT POOL_PRINT *Str,
857 IN VOID *DevPath,
858 IN BOOLEAN DisplayOnly,
859 IN BOOLEAN AllowShortcuts
860 )
861 {
862 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
863
864 LogicalUnit = DevPath;
865 UefiDevicePathLibCatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun);
866 }
867
868 /**
869 Converts a USB class device path structure to its string representative.
870
871 @param Str The string representative of input device.
872 @param DevPath The input device path structure.
873 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
874 of the display node is used, where applicable. If DisplayOnly
875 is FALSE, then the longer text representation of the display node
876 is used.
877 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
878 representation for a device node can be used, where applicable.
879
880 **/
881 VOID
882 DevPathToTextUsbClass (
883 IN OUT POOL_PRINT *Str,
884 IN VOID *DevPath,
885 IN BOOLEAN DisplayOnly,
886 IN BOOLEAN AllowShortcuts
887 )
888 {
889 USB_CLASS_DEVICE_PATH *UsbClass;
890 BOOLEAN IsKnownSubClass;
891
892
893 UsbClass = DevPath;
894
895 IsKnownSubClass = TRUE;
896 switch (UsbClass->DeviceClass) {
897 case USB_CLASS_AUDIO:
898 UefiDevicePathLibCatPrint (Str, L"UsbAudio");
899 break;
900
901 case USB_CLASS_CDCCONTROL:
902 UefiDevicePathLibCatPrint (Str, L"UsbCDCControl");
903 break;
904
905 case USB_CLASS_HID:
906 UefiDevicePathLibCatPrint (Str, L"UsbHID");
907 break;
908
909 case USB_CLASS_IMAGE:
910 UefiDevicePathLibCatPrint (Str, L"UsbImage");
911 break;
912
913 case USB_CLASS_PRINTER:
914 UefiDevicePathLibCatPrint (Str, L"UsbPrinter");
915 break;
916
917 case USB_CLASS_MASS_STORAGE:
918 UefiDevicePathLibCatPrint (Str, L"UsbMassStorage");
919 break;
920
921 case USB_CLASS_HUB:
922 UefiDevicePathLibCatPrint (Str, L"UsbHub");
923 break;
924
925 case USB_CLASS_CDCDATA:
926 UefiDevicePathLibCatPrint (Str, L"UsbCDCData");
927 break;
928
929 case USB_CLASS_SMART_CARD:
930 UefiDevicePathLibCatPrint (Str, L"UsbSmartCard");
931 break;
932
933 case USB_CLASS_VIDEO:
934 UefiDevicePathLibCatPrint (Str, L"UsbVideo");
935 break;
936
937 case USB_CLASS_DIAGNOSTIC:
938 UefiDevicePathLibCatPrint (Str, L"UsbDiagnostic");
939 break;
940
941 case USB_CLASS_WIRELESS:
942 UefiDevicePathLibCatPrint (Str, L"UsbWireless");
943 break;
944
945 default:
946 IsKnownSubClass = FALSE;
947 break;
948 }
949
950 if (IsKnownSubClass) {
951 UefiDevicePathLibCatPrint (
952 Str,
953 L"(0x%x,0x%x,0x%x,0x%x)",
954 UsbClass->VendorId,
955 UsbClass->ProductId,
956 UsbClass->DeviceSubClass,
957 UsbClass->DeviceProtocol
958 );
959 return;
960 }
961
962 if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {
963 if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {
964 UefiDevicePathLibCatPrint (
965 Str,
966 L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",
967 UsbClass->VendorId,
968 UsbClass->ProductId,
969 UsbClass->DeviceProtocol
970 );
971 return;
972 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {
973 UefiDevicePathLibCatPrint (
974 Str,
975 L"UsbIrdaBridge(0x%x,0x%x,0x%x)",
976 UsbClass->VendorId,
977 UsbClass->ProductId,
978 UsbClass->DeviceProtocol
979 );
980 return;
981 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {
982 UefiDevicePathLibCatPrint (
983 Str,
984 L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",
985 UsbClass->VendorId,
986 UsbClass->ProductId,
987 UsbClass->DeviceProtocol
988 );
989 return;
990 }
991 }
992
993 UefiDevicePathLibCatPrint (
994 Str,
995 L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",
996 UsbClass->VendorId,
997 UsbClass->ProductId,
998 UsbClass->DeviceClass,
999 UsbClass->DeviceSubClass,
1000 UsbClass->DeviceProtocol
1001 );
1002 }
1003
1004 /**
1005 Converts a SATA device path structure to its string representative.
1006
1007 @param Str The string representative of input device.
1008 @param DevPath The input device path structure.
1009 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1010 of the display node is used, where applicable. If DisplayOnly
1011 is FALSE, then the longer text representation of the display node
1012 is used.
1013 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1014 representation for a device node can be used, where applicable.
1015
1016 **/
1017 VOID
1018 DevPathToTextSata (
1019 IN OUT POOL_PRINT *Str,
1020 IN VOID *DevPath,
1021 IN BOOLEAN DisplayOnly,
1022 IN BOOLEAN AllowShortcuts
1023 )
1024 {
1025 SATA_DEVICE_PATH *Sata;
1026
1027 Sata = DevPath;
1028 UefiDevicePathLibCatPrint (
1029 Str,
1030 L"Sata(0x%x,0x%x,0x%x)",
1031 Sata->HBAPortNumber,
1032 Sata->PortMultiplierPortNumber,
1033 Sata->Lun
1034 );
1035 }
1036
1037 /**
1038 Converts a I20 device path structure to its string representative.
1039
1040 @param Str The string representative of input device.
1041 @param DevPath The input device path structure.
1042 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1043 of the display node is used, where applicable. If DisplayOnly
1044 is FALSE, then the longer text representation of the display node
1045 is used.
1046 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1047 representation for a device node can be used, where applicable.
1048
1049 **/
1050 VOID
1051 DevPathToTextI2O (
1052 IN OUT POOL_PRINT *Str,
1053 IN VOID *DevPath,
1054 IN BOOLEAN DisplayOnly,
1055 IN BOOLEAN AllowShortcuts
1056 )
1057 {
1058 I2O_DEVICE_PATH *I2ODevPath;
1059
1060 I2ODevPath = DevPath;
1061 UefiDevicePathLibCatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid);
1062 }
1063
1064 /**
1065 Converts a MAC address device path structure to its string representative.
1066
1067 @param Str The string representative of input device.
1068 @param DevPath The input device path structure.
1069 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1070 of the display node is used, where applicable. If DisplayOnly
1071 is FALSE, then the longer text representation of the display node
1072 is used.
1073 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1074 representation for a device node can be used, where applicable.
1075
1076 **/
1077 VOID
1078 DevPathToTextMacAddr (
1079 IN OUT POOL_PRINT *Str,
1080 IN VOID *DevPath,
1081 IN BOOLEAN DisplayOnly,
1082 IN BOOLEAN AllowShortcuts
1083 )
1084 {
1085 MAC_ADDR_DEVICE_PATH *MacDevPath;
1086 UINTN HwAddressSize;
1087 UINTN Index;
1088
1089 MacDevPath = DevPath;
1090
1091 HwAddressSize = sizeof (EFI_MAC_ADDRESS);
1092 if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {
1093 HwAddressSize = 6;
1094 }
1095
1096 UefiDevicePathLibCatPrint (Str, L"MAC(");
1097
1098 for (Index = 0; Index < HwAddressSize; Index++) {
1099 UefiDevicePathLibCatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]);
1100 }
1101
1102 UefiDevicePathLibCatPrint (Str, L",0x%x)", MacDevPath->IfType);
1103 }
1104
1105 /**
1106 Converts network protocol string to its text representation.
1107
1108 @param Str The string representative of input device.
1109 @param Protocol The network protocol ID.
1110
1111 **/
1112 VOID
1113 CatNetworkProtocol (
1114 IN OUT POOL_PRINT *Str,
1115 IN UINT16 Protocol
1116 )
1117 {
1118 if (Protocol == RFC_1700_TCP_PROTOCOL) {
1119 UefiDevicePathLibCatPrint (Str, L"TCP");
1120 } else if (Protocol == RFC_1700_UDP_PROTOCOL) {
1121 UefiDevicePathLibCatPrint (Str, L"UDP");
1122 } else {
1123 UefiDevicePathLibCatPrint (Str, L"0x%x", Protocol);
1124 }
1125 }
1126
1127 /**
1128 Converts IP v4 address to its text representation.
1129
1130 @param Str The string representative of input device.
1131 @param Address The IP v4 address.
1132 **/
1133 VOID
1134 CatIPv4Address (
1135 IN OUT POOL_PRINT *Str,
1136 IN EFI_IPv4_ADDRESS *Address
1137 )
1138 {
1139 UefiDevicePathLibCatPrint (Str, L"%d.%d.%d.%d", Address->Addr[0], Address->Addr[1], Address->Addr[2], Address->Addr[3]);
1140 }
1141
1142 /**
1143 Converts IP v6 address to its text representation.
1144
1145 @param Str The string representative of input device.
1146 @param Address The IP v6 address.
1147 **/
1148 VOID
1149 CatIPv6Address (
1150 IN OUT POOL_PRINT *Str,
1151 IN EFI_IPv6_ADDRESS *Address
1152 )
1153 {
1154 UefiDevicePathLibCatPrint (
1155 Str, L"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
1156 Address->Addr[0], Address->Addr[1],
1157 Address->Addr[2], Address->Addr[3],
1158 Address->Addr[4], Address->Addr[5],
1159 Address->Addr[6], Address->Addr[7],
1160 Address->Addr[8], Address->Addr[9],
1161 Address->Addr[10], Address->Addr[11],
1162 Address->Addr[12], Address->Addr[13],
1163 Address->Addr[14], Address->Addr[15]
1164 );
1165 }
1166
1167 /**
1168 Converts a IPv4 device path structure to its string representative.
1169
1170 @param Str The string representative of input device.
1171 @param DevPath The input device path structure.
1172 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1173 of the display node is used, where applicable. If DisplayOnly
1174 is FALSE, then the longer text representation of the display node
1175 is used.
1176 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1177 representation for a device node can be used, where applicable.
1178
1179 **/
1180 VOID
1181 DevPathToTextIPv4 (
1182 IN OUT POOL_PRINT *Str,
1183 IN VOID *DevPath,
1184 IN BOOLEAN DisplayOnly,
1185 IN BOOLEAN AllowShortcuts
1186 )
1187 {
1188 IPv4_DEVICE_PATH *IPDevPath;
1189
1190 IPDevPath = DevPath;
1191 UefiDevicePathLibCatPrint (Str, L"IPv4(");
1192 CatIPv4Address (Str, &IPDevPath->RemoteIpAddress);
1193
1194 if (DisplayOnly) {
1195 UefiDevicePathLibCatPrint (Str, L")");
1196 return ;
1197 }
1198
1199 UefiDevicePathLibCatPrint (Str, L",");
1200 CatNetworkProtocol (Str, IPDevPath->Protocol);
1201
1202 UefiDevicePathLibCatPrint (Str, L",%s,", IPDevPath->StaticIpAddress ? L"Static" : L"DHCP");
1203 CatIPv4Address (Str, &IPDevPath->LocalIpAddress);
1204 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv4_DEVICE_PATH)) {
1205 UefiDevicePathLibCatPrint (Str, L",");
1206 CatIPv4Address (Str, &IPDevPath->GatewayIpAddress);
1207 UefiDevicePathLibCatPrint (Str, L",");
1208 CatIPv4Address (Str, &IPDevPath->SubnetMask);
1209 }
1210 UefiDevicePathLibCatPrint (Str, L")");
1211 }
1212
1213 /**
1214 Converts a IPv6 device path structure to its string representative.
1215
1216 @param Str The string representative of input device.
1217 @param DevPath The input device path structure.
1218 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1219 of the display node is used, where applicable. If DisplayOnly
1220 is FALSE, then the longer text representation of the display node
1221 is used.
1222 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1223 representation for a device node can be used, where applicable.
1224
1225 **/
1226 VOID
1227 DevPathToTextIPv6 (
1228 IN OUT POOL_PRINT *Str,
1229 IN VOID *DevPath,
1230 IN BOOLEAN DisplayOnly,
1231 IN BOOLEAN AllowShortcuts
1232 )
1233 {
1234 IPv6_DEVICE_PATH *IPDevPath;
1235
1236 IPDevPath = DevPath;
1237 UefiDevicePathLibCatPrint (Str, L"IPv6(");
1238 CatIPv6Address (Str, &IPDevPath->RemoteIpAddress);
1239 if (DisplayOnly) {
1240 UefiDevicePathLibCatPrint (Str, L")");
1241 return ;
1242 }
1243
1244 UefiDevicePathLibCatPrint (Str, L",");
1245 CatNetworkProtocol (Str, IPDevPath->Protocol);
1246
1247 switch (IPDevPath->IpAddressOrigin) {
1248 case 0:
1249 UefiDevicePathLibCatPrint (Str, L",Static,");
1250 break;
1251 case 1:
1252 UefiDevicePathLibCatPrint (Str, L",StatelessAutoConfigure,");
1253 break;
1254 default:
1255 UefiDevicePathLibCatPrint (Str, L",StatefulAutoConfigure,");
1256 break;
1257 }
1258
1259 CatIPv6Address (Str, &IPDevPath->LocalIpAddress);
1260
1261 if (DevicePathNodeLength (IPDevPath) == sizeof (IPv6_DEVICE_PATH)) {
1262 UefiDevicePathLibCatPrint (Str, L",0x%x,", IPDevPath->PrefixLength);
1263 CatIPv6Address (Str, &IPDevPath->GatewayIpAddress);
1264 }
1265 UefiDevicePathLibCatPrint (Str, L")");
1266 }
1267
1268 /**
1269 Converts an Infini Band device path structure to its string representative.
1270
1271 @param Str The string representative of input device.
1272 @param DevPath The input device path structure.
1273 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1274 of the display node is used, where applicable. If DisplayOnly
1275 is FALSE, then the longer text representation of the display node
1276 is used.
1277 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1278 representation for a device node can be used, where applicable.
1279
1280 **/
1281 VOID
1282 DevPathToTextInfiniBand (
1283 IN OUT POOL_PRINT *Str,
1284 IN VOID *DevPath,
1285 IN BOOLEAN DisplayOnly,
1286 IN BOOLEAN AllowShortcuts
1287 )
1288 {
1289 INFINIBAND_DEVICE_PATH *InfiniBand;
1290
1291 InfiniBand = DevPath;
1292 UefiDevicePathLibCatPrint (
1293 Str,
1294 L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",
1295 InfiniBand->ResourceFlags,
1296 InfiniBand->PortGid,
1297 InfiniBand->ServiceId,
1298 InfiniBand->TargetPortId,
1299 InfiniBand->DeviceId
1300 );
1301 }
1302
1303 /**
1304 Converts a UART device path structure to its string representative.
1305
1306 @param Str The string representative of input device.
1307 @param DevPath The input device path structure.
1308 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1309 of the display node is used, where applicable. If DisplayOnly
1310 is FALSE, then the longer text representation of the display node
1311 is used.
1312 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1313 representation for a device node can be used, where applicable.
1314
1315 **/
1316 VOID
1317 DevPathToTextUart (
1318 IN OUT POOL_PRINT *Str,
1319 IN VOID *DevPath,
1320 IN BOOLEAN DisplayOnly,
1321 IN BOOLEAN AllowShortcuts
1322 )
1323 {
1324 UART_DEVICE_PATH *Uart;
1325 CHAR8 Parity;
1326
1327 Uart = DevPath;
1328 switch (Uart->Parity) {
1329 case 0:
1330 Parity = 'D';
1331 break;
1332
1333 case 1:
1334 Parity = 'N';
1335 break;
1336
1337 case 2:
1338 Parity = 'E';
1339 break;
1340
1341 case 3:
1342 Parity = 'O';
1343 break;
1344
1345 case 4:
1346 Parity = 'M';
1347 break;
1348
1349 case 5:
1350 Parity = 'S';
1351 break;
1352
1353 default:
1354 Parity = 'x';
1355 break;
1356 }
1357
1358 if (Uart->BaudRate == 0) {
1359 UefiDevicePathLibCatPrint (Str, L"Uart(DEFAULT,");
1360 } else {
1361 UefiDevicePathLibCatPrint (Str, L"Uart(%ld,", Uart->BaudRate);
1362 }
1363
1364 if (Uart->DataBits == 0) {
1365 UefiDevicePathLibCatPrint (Str, L"DEFAULT,");
1366 } else {
1367 UefiDevicePathLibCatPrint (Str, L"%d,", Uart->DataBits);
1368 }
1369
1370 UefiDevicePathLibCatPrint (Str, L"%c,", Parity);
1371
1372 switch (Uart->StopBits) {
1373 case 0:
1374 UefiDevicePathLibCatPrint (Str, L"D)");
1375 break;
1376
1377 case 1:
1378 UefiDevicePathLibCatPrint (Str, L"1)");
1379 break;
1380
1381 case 2:
1382 UefiDevicePathLibCatPrint (Str, L"1.5)");
1383 break;
1384
1385 case 3:
1386 UefiDevicePathLibCatPrint (Str, L"2)");
1387 break;
1388
1389 default:
1390 UefiDevicePathLibCatPrint (Str, L"x)");
1391 break;
1392 }
1393 }
1394
1395 /**
1396 Converts an iSCSI device path structure to its string representative.
1397
1398 @param Str The string representative of input device.
1399 @param DevPath The input device path structure.
1400 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1401 of the display node is used, where applicable. If DisplayOnly
1402 is FALSE, then the longer text representation of the display node
1403 is used.
1404 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1405 representation for a device node can be used, where applicable.
1406
1407 **/
1408 VOID
1409 DevPathToTextiSCSI (
1410 IN OUT POOL_PRINT *Str,
1411 IN VOID *DevPath,
1412 IN BOOLEAN DisplayOnly,
1413 IN BOOLEAN AllowShortcuts
1414 )
1415 {
1416 ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;
1417 UINT16 Options;
1418
1419 ISCSIDevPath = DevPath;
1420 UefiDevicePathLibCatPrint (
1421 Str,
1422 L"iSCSI(%a,0x%x,0x%lx,",
1423 ISCSIDevPath->TargetName,
1424 ISCSIDevPath->TargetPortalGroupTag,
1425 ISCSIDevPath->Lun
1426 );
1427
1428 Options = ISCSIDevPath->LoginOption;
1429 UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");
1430 UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");
1431 if (((Options >> 11) & 0x0001) != 0) {
1432 UefiDevicePathLibCatPrint (Str, L"%s,", L"None");
1433 } else if (((Options >> 12) & 0x0001) != 0) {
1434 UefiDevicePathLibCatPrint (Str, L"%s,", L"CHAP_UNI");
1435 } else {
1436 UefiDevicePathLibCatPrint (Str, L"%s,", L"CHAP_BI");
1437
1438 }
1439
1440 UefiDevicePathLibCatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");
1441 }
1442
1443 /**
1444 Converts a VLAN device path structure to its string representative.
1445
1446 @param Str The string representative of input device.
1447 @param DevPath The input device path structure.
1448 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1449 of the display node is used, where applicable. If DisplayOnly
1450 is FALSE, then the longer text representation of the display node
1451 is used.
1452 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1453 representation for a device node can be used, where applicable.
1454
1455 **/
1456 VOID
1457 DevPathToTextVlan (
1458 IN OUT POOL_PRINT *Str,
1459 IN VOID *DevPath,
1460 IN BOOLEAN DisplayOnly,
1461 IN BOOLEAN AllowShortcuts
1462 )
1463 {
1464 VLAN_DEVICE_PATH *Vlan;
1465
1466 Vlan = DevPath;
1467 UefiDevicePathLibCatPrint (Str, L"Vlan(%d)", Vlan->VlanId);
1468 }
1469
1470 /**
1471 Converts a Hard drive device path structure to its string representative.
1472
1473 @param Str The string representative of input device.
1474 @param DevPath The input device path structure.
1475 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1476 of the display node is used, where applicable. If DisplayOnly
1477 is FALSE, then the longer text representation of the display node
1478 is used.
1479 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1480 representation for a device node can be used, where applicable.
1481
1482 **/
1483 VOID
1484 DevPathToTextHardDrive (
1485 IN OUT POOL_PRINT *Str,
1486 IN VOID *DevPath,
1487 IN BOOLEAN DisplayOnly,
1488 IN BOOLEAN AllowShortcuts
1489 )
1490 {
1491 HARDDRIVE_DEVICE_PATH *Hd;
1492
1493 Hd = DevPath;
1494 switch (Hd->SignatureType) {
1495 case SIGNATURE_TYPE_MBR:
1496 UefiDevicePathLibCatPrint (
1497 Str,
1498 L"HD(%d,%s,0x%08x,",
1499 Hd->PartitionNumber,
1500 L"MBR",
1501 *((UINT32 *) (&(Hd->Signature[0])))
1502 );
1503 break;
1504
1505 case SIGNATURE_TYPE_GUID:
1506 UefiDevicePathLibCatPrint (
1507 Str,
1508 L"HD(%d,%s,%g,",
1509 Hd->PartitionNumber,
1510 L"GPT",
1511 (EFI_GUID *) &(Hd->Signature[0])
1512 );
1513 break;
1514
1515 default:
1516 UefiDevicePathLibCatPrint (
1517 Str,
1518 L"HD(%d,%d,0,",
1519 Hd->PartitionNumber,
1520 Hd->SignatureType
1521 );
1522 break;
1523 }
1524
1525 UefiDevicePathLibCatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);
1526 }
1527
1528 /**
1529 Converts a CDROM 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 DevPathToTextCDROM (
1543 IN OUT POOL_PRINT *Str,
1544 IN VOID *DevPath,
1545 IN BOOLEAN DisplayOnly,
1546 IN BOOLEAN AllowShortcuts
1547 )
1548 {
1549 CDROM_DEVICE_PATH *Cd;
1550
1551 Cd = DevPath;
1552 if (DisplayOnly) {
1553 UefiDevicePathLibCatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);
1554 return ;
1555 }
1556
1557 UefiDevicePathLibCatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);
1558 }
1559
1560 /**
1561 Converts a File device path structure to its string representative.
1562
1563 @param Str The string representative of input device.
1564 @param DevPath The input device path structure.
1565 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1566 of the display node is used, where applicable. If DisplayOnly
1567 is FALSE, then the longer text representation of the display node
1568 is used.
1569 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1570 representation for a device node can be used, where applicable.
1571
1572 **/
1573 VOID
1574 DevPathToTextFilePath (
1575 IN OUT POOL_PRINT *Str,
1576 IN VOID *DevPath,
1577 IN BOOLEAN DisplayOnly,
1578 IN BOOLEAN AllowShortcuts
1579 )
1580 {
1581 FILEPATH_DEVICE_PATH *Fp;
1582
1583 Fp = DevPath;
1584 UefiDevicePathLibCatPrint (Str, L"%s", Fp->PathName);
1585 }
1586
1587 /**
1588 Converts a Media protocol device path structure to its string representative.
1589
1590 @param Str The string representative of input device.
1591 @param DevPath The input device path structure.
1592 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1593 of the display node is used, where applicable. If DisplayOnly
1594 is FALSE, then the longer text representation of the display node
1595 is used.
1596 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1597 representation for a device node can be used, where applicable.
1598
1599 **/
1600 VOID
1601 DevPathToTextMediaProtocol (
1602 IN OUT POOL_PRINT *Str,
1603 IN VOID *DevPath,
1604 IN BOOLEAN DisplayOnly,
1605 IN BOOLEAN AllowShortcuts
1606 )
1607 {
1608 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;
1609
1610 MediaProt = DevPath;
1611 UefiDevicePathLibCatPrint (Str, L"Media(%g)", &MediaProt->Protocol);
1612 }
1613
1614 /**
1615 Converts a Firmware Volume device path structure to its string representative.
1616
1617 @param Str The string representative of input device.
1618 @param DevPath The input device path structure.
1619 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1620 of the display node is used, where applicable. If DisplayOnly
1621 is FALSE, then the longer text representation of the display node
1622 is used.
1623 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1624 representation for a device node can be used, where applicable.
1625
1626 **/
1627 VOID
1628 DevPathToTextFv (
1629 IN OUT POOL_PRINT *Str,
1630 IN VOID *DevPath,
1631 IN BOOLEAN DisplayOnly,
1632 IN BOOLEAN AllowShortcuts
1633 )
1634 {
1635 MEDIA_FW_VOL_DEVICE_PATH *Fv;
1636
1637 Fv = DevPath;
1638 UefiDevicePathLibCatPrint (Str, L"Fv(%g)", &Fv->FvName);
1639 }
1640
1641 /**
1642 Converts a Firmware Volume File device path structure to its string representative.
1643
1644 @param Str The string representative of input device.
1645 @param DevPath The input device path structure.
1646 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1647 of the display node is used, where applicable. If DisplayOnly
1648 is FALSE, then the longer text representation of the display node
1649 is used.
1650 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1651 representation for a device node can be used, where applicable.
1652
1653 **/
1654 VOID
1655 DevPathToTextFvFile (
1656 IN OUT POOL_PRINT *Str,
1657 IN VOID *DevPath,
1658 IN BOOLEAN DisplayOnly,
1659 IN BOOLEAN AllowShortcuts
1660 )
1661 {
1662 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;
1663
1664 FvFile = DevPath;
1665 UefiDevicePathLibCatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);
1666 }
1667
1668 /**
1669 Converts a Relative Offset device path structure to its string representative.
1670
1671 @param Str The string representative of input device.
1672 @param DevPath The input device path structure.
1673 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1674 of the display node is used, where applicable. If DisplayOnly
1675 is FALSE, then the longer text representation of the display node
1676 is used.
1677 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1678 representation for a device node can be used, where applicable.
1679
1680 **/
1681 VOID
1682 DevPathRelativeOffsetRange (
1683 IN OUT POOL_PRINT *Str,
1684 IN VOID *DevPath,
1685 IN BOOLEAN DisplayOnly,
1686 IN BOOLEAN AllowShortcuts
1687 )
1688 {
1689 MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;
1690
1691 Offset = DevPath;
1692 UefiDevicePathLibCatPrint (
1693 Str,
1694 L"Offset(0x%lx,0x%lx)",
1695 Offset->StartingOffset,
1696 Offset->EndingOffset
1697 );
1698 }
1699
1700 /**
1701 Converts a BIOS Boot Specification device path structure to its string representative.
1702
1703 @param Str The string representative of input device.
1704 @param DevPath The input device path structure.
1705 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1706 of the display node is used, where applicable. If DisplayOnly
1707 is FALSE, then the longer text representation of the display node
1708 is used.
1709 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1710 representation for a device node can be used, where applicable.
1711
1712 **/
1713 VOID
1714 DevPathToTextBBS (
1715 IN OUT POOL_PRINT *Str,
1716 IN VOID *DevPath,
1717 IN BOOLEAN DisplayOnly,
1718 IN BOOLEAN AllowShortcuts
1719 )
1720 {
1721 BBS_BBS_DEVICE_PATH *Bbs;
1722 CHAR16 *Type;
1723
1724 Bbs = DevPath;
1725 switch (Bbs->DeviceType) {
1726 case BBS_TYPE_FLOPPY:
1727 Type = L"Floppy";
1728 break;
1729
1730 case BBS_TYPE_HARDDRIVE:
1731 Type = L"HD";
1732 break;
1733
1734 case BBS_TYPE_CDROM:
1735 Type = L"CDROM";
1736 break;
1737
1738 case BBS_TYPE_PCMCIA:
1739 Type = L"PCMCIA";
1740 break;
1741
1742 case BBS_TYPE_USB:
1743 Type = L"USB";
1744 break;
1745
1746 case BBS_TYPE_EMBEDDED_NETWORK:
1747 Type = L"Network";
1748 break;
1749
1750 default:
1751 Type = NULL;
1752 break;
1753 }
1754
1755 if (Type != NULL) {
1756 UefiDevicePathLibCatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);
1757 } else {
1758 UefiDevicePathLibCatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String);
1759 }
1760
1761 if (DisplayOnly) {
1762 UefiDevicePathLibCatPrint (Str, L")");
1763 return ;
1764 }
1765
1766 UefiDevicePathLibCatPrint (Str, L",0x%x)", Bbs->StatusFlag);
1767 }
1768
1769 /**
1770 Converts an End-of-Device-Path structure to its string representative.
1771
1772 @param Str The string representative of input device.
1773 @param DevPath The input device path structure.
1774 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1775 of the display node is used, where applicable. If DisplayOnly
1776 is FALSE, then the longer text representation of the display node
1777 is used.
1778 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1779 representation for a device node can be used, where applicable.
1780
1781 **/
1782 VOID
1783 DevPathToTextEndInstance (
1784 IN OUT POOL_PRINT *Str,
1785 IN VOID *DevPath,
1786 IN BOOLEAN DisplayOnly,
1787 IN BOOLEAN AllowShortcuts
1788 )
1789 {
1790 UefiDevicePathLibCatPrint (Str, L",");
1791 }
1792
1793 GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_GENERIC_TABLE mUefiDevicePathLibToTextTableGeneric[] = {
1794 {HARDWARE_DEVICE_PATH, L"HardwarePath" },
1795 {ACPI_DEVICE_PATH, L"AcpiPath" },
1796 {MESSAGING_DEVICE_PATH, L"Msg" },
1797 {MEDIA_DEVICE_PATH, L"MediaPath" },
1798 {BBS_DEVICE_PATH, L"BbsPath" },
1799 {0, NULL}
1800 };
1801
1802 /**
1803 Converts an unknown device path structure to its string representative.
1804
1805 @param Str The string representative of input device.
1806 @param DevPath The input device path structure.
1807 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1808 of the display node is used, where applicable. If DisplayOnly
1809 is FALSE, then the longer text representation of the display node
1810 is used.
1811 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1812 representation for a device node can be used, where applicable.
1813
1814 **/
1815 VOID
1816 DevPathToTextNodeGeneric (
1817 IN OUT POOL_PRINT *Str,
1818 IN VOID *DevPath,
1819 IN BOOLEAN DisplayOnly,
1820 IN BOOLEAN AllowShortcuts
1821 )
1822 {
1823 EFI_DEVICE_PATH_PROTOCOL *Node;
1824 UINTN Index;
1825
1826 Node = DevPath;
1827
1828 for (Index = 0; mUefiDevicePathLibToTextTableGeneric[Index].Text != NULL; Index++) {
1829 if (DevicePathType (Node) == mUefiDevicePathLibToTextTableGeneric[Index].Type) {
1830 break;
1831 }
1832 }
1833
1834 if (mUefiDevicePathLibToTextTableGeneric[Index].Text == NULL) {
1835 //
1836 // It's a node whose type cannot be recognized
1837 //
1838 UefiDevicePathLibCatPrint (Str, L"Path(%d,%d", DevicePathType (Node), DevicePathSubType (Node));
1839 } else {
1840 //
1841 // It's a node whose type can be recognized
1842 //
1843 UefiDevicePathLibCatPrint (Str, L"%s(%d", mUefiDevicePathLibToTextTableGeneric[Index].Text, DevicePathSubType (Node));
1844 }
1845
1846 Index = sizeof (EFI_DEVICE_PATH_PROTOCOL);
1847 if (Index < DevicePathNodeLength (Node)) {
1848 UefiDevicePathLibCatPrint (Str, L",");
1849 for (; Index < DevicePathNodeLength (Node); Index++) {
1850 UefiDevicePathLibCatPrint (Str, L"%02x", ((UINT8 *) Node)[Index]);
1851 }
1852 }
1853
1854 UefiDevicePathLibCatPrint (Str, L")");
1855 }
1856
1857 GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = {
1858 {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci },
1859 {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard },
1860 {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap },
1861 {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor },
1862 {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController },
1863 {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi },
1864 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx },
1865 {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr },
1866 {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi },
1867 {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi },
1868 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre },
1869 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx },
1870 {MESSAGING_DEVICE_PATH, MSG_SASEX_DP, DevPathToTextSasEx },
1871 {MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP, DevPathToTextNVMe },
1872 {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394 },
1873 {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb },
1874 {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID },
1875 {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit },
1876 {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass },
1877 {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata },
1878 {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O },
1879 {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr },
1880 {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4 },
1881 {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6 },
1882 {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand },
1883 {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart },
1884 {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor },
1885 {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI },
1886 {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan },
1887 {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive },
1888 {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM },
1889 {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor },
1890 {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol },
1891 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath },
1892 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv },
1893 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile },
1894 {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange },
1895 {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS },
1896 {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance },
1897 {0, 0, NULL}
1898 };
1899
1900 /**
1901 Converts a device node to its string representation.
1902
1903 @param DeviceNode A Pointer to the device node to be converted.
1904 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1905 of the display node is used, where applicable. If DisplayOnly
1906 is FALSE, then the longer text representation of the display node
1907 is used.
1908 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1909 representation for a device node can be used, where applicable.
1910
1911 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode
1912 is NULL or there was insufficient memory.
1913
1914 **/
1915 CHAR16 *
1916 EFIAPI
1917 UefiDevicePathLibConvertDeviceNodeToText (
1918 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
1919 IN BOOLEAN DisplayOnly,
1920 IN BOOLEAN AllowShortcuts
1921 )
1922 {
1923 POOL_PRINT Str;
1924 UINTN Index;
1925 DEVICE_PATH_TO_TEXT ToText;
1926
1927 if (DeviceNode == NULL) {
1928 return NULL;
1929 }
1930
1931 ZeroMem (&Str, sizeof (Str));
1932
1933 //
1934 // Process the device path node
1935 // If not found, use a generic function
1936 //
1937 ToText = DevPathToTextNodeGeneric;
1938 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index++) {
1939 if (DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type &&
1940 DevicePathSubType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].SubType
1941 ) {
1942 ToText = mUefiDevicePathLibToTextTable[Index].Function;
1943 break;
1944 }
1945 }
1946
1947 //
1948 // Print this node
1949 //
1950 ToText (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);
1951
1952 ASSERT (Str.Str != NULL);
1953 return Str.Str;
1954 }
1955
1956 /**
1957 Converts a device path to its text representation.
1958
1959 @param DevicePath A Pointer to the device to be converted.
1960 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
1961 of the display node is used, where applicable. If DisplayOnly
1962 is FALSE, then the longer text representation of the display node
1963 is used.
1964 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
1965 representation for a device node can be used, where applicable.
1966
1967 @return A pointer to the allocated text representation of the device path or
1968 NULL if DeviceNode is NULL or there was insufficient memory.
1969
1970 **/
1971 CHAR16 *
1972 EFIAPI
1973 UefiDevicePathLibConvertDevicePathToText (
1974 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
1975 IN BOOLEAN DisplayOnly,
1976 IN BOOLEAN AllowShortcuts
1977 )
1978 {
1979 POOL_PRINT Str;
1980 EFI_DEVICE_PATH_PROTOCOL *Node;
1981 EFI_DEVICE_PATH_PROTOCOL *AlignedNode;
1982 UINTN Index;
1983 DEVICE_PATH_TO_TEXT ToText;
1984
1985 if (DevicePath == NULL) {
1986 return NULL;
1987 }
1988
1989 ZeroMem (&Str, sizeof (Str));
1990
1991 //
1992 // Process each device path node
1993 //
1994 Node = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;
1995 while (!IsDevicePathEnd (Node)) {
1996 //
1997 // Find the handler to dump this device path node
1998 // If not found, use a generic function
1999 //
2000 ToText = DevPathToTextNodeGeneric;
2001 for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index += 1) {
2002
2003 if (DevicePathType (Node) == mUefiDevicePathLibToTextTable[Index].Type &&
2004 DevicePathSubType (Node) == mUefiDevicePathLibToTextTable[Index].SubType
2005 ) {
2006 ToText = mUefiDevicePathLibToTextTable[Index].Function;
2007 break;
2008 }
2009 }
2010 //
2011 // Put a path separator in if needed
2012 //
2013 if ((Str.Count != 0) && (ToText != DevPathToTextEndInstance)) {
2014 if (Str.Str[Str.Count] != L',') {
2015 UefiDevicePathLibCatPrint (&Str, L"/");
2016 }
2017 }
2018
2019 AlignedNode = AllocateCopyPool (DevicePathNodeLength (Node), Node);
2020 //
2021 // Print this node of the device path
2022 //
2023 ToText (&Str, AlignedNode, DisplayOnly, AllowShortcuts);
2024 FreePool (AlignedNode);
2025
2026 //
2027 // Next device path node
2028 //
2029 Node = NextDevicePathNode (Node);
2030 }
2031
2032 if (Str.Str == NULL) {
2033 return AllocateZeroPool (sizeof (CHAR16));
2034 } else {
2035 return Str.Str;
2036 }
2037 }