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