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