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