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