VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c

Last change on this file was 108794, checked in by vboxsync, 3 weeks ago

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette