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