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