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