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