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