]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/GenericBdsLib/DevicePath.c
Synchronize GenericBdsLib library class's header file to library instance.
[mirror_edk2.git] / MdeModulePkg / Library / GenericBdsLib / DevicePath.c
CommitLineData
897f0eee 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
897f0eee 18/**\r
19 Concatenates a formatted unicode string to allocated pool.\r
20 The caller must free the resulting buffer.\r
21\r
262b0668 22 @param Str Tracks the allocated pool, size in use, and amount of pool allocated.\r
897f0eee 23 @param fmt The format string\r
262b0668 24 @param ... The data will be printed.\r
11ef23f9 25\r
897f0eee 26 @return Allocated buffer with the formatted string printed in it.\r
262b0668 27 The caller must free the allocated buffer.\r
28 The buffer allocation is not packed.\r
897f0eee 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
11ef23f9 40 VA_LIST Args;\r
41 UINTN StringSize;\r
897f0eee 42\r
43 AppendStr = AllocateZeroPool (0x1000);\r
44 if (AppendStr == NULL) {\r
45 return Str->str;\r
46 }\r
47\r
11ef23f9 48 VA_START (Args, fmt);\r
49 UnicodeVSPrint (AppendStr, 0x1000, fmt, Args);\r
50 VA_END (Args);\r
897f0eee 51 if (NULL == Str->str) {\r
11ef23f9 52 StringSize = StrSize (AppendStr);\r
53 Str->str = AllocateZeroPool (StringSize);\r
897f0eee 54 ASSERT (Str->str != NULL);\r
55 } else {\r
11ef23f9 56 StringSize = StrSize (AppendStr);\r
57 StringSize += (StrSize (Str->str) - sizeof (UINT16));\r
897f0eee 58\r
59 Str->str = ReallocatePool (\r
897f0eee 60 StrSize (Str->str),\r
d7774861 61 StringSize,\r
62 Str->str\r
897f0eee 63 );\r
64 ASSERT (Str->str != NULL);\r
65 }\r
66\r
67 Str->maxlen = MAX_CHAR * sizeof (UINT16);\r
11ef23f9 68 if (StringSize < Str->maxlen) {\r
897f0eee 69 StrCat (Str->str, AppendStr);\r
11ef23f9 70 Str->len = StringSize - sizeof (UINT16);\r
897f0eee 71 }\r
72\r
676df92c 73 FreePool (AppendStr);\r
897f0eee 74 return Str->str;\r
75}\r
76\r
11ef23f9 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
897f0eee 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
11ef23f9 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
897f0eee 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
11ef23f9 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
897f0eee 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
143 MemMap->MemoryType,\r
144 MemMap->StartingAddress,\r
145 MemMap->EndingAddress\r
146 );\r
147}\r
148\r
11ef23f9 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
897f0eee 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
262b0668 173 Convert Vendor device path to device name.\r
897f0eee 174\r
262b0668 175 @param Str The buffer store device name\r
176 @param DevPath Pointer to vendor device path\r
897f0eee 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
897f0eee 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
ec8cd35c 215 } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid )) {\r
897f0eee 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
ec8cd35c 236 } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {\r
897f0eee 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
242 ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
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
11ef23f9 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
897f0eee 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
11ef23f9 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
897f0eee 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
11ef23f9 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
897f0eee 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
ec8cd35c 336 \r
897f0eee 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
348 ASSERT (Str != NULL);\r
349 ASSERT (DevPath != NULL);\r
350\r
351 HIDSTRIdx = 0;\r
352 UIDSTRIdx = 0;\r
353 CIDSTRIdx = 0;\r
354 ExtendedAcpi = DevPath;\r
355 Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) ExtendedAcpi);\r
356\r
357 ASSERT (Length >= 19);\r
358 AsChar8Array = (CHAR8 *) ExtendedAcpi;\r
359\r
360 //\r
361 // find HIDSTR\r
362 //\r
363 Anchor = 16;\r
11ef23f9 364 for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {\r
897f0eee 365 ;\r
366 }\r
367 if (Index > Anchor) {\r
368 HIDSTRIdx = Anchor;\r
369 }\r
370 //\r
371 // find UIDSTR\r
372 //\r
373 Anchor = (UINT16) (Index + 1);\r
11ef23f9 374 for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {\r
897f0eee 375 ;\r
376 }\r
377 if (Index > Anchor) {\r
378 UIDSTRIdx = Anchor;\r
379 }\r
380 //\r
381 // find CIDSTR\r
382 //\r
383 Anchor = (UINT16) (Index + 1);\r
11ef23f9 384 for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {\r
897f0eee 385 ;\r
386 }\r
387 if (Index > Anchor) {\r
388 CIDSTRIdx = Anchor;\r
389 }\r
390\r
391 if (HIDSTRIdx == 0 && CIDSTRIdx == 0 && ExtendedAcpi->UID == 0) {\r
392 CatPrint (Str, L"AcpiExp(");\r
393 if ((ExtendedAcpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
394 CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->HID));\r
395 } else {\r
396 CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->HID);\r
397 }\r
398 if ((ExtendedAcpi->CID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
399 CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->CID));\r
400 } else {\r
401 CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->CID);\r
402 }\r
403 if (UIDSTRIdx != 0) {\r
404 CatPrint (Str, L"%a)", AsChar8Array + UIDSTRIdx);\r
405 } else {\r
406 CatPrint (Str, L"\"\")");\r
407 }\r
408 } else {\r
409 CatPrint (Str, L"AcpiEx(");\r
410 if ((ExtendedAcpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
411 CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->HID));\r
412 } else {\r
413 CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->HID);\r
414 }\r
415 if ((ExtendedAcpi->CID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
416 CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->CID));\r
417 } else {\r
418 CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->CID);\r
419 }\r
420 CatPrint (Str, L"%x,", (UINTN) ExtendedAcpi->UID);\r
421\r
422 if (HIDSTRIdx != 0) {\r
423 CatPrint (Str, L"%a,", AsChar8Array + HIDSTRIdx);\r
424 } else {\r
425 CatPrint (Str, L"\"\",");\r
426 }\r
427 if (CIDSTRIdx != 0) {\r
428 CatPrint (Str, L"%a,", AsChar8Array + CIDSTRIdx);\r
429 } else {\r
430 CatPrint (Str, L"\"\",");\r
431 }\r
432 if (UIDSTRIdx != 0) {\r
433 CatPrint (Str, L"%a)", AsChar8Array + UIDSTRIdx);\r
434 } else {\r
435 CatPrint (Str, L"\"\")");\r
436 }\r
437 }\r
438\r
439}\r
440\r
11ef23f9 441/**\r
442 Convert Device Path to a Unicode string for printing.\r
443\r
444 @param Str The buffer holding the output string.\r
445 This buffer contains the length of the\r
446 string and the maixmum length reserved\r
447 for the string buffer.\r
448 @param DevPath The device path.\r
449\r
450**/\r
897f0eee 451VOID\r
452DevPathAdrAcpi (\r
453 IN OUT POOL_PRINT *Str,\r
454 IN VOID *DevPath\r
455 )\r
456{\r
457 ACPI_ADR_DEVICE_PATH *AcpiAdr;\r
458 UINT16 Index;\r
459 UINT16 Length;\r
460 UINT16 AdditionalAdrCount;\r
461\r
462 AcpiAdr = DevPath;\r
463 Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);\r
464 AdditionalAdrCount = (UINT16) ((Length - 8) / 4);\r
465\r
466 CatPrint (Str, L"AcpiAdr(%x", (UINTN) AcpiAdr->ADR);\r
467 for (Index = 0; Index < AdditionalAdrCount; Index++) {\r
468 CatPrint (Str, L",%x", (UINTN) *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r
469 }\r
470 CatPrint (Str, L")");\r
471}\r
472\r
11ef23f9 473/**\r
474 Convert Device Path to a Unicode string for printing.\r
475\r
476 @param Str The buffer holding the output string.\r
477 This buffer contains the length of the\r
478 string and the maixmum length reserved\r
479 for the string buffer.\r
480 @param DevPath The device path.\r
481\r
482**/\r
897f0eee 483VOID\r
484DevPathAtapi (\r
485 IN OUT POOL_PRINT *Str,\r
486 IN VOID *DevPath\r
487 )\r
488{\r
489 ATAPI_DEVICE_PATH *Atapi;\r
490\r
491 Atapi = DevPath;\r
492 CatPrint (\r
493 Str,\r
494 L"Ata(%s,%s)",\r
495 Atapi->PrimarySecondary ? L"Secondary" : L"Primary",\r
496 Atapi->SlaveMaster ? L"Slave" : L"Master"\r
497 );\r
498}\r
499\r
11ef23f9 500/**\r
501 Convert Device Path to a Unicode string for printing.\r
502\r
503 @param Str The buffer holding the output string.\r
504 This buffer contains the length of the\r
505 string and the maixmum length reserved\r
506 for the string buffer.\r
507 @param DevPath The device path.\r
508\r
509**/\r
897f0eee 510VOID\r
511DevPathScsi (\r
512 IN OUT POOL_PRINT *Str,\r
513 IN VOID *DevPath\r
514 )\r
515{\r
516 SCSI_DEVICE_PATH *Scsi;\r
517\r
518 Scsi = DevPath;\r
519 CatPrint (Str, L"Scsi(Pun%x,Lun%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun);\r
520}\r
521\r
11ef23f9 522/**\r
523 Convert Device Path to a Unicode string for printing.\r
524\r
525 @param Str The buffer holding the output string.\r
526 This buffer contains the length of the\r
527 string and the maixmum length reserved\r
528 for the string buffer.\r
529 @param DevPath The device path.\r
530\r
531**/\r
897f0eee 532VOID\r
533DevPathFibre (\r
534 IN OUT POOL_PRINT *Str,\r
535 IN VOID *DevPath\r
536 )\r
537{\r
538 FIBRECHANNEL_DEVICE_PATH *Fibre;\r
539\r
540 Fibre = DevPath;\r
541 CatPrint (Str, L"Fibre(Wwn%lx,Lun%x)", Fibre->WWN, Fibre->Lun);\r
542}\r
543\r
11ef23f9 544/**\r
545 Convert Device Path to a Unicode string for printing.\r
546\r
547 @param Str The buffer holding the output string.\r
548 This buffer contains the length of the\r
549 string and the maixmum length reserved\r
550 for the string buffer.\r
551 @param DevPath The device path.\r
552\r
553**/\r
897f0eee 554VOID\r
555DevPath1394 (\r
556 IN OUT POOL_PRINT *Str,\r
557 IN VOID *DevPath\r
558 )\r
559{\r
11ef23f9 560 F1394_DEVICE_PATH *F1394Path;\r
897f0eee 561\r
11ef23f9 562 F1394Path = DevPath;\r
563 CatPrint (Str, L"1394(%g)", &F1394Path->Guid);\r
897f0eee 564}\r
565\r
11ef23f9 566/**\r
567 Convert Device Path to a Unicode string for printing.\r
568\r
569 @param Str The buffer holding the output string.\r
570 This buffer contains the length of the\r
571 string and the maixmum length reserved\r
572 for the string buffer.\r
573 @param DevPath The device path.\r
574\r
575**/\r
897f0eee 576VOID\r
577DevPathUsb (\r
578 IN OUT POOL_PRINT *Str,\r
579 IN VOID *DevPath\r
580 )\r
581{\r
582 USB_DEVICE_PATH *Usb;\r
583\r
584 Usb = DevPath;\r
585 CatPrint (Str, L"Usb(%x,%x)", (UINTN) Usb->ParentPortNumber, (UINTN) Usb->InterfaceNumber);\r
586}\r
587\r
11ef23f9 588/**\r
589 Convert Device Path to a Unicode string for printing.\r
590\r
591 @param Str The buffer holding the output string.\r
592 This buffer contains the length of the\r
593 string and the maixmum length reserved\r
594 for the string buffer.\r
595 @param DevPath The device path.\r
596\r
597**/\r
897f0eee 598VOID\r
599DevPathUsbWWID (\r
600 IN OUT POOL_PRINT *Str,\r
601 IN VOID *DevPath\r
602 )\r
603{\r
604 USB_WWID_DEVICE_PATH *UsbWWId;\r
605\r
606 UsbWWId = DevPath;\r
607 CatPrint (\r
608 Str,\r
609 L"UsbWwid(%x,%x,%x,\"WWID\")",\r
610 (UINTN) UsbWWId->VendorId,\r
611 (UINTN) UsbWWId->ProductId,\r
612 (UINTN) UsbWWId->InterfaceNumber\r
613 );\r
614}\r
615\r
11ef23f9 616/**\r
617 Convert Device Path to a Unicode string for printing.\r
618\r
619 @param Str The buffer holding the output string.\r
620 This buffer contains the length of the\r
621 string and the maixmum length reserved\r
622 for the string buffer.\r
623 @param DevPath The device path.\r
624\r
625**/\r
897f0eee 626VOID\r
627DevPathLogicalUnit (\r
628 IN OUT POOL_PRINT *Str,\r
629 IN VOID *DevPath\r
630 )\r
631{\r
632 DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
633\r
634 LogicalUnit = DevPath;\r
635 CatPrint (Str, L"Unit(%x)", (UINTN) LogicalUnit->Lun);\r
636}\r
637\r
11ef23f9 638/**\r
639 Convert Device Path to a Unicode string for printing.\r
640\r
641 @param Str The buffer holding the output string.\r
642 This buffer contains the length of the\r
643 string and the maixmum length reserved\r
644 for the string buffer.\r
645 @param DevPath The device path.\r
646\r
647**/\r
897f0eee 648VOID\r
649DevPathUsbClass (\r
650 IN OUT POOL_PRINT *Str,\r
651 IN VOID *DevPath\r
652 )\r
653{\r
654 USB_CLASS_DEVICE_PATH *UsbClass;\r
655\r
656 UsbClass = DevPath;\r
657 CatPrint (\r
658 Str,\r
659 L"Usb Class(%x,%x,%x,%x,%x)",\r
660 (UINTN) UsbClass->VendorId,\r
661 (UINTN) UsbClass->ProductId,\r
662 (UINTN) UsbClass->DeviceClass,\r
663 (UINTN) UsbClass->DeviceSubClass,\r
664 (UINTN) UsbClass->DeviceProtocol\r
665 );\r
666}\r
667\r
11ef23f9 668/**\r
669 Convert Device Path to a Unicode string for printing.\r
670\r
671 @param Str The buffer holding the output string.\r
672 This buffer contains the length of the\r
673 string and the maixmum length reserved\r
674 for the string buffer.\r
675 @param DevPath The device path.\r
676\r
677**/\r
897f0eee 678VOID\r
679DevPathSata (\r
680 IN OUT POOL_PRINT *Str,\r
681 IN VOID *DevPath\r
682 )\r
683{\r
684 SATA_DEVICE_PATH *Sata;\r
685\r
686 Sata = DevPath;\r
687 CatPrint (\r
688 Str,\r
689 L"Sata(%x,%x,%x)",\r
690 (UINTN) Sata->HBAPortNumber,\r
691 (UINTN) Sata->PortMultiplierPortNumber,\r
692 (UINTN) Sata->Lun\r
693 );\r
694}\r
695\r
11ef23f9 696/**\r
697 Convert Device Path to a Unicode string for printing.\r
698\r
699 @param Str The buffer holding the output string.\r
700 This buffer contains the length of the\r
701 string and the maixmum length reserved\r
702 for the string buffer.\r
703 @param DevPath The device path.\r
704\r
705**/\r
897f0eee 706VOID\r
707DevPathI2O (\r
708 IN OUT POOL_PRINT *Str,\r
709 IN VOID *DevPath\r
710 )\r
711{\r
11ef23f9 712 I2O_DEVICE_PATH *I2OPath;\r
897f0eee 713\r
11ef23f9 714 I2OPath = DevPath;\r
715 CatPrint (Str, L"I2O(%x)", (UINTN) I2OPath->Tid);\r
897f0eee 716}\r
717\r
11ef23f9 718/**\r
719 Convert Device Path to a Unicode string for printing.\r
720\r
721 @param Str The buffer holding the output string.\r
722 This buffer contains the length of the\r
723 string and the maixmum length reserved\r
724 for the string buffer.\r
725 @param DevPath The device path.\r
726\r
727**/\r
897f0eee 728VOID\r
729DevPathMacAddr (\r
730 IN OUT POOL_PRINT *Str,\r
731 IN VOID *DevPath\r
732 )\r
733{\r
11ef23f9 734 MAC_ADDR_DEVICE_PATH *MACDevPath;\r
897f0eee 735 UINTN HwAddressSize;\r
736 UINTN Index;\r
737\r
11ef23f9 738 MACDevPath = DevPath;\r
897f0eee 739\r
740 HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
11ef23f9 741 if (MACDevPath->IfType == 0x01 || MACDevPath->IfType == 0x00) {\r
897f0eee 742 HwAddressSize = 6;\r
743 }\r
744\r
745 CatPrint (Str, L"Mac(");\r
746\r
747 for (Index = 0; Index < HwAddressSize; Index++) {\r
11ef23f9 748 CatPrint (Str, L"%02x", (UINTN) MACDevPath->MacAddress.Addr[Index]);\r
897f0eee 749 }\r
750\r
751 CatPrint (Str, L")");\r
752}\r
753\r
11ef23f9 754/**\r
755 Convert Device Path to a Unicode string for printing.\r
756\r
757 @param Str The buffer holding the output string.\r
758 This buffer contains the length of the\r
759 string and the maixmum length reserved\r
760 for the string buffer.\r
761 @param DevPath The device path.\r
762\r
763**/\r
897f0eee 764VOID\r
765DevPathIPv4 (\r
766 IN OUT POOL_PRINT *Str,\r
767 IN VOID *DevPath\r
768 )\r
769{\r
11ef23f9 770 IPv4_DEVICE_PATH *IPDevPath;\r
897f0eee 771\r
11ef23f9 772 IPDevPath = DevPath;\r
897f0eee 773 CatPrint (\r
774 Str,\r
775 L"IPv4(%d.%d.%d.%d:%d)",\r
11ef23f9 776 (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
777 (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
778 (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
779 (UINTN) IPDevPath->RemoteIpAddress.Addr[3],\r
780 (UINTN) IPDevPath->RemotePort\r
897f0eee 781 );\r
782}\r
783\r
11ef23f9 784/**\r
785 Convert Device Path to a Unicode string for printing.\r
786\r
787 @param Str The buffer holding the output string.\r
788 This buffer contains the length of the\r
789 string and the maixmum length reserved\r
790 for the string buffer.\r
791 @param DevPath The device path.\r
792\r
793**/\r
897f0eee 794VOID\r
795DevPathIPv6 (\r
796 IN OUT POOL_PRINT *Str,\r
797 IN VOID *DevPath\r
798 )\r
799{\r
11ef23f9 800 IPv6_DEVICE_PATH *IPv6DevPath;\r
897f0eee 801\r
11ef23f9 802 IPv6DevPath = DevPath;\r
897f0eee 803 CatPrint (\r
804 Str,\r
805 L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
11ef23f9 806 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[0],\r
807 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[1],\r
808 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[2],\r
809 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[3],\r
810 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[4],\r
811 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[5],\r
812 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[6],\r
813 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[7],\r
814 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[8],\r
815 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[9],\r
816 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[10],\r
817 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[11],\r
818 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[12],\r
819 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[13],\r
820 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[14],\r
821 (UINTN) IPv6DevPath->RemoteIpAddress.Addr[15]\r
897f0eee 822 );\r
823}\r
824\r
11ef23f9 825/**\r
826 Convert Device Path to a Unicode string for printing.\r
827\r
828 @param Str The buffer holding the output string.\r
829 This buffer contains the length of the\r
830 string and the maixmum length reserved\r
831 for the string buffer.\r
832 @param DevPath The device path.\r
833\r
834**/\r
897f0eee 835VOID\r
836DevPathInfiniBand (\r
837 IN OUT POOL_PRINT *Str,\r
838 IN VOID *DevPath\r
839 )\r
840{\r
841 INFINIBAND_DEVICE_PATH *InfiniBand;\r
842\r
843 InfiniBand = DevPath;\r
844 CatPrint (\r
845 Str,\r
846 L"Infiniband(%x,%g,%lx,%lx,%lx)",\r
847 (UINTN) InfiniBand->ResourceFlags,\r
848 InfiniBand->PortGid,\r
849 InfiniBand->ServiceId,\r
850 InfiniBand->TargetPortId,\r
851 InfiniBand->DeviceId\r
852 );\r
853}\r
854\r
11ef23f9 855/**\r
856 Convert Device Path to a Unicode string for printing.\r
857\r
858 @param Str The buffer holding the output string.\r
859 This buffer contains the length of the\r
860 string and the maixmum length reserved\r
861 for the string buffer.\r
862 @param DevPath The device path.\r
863\r
864**/\r
897f0eee 865VOID\r
866DevPathUart (\r
867 IN OUT POOL_PRINT *Str,\r
868 IN VOID *DevPath\r
869 )\r
870{\r
871 UART_DEVICE_PATH *Uart;\r
872 CHAR8 Parity;\r
873\r
874 Uart = DevPath;\r
875 switch (Uart->Parity) {\r
876 case 0:\r
877 Parity = 'D';\r
878 break;\r
879\r
880 case 1:\r
881 Parity = 'N';\r
882 break;\r
883\r
884 case 2:\r
885 Parity = 'E';\r
886 break;\r
887\r
888 case 3:\r
889 Parity = 'O';\r
890 break;\r
891\r
892 case 4:\r
893 Parity = 'M';\r
894 break;\r
895\r
896 case 5:\r
897 Parity = 'S';\r
898 break;\r
899\r
900 default:\r
901 Parity = 'x';\r
902 break;\r
903 }\r
904\r
905 if (Uart->BaudRate == 0) {\r
906 CatPrint (Str, L"Uart(DEFAULT,%c,", Parity);\r
907 } else {\r
908 CatPrint (Str, L"Uart(%d,%c,", Uart->BaudRate, Parity);\r
909 }\r
910\r
911 if (Uart->DataBits == 0) {\r
912 CatPrint (Str, L"D,");\r
913 } else {\r
914 CatPrint (Str, L"%d,", (UINTN) Uart->DataBits);\r
915 }\r
916\r
917 switch (Uart->StopBits) {\r
918 case 0:\r
919 CatPrint (Str, L"D)");\r
920 break;\r
921\r
922 case 1:\r
923 CatPrint (Str, L"1)");\r
924 break;\r
925\r
926 case 2:\r
927 CatPrint (Str, L"1.5)");\r
928 break;\r
929\r
930 case 3:\r
931 CatPrint (Str, L"2)");\r
932 break;\r
933\r
934 default:\r
935 CatPrint (Str, L"x)");\r
936 break;\r
937 }\r
938}\r
939\r
11ef23f9 940/**\r
941 Convert Device Path to a Unicode string for printing.\r
942\r
943 @param Str The buffer holding the output string.\r
944 This buffer contains the length of the\r
945 string and the maixmum length reserved\r
946 for the string buffer.\r
947 @param DevPath The device path.\r
948\r
949**/\r
897f0eee 950VOID\r
951DevPathiSCSI (\r
952 IN OUT POOL_PRINT *Str,\r
953 IN VOID *DevPath\r
954 )\r
955{\r
11ef23f9 956 ISCSI_DEVICE_PATH_WITH_NAME *IScsi;\r
897f0eee 957 UINT16 Options;\r
958\r
959 ASSERT (Str != NULL);\r
960 ASSERT (DevPath != NULL);\r
961\r
11ef23f9 962 IScsi = DevPath;\r
897f0eee 963 CatPrint (\r
964 Str,\r
965 L"iSCSI(%s,%x,%lx,",\r
11ef23f9 966 IScsi->iSCSITargetName,\r
967 IScsi->TargetPortalGroupTag,\r
968 IScsi->Lun\r
897f0eee 969 );\r
970\r
11ef23f9 971 Options = IScsi->LoginOption;\r
972 CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
973 CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
974 if (((Options >> 11) & 0x0001) != 0) {\r
897f0eee 975 CatPrint (Str, L"%s,", L"None");\r
11ef23f9 976 } else if (((Options >> 12) & 0x0001) != 0) {\r
897f0eee 977 CatPrint (Str, L"%s,", L"CHAP_UNI");\r
978 } else {\r
979 CatPrint (Str, L"%s,", L"CHAP_BI");\r
980\r
981 }\r
982\r
11ef23f9 983 CatPrint (Str, L"%s)", (IScsi->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
897f0eee 984}\r
985\r
11ef23f9 986/**\r
987 Convert Device Path to a Unicode string for printing.\r
988\r
989 @param Str The buffer holding the output string.\r
990 This buffer contains the length of the\r
991 string and the maixmum length reserved\r
992 for the string buffer.\r
993 @param DevPath The device path.\r
994\r
995**/\r
897f0eee 996VOID\r
997DevPathHardDrive (\r
998 IN OUT POOL_PRINT *Str,\r
999 IN VOID *DevPath\r
1000 )\r
1001{\r
1002 HARDDRIVE_DEVICE_PATH *Hd;\r
1003\r
1004 Hd = DevPath;\r
1005 switch (Hd->SignatureType) {\r
1006 case SIGNATURE_TYPE_MBR:\r
1007 CatPrint (\r
1008 Str,\r
1009 L"HD(Part%d,Sig%08x)",\r
1010 (UINTN) Hd->PartitionNumber,\r
1011 (UINTN) *((UINT32 *) (&(Hd->Signature[0])))\r
1012 );\r
1013 break;\r
1014\r
1015 case SIGNATURE_TYPE_GUID:\r
1016 CatPrint (\r
1017 Str,\r
1018 L"HD(Part%d,Sig%g)",\r
1019 (UINTN) Hd->PartitionNumber,\r
1020 (EFI_GUID *) &(Hd->Signature[0])\r
1021 );\r
1022 break;\r
1023\r
1024 default:\r
1025 CatPrint (\r
1026 Str,\r
1027 L"HD(Part%d,MBRType=%02x,SigType=%02x)",\r
1028 (UINTN) Hd->PartitionNumber,\r
1029 (UINTN) Hd->MBRType,\r
1030 (UINTN) Hd->SignatureType\r
1031 );\r
1032 break;\r
1033 }\r
1034}\r
1035\r
11ef23f9 1036/**\r
1037 Convert Device Path to a Unicode string for printing.\r
1038\r
1039 @param Str The buffer holding the output string.\r
1040 This buffer contains the length of the\r
1041 string and the maixmum length reserved\r
1042 for the string buffer.\r
1043 @param DevPath The device path.\r
1044\r
1045**/\r
897f0eee 1046VOID\r
1047DevPathCDROM (\r
1048 IN OUT POOL_PRINT *Str,\r
1049 IN VOID *DevPath\r
1050 )\r
1051{\r
1052 CDROM_DEVICE_PATH *Cd;\r
1053\r
1054 Cd = DevPath;\r
1055 CatPrint (Str, L"CDROM(Entry%x)", (UINTN) Cd->BootEntry);\r
1056}\r
1057\r
11ef23f9 1058/**\r
1059 Convert Device Path to a Unicode string for printing.\r
1060\r
1061 @param Str The buffer holding the output string.\r
1062 This buffer contains the length of the\r
1063 string and the maixmum length reserved\r
1064 for the string buffer.\r
1065 @param DevPath The device path.\r
1066\r
1067**/\r
897f0eee 1068VOID\r
1069DevPathFilePath (\r
1070 IN OUT POOL_PRINT *Str,\r
1071 IN VOID *DevPath\r
1072 )\r
1073{\r
1074 FILEPATH_DEVICE_PATH *Fp;\r
1075\r
1076 Fp = DevPath;\r
1077 CatPrint (Str, L"%s", Fp->PathName);\r
1078}\r
1079\r
11ef23f9 1080/**\r
1081 Convert Device Path to a Unicode string for printing.\r
1082\r
1083 @param Str The buffer holding the output string.\r
1084 This buffer contains the length of the\r
1085 string and the maixmum length reserved\r
1086 for the string buffer.\r
1087 @param DevPath The device path.\r
1088\r
1089**/\r
897f0eee 1090VOID\r
1091DevPathMediaProtocol (\r
1092 IN OUT POOL_PRINT *Str,\r
1093 IN VOID *DevPath\r
1094 )\r
1095{\r
1096 MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;\r
1097\r
1098 MediaProt = DevPath;\r
1099 CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
1100}\r
1101\r
11ef23f9 1102/**\r
1103 Convert Device Path to a Unicode string for printing.\r
1104\r
1105 @param Str The buffer holding the output string.\r
1106 This buffer contains the length of the\r
1107 string and the maixmum length reserved\r
1108 for the string buffer.\r
1109 @param DevPath The device path.\r
1110\r
1111**/\r
897f0eee 1112VOID\r
1113DevPathFvFilePath (\r
1114 IN OUT POOL_PRINT *Str,\r
1115 IN VOID *DevPath\r
1116 )\r
1117{\r
1118 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;\r
1119\r
1120 FvFilePath = DevPath;\r
1121 CatPrint (Str, L"%g", &FvFilePath->FvFileName);\r
1122}\r
1123\r
11ef23f9 1124/**\r
1125 Convert Device Path to a Unicode string for printing.\r
1126\r
1127 @param Str The buffer holding the output string.\r
1128 This buffer contains the length of the\r
1129 string and the maixmum length reserved\r
1130 for the string buffer.\r
1131 @param DevPath The device path.\r
1132\r
1133**/\r
897f0eee 1134VOID\r
1135DevPathBssBss (\r
1136 IN OUT POOL_PRINT *Str,\r
1137 IN VOID *DevPath\r
1138 )\r
1139{\r
1140 BBS_BBS_DEVICE_PATH *Bbs;\r
1141 CHAR16 *Type;\r
1142\r
1143 Bbs = DevPath;\r
1144 switch (Bbs->DeviceType) {\r
1145 case BBS_TYPE_FLOPPY:\r
1146 Type = L"Floppy";\r
1147 break;\r
1148\r
1149 case BBS_TYPE_HARDDRIVE:\r
1150 Type = L"Harddrive";\r
1151 break;\r
1152\r
1153 case BBS_TYPE_CDROM:\r
1154 Type = L"CDROM";\r
1155 break;\r
1156\r
1157 case BBS_TYPE_PCMCIA:\r
1158 Type = L"PCMCIA";\r
1159 break;\r
1160\r
1161 case BBS_TYPE_USB:\r
1162 Type = L"Usb";\r
1163 break;\r
1164\r
1165 case BBS_TYPE_EMBEDDED_NETWORK:\r
1166 Type = L"Net";\r
1167 break;\r
1168\r
1169 case BBS_TYPE_BEV:\r
1170 Type = L"BEV";\r
1171 break;\r
1172\r
1173 default:\r
1174 Type = L"?";\r
1175 break;\r
1176 }\r
1177 CatPrint (Str, L"Legacy-%s", Type);\r
1178}\r
1179\r
11ef23f9 1180/**\r
1181 Convert Device Path to a Unicode string for printing.\r
1182\r
1183 @param Str The buffer holding the output string.\r
1184 This buffer contains the length of the\r
1185 string and the maixmum length reserved\r
1186 for the string buffer.\r
1187 @param DevPath The device path.\r
1188\r
1189**/\r
897f0eee 1190VOID\r
1191DevPathEndInstance (\r
1192 IN OUT POOL_PRINT *Str,\r
1193 IN VOID *DevPath\r
1194 )\r
1195{\r
1196 CatPrint (Str, L",");\r
1197}\r
1198\r
11ef23f9 1199/**\r
1200 Convert Device Path to a Unicode string for printing.\r
1201\r
1202 @param Str The buffer holding the output string.\r
1203 This buffer contains the length of the\r
1204 string and the maixmum length reserved\r
1205 for the string buffer.\r
1206 @param DevPath The device path.\r
1207\r
1208**/\r
897f0eee 1209VOID\r
1210DevPathNodeUnknown (\r
1211 IN OUT POOL_PRINT *Str,\r
1212 IN VOID *DevPath\r
1213 )\r
1214{\r
1215 CatPrint (Str, L"?");\r
1216}\r
1217\r
1218DEVICE_PATH_STRING_TABLE DevPathTable[] = {\r
7b25a79d 1219 {\r
1220 HARDWARE_DEVICE_PATH,\r
1221 HW_PCI_DP,\r
1222 DevPathPci\r
1223 },\r
1224 {\r
1225 HARDWARE_DEVICE_PATH,\r
1226 HW_PCCARD_DP,\r
1227 DevPathPccard\r
1228 },\r
1229 {\r
1230 HARDWARE_DEVICE_PATH,\r
1231 HW_MEMMAP_DP,\r
1232 DevPathMemMap\r
1233 },\r
1234 {\r
1235 HARDWARE_DEVICE_PATH,\r
1236 HW_VENDOR_DP,\r
1237 DevPathVendor\r
1238 },\r
1239 {\r
1240 HARDWARE_DEVICE_PATH,\r
1241 HW_CONTROLLER_DP,\r
1242 DevPathController\r
1243 },\r
1244 {\r
1245 ACPI_DEVICE_PATH,\r
1246 ACPI_DP,\r
1247 DevPathAcpi\r
1248 },\r
1249 {\r
1250 ACPI_DEVICE_PATH,\r
1251 ACPI_EXTENDED_DP,\r
1252 DevPathExtendedAcpi\r
1253 },\r
1254 {\r
1255 ACPI_DEVICE_PATH,\r
1256 ACPI_ADR_DP,\r
1257 DevPathAdrAcpi\r
1258 },\r
1259 {\r
1260 MESSAGING_DEVICE_PATH,\r
1261 MSG_ATAPI_DP,\r
1262 DevPathAtapi\r
1263 },\r
1264 {\r
1265 MESSAGING_DEVICE_PATH,\r
1266 MSG_SCSI_DP,\r
1267 DevPathScsi\r
1268 },\r
1269 {\r
1270 MESSAGING_DEVICE_PATH,\r
1271 MSG_FIBRECHANNEL_DP,\r
1272 DevPathFibre\r
1273 },\r
1274 {\r
1275 MESSAGING_DEVICE_PATH,\r
1276 MSG_1394_DP,\r
1277 DevPath1394\r
1278 },\r
1279 {\r
1280 MESSAGING_DEVICE_PATH,\r
1281 MSG_USB_DP,\r
1282 DevPathUsb\r
1283 },\r
1284 {\r
1285 MESSAGING_DEVICE_PATH,\r
1286 MSG_USB_WWID_DP,\r
1287 DevPathUsbWWID\r
1288 },\r
1289 {\r
1290 MESSAGING_DEVICE_PATH,\r
1291 MSG_DEVICE_LOGICAL_UNIT_DP,\r
1292 DevPathLogicalUnit\r
1293 },\r
1294 {\r
1295 MESSAGING_DEVICE_PATH,\r
1296 MSG_USB_CLASS_DP,\r
1297 DevPathUsbClass\r
1298 },\r
1299 {\r
1300 MESSAGING_DEVICE_PATH,\r
1301 MSG_SATA_DP,\r
1302 DevPathSata\r
1303 },\r
1304 {\r
1305 MESSAGING_DEVICE_PATH,\r
1306 MSG_I2O_DP,\r
1307 DevPathI2O\r
1308 },\r
1309 {\r
1310 MESSAGING_DEVICE_PATH,\r
1311 MSG_MAC_ADDR_DP,\r
1312 DevPathMacAddr\r
1313 },\r
1314 {\r
1315 MESSAGING_DEVICE_PATH,\r
1316 MSG_IPv4_DP,\r
1317 DevPathIPv4\r
1318 },\r
1319 {\r
1320 MESSAGING_DEVICE_PATH,\r
1321 MSG_IPv6_DP,\r
1322 DevPathIPv6\r
1323 },\r
1324 {\r
1325 MESSAGING_DEVICE_PATH,\r
1326 MSG_INFINIBAND_DP,\r
1327 DevPathInfiniBand\r
1328 },\r
1329 {\r
1330 MESSAGING_DEVICE_PATH,\r
1331 MSG_UART_DP,\r
1332 DevPathUart\r
1333 },\r
1334 {\r
1335 MESSAGING_DEVICE_PATH,\r
1336 MSG_VENDOR_DP,\r
1337 DevPathVendor\r
1338 },\r
1339 {\r
1340 MESSAGING_DEVICE_PATH,\r
1341 MSG_ISCSI_DP,\r
1342 DevPathiSCSI\r
1343 },\r
1344 {\r
1345 MEDIA_DEVICE_PATH,\r
1346 MEDIA_HARDDRIVE_DP,\r
1347 DevPathHardDrive\r
1348 },\r
1349 {\r
1350 MEDIA_DEVICE_PATH,\r
1351 MEDIA_CDROM_DP,\r
1352 DevPathCDROM\r
1353 },\r
1354 {\r
1355 MEDIA_DEVICE_PATH,\r
1356 MEDIA_VENDOR_DP,\r
1357 DevPathVendor\r
1358 },\r
1359 {\r
1360 MEDIA_DEVICE_PATH,\r
1361 MEDIA_FILEPATH_DP,\r
1362 DevPathFilePath\r
1363 },\r
1364 {\r
1365 MEDIA_DEVICE_PATH,\r
1366 MEDIA_PROTOCOL_DP,\r
1367 DevPathMediaProtocol\r
1368 },\r
1369 {\r
1370 MEDIA_DEVICE_PATH,\r
1371 MEDIA_PIWG_FW_FILE_DP,\r
1372 DevPathFvFilePath\r
1373 },\r
1374 {\r
1375 BBS_DEVICE_PATH,\r
1376 BBS_BBS_DP,\r
1377 DevPathBssBss\r
1378 },\r
1379 {\r
1380 END_DEVICE_PATH_TYPE,\r
1381 END_INSTANCE_DEVICE_PATH_SUBTYPE,\r
1382 DevPathEndInstance\r
1383 },\r
1384 {\r
1385 0,\r
1386 0,\r
1387 NULL\r
1388 }\r
897f0eee 1389};\r
1390\r
1391\r
1392/**\r
1393 This function converts an input device structure to a Unicode string.\r
1394\r
1395 @param DevPath A pointer to the device path structure.\r
1396\r
1397 @return A new allocated Unicode string that represents the device path.\r
1398\r
1399**/\r
1400CHAR16 *\r
1401EFIAPI\r
1402DevicePathToStr (\r
1403 IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
1404 )\r
1405{\r
1406 POOL_PRINT Str;\r
1407 EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r
1408 VOID (*DumpNode) (POOL_PRINT *, VOID *);\r
1409\r
1410 UINTN Index;\r
1411 UINTN NewSize;\r
1412\r
1413 EFI_STATUS Status;\r
1414 CHAR16 *ToText;\r
1415 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;\r
1416\r
1417 ZeroMem (&Str, sizeof (Str));\r
1418\r
1419 if (DevPath == NULL) {\r
1420 goto Done;\r
1421 }\r
1422\r
1423 Status = gBS->LocateProtocol (\r
1424 &gEfiDevicePathToTextProtocolGuid,\r
1425 NULL,\r
1426 (VOID **) &DevPathToText\r
1427 );\r
1428 if (!EFI_ERROR (Status)) {\r
1429 ToText = DevPathToText->ConvertDevicePathToText (\r
1430 DevPath,\r
1431 FALSE,\r
1432 TRUE\r
1433 );\r
1434 ASSERT (ToText != NULL);\r
1435 return ToText;\r
1436 }\r
1437\r
897f0eee 1438 //\r
1439 // Process each device path node\r
1440 //\r
1441 DevPathNode = DevPath;\r
1442 while (!IsDevicePathEnd (DevPathNode)) {\r
1443 //\r
1444 // Find the handler to dump this device path node\r
1445 //\r
1446 DumpNode = NULL;\r
1447 for (Index = 0; DevPathTable[Index].Function; Index += 1) {\r
1448\r
1449 if (DevicePathType (DevPathNode) == DevPathTable[Index].Type &&\r
1450 DevicePathSubType (DevPathNode) == DevPathTable[Index].SubType\r
1451 ) {\r
1452 DumpNode = DevPathTable[Index].Function;\r
1453 break;\r
1454 }\r
1455 }\r
1456 //\r
1457 // If not found, use a generic function\r
1458 //\r
1459 if (!DumpNode) {\r
1460 DumpNode = DevPathNodeUnknown;\r
1461 }\r
1462 //\r
1463 // Put a path seperator in if needed\r
1464 //\r
1465 if (Str.len && DumpNode != DevPathEndInstance) {\r
1466 CatPrint (&Str, L"/");\r
1467 }\r
1468 //\r
1469 // Print this node of the device path\r
1470 //\r
1471 DumpNode (&Str, DevPathNode);\r
1472\r
1473 //\r
1474 // Next device path node\r
1475 //\r
1476 DevPathNode = NextDevicePathNode (DevPathNode);\r
1477 }\r
1478 //\r
1479 // Shrink pool used for string allocation\r
1480 //\r
676df92c 1481 FreePool (DevPath);\r
897f0eee 1482\r
1483Done:\r
1484 NewSize = (Str.len + 1) * sizeof (CHAR16);\r
d7774861 1485 Str.str = ReallocatePool (NewSize, NewSize, Str.str);\r
897f0eee 1486 ASSERT (Str.str != NULL);\r
1487 Str.str[Str.len] = 0;\r
1488 return Str.str;\r
1489}\r