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