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