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