]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | DevicePathToText protocol as defined in the UEFI 2.0 specification.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "DevicePath.h"\r | |
16 | \r | |
17 | /**\r | |
18 | Concatenates a formatted unicode string to allocated pool. The caller must\r | |
19 | free the resulting buffer.\r | |
20 | \r | |
21 | @param Str Tracks the allocated pool, size in use, and\r | |
22 | amount of pool allocated.\r | |
23 | @param Fmt The format string\r | |
24 | @param ... Variable arguments based on the format string.\r | |
25 | \r | |
26 | @return Allocated buffer with the formatted string printed in it.\r | |
27 | The caller must free the allocated buffer. The buffer\r | |
28 | allocation is not packed.\r | |
29 | \r | |
30 | **/\r | |
31 | CHAR16 *\r | |
32 | EFIAPI\r | |
33 | CatPrint (\r | |
34 | IN OUT POOL_PRINT *Str,\r | |
35 | IN CHAR16 *Fmt,\r | |
36 | ...\r | |
37 | )\r | |
38 | {\r | |
39 | UINT16 *AppendStr;\r | |
40 | VA_LIST Args;\r | |
41 | UINTN Size;\r | |
42 | \r | |
43 | AppendStr = AllocateZeroPool (0x1000);\r | |
44 | if (AppendStr == NULL) {\r | |
45 | return Str->Str;\r | |
46 | }\r | |
47 | \r | |
48 | VA_START (Args, Fmt);\r | |
49 | UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);\r | |
50 | VA_END (Args);\r | |
51 | if (NULL == Str->Str) {\r | |
52 | Size = StrSize (AppendStr);\r | |
53 | Str->Str = AllocateZeroPool (Size);\r | |
54 | ASSERT (Str->Str != NULL);\r | |
55 | } else {\r | |
56 | Size = StrSize (AppendStr) - sizeof (UINT16);\r | |
57 | Size = Size + StrSize (Str->Str);\r | |
58 | Str->Str = ReallocatePool (\r | |
59 | StrSize (Str->Str),\r | |
60 | Size,\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 (Size < Str->MaxLen) {\r | |
68 | StrCat (Str->Str, AppendStr);\r | |
69 | Str->Len = Size - sizeof (UINT16);\r | |
70 | }\r | |
71 | \r | |
72 | FreePool (AppendStr);\r | |
73 | return Str->Str;\r | |
74 | }\r | |
75 | \r | |
76 | /**\r | |
77 | Converts a PCI device path structure to its string representative.\r | |
78 | \r | |
79 | @param Str The string representative of input device.\r | |
80 | @param DevPath The input device path structure.\r | |
81 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
82 | of the display node is used, where applicable. If DisplayOnly\r | |
83 | is FALSE, then the longer text representation of the display node\r | |
84 | is used.\r | |
85 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
86 | representation for a device node can be used, where applicable.\r | |
87 | \r | |
88 | **/\r | |
89 | VOID\r | |
90 | DevPathToTextPci (\r | |
91 | IN OUT POOL_PRINT *Str,\r | |
92 | IN VOID *DevPath,\r | |
93 | IN BOOLEAN DisplayOnly,\r | |
94 | IN BOOLEAN AllowShortcuts\r | |
95 | )\r | |
96 | {\r | |
97 | PCI_DEVICE_PATH *Pci;\r | |
98 | \r | |
99 | Pci = DevPath;\r | |
100 | CatPrint (Str, L"Pci(0x%x,0x%x)", (UINTN) Pci->Device, (UINTN) Pci->Function);\r | |
101 | }\r | |
102 | \r | |
103 | /**\r | |
104 | Converts a PC Card device path structure to its string representative.\r | |
105 | \r | |
106 | @param Str The string representative of input device.\r | |
107 | @param DevPath The input device path structure.\r | |
108 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
109 | of the display node is used, where applicable. If DisplayOnly\r | |
110 | is FALSE, then the longer text representation of the display node\r | |
111 | is used.\r | |
112 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
113 | representation for a device node can be used, where applicable.\r | |
114 | \r | |
115 | **/\r | |
116 | VOID\r | |
117 | DevPathToTextPccard (\r | |
118 | IN OUT POOL_PRINT *Str,\r | |
119 | IN VOID *DevPath,\r | |
120 | IN BOOLEAN DisplayOnly,\r | |
121 | IN BOOLEAN AllowShortcuts\r | |
122 | )\r | |
123 | {\r | |
124 | PCCARD_DEVICE_PATH *Pccard;\r | |
125 | \r | |
126 | Pccard = DevPath;\r | |
127 | CatPrint (Str, L"PcCard(0x%x)", (UINTN) Pccard->FunctionNumber);\r | |
128 | }\r | |
129 | \r | |
130 | /**\r | |
131 | Converts a Memory Map device path structure to its string representative.\r | |
132 | \r | |
133 | @param Str The string representative of input device.\r | |
134 | @param DevPath The input device path structure.\r | |
135 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
136 | of the display node is used, where applicable. If DisplayOnly\r | |
137 | is FALSE, then the longer text representation of the display node\r | |
138 | is used.\r | |
139 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
140 | representation for a device node can be used, where applicable.\r | |
141 | \r | |
142 | **/\r | |
143 | VOID\r | |
144 | DevPathToTextMemMap (\r | |
145 | IN OUT POOL_PRINT *Str,\r | |
146 | IN VOID *DevPath,\r | |
147 | IN BOOLEAN DisplayOnly,\r | |
148 | IN BOOLEAN AllowShortcuts\r | |
149 | )\r | |
150 | {\r | |
151 | MEMMAP_DEVICE_PATH *MemMap;\r | |
152 | \r | |
153 | MemMap = DevPath;\r | |
154 | CatPrint (\r | |
155 | Str,\r | |
156 | L"MemoryMapped(0x%x,0x%lx,0x%lx)",\r | |
157 | (UINTN) MemMap->MemoryType,\r | |
158 | MemMap->StartingAddress,\r | |
159 | MemMap->EndingAddress\r | |
160 | );\r | |
161 | }\r | |
162 | \r | |
163 | /**\r | |
164 | Converts a Vendor device path structure to its string representative.\r | |
165 | \r | |
166 | @param Str The string representative of input device.\r | |
167 | @param DevPath The input device path structure.\r | |
168 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
169 | of the display node is used, where applicable. If DisplayOnly\r | |
170 | is FALSE, then the longer text representation of the display node\r | |
171 | is used.\r | |
172 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
173 | representation for a device node can be used, where applicable.\r | |
174 | \r | |
175 | **/\r | |
176 | VOID\r | |
177 | DevPathToTextVendor (\r | |
178 | IN OUT POOL_PRINT *Str,\r | |
179 | IN VOID *DevPath,\r | |
180 | IN BOOLEAN DisplayOnly,\r | |
181 | IN BOOLEAN AllowShortcuts\r | |
182 | )\r | |
183 | {\r | |
184 | VENDOR_DEVICE_PATH *Vendor;\r | |
185 | CHAR16 *Type;\r | |
186 | UINTN Index;\r | |
187 | UINTN DataLength;\r | |
188 | UINT32 FlowControlMap;\r | |
189 | UINT16 Info;\r | |
190 | \r | |
191 | Vendor = (VENDOR_DEVICE_PATH *) DevPath;\r | |
192 | switch (DevicePathType (&Vendor->Header)) {\r | |
193 | case HARDWARE_DEVICE_PATH:\r | |
194 | Type = L"Hw";\r | |
195 | break;\r | |
196 | \r | |
197 | case MESSAGING_DEVICE_PATH:\r | |
198 | Type = L"Msg";\r | |
199 | if (AllowShortcuts) {\r | |
200 | if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {\r | |
201 | CatPrint (Str, L"VenPcAnsi()");\r | |
202 | return ;\r | |
203 | } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {\r | |
204 | CatPrint (Str, L"VenVt100()");\r | |
205 | return ;\r | |
206 | } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {\r | |
207 | CatPrint (Str, L"VenVt100Plus()");\r | |
208 | return ;\r | |
209 | } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {\r | |
210 | CatPrint (Str, L"VenUft8()");\r | |
211 | return ;\r | |
212 | } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) {\r | |
213 | FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);\r | |
214 | switch (FlowControlMap & 0x00000003) {\r | |
215 | case 0:\r | |
216 | CatPrint (Str, L"UartFlowCtrl(%s)", L"None");\r | |
217 | break;\r | |
218 | \r | |
219 | case 1:\r | |
220 | CatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware");\r | |
221 | break;\r | |
222 | \r | |
223 | case 2:\r | |
224 | CatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff");\r | |
225 | break;\r | |
226 | \r | |
227 | default:\r | |
228 | break;\r | |
229 | }\r | |
230 | \r | |
231 | return ;\r | |
232 | } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {\r | |
233 | CatPrint (\r | |
234 | Str,\r | |
235 | L"SAS(0x%lx,0x%lx,0x%x,",\r | |
236 | ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r | |
237 | ((SAS_DEVICE_PATH *) Vendor)->Lun,\r | |
238 | (UINTN) ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r | |
239 | );\r | |
240 | Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);\r | |
241 | if ((Info & 0x0f) == 0) {\r | |
242 | CatPrint (Str, L"NoTopology,0,0,0,");\r | |
243 | } else if (((Info & 0x0f) == 1) || ((Info & 0x0f) == 2)) {\r | |
244 | CatPrint (\r | |
245 | Str,\r | |
246 | L"%s,%s,%s,",\r | |
247 | ((Info & (0x1 << 4)) != 0) ? L"SATA" : L"SAS",\r | |
248 | ((Info & (0x1 << 5)) != 0) ? L"External" : L"Internal",\r | |
249 | ((Info & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct"\r | |
250 | );\r | |
251 | if ((Info & 0x0f) == 1) {\r | |
252 | CatPrint (Str, L"0,");\r | |
253 | } else {\r | |
254 | CatPrint (Str, L"0x%x,",(UINTN) (Info >> 8) & 0xff);\r | |
255 | }\r | |
256 | } else {\r | |
257 | CatPrint (Str, L"0,0,0,0,");\r | |
258 | }\r | |
259 | \r | |
260 | CatPrint (Str, L"0x%x)", (UINTN) ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r | |
261 | return ;\r | |
262 | } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r | |
263 | CatPrint (Str, L"DebugPort()");\r | |
264 | return ;\r | |
265 | }\r | |
266 | }\r | |
267 | break;\r | |
268 | \r | |
269 | case MEDIA_DEVICE_PATH:\r | |
270 | Type = L"Media";\r | |
271 | break;\r | |
272 | \r | |
273 | default:\r | |
274 | Type = L"?";\r | |
275 | break;\r | |
276 | }\r | |
277 | \r | |
278 | DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);\r | |
279 | CatPrint (Str, L"Ven%s(%g", Type, &Vendor->Guid);\r | |
280 | if (DataLength != 0) {\r | |
281 | CatPrint (Str, L",");\r | |
282 | for (Index = 0; Index < DataLength; Index++) {\r | |
283 | CatPrint (Str, L"%02x", (UINTN) ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r | |
284 | }\r | |
285 | }\r | |
286 | \r | |
287 | CatPrint (Str, L")");\r | |
288 | }\r | |
289 | \r | |
290 | /**\r | |
291 | Converts a Controller device path structure to its string representative.\r | |
292 | \r | |
293 | @param Str The string representative of input device.\r | |
294 | @param DevPath The input device path structure.\r | |
295 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
296 | of the display node is used, where applicable. If DisplayOnly\r | |
297 | is FALSE, then the longer text representation of the display node\r | |
298 | is used.\r | |
299 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
300 | representation for a device node can be used, where applicable.\r | |
301 | \r | |
302 | **/\r | |
303 | VOID\r | |
304 | DevPathToTextController (\r | |
305 | IN OUT POOL_PRINT *Str,\r | |
306 | IN VOID *DevPath,\r | |
307 | IN BOOLEAN DisplayOnly,\r | |
308 | IN BOOLEAN AllowShortcuts\r | |
309 | )\r | |
310 | {\r | |
311 | CONTROLLER_DEVICE_PATH *Controller;\r | |
312 | \r | |
313 | Controller = DevPath;\r | |
314 | CatPrint (\r | |
315 | Str,\r | |
316 | L"Ctrl(0x%x)",\r | |
317 | (UINTN) Controller->ControllerNumber\r | |
318 | );\r | |
319 | }\r | |
320 | \r | |
321 | /**\r | |
322 | Converts a ACPI device path structure to its string representative.\r | |
323 | \r | |
324 | @param Str The string representative of input device.\r | |
325 | @param DevPath The input device path structure.\r | |
326 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
327 | of the display node is used, where applicable. If DisplayOnly\r | |
328 | is FALSE, then the longer text representation of the display node\r | |
329 | is used.\r | |
330 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
331 | representation for a device node can be used, where applicable.\r | |
332 | \r | |
333 | **/\r | |
334 | VOID\r | |
335 | DevPathToTextAcpi (\r | |
336 | IN OUT POOL_PRINT *Str,\r | |
337 | IN VOID *DevPath,\r | |
338 | IN BOOLEAN DisplayOnly,\r | |
339 | IN BOOLEAN AllowShortcuts\r | |
340 | )\r | |
341 | {\r | |
342 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
343 | \r | |
344 | Acpi = DevPath;\r | |
345 | if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r | |
346 | switch (EISA_ID_TO_NUM (Acpi->HID)) {\r | |
347 | case 0x0a03:\r | |
348 | CatPrint (Str, L"PciRoot(0x%x)", (UINTN) Acpi->UID);\r | |
349 | break;\r | |
350 | \r | |
351 | case 0x0604:\r | |
352 | CatPrint (Str, L"Floppy(0x%x)", (UINTN) Acpi->UID);\r | |
353 | break;\r | |
354 | \r | |
355 | case 0x0301:\r | |
356 | CatPrint (Str, L"Keyboard(0x%x)", (UINTN) Acpi->UID);\r | |
357 | break;\r | |
358 | \r | |
359 | case 0x0501:\r | |
360 | CatPrint (Str, L"Serial(0x%x)", (UINTN) Acpi->UID);\r | |
361 | break;\r | |
362 | \r | |
363 | case 0x0401:\r | |
364 | CatPrint (Str, L"ParallelPort(0x%x)", (UINTN) Acpi->UID);\r | |
365 | break;\r | |
366 | \r | |
367 | default:\r | |
368 | CatPrint (Str, L"Acpi(PNP%04x,0x%x)", (UINTN) EISA_ID_TO_NUM (Acpi->HID), (UINTN) Acpi->UID);\r | |
369 | break;\r | |
370 | }\r | |
371 | } else {\r | |
372 | CatPrint (Str, L"Acpi(0x%08x,0x%x)", (UINTN) Acpi->HID, (UINTN) Acpi->UID);\r | |
373 | }\r | |
374 | }\r | |
375 | \r | |
376 | /**\r | |
377 | Converts EISA identification to string.\r | |
378 | \r | |
379 | @param EisaId The input EISA identification.\r | |
380 | @param Text A pointer to the output string.\r | |
381 | \r | |
382 | **/\r | |
383 | VOID\r | |
384 | EisaIdToText (\r | |
385 | IN UINT32 EisaId,\r | |
386 | IN OUT CHAR16 *Text\r | |
387 | )\r | |
388 | {\r | |
389 | CHAR16 PnpIdStr[17];\r | |
390 | \r | |
391 | //\r | |
392 | //UnicodeSPrint ("%X", 0x0a03) => "0000000000000A03"\r | |
393 | //\r | |
394 | UnicodeSPrint (PnpIdStr, 17 * 2, L"%16X", EisaId >> 16);\r | |
395 | \r | |
396 | UnicodeSPrint (\r | |
397 | Text,\r | |
398 | sizeof (CHAR16) + sizeof (CHAR16) + sizeof (CHAR16) + sizeof (PnpIdStr),\r | |
399 | L"%c%c%c%s",\r | |
400 | '@' + ((EisaId >> 10) & 0x1f),\r | |
401 | '@' + ((EisaId >> 5) & 0x1f),\r | |
402 | '@' + ((EisaId >> 0) & 0x1f),\r | |
403 | PnpIdStr + (16 - 4)\r | |
404 | );\r | |
405 | }\r | |
406 | \r | |
407 | /**\r | |
408 | Converts a ACPI extended HID device path structure to its string representative.\r | |
409 | \r | |
410 | @param Str The string representative of input device.\r | |
411 | @param DevPath The input device path structure.\r | |
412 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
413 | of the display node is used, where applicable. If DisplayOnly\r | |
414 | is FALSE, then the longer text representation of the display node\r | |
415 | is used.\r | |
416 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
417 | representation for a device node can be used, where applicable.\r | |
418 | \r | |
419 | **/\r | |
420 | VOID\r | |
421 | DevPathToTextAcpiEx (\r | |
422 | IN OUT POOL_PRINT *Str,\r | |
423 | IN VOID *DevPath,\r | |
424 | IN BOOLEAN DisplayOnly,\r | |
425 | IN BOOLEAN AllowShortcuts\r | |
426 | )\r | |
427 | {\r | |
428 | ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;\r | |
429 | CHAR8 *HIDStr;\r | |
430 | CHAR8 *UIDStr;\r | |
431 | CHAR8 *CIDStr;\r | |
432 | CHAR16 HIDText[11];\r | |
433 | CHAR16 CIDText[11];\r | |
434 | \r | |
435 | AcpiEx = DevPath;\r | |
436 | HIDStr = (CHAR8 *) (((UINT8 *) AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r | |
437 | UIDStr = HIDStr + AsciiStrLen (HIDStr) + 1;\r | |
438 | CIDStr = UIDStr + AsciiStrLen (UIDStr) + 1;\r | |
439 | \r | |
440 | EisaIdToText (AcpiEx->HID, HIDText);\r | |
441 | EisaIdToText (AcpiEx->CID, CIDText);\r | |
442 | \r | |
443 | if ((*HIDStr == '\0') && (*CIDStr == '\0') && (AcpiEx->UID == 0)) {\r | |
444 | //\r | |
445 | // use AcpiExp()\r | |
446 | //\r | |
447 | CatPrint (\r | |
448 | Str,\r | |
449 | L"AcpiExp(%s,%s,%a)",\r | |
450 | HIDText,\r | |
451 | CIDText,\r | |
452 | UIDStr\r | |
453 | );\r | |
454 | } else {\r | |
455 | if (AllowShortcuts) {\r | |
456 | //\r | |
457 | // display only\r | |
458 | //\r | |
459 | if (AcpiEx->HID == 0) {\r | |
460 | CatPrint (Str, L"AcpiEx(%a,", HIDStr);\r | |
461 | } else {\r | |
462 | CatPrint (Str, L"AcpiEx(%s,", HIDText);\r | |
463 | }\r | |
464 | \r | |
465 | if (AcpiEx->UID == 0) {\r | |
466 | CatPrint (Str, L"%a,", UIDStr);\r | |
467 | } else {\r | |
468 | CatPrint (Str, L"0x%x,", (UINTN) AcpiEx->UID);\r | |
469 | }\r | |
470 | \r | |
471 | if (AcpiEx->CID == 0) {\r | |
472 | CatPrint (Str, L"%a)", CIDStr);\r | |
473 | } else {\r | |
474 | CatPrint (Str, L"%s)", CIDText);\r | |
475 | }\r | |
476 | } else {\r | |
477 | CatPrint (\r | |
478 | Str,\r | |
479 | L"AcpiEx(%s,%s,0x%x,%a,%a,%a)",\r | |
480 | HIDText,\r | |
481 | CIDText,\r | |
482 | (UINTN) AcpiEx->UID,\r | |
483 | HIDStr,\r | |
484 | CIDStr,\r | |
485 | UIDStr\r | |
486 | );\r | |
487 | }\r | |
488 | }\r | |
489 | }\r | |
490 | \r | |
491 | /**\r | |
492 | Converts a ACPI address device path structure to its string representative.\r | |
493 | \r | |
494 | @param Str The string representative of input device.\r | |
495 | @param DevPath The input device path structure.\r | |
496 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
497 | of the display node is used, where applicable. If DisplayOnly\r | |
498 | is FALSE, then the longer text representation of the display node\r | |
499 | is used.\r | |
500 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
501 | representation for a device node can be used, where applicable.\r | |
502 | \r | |
503 | **/\r | |
504 | VOID\r | |
505 | DevPathToTextAcpiAdr (\r | |
506 | IN OUT POOL_PRINT *Str,\r | |
507 | IN VOID *DevPath,\r | |
508 | IN BOOLEAN DisplayOnly,\r | |
509 | IN BOOLEAN AllowShortcuts\r | |
510 | )\r | |
511 | {\r | |
512 | ACPI_ADR_DEVICE_PATH *AcpiAdr;\r | |
513 | UINT16 Index;\r | |
514 | UINT16 Length;\r | |
515 | UINT16 AdditionalAdrCount;\r | |
516 | \r | |
517 | AcpiAdr = DevPath;\r | |
518 | Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);\r | |
519 | AdditionalAdrCount = (UINT16) ((Length - 8) / 4);\r | |
520 | \r | |
521 | CatPrint (Str, L"AcpiAdr(0x%x", (UINTN) AcpiAdr->ADR);\r | |
522 | for (Index = 0; Index < AdditionalAdrCount; Index++) {\r | |
523 | CatPrint (Str, L",0x%x", (UINTN) *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r | |
524 | }\r | |
525 | CatPrint (Str, L")");\r | |
526 | }\r | |
527 | \r | |
528 | /**\r | |
529 | Converts a ATAPI device path structure to its string representative.\r | |
530 | \r | |
531 | @param Str The string representative of input device.\r | |
532 | @param DevPath The input device path structure.\r | |
533 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
534 | of the display node is used, where applicable. If DisplayOnly\r | |
535 | is FALSE, then the longer text representation of the display node\r | |
536 | is used.\r | |
537 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
538 | representation for a device node can be used, where applicable.\r | |
539 | \r | |
540 | **/\r | |
541 | VOID\r | |
542 | DevPathToTextAtapi (\r | |
543 | IN OUT POOL_PRINT *Str,\r | |
544 | IN VOID *DevPath,\r | |
545 | IN BOOLEAN DisplayOnly,\r | |
546 | IN BOOLEAN AllowShortcuts\r | |
547 | )\r | |
548 | {\r | |
549 | ATAPI_DEVICE_PATH *Atapi;\r | |
550 | \r | |
551 | Atapi = DevPath;\r | |
552 | \r | |
553 | if (DisplayOnly) {\r | |
554 | CatPrint (Str, L"Ata(0x%x)", (UINTN) Atapi->Lun);\r | |
555 | } else {\r | |
556 | CatPrint (\r | |
557 | Str,\r | |
558 | L"Ata(%s,%s,0x%x)",\r | |
559 | (Atapi->PrimarySecondary == 1) ? L"Secondary" : L"Primary",\r | |
560 | (Atapi->SlaveMaster == 1) ? L"Slave" : L"Master",\r | |
561 | (UINTN) Atapi->Lun\r | |
562 | );\r | |
563 | }\r | |
564 | }\r | |
565 | \r | |
566 | /**\r | |
567 | Converts a SCSI device path structure to its string representative.\r | |
568 | \r | |
569 | @param Str The string representative of input device.\r | |
570 | @param DevPath The input device path structure.\r | |
571 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
572 | of the display node is used, where applicable. If DisplayOnly\r | |
573 | is FALSE, then the longer text representation of the display node\r | |
574 | is used.\r | |
575 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
576 | representation for a device node can be used, where applicable.\r | |
577 | \r | |
578 | **/\r | |
579 | VOID\r | |
580 | DevPathToTextScsi (\r | |
581 | IN OUT POOL_PRINT *Str,\r | |
582 | IN VOID *DevPath,\r | |
583 | IN BOOLEAN DisplayOnly,\r | |
584 | IN BOOLEAN AllowShortcuts\r | |
585 | )\r | |
586 | {\r | |
587 | SCSI_DEVICE_PATH *Scsi;\r | |
588 | \r | |
589 | Scsi = DevPath;\r | |
590 | CatPrint (Str, L"Scsi(0x%x,0x%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun);\r | |
591 | }\r | |
592 | \r | |
593 | /**\r | |
594 | Converts a Fibre device path structure to its string representative.\r | |
595 | \r | |
596 | @param Str The string representative of input device.\r | |
597 | @param DevPath The input device path structure.\r | |
598 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
599 | of the display node is used, where applicable. If DisplayOnly\r | |
600 | is FALSE, then the longer text representation of the display node\r | |
601 | is used.\r | |
602 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
603 | representation for a device node can be used, where applicable.\r | |
604 | \r | |
605 | **/\r | |
606 | VOID\r | |
607 | DevPathToTextFibre (\r | |
608 | IN OUT POOL_PRINT *Str,\r | |
609 | IN VOID *DevPath,\r | |
610 | IN BOOLEAN DisplayOnly,\r | |
611 | IN BOOLEAN AllowShortcuts\r | |
612 | )\r | |
613 | {\r | |
614 | FIBRECHANNEL_DEVICE_PATH *Fibre;\r | |
615 | \r | |
616 | Fibre = DevPath;\r | |
617 | CatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);\r | |
618 | }\r | |
619 | \r | |
620 | /**\r | |
621 | Converts a 1394 device path structure to its string representative.\r | |
622 | \r | |
623 | @param Str The string representative of input device.\r | |
624 | @param DevPath The input device path structure.\r | |
625 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
626 | of the display node is used, where applicable. If DisplayOnly\r | |
627 | is FALSE, then the longer text representation of the display node\r | |
628 | is used.\r | |
629 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
630 | representation for a device node can be used, where applicable.\r | |
631 | \r | |
632 | **/\r | |
633 | VOID\r | |
634 | DevPathToText1394 (\r | |
635 | IN OUT POOL_PRINT *Str,\r | |
636 | IN VOID *DevPath,\r | |
637 | IN BOOLEAN DisplayOnly,\r | |
638 | IN BOOLEAN AllowShortcuts\r | |
639 | )\r | |
640 | {\r | |
641 | F1394_DEVICE_PATH *F1394DevPath;\r | |
642 | \r | |
643 | F1394DevPath = DevPath;\r | |
644 | //\r | |
645 | // Guid has format of IEEE-EUI64\r | |
646 | //\r | |
647 | CatPrint (Str, L"I1394(%016lx)", F1394DevPath->Guid);\r | |
648 | }\r | |
649 | \r | |
650 | /**\r | |
651 | Converts a USB device path structure to its string representative.\r | |
652 | \r | |
653 | @param Str The string representative of input device.\r | |
654 | @param DevPath The input device path structure.\r | |
655 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
656 | of the display node is used, where applicable. If DisplayOnly\r | |
657 | is FALSE, then the longer text representation of the display node\r | |
658 | is used.\r | |
659 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
660 | representation for a device node can be used, where applicable.\r | |
661 | \r | |
662 | **/\r | |
663 | VOID\r | |
664 | DevPathToTextUsb (\r | |
665 | IN OUT POOL_PRINT *Str,\r | |
666 | IN VOID *DevPath,\r | |
667 | IN BOOLEAN DisplayOnly,\r | |
668 | IN BOOLEAN AllowShortcuts\r | |
669 | )\r | |
670 | {\r | |
671 | USB_DEVICE_PATH *Usb;\r | |
672 | \r | |
673 | Usb = DevPath;\r | |
674 | CatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);\r | |
675 | }\r | |
676 | \r | |
677 | /**\r | |
678 | Converts a USB WWID device path structure to its string representative.\r | |
679 | \r | |
680 | @param Str The string representative of input device.\r | |
681 | @param DevPath The input device path structure.\r | |
682 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
683 | of the display node is used, where applicable. If DisplayOnly\r | |
684 | is FALSE, then the longer text representation of the display node\r | |
685 | is used.\r | |
686 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
687 | representation for a device node can be used, where applicable.\r | |
688 | \r | |
689 | **/\r | |
690 | VOID\r | |
691 | DevPathToTextUsbWWID (\r | |
692 | IN OUT POOL_PRINT *Str,\r | |
693 | IN VOID *DevPath,\r | |
694 | IN BOOLEAN DisplayOnly,\r | |
695 | IN BOOLEAN AllowShortcuts\r | |
696 | )\r | |
697 | {\r | |
698 | USB_WWID_DEVICE_PATH *UsbWWId;\r | |
699 | CHAR16 *SerialNumberStr;\r | |
700 | CHAR16 *NewStr;\r | |
701 | UINT16 Length;\r | |
702 | \r | |
703 | UsbWWId = DevPath;\r | |
704 | \r | |
705 | SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof (USB_WWID_DEVICE_PATH));\r | |
706 | Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));\r | |
707 | if (SerialNumberStr [Length - 1] != 0) {\r | |
708 | //\r | |
709 | // In case no NULL terminator in SerialNumber, create a new one with NULL terminator\r | |
710 | //\r | |
711 | NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);\r | |
712 | ASSERT (NewStr != NULL);\r | |
713 | NewStr [Length] = 0;\r | |
714 | SerialNumberStr = NewStr;\r | |
715 | }\r | |
716 | \r | |
717 | CatPrint (\r | |
718 | Str,\r | |
719 | L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",\r | |
720 | (UINTN) UsbWWId->VendorId,\r | |
721 | (UINTN) UsbWWId->ProductId,\r | |
722 | (UINTN) UsbWWId->InterfaceNumber,\r | |
723 | SerialNumberStr\r | |
724 | );\r | |
725 | }\r | |
726 | \r | |
727 | /**\r | |
728 | Converts a Logic Unit device path structure to its string representative.\r | |
729 | \r | |
730 | @param Str The string representative of input device.\r | |
731 | @param DevPath The input device path structure.\r | |
732 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
733 | of the display node is used, where applicable. If DisplayOnly\r | |
734 | is FALSE, then the longer text representation of the display node\r | |
735 | is used.\r | |
736 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
737 | representation for a device node can be used, where applicable.\r | |
738 | \r | |
739 | **/\r | |
740 | VOID\r | |
741 | DevPathToTextLogicalUnit (\r | |
742 | IN OUT POOL_PRINT *Str,\r | |
743 | IN VOID *DevPath,\r | |
744 | IN BOOLEAN DisplayOnly,\r | |
745 | IN BOOLEAN AllowShortcuts\r | |
746 | )\r | |
747 | {\r | |
748 | DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r | |
749 | \r | |
750 | LogicalUnit = DevPath;\r | |
751 | CatPrint (Str, L"Unit(0x%x)", (UINTN) LogicalUnit->Lun);\r | |
752 | }\r | |
753 | \r | |
754 | /**\r | |
755 | Converts a USB class device path structure to its string representative.\r | |
756 | \r | |
757 | @param Str The string representative of input device.\r | |
758 | @param DevPath The input device path structure.\r | |
759 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
760 | of the display node is used, where applicable. If DisplayOnly\r | |
761 | is FALSE, then the longer text representation of the display node\r | |
762 | is used.\r | |
763 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
764 | representation for a device node can be used, where applicable.\r | |
765 | \r | |
766 | **/\r | |
767 | VOID\r | |
768 | DevPathToTextUsbClass (\r | |
769 | IN OUT POOL_PRINT *Str,\r | |
770 | IN VOID *DevPath,\r | |
771 | IN BOOLEAN DisplayOnly,\r | |
772 | IN BOOLEAN AllowShortcuts\r | |
773 | )\r | |
774 | {\r | |
775 | USB_CLASS_DEVICE_PATH *UsbClass;\r | |
776 | BOOLEAN IsKnownSubClass;\r | |
777 | \r | |
778 | \r | |
779 | UsbClass = DevPath;\r | |
780 | \r | |
781 | IsKnownSubClass = TRUE;\r | |
782 | switch (UsbClass->DeviceClass) {\r | |
783 | case USB_CLASS_AUDIO:\r | |
784 | CatPrint (Str, L"UsbAudio");\r | |
785 | break;\r | |
786 | \r | |
787 | case USB_CLASS_CDCCONTROL:\r | |
788 | CatPrint (Str, L"UsbCDCControl");\r | |
789 | break;\r | |
790 | \r | |
791 | case USB_CLASS_HID:\r | |
792 | CatPrint (Str, L"UsbHID");\r | |
793 | break;\r | |
794 | \r | |
795 | case USB_CLASS_IMAGE:\r | |
796 | CatPrint (Str, L"UsbImage");\r | |
797 | break;\r | |
798 | \r | |
799 | case USB_CLASS_PRINTER:\r | |
800 | CatPrint (Str, L"UsbPrinter");\r | |
801 | break;\r | |
802 | \r | |
803 | case USB_CLASS_MASS_STORAGE:\r | |
804 | CatPrint (Str, L"UsbMassStorage");\r | |
805 | break;\r | |
806 | \r | |
807 | case USB_CLASS_HUB:\r | |
808 | CatPrint (Str, L"UsbHub");\r | |
809 | break;\r | |
810 | \r | |
811 | case USB_CLASS_CDCDATA:\r | |
812 | CatPrint (Str, L"UsbCDCData");\r | |
813 | break;\r | |
814 | \r | |
815 | case USB_CLASS_SMART_CARD:\r | |
816 | CatPrint (Str, L"UsbSmartCard");\r | |
817 | break;\r | |
818 | \r | |
819 | case USB_CLASS_VIDEO:\r | |
820 | CatPrint (Str, L"UsbVideo");\r | |
821 | break;\r | |
822 | \r | |
823 | case USB_CLASS_DIAGNOSTIC:\r | |
824 | CatPrint (Str, L"UsbDiagnostic");\r | |
825 | break;\r | |
826 | \r | |
827 | case USB_CLASS_WIRELESS:\r | |
828 | CatPrint (Str, L"UsbWireless");\r | |
829 | break;\r | |
830 | \r | |
831 | default:\r | |
832 | IsKnownSubClass = FALSE;\r | |
833 | break;\r | |
834 | }\r | |
835 | \r | |
836 | if (IsKnownSubClass) {\r | |
837 | CatPrint (\r | |
838 | Str,\r | |
839 | L"(0x%x,0x%x,0x%x,0x%x)",\r | |
840 | (UINTN) UsbClass->VendorId,\r | |
841 | (UINTN) UsbClass->ProductId,\r | |
842 | (UINTN) UsbClass->DeviceSubClass,\r | |
843 | (UINTN) UsbClass->DeviceProtocol\r | |
844 | );\r | |
845 | return;\r | |
846 | }\r | |
847 | \r | |
848 | if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {\r | |
849 | if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {\r | |
850 | CatPrint (\r | |
851 | Str,\r | |
852 | L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",\r | |
853 | (UINTN) UsbClass->VendorId,\r | |
854 | (UINTN) UsbClass->ProductId,\r | |
855 | (UINTN) UsbClass->DeviceProtocol\r | |
856 | );\r | |
857 | return;\r | |
858 | } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {\r | |
859 | CatPrint (\r | |
860 | Str,\r | |
861 | L"UsbIrdaBridge(0x%x,0x%x,0x%x)",\r | |
862 | (UINTN) UsbClass->VendorId,\r | |
863 | (UINTN) UsbClass->ProductId,\r | |
864 | (UINTN) UsbClass->DeviceProtocol\r | |
865 | );\r | |
866 | return;\r | |
867 | } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {\r | |
868 | CatPrint (\r | |
869 | Str,\r | |
870 | L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",\r | |
871 | (UINTN) UsbClass->VendorId,\r | |
872 | (UINTN) UsbClass->ProductId,\r | |
873 | (UINTN) UsbClass->DeviceProtocol\r | |
874 | );\r | |
875 | return;\r | |
876 | }\r | |
877 | }\r | |
878 | \r | |
879 | CatPrint (\r | |
880 | Str,\r | |
881 | L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",\r | |
882 | (UINTN) UsbClass->VendorId,\r | |
883 | (UINTN) UsbClass->ProductId,\r | |
884 | (UINTN) UsbClass->DeviceClass,\r | |
885 | (UINTN) UsbClass->DeviceSubClass,\r | |
886 | (UINTN) UsbClass->DeviceProtocol\r | |
887 | );\r | |
888 | }\r | |
889 | \r | |
890 | /**\r | |
891 | Converts a SATA device path structure to its string representative.\r | |
892 | \r | |
893 | @param Str The string representative of input device.\r | |
894 | @param DevPath The input device path structure.\r | |
895 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
896 | of the display node is used, where applicable. If DisplayOnly\r | |
897 | is FALSE, then the longer text representation of the display node\r | |
898 | is used.\r | |
899 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
900 | representation for a device node can be used, where applicable.\r | |
901 | \r | |
902 | **/\r | |
903 | VOID\r | |
904 | DevPathToTextSata (\r | |
905 | IN OUT POOL_PRINT *Str,\r | |
906 | IN VOID *DevPath,\r | |
907 | IN BOOLEAN DisplayOnly,\r | |
908 | IN BOOLEAN AllowShortcuts\r | |
909 | )\r | |
910 | {\r | |
911 | SATA_DEVICE_PATH *Sata;\r | |
912 | \r | |
913 | Sata = DevPath;\r | |
914 | if ((Sata->PortMultiplierPortNumber & SATA_HBA_DIRECT_CONNECT_FLAG) != 0) {\r | |
915 | CatPrint (\r | |
916 | Str,\r | |
917 | L"Sata(0x%x,0x%x)",\r | |
918 | (UINTN) Sata->HBAPortNumber,\r | |
919 | (UINTN) Sata->Lun\r | |
920 | );\r | |
921 | } else {\r | |
922 | CatPrint (\r | |
923 | Str,\r | |
924 | L"Sata(0x%x,0x%x,0x%x)",\r | |
925 | (UINTN) Sata->HBAPortNumber,\r | |
926 | (UINTN) Sata->PortMultiplierPortNumber,\r | |
927 | (UINTN) Sata->Lun\r | |
928 | );\r | |
929 | }\r | |
930 | }\r | |
931 | \r | |
932 | /**\r | |
933 | Converts a I20 device path structure to its string representative.\r | |
934 | \r | |
935 | @param Str The string representative of input device.\r | |
936 | @param DevPath The input device path structure.\r | |
937 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
938 | of the display node is used, where applicable. If DisplayOnly\r | |
939 | is FALSE, then the longer text representation of the display node\r | |
940 | is used.\r | |
941 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
942 | representation for a device node can be used, where applicable.\r | |
943 | \r | |
944 | **/\r | |
945 | VOID\r | |
946 | DevPathToTextI2O (\r | |
947 | IN OUT POOL_PRINT *Str,\r | |
948 | IN VOID *DevPath,\r | |
949 | IN BOOLEAN DisplayOnly,\r | |
950 | IN BOOLEAN AllowShortcuts\r | |
951 | )\r | |
952 | {\r | |
953 | I2O_DEVICE_PATH *I2ODevPath;\r | |
954 | \r | |
955 | I2ODevPath = DevPath;\r | |
956 | CatPrint (Str, L"I2O(0x%x)", (UINTN) I2ODevPath->Tid);\r | |
957 | }\r | |
958 | \r | |
959 | /**\r | |
960 | Converts a MAC address device path structure to its string representative.\r | |
961 | \r | |
962 | @param Str The string representative of input device.\r | |
963 | @param DevPath The input device path structure.\r | |
964 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
965 | of the display node is used, where applicable. If DisplayOnly\r | |
966 | is FALSE, then the longer text representation of the display node\r | |
967 | is used.\r | |
968 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
969 | representation for a device node can be used, where applicable.\r | |
970 | \r | |
971 | **/\r | |
972 | VOID\r | |
973 | DevPathToTextMacAddr (\r | |
974 | IN OUT POOL_PRINT *Str,\r | |
975 | IN VOID *DevPath,\r | |
976 | IN BOOLEAN DisplayOnly,\r | |
977 | IN BOOLEAN AllowShortcuts\r | |
978 | )\r | |
979 | {\r | |
980 | MAC_ADDR_DEVICE_PATH *MacDevPath;\r | |
981 | UINTN HwAddressSize;\r | |
982 | UINTN Index;\r | |
983 | \r | |
984 | MacDevPath = DevPath;\r | |
985 | \r | |
986 | HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r | |
987 | if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {\r | |
988 | HwAddressSize = 6;\r | |
989 | }\r | |
990 | \r | |
991 | CatPrint (Str, L"MAC(");\r | |
992 | \r | |
993 | for (Index = 0; Index < HwAddressSize; Index++) {\r | |
994 | CatPrint (Str, L"%02x", (UINTN) MacDevPath->MacAddress.Addr[Index]);\r | |
995 | }\r | |
996 | \r | |
997 | CatPrint (Str, L",0x%x)", (UINTN) MacDevPath->IfType);\r | |
998 | }\r | |
999 | \r | |
1000 | /**\r | |
1001 | Converts network protocol string to its text representation.\r | |
1002 | \r | |
1003 | @param Str The string representative of input device.\r | |
1004 | @param Protocol The network protocol ID.\r | |
1005 | \r | |
1006 | **/\r | |
1007 | VOID\r | |
1008 | CatNetworkProtocol (\r | |
1009 | IN OUT POOL_PRINT *Str,\r | |
1010 | IN UINT16 Protocol\r | |
1011 | )\r | |
1012 | {\r | |
1013 | if (Protocol == RFC_1700_TCP_PROTOCOL) {\r | |
1014 | CatPrint (Str, L"TCP");\r | |
1015 | } else if (Protocol == RFC_1700_UDP_PROTOCOL) {\r | |
1016 | CatPrint (Str, L"UDP");\r | |
1017 | } else {\r | |
1018 | CatPrint (Str, L"0x%x", Protocol);\r | |
1019 | }\r | |
1020 | }\r | |
1021 | \r | |
1022 | /**\r | |
1023 | Converts a IPv4 device path structure to its string representative.\r | |
1024 | \r | |
1025 | @param Str The string representative of input device.\r | |
1026 | @param DevPath The input device path structure.\r | |
1027 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1028 | of the display node is used, where applicable. If DisplayOnly\r | |
1029 | is FALSE, then the longer text representation of the display node\r | |
1030 | is used.\r | |
1031 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1032 | representation for a device node can be used, where applicable.\r | |
1033 | \r | |
1034 | **/\r | |
1035 | VOID\r | |
1036 | DevPathToTextIPv4 (\r | |
1037 | IN OUT POOL_PRINT *Str,\r | |
1038 | IN VOID *DevPath,\r | |
1039 | IN BOOLEAN DisplayOnly,\r | |
1040 | IN BOOLEAN AllowShortcuts\r | |
1041 | )\r | |
1042 | {\r | |
1043 | IPv4_DEVICE_PATH *IPDevPath;\r | |
1044 | \r | |
1045 | IPDevPath = DevPath;\r | |
1046 | if (DisplayOnly) {\r | |
1047 | CatPrint (\r | |
1048 | Str,\r | |
1049 | L"IPv4(%d.%d.%d.%d)",\r | |
1050 | (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r | |
1051 | (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r | |
1052 | (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r | |
1053 | (UINTN) IPDevPath->RemoteIpAddress.Addr[3]\r | |
1054 | );\r | |
1055 | return ;\r | |
1056 | }\r | |
1057 | \r | |
1058 | CatPrint (\r | |
1059 | Str,\r | |
1060 | L"IPv4(%d.%d.%d.%d,",\r | |
1061 | (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r | |
1062 | (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r | |
1063 | (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r | |
1064 | (UINTN) IPDevPath->RemoteIpAddress.Addr[3]\r | |
1065 | );\r | |
1066 | \r | |
1067 | CatNetworkProtocol (\r | |
1068 | Str,\r | |
1069 | IPDevPath->Protocol\r | |
1070 | );\r | |
1071 | \r | |
1072 | CatPrint (\r | |
1073 | Str,\r | |
1074 | L",%s,%d.%d.%d.%d)",\r | |
1075 | IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r | |
1076 | (UINTN) IPDevPath->LocalIpAddress.Addr[0],\r | |
1077 | (UINTN) IPDevPath->LocalIpAddress.Addr[1],\r | |
1078 | (UINTN) IPDevPath->LocalIpAddress.Addr[2],\r | |
1079 | (UINTN) IPDevPath->LocalIpAddress.Addr[3]\r | |
1080 | );\r | |
1081 | }\r | |
1082 | \r | |
1083 | /**\r | |
1084 | Converts a IPv6 device path structure to its string representative.\r | |
1085 | \r | |
1086 | @param Str The string representative of input device.\r | |
1087 | @param DevPath The input device path structure.\r | |
1088 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1089 | of the display node is used, where applicable. If DisplayOnly\r | |
1090 | is FALSE, then the longer text representation of the display node\r | |
1091 | is used.\r | |
1092 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1093 | representation for a device node can be used, where applicable.\r | |
1094 | \r | |
1095 | **/\r | |
1096 | VOID\r | |
1097 | DevPathToTextIPv6 (\r | |
1098 | IN OUT POOL_PRINT *Str,\r | |
1099 | IN VOID *DevPath,\r | |
1100 | IN BOOLEAN DisplayOnly,\r | |
1101 | IN BOOLEAN AllowShortcuts\r | |
1102 | )\r | |
1103 | {\r | |
1104 | IPv6_DEVICE_PATH *IPDevPath;\r | |
1105 | \r | |
1106 | IPDevPath = DevPath;\r | |
1107 | if (DisplayOnly) {\r | |
1108 | CatPrint (\r | |
1109 | Str,\r | |
1110 | L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r | |
1111 | (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r | |
1112 | (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r | |
1113 | (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r | |
1114 | (UINTN) IPDevPath->RemoteIpAddress.Addr[3],\r | |
1115 | (UINTN) IPDevPath->RemoteIpAddress.Addr[4],\r | |
1116 | (UINTN) IPDevPath->RemoteIpAddress.Addr[5],\r | |
1117 | (UINTN) IPDevPath->RemoteIpAddress.Addr[6],\r | |
1118 | (UINTN) IPDevPath->RemoteIpAddress.Addr[7],\r | |
1119 | (UINTN) IPDevPath->RemoteIpAddress.Addr[8],\r | |
1120 | (UINTN) IPDevPath->RemoteIpAddress.Addr[9],\r | |
1121 | (UINTN) IPDevPath->RemoteIpAddress.Addr[10],\r | |
1122 | (UINTN) IPDevPath->RemoteIpAddress.Addr[11],\r | |
1123 | (UINTN) IPDevPath->RemoteIpAddress.Addr[12],\r | |
1124 | (UINTN) IPDevPath->RemoteIpAddress.Addr[13],\r | |
1125 | (UINTN) IPDevPath->RemoteIpAddress.Addr[14],\r | |
1126 | (UINTN) IPDevPath->RemoteIpAddress.Addr[15]\r | |
1127 | );\r | |
1128 | return ;\r | |
1129 | }\r | |
1130 | \r | |
1131 | CatPrint (\r | |
1132 | Str,\r | |
1133 | L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,",\r | |
1134 | (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r | |
1135 | (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r | |
1136 | (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r | |
1137 | (UINTN) IPDevPath->RemoteIpAddress.Addr[3],\r | |
1138 | (UINTN) IPDevPath->RemoteIpAddress.Addr[4],\r | |
1139 | (UINTN) IPDevPath->RemoteIpAddress.Addr[5],\r | |
1140 | (UINTN) IPDevPath->RemoteIpAddress.Addr[6],\r | |
1141 | (UINTN) IPDevPath->RemoteIpAddress.Addr[7],\r | |
1142 | (UINTN) IPDevPath->RemoteIpAddress.Addr[8],\r | |
1143 | (UINTN) IPDevPath->RemoteIpAddress.Addr[9],\r | |
1144 | (UINTN) IPDevPath->RemoteIpAddress.Addr[10],\r | |
1145 | (UINTN) IPDevPath->RemoteIpAddress.Addr[11],\r | |
1146 | (UINTN) IPDevPath->RemoteIpAddress.Addr[12],\r | |
1147 | (UINTN) IPDevPath->RemoteIpAddress.Addr[13],\r | |
1148 | (UINTN) IPDevPath->RemoteIpAddress.Addr[14],\r | |
1149 | (UINTN) IPDevPath->RemoteIpAddress.Addr[15]\r | |
1150 | );\r | |
1151 | \r | |
1152 | CatNetworkProtocol (\r | |
1153 | Str,\r | |
1154 | IPDevPath->Protocol\r | |
1155 | );\r | |
1156 | \r | |
1157 | CatPrint (\r | |
1158 | Str,\r | |
1159 | L",%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r | |
1160 | IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r | |
1161 | (UINTN) IPDevPath->LocalIpAddress.Addr[0],\r | |
1162 | (UINTN) IPDevPath->LocalIpAddress.Addr[1],\r | |
1163 | (UINTN) IPDevPath->LocalIpAddress.Addr[2],\r | |
1164 | (UINTN) IPDevPath->LocalIpAddress.Addr[3],\r | |
1165 | (UINTN) IPDevPath->LocalIpAddress.Addr[4],\r | |
1166 | (UINTN) IPDevPath->LocalIpAddress.Addr[5],\r | |
1167 | (UINTN) IPDevPath->LocalIpAddress.Addr[6],\r | |
1168 | (UINTN) IPDevPath->LocalIpAddress.Addr[7],\r | |
1169 | (UINTN) IPDevPath->LocalIpAddress.Addr[8],\r | |
1170 | (UINTN) IPDevPath->LocalIpAddress.Addr[9],\r | |
1171 | (UINTN) IPDevPath->LocalIpAddress.Addr[10],\r | |
1172 | (UINTN) IPDevPath->LocalIpAddress.Addr[11],\r | |
1173 | (UINTN) IPDevPath->LocalIpAddress.Addr[12],\r | |
1174 | (UINTN) IPDevPath->LocalIpAddress.Addr[13],\r | |
1175 | (UINTN) IPDevPath->LocalIpAddress.Addr[14],\r | |
1176 | (UINTN) IPDevPath->LocalIpAddress.Addr[15]\r | |
1177 | );\r | |
1178 | }\r | |
1179 | \r | |
1180 | /**\r | |
1181 | Converts an Infini Band device path structure to its string representative.\r | |
1182 | \r | |
1183 | @param Str The string representative of input device.\r | |
1184 | @param DevPath The input device path structure.\r | |
1185 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1186 | of the display node is used, where applicable. If DisplayOnly\r | |
1187 | is FALSE, then the longer text representation of the display node\r | |
1188 | is used.\r | |
1189 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1190 | representation for a device node can be used, where applicable.\r | |
1191 | \r | |
1192 | **/\r | |
1193 | VOID\r | |
1194 | DevPathToTextInfiniBand (\r | |
1195 | IN OUT POOL_PRINT *Str,\r | |
1196 | IN VOID *DevPath,\r | |
1197 | IN BOOLEAN DisplayOnly,\r | |
1198 | IN BOOLEAN AllowShortcuts\r | |
1199 | )\r | |
1200 | {\r | |
1201 | INFINIBAND_DEVICE_PATH *InfiniBand;\r | |
1202 | \r | |
1203 | InfiniBand = DevPath;\r | |
1204 | CatPrint (\r | |
1205 | Str,\r | |
1206 | L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",\r | |
1207 | (UINTN) InfiniBand->ResourceFlags,\r | |
1208 | InfiniBand->PortGid,\r | |
1209 | InfiniBand->ServiceId,\r | |
1210 | InfiniBand->TargetPortId,\r | |
1211 | InfiniBand->DeviceId\r | |
1212 | );\r | |
1213 | }\r | |
1214 | \r | |
1215 | /**\r | |
1216 | Converts a UART device path structure to its string representative.\r | |
1217 | \r | |
1218 | @param Str The string representative of input device.\r | |
1219 | @param DevPath The input device path structure.\r | |
1220 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1221 | of the display node is used, where applicable. If DisplayOnly\r | |
1222 | is FALSE, then the longer text representation of the display node\r | |
1223 | is used.\r | |
1224 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1225 | representation for a device node can be used, where applicable.\r | |
1226 | \r | |
1227 | **/\r | |
1228 | VOID\r | |
1229 | DevPathToTextUart (\r | |
1230 | IN OUT POOL_PRINT *Str,\r | |
1231 | IN VOID *DevPath,\r | |
1232 | IN BOOLEAN DisplayOnly,\r | |
1233 | IN BOOLEAN AllowShortcuts\r | |
1234 | )\r | |
1235 | {\r | |
1236 | UART_DEVICE_PATH *Uart;\r | |
1237 | CHAR8 Parity;\r | |
1238 | \r | |
1239 | Uart = DevPath;\r | |
1240 | switch (Uart->Parity) {\r | |
1241 | case 0:\r | |
1242 | Parity = 'D';\r | |
1243 | break;\r | |
1244 | \r | |
1245 | case 1:\r | |
1246 | Parity = 'N';\r | |
1247 | break;\r | |
1248 | \r | |
1249 | case 2:\r | |
1250 | Parity = 'E';\r | |
1251 | break;\r | |
1252 | \r | |
1253 | case 3:\r | |
1254 | Parity = 'O';\r | |
1255 | break;\r | |
1256 | \r | |
1257 | case 4:\r | |
1258 | Parity = 'M';\r | |
1259 | break;\r | |
1260 | \r | |
1261 | case 5:\r | |
1262 | Parity = 'S';\r | |
1263 | break;\r | |
1264 | \r | |
1265 | default:\r | |
1266 | Parity = 'x';\r | |
1267 | break;\r | |
1268 | }\r | |
1269 | \r | |
1270 | if (Uart->BaudRate == 0) {\r | |
1271 | CatPrint (Str, L"Uart(DEFAULT,");\r | |
1272 | } else {\r | |
1273 | CatPrint (Str, L"Uart(%ld,", Uart->BaudRate);\r | |
1274 | }\r | |
1275 | \r | |
1276 | if (Uart->DataBits == 0) {\r | |
1277 | CatPrint (Str, L"DEFAULT,");\r | |
1278 | } else {\r | |
1279 | CatPrint (Str, L"%d,", (UINTN) Uart->DataBits);\r | |
1280 | }\r | |
1281 | \r | |
1282 | CatPrint (Str, L"%c,", Parity);\r | |
1283 | \r | |
1284 | switch (Uart->StopBits) {\r | |
1285 | case 0:\r | |
1286 | CatPrint (Str, L"D)");\r | |
1287 | break;\r | |
1288 | \r | |
1289 | case 1:\r | |
1290 | CatPrint (Str, L"1)");\r | |
1291 | break;\r | |
1292 | \r | |
1293 | case 2:\r | |
1294 | CatPrint (Str, L"1.5)");\r | |
1295 | break;\r | |
1296 | \r | |
1297 | case 3:\r | |
1298 | CatPrint (Str, L"2)");\r | |
1299 | break;\r | |
1300 | \r | |
1301 | default:\r | |
1302 | CatPrint (Str, L"x)");\r | |
1303 | break;\r | |
1304 | }\r | |
1305 | }\r | |
1306 | \r | |
1307 | /**\r | |
1308 | Converts an iSCSI device path structure to its string representative.\r | |
1309 | \r | |
1310 | @param Str The string representative of input device.\r | |
1311 | @param DevPath The input device path structure.\r | |
1312 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1313 | of the display node is used, where applicable. If DisplayOnly\r | |
1314 | is FALSE, then the longer text representation of the display node\r | |
1315 | is used.\r | |
1316 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1317 | representation for a device node can be used, where applicable.\r | |
1318 | \r | |
1319 | **/\r | |
1320 | VOID\r | |
1321 | DevPathToTextiSCSI (\r | |
1322 | IN OUT POOL_PRINT *Str,\r | |
1323 | IN VOID *DevPath,\r | |
1324 | IN BOOLEAN DisplayOnly,\r | |
1325 | IN BOOLEAN AllowShortcuts\r | |
1326 | )\r | |
1327 | {\r | |
1328 | ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r | |
1329 | UINT16 Options;\r | |
1330 | \r | |
1331 | ISCSIDevPath = DevPath;\r | |
1332 | CatPrint (\r | |
1333 | Str,\r | |
1334 | L"iSCSI(%a,0x%x,0x%lx,",\r | |
1335 | ISCSIDevPath->TargetName,\r | |
1336 | (UINTN) ISCSIDevPath->TargetPortalGroupTag,\r | |
1337 | ISCSIDevPath->Lun\r | |
1338 | );\r | |
1339 | \r | |
1340 | Options = ISCSIDevPath->LoginOption;\r | |
1341 | CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r | |
1342 | CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r | |
1343 | if (((Options >> 11) & 0x0001) != 0) {\r | |
1344 | CatPrint (Str, L"%s,", L"None");\r | |
1345 | } else if (((Options >> 12) & 0x0001) != 0) {\r | |
1346 | CatPrint (Str, L"%s,", L"CHAP_UNI");\r | |
1347 | } else {\r | |
1348 | CatPrint (Str, L"%s,", L"CHAP_BI");\r | |
1349 | \r | |
1350 | }\r | |
1351 | \r | |
1352 | CatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r | |
1353 | }\r | |
1354 | \r | |
1355 | /**\r | |
1356 | Converts a VLAN device path structure to its string representative.\r | |
1357 | \r | |
1358 | @param Str The string representative of input device.\r | |
1359 | @param DevPath The input device path structure.\r | |
1360 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1361 | of the display node is used, where applicable. If DisplayOnly\r | |
1362 | is FALSE, then the longer text representation of the display node\r | |
1363 | is used.\r | |
1364 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1365 | representation for a device node can be used, where applicable.\r | |
1366 | \r | |
1367 | **/\r | |
1368 | VOID\r | |
1369 | DevPathToTextVlan (\r | |
1370 | IN OUT POOL_PRINT *Str,\r | |
1371 | IN VOID *DevPath,\r | |
1372 | IN BOOLEAN DisplayOnly,\r | |
1373 | IN BOOLEAN AllowShortcuts\r | |
1374 | )\r | |
1375 | {\r | |
1376 | VLAN_DEVICE_PATH *Vlan;\r | |
1377 | \r | |
1378 | Vlan = DevPath;\r | |
1379 | CatPrint (Str, L"Vlan(%d)", (UINTN) Vlan->VlanId);\r | |
1380 | }\r | |
1381 | \r | |
1382 | /**\r | |
1383 | Converts a Hard drive device path structure to its string representative.\r | |
1384 | \r | |
1385 | @param Str The string representative of input device.\r | |
1386 | @param DevPath The input device path structure.\r | |
1387 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1388 | of the display node is used, where applicable. If DisplayOnly\r | |
1389 | is FALSE, then the longer text representation of the display node\r | |
1390 | is used.\r | |
1391 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1392 | representation for a device node can be used, where applicable.\r | |
1393 | \r | |
1394 | **/\r | |
1395 | VOID\r | |
1396 | DevPathToTextHardDrive (\r | |
1397 | IN OUT POOL_PRINT *Str,\r | |
1398 | IN VOID *DevPath,\r | |
1399 | IN BOOLEAN DisplayOnly,\r | |
1400 | IN BOOLEAN AllowShortcuts\r | |
1401 | )\r | |
1402 | {\r | |
1403 | HARDDRIVE_DEVICE_PATH *Hd;\r | |
1404 | \r | |
1405 | Hd = DevPath;\r | |
1406 | switch (Hd->SignatureType) {\r | |
1407 | case SIGNATURE_TYPE_MBR:\r | |
1408 | CatPrint (\r | |
1409 | Str,\r | |
1410 | L"HD(%d,%s,0x%08x,",\r | |
1411 | (UINTN) Hd->PartitionNumber,\r | |
1412 | L"MBR",\r | |
1413 | (UINTN) *((UINT32 *) (&(Hd->Signature[0])))\r | |
1414 | );\r | |
1415 | break;\r | |
1416 | \r | |
1417 | case SIGNATURE_TYPE_GUID:\r | |
1418 | CatPrint (\r | |
1419 | Str,\r | |
1420 | L"HD(%d,%s,%g,",\r | |
1421 | (UINTN) Hd->PartitionNumber,\r | |
1422 | L"GPT",\r | |
1423 | (EFI_GUID *) &(Hd->Signature[0])\r | |
1424 | );\r | |
1425 | break;\r | |
1426 | \r | |
1427 | default:\r | |
1428 | CatPrint (\r | |
1429 | Str,\r | |
1430 | L"HD(%d,%d,0,",\r | |
1431 | (UINTN) Hd->PartitionNumber,\r | |
1432 | (UINTN) Hd->SignatureType\r | |
1433 | );\r | |
1434 | break;\r | |
1435 | }\r | |
1436 | \r | |
1437 | CatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);\r | |
1438 | }\r | |
1439 | \r | |
1440 | /**\r | |
1441 | Converts a CDROM device path structure to its string representative.\r | |
1442 | \r | |
1443 | @param Str The string representative of input device.\r | |
1444 | @param DevPath The input device path structure.\r | |
1445 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1446 | of the display node is used, where applicable. If DisplayOnly\r | |
1447 | is FALSE, then the longer text representation of the display node\r | |
1448 | is used.\r | |
1449 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1450 | representation for a device node can be used, where applicable.\r | |
1451 | \r | |
1452 | **/\r | |
1453 | VOID\r | |
1454 | DevPathToTextCDROM (\r | |
1455 | IN OUT POOL_PRINT *Str,\r | |
1456 | IN VOID *DevPath,\r | |
1457 | IN BOOLEAN DisplayOnly,\r | |
1458 | IN BOOLEAN AllowShortcuts\r | |
1459 | )\r | |
1460 | {\r | |
1461 | CDROM_DEVICE_PATH *Cd;\r | |
1462 | \r | |
1463 | Cd = DevPath;\r | |
1464 | if (DisplayOnly) {\r | |
1465 | CatPrint (Str, L"CDROM(0x%x)", (UINTN) Cd->BootEntry);\r | |
1466 | return ;\r | |
1467 | }\r | |
1468 | \r | |
1469 | CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", (UINTN) Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r | |
1470 | }\r | |
1471 | \r | |
1472 | /**\r | |
1473 | Converts a File device path structure to its string representative.\r | |
1474 | \r | |
1475 | @param Str The string representative of input device.\r | |
1476 | @param DevPath The input device path structure.\r | |
1477 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1478 | of the display node is used, where applicable. If DisplayOnly\r | |
1479 | is FALSE, then the longer text representation of the display node\r | |
1480 | is used.\r | |
1481 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1482 | representation for a device node can be used, where applicable.\r | |
1483 | \r | |
1484 | **/\r | |
1485 | VOID\r | |
1486 | DevPathToTextFilePath (\r | |
1487 | IN OUT POOL_PRINT *Str,\r | |
1488 | IN VOID *DevPath,\r | |
1489 | IN BOOLEAN DisplayOnly,\r | |
1490 | IN BOOLEAN AllowShortcuts\r | |
1491 | )\r | |
1492 | {\r | |
1493 | FILEPATH_DEVICE_PATH *Fp;\r | |
1494 | \r | |
1495 | Fp = DevPath;\r | |
1496 | CatPrint (Str, L"%s", Fp->PathName);\r | |
1497 | }\r | |
1498 | \r | |
1499 | /**\r | |
1500 | Converts a Media protocol device path structure to its string representative.\r | |
1501 | \r | |
1502 | @param Str The string representative of input device.\r | |
1503 | @param DevPath The input device path structure.\r | |
1504 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1505 | of the display node is used, where applicable. If DisplayOnly\r | |
1506 | is FALSE, then the longer text representation of the display node\r | |
1507 | is used.\r | |
1508 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1509 | representation for a device node can be used, where applicable.\r | |
1510 | \r | |
1511 | **/\r | |
1512 | VOID\r | |
1513 | DevPathToTextMediaProtocol (\r | |
1514 | IN OUT POOL_PRINT *Str,\r | |
1515 | IN VOID *DevPath,\r | |
1516 | IN BOOLEAN DisplayOnly,\r | |
1517 | IN BOOLEAN AllowShortcuts\r | |
1518 | )\r | |
1519 | {\r | |
1520 | MEDIA_PROTOCOL_DEVICE_PATH *MediaProt;\r | |
1521 | \r | |
1522 | MediaProt = DevPath;\r | |
1523 | CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r | |
1524 | }\r | |
1525 | \r | |
1526 | /**\r | |
1527 | Converts a Firmware Volume device path structure to its string representative.\r | |
1528 | \r | |
1529 | @param Str The string representative of input device.\r | |
1530 | @param DevPath The input device path structure.\r | |
1531 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1532 | of the display node is used, where applicable. If DisplayOnly\r | |
1533 | is FALSE, then the longer text representation of the display node\r | |
1534 | is used.\r | |
1535 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1536 | representation for a device node can be used, where applicable.\r | |
1537 | \r | |
1538 | **/\r | |
1539 | VOID\r | |
1540 | DevPathToTextFv (\r | |
1541 | IN OUT POOL_PRINT *Str,\r | |
1542 | IN VOID *DevPath,\r | |
1543 | IN BOOLEAN DisplayOnly,\r | |
1544 | IN BOOLEAN AllowShortcuts\r | |
1545 | )\r | |
1546 | {\r | |
1547 | MEDIA_FW_VOL_DEVICE_PATH *Fv;\r | |
1548 | \r | |
1549 | Fv = DevPath;\r | |
1550 | CatPrint (Str, L"Fv(%g)", &Fv->FvName);\r | |
1551 | }\r | |
1552 | \r | |
1553 | /**\r | |
1554 | Converts a Firmware Volume File device path structure to its string representative.\r | |
1555 | \r | |
1556 | @param Str The string representative of input device.\r | |
1557 | @param DevPath The input device path structure.\r | |
1558 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1559 | of the display node is used, where applicable. If DisplayOnly\r | |
1560 | is FALSE, then the longer text representation of the display node\r | |
1561 | is used.\r | |
1562 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1563 | representation for a device node can be used, where applicable.\r | |
1564 | \r | |
1565 | **/\r | |
1566 | VOID\r | |
1567 | DevPathToTextFvFile (\r | |
1568 | IN OUT POOL_PRINT *Str,\r | |
1569 | IN VOID *DevPath,\r | |
1570 | IN BOOLEAN DisplayOnly,\r | |
1571 | IN BOOLEAN AllowShortcuts\r | |
1572 | )\r | |
1573 | {\r | |
1574 | MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;\r | |
1575 | \r | |
1576 | FvFile = DevPath;\r | |
1577 | CatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);\r | |
1578 | }\r | |
1579 | \r | |
1580 | /**\r | |
1581 | Converts a Relative Offset device path structure to its string representative.\r | |
1582 | \r | |
1583 | @param Str The string representative of input device.\r | |
1584 | @param DevPath The input device path structure.\r | |
1585 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1586 | of the display node is used, where applicable. If DisplayOnly\r | |
1587 | is FALSE, then the longer text representation of the display node\r | |
1588 | is used.\r | |
1589 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1590 | representation for a device node can be used, where applicable.\r | |
1591 | \r | |
1592 | **/\r | |
1593 | VOID\r | |
1594 | DevPathRelativeOffsetRange (\r | |
1595 | IN OUT POOL_PRINT *Str,\r | |
1596 | IN VOID *DevPath,\r | |
1597 | IN BOOLEAN DisplayOnly,\r | |
1598 | IN BOOLEAN AllowShortcuts\r | |
1599 | )\r | |
1600 | {\r | |
1601 | MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r | |
1602 | \r | |
1603 | Offset = DevPath;\r | |
1604 | CatPrint (\r | |
1605 | Str,\r | |
1606 | L"Offset(0x%lx,0x%lx)",\r | |
1607 | Offset->StartingOffset,\r | |
1608 | Offset->EndingOffset\r | |
1609 | );\r | |
1610 | }\r | |
1611 | \r | |
1612 | /**\r | |
1613 | Converts a BIOS Boot Specification device path structure to its string representative.\r | |
1614 | \r | |
1615 | @param Str The string representative of input device.\r | |
1616 | @param DevPath The input device path structure.\r | |
1617 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1618 | of the display node is used, where applicable. If DisplayOnly\r | |
1619 | is FALSE, then the longer text representation of the display node\r | |
1620 | is used.\r | |
1621 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1622 | representation for a device node can be used, where applicable.\r | |
1623 | \r | |
1624 | **/\r | |
1625 | VOID\r | |
1626 | DevPathToTextBBS (\r | |
1627 | IN OUT POOL_PRINT *Str,\r | |
1628 | IN VOID *DevPath,\r | |
1629 | IN BOOLEAN DisplayOnly,\r | |
1630 | IN BOOLEAN AllowShortcuts\r | |
1631 | )\r | |
1632 | {\r | |
1633 | BBS_BBS_DEVICE_PATH *Bbs;\r | |
1634 | CHAR16 *Type;\r | |
1635 | \r | |
1636 | Bbs = DevPath;\r | |
1637 | switch (Bbs->DeviceType) {\r | |
1638 | case BBS_TYPE_FLOPPY:\r | |
1639 | Type = L"Floppy";\r | |
1640 | break;\r | |
1641 | \r | |
1642 | case BBS_TYPE_HARDDRIVE:\r | |
1643 | Type = L"HD";\r | |
1644 | break;\r | |
1645 | \r | |
1646 | case BBS_TYPE_CDROM:\r | |
1647 | Type = L"CDROM";\r | |
1648 | break;\r | |
1649 | \r | |
1650 | case BBS_TYPE_PCMCIA:\r | |
1651 | Type = L"PCMCIA";\r | |
1652 | break;\r | |
1653 | \r | |
1654 | case BBS_TYPE_USB:\r | |
1655 | Type = L"USB";\r | |
1656 | break;\r | |
1657 | \r | |
1658 | case BBS_TYPE_EMBEDDED_NETWORK:\r | |
1659 | Type = L"Network";\r | |
1660 | break;\r | |
1661 | \r | |
1662 | default:\r | |
1663 | Type = NULL;\r | |
1664 | break;\r | |
1665 | }\r | |
1666 | \r | |
1667 | if (Type != NULL) {\r | |
1668 | CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r | |
1669 | } else {\r | |
1670 | CatPrint (Str, L"BBS(0x%x,%a", (UINTN) Bbs->DeviceType, Bbs->String);\r | |
1671 | }\r | |
1672 | \r | |
1673 | if (DisplayOnly) {\r | |
1674 | CatPrint (Str, L")");\r | |
1675 | return ;\r | |
1676 | }\r | |
1677 | \r | |
1678 | CatPrint (Str, L",0x%x)", (UINTN) Bbs->StatusFlag);\r | |
1679 | }\r | |
1680 | \r | |
1681 | /**\r | |
1682 | Converts an End-of-Device-Path structure to its string representative.\r | |
1683 | \r | |
1684 | @param Str The string representative of input device.\r | |
1685 | @param DevPath The input device path structure.\r | |
1686 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1687 | of the display node is used, where applicable. If DisplayOnly\r | |
1688 | is FALSE, then the longer text representation of the display node\r | |
1689 | is used.\r | |
1690 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1691 | representation for a device node can be used, where applicable.\r | |
1692 | \r | |
1693 | **/\r | |
1694 | VOID\r | |
1695 | DevPathToTextEndInstance (\r | |
1696 | IN OUT POOL_PRINT *Str,\r | |
1697 | IN VOID *DevPath,\r | |
1698 | IN BOOLEAN DisplayOnly,\r | |
1699 | IN BOOLEAN AllowShortcuts\r | |
1700 | )\r | |
1701 | {\r | |
1702 | CatPrint (Str, L",");\r | |
1703 | }\r | |
1704 | \r | |
1705 | /**\r | |
1706 | Converts an unknown device path structure to its string representative.\r | |
1707 | \r | |
1708 | @param Str The string representative of input device.\r | |
1709 | @param DevPath The input device path structure.\r | |
1710 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1711 | of the display node is used, where applicable. If DisplayOnly\r | |
1712 | is FALSE, then the longer text representation of the display node\r | |
1713 | is used.\r | |
1714 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1715 | representation for a device node can be used, where applicable.\r | |
1716 | \r | |
1717 | **/\r | |
1718 | VOID\r | |
1719 | DevPathToTextNodeUnknown (\r | |
1720 | IN OUT POOL_PRINT *Str,\r | |
1721 | IN VOID *DevPath,\r | |
1722 | IN BOOLEAN DisplayOnly,\r | |
1723 | IN BOOLEAN AllowShortcuts\r | |
1724 | )\r | |
1725 | {\r | |
1726 | CatPrint (Str, L"?");\r | |
1727 | }\r | |
1728 | \r | |
1729 | GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable[] = {\r | |
1730 | {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci},\r | |
1731 | {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard},\r | |
1732 | {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap},\r | |
1733 | {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor},\r | |
1734 | {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController},\r | |
1735 | {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi},\r | |
1736 | {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx},\r | |
1737 | {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr},\r | |
1738 | {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi},\r | |
1739 | {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi},\r | |
1740 | {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre},\r | |
1741 | {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394},\r | |
1742 | {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb},\r | |
1743 | {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID},\r | |
1744 | {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit},\r | |
1745 | {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass},\r | |
1746 | {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata},\r | |
1747 | {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O},\r | |
1748 | {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr},\r | |
1749 | {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4},\r | |
1750 | {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6},\r | |
1751 | {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand},\r | |
1752 | {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart},\r | |
1753 | {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor},\r | |
1754 | {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI},\r | |
1755 | {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan},\r | |
1756 | {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive},\r | |
1757 | {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM},\r | |
1758 | {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor},\r | |
1759 | {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol},\r | |
1760 | {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r | |
1761 | {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv},\r | |
1762 | {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile},\r | |
1763 | {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange},\r | |
1764 | {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS},\r | |
1765 | {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance},\r | |
1766 | {0, 0, NULL}\r | |
1767 | };\r | |
1768 | \r | |
1769 | /**\r | |
1770 | Converts a device node to its string representation.\r | |
1771 | \r | |
1772 | @param DeviceNode A Pointer to the device node to be converted.\r | |
1773 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1774 | of the display node is used, where applicable. If DisplayOnly\r | |
1775 | is FALSE, then the longer text representation of the display node\r | |
1776 | is used.\r | |
1777 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1778 | representation for a device node can be used, where applicable.\r | |
1779 | \r | |
1780 | @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r | |
1781 | is NULL or there was insufficient memory.\r | |
1782 | \r | |
1783 | **/\r | |
1784 | CHAR16 *\r | |
1785 | EFIAPI\r | |
1786 | ConvertDeviceNodeToText (\r | |
1787 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r | |
1788 | IN BOOLEAN DisplayOnly,\r | |
1789 | IN BOOLEAN AllowShortcuts\r | |
1790 | )\r | |
1791 | {\r | |
1792 | POOL_PRINT Str;\r | |
1793 | UINTN Index;\r | |
1794 | UINTN NewSize;\r | |
1795 | VOID (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r | |
1796 | \r | |
1797 | if (DeviceNode == NULL) {\r | |
1798 | return NULL;\r | |
1799 | }\r | |
1800 | \r | |
1801 | ZeroMem (&Str, sizeof (Str));\r | |
1802 | \r | |
1803 | //\r | |
1804 | // Process the device path node\r | |
1805 | //\r | |
1806 | DumpNode = NULL;\r | |
1807 | for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index++) {\r | |
1808 | if (DevicePathType (DeviceNode) == DevPathToTextTable[Index].Type &&\r | |
1809 | DevicePathSubType (DeviceNode) == DevPathToTextTable[Index].SubType\r | |
1810 | ) {\r | |
1811 | DumpNode = DevPathToTextTable[Index].Function;\r | |
1812 | break;\r | |
1813 | }\r | |
1814 | }\r | |
1815 | //\r | |
1816 | // If not found, use a generic function\r | |
1817 | //\r | |
1818 | if (DumpNode == NULL) {\r | |
1819 | DumpNode = DevPathToTextNodeUnknown;\r | |
1820 | }\r | |
1821 | \r | |
1822 | //\r | |
1823 | // Print this node\r | |
1824 | //\r | |
1825 | DumpNode (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r | |
1826 | \r | |
1827 | //\r | |
1828 | // Shrink pool used for string allocation\r | |
1829 | //\r | |
1830 | NewSize = (Str.Len + 1) * sizeof (CHAR16);\r | |
1831 | Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r | |
1832 | ASSERT (Str.Str != NULL);\r | |
1833 | Str.Str[Str.Len] = 0;\r | |
1834 | return Str.Str;\r | |
1835 | }\r | |
1836 | \r | |
1837 | /**\r | |
1838 | Converts a device path to its text representation.\r | |
1839 | \r | |
1840 | @param DevicePath A Pointer to the device to be converted.\r | |
1841 | @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r | |
1842 | of the display node is used, where applicable. If DisplayOnly\r | |
1843 | is FALSE, then the longer text representation of the display node\r | |
1844 | is used.\r | |
1845 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
1846 | representation for a device node can be used, where applicable.\r | |
1847 | \r | |
1848 | @return A pointer to the allocated text representation of the device path or\r | |
1849 | NULL if DeviceNode is NULL or there was insufficient memory.\r | |
1850 | \r | |
1851 | **/\r | |
1852 | CHAR16 *\r | |
1853 | EFIAPI\r | |
1854 | ConvertDevicePathToText (\r | |
1855 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
1856 | IN BOOLEAN DisplayOnly,\r | |
1857 | IN BOOLEAN AllowShortcuts\r | |
1858 | )\r | |
1859 | {\r | |
1860 | POOL_PRINT Str;\r | |
1861 | EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r | |
1862 | EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode;\r | |
1863 | UINTN Index;\r | |
1864 | UINTN NewSize;\r | |
1865 | VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r | |
1866 | \r | |
1867 | if (DevicePath == NULL) {\r | |
1868 | return NULL;\r | |
1869 | }\r | |
1870 | \r | |
1871 | ZeroMem (&Str, sizeof (Str));\r | |
1872 | \r | |
1873 | //\r | |
1874 | // Process each device path node\r | |
1875 | //\r | |
1876 | DevPathNode = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;\r | |
1877 | while (!IsDevicePathEnd (DevPathNode)) {\r | |
1878 | //\r | |
1879 | // Find the handler to dump this device path node\r | |
1880 | //\r | |
1881 | DumpNode = NULL;\r | |
1882 | for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index += 1) {\r | |
1883 | \r | |
1884 | if (DevicePathType (DevPathNode) == DevPathToTextTable[Index].Type &&\r | |
1885 | DevicePathSubType (DevPathNode) == DevPathToTextTable[Index].SubType\r | |
1886 | ) {\r | |
1887 | DumpNode = DevPathToTextTable[Index].Function;\r | |
1888 | break;\r | |
1889 | }\r | |
1890 | }\r | |
1891 | //\r | |
1892 | // If not found, use a generic function\r | |
1893 | //\r | |
1894 | if (!DumpNode) {\r | |
1895 | DumpNode = DevPathToTextNodeUnknown;\r | |
1896 | }\r | |
1897 | //\r | |
1898 | // Put a path separator in if needed\r | |
1899 | //\r | |
1900 | if ((Str.Len != 0) && DumpNode != DevPathToTextEndInstance) {\r | |
1901 | if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') {\r | |
1902 | CatPrint (&Str, L"/");\r | |
1903 | }\r | |
1904 | }\r | |
1905 | \r | |
1906 | AlignedDevPathNode = AllocateCopyPool (DevicePathNodeLength (DevPathNode), DevPathNode);\r | |
1907 | //\r | |
1908 | // Print this node of the device path\r | |
1909 | //\r | |
1910 | DumpNode (&Str, AlignedDevPathNode, DisplayOnly, AllowShortcuts);\r | |
1911 | FreePool (AlignedDevPathNode);\r | |
1912 | \r | |
1913 | //\r | |
1914 | // Next device path node\r | |
1915 | //\r | |
1916 | DevPathNode = NextDevicePathNode (DevPathNode);\r | |
1917 | }\r | |
1918 | \r | |
1919 | NewSize = (Str.Len + 1) * sizeof (CHAR16);\r | |
1920 | Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r | |
1921 | ASSERT (Str.Str != NULL);\r | |
1922 | Str.Str[Str.Len] = 0;\r | |
1923 | return Str.Str;\r | |
1924 | }\r |