]>
Commit | Line | Data |
---|---|---|
13d40edd | 1 | /** @file\r |
2 | DevicePathToText protocol as defined in the UEFI 2.0 specification.\r | |
95276127 | 3 | \r |
e5eed7d3 HT |
4 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials\r | |
13d40edd | 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 | |
95276127 | 9 | \r |
13d40edd | 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 | |
95276127 | 12 | \r |
13d40edd | 13 | **/\r |
95276127 | 14 | \r |
95276127 | 15 | #include "DevicePath.h"\r |
16 | \r | |
572f5d8a | 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 | |
95276127 | 31 | CHAR16 *\r |
8091267c | 32 | EFIAPI\r |
95276127 | 33 | CatPrint (\r |
34 | IN OUT POOL_PRINT *Str,\r | |
35 | IN CHAR16 *Fmt,\r | |
36 | ...\r | |
37 | )\r | |
95276127 | 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 | |
572f5d8a | 56 | Size = StrSize (AppendStr) - sizeof (UINT16);\r |
95276127 | 57 | Size = Size + StrSize (Str->Str);\r |
58 | Str->Str = ReallocatePool (\r | |
48557c65 | 59 | StrSize (Str->Str),\r |
60 | Size,\r | |
61 | Str->Str\r | |
62 | );\r | |
95276127 | 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 | |
572f5d8a | 76 | /**\r |
48557c65 | 77 | Converts a PCI device path structure to its string representative.\r |
572f5d8a | 78 | \r |
48557c65 | 79 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
186ca8b0 | 100 | CatPrint (Str, L"Pci(0x%x,0x%x)", (UINTN) Pci->Device, (UINTN) Pci->Function);\r |
95276127 | 101 | }\r |
102 | \r | |
572f5d8a | 103 | /**\r |
48557c65 | 104 | Converts a PC Card device path structure to its string representative.\r |
572f5d8a | 105 | \r |
48557c65 | 106 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
186ca8b0 | 127 | CatPrint (Str, L"PcCard(0x%x)", (UINTN) Pccard->FunctionNumber);\r |
95276127 | 128 | }\r |
129 | \r | |
572f5d8a | 130 | /**\r |
48557c65 | 131 | Converts a Memory Map device path structure to its string representative.\r |
572f5d8a | 132 | \r |
48557c65 | 133 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
cf40f28a | 156 | L"MemoryMapped(0x%x,0x%lx,0x%lx)",\r |
186ca8b0 | 157 | (UINTN) MemMap->MemoryType,\r |
95276127 | 158 | MemMap->StartingAddress,\r |
159 | MemMap->EndingAddress\r | |
160 | );\r | |
161 | }\r | |
162 | \r | |
572f5d8a | 163 | /**\r |
48557c65 | 164 | Converts a Vendor device path structure to its string representative.\r |
572f5d8a | 165 | \r |
48557c65 | 166 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
cf40f28a | 187 | UINTN DataLength;\r |
95276127 | 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 | |
48557c65 | 212 | } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) {\r |
95276127 | 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 | |
48557c65 | 232 | } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {\r |
95276127 | 233 | CatPrint (\r |
234 | Str,\r | |
cf40f28a | 235 | L"SAS(0x%lx,0x%lx,0x%x,",\r |
95276127 | 236 | ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r |
237 | ((SAS_DEVICE_PATH *) Vendor)->Lun,\r | |
186ca8b0 | 238 | (UINTN) ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r |
95276127 | 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 | |
572f5d8a | 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 | |
95276127 | 250 | );\r |
251 | if ((Info & 0x0f) == 1) {\r | |
252 | CatPrint (Str, L"0,");\r | |
253 | } else {\r | |
186ca8b0 | 254 | CatPrint (Str, L"0x%x,",(UINTN) (Info >> 8) & 0xff);\r |
95276127 | 255 | }\r |
256 | } else {\r | |
257 | CatPrint (Str, L"0,0,0,0,");\r | |
258 | }\r | |
259 | \r | |
186ca8b0 | 260 | CatPrint (Str, L"0x%x)", (UINTN) ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r |
95276127 | 261 | return ;\r |
262 | } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r | |
263 | CatPrint (Str, L"DebugPort()");\r | |
264 | return ;\r | |
95276127 | 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 | |
cf40f28a | 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 | |
186ca8b0 | 283 | CatPrint (Str, L"%02x", (UINTN) ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r |
cf40f28a | 284 | }\r |
95276127 | 285 | }\r |
286 | \r | |
287 | CatPrint (Str, L")");\r | |
288 | }\r | |
289 | \r | |
572f5d8a | 290 | /**\r |
48557c65 | 291 | Converts a Controller device path structure to its string representative.\r |
572f5d8a | 292 | \r |
48557c65 | 293 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
cf40f28a | 316 | L"Ctrl(0x%x)",\r |
186ca8b0 | 317 | (UINTN) Controller->ControllerNumber\r |
95276127 | 318 | );\r |
319 | }\r | |
320 | \r | |
572f5d8a | 321 | /**\r |
48557c65 | 322 | Converts a ACPI device path structure to its string representative.\r |
572f5d8a | 323 | \r |
48557c65 | 324 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
cf40f28a | 346 | switch (EISA_ID_TO_NUM (Acpi->HID)) {\r |
347 | case 0x0a03:\r | |
186ca8b0 | 348 | CatPrint (Str, L"PciRoot(0x%x)", (UINTN) Acpi->UID);\r |
cf40f28a | 349 | break;\r |
95276127 | 350 | \r |
cf40f28a | 351 | case 0x0604:\r |
186ca8b0 | 352 | CatPrint (Str, L"Floppy(0x%x)", (UINTN) Acpi->UID);\r |
cf40f28a | 353 | break;\r |
95276127 | 354 | \r |
cf40f28a | 355 | case 0x0301:\r |
186ca8b0 | 356 | CatPrint (Str, L"Keyboard(0x%x)", (UINTN) Acpi->UID);\r |
cf40f28a | 357 | break;\r |
95276127 | 358 | \r |
cf40f28a | 359 | case 0x0501:\r |
186ca8b0 | 360 | CatPrint (Str, L"Serial(0x%x)", (UINTN) Acpi->UID);\r |
cf40f28a | 361 | break;\r |
95276127 | 362 | \r |
cf40f28a | 363 | case 0x0401:\r |
186ca8b0 | 364 | CatPrint (Str, L"ParallelPort(0x%x)", (UINTN) Acpi->UID);\r |
cf40f28a | 365 | break;\r |
95276127 | 366 | \r |
cf40f28a | 367 | default:\r |
186ca8b0 | 368 | CatPrint (Str, L"Acpi(PNP%04x,0x%x)", (UINTN) EISA_ID_TO_NUM (Acpi->HID), (UINTN) Acpi->UID);\r |
cf40f28a | 369 | break;\r |
95276127 | 370 | }\r |
95276127 | 371 | } else {\r |
186ca8b0 | 372 | CatPrint (Str, L"Acpi(0x%08x,0x%x)", (UINTN) Acpi->HID, (UINTN) Acpi->UID);\r |
95276127 | 373 | }\r |
374 | }\r | |
375 | \r | |
572f5d8a | 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 | |
cf40f28a | 383 | VOID\r |
384 | EisaIdToText (\r | |
385 | IN UINT32 EisaId,\r | |
572f5d8a | 386 | IN OUT CHAR16 *Text\r |
cf40f28a | 387 | )\r |
388 | {\r | |
389 | CHAR16 PnpIdStr[17];\r | |
390 | \r | |
391 | //\r | |
392 | //UnicodeSPrint ("%X", 0x0a03) => "0000000000000A03"\r | |
393 | //\r | |
372285d1 | 394 | UnicodeSPrint (PnpIdStr, 17 * 2, L"%16X", EisaId >> 16);\r |
cf40f28a | 395 | \r |
396 | UnicodeSPrint (\r | |
397 | Text,\r | |
372285d1 | 398 | sizeof (CHAR16) + sizeof (CHAR16) + sizeof (CHAR16) + sizeof (PnpIdStr),\r |
cf40f28a | 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 | |
95276127 | 406 | \r |
572f5d8a | 407 | /**\r |
48557c65 | 408 | Converts a ACPI extended HID device path structure to its string representative.\r |
572f5d8a | 409 | \r |
48557c65 | 410 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 420 | VOID\r |
cf40f28a | 421 | DevPathToTextAcpiEx (\r |
95276127 | 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 | |
cf40f28a | 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 | |
95276127 | 464 | \r |
cf40f28a | 465 | if (AcpiEx->UID == 0) {\r |
466 | CatPrint (Str, L"%a,", UIDStr);\r | |
467 | } else {\r | |
186ca8b0 | 468 | CatPrint (Str, L"0x%x,", (UINTN) AcpiEx->UID);\r |
cf40f28a | 469 | }\r |
95276127 | 470 | \r |
cf40f28a | 471 | if (AcpiEx->CID == 0) {\r |
472 | CatPrint (Str, L"%a)", CIDStr);\r | |
95276127 | 473 | } else {\r |
cf40f28a | 474 | CatPrint (Str, L"%s)", CIDText);\r |
95276127 | 475 | }\r |
cf40f28a | 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 | |
186ca8b0 | 482 | (UINTN) AcpiEx->UID,\r |
cf40f28a | 483 | HIDStr,\r |
484 | CIDStr,\r | |
485 | UIDStr\r | |
486 | );\r | |
95276127 | 487 | }\r |
95276127 | 488 | }\r |
cf40f28a | 489 | }\r |
95276127 | 490 | \r |
572f5d8a | 491 | /**\r |
48557c65 | 492 | Converts a ACPI address device path structure to its string representative.\r |
572f5d8a | 493 | \r |
48557c65 | 494 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
cf40f28a | 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 | |
186ca8b0 | 521 | CatPrint (Str, L"AcpiAdr(0x%x", (UINTN) AcpiAdr->ADR);\r |
cf40f28a | 522 | for (Index = 0; Index < AdditionalAdrCount; Index++) {\r |
186ca8b0 | 523 | CatPrint (Str, L",0x%x", (UINTN) *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r |
95276127 | 524 | }\r |
cf40f28a | 525 | CatPrint (Str, L")");\r |
95276127 | 526 | }\r |
527 | \r | |
572f5d8a | 528 | /**\r |
48557c65 | 529 | Converts a ATAPI device path structure to its string representative.\r |
572f5d8a | 530 | \r |
48557c65 | 531 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
186ca8b0 | 554 | CatPrint (Str, L"Ata(0x%x)", (UINTN) Atapi->Lun);\r |
95276127 | 555 | } else {\r |
556 | CatPrint (\r | |
557 | Str,\r | |
cf40f28a | 558 | L"Ata(%s,%s,0x%x)",\r |
7ae9c1ce | 559 | (Atapi->PrimarySecondary == 1) ? L"Secondary" : L"Primary",\r |
560 | (Atapi->SlaveMaster == 1) ? L"Slave" : L"Master",\r | |
186ca8b0 | 561 | (UINTN) Atapi->Lun\r |
95276127 | 562 | );\r |
563 | }\r | |
564 | }\r | |
565 | \r | |
572f5d8a | 566 | /**\r |
48557c65 | 567 | Converts a SCSI device path structure to its string representative.\r |
572f5d8a | 568 | \r |
48557c65 | 569 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
186ca8b0 | 590 | CatPrint (Str, L"Scsi(0x%x,0x%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun);\r |
95276127 | 591 | }\r |
592 | \r | |
572f5d8a | 593 | /**\r |
48557c65 | 594 | Converts a Fibre device path structure to its string representative.\r |
572f5d8a | 595 | \r |
48557c65 | 596 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
cf40f28a | 617 | CatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);\r |
95276127 | 618 | }\r |
619 | \r | |
572f5d8a | 620 | /**\r |
48557c65 | 621 | Converts a 1394 device path structure to its string representative.\r |
572f5d8a | 622 | \r |
48557c65 | 623 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
572f5d8a | 641 | F1394_DEVICE_PATH *F1394DevPath;\r |
95276127 | 642 | \r |
572f5d8a | 643 | F1394DevPath = DevPath;\r |
cf40f28a | 644 | //\r |
645 | // Guid has format of IEEE-EUI64\r | |
646 | //\r | |
572f5d8a | 647 | CatPrint (Str, L"I1394(%016lx)", F1394DevPath->Guid);\r |
95276127 | 648 | }\r |
649 | \r | |
572f5d8a | 650 | /**\r |
48557c65 | 651 | Converts a USB device path structure to its string representative.\r |
572f5d8a | 652 | \r |
48557c65 | 653 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
cf40f28a | 674 | CatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);\r |
95276127 | 675 | }\r |
676 | \r | |
572f5d8a | 677 | /**\r |
48557c65 | 678 | Converts a USB WWID device path structure to its string representative.\r |
572f5d8a | 679 | \r |
48557c65 | 680 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
cf40f28a | 699 | CHAR16 *SerialNumberStr;\r |
700 | CHAR16 *NewStr;\r | |
701 | UINT16 Length;\r | |
95276127 | 702 | \r |
703 | UsbWWId = DevPath;\r | |
cf40f28a | 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 | |
3069bc19 | 712 | ASSERT (NewStr != NULL);\r |
cf40f28a | 713 | NewStr [Length] = 0;\r |
714 | SerialNumberStr = NewStr;\r | |
715 | }\r | |
716 | \r | |
95276127 | 717 | CatPrint (\r |
718 | Str,\r | |
cf40f28a | 719 | L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",\r |
186ca8b0 | 720 | (UINTN) UsbWWId->VendorId,\r |
721 | (UINTN) UsbWWId->ProductId,\r | |
722 | (UINTN) UsbWWId->InterfaceNumber,\r | |
cf40f28a | 723 | SerialNumberStr\r |
95276127 | 724 | );\r |
725 | }\r | |
726 | \r | |
572f5d8a | 727 | /**\r |
48557c65 | 728 | Converts a Logic Unit device path structure to its string representative.\r |
572f5d8a | 729 | \r |
48557c65 | 730 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
186ca8b0 | 751 | CatPrint (Str, L"Unit(0x%x)", (UINTN) LogicalUnit->Lun);\r |
95276127 | 752 | }\r |
753 | \r | |
572f5d8a | 754 | /**\r |
48557c65 | 755 | Converts a USB class device path structure to its string representative.\r |
572f5d8a | 756 | \r |
48557c65 | 757 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
cf40f28a | 776 | BOOLEAN IsKnownSubClass;\r |
777 | \r | |
95276127 | 778 | \r |
779 | UsbClass = DevPath;\r | |
780 | \r | |
cf40f28a | 781 | IsKnownSubClass = TRUE;\r |
782 | switch (UsbClass->DeviceClass) {\r | |
783 | case USB_CLASS_AUDIO:\r | |
784 | CatPrint (Str, L"UsbAudio");\r | |
785 | break;\r | |
95276127 | 786 | \r |
cf40f28a | 787 | case USB_CLASS_CDCCONTROL:\r |
788 | CatPrint (Str, L"UsbCDCControl");\r | |
789 | break;\r | |
95276127 | 790 | \r |
cf40f28a | 791 | case USB_CLASS_HID:\r |
792 | CatPrint (Str, L"UsbHID");\r | |
793 | break;\r | |
95276127 | 794 | \r |
cf40f28a | 795 | case USB_CLASS_IMAGE:\r |
796 | CatPrint (Str, L"UsbImage");\r | |
797 | break;\r | |
95276127 | 798 | \r |
cf40f28a | 799 | case USB_CLASS_PRINTER:\r |
800 | CatPrint (Str, L"UsbPrinter");\r | |
801 | break;\r | |
95276127 | 802 | \r |
cf40f28a | 803 | case USB_CLASS_MASS_STORAGE:\r |
804 | CatPrint (Str, L"UsbMassStorage");\r | |
805 | break;\r | |
95276127 | 806 | \r |
cf40f28a | 807 | case USB_CLASS_HUB:\r |
808 | CatPrint (Str, L"UsbHub");\r | |
809 | break;\r | |
95276127 | 810 | \r |
cf40f28a | 811 | case USB_CLASS_CDCDATA:\r |
812 | CatPrint (Str, L"UsbCDCData");\r | |
813 | break;\r | |
95276127 | 814 | \r |
cf40f28a | 815 | case USB_CLASS_SMART_CARD:\r |
816 | CatPrint (Str, L"UsbSmartCard");\r | |
817 | break;\r | |
95276127 | 818 | \r |
cf40f28a | 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 | |
186ca8b0 | 840 | (UINTN) UsbClass->VendorId,\r |
841 | (UINTN) UsbClass->ProductId,\r | |
842 | (UINTN) UsbClass->DeviceSubClass,\r | |
843 | (UINTN) UsbClass->DeviceProtocol\r | |
cf40f28a | 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 | |
95276127 | 850 | CatPrint (\r |
851 | Str,\r | |
cf40f28a | 852 | L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",\r |
186ca8b0 | 853 | (UINTN) UsbClass->VendorId,\r |
854 | (UINTN) UsbClass->ProductId,\r | |
855 | (UINTN) UsbClass->DeviceProtocol\r | |
95276127 | 856 | );\r |
cf40f28a | 857 | return;\r |
858 | } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {\r | |
95276127 | 859 | CatPrint (\r |
860 | Str,\r | |
cf40f28a | 861 | L"UsbIrdaBridge(0x%x,0x%x,0x%x)",\r |
186ca8b0 | 862 | (UINTN) UsbClass->VendorId,\r |
863 | (UINTN) UsbClass->ProductId,\r | |
864 | (UINTN) UsbClass->DeviceProtocol\r | |
95276127 | 865 | );\r |
cf40f28a | 866 | return;\r |
867 | } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {\r | |
95276127 | 868 | CatPrint (\r |
869 | Str,\r | |
cf40f28a | 870 | L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",\r |
186ca8b0 | 871 | (UINTN) UsbClass->VendorId,\r |
872 | (UINTN) UsbClass->ProductId,\r | |
873 | (UINTN) UsbClass->DeviceProtocol\r | |
95276127 | 874 | );\r |
cf40f28a | 875 | return;\r |
95276127 | 876 | }\r |
95276127 | 877 | }\r |
878 | \r | |
879 | CatPrint (\r | |
880 | Str,\r | |
cf40f28a | 881 | L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",\r |
186ca8b0 | 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 | |
95276127 | 887 | );\r |
888 | }\r | |
889 | \r | |
572f5d8a | 890 | /**\r |
48557c65 | 891 | Converts a SATA device path structure to its string representative.\r |
572f5d8a | 892 | \r |
48557c65 | 893 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
cf40f28a | 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 | |
4140a663 | 914 | if ((Sata->PortMultiplierPortNumber & SATA_HBA_DIRECT_CONNECT_FLAG) != 0) {\r |
186ca8b0 | 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 | |
cf40f28a | 930 | }\r |
931 | \r | |
572f5d8a | 932 | /**\r |
48557c65 | 933 | Converts a I20 device path structure to its string representative.\r |
572f5d8a | 934 | \r |
48557c65 | 935 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
572f5d8a | 953 | I2O_DEVICE_PATH *I2ODevPath;\r |
95276127 | 954 | \r |
572f5d8a | 955 | I2ODevPath = DevPath;\r |
186ca8b0 | 956 | CatPrint (Str, L"I2O(0x%x)", (UINTN) I2ODevPath->Tid);\r |
95276127 | 957 | }\r |
958 | \r | |
572f5d8a | 959 | /**\r |
48557c65 | 960 | Converts a MAC address device path structure to its string representative.\r |
572f5d8a | 961 | \r |
48557c65 | 962 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
572f5d8a | 980 | MAC_ADDR_DEVICE_PATH *MacDevPath;\r |
95276127 | 981 | UINTN HwAddressSize;\r |
982 | UINTN Index;\r | |
983 | \r | |
572f5d8a | 984 | MacDevPath = DevPath;\r |
95276127 | 985 | \r |
986 | HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r | |
572f5d8a | 987 | if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {\r |
95276127 | 988 | HwAddressSize = 6;\r |
989 | }\r | |
990 | \r | |
991 | CatPrint (Str, L"MAC(");\r | |
992 | \r | |
993 | for (Index = 0; Index < HwAddressSize; Index++) {\r | |
186ca8b0 | 994 | CatPrint (Str, L"%02x", (UINTN) MacDevPath->MacAddress.Addr[Index]);\r |
95276127 | 995 | }\r |
996 | \r | |
186ca8b0 | 997 | CatPrint (Str, L",0x%x)", (UINTN) MacDevPath->IfType);\r |
95276127 | 998 | }\r |
999 | \r | |
052019e1 | 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 | |
572f5d8a | 1022 | /**\r |
48557c65 | 1023 | Converts a IPv4 device path structure to its string representative.\r |
572f5d8a | 1024 | \r |
48557c65 | 1025 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
572f5d8a | 1043 | IPv4_DEVICE_PATH *IPDevPath;\r |
95276127 | 1044 | \r |
572f5d8a | 1045 | IPDevPath = DevPath;\r |
1046 | if (DisplayOnly) {\r | |
95276127 | 1047 | CatPrint (\r |
1048 | Str,\r | |
1049 | L"IPv4(%d.%d.%d.%d)",\r | |
186ca8b0 | 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 | |
95276127 | 1054 | );\r |
1055 | return ;\r | |
1056 | }\r | |
1057 | \r | |
1058 | CatPrint (\r | |
1059 | Str,\r | |
052019e1 | 1060 | L"IPv4(%d.%d.%d.%d,",\r |
186ca8b0 | 1061 | (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r |
1062 | (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r | |
1063 | (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r | |
052019e1 | 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 | |
7ae9c1ce | 1075 | IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r |
186ca8b0 | 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 | |
95276127 | 1080 | );\r |
1081 | }\r | |
1082 | \r | |
572f5d8a | 1083 | /**\r |
48557c65 | 1084 | Converts a IPv6 device path structure to its string representative.\r |
572f5d8a | 1085 | \r |
48557c65 | 1086 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
572f5d8a | 1104 | IPv6_DEVICE_PATH *IPDevPath;\r |
95276127 | 1105 | \r |
572f5d8a | 1106 | IPDevPath = DevPath;\r |
1107 | if (DisplayOnly) {\r | |
95276127 | 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 | |
186ca8b0 | 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 | |
95276127 | 1127 | );\r |
1128 | return ;\r | |
1129 | }\r | |
1130 | \r | |
1131 | CatPrint (\r | |
1132 | Str,\r | |
052019e1 | 1133 | L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,",\r |
186ca8b0 | 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 | |
052019e1 | 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 | |
7ae9c1ce | 1160 | IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r |
186ca8b0 | 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 | |
95276127 | 1177 | );\r |
1178 | }\r | |
1179 | \r | |
572f5d8a | 1180 | /**\r |
48557c65 | 1181 | Converts an Infini Band device path structure to its string representative.\r |
572f5d8a | 1182 | \r |
48557c65 | 1183 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
cf40f28a | 1206 | L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",\r |
186ca8b0 | 1207 | (UINTN) InfiniBand->ResourceFlags,\r |
95276127 | 1208 | InfiniBand->PortGid,\r |
1209 | InfiniBand->ServiceId,\r | |
1210 | InfiniBand->TargetPortId,\r | |
1211 | InfiniBand->DeviceId\r | |
1212 | );\r | |
1213 | }\r | |
1214 | \r | |
572f5d8a | 1215 | /**\r |
48557c65 | 1216 | Converts a UART device path structure to its string representative.\r |
572f5d8a | 1217 | \r |
48557c65 | 1218 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
186ca8b0 | 1279 | CatPrint (Str, L"%d,", (UINTN) Uart->DataBits);\r |
95276127 | 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 | |
572f5d8a | 1307 | /**\r |
48557c65 | 1308 | Converts an iSCSI device path structure to its string representative.\r |
572f5d8a | 1309 | \r |
48557c65 | 1310 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
572f5d8a | 1328 | ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r |
95276127 | 1329 | UINT16 Options;\r |
1330 | \r | |
572f5d8a | 1331 | ISCSIDevPath = DevPath;\r |
95276127 | 1332 | CatPrint (\r |
1333 | Str,\r | |
cf40f28a | 1334 | L"iSCSI(%a,0x%x,0x%lx,",\r |
184f7d83 | 1335 | ISCSIDevPath->TargetName,\r |
186ca8b0 | 1336 | (UINTN) ISCSIDevPath->TargetPortalGroupTag,\r |
572f5d8a | 1337 | ISCSIDevPath->Lun\r |
95276127 | 1338 | );\r |
1339 | \r | |
572f5d8a | 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 | |
95276127 | 1344 | CatPrint (Str, L"%s,", L"None");\r |
572f5d8a | 1345 | } else if (((Options >> 12) & 0x0001) != 0) {\r |
95276127 | 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 | |
572f5d8a | 1352 | CatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r |
95276127 | 1353 | }\r |
1354 | \r | |
8f97f911 | 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 | |
572f5d8a | 1382 | /**\r |
48557c65 | 1383 | Converts a Hard drive device path structure to its string representative.\r |
572f5d8a | 1384 | \r |
48557c65 | 1385 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
95276127 | 1407 | case SIGNATURE_TYPE_MBR:\r |
1408 | CatPrint (\r | |
1409 | Str,\r | |
cf40f28a | 1410 | L"HD(%d,%s,0x%08x,",\r |
186ca8b0 | 1411 | (UINTN) Hd->PartitionNumber,\r |
95276127 | 1412 | L"MBR",\r |
186ca8b0 | 1413 | (UINTN) *((UINT32 *) (&(Hd->Signature[0])))\r |
95276127 | 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 | |
186ca8b0 | 1421 | (UINTN) Hd->PartitionNumber,\r |
cf40f28a | 1422 | L"GPT",\r |
95276127 | 1423 | (EFI_GUID *) &(Hd->Signature[0])\r |
1424 | );\r | |
1425 | break;\r | |
1426 | \r | |
1427 | default:\r | |
cf40f28a | 1428 | CatPrint (\r |
1429 | Str,\r | |
1430 | L"HD(%d,%d,0,",\r | |
186ca8b0 | 1431 | (UINTN) Hd->PartitionNumber,\r |
1432 | (UINTN) Hd->SignatureType\r | |
cf40f28a | 1433 | );\r |
95276127 | 1434 | break;\r |
1435 | }\r | |
1436 | \r | |
cf40f28a | 1437 | CatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);\r |
95276127 | 1438 | }\r |
1439 | \r | |
572f5d8a | 1440 | /**\r |
48557c65 | 1441 | Converts a CDROM device path structure to its string representative.\r |
572f5d8a | 1442 | \r |
48557c65 | 1443 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
572f5d8a | 1464 | if (DisplayOnly) {\r |
186ca8b0 | 1465 | CatPrint (Str, L"CDROM(0x%x)", (UINTN) Cd->BootEntry);\r |
95276127 | 1466 | return ;\r |
1467 | }\r | |
1468 | \r | |
186ca8b0 | 1469 | CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", (UINTN) Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r |
95276127 | 1470 | }\r |
1471 | \r | |
572f5d8a | 1472 | /**\r |
48557c65 | 1473 | Converts a File device path structure to its string representative.\r |
572f5d8a | 1474 | \r |
48557c65 | 1475 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
572f5d8a | 1499 | /**\r |
48557c65 | 1500 | Converts a Media protocol device path structure to its string representative.\r |
572f5d8a | 1501 | \r |
48557c65 | 1502 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
572f5d8a | 1526 | /**\r |
48557c65 | 1527 | Converts a Firmware Volume device path structure to its string representative.\r |
572f5d8a | 1528 | \r |
48557c65 | 1529 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
cf40f28a | 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 | |
572f5d8a | 1553 | /**\r |
48557c65 | 1554 | Converts a Firmware Volume File device path structure to its string representative.\r |
572f5d8a | 1555 | \r |
48557c65 | 1556 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
cf40f28a | 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 | |
09e15613 | 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 | |
7748eb28 | 1606 | L"Offset(0x%lx,0x%lx)",\r |
09e15613 | 1607 | Offset->StartingOffset,\r |
1608 | Offset->EndingOffset\r | |
1609 | );\r | |
1610 | }\r | |
1611 | \r | |
572f5d8a | 1612 | /**\r |
48557c65 | 1613 | Converts a BIOS Boot Specification device path structure to its string representative.\r |
572f5d8a | 1614 | \r |
48557c65 | 1615 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
cf40f28a | 1663 | Type = NULL;\r |
95276127 | 1664 | break;\r |
1665 | }\r | |
1666 | \r | |
cf40f28a | 1667 | if (Type != NULL) {\r |
1668 | CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r | |
1669 | } else {\r | |
186ca8b0 | 1670 | CatPrint (Str, L"BBS(0x%x,%a", (UINTN) Bbs->DeviceType, Bbs->String);\r |
cf40f28a | 1671 | }\r |
95276127 | 1672 | \r |
572f5d8a | 1673 | if (DisplayOnly) {\r |
95276127 | 1674 | CatPrint (Str, L")");\r |
1675 | return ;\r | |
1676 | }\r | |
1677 | \r | |
186ca8b0 | 1678 | CatPrint (Str, L",0x%x)", (UINTN) Bbs->StatusFlag);\r |
95276127 | 1679 | }\r |
1680 | \r | |
572f5d8a | 1681 | /**\r |
48557c65 | 1682 | Converts an End-of-Device-Path structure to its string representative.\r |
572f5d8a | 1683 | \r |
48557c65 | 1684 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
572f5d8a | 1705 | /**\r |
48557c65 | 1706 | Converts an unknown device path structure to its string representative.\r |
572f5d8a | 1707 | \r |
48557c65 | 1708 | @param Str The string representative of input device.\r |
572f5d8a | 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 | |
95276127 | 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 | |
cf40f28a | 1736 | {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx},\r |
1737 | {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr},\r | |
95276127 | 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 | |
cf40f28a | 1746 | {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata},\r |
95276127 | 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 | |
8f97f911 | 1755 | {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan},\r |
95276127 | 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 | |
95276127 | 1759 | {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol},\r |
1760 | {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r | |
cf40f28a | 1761 | {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv},\r |
1762 | {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile},\r | |
09e15613 | 1763 | {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange},\r |
95276127 | 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 | |
572f5d8a | 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 | |
95276127 | 1784 | CHAR16 *\r |
572f5d8a | 1785 | EFIAPI\r |
95276127 | 1786 | ConvertDeviceNodeToText (\r |
1787 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r | |
1788 | IN BOOLEAN DisplayOnly,\r | |
1789 | IN BOOLEAN AllowShortcuts\r | |
1790 | )\r | |
95276127 | 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 | |
c4648495 | 1831 | Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r |
95276127 | 1832 | ASSERT (Str.Str != NULL);\r |
1833 | Str.Str[Str.Len] = 0;\r | |
1834 | return Str.Str;\r | |
1835 | }\r | |
1836 | \r | |
572f5d8a | 1837 | /**\r |
1838 | Converts a device path to its text representation.\r | |
95276127 | 1839 | \r |
572f5d8a | 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 | |
95276127 | 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 | |
572f5d8a | 1845 | @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r |
95276127 | 1846 | representation for a device node can be used, where applicable.\r |
1847 | \r | |
572f5d8a | 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 | |
95276127 | 1850 | \r |
572f5d8a | 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 | |
95276127 | 1859 | {\r |
1860 | POOL_PRINT Str;\r | |
1861 | EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r | |
1232b214 | 1862 | EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode;\r |
95276127 | 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 | |
95276127 | 1873 | //\r |
1874 | // Process each device path node\r | |
1875 | //\r | |
1232b214 | 1876 | DevPathNode = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;\r |
95276127 | 1877 | while (!IsDevicePathEnd (DevPathNode)) {\r |
1878 | //\r | |
1879 | // Find the handler to dump this device path node\r | |
1880 | //\r | |
1881 | DumpNode = NULL;\r | |
7ae9c1ce | 1882 | for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index += 1) {\r |
95276127 | 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 | |
5755841f | 1898 | // Put a path separator in if needed\r |
95276127 | 1899 | //\r |
572f5d8a | 1900 | if ((Str.Len != 0) && DumpNode != DevPathToTextEndInstance) {\r |
cf40f28a | 1901 | if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') {\r |
95276127 | 1902 | CatPrint (&Str, L"/");\r |
cf40f28a | 1903 | }\r |
95276127 | 1904 | }\r |
1232b214 | 1905 | \r |
1906 | AlignedDevPathNode = AllocateCopyPool (DevicePathNodeLength (DevPathNode), DevPathNode);\r | |
95276127 | 1907 | //\r |
1908 | // Print this node of the device path\r | |
1909 | //\r | |
1232b214 | 1910 | DumpNode (&Str, AlignedDevPathNode, DisplayOnly, AllowShortcuts);\r |
1911 | FreePool (AlignedDevPathNode);\r | |
1912 | \r | |
95276127 | 1913 | //\r |
1914 | // Next device path node\r | |
1915 | //\r | |
1916 | DevPathNode = NextDevicePathNode (DevPathNode);\r | |
1917 | }\r | |
95276127 | 1918 | \r |
1919 | NewSize = (Str.Len + 1) * sizeof (CHAR16);\r | |
c4648495 | 1920 | Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r |
95276127 | 1921 | ASSERT (Str.Str != NULL);\r |
1922 | Str.Str[Str.Len] = 0;\r | |
1923 | return Str.Str;\r | |
1924 | }\r |