]>
Commit | Line | Data |
---|---|---|
a405b86d | 1 | /** @file\r |
2 | Main file for support of shell consist mapping.\r | |
3 | \r | |
ba0014b9 | 4 | Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r |
56ba3746 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
a405b86d | 6 | **/\r |
7 | \r | |
8 | #include "UefiShellCommandLib.h"\r | |
9 | #include <Library/DevicePathLib.h>\r | |
10 | #include <Library/SortLib.h>\r | |
cc4c3312 | 11 | #include <Library/UefiLib.h>\r |
0db3fade | 12 | #include <Protocol/UsbIo.h>\r |
e9fc5387 QS |
13 | #include <Protocol/BlockIo.h>\r |
14 | #include <Protocol/SimpleFileSystem.h>\r | |
15 | \r | |
a405b86d | 16 | typedef enum {\r |
17 | MTDTypeUnknown,\r | |
18 | MTDTypeFloppy,\r | |
19 | MTDTypeHardDisk,\r | |
20 | MTDTypeCDRom,\r | |
21 | MTDTypeEnd\r | |
22 | } MTD_TYPE;\r | |
23 | \r | |
24 | typedef struct {\r | |
47d20b54 MK |
25 | CHAR16 *Str;\r |
26 | UINTN Len;\r | |
a405b86d | 27 | } POOL_PRINT;\r |
28 | \r | |
29 | typedef struct {\r | |
47d20b54 MK |
30 | UINTN Hi;\r |
31 | MTD_TYPE Mtd;\r | |
32 | POOL_PRINT Csd;\r | |
33 | BOOLEAN Digital;\r | |
a405b86d | 34 | } DEVICE_CONSIST_MAPPING_INFO;\r |
35 | \r | |
36 | typedef struct {\r | |
47d20b54 MK |
37 | MTD_TYPE MTDType;\r |
38 | CHAR16 *Name;\r | |
a405b86d | 39 | } MTD_NAME;\r |
40 | \r | |
41089802 ED |
41 | /**\r |
42 | Serial Decode function.\r | |
43 | \r | |
44 | @param DevPath The Device path info.\r | |
45 | @param MapInfo The map info.\r | |
46 | @param OrigDevPath The original device path protocol.\r | |
47 | \r | |
2c7c3b87 RN |
48 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r |
49 | @retval EFI_SUCCESS The appending was successful.\r | |
41089802 | 50 | **/\r |
ba0014b9 LG |
51 | typedef\r |
52 | EFI_STATUS\r | |
2c7c3b87 | 53 | (*SERIAL_DECODE_FUNCTION) (\r |
47d20b54 MK |
54 | EFI_DEVICE_PATH_PROTOCOL *DevPath,\r |
55 | DEVICE_CONSIST_MAPPING_INFO *MapInfo,\r | |
56 | EFI_DEVICE_PATH_PROTOCOL *OrigDevPath\r | |
41089802 | 57 | );\r |
0db3fade | 58 | \r |
a405b86d | 59 | typedef struct {\r |
47d20b54 MK |
60 | UINT8 Type;\r |
61 | UINT8 SubType;\r | |
62 | SERIAL_DECODE_FUNCTION SerialFun;\r | |
63 | INTN (EFIAPI *CompareFun)(EFI_DEVICE_PATH_PROTOCOL *DevPath, EFI_DEVICE_PATH_PROTOCOL *DevPath2);\r | |
a405b86d | 64 | } DEV_PATH_CONSIST_MAPPING_TABLE;\r |
65 | \r | |
a405b86d | 66 | /**\r |
67 | Concatenates a formatted unicode string to allocated pool.\r | |
68 | The caller must free the resulting buffer.\r | |
69 | \r | |
70 | @param Str Tracks the allocated pool, size in use, and amount of pool allocated.\r | |
71 | @param Fmt The format string\r | |
72 | @param ... The data will be printed.\r | |
73 | \r | |
2c7c3b87 RN |
74 | @retval EFI_SUCCESS The string is concatenated successfully.\r |
75 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
a405b86d | 76 | \r |
77 | **/\r | |
2c7c3b87 | 78 | EFI_STATUS\r |
af90df3c | 79 | EFIAPI\r |
a405b86d | 80 | CatPrint (\r |
47d20b54 MK |
81 | IN OUT POOL_PRINT *Str,\r |
82 | IN CHAR16 *Fmt,\r | |
a405b86d | 83 | ...\r |
84 | )\r | |
85 | {\r | |
47d20b54 MK |
86 | UINT16 *AppendStr;\r |
87 | VA_LIST Args;\r | |
88 | UINTN StringSize;\r | |
89 | CHAR16 *NewStr;\r | |
a405b86d | 90 | \r |
91 | AppendStr = AllocateZeroPool (0x1000);\r | |
92 | if (AppendStr == NULL) {\r | |
2c7c3b87 | 93 | return EFI_OUT_OF_RESOURCES;\r |
a405b86d | 94 | }\r |
95 | \r | |
96 | VA_START (Args, Fmt);\r | |
97 | UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);\r | |
98 | VA_END (Args);\r | |
99 | if (NULL == Str->Str) {\r | |
2c7c3b87 | 100 | StringSize = StrSize (AppendStr);\r |
47d20b54 | 101 | NewStr = AllocateZeroPool (StringSize);\r |
a405b86d | 102 | } else {\r |
47d20b54 | 103 | StringSize = StrSize (AppendStr);\r |
a405b86d | 104 | StringSize += (StrSize (Str->Str) - sizeof (UINT16));\r |
105 | \r | |
2c7c3b87 RN |
106 | NewStr = ReallocatePool (\r |
107 | StrSize (Str->Str),\r | |
108 | StringSize,\r | |
109 | Str->Str\r | |
a405b86d | 110 | );\r |
2c7c3b87 | 111 | }\r |
47d20b54 | 112 | \r |
2c7c3b87 RN |
113 | if (NewStr == NULL) {\r |
114 | FreePool (AppendStr);\r | |
115 | return EFI_OUT_OF_RESOURCES;\r | |
a405b86d | 116 | }\r |
117 | \r | |
2c7c3b87 | 118 | Str->Str = NewStr;\r |
47d20b54 | 119 | StrCatS (Str->Str, StringSize/sizeof (CHAR16), AppendStr);\r |
a405b86d | 120 | Str->Len = StringSize;\r |
121 | \r | |
122 | FreePool (AppendStr);\r | |
2c7c3b87 | 123 | return EFI_SUCCESS;\r |
a405b86d | 124 | }\r |
125 | \r | |
126 | MTD_NAME mMTDName[] = {\r | |
127 | {\r | |
128 | MTDTypeUnknown,\r | |
129 | L"F"\r | |
130 | },\r | |
131 | {\r | |
132 | MTDTypeFloppy,\r | |
133 | L"FP"\r | |
134 | },\r | |
135 | {\r | |
136 | MTDTypeHardDisk,\r | |
137 | L"HD"\r | |
138 | },\r | |
139 | {\r | |
140 | MTDTypeCDRom,\r | |
141 | L"CD"\r | |
142 | },\r | |
143 | {\r | |
144 | MTDTypeEnd,\r | |
145 | NULL\r | |
146 | }\r | |
147 | };\r | |
148 | \r | |
1a63ec8f | 149 | /**\r |
150 | Function to append a 64 bit number / 25 onto the string.\r | |
151 | \r | |
4ff7e37b ED |
152 | @param[in, out] Str The string so append onto.\r |
153 | @param[in] Num The number to divide and append.\r | |
1a63ec8f | 154 | \r |
2c7c3b87 | 155 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r |
1a63ec8f | 156 | @retval EFI_SUCCESS The appending was successful.\r |
157 | **/\r | |
158 | EFI_STATUS\r | |
a405b86d | 159 | AppendCSDNum2 (\r |
47d20b54 MK |
160 | IN OUT POOL_PRINT *Str,\r |
161 | IN UINT64 Num\r | |
a405b86d | 162 | )\r |
163 | {\r | |
47d20b54 MK |
164 | EFI_STATUS Status;\r |
165 | UINT64 Result;\r | |
166 | UINT32 Rem;\r | |
a405b86d | 167 | \r |
2c7c3b87 | 168 | ASSERT (Str != NULL);\r |
a405b86d | 169 | \r |
170 | Result = DivU64x32Remainder (Num, 25, &Rem);\r | |
171 | if (Result > 0) {\r | |
2c7c3b87 RN |
172 | Status = AppendCSDNum2 (Str, Result);\r |
173 | if (EFI_ERROR (Status)) {\r | |
174 | return Status;\r | |
175 | }\r | |
a405b86d | 176 | }\r |
177 | \r | |
2c7c3b87 | 178 | return CatPrint (Str, L"%c", Rem + 'a');\r |
a405b86d | 179 | }\r |
180 | \r | |
1a63ec8f | 181 | /**\r |
182 | Function to append a 64 bit number onto the mapping info.\r | |
183 | \r | |
4ff7e37b ED |
184 | @param[in, out] MappingItem The mapping info object to append onto.\r |
185 | @param[in] Num The info to append.\r | |
1a63ec8f | 186 | \r |
2c7c3b87 | 187 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r |
1a63ec8f | 188 | @retval EFI_SUCCESS The appending was successful.\r |
2c7c3b87 | 189 | \r |
1a63ec8f | 190 | **/\r |
191 | EFI_STATUS\r | |
a405b86d | 192 | AppendCSDNum (\r |
47d20b54 MK |
193 | IN OUT DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
194 | IN UINT64 Num\r | |
a405b86d | 195 | )\r |
196 | {\r | |
47d20b54 MK |
197 | EFI_STATUS Status;\r |
198 | \r | |
2c7c3b87 | 199 | ASSERT (MappingItem != NULL);\r |
a405b86d | 200 | \r |
201 | if (MappingItem->Digital) {\r | |
2c7c3b87 | 202 | Status = CatPrint (&MappingItem->Csd, L"%ld", Num);\r |
a405b86d | 203 | } else {\r |
2c7c3b87 | 204 | Status = AppendCSDNum2 (&MappingItem->Csd, Num);\r |
a405b86d | 205 | }\r |
206 | \r | |
2c7c3b87 RN |
207 | if (!EFI_ERROR (Status)) {\r |
208 | MappingItem->Digital = (BOOLEAN) !(MappingItem->Digital);\r | |
209 | }\r | |
1a63ec8f | 210 | \r |
2c7c3b87 | 211 | return Status;\r |
a405b86d | 212 | }\r |
213 | \r | |
1a63ec8f | 214 | /**\r |
215 | Function to append string into the mapping info.\r | |
216 | \r | |
4ff7e37b ED |
217 | @param[in, out] MappingItem The mapping info object to append onto.\r |
218 | @param[in] Str The info to append.\r | |
1a63ec8f | 219 | \r |
2c7c3b87 | 220 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r |
1a63ec8f | 221 | @retval EFI_SUCCESS The appending was successful.\r |
222 | **/\r | |
223 | EFI_STATUS\r | |
a405b86d | 224 | AppendCSDStr (\r |
47d20b54 MK |
225 | IN OUT DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
226 | IN CHAR16 *Str\r | |
a405b86d | 227 | )\r |
228 | {\r | |
47d20b54 MK |
229 | CHAR16 *Index;\r |
230 | EFI_STATUS Status;\r | |
a405b86d | 231 | \r |
2c7c3b87 RN |
232 | ASSERT (Str != NULL && MappingItem != NULL);\r |
233 | \r | |
234 | Status = EFI_SUCCESS;\r | |
a405b86d | 235 | \r |
236 | if (MappingItem->Digital) {\r | |
237 | //\r | |
238 | // To aVOID mult-meaning, the mapping is:\r | |
239 | // 0 1 2 3 4 5 6 7 8 9 a b c d e f\r | |
240 | // 0 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15\r | |
241 | //\r | |
242 | for (Index = Str; *Index != 0; Index++) {\r | |
243 | switch (*Index) {\r | |
47d20b54 MK |
244 | case '0':\r |
245 | case '2':\r | |
246 | case '3':\r | |
247 | case '4':\r | |
248 | case '5':\r | |
249 | case '6':\r | |
250 | case '7':\r | |
251 | case '8':\r | |
252 | case '9':\r | |
253 | Status = CatPrint (&MappingItem->Csd, L"%c", *Index);\r | |
254 | break;\r | |
a405b86d | 255 | \r |
47d20b54 MK |
256 | case '1':\r |
257 | Status = CatPrint (&MappingItem->Csd, L"16");\r | |
258 | break;\r | |
a405b86d | 259 | \r |
47d20b54 MK |
260 | case 'a':\r |
261 | case 'b':\r | |
262 | case 'c':\r | |
263 | case 'd':\r | |
264 | case 'e':\r | |
265 | case 'f':\r | |
266 | Status = CatPrint (&MappingItem->Csd, L"1%c", *Index - 'a' + '0');\r | |
267 | break;\r | |
a405b86d | 268 | \r |
47d20b54 MK |
269 | case 'A':\r |
270 | case 'B':\r | |
271 | case 'C':\r | |
272 | case 'D':\r | |
273 | case 'E':\r | |
274 | case 'F':\r | |
275 | Status = CatPrint (&MappingItem->Csd, L"1%c", *Index - 'A' + '0');\r | |
276 | break;\r | |
a405b86d | 277 | }\r |
2c7c3b87 RN |
278 | \r |
279 | if (EFI_ERROR (Status)) {\r | |
280 | return Status;\r | |
281 | }\r | |
a405b86d | 282 | }\r |
283 | } else {\r | |
284 | for (Index = Str; *Index != 0; Index++) {\r | |
285 | //\r | |
286 | // The mapping is:\r | |
287 | // 0 1 2 3 4 5 6 7 8 9 a b c d e f\r | |
288 | // a b c d e f g h i j k l m n o p\r | |
289 | //\r | |
47d20b54 | 290 | if ((*Index >= '0') && (*Index <= '9')) {\r |
2c7c3b87 | 291 | Status = CatPrint (&MappingItem->Csd, L"%c", *Index - '0' + 'a');\r |
47d20b54 | 292 | } else if ((*Index >= 'a') && (*Index <= 'f')) {\r |
2c7c3b87 | 293 | Status = CatPrint (&MappingItem->Csd, L"%c", *Index - 'a' + 'k');\r |
47d20b54 | 294 | } else if ((*Index >= 'A') && (*Index <= 'F')) {\r |
2c7c3b87 RN |
295 | Status = CatPrint (&MappingItem->Csd, L"%c", *Index - 'A' + 'k');\r |
296 | }\r | |
297 | \r | |
298 | if (EFI_ERROR (Status)) {\r | |
299 | return Status;\r | |
a405b86d | 300 | }\r |
301 | }\r | |
302 | }\r | |
303 | \r | |
47d20b54 | 304 | MappingItem->Digital = (BOOLEAN) !(MappingItem->Digital);\r |
1a63ec8f | 305 | \r |
306 | return (EFI_SUCCESS);\r | |
a405b86d | 307 | }\r |
308 | \r | |
1a63ec8f | 309 | /**\r |
310 | Function to append a Guid to the mapping item.\r | |
311 | \r | |
4ff7e37b ED |
312 | @param[in, out] MappingItem The item to append onto.\r |
313 | @param[in] Guid The guid to append.\r | |
1a63ec8f | 314 | \r |
2c7c3b87 RN |
315 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r |
316 | @retval EFI_SUCCESS The appending was successful.\r | |
1a63ec8f | 317 | **/\r |
318 | EFI_STATUS\r | |
a405b86d | 319 | AppendCSDGuid (\r |
47d20b54 MK |
320 | DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
321 | EFI_GUID *Guid\r | |
a405b86d | 322 | )\r |
323 | {\r | |
324 | CHAR16 Buffer[64];\r | |
1a63ec8f | 325 | \r |
2c7c3b87 | 326 | ASSERT (Guid != NULL && MappingItem != NULL);\r |
a405b86d | 327 | \r |
328 | UnicodeSPrint (\r | |
329 | Buffer,\r | |
330 | 0,\r | |
331 | L"%g",\r | |
332 | Guid\r | |
47d20b54 | 333 | );\r |
1a63ec8f | 334 | \r |
2c7c3b87 | 335 | return AppendCSDStr (MappingItem, Buffer);\r |
a405b86d | 336 | }\r |
337 | \r | |
1a63ec8f | 338 | /**\r |
339 | Function to compare 2 APCI device paths.\r | |
340 | \r | |
341 | @param[in] DevicePath1 The first device path to compare.\r | |
342 | @param[in] DevicePath2 The second device path to compare.\r | |
343 | \r | |
344 | @retval 0 The device paths represent the same device.\r | |
345 | @return Non zero if the devices are different, zero otherwise.\r | |
346 | **/\r | |
a405b86d | 347 | INTN\r |
e26d7b59 | 348 | EFIAPI\r |
1a63ec8f | 349 | DevPathCompareAcpi (\r |
47d20b54 MK |
350 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath1,\r |
351 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath2\r | |
a405b86d | 352 | )\r |
353 | {\r | |
354 | ACPI_HID_DEVICE_PATH *Acpi1;\r | |
355 | ACPI_HID_DEVICE_PATH *Acpi2;\r | |
356 | \r | |
47d20b54 | 357 | if ((DevicePath1 == NULL) || (DevicePath2 == NULL)) {\r |
1a63ec8f | 358 | return (-2);\r |
359 | }\r | |
a405b86d | 360 | \r |
47d20b54 MK |
361 | Acpi1 = (ACPI_HID_DEVICE_PATH *)DevicePath1;\r |
362 | Acpi2 = (ACPI_HID_DEVICE_PATH *)DevicePath2;\r | |
363 | if ((Acpi1->HID > Acpi2->HID) || ((Acpi1->HID == Acpi2->HID) && (Acpi1->UID > Acpi2->UID))) {\r | |
a405b86d | 364 | return 1;\r |
365 | }\r | |
366 | \r | |
47d20b54 | 367 | if ((Acpi1->HID == Acpi2->HID) && (Acpi1->UID == Acpi2->UID)) {\r |
a405b86d | 368 | return 0;\r |
369 | }\r | |
370 | \r | |
371 | return -1;\r | |
372 | }\r | |
373 | \r | |
1a63ec8f | 374 | /**\r |
375 | Function to compare 2 PCI device paths.\r | |
376 | \r | |
377 | @param[in] DevicePath1 The first device path to compare.\r | |
378 | @param[in] DevicePath2 The second device path to compare.\r | |
379 | \r | |
380 | @retval 0 The device paths represent the same device.\r | |
381 | @return Non zero if the devices are different, zero otherwise.\r | |
382 | **/\r | |
a405b86d | 383 | INTN\r |
e26d7b59 | 384 | EFIAPI\r |
1a63ec8f | 385 | DevPathComparePci (\r |
47d20b54 MK |
386 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath1,\r |
387 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath2\r | |
a405b86d | 388 | )\r |
389 | {\r | |
47d20b54 MK |
390 | PCI_DEVICE_PATH *Pci1;\r |
391 | PCI_DEVICE_PATH *Pci2;\r | |
a405b86d | 392 | \r |
47d20b54 MK |
393 | ASSERT (DevicePath1 != NULL);\r |
394 | ASSERT (DevicePath2 != NULL);\r | |
a405b86d | 395 | \r |
47d20b54 MK |
396 | Pci1 = (PCI_DEVICE_PATH *)DevicePath1;\r |
397 | Pci2 = (PCI_DEVICE_PATH *)DevicePath2;\r | |
398 | if ((Pci1->Device > Pci2->Device) || ((Pci1->Device == Pci2->Device) && (Pci1->Function > Pci2->Function))) {\r | |
a405b86d | 399 | return 1;\r |
400 | }\r | |
401 | \r | |
47d20b54 | 402 | if ((Pci1->Device == Pci2->Device) && (Pci1->Function == Pci2->Function)) {\r |
a405b86d | 403 | return 0;\r |
404 | }\r | |
405 | \r | |
406 | return -1;\r | |
407 | }\r | |
408 | \r | |
409 | /**\r | |
410 | Do a comparison on 2 device paths.\r | |
411 | \r | |
412 | @param[in] DevicePath1 The first device path.\r | |
413 | @param[in] DevicePath2 The second device path.\r | |
414 | \r | |
415 | @retval 0 The 2 device paths are the same.\r | |
416 | @retval <0 DevicePath2 is greater than DevicePath1.\r | |
417 | @retval >0 DevicePath1 is greater than DevicePath2.\r | |
418 | **/\r | |
419 | INTN\r | |
420 | EFIAPI\r | |
421 | DevPathCompareDefault (\r | |
47d20b54 MK |
422 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath1,\r |
423 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath2\r | |
a405b86d | 424 | )\r |
425 | {\r | |
47d20b54 MK |
426 | UINTN DevPathSize1;\r |
427 | UINTN DevPathSize2;\r | |
a405b86d | 428 | \r |
47d20b54 MK |
429 | ASSERT (DevicePath1 != NULL);\r |
430 | ASSERT (DevicePath2 != NULL);\r | |
a405b86d | 431 | \r |
47d20b54 MK |
432 | DevPathSize1 = DevicePathNodeLength (DevicePath1);\r |
433 | DevPathSize2 = DevicePathNodeLength (DevicePath2);\r | |
a405b86d | 434 | if (DevPathSize1 > DevPathSize2) {\r |
435 | return 1;\r | |
436 | } else if (DevPathSize1 < DevPathSize2) {\r | |
437 | return -1;\r | |
438 | } else {\r | |
439 | return CompareMem (DevicePath1, DevicePath2, DevPathSize1);\r | |
440 | }\r | |
441 | }\r | |
442 | \r | |
443 | /**\r | |
444 | DevicePathNode must be SerialHDD Channel type and this will populate the MappingItem.\r | |
445 | \r | |
446 | @param[in] DevicePathNode The node to get info on.\r | |
447 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 448 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
449 | \r |
450 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
451 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 452 | **/\r |
2c7c3b87 | 453 | EFI_STATUS\r |
a405b86d | 454 | DevPathSerialHardDrive (\r |
455 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 456 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
457 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 458 | )\r |
459 | {\r | |
47d20b54 | 460 | HARDDRIVE_DEVICE_PATH *Hd;\r |
a405b86d | 461 | \r |
47d20b54 MK |
462 | ASSERT (DevicePathNode != NULL);\r |
463 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 464 | \r |
47d20b54 | 465 | Hd = (HARDDRIVE_DEVICE_PATH *)DevicePathNode;\r |
1a63ec8f | 466 | if (MappingItem->Mtd == MTDTypeUnknown) {\r |
467 | MappingItem->Mtd = MTDTypeHardDisk;\r | |
a405b86d | 468 | }\r |
469 | \r | |
2c7c3b87 | 470 | return AppendCSDNum (MappingItem, Hd->PartitionNumber);\r |
a405b86d | 471 | }\r |
472 | \r | |
473 | /**\r | |
474 | DevicePathNode must be SerialAtapi Channel type and this will populate the MappingItem.\r | |
475 | \r | |
476 | @param[in] DevicePathNode The node to get info on.\r | |
477 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 478 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
479 | \r |
480 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
481 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 482 | **/\r |
2c7c3b87 | 483 | EFI_STATUS\r |
a405b86d | 484 | DevPathSerialAtapi (\r |
485 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 486 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
487 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 488 | )\r |
489 | {\r | |
47d20b54 | 490 | ATAPI_DEVICE_PATH *Atapi;\r |
a405b86d | 491 | \r |
47d20b54 MK |
492 | ASSERT (DevicePathNode != NULL);\r |
493 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 494 | \r |
47d20b54 | 495 | Atapi = (ATAPI_DEVICE_PATH *)DevicePathNode;\r |
2c7c3b87 | 496 | return AppendCSDNum (MappingItem, (Atapi->PrimarySecondary * 2 + Atapi->SlaveMaster));\r |
a405b86d | 497 | }\r |
498 | \r | |
499 | /**\r | |
500 | DevicePathNode must be SerialCDROM Channel type and this will populate the MappingItem.\r | |
501 | \r | |
502 | @param[in] DevicePathNode The node to get info on.\r | |
503 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 504 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
505 | \r |
506 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
507 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 508 | **/\r |
2c7c3b87 | 509 | EFI_STATUS\r |
a405b86d | 510 | DevPathSerialCdRom (\r |
511 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 512 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
513 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 514 | )\r |
515 | {\r | |
47d20b54 | 516 | CDROM_DEVICE_PATH *Cd;\r |
a405b86d | 517 | \r |
47d20b54 MK |
518 | ASSERT (DevicePathNode != NULL);\r |
519 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 520 | \r |
47d20b54 MK |
521 | Cd = (CDROM_DEVICE_PATH *)DevicePathNode;\r |
522 | MappingItem->Mtd = MTDTypeCDRom;\r | |
2c7c3b87 | 523 | return AppendCSDNum (MappingItem, Cd->BootEntry);\r |
a405b86d | 524 | }\r |
525 | \r | |
526 | /**\r | |
527 | DevicePathNode must be SerialFibre Channel type and this will populate the MappingItem.\r | |
528 | \r | |
529 | @param[in] DevicePathNode The node to get info on.\r | |
530 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 531 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
532 | \r |
533 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
534 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 535 | **/\r |
2c7c3b87 | 536 | EFI_STATUS\r |
a405b86d | 537 | DevPathSerialFibre (\r |
538 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 539 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
540 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 541 | )\r |
542 | {\r | |
2c7c3b87 | 543 | EFI_STATUS Status;\r |
a405b86d | 544 | FIBRECHANNEL_DEVICE_PATH *Fibre;\r |
545 | \r | |
47d20b54 MK |
546 | ASSERT (DevicePathNode != NULL);\r |
547 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 548 | \r |
47d20b54 | 549 | Fibre = (FIBRECHANNEL_DEVICE_PATH *)DevicePathNode;\r |
2c7c3b87 RN |
550 | Status = AppendCSDNum (MappingItem, Fibre->WWN);\r |
551 | if (!EFI_ERROR (Status)) {\r | |
552 | Status = AppendCSDNum (MappingItem, Fibre->Lun);\r | |
553 | }\r | |
47d20b54 | 554 | \r |
2c7c3b87 | 555 | return Status;\r |
a405b86d | 556 | }\r |
557 | \r | |
558 | /**\r | |
559 | DevicePathNode must be SerialUart type and this will populate the MappingItem.\r | |
560 | \r | |
561 | @param[in] DevicePathNode The node to get info on.\r | |
562 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 563 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
564 | \r |
565 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
566 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 567 | **/\r |
2c7c3b87 | 568 | EFI_STATUS\r |
a405b86d | 569 | DevPathSerialUart (\r |
570 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 571 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
572 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 573 | )\r |
574 | {\r | |
47d20b54 MK |
575 | EFI_STATUS Status;\r |
576 | UART_DEVICE_PATH *Uart;\r | |
a405b86d | 577 | \r |
47d20b54 MK |
578 | ASSERT (DevicePathNode != NULL);\r |
579 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 580 | \r |
47d20b54 | 581 | Uart = (UART_DEVICE_PATH *)DevicePathNode;\r |
2c7c3b87 RN |
582 | Status = AppendCSDNum (MappingItem, Uart->BaudRate);\r |
583 | if (!EFI_ERROR (Status)) {\r | |
584 | Status = AppendCSDNum (MappingItem, Uart->DataBits);\r | |
585 | }\r | |
47d20b54 | 586 | \r |
2c7c3b87 RN |
587 | if (!EFI_ERROR (Status)) {\r |
588 | Status = AppendCSDNum (MappingItem, Uart->Parity);\r | |
589 | }\r | |
47d20b54 | 590 | \r |
2c7c3b87 RN |
591 | if (!EFI_ERROR (Status)) {\r |
592 | Status = AppendCSDNum (MappingItem, Uart->StopBits);\r | |
593 | }\r | |
47d20b54 | 594 | \r |
2c7c3b87 | 595 | return Status;\r |
a405b86d | 596 | }\r |
597 | \r | |
598 | /**\r | |
599 | DevicePathNode must be SerialUSB type and this will populate the MappingItem.\r | |
600 | \r | |
601 | @param[in] DevicePathNode The node to get info on.\r | |
602 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 603 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
604 | \r |
605 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
606 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 607 | **/\r |
2c7c3b87 | 608 | EFI_STATUS\r |
a405b86d | 609 | DevPathSerialUsb (\r |
610 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 611 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
612 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 613 | )\r |
614 | {\r | |
0db3fade | 615 | USB_DEVICE_PATH *Usb;\r |
616 | EFI_USB_IO_PROTOCOL *UsbIo;\r | |
617 | EFI_HANDLE TempHandle;\r | |
618 | EFI_STATUS Status;\r | |
619 | USB_INTERFACE_DESCRIPTOR InterfaceDesc;\r | |
620 | \r | |
47d20b54 MK |
621 | ASSERT (DevicePathNode != NULL);\r |
622 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 623 | \r |
47d20b54 | 624 | Usb = (USB_DEVICE_PATH *)DevicePathNode;\r |
2c7c3b87 RN |
625 | Status = AppendCSDNum (MappingItem, Usb->ParentPortNumber);\r |
626 | if (!EFI_ERROR (Status)) {\r | |
627 | Status = AppendCSDNum (MappingItem, Usb->InterfaceNumber);\r | |
628 | }\r | |
629 | \r | |
630 | if (EFI_ERROR (Status)) {\r | |
631 | return Status;\r | |
632 | }\r | |
0db3fade | 633 | \r |
47d20b54 MK |
634 | if (PcdGetBool (PcdUsbExtendedDecode)) {\r |
635 | Status = gBS->LocateDevicePath (&gEfiUsbIoProtocolGuid, &DevicePath, &TempHandle);\r | |
636 | UsbIo = NULL;\r | |
637 | if (!EFI_ERROR (Status)) {\r | |
638 | Status = gBS->OpenProtocol (TempHandle, &gEfiUsbIoProtocolGuid, (VOID **)&UsbIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r | |
ba0014b9 | 639 | }\r |
0db3fade | 640 | \r |
47d20b54 MK |
641 | if (!EFI_ERROR (Status)) {\r |
642 | ASSERT (UsbIo != NULL);\r | |
643 | Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDesc);\r | |
644 | if (!EFI_ERROR (Status)) {\r | |
645 | if ((InterfaceDesc.InterfaceClass == USB_MASS_STORE_CLASS) && (MappingItem->Mtd == MTDTypeUnknown)) {\r | |
646 | switch (InterfaceDesc.InterfaceSubClass) {\r | |
0db3fade | 647 | case USB_MASS_STORE_SCSI:\r |
648 | MappingItem->Mtd = MTDTypeHardDisk;\r | |
649 | break;\r | |
650 | case USB_MASS_STORE_8070I:\r | |
651 | case USB_MASS_STORE_UFI:\r | |
652 | MappingItem->Mtd = MTDTypeFloppy;\r | |
653 | break;\r | |
654 | case USB_MASS_STORE_8020I:\r | |
47d20b54 | 655 | MappingItem->Mtd = MTDTypeCDRom;\r |
0db3fade | 656 | break;\r |
657 | }\r | |
658 | }\r | |
659 | }\r | |
ba0014b9 | 660 | }\r |
0db3fade | 661 | }\r |
47d20b54 | 662 | \r |
2c7c3b87 | 663 | return Status;\r |
a405b86d | 664 | }\r |
665 | \r | |
666 | /**\r | |
667 | DevicePathNode must be SerialVendor type and this will populate the MappingItem.\r | |
668 | \r | |
669 | @param[in] DevicePathNode The node to get info on.\r | |
670 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 671 | @param[in] DevicePath Ignored.\r |
1a63ec8f | 672 | \r |
2c7c3b87 RN |
673 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r |
674 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 675 | **/\r |
2c7c3b87 | 676 | EFI_STATUS\r |
a405b86d | 677 | DevPathSerialVendor (\r |
678 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 679 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
680 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 681 | )\r |
682 | {\r | |
2c7c3b87 | 683 | EFI_STATUS Status;\r |
a405b86d | 684 | VENDOR_DEVICE_PATH *Vendor;\r |
685 | SAS_DEVICE_PATH *Sas;\r | |
cc4c3312 | 686 | UINTN TargetNameLength;\r |
687 | UINTN Index;\r | |
688 | CHAR16 *Buffer;\r | |
2c7c3b87 | 689 | CHAR16 *NewBuffer;\r |
a405b86d | 690 | \r |
47d20b54 MK |
691 | ASSERT (DevicePathNode != NULL);\r |
692 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 693 | \r |
47d20b54 | 694 | Vendor = (VENDOR_DEVICE_PATH *)DevicePathNode;\r |
2c7c3b87 RN |
695 | Status = AppendCSDGuid (MappingItem, &Vendor->Guid);\r |
696 | if (EFI_ERROR (Status)) {\r | |
697 | return Status;\r | |
698 | }\r | |
a405b86d | 699 | \r |
1a63ec8f | 700 | if (CompareGuid (&gEfiSasDevicePathGuid, &Vendor->Guid)) {\r |
47d20b54 | 701 | Sas = (SAS_DEVICE_PATH *)Vendor;\r |
2c7c3b87 RN |
702 | Status = AppendCSDNum (MappingItem, Sas->SasAddress);\r |
703 | if (!EFI_ERROR (Status)) {\r | |
704 | Status = AppendCSDNum (MappingItem, Sas->Lun);\r | |
705 | }\r | |
47d20b54 | 706 | \r |
2c7c3b87 RN |
707 | if (!EFI_ERROR (Status)) {\r |
708 | Status = AppendCSDNum (MappingItem, Sas->DeviceTopology);\r | |
709 | }\r | |
47d20b54 | 710 | \r |
2c7c3b87 RN |
711 | if (!EFI_ERROR (Status)) {\r |
712 | Status = AppendCSDNum (MappingItem, Sas->RelativeTargetPort);\r | |
713 | }\r | |
cc4c3312 | 714 | } else {\r |
47d20b54 | 715 | TargetNameLength = MIN (DevicePathNodeLength (DevicePathNode) - sizeof (VENDOR_DEVICE_PATH), PcdGet32 (PcdShellVendorExtendedDecode));\r |
cc4c3312 | 716 | if (TargetNameLength != 0) {\r |
717 | //\r | |
718 | // String is 2 chars per data byte, plus NULL terminator\r | |
719 | //\r | |
47d20b54 | 720 | Buffer = AllocateZeroPool (((TargetNameLength * 2) + 1) * sizeof (CHAR16));\r |
cc4c3312 | 721 | if (Buffer == NULL) {\r |
2c7c3b87 RN |
722 | return EFI_OUT_OF_RESOURCES;\r |
723 | }\r | |
cc4c3312 | 724 | \r |
725 | //\r | |
726 | // Build the string data\r | |
727 | //\r | |
728 | for (Index = 0; Index < TargetNameLength; Index++) {\r | |
47d20b54 | 729 | NewBuffer = CatSPrint (Buffer, L"%02x", *((UINT8 *)Vendor + sizeof (VENDOR_DEVICE_PATH) + Index));\r |
2c7c3b87 RN |
730 | if (NewBuffer == NULL) {\r |
731 | Status = EFI_OUT_OF_RESOURCES;\r | |
732 | break;\r | |
733 | }\r | |
47d20b54 | 734 | \r |
2c7c3b87 RN |
735 | Buffer = NewBuffer;\r |
736 | }\r | |
cc4c3312 | 737 | \r |
738 | //\r | |
739 | // Append the new data block\r | |
740 | //\r | |
2c7c3b87 RN |
741 | if (!EFI_ERROR (Status)) {\r |
742 | Status = AppendCSDStr (MappingItem, Buffer);\r | |
743 | }\r | |
cc4c3312 | 744 | \r |
47d20b54 | 745 | FreePool (Buffer);\r |
cc4c3312 | 746 | }\r |
a405b86d | 747 | }\r |
47d20b54 | 748 | \r |
2c7c3b87 | 749 | return Status;\r |
a405b86d | 750 | }\r |
751 | \r | |
752 | /**\r | |
753 | DevicePathNode must be SerialLun type and this will populate the MappingItem.\r | |
754 | \r | |
755 | @param[in] DevicePathNode The node to get info on.\r | |
756 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 757 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
758 | \r |
759 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
760 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 761 | **/\r |
2c7c3b87 | 762 | EFI_STATUS\r |
a405b86d | 763 | DevPathSerialLun (\r |
764 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 765 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
766 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 767 | )\r |
768 | {\r | |
47d20b54 | 769 | DEVICE_LOGICAL_UNIT_DEVICE_PATH *Lun;\r |
a405b86d | 770 | \r |
47d20b54 MK |
771 | ASSERT (DevicePathNode != NULL);\r |
772 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 773 | \r |
47d20b54 | 774 | Lun = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *)DevicePathNode;\r |
2c7c3b87 | 775 | return AppendCSDNum (MappingItem, Lun->Lun);\r |
a405b86d | 776 | }\r |
777 | \r | |
778 | /**\r | |
779 | DevicePathNode must be SerialSata type and this will populate the MappingItem.\r | |
780 | \r | |
781 | @param[in] DevicePathNode The node to get info on.\r | |
782 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 783 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
784 | \r |
785 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
786 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 787 | **/\r |
2c7c3b87 | 788 | EFI_STATUS\r |
a405b86d | 789 | DevPathSerialSata (\r |
790 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 791 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
792 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 793 | )\r |
794 | {\r | |
2c7c3b87 | 795 | EFI_STATUS Status;\r |
a405b86d | 796 | SATA_DEVICE_PATH *Sata;\r |
797 | \r | |
47d20b54 MK |
798 | ASSERT (DevicePathNode != NULL);\r |
799 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 800 | \r |
47d20b54 | 801 | Sata = (SATA_DEVICE_PATH *)DevicePathNode;\r |
2c7c3b87 RN |
802 | Status = AppendCSDNum (MappingItem, Sata->HBAPortNumber);\r |
803 | if (!EFI_ERROR (Status)) {\r | |
804 | Status = AppendCSDNum (MappingItem, Sata->PortMultiplierPortNumber);\r | |
805 | }\r | |
47d20b54 | 806 | \r |
2c7c3b87 RN |
807 | if (!EFI_ERROR (Status)) {\r |
808 | Status = AppendCSDNum (MappingItem, Sata->Lun);\r | |
809 | }\r | |
47d20b54 | 810 | \r |
2c7c3b87 | 811 | return Status;\r |
a405b86d | 812 | }\r |
813 | \r | |
814 | /**\r | |
815 | DevicePathNode must be SerialSCSI type and this will populate the MappingItem.\r | |
816 | \r | |
817 | @param[in] DevicePathNode The node to get info on.\r | |
818 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 819 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
820 | \r |
821 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
822 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 823 | **/\r |
2c7c3b87 | 824 | EFI_STATUS\r |
a405b86d | 825 | DevPathSerialIScsi (\r |
826 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 827 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
828 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 829 | )\r |
830 | {\r | |
2c7c3b87 | 831 | EFI_STATUS Status;\r |
a405b86d | 832 | ISCSI_DEVICE_PATH *IScsi;\r |
833 | UINT8 *IScsiTargetName;\r | |
834 | CHAR16 *TargetName;\r | |
835 | UINTN TargetNameLength;\r | |
836 | UINTN Index;\r | |
837 | \r | |
47d20b54 MK |
838 | ASSERT (DevicePathNode != NULL);\r |
839 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 840 | \r |
2c7c3b87 RN |
841 | Status = EFI_SUCCESS;\r |
842 | \r | |
47d20b54 MK |
843 | if (PcdGetBool (PcdShellDecodeIScsiMapNames)) {\r |
844 | IScsi = (ISCSI_DEVICE_PATH *)DevicePathNode;\r | |
2c7c3b87 RN |
845 | Status = AppendCSDNum (MappingItem, IScsi->NetworkProtocol);\r |
846 | if (!EFI_ERROR (Status)) {\r | |
847 | Status = AppendCSDNum (MappingItem, IScsi->LoginOption);\r | |
848 | }\r | |
47d20b54 | 849 | \r |
2c7c3b87 RN |
850 | if (!EFI_ERROR (Status)) {\r |
851 | Status = AppendCSDNum (MappingItem, IScsi->Lun);\r | |
852 | }\r | |
47d20b54 | 853 | \r |
2c7c3b87 RN |
854 | if (!EFI_ERROR (Status)) {\r |
855 | Status = AppendCSDNum (MappingItem, IScsi->TargetPortalGroupTag);\r | |
856 | }\r | |
47d20b54 | 857 | \r |
2c7c3b87 RN |
858 | if (EFI_ERROR (Status)) {\r |
859 | return Status;\r | |
860 | }\r | |
47d20b54 | 861 | \r |
9b589522 JC |
862 | TargetNameLength = DevicePathNodeLength (DevicePathNode) - sizeof (ISCSI_DEVICE_PATH);\r |
863 | if (TargetNameLength > 0) {\r | |
864 | TargetName = AllocateZeroPool ((TargetNameLength + 1) * sizeof (CHAR16));\r | |
2c7c3b87 RN |
865 | if (TargetName == NULL) {\r |
866 | Status = EFI_OUT_OF_RESOURCES;\r | |
867 | } else {\r | |
47d20b54 | 868 | IScsiTargetName = (UINT8 *)(IScsi + 1);\r |
9b589522 | 869 | for (Index = 0; Index < TargetNameLength; Index++) {\r |
47d20b54 | 870 | TargetName[Index] = (CHAR16)IScsiTargetName[Index];\r |
9b589522 | 871 | }\r |
47d20b54 | 872 | \r |
2c7c3b87 | 873 | Status = AppendCSDStr (MappingItem, TargetName);\r |
9b589522 | 874 | FreePool (TargetName);\r |
a405b86d | 875 | }\r |
a405b86d | 876 | }\r |
877 | }\r | |
47d20b54 | 878 | \r |
2c7c3b87 | 879 | return Status;\r |
a405b86d | 880 | }\r |
881 | \r | |
882 | /**\r | |
883 | DevicePathNode must be SerialI20 type and this will populate the MappingItem.\r | |
884 | \r | |
885 | @param[in] DevicePathNode The node to get info on.\r | |
886 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 887 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
888 | \r |
889 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
890 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 891 | **/\r |
2c7c3b87 | 892 | EFI_STATUS\r |
a405b86d | 893 | DevPathSerialI2O (\r |
894 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 895 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
896 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 897 | )\r |
898 | {\r | |
47d20b54 | 899 | I2O_DEVICE_PATH *DevicePath_I20;\r |
a405b86d | 900 | \r |
47d20b54 MK |
901 | ASSERT (DevicePathNode != NULL);\r |
902 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 903 | \r |
47d20b54 | 904 | DevicePath_I20 = (I2O_DEVICE_PATH *)DevicePathNode;\r |
2c7c3b87 | 905 | return AppendCSDNum (MappingItem, DevicePath_I20->Tid);\r |
a405b86d | 906 | }\r |
907 | \r | |
908 | /**\r | |
909 | DevicePathNode must be Mac Address type and this will populate the MappingItem.\r | |
910 | \r | |
911 | @param[in] DevicePathNode The node to get info on.\r | |
912 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 913 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
914 | \r |
915 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
916 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 917 | **/\r |
2c7c3b87 | 918 | EFI_STATUS\r |
a405b86d | 919 | DevPathSerialMacAddr (\r |
920 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 921 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
922 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 923 | )\r |
924 | {\r | |
925 | MAC_ADDR_DEVICE_PATH *Mac;\r | |
926 | UINTN HwAddressSize;\r | |
927 | UINTN Index;\r | |
928 | CHAR16 Buffer[64];\r | |
929 | CHAR16 *PBuffer;\r | |
930 | \r | |
47d20b54 MK |
931 | ASSERT (DevicePathNode != NULL);\r |
932 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 933 | \r |
47d20b54 | 934 | Mac = (MAC_ADDR_DEVICE_PATH *)DevicePathNode;\r |
a405b86d | 935 | \r |
936 | HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r | |
47d20b54 | 937 | if ((Mac->IfType == 0x01) || (Mac->IfType == 0x00)) {\r |
a405b86d | 938 | HwAddressSize = 6;\r |
939 | }\r | |
940 | \r | |
941 | for (Index = 0, PBuffer = Buffer; Index < HwAddressSize; Index++, PBuffer += 2) {\r | |
47d20b54 | 942 | UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN)Mac->MacAddress.Addr[Index]);\r |
a405b86d | 943 | }\r |
944 | \r | |
2c7c3b87 | 945 | return AppendCSDStr (MappingItem, Buffer);\r |
a405b86d | 946 | }\r |
947 | \r | |
948 | /**\r | |
949 | DevicePathNode must be InfiniBand type and this will populate the MappingItem.\r | |
950 | \r | |
951 | @param[in] DevicePathNode The node to get info on.\r | |
952 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 953 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
954 | \r |
955 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
956 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 957 | **/\r |
2c7c3b87 | 958 | EFI_STATUS\r |
a405b86d | 959 | DevPathSerialInfiniBand (\r |
960 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 961 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
962 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 963 | )\r |
964 | {\r | |
2c7c3b87 | 965 | EFI_STATUS Status;\r |
a405b86d | 966 | INFINIBAND_DEVICE_PATH *InfiniBand;\r |
967 | UINTN Index;\r | |
968 | CHAR16 Buffer[64];\r | |
969 | CHAR16 *PBuffer;\r | |
970 | \r | |
47d20b54 MK |
971 | ASSERT (DevicePathNode != NULL);\r |
972 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 973 | \r |
47d20b54 | 974 | InfiniBand = (INFINIBAND_DEVICE_PATH *)DevicePathNode;\r |
a405b86d | 975 | for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {\r |
47d20b54 | 976 | UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN)InfiniBand->PortGid[Index]);\r |
a405b86d | 977 | }\r |
978 | \r | |
2c7c3b87 RN |
979 | Status = AppendCSDStr (MappingItem, Buffer);\r |
980 | if (!EFI_ERROR (Status)) {\r | |
981 | Status = AppendCSDNum (MappingItem, InfiniBand->ServiceId);\r | |
982 | }\r | |
47d20b54 | 983 | \r |
2c7c3b87 RN |
984 | if (!EFI_ERROR (Status)) {\r |
985 | Status = AppendCSDNum (MappingItem, InfiniBand->TargetPortId);\r | |
986 | }\r | |
47d20b54 | 987 | \r |
2c7c3b87 RN |
988 | if (!EFI_ERROR (Status)) {\r |
989 | Status = AppendCSDNum (MappingItem, InfiniBand->DeviceId);\r | |
990 | }\r | |
47d20b54 | 991 | \r |
2c7c3b87 | 992 | return Status;\r |
a405b86d | 993 | }\r |
994 | \r | |
995 | /**\r | |
996 | DevicePathNode must be IPv4 type and this will populate the MappingItem.\r | |
997 | \r | |
998 | @param[in] DevicePathNode The node to get info on.\r | |
999 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 1000 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
1001 | \r |
1002 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
1003 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 1004 | **/\r |
2c7c3b87 | 1005 | EFI_STATUS\r |
a405b86d | 1006 | DevPathSerialIPv4 (\r |
1007 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 1008 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
1009 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 1010 | )\r |
1011 | {\r | |
2c7c3b87 | 1012 | EFI_STATUS Status;\r |
a405b86d | 1013 | IPv4_DEVICE_PATH *Ip;\r |
1014 | CHAR16 Buffer[10];\r | |
1015 | \r | |
47d20b54 MK |
1016 | ASSERT (DevicePathNode != NULL);\r |
1017 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 1018 | \r |
47d20b54 | 1019 | Ip = (IPv4_DEVICE_PATH *)DevicePathNode;\r |
a405b86d | 1020 | UnicodeSPrint (\r |
1021 | Buffer,\r | |
1022 | 0,\r | |
1023 | L"%02x%02x%02x%02x",\r | |
47d20b54 MK |
1024 | (UINTN)Ip->LocalIpAddress.Addr[0],\r |
1025 | (UINTN)Ip->LocalIpAddress.Addr[1],\r | |
1026 | (UINTN)Ip->LocalIpAddress.Addr[2],\r | |
1027 | (UINTN)Ip->LocalIpAddress.Addr[3]\r | |
1028 | );\r | |
2c7c3b87 RN |
1029 | Status = AppendCSDStr (MappingItem, Buffer);\r |
1030 | if (!EFI_ERROR (Status)) {\r | |
1031 | Status = AppendCSDNum (MappingItem, Ip->LocalPort);\r | |
1032 | }\r | |
47d20b54 | 1033 | \r |
2c7c3b87 RN |
1034 | if (!EFI_ERROR (Status)) {\r |
1035 | UnicodeSPrint (\r | |
1036 | Buffer,\r | |
1037 | 0,\r | |
1038 | L"%02x%02x%02x%02x",\r | |
47d20b54 MK |
1039 | (UINTN)Ip->RemoteIpAddress.Addr[0],\r |
1040 | (UINTN)Ip->RemoteIpAddress.Addr[1],\r | |
1041 | (UINTN)Ip->RemoteIpAddress.Addr[2],\r | |
1042 | (UINTN)Ip->RemoteIpAddress.Addr[3]\r | |
1043 | );\r | |
2c7c3b87 RN |
1044 | Status = AppendCSDStr (MappingItem, Buffer);\r |
1045 | }\r | |
47d20b54 | 1046 | \r |
2c7c3b87 RN |
1047 | if (!EFI_ERROR (Status)) {\r |
1048 | Status = AppendCSDNum (MappingItem, Ip->RemotePort);\r | |
1049 | }\r | |
47d20b54 | 1050 | \r |
2c7c3b87 | 1051 | return Status;\r |
a405b86d | 1052 | }\r |
1053 | \r | |
1054 | /**\r | |
1055 | DevicePathNode must be IPv6 type and this will populate the MappingItem.\r | |
1056 | \r | |
1057 | @param[in] DevicePathNode The node to get info on.\r | |
1058 | @param[in] MappingItem The info item to populate.\r | |
41089802 ED |
1059 | @param[in] DevicePath Ignored.\r |
1060 | \r | |
2c7c3b87 RN |
1061 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r |
1062 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 1063 | **/\r |
2c7c3b87 | 1064 | EFI_STATUS\r |
a405b86d | 1065 | DevPathSerialIPv6 (\r |
1066 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 1067 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
1068 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 1069 | )\r |
1070 | {\r | |
2c7c3b87 | 1071 | EFI_STATUS Status;\r |
a405b86d | 1072 | IPv6_DEVICE_PATH *Ip;\r |
1073 | UINTN Index;\r | |
1074 | CHAR16 Buffer[64];\r | |
1075 | CHAR16 *PBuffer;\r | |
1076 | \r | |
47d20b54 MK |
1077 | ASSERT (DevicePathNode != NULL);\r |
1078 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 1079 | \r |
47d20b54 | 1080 | Ip = (IPv6_DEVICE_PATH *)DevicePathNode;\r |
a405b86d | 1081 | for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {\r |
47d20b54 | 1082 | UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN)Ip->LocalIpAddress.Addr[Index]);\r |
a405b86d | 1083 | }\r |
1084 | \r | |
2c7c3b87 RN |
1085 | Status = AppendCSDStr (MappingItem, Buffer);\r |
1086 | if (!EFI_ERROR (Status)) {\r | |
1087 | Status = AppendCSDNum (MappingItem, Ip->LocalPort);\r | |
a405b86d | 1088 | }\r |
47d20b54 | 1089 | \r |
2c7c3b87 RN |
1090 | if (!EFI_ERROR (Status)) {\r |
1091 | for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {\r | |
47d20b54 | 1092 | UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN)Ip->RemoteIpAddress.Addr[Index]);\r |
2c7c3b87 | 1093 | }\r |
a405b86d | 1094 | \r |
2c7c3b87 RN |
1095 | Status = AppendCSDStr (MappingItem, Buffer);\r |
1096 | }\r | |
47d20b54 | 1097 | \r |
2c7c3b87 RN |
1098 | if (!EFI_ERROR (Status)) {\r |
1099 | Status = AppendCSDNum (MappingItem, Ip->RemotePort);\r | |
1100 | }\r | |
47d20b54 | 1101 | \r |
2c7c3b87 | 1102 | return Status;\r |
a405b86d | 1103 | }\r |
1104 | \r | |
1105 | /**\r | |
1106 | DevicePathNode must be SCSI type and this will populate the MappingItem.\r | |
1107 | \r | |
1108 | @param[in] DevicePathNode The node to get info on.\r | |
1109 | @param[in] MappingItem The info item to populate.\r | |
41089802 ED |
1110 | @param[in] DevicePath Ignored.\r |
1111 | \r | |
2c7c3b87 RN |
1112 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r |
1113 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 1114 | **/\r |
2c7c3b87 | 1115 | EFI_STATUS\r |
a405b86d | 1116 | DevPathSerialScsi (\r |
1117 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 1118 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
1119 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 1120 | )\r |
1121 | {\r | |
2c7c3b87 | 1122 | EFI_STATUS Status;\r |
a405b86d | 1123 | SCSI_DEVICE_PATH *Scsi;\r |
1124 | \r | |
47d20b54 MK |
1125 | ASSERT (DevicePathNode != NULL);\r |
1126 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 1127 | \r |
47d20b54 | 1128 | Scsi = (SCSI_DEVICE_PATH *)DevicePathNode;\r |
2c7c3b87 RN |
1129 | Status = AppendCSDNum (MappingItem, Scsi->Pun);\r |
1130 | if (!EFI_ERROR (Status)) {\r | |
1131 | Status = AppendCSDNum (MappingItem, Scsi->Lun);\r | |
1132 | }\r | |
47d20b54 | 1133 | \r |
2c7c3b87 | 1134 | return Status;\r |
a405b86d | 1135 | }\r |
1136 | \r | |
1137 | /**\r | |
1138 | DevicePathNode must be 1394 type and this will populate the MappingItem.\r | |
1139 | \r | |
1140 | @param[in] DevicePathNode The node to get info on.\r | |
1141 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 1142 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
1143 | \r |
1144 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
1145 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 1146 | **/\r |
2c7c3b87 | 1147 | EFI_STATUS\r |
a405b86d | 1148 | DevPathSerial1394 (\r |
1149 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 1150 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
1151 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 1152 | )\r |
1153 | {\r | |
47d20b54 MK |
1154 | F1394_DEVICE_PATH *DevicePath_F1394;\r |
1155 | CHAR16 Buffer[20];\r | |
a405b86d | 1156 | \r |
47d20b54 MK |
1157 | ASSERT (DevicePathNode != NULL);\r |
1158 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 1159 | \r |
47d20b54 | 1160 | DevicePath_F1394 = (F1394_DEVICE_PATH *)DevicePathNode;\r |
1a63ec8f | 1161 | UnicodeSPrint (Buffer, 0, L"%lx", DevicePath_F1394->Guid);\r |
2c7c3b87 | 1162 | return AppendCSDStr (MappingItem, Buffer);\r |
a405b86d | 1163 | }\r |
1164 | \r | |
1165 | /**\r | |
1166 | If the node is floppy type then populate the MappingItem.\r | |
1167 | \r | |
1168 | @param[in] DevicePathNode The node to get info on.\r | |
1169 | @param[in] MappingItem The info item to populate.\r | |
41089802 | 1170 | @param[in] DevicePath Ignored.\r |
2c7c3b87 RN |
1171 | \r |
1172 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
1173 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 1174 | **/\r |
2c7c3b87 | 1175 | EFI_STATUS\r |
a405b86d | 1176 | DevPathSerialAcpi (\r |
1177 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 1178 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
1179 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 1180 | )\r |
1181 | {\r | |
1182 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
1183 | \r | |
47d20b54 MK |
1184 | ASSERT (DevicePathNode != NULL);\r |
1185 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 1186 | \r |
47d20b54 | 1187 | Acpi = (ACPI_HID_DEVICE_PATH *)DevicePathNode;\r |
a405b86d | 1188 | if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r |
1189 | if (EISA_ID_TO_NUM (Acpi->HID) == 0x0604) {\r | |
1a63ec8f | 1190 | MappingItem->Mtd = MTDTypeFloppy;\r |
2c7c3b87 | 1191 | return AppendCSDNum (MappingItem, Acpi->UID);\r |
a405b86d | 1192 | }\r |
1193 | }\r | |
47d20b54 | 1194 | \r |
2c7c3b87 | 1195 | return EFI_SUCCESS;\r |
a405b86d | 1196 | }\r |
1197 | \r | |
1198 | /**\r | |
1199 | Empty function used for unknown devices.\r | |
1200 | \r | |
1a63ec8f | 1201 | @param[in] DevicePathNode Ignored.\r |
1202 | @param[in] MappingItem Ignored.\r | |
41089802 | 1203 | @param[in] DevicePath Ignored.\r |
1a63ec8f | 1204 | \r |
2c7c3b87 RN |
1205 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r |
1206 | @retval EFI_SUCCESS The appending was successful.\r | |
a405b86d | 1207 | **/\r |
2c7c3b87 | 1208 | EFI_STATUS\r |
a405b86d | 1209 | DevPathSerialDefault (\r |
1210 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
0db3fade | 1211 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
1212 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 1213 | )\r |
1214 | {\r | |
2c7c3b87 | 1215 | return EFI_SUCCESS;\r |
a405b86d | 1216 | }\r |
1217 | \r | |
1218 | DEV_PATH_CONSIST_MAPPING_TABLE DevPathConsistMappingTable[] = {\r | |
ce68d3bc SZ |
1219 | {\r |
1220 | HARDWARE_DEVICE_PATH,\r | |
1221 | HW_PCI_DP,\r | |
1222 | DevPathSerialDefault,\r | |
1223 | DevPathComparePci\r | |
1224 | },\r | |
1225 | {\r | |
1226 | ACPI_DEVICE_PATH,\r | |
1227 | ACPI_DP,\r | |
1228 | DevPathSerialAcpi,\r | |
1229 | DevPathCompareAcpi\r | |
1230 | },\r | |
1231 | {\r | |
1232 | MESSAGING_DEVICE_PATH,\r | |
1233 | MSG_ATAPI_DP,\r | |
1234 | DevPathSerialAtapi,\r | |
1235 | DevPathCompareDefault\r | |
1236 | },\r | |
1237 | {\r | |
1238 | MESSAGING_DEVICE_PATH,\r | |
1239 | MSG_SCSI_DP,\r | |
1240 | DevPathSerialScsi,\r | |
1241 | DevPathCompareDefault\r | |
1242 | },\r | |
1243 | {\r | |
1244 | MESSAGING_DEVICE_PATH,\r | |
1245 | MSG_FIBRECHANNEL_DP,\r | |
1246 | DevPathSerialFibre,\r | |
1247 | DevPathCompareDefault\r | |
1248 | },\r | |
1249 | {\r | |
1250 | MESSAGING_DEVICE_PATH,\r | |
1251 | MSG_1394_DP,\r | |
1252 | DevPathSerial1394,\r | |
1253 | DevPathCompareDefault\r | |
1254 | },\r | |
1255 | {\r | |
1256 | MESSAGING_DEVICE_PATH,\r | |
1257 | MSG_USB_DP,\r | |
1258 | DevPathSerialUsb,\r | |
1259 | DevPathCompareDefault\r | |
1260 | },\r | |
1261 | {\r | |
1262 | MESSAGING_DEVICE_PATH,\r | |
1263 | MSG_I2O_DP,\r | |
1264 | DevPathSerialI2O,\r | |
1265 | DevPathCompareDefault\r | |
1266 | },\r | |
1267 | {\r | |
1268 | MESSAGING_DEVICE_PATH,\r | |
1269 | MSG_MAC_ADDR_DP,\r | |
1270 | DevPathSerialMacAddr,\r | |
1271 | DevPathCompareDefault\r | |
1272 | },\r | |
1273 | {\r | |
1274 | MESSAGING_DEVICE_PATH,\r | |
1275 | MSG_IPv4_DP,\r | |
1276 | DevPathSerialIPv4,\r | |
1277 | DevPathCompareDefault\r | |
1278 | },\r | |
1279 | {\r | |
1280 | MESSAGING_DEVICE_PATH,\r | |
1281 | MSG_IPv6_DP,\r | |
1282 | DevPathSerialIPv6,\r | |
1283 | DevPathCompareDefault\r | |
1284 | },\r | |
1285 | {\r | |
1286 | MESSAGING_DEVICE_PATH,\r | |
1287 | MSG_INFINIBAND_DP,\r | |
1288 | DevPathSerialInfiniBand,\r | |
1289 | DevPathCompareDefault\r | |
1290 | },\r | |
1291 | {\r | |
1292 | MESSAGING_DEVICE_PATH,\r | |
1293 | MSG_UART_DP,\r | |
1294 | DevPathSerialUart,\r | |
1295 | DevPathCompareDefault\r | |
1296 | },\r | |
1297 | {\r | |
1298 | MESSAGING_DEVICE_PATH,\r | |
1299 | MSG_VENDOR_DP,\r | |
1300 | DevPathSerialVendor,\r | |
1301 | DevPathCompareDefault\r | |
1302 | },\r | |
1303 | {\r | |
1304 | MESSAGING_DEVICE_PATH,\r | |
1305 | MSG_DEVICE_LOGICAL_UNIT_DP,\r | |
1306 | DevPathSerialLun,\r | |
1307 | DevPathCompareDefault\r | |
1308 | },\r | |
1309 | {\r | |
1310 | MESSAGING_DEVICE_PATH,\r | |
1311 | MSG_SATA_DP,\r | |
1312 | DevPathSerialSata,\r | |
1313 | DevPathCompareDefault\r | |
1314 | },\r | |
1315 | {\r | |
1316 | MESSAGING_DEVICE_PATH,\r | |
1317 | MSG_ISCSI_DP,\r | |
1318 | DevPathSerialIScsi,\r | |
1319 | DevPathCompareDefault\r | |
1320 | },\r | |
1321 | {\r | |
1322 | MEDIA_DEVICE_PATH,\r | |
1323 | MEDIA_HARDDRIVE_DP,\r | |
1324 | DevPathSerialHardDrive,\r | |
1325 | DevPathCompareDefault\r | |
1326 | },\r | |
1327 | {\r | |
1328 | MEDIA_DEVICE_PATH,\r | |
1329 | MEDIA_CDROM_DP,\r | |
1330 | DevPathSerialCdRom,\r | |
1331 | DevPathCompareDefault\r | |
1332 | },\r | |
1333 | {\r | |
1334 | MEDIA_DEVICE_PATH,\r | |
1335 | MEDIA_VENDOR_DP,\r | |
1336 | DevPathSerialVendor,\r | |
1337 | DevPathCompareDefault\r | |
1338 | },\r | |
1339 | {\r | |
1340 | 0,\r | |
1341 | 0,\r | |
1342 | NULL,\r | |
1343 | NULL\r | |
1344 | }\r | |
a405b86d | 1345 | };\r |
1346 | \r | |
1347 | /**\r | |
1348 | Function to determine if a device path node is Hi or not.\r | |
1349 | \r | |
1350 | @param[in] DevicePathNode The node to check.\r | |
1351 | \r | |
1a63ec8f | 1352 | @retval TRUE The node is Hi.\r |
1353 | @retval FALSE The node is not Hi.\r | |
a405b86d | 1354 | **/\r |
1355 | BOOLEAN\r | |
a405b86d | 1356 | IsHIDevicePathNode (\r |
47d20b54 | 1357 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode\r |
a405b86d | 1358 | )\r |
1359 | {\r | |
1360 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
1361 | \r | |
47d20b54 | 1362 | ASSERT (DevicePathNode != NULL);\r |
a405b86d | 1363 | \r |
1364 | if (DevicePathNode->Type == HARDWARE_DEVICE_PATH) {\r | |
1365 | return TRUE;\r | |
1366 | }\r | |
1367 | \r | |
1368 | if (DevicePathNode->Type == ACPI_DEVICE_PATH) {\r | |
47d20b54 | 1369 | Acpi = (ACPI_HID_DEVICE_PATH *)DevicePathNode;\r |
a405b86d | 1370 | switch (EISA_ID_TO_NUM (Acpi->HID)) {\r |
47d20b54 MK |
1371 | case 0x0301:\r |
1372 | case 0x0401:\r | |
1373 | case 0x0501:\r | |
1374 | case 0x0604:\r | |
1375 | return FALSE;\r | |
a405b86d | 1376 | }\r |
1377 | \r | |
1378 | return TRUE;\r | |
1379 | }\r | |
1380 | \r | |
1381 | return FALSE;\r | |
1382 | }\r | |
1383 | \r | |
1384 | /**\r | |
1a63ec8f | 1385 | Function to convert a standard device path structure into a Hi version.\r |
a405b86d | 1386 | \r |
1387 | @param[in] DevicePath The device path to convert.\r | |
1388 | \r | |
1a63ec8f | 1389 | @return the device path portion that is Hi.\r |
a405b86d | 1390 | **/\r |
1391 | EFI_DEVICE_PATH_PROTOCOL *\r | |
a405b86d | 1392 | GetHIDevicePath (\r |
47d20b54 | 1393 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r |
a405b86d | 1394 | )\r |
1395 | {\r | |
1396 | UINTN NonHIDevicePathNodeCount;\r | |
1397 | UINTN Index;\r | |
1398 | EFI_DEV_PATH Node;\r | |
1399 | EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;\r | |
1400 | EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r | |
1401 | \r | |
47d20b54 | 1402 | ASSERT (DevicePath != NULL);\r |
a405b86d | 1403 | \r |
47d20b54 | 1404 | NonHIDevicePathNodeCount = 0;\r |
a405b86d | 1405 | \r |
47d20b54 | 1406 | HIDevicePath = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));\r |
a405b86d | 1407 | SetDevicePathEndNode (HIDevicePath);\r |
1408 | \r | |
47d20b54 MK |
1409 | Node.DevPath.Type = END_DEVICE_PATH_TYPE;\r |
1410 | Node.DevPath.SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;\r | |
1411 | Node.DevPath.Length[0] = (UINT8)sizeof (EFI_DEVICE_PATH_PROTOCOL);\r | |
1412 | Node.DevPath.Length[1] = 0;\r | |
a405b86d | 1413 | \r |
1414 | while (!IsDevicePathEnd (DevicePath)) {\r | |
1415 | if (IsHIDevicePathNode (DevicePath)) {\r | |
1416 | for (Index = 0; Index < NonHIDevicePathNodeCount; Index++) {\r | |
1417 | TempDevicePath = AppendDevicePathNode (HIDevicePath, &Node.DevPath);\r | |
1418 | FreePool (HIDevicePath);\r | |
1419 | HIDevicePath = TempDevicePath;\r | |
1420 | }\r | |
1421 | \r | |
1422 | TempDevicePath = AppendDevicePathNode (HIDevicePath, DevicePath);\r | |
1423 | FreePool (HIDevicePath);\r | |
1424 | HIDevicePath = TempDevicePath;\r | |
1425 | } else {\r | |
1426 | NonHIDevicePathNodeCount++;\r | |
1427 | }\r | |
47d20b54 | 1428 | \r |
a405b86d | 1429 | //\r |
1430 | // Next device path node\r | |
1431 | //\r | |
47d20b54 | 1432 | DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)NextDevicePathNode (DevicePath);\r |
a405b86d | 1433 | }\r |
1434 | \r | |
1435 | return HIDevicePath;\r | |
1436 | }\r | |
1437 | \r | |
1438 | /**\r | |
1439 | Function to walk the device path looking for a dumpable node.\r | |
1440 | \r | |
1441 | @param[in] MappingItem The Item to fill with data.\r | |
1442 | @param[in] DevicePath The path of the item to get data on.\r | |
1443 | \r | |
1444 | @return EFI_SUCCESS Always returns success.\r | |
1445 | **/\r | |
1446 | EFI_STATUS\r | |
a405b86d | 1447 | GetDeviceConsistMappingInfo (\r |
47d20b54 MK |
1448 | IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,\r |
1449 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
a405b86d | 1450 | )\r |
1451 | {\r | |
2c7c3b87 | 1452 | EFI_STATUS Status;\r |
41089802 | 1453 | SERIAL_DECODE_FUNCTION SerialFun;\r |
0db3fade | 1454 | UINTN Index;\r |
1455 | EFI_DEVICE_PATH_PROTOCOL *OriginalDevicePath;\r | |
a405b86d | 1456 | \r |
47d20b54 MK |
1457 | ASSERT (DevicePath != NULL);\r |
1458 | ASSERT (MappingItem != NULL);\r | |
a405b86d | 1459 | \r |
1a63ec8f | 1460 | SetMem (&MappingItem->Csd, sizeof (POOL_PRINT), 0);\r |
0db3fade | 1461 | OriginalDevicePath = DevicePath;\r |
a405b86d | 1462 | \r |
1463 | while (!IsDevicePathEnd (DevicePath)) {\r | |
1464 | //\r | |
0db3fade | 1465 | // Find the handler to dump this device path node and\r |
1466 | // initialize with generic function in case nothing is found\r | |
a405b86d | 1467 | //\r |
0db3fade | 1468 | for (SerialFun = DevPathSerialDefault, Index = 0; DevPathConsistMappingTable[Index].SerialFun != NULL; Index += 1) {\r |
47d20b54 MK |
1469 | if ((DevicePathType (DevicePath) == DevPathConsistMappingTable[Index].Type) &&\r |
1470 | (DevicePathSubType (DevicePath) == DevPathConsistMappingTable[Index].SubType)\r | |
1471 | )\r | |
1472 | {\r | |
a405b86d | 1473 | SerialFun = DevPathConsistMappingTable[Index].SerialFun;\r |
1474 | break;\r | |
1475 | }\r | |
1476 | }\r | |
a405b86d | 1477 | \r |
2c7c3b87 RN |
1478 | Status = SerialFun (DevicePath, MappingItem, OriginalDevicePath);\r |
1479 | if (EFI_ERROR (Status)) {\r | |
1480 | SHELL_FREE_NON_NULL (MappingItem->Csd.Str);\r | |
1481 | return Status;\r | |
1482 | }\r | |
a405b86d | 1483 | \r |
1484 | //\r | |
1485 | // Next device path node\r | |
1486 | //\r | |
47d20b54 | 1487 | DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)NextDevicePathNode (DevicePath);\r |
a405b86d | 1488 | }\r |
1489 | \r | |
1490 | return EFI_SUCCESS;\r | |
1491 | }\r | |
1492 | \r | |
1493 | /**\r | |
1494 | Function to initialize the table for creating consistent map names.\r | |
1495 | \r | |
1496 | @param[out] Table The pointer to pointer to pointer to DevicePathProtocol object.\r | |
1497 | \r | |
1498 | @retval EFI_SUCCESS The table was created successfully.\r | |
1499 | **/\r | |
1500 | EFI_STATUS\r | |
1501 | EFIAPI\r | |
1502 | ShellCommandConsistMappingInitialize (\r | |
47d20b54 | 1503 | OUT EFI_DEVICE_PATH_PROTOCOL ***Table\r |
a405b86d | 1504 | )\r |
1505 | {\r | |
47d20b54 MK |
1506 | EFI_HANDLE *HandleBuffer;\r |
1507 | UINTN HandleNum;\r | |
1508 | UINTN HandleLoop;\r | |
1509 | EFI_DEVICE_PATH_PROTOCOL **TempTable;\r | |
1510 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
1511 | EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;\r | |
1512 | EFI_BLOCK_IO_PROTOCOL *BlockIo;\r | |
1513 | EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;\r | |
1514 | UINTN Index;\r | |
1515 | EFI_STATUS Status;\r | |
1516 | \r | |
1517 | HandleBuffer = NULL;\r | |
a405b86d | 1518 | \r |
1519 | Status = gBS->LocateHandleBuffer (\r | |
47d20b54 MK |
1520 | ByProtocol,\r |
1521 | &gEfiDevicePathProtocolGuid,\r | |
1522 | NULL,\r | |
1523 | &HandleNum,\r | |
1524 | &HandleBuffer\r | |
1525 | );\r | |
1526 | ASSERT_EFI_ERROR (Status);\r | |
1527 | \r | |
1528 | TempTable = AllocateZeroPool ((HandleNum + 1) * sizeof (EFI_DEVICE_PATH_PROTOCOL *));\r | |
a405b86d | 1529 | if (TempTable == NULL) {\r |
1530 | return EFI_OUT_OF_RESOURCES;\r | |
1531 | }\r | |
1532 | \r | |
47d20b54 | 1533 | for (HandleLoop = 0; HandleLoop < HandleNum; HandleLoop++) {\r |
a405b86d | 1534 | DevicePath = DevicePathFromHandle (HandleBuffer[HandleLoop]);\r |
1535 | if (DevicePath == NULL) {\r | |
1536 | continue;\r | |
1537 | }\r | |
1538 | \r | |
1539 | HIDevicePath = GetHIDevicePath (DevicePath);\r | |
1540 | if (HIDevicePath == NULL) {\r | |
1541 | continue;\r | |
1542 | }\r | |
1543 | \r | |
47d20b54 MK |
1544 | Status = gBS->HandleProtocol (\r |
1545 | HandleBuffer[HandleLoop],\r | |
1546 | &gEfiBlockIoProtocolGuid,\r | |
1547 | (VOID **)&BlockIo\r | |
1548 | );\r | |
1549 | if (EFI_ERROR (Status)) {\r | |
1550 | Status = gBS->HandleProtocol (\r | |
1551 | HandleBuffer[HandleLoop],\r | |
1552 | &gEfiSimpleFileSystemProtocolGuid,\r | |
1553 | (VOID **)&SimpleFileSystem\r | |
1554 | );\r | |
1555 | if (EFI_ERROR (Status)) {\r | |
990046ca | 1556 | FreePool (HIDevicePath);\r |
e9fc5387 QS |
1557 | continue;\r |
1558 | }\r | |
1559 | }\r | |
1560 | \r | |
a405b86d | 1561 | for (Index = 0; TempTable[Index] != NULL; Index++) {\r |
1562 | if (DevicePathCompare (&TempTable[Index], &HIDevicePath) == 0) {\r | |
1563 | FreePool (HIDevicePath);\r | |
1564 | break;\r | |
1565 | }\r | |
1566 | }\r | |
1567 | \r | |
1568 | if (TempTable[Index] == NULL) {\r | |
1569 | TempTable[Index] = HIDevicePath;\r | |
1570 | }\r | |
1571 | }\r | |
1572 | \r | |
47d20b54 MK |
1573 | for (Index = 0; TempTable[Index] != NULL; Index++) {\r |
1574 | }\r | |
1575 | \r | |
1576 | PerformQuickSort (TempTable, Index, sizeof (EFI_DEVICE_PATH_PROTOCOL *), DevicePathCompare);\r | |
a405b86d | 1577 | *Table = TempTable;\r |
1578 | \r | |
1579 | if (HandleBuffer != NULL) {\r | |
1580 | FreePool (HandleBuffer);\r | |
1581 | }\r | |
1582 | \r | |
1583 | return EFI_SUCCESS;\r | |
1584 | }\r | |
1585 | \r | |
1586 | /**\r | |
1587 | Function to uninitialize the table for creating consistent map names.\r | |
1588 | \r | |
1589 | The parameter must have been received from ShellCommandConsistMappingInitialize.\r | |
1590 | \r | |
1591 | @param[out] Table The pointer to pointer to DevicePathProtocol object.\r | |
1592 | \r | |
1593 | @retval EFI_SUCCESS The table was deleted successfully.\r | |
1594 | **/\r | |
1595 | EFI_STATUS\r | |
1596 | EFIAPI\r | |
1597 | ShellCommandConsistMappingUnInitialize (\r | |
47d20b54 | 1598 | EFI_DEVICE_PATH_PROTOCOL **Table\r |
a405b86d | 1599 | )\r |
1600 | {\r | |
47d20b54 | 1601 | UINTN Index;\r |
a405b86d | 1602 | \r |
47d20b54 | 1603 | ASSERT (Table != NULL);\r |
a405b86d | 1604 | \r |
1605 | for (Index = 0; Table[Index] != NULL; Index++) {\r | |
1606 | FreePool (Table[Index]);\r | |
1607 | }\r | |
1608 | \r | |
1609 | FreePool (Table);\r | |
1610 | return EFI_SUCCESS;\r | |
1611 | }\r | |
1612 | \r | |
1613 | /**\r | |
e26d7b59 | 1614 | Create a consistent mapped name for the device specified by DevicePath\r |
a405b86d | 1615 | based on the Table.\r |
1616 | \r | |
e26d7b59 | 1617 | This must be called after ShellCommandConsistMappingInitialize() and\r |
a405b86d | 1618 | before ShellCommandConsistMappingUnInitialize() is called.\r |
1619 | \r | |
1a63ec8f | 1620 | @param[in] DevicePath The pointer to the dev path for the device.\r |
a405b86d | 1621 | @param[in] Table The Table of mapping information.\r |
1622 | \r | |
1623 | @retval NULL A consistent mapped name could not be created.\r | |
1624 | @return A pointer to a string allocated from pool with the device name.\r | |
1625 | **/\r | |
1626 | CHAR16 *\r | |
1627 | EFIAPI\r | |
1628 | ShellCommandConsistMappingGenMappingName (\r | |
47d20b54 MK |
1629 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r |
1630 | IN EFI_DEVICE_PATH_PROTOCOL **Table\r | |
a405b86d | 1631 | )\r |
1632 | {\r | |
47d20b54 MK |
1633 | EFI_STATUS Status;\r |
1634 | POOL_PRINT Str;\r | |
1635 | DEVICE_CONSIST_MAPPING_INFO MappingInfo;\r | |
1636 | EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;\r | |
1637 | UINTN Index;\r | |
a405b86d | 1638 | \r |
47d20b54 MK |
1639 | ASSERT (DevicePath != NULL);\r |
1640 | ASSERT (Table != NULL);\r | |
a405b86d | 1641 | \r |
1642 | HIDevicePath = GetHIDevicePath (DevicePath);\r | |
1643 | if (HIDevicePath == NULL) {\r | |
1644 | return NULL;\r | |
1645 | }\r | |
1646 | \r | |
1647 | for (Index = 0; Table[Index] != NULL; Index++) {\r | |
1648 | if (DevicePathCompare (&Table[Index], &HIDevicePath) == 0) {\r | |
1649 | break;\r | |
1650 | }\r | |
1651 | }\r | |
1652 | \r | |
1653 | FreePool (HIDevicePath);\r | |
1654 | if (Table[Index] == NULL) {\r | |
1655 | return NULL;\r | |
1656 | }\r | |
1657 | \r | |
1a63ec8f | 1658 | MappingInfo.Hi = Index;\r |
1659 | MappingInfo.Mtd = MTDTypeUnknown;\r | |
a405b86d | 1660 | MappingInfo.Digital = FALSE;\r |
1661 | \r | |
2c7c3b87 RN |
1662 | Status = GetDeviceConsistMappingInfo (&MappingInfo, DevicePath);\r |
1663 | if (EFI_ERROR (Status)) {\r | |
1664 | return NULL;\r | |
1665 | }\r | |
a405b86d | 1666 | \r |
1667 | SetMem (&Str, sizeof (Str), 0);\r | |
1668 | for (Index = 0; mMTDName[Index].MTDType != MTDTypeEnd; Index++) {\r | |
1a63ec8f | 1669 | if (MappingInfo.Mtd == mMTDName[Index].MTDType) {\r |
a405b86d | 1670 | break;\r |
1671 | }\r | |
1672 | }\r | |
1673 | \r | |
1674 | if (mMTDName[Index].MTDType != MTDTypeEnd) {\r | |
2c7c3b87 | 1675 | Status = CatPrint (&Str, L"%s", mMTDName[Index].Name);\r |
a405b86d | 1676 | }\r |
1677 | \r | |
2c7c3b87 | 1678 | if (!EFI_ERROR (Status)) {\r |
47d20b54 | 1679 | Status = CatPrint (&Str, L"%d", (UINTN)MappingInfo.Hi);\r |
2c7c3b87 | 1680 | }\r |
47d20b54 MK |
1681 | \r |
1682 | if (!EFI_ERROR (Status) && (MappingInfo.Csd.Str != NULL)) {\r | |
2c7c3b87 | 1683 | Status = CatPrint (&Str, L"%s", MappingInfo.Csd.Str);\r |
1a63ec8f | 1684 | FreePool (MappingInfo.Csd.Str);\r |
a405b86d | 1685 | }\r |
1686 | \r | |
47d20b54 | 1687 | if (!EFI_ERROR (Status) && (Str.Str != NULL)) {\r |
2c7c3b87 RN |
1688 | Status = CatPrint (&Str, L":");\r |
1689 | }\r | |
47d20b54 | 1690 | \r |
2c7c3b87 RN |
1691 | if (EFI_ERROR (Status)) {\r |
1692 | SHELL_FREE_NON_NULL (Str.Str);\r | |
1693 | return NULL;\r | |
a405b86d | 1694 | }\r |
1695 | \r | |
17c3dc19 | 1696 | return Str.Str;\r |
a405b86d | 1697 | }\r |
1698 | \r | |
1699 | /**\r | |
1700 | Function to search the list of mappings for the node on the list based on the key.\r | |
1701 | \r | |
1702 | @param[in] MapKey String Key to search for on the map\r | |
1703 | \r | |
1704 | @return the node on the list.\r | |
1705 | **/\r | |
1706 | SHELL_MAP_LIST *\r | |
1707 | EFIAPI\r | |
1708 | ShellCommandFindMapItem (\r | |
47d20b54 | 1709 | IN CONST CHAR16 *MapKey\r |
a405b86d | 1710 | )\r |
1711 | {\r | |
47d20b54 | 1712 | SHELL_MAP_LIST *MapListItem;\r |
a405b86d | 1713 | \r |
47d20b54 MK |
1714 | for ( MapListItem = (SHELL_MAP_LIST *)GetFirstNode (&gShellMapList.Link)\r |
1715 | ; !IsNull (&gShellMapList.Link, &MapListItem->Link)\r | |
1716 | ; MapListItem = (SHELL_MAP_LIST *)GetNextNode (&gShellMapList.Link, &MapListItem->Link)\r | |
1717 | )\r | |
1718 | {\r | |
1719 | if (gUnicodeCollation->StriColl (gUnicodeCollation, MapListItem->MapName, (CHAR16 *)MapKey) == 0) {\r | |
a405b86d | 1720 | return (MapListItem);\r |
1721 | }\r | |
1722 | }\r | |
47d20b54 | 1723 | \r |
a405b86d | 1724 | return (NULL);\r |
1725 | }\r |