]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
UEFI HII: Merge UEFI HII support changes from branch.
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePathToText.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 DevicePathToText.c
15
16 Abstract:
17
18 DevicePathToText protocol as defined in the UEFI 2.0 specification.
19
20 --*/
21
22 #include "DevicePath.h"
23
24 STATIC
25 EFI_DEVICE_PATH_PROTOCOL *
26 UnpackDevicePath (
27 IN EFI_DEVICE_PATH_PROTOCOL *DevPath
28 )
29 /*++
30
31 Routine Description:
32 Function unpacks a device path data structure so that all the nodes of a device path
33 are naturally aligned.
34
35 Arguments:
36 DevPath - A pointer to a device path data structure
37
38 Returns:
39 If the memory for the device path is successfully allocated, then a pointer to the
40 new device path is returned. Otherwise, NULL is returned.
41
42 --*/
43 {
44 EFI_DEVICE_PATH_PROTOCOL *Src;
45 EFI_DEVICE_PATH_PROTOCOL *Dest;
46 EFI_DEVICE_PATH_PROTOCOL *NewPath;
47 UINTN Size;
48
49 if (DevPath == NULL) {
50 return NULL;
51 }
52 //
53 // Walk device path and round sizes to valid boundries
54 //
55 Src = DevPath;
56 Size = 0;
57 for (;;) {
58 Size += DevicePathNodeLength (Src);
59 Size += ALIGN_SIZE (Size);
60
61 if (IsDevicePathEnd (Src)) {
62 break;
63 }
64
65 Src = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (Src);
66 }
67 //
68 // Allocate space for the unpacked path
69 //
70 NewPath = AllocateZeroPool (Size);
71 if (NewPath != NULL) {
72
73 ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0);
74
75 //
76 // Copy each node
77 //
78 Src = DevPath;
79 Dest = NewPath;
80 for (;;) {
81 Size = DevicePathNodeLength (Src);
82 CopyMem (Dest, Src, Size);
83 Size += ALIGN_SIZE (Size);
84 SetDevicePathNodeLength (Dest, Size);
85 Dest->Type |= EFI_DP_TYPE_UNPACKED;
86 Dest = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) Dest) + Size);
87
88 if (IsDevicePathEnd (Src)) {
89 break;
90 }
91
92 Src = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (Src);
93 }
94 }
95
96 return NewPath;
97 }
98
99 STATIC
100 VOID *
101 ReallocatePool (
102 IN VOID *OldPool,
103 IN UINTN OldSize,
104 IN UINTN NewSize
105 )
106 /*++
107
108 Routine Description:
109 Adjusts the size of a previously allocated buffer.
110
111 Arguments:
112 OldPool - A pointer to the buffer whose size is being adjusted.
113 OldSize - The size of the current buffer.
114 NewSize - The size of the new buffer.
115
116 Returns:
117 EFI_SUCEESS - The requested number of bytes were allocated.
118 EFI_OUT_OF_RESOURCES - The pool requested could not be allocated.
119 EFI_INVALID_PARAMETER - The buffer was invalid.
120
121 --*/
122 {
123 VOID *NewPool;
124
125 NewPool = NULL;
126 if (NewSize) {
127 NewPool = AllocateZeroPool (NewSize);
128 }
129
130 if (OldPool) {
131 if (NewPool) {
132 CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);
133 }
134
135 FreePool (OldPool);
136 }
137
138 return NewPool;
139 }
140
141 STATIC
142 CHAR16 *
143 CatPrint (
144 IN OUT POOL_PRINT *Str,
145 IN CHAR16 *Fmt,
146 ...
147 )
148 /*++
149
150 Routine Description:
151 Concatenates a formatted unicode string to allocated pool.
152 The caller must free the resulting buffer.
153
154 Arguments:
155 Str - Tracks the allocated pool, size in use, and
156 amount of pool allocated.
157 Fmt - The format string
158
159 Returns:
160 Allocated buffer with the formatted string printed in it.
161 The caller must free the allocated buffer. The buffer
162 allocation is not packed.
163
164 --*/
165 {
166 UINT16 *AppendStr;
167 VA_LIST Args;
168 UINTN Size;
169
170 AppendStr = AllocateZeroPool (0x1000);
171 if (AppendStr == NULL) {
172 return Str->Str;
173 }
174
175 VA_START (Args, Fmt);
176 UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);
177 VA_END (Args);
178 if (NULL == Str->Str) {
179 Size = StrSize (AppendStr);
180 Str->Str = AllocateZeroPool (Size);
181 ASSERT (Str->Str != NULL);
182 } else {
183 Size = StrSize (AppendStr) - sizeof (UINT16);
184 Size = Size + StrSize (Str->Str);
185 Str->Str = ReallocatePool (
186 Str->Str,
187 StrSize (Str->Str),
188 Size
189 );
190 ASSERT (Str->Str != NULL);
191 }
192
193 Str->MaxLen = MAX_CHAR * sizeof (UINT16);
194 if (Size < Str->MaxLen) {
195 StrCat (Str->Str, AppendStr);
196 Str->Len = Size - sizeof (UINT16);
197 }
198
199 FreePool (AppendStr);
200 return Str->Str;
201 }
202
203 STATIC
204 VOID
205 DevPathToTextPci (
206 IN OUT POOL_PRINT *Str,
207 IN VOID *DevPath,
208 IN BOOLEAN DisplayOnly,
209 IN BOOLEAN AllowShortcuts
210 )
211 {
212 PCI_DEVICE_PATH *Pci;
213
214 Pci = DevPath;
215 CatPrint (Str, L"Pci(0x%x,0x%x)", Pci->Device, Pci->Function);
216 }
217
218 STATIC
219 VOID
220 DevPathToTextPccard (
221 IN OUT POOL_PRINT *Str,
222 IN VOID *DevPath,
223 IN BOOLEAN DisplayOnly,
224 IN BOOLEAN AllowShortcuts
225 )
226 {
227 PCCARD_DEVICE_PATH *Pccard;
228
229 Pccard = DevPath;
230 CatPrint (Str, L"PcCard(0x%x)", Pccard->FunctionNumber);
231 }
232
233 STATIC
234 VOID
235 DevPathToTextMemMap (
236 IN OUT POOL_PRINT *Str,
237 IN VOID *DevPath,
238 IN BOOLEAN DisplayOnly,
239 IN BOOLEAN AllowShortcuts
240 )
241 {
242 MEMMAP_DEVICE_PATH *MemMap;
243
244 MemMap = DevPath;
245 CatPrint (
246 Str,
247 L"MemoryMapped(0x%x,0x%lx,0x%lx)",
248 MemMap->MemoryType,
249 MemMap->StartingAddress,
250 MemMap->EndingAddress
251 );
252 }
253
254 STATIC
255 VOID
256 DevPathToTextVendor (
257 IN OUT POOL_PRINT *Str,
258 IN VOID *DevPath,
259 IN BOOLEAN DisplayOnly,
260 IN BOOLEAN AllowShortcuts
261 )
262 {
263 VENDOR_DEVICE_PATH *Vendor;
264 CHAR16 *Type;
265 UINTN Index;
266 UINTN DataLength;
267 UINT32 FlowControlMap;
268 UINT16 Info;
269
270 Vendor = (VENDOR_DEVICE_PATH *) DevPath;
271 switch (DevicePathType (&Vendor->Header)) {
272 case HARDWARE_DEVICE_PATH:
273 Type = L"Hw";
274 break;
275
276 case MESSAGING_DEVICE_PATH:
277 Type = L"Msg";
278 if (AllowShortcuts) {
279 if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {
280 CatPrint (Str, L"VenPcAnsi()");
281 return ;
282 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {
283 CatPrint (Str, L"VenVt100()");
284 return ;
285 } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {
286 CatPrint (Str, L"VenVt100Plus()");
287 return ;
288 } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {
289 CatPrint (Str, L"VenUft8()");
290 return ;
291 } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingUartFlowControlGuid)) {
292 FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);
293 switch (FlowControlMap & 0x00000003) {
294 case 0:
295 CatPrint (Str, L"UartFlowCtrl(%s)", L"None");
296 break;
297
298 case 1:
299 CatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware");
300 break;
301
302 case 2:
303 CatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff");
304 break;
305
306 default:
307 break;
308 }
309
310 return ;
311 } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingSASGuid)) {
312 CatPrint (
313 Str,
314 L"SAS(0x%lx,0x%lx,0x%x,",
315 ((SAS_DEVICE_PATH *) Vendor)->SasAddress,
316 ((SAS_DEVICE_PATH *) Vendor)->Lun,
317 ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort
318 );
319 Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);
320 if ((Info & 0x0f) == 0) {
321 CatPrint (Str, L"NoTopology,0,0,0,");
322 } else if (((Info & 0x0f) == 1) || ((Info & 0x0f) == 2)) {
323 CatPrint (
324 Str,
325 L"%s,%s,%s,",
326 (Info & (0x1 << 4)) ? L"SATA" : L"SAS",
327 (Info & (0x1 << 5)) ? L"External" : L"Internal",
328 (Info & (0x1 << 6)) ? L"Expanded" : L"Direct"
329 );
330 if ((Info & 0x0f) == 1) {
331 CatPrint (Str, L"0,");
332 } else {
333 CatPrint (Str, L"0x%x,", (Info >> 8) & 0xff);
334 }
335 } else {
336 CatPrint (Str, L"0,0,0,0,");
337 }
338
339 CatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);
340 return ;
341 } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {
342 CatPrint (Str, L"DebugPort()");
343 return ;
344 }
345 }
346 break;
347
348 case MEDIA_DEVICE_PATH:
349 Type = L"Media";
350 break;
351
352 default:
353 Type = L"?";
354 break;
355 }
356
357 DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);
358 CatPrint (Str, L"Ven%s(%g", Type, &Vendor->Guid);
359 if (DataLength != 0) {
360 CatPrint (Str, L",");
361 for (Index = 0; Index < DataLength; Index++) {
362 CatPrint (Str, L"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);
363 }
364 }
365
366 CatPrint (Str, L")");
367 }
368
369 STATIC
370 VOID
371 DevPathToTextController (
372 IN OUT POOL_PRINT *Str,
373 IN VOID *DevPath,
374 IN BOOLEAN DisplayOnly,
375 IN BOOLEAN AllowShortcuts
376 )
377 {
378 CONTROLLER_DEVICE_PATH *Controller;
379
380 Controller = DevPath;
381 CatPrint (
382 Str,
383 L"Ctrl(0x%x)",
384 Controller->ControllerNumber
385 );
386 }
387
388 STATIC
389 VOID
390 DevPathToTextAcpi (
391 IN OUT POOL_PRINT *Str,
392 IN VOID *DevPath,
393 IN BOOLEAN DisplayOnly,
394 IN BOOLEAN AllowShortcuts
395 )
396 {
397 ACPI_HID_DEVICE_PATH *Acpi;
398
399 Acpi = DevPath;
400 if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
401 switch (EISA_ID_TO_NUM (Acpi->HID)) {
402 case 0x0a03:
403 CatPrint (Str, L"PciRoot(0x%x)", Acpi->UID);
404 break;
405
406 case 0x0604:
407 CatPrint (Str, L"Floppy(0x%x)", Acpi->UID);
408 break;
409
410 case 0x0301:
411 CatPrint (Str, L"Keyboard(0x%x)", Acpi->UID);
412 break;
413
414 case 0x0501:
415 CatPrint (Str, L"Serial(0x%x)", Acpi->UID);
416 break;
417
418 case 0x0401:
419 CatPrint (Str, L"ParallelPort(0x%x)", Acpi->UID);
420 break;
421
422 default:
423 CatPrint (Str, L"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);
424 break;
425 }
426 } else {
427 CatPrint (Str, L"Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID);
428 }
429 }
430
431 STATIC
432 VOID
433 EisaIdToText (
434 IN UINT32 EisaId,
435 IN OUT CHAR16 *Text
436 )
437 {
438 CHAR16 PnpIdStr[17];
439
440 //
441 //UnicodeSPrint ("%X", 0x0a03) => "0000000000000A03"
442 //
443 UnicodeSPrint (PnpIdStr, 17 * 2, L"%X", EisaId >> 16);
444
445 UnicodeSPrint (
446 Text,
447 0,
448 L"%c%c%c%s",
449 '@' + ((EisaId >> 10) & 0x1f),
450 '@' + ((EisaId >> 5) & 0x1f),
451 '@' + ((EisaId >> 0) & 0x1f),
452 PnpIdStr + (16 - 4)
453 );
454 }
455
456 STATIC
457 VOID
458 DevPathToTextAcpiEx (
459 IN OUT POOL_PRINT *Str,
460 IN VOID *DevPath,
461 IN BOOLEAN DisplayOnly,
462 IN BOOLEAN AllowShortcuts
463 )
464 {
465 ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;
466 CHAR8 *HIDStr;
467 CHAR8 *UIDStr;
468 CHAR8 *CIDStr;
469 CHAR16 HIDText[11];
470 CHAR16 CIDText[11];
471
472 AcpiEx = DevPath;
473 HIDStr = (CHAR8 *) (((UINT8 *) AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
474 UIDStr = HIDStr + AsciiStrLen (HIDStr) + 1;
475 CIDStr = UIDStr + AsciiStrLen (UIDStr) + 1;
476
477 EisaIdToText (AcpiEx->HID, HIDText);
478 EisaIdToText (AcpiEx->CID, CIDText);
479
480 if ((*HIDStr == '\0') && (*CIDStr == '\0') && (AcpiEx->UID == 0)) {
481 //
482 // use AcpiExp()
483 //
484 CatPrint (
485 Str,
486 L"AcpiExp(%s,%s,%a)",
487 HIDText,
488 CIDText,
489 UIDStr
490 );
491 } else {
492 if (AllowShortcuts) {
493 //
494 // display only
495 //
496 if (AcpiEx->HID == 0) {
497 CatPrint (Str, L"AcpiEx(%a,", HIDStr);
498 } else {
499 CatPrint (Str, L"AcpiEx(%s,", HIDText);
500 }
501
502 if (AcpiEx->UID == 0) {
503 CatPrint (Str, L"%a,", UIDStr);
504 } else {
505 CatPrint (Str, L"0x%x,", AcpiEx->UID);
506 }
507
508 if (AcpiEx->CID == 0) {
509 CatPrint (Str, L"%a)", CIDStr);
510 } else {
511 CatPrint (Str, L"%s)", CIDText);
512 }
513 } else {
514 CatPrint (
515 Str,
516 L"AcpiEx(%s,%s,0x%x,%a,%a,%a)",
517 HIDText,
518 CIDText,
519 AcpiEx->UID,
520 HIDStr,
521 CIDStr,
522 UIDStr
523 );
524 }
525 }
526 }
527
528 STATIC
529 VOID
530 DevPathToTextAcpiAdr (
531 IN OUT POOL_PRINT *Str,
532 IN VOID *DevPath,
533 IN BOOLEAN DisplayOnly,
534 IN BOOLEAN AllowShortcuts
535 )
536 {
537 ACPI_ADR_DEVICE_PATH *AcpiAdr;
538 UINT16 Index;
539 UINT16 Length;
540 UINT16 AdditionalAdrCount;
541
542 AcpiAdr = DevPath;
543 Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);
544 AdditionalAdrCount = (UINT16) ((Length - 8) / 4);
545
546 CatPrint (Str, L"AcpiAdr(0x%x", AcpiAdr->ADR);
547 for (Index = 0; Index < AdditionalAdrCount; Index++) {
548 CatPrint (Str, L",0x%x", *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));
549 }
550 CatPrint (Str, L")");
551 }
552
553 STATIC
554 VOID
555 DevPathToTextAtapi (
556 IN OUT POOL_PRINT *Str,
557 IN VOID *DevPath,
558 IN BOOLEAN DisplayOnly,
559 IN BOOLEAN AllowShortcuts
560 )
561 {
562 ATAPI_DEVICE_PATH *Atapi;
563
564 Atapi = DevPath;
565
566 if (DisplayOnly) {
567 CatPrint (Str, L"Ata(0x%x)", Atapi->Lun);
568 } else {
569 CatPrint (
570 Str,
571 L"Ata(%s,%s,0x%x)",
572 Atapi->PrimarySecondary ? L"Secondary" : L"Primary",
573 Atapi->SlaveMaster ? L"Slave" : L"Master",
574 Atapi->Lun
575 );
576 }
577 }
578
579 STATIC
580 VOID
581 DevPathToTextScsi (
582 IN OUT POOL_PRINT *Str,
583 IN VOID *DevPath,
584 IN BOOLEAN DisplayOnly,
585 IN BOOLEAN AllowShortcuts
586 )
587 {
588 SCSI_DEVICE_PATH *Scsi;
589
590 Scsi = DevPath;
591 CatPrint (Str, L"Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun);
592 }
593
594 STATIC
595 VOID
596 DevPathToTextFibre (
597 IN OUT POOL_PRINT *Str,
598 IN VOID *DevPath,
599 IN BOOLEAN DisplayOnly,
600 IN BOOLEAN AllowShortcuts
601 )
602 {
603 FIBRECHANNEL_DEVICE_PATH *Fibre;
604
605 Fibre = DevPath;
606 CatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);
607 }
608
609 STATIC
610 VOID
611 DevPathToText1394 (
612 IN OUT POOL_PRINT *Str,
613 IN VOID *DevPath,
614 IN BOOLEAN DisplayOnly,
615 IN BOOLEAN AllowShortcuts
616 )
617 {
618 F1394_DEVICE_PATH *F1394;
619
620 F1394 = DevPath;
621 //
622 // Guid has format of IEEE-EUI64
623 //
624 CatPrint (Str, L"I1394(%016lx)", F1394->Guid);
625 }
626
627 STATIC
628 VOID
629 DevPathToTextUsb (
630 IN OUT POOL_PRINT *Str,
631 IN VOID *DevPath,
632 IN BOOLEAN DisplayOnly,
633 IN BOOLEAN AllowShortcuts
634 )
635 {
636 USB_DEVICE_PATH *Usb;
637
638 Usb = DevPath;
639 CatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);
640 }
641
642 STATIC
643 VOID
644 DevPathToTextUsbWWID (
645 IN OUT POOL_PRINT *Str,
646 IN VOID *DevPath,
647 IN BOOLEAN DisplayOnly,
648 IN BOOLEAN AllowShortcuts
649 )
650 {
651 USB_WWID_DEVICE_PATH *UsbWWId;
652 CHAR16 *SerialNumberStr;
653 CHAR16 *NewStr;
654 UINT16 Length;
655
656 UsbWWId = DevPath;
657
658 SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof (USB_WWID_DEVICE_PATH));
659 Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));
660 if (SerialNumberStr [Length - 1] != 0) {
661 //
662 // In case no NULL terminator in SerialNumber, create a new one with NULL terminator
663 //
664 NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);
665 NewStr [Length] = 0;
666 SerialNumberStr = NewStr;
667 }
668
669 CatPrint (
670 Str,
671 L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",
672 UsbWWId->VendorId,
673 UsbWWId->ProductId,
674 UsbWWId->InterfaceNumber,
675 SerialNumberStr
676 );
677 }
678
679 STATIC
680 VOID
681 DevPathToTextLogicalUnit (
682 IN OUT POOL_PRINT *Str,
683 IN VOID *DevPath,
684 IN BOOLEAN DisplayOnly,
685 IN BOOLEAN AllowShortcuts
686 )
687 {
688 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
689
690 LogicalUnit = DevPath;
691 CatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun);
692 }
693
694 STATIC
695 VOID
696 DevPathToTextUsbClass (
697 IN OUT POOL_PRINT *Str,
698 IN VOID *DevPath,
699 IN BOOLEAN DisplayOnly,
700 IN BOOLEAN AllowShortcuts
701 )
702 {
703 USB_CLASS_DEVICE_PATH *UsbClass;
704 BOOLEAN IsKnownSubClass;
705
706
707 UsbClass = DevPath;
708
709 IsKnownSubClass = TRUE;
710 switch (UsbClass->DeviceClass) {
711 case USB_CLASS_AUDIO:
712 CatPrint (Str, L"UsbAudio");
713 break;
714
715 case USB_CLASS_CDCCONTROL:
716 CatPrint (Str, L"UsbCDCControl");
717 break;
718
719 case USB_CLASS_HID:
720 CatPrint (Str, L"UsbHID");
721 break;
722
723 case USB_CLASS_IMAGE:
724 CatPrint (Str, L"UsbImage");
725 break;
726
727 case USB_CLASS_PRINTER:
728 CatPrint (Str, L"UsbPrinter");
729 break;
730
731 case USB_CLASS_MASS_STORAGE:
732 CatPrint (Str, L"UsbMassStorage");
733 break;
734
735 case USB_CLASS_HUB:
736 CatPrint (Str, L"UsbHub");
737 break;
738
739 case USB_CLASS_CDCDATA:
740 CatPrint (Str, L"UsbCDCData");
741 break;
742
743 case USB_CLASS_SMART_CARD:
744 CatPrint (Str, L"UsbSmartCard");
745 break;
746
747 case USB_CLASS_VIDEO:
748 CatPrint (Str, L"UsbVideo");
749 break;
750
751 case USB_CLASS_DIAGNOSTIC:
752 CatPrint (Str, L"UsbDiagnostic");
753 break;
754
755 case USB_CLASS_WIRELESS:
756 CatPrint (Str, L"UsbWireless");
757 break;
758
759 default:
760 IsKnownSubClass = FALSE;
761 break;
762 }
763
764 if (IsKnownSubClass) {
765 CatPrint (
766 Str,
767 L"(0x%x,0x%x,0x%x,0x%x)",
768 UsbClass->VendorId,
769 UsbClass->ProductId,
770 UsbClass->DeviceSubClass,
771 UsbClass->DeviceProtocol
772 );
773 return;
774 }
775
776 if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {
777 if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {
778 CatPrint (
779 Str,
780 L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",
781 UsbClass->VendorId,
782 UsbClass->ProductId,
783 UsbClass->DeviceProtocol
784 );
785 return;
786 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {
787 CatPrint (
788 Str,
789 L"UsbIrdaBridge(0x%x,0x%x,0x%x)",
790 UsbClass->VendorId,
791 UsbClass->ProductId,
792 UsbClass->DeviceProtocol
793 );
794 return;
795 } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {
796 CatPrint (
797 Str,
798 L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",
799 UsbClass->VendorId,
800 UsbClass->ProductId,
801 UsbClass->DeviceProtocol
802 );
803 return;
804 }
805 }
806
807 CatPrint (
808 Str,
809 L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",
810 UsbClass->VendorId,
811 UsbClass->ProductId,
812 UsbClass->DeviceClass,
813 UsbClass->DeviceSubClass,
814 UsbClass->DeviceProtocol
815 );
816 }
817
818 STATIC
819 VOID
820 DevPathToTextSata (
821 IN OUT POOL_PRINT *Str,
822 IN VOID *DevPath,
823 IN BOOLEAN DisplayOnly,
824 IN BOOLEAN AllowShortcuts
825 )
826 {
827 SATA_DEVICE_PATH *Sata;
828
829 Sata = DevPath;
830 CatPrint (
831 Str,
832 L"Sata(0x%x,0x%x,0x%x)",
833 (UINTN) Sata->HBAPortNumber,
834 (UINTN) Sata->PortMultiplierPortNumber,
835 (UINTN) Sata->Lun
836 );
837 }
838
839 STATIC
840 VOID
841 DevPathToTextI2O (
842 IN OUT POOL_PRINT *Str,
843 IN VOID *DevPath,
844 IN BOOLEAN DisplayOnly,
845 IN BOOLEAN AllowShortcuts
846 )
847 {
848 I2O_DEVICE_PATH *I2O;
849
850 I2O = DevPath;
851 CatPrint (Str, L"I2O(0x%x)", I2O->Tid);
852 }
853
854 STATIC
855 VOID
856 DevPathToTextMacAddr (
857 IN OUT POOL_PRINT *Str,
858 IN VOID *DevPath,
859 IN BOOLEAN DisplayOnly,
860 IN BOOLEAN AllowShortcuts
861 )
862 {
863 MAC_ADDR_DEVICE_PATH *MAC;
864 UINTN HwAddressSize;
865 UINTN Index;
866
867 MAC = DevPath;
868
869 HwAddressSize = sizeof (EFI_MAC_ADDRESS);
870 if (MAC->IfType == 0x01 || MAC->IfType == 0x00) {
871 HwAddressSize = 6;
872 }
873
874 CatPrint (Str, L"MAC(");
875
876 for (Index = 0; Index < HwAddressSize; Index++) {
877 CatPrint (Str, L"%02x", MAC->MacAddress.Addr[Index]);
878 }
879
880 CatPrint (Str, L",0x%x)", MAC->IfType);
881 }
882
883 STATIC
884 VOID
885 DevPathToTextIPv4 (
886 IN OUT POOL_PRINT *Str,
887 IN VOID *DevPath,
888 IN BOOLEAN DisplayOnly,
889 IN BOOLEAN AllowShortcuts
890 )
891 {
892 IPv4_DEVICE_PATH *IP;
893
894 IP = DevPath;
895 if (DisplayOnly == TRUE) {
896 CatPrint (
897 Str,
898 L"IPv4(%d.%d.%d.%d)",
899 IP->RemoteIpAddress.Addr[0],
900 IP->RemoteIpAddress.Addr[1],
901 IP->RemoteIpAddress.Addr[2],
902 IP->RemoteIpAddress.Addr[3]
903 );
904 return ;
905 }
906
907 CatPrint (
908 Str,
909 L"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)",
910 IP->RemoteIpAddress.Addr[0],
911 IP->RemoteIpAddress.Addr[1],
912 IP->RemoteIpAddress.Addr[2],
913 IP->RemoteIpAddress.Addr[3],
914 IP->Protocol ? L"TCP" : L"UDP",
915 (IP->StaticIpAddress == TRUE) ? L"Static" : L"DHCP",
916 IP->LocalIpAddress.Addr[0],
917 IP->LocalIpAddress.Addr[1],
918 IP->LocalIpAddress.Addr[2],
919 IP->LocalIpAddress.Addr[3]
920 );
921 }
922
923 STATIC
924 VOID
925 DevPathToTextIPv6 (
926 IN OUT POOL_PRINT *Str,
927 IN VOID *DevPath,
928 IN BOOLEAN DisplayOnly,
929 IN BOOLEAN AllowShortcuts
930 )
931 {
932 IPv6_DEVICE_PATH *IP;
933
934 IP = DevPath;
935 if (DisplayOnly == TRUE) {
936 CatPrint (
937 Str,
938 L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
939 IP->RemoteIpAddress.Addr[0],
940 IP->RemoteIpAddress.Addr[1],
941 IP->RemoteIpAddress.Addr[2],
942 IP->RemoteIpAddress.Addr[3],
943 IP->RemoteIpAddress.Addr[4],
944 IP->RemoteIpAddress.Addr[5],
945 IP->RemoteIpAddress.Addr[6],
946 IP->RemoteIpAddress.Addr[7],
947 IP->RemoteIpAddress.Addr[8],
948 IP->RemoteIpAddress.Addr[9],
949 IP->RemoteIpAddress.Addr[10],
950 IP->RemoteIpAddress.Addr[11],
951 IP->RemoteIpAddress.Addr[12],
952 IP->RemoteIpAddress.Addr[13],
953 IP->RemoteIpAddress.Addr[14],
954 IP->RemoteIpAddress.Addr[15]
955 );
956 return ;
957 }
958
959 CatPrint (
960 Str,
961 L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,%s,%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
962 IP->RemoteIpAddress.Addr[0],
963 IP->RemoteIpAddress.Addr[1],
964 IP->RemoteIpAddress.Addr[2],
965 IP->RemoteIpAddress.Addr[3],
966 IP->RemoteIpAddress.Addr[4],
967 IP->RemoteIpAddress.Addr[5],
968 IP->RemoteIpAddress.Addr[6],
969 IP->RemoteIpAddress.Addr[7],
970 IP->RemoteIpAddress.Addr[8],
971 IP->RemoteIpAddress.Addr[9],
972 IP->RemoteIpAddress.Addr[10],
973 IP->RemoteIpAddress.Addr[11],
974 IP->RemoteIpAddress.Addr[12],
975 IP->RemoteIpAddress.Addr[13],
976 IP->RemoteIpAddress.Addr[14],
977 IP->RemoteIpAddress.Addr[15],
978 IP->Protocol ? L"TCP" : L"UDP",
979 (IP->StaticIpAddress == TRUE) ? L"Static" : L"DHCP",
980 IP->LocalIpAddress.Addr[0],
981 IP->LocalIpAddress.Addr[1],
982 IP->LocalIpAddress.Addr[2],
983 IP->LocalIpAddress.Addr[3],
984 IP->LocalIpAddress.Addr[4],
985 IP->LocalIpAddress.Addr[5],
986 IP->LocalIpAddress.Addr[6],
987 IP->LocalIpAddress.Addr[7],
988 IP->LocalIpAddress.Addr[8],
989 IP->LocalIpAddress.Addr[9],
990 IP->LocalIpAddress.Addr[10],
991 IP->LocalIpAddress.Addr[11],
992 IP->LocalIpAddress.Addr[12],
993 IP->LocalIpAddress.Addr[13],
994 IP->LocalIpAddress.Addr[14],
995 IP->LocalIpAddress.Addr[15]
996 );
997 }
998
999 STATIC
1000 VOID
1001 DevPathToTextInfiniBand (
1002 IN OUT POOL_PRINT *Str,
1003 IN VOID *DevPath,
1004 IN BOOLEAN DisplayOnly,
1005 IN BOOLEAN AllowShortcuts
1006 )
1007 {
1008 INFINIBAND_DEVICE_PATH *InfiniBand;
1009
1010 InfiniBand = DevPath;
1011 CatPrint (
1012 Str,
1013 L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",
1014 InfiniBand->ResourceFlags,
1015 InfiniBand->PortGid,
1016 InfiniBand->ServiceId,
1017 InfiniBand->TargetPortId,
1018 InfiniBand->DeviceId
1019 );
1020 }
1021
1022 STATIC
1023 VOID
1024 DevPathToTextUart (
1025 IN OUT POOL_PRINT *Str,
1026 IN VOID *DevPath,
1027 IN BOOLEAN DisplayOnly,
1028 IN BOOLEAN AllowShortcuts
1029 )
1030 {
1031 UART_DEVICE_PATH *Uart;
1032 CHAR8 Parity;
1033
1034 Uart = DevPath;
1035 switch (Uart->Parity) {
1036 case 0:
1037 Parity = 'D';
1038 break;
1039
1040 case 1:
1041 Parity = 'N';
1042 break;
1043
1044 case 2:
1045 Parity = 'E';
1046 break;
1047
1048 case 3:
1049 Parity = 'O';
1050 break;
1051
1052 case 4:
1053 Parity = 'M';
1054 break;
1055
1056 case 5:
1057 Parity = 'S';
1058 break;
1059
1060 default:
1061 Parity = 'x';
1062 break;
1063 }
1064
1065 if (Uart->BaudRate == 0) {
1066 CatPrint (Str, L"Uart(DEFAULT,");
1067 } else {
1068 CatPrint (Str, L"Uart(%ld,", Uart->BaudRate);
1069 }
1070
1071 if (Uart->DataBits == 0) {
1072 CatPrint (Str, L"DEFAULT,");
1073 } else {
1074 CatPrint (Str, L"%d,", Uart->DataBits);
1075 }
1076
1077 CatPrint (Str, L"%c,", Parity);
1078
1079 switch (Uart->StopBits) {
1080 case 0:
1081 CatPrint (Str, L"D)");
1082 break;
1083
1084 case 1:
1085 CatPrint (Str, L"1)");
1086 break;
1087
1088 case 2:
1089 CatPrint (Str, L"1.5)");
1090 break;
1091
1092 case 3:
1093 CatPrint (Str, L"2)");
1094 break;
1095
1096 default:
1097 CatPrint (Str, L"x)");
1098 break;
1099 }
1100 }
1101
1102 STATIC
1103 VOID
1104 DevPathToTextiSCSI (
1105 IN OUT POOL_PRINT *Str,
1106 IN VOID *DevPath,
1107 IN BOOLEAN DisplayOnly,
1108 IN BOOLEAN AllowShortcuts
1109 )
1110 {
1111 ISCSI_DEVICE_PATH_WITH_NAME *iSCSI;
1112 UINT16 Options;
1113
1114 iSCSI = DevPath;
1115 CatPrint (
1116 Str,
1117 L"iSCSI(%a,0x%x,0x%lx,",
1118 iSCSI->iSCSITargetName,
1119 iSCSI->TargetPortalGroupTag,
1120 iSCSI->Lun
1121 );
1122
1123 Options = iSCSI->LoginOption;
1124 CatPrint (Str, L"%s,", ((Options >> 1) & 0x0001) ? L"CRC32C" : L"None");
1125 CatPrint (Str, L"%s,", ((Options >> 3) & 0x0001) ? L"CRC32C" : L"None");
1126 if ((Options >> 11) & 0x0001) {
1127 CatPrint (Str, L"%s,", L"None");
1128 } else if ((Options >> 12) & 0x0001) {
1129 CatPrint (Str, L"%s,", L"CHAP_UNI");
1130 } else {
1131 CatPrint (Str, L"%s,", L"CHAP_BI");
1132
1133 }
1134
1135 CatPrint (Str, L"%s)", (iSCSI->NetworkProtocol == 0) ? L"TCP" : L"reserved");
1136 }
1137
1138 STATIC
1139 VOID
1140 DevPathToTextHardDrive (
1141 IN OUT POOL_PRINT *Str,
1142 IN VOID *DevPath,
1143 IN BOOLEAN DisplayOnly,
1144 IN BOOLEAN AllowShortcuts
1145 )
1146 {
1147 HARDDRIVE_DEVICE_PATH *Hd;
1148
1149 Hd = DevPath;
1150 switch (Hd->SignatureType) {
1151 case SIGNATURE_TYPE_MBR:
1152 CatPrint (
1153 Str,
1154 L"HD(%d,%s,0x%08x,",
1155 Hd->PartitionNumber,
1156 L"MBR",
1157 *((UINT32 *) (&(Hd->Signature[0])))
1158 );
1159 break;
1160
1161 case SIGNATURE_TYPE_GUID:
1162 CatPrint (
1163 Str,
1164 L"HD(%d,%s,%g,",
1165 Hd->PartitionNumber,
1166 L"GPT",
1167 (EFI_GUID *) &(Hd->Signature[0])
1168 );
1169 break;
1170
1171 default:
1172 CatPrint (
1173 Str,
1174 L"HD(%d,%d,0,",
1175 Hd->PartitionNumber,
1176 Hd->SignatureType
1177 );
1178 break;
1179 }
1180
1181 CatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);
1182 }
1183
1184 STATIC
1185 VOID
1186 DevPathToTextCDROM (
1187 IN OUT POOL_PRINT *Str,
1188 IN VOID *DevPath,
1189 IN BOOLEAN DisplayOnly,
1190 IN BOOLEAN AllowShortcuts
1191 )
1192 {
1193 CDROM_DEVICE_PATH *Cd;
1194
1195 Cd = DevPath;
1196 if (DisplayOnly == TRUE) {
1197 CatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);
1198 return ;
1199 }
1200
1201 CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);
1202 }
1203
1204 STATIC
1205 VOID
1206 DevPathToTextFilePath (
1207 IN OUT POOL_PRINT *Str,
1208 IN VOID *DevPath,
1209 IN BOOLEAN DisplayOnly,
1210 IN BOOLEAN AllowShortcuts
1211 )
1212 {
1213 FILEPATH_DEVICE_PATH *Fp;
1214
1215 Fp = DevPath;
1216 CatPrint (Str, L"%s", Fp->PathName);
1217 }
1218
1219 STATIC
1220 VOID
1221 DevPathToTextMediaProtocol (
1222 IN OUT POOL_PRINT *Str,
1223 IN VOID *DevPath,
1224 IN BOOLEAN DisplayOnly,
1225 IN BOOLEAN AllowShortcuts
1226 )
1227 {
1228 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;
1229
1230 MediaProt = DevPath;
1231 CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);
1232 }
1233
1234 STATIC
1235 VOID
1236 DevPathToTextFv (
1237 IN OUT POOL_PRINT *Str,
1238 IN VOID *DevPath,
1239 IN BOOLEAN DisplayOnly,
1240 IN BOOLEAN AllowShortcuts
1241 )
1242 {
1243 MEDIA_FW_VOL_DEVICE_PATH *Fv;
1244
1245 Fv = DevPath;
1246 CatPrint (Str, L"Fv(%g)", &Fv->FvName);
1247 }
1248
1249 STATIC
1250 VOID
1251 DevPathToTextFvFile (
1252 IN OUT POOL_PRINT *Str,
1253 IN VOID *DevPath,
1254 IN BOOLEAN DisplayOnly,
1255 IN BOOLEAN AllowShortcuts
1256 )
1257 {
1258 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;
1259
1260 FvFile = DevPath;
1261 CatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);
1262 }
1263
1264 STATIC
1265 VOID
1266 DevPathToTextBBS (
1267 IN OUT POOL_PRINT *Str,
1268 IN VOID *DevPath,
1269 IN BOOLEAN DisplayOnly,
1270 IN BOOLEAN AllowShortcuts
1271 )
1272 {
1273 BBS_BBS_DEVICE_PATH *Bbs;
1274 CHAR16 *Type;
1275
1276 Bbs = DevPath;
1277 switch (Bbs->DeviceType) {
1278 case BBS_TYPE_FLOPPY:
1279 Type = L"Floppy";
1280 break;
1281
1282 case BBS_TYPE_HARDDRIVE:
1283 Type = L"HD";
1284 break;
1285
1286 case BBS_TYPE_CDROM:
1287 Type = L"CDROM";
1288 break;
1289
1290 case BBS_TYPE_PCMCIA:
1291 Type = L"PCMCIA";
1292 break;
1293
1294 case BBS_TYPE_USB:
1295 Type = L"USB";
1296 break;
1297
1298 case BBS_TYPE_EMBEDDED_NETWORK:
1299 Type = L"Network";
1300 break;
1301
1302 default:
1303 Type = NULL;
1304 break;
1305 }
1306
1307 if (Type != NULL) {
1308 CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);
1309 } else {
1310 CatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String);
1311 }
1312
1313 if (DisplayOnly == TRUE) {
1314 CatPrint (Str, L")");
1315 return ;
1316 }
1317
1318 CatPrint (Str, L",0x%x)", Bbs->StatusFlag);
1319 }
1320
1321 STATIC
1322 VOID
1323 DevPathToTextEndInstance (
1324 IN OUT POOL_PRINT *Str,
1325 IN VOID *DevPath,
1326 IN BOOLEAN DisplayOnly,
1327 IN BOOLEAN AllowShortcuts
1328 )
1329 {
1330 CatPrint (Str, L",");
1331 }
1332
1333 STATIC
1334 VOID
1335 DevPathToTextNodeUnknown (
1336 IN OUT POOL_PRINT *Str,
1337 IN VOID *DevPath,
1338 IN BOOLEAN DisplayOnly,
1339 IN BOOLEAN AllowShortcuts
1340 )
1341 {
1342 CatPrint (Str, L"?");
1343 }
1344
1345 GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable[] = {
1346 {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci},
1347 {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard},
1348 {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap},
1349 {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor},
1350 {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController},
1351 {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi},
1352 {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx},
1353 {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr},
1354 {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi},
1355 {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi},
1356 {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre},
1357 {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394},
1358 {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb},
1359 {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID},
1360 {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit},
1361 {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass},
1362 {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata},
1363 {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O},
1364 {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr},
1365 {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4},
1366 {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6},
1367 {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand},
1368 {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart},
1369 {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor},
1370 {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI},
1371 {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive},
1372 {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM},
1373 {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor},
1374 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},
1375 {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol},
1376 {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},
1377 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv},
1378 {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile},
1379 {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS},
1380 {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance},
1381 {0, 0, NULL}
1382 };
1383
1384 CHAR16 *
1385 ConvertDeviceNodeToText (
1386 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
1387 IN BOOLEAN DisplayOnly,
1388 IN BOOLEAN AllowShortcuts
1389 )
1390 /*++
1391
1392 Routine Description:
1393 Convert a device node to its text representation.
1394
1395 Arguments:
1396 DeviceNode - Points to the device node to be converted.
1397 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
1398 of the display node is used, where applicable. If DisplayOnly
1399 is FALSE, then the longer text representation of the display node
1400 is used.
1401 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
1402 representation for a device node can be used, where applicable.
1403
1404 Returns:
1405 A pointer - a pointer to the allocated text representation of the device node.
1406 NULL - if DeviceNode is NULL or there was insufficient memory.
1407
1408 --*/
1409 {
1410 POOL_PRINT Str;
1411 UINTN Index;
1412 UINTN NewSize;
1413 VOID (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);
1414
1415 if (DeviceNode == NULL) {
1416 return NULL;
1417 }
1418
1419 ZeroMem (&Str, sizeof (Str));
1420
1421 //
1422 // Process the device path node
1423 //
1424 DumpNode = NULL;
1425 for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index++) {
1426 if (DevicePathType (DeviceNode) == DevPathToTextTable[Index].Type &&
1427 DevicePathSubType (DeviceNode) == DevPathToTextTable[Index].SubType
1428 ) {
1429 DumpNode = DevPathToTextTable[Index].Function;
1430 break;
1431 }
1432 }
1433 //
1434 // If not found, use a generic function
1435 //
1436 if (DumpNode == NULL) {
1437 DumpNode = DevPathToTextNodeUnknown;
1438 }
1439
1440 //
1441 // Print this node
1442 //
1443 DumpNode (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);
1444
1445 //
1446 // Shrink pool used for string allocation
1447 //
1448 NewSize = (Str.Len + 1) * sizeof (CHAR16);
1449 Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);
1450 ASSERT (Str.Str != NULL);
1451 Str.Str[Str.Len] = 0;
1452 return Str.Str;
1453 }
1454
1455 CHAR16 *
1456 ConvertDevicePathToText (
1457 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
1458 IN BOOLEAN DisplayOnly,
1459 IN BOOLEAN AllowShortcuts
1460 )
1461 /*++
1462
1463 Routine Description:
1464 Convert a device path to its text representation.
1465
1466 Arguments:
1467 DeviceNode - Points to the device path to be converted.
1468 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
1469 of the display node is used, where applicable. If DisplayOnly
1470 is FALSE, then the longer text representation of the display node
1471 is used.
1472 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
1473 representation for a device node can be used, where applicable.
1474
1475 Returns:
1476 A pointer - a pointer to the allocated text representation of the device path.
1477 NULL - if DeviceNode is NULL or there was insufficient memory.
1478
1479 --*/
1480 {
1481 POOL_PRINT Str;
1482 EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
1483 EFI_DEVICE_PATH_PROTOCOL *UnpackDevPath;
1484 UINTN Index;
1485 UINTN NewSize;
1486 VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);
1487
1488 if (DevicePath == NULL) {
1489 return NULL;
1490 }
1491
1492 ZeroMem (&Str, sizeof (Str));
1493
1494 //
1495 // Unpacked the device path
1496 //
1497 UnpackDevPath = UnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) DevicePath);
1498 ASSERT (UnpackDevPath != NULL);
1499
1500 //
1501 // Process each device path node
1502 //
1503 DevPathNode = UnpackDevPath;
1504 while (!IsDevicePathEnd (DevPathNode)) {
1505 //
1506 // Find the handler to dump this device path node
1507 //
1508 DumpNode = NULL;
1509 for (Index = 0; DevPathToTextTable[Index].Function; Index += 1) {
1510
1511 if (DevicePathType (DevPathNode) == DevPathToTextTable[Index].Type &&
1512 DevicePathSubType (DevPathNode) == DevPathToTextTable[Index].SubType
1513 ) {
1514 DumpNode = DevPathToTextTable[Index].Function;
1515 break;
1516 }
1517 }
1518 //
1519 // If not found, use a generic function
1520 //
1521 if (!DumpNode) {
1522 DumpNode = DevPathToTextNodeUnknown;
1523 }
1524 //
1525 // Put a path seperator in if needed
1526 //
1527 if (Str.Len && DumpNode != DevPathToTextEndInstance) {
1528 if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') {
1529 CatPrint (&Str, L"/");
1530 }
1531 }
1532 //
1533 // Print this node of the device path
1534 //
1535 DumpNode (&Str, DevPathNode, DisplayOnly, AllowShortcuts);
1536
1537 //
1538 // Next device path node
1539 //
1540 DevPathNode = NextDevicePathNode (DevPathNode);
1541 }
1542 //
1543 // Shrink pool used for string allocation
1544 //
1545 FreePool (UnpackDevPath);
1546
1547 NewSize = (Str.Len + 1) * sizeof (CHAR16);
1548 Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);
1549 ASSERT (Str.Str != NULL);
1550 Str.Str[Str.Len] = 0;
1551 return Str.Str;
1552 }