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