MdePkg: Move SMBIOS data into the IndustryStandard header.
[mirror_edk2.git] / ShellPkg / Library / UefiHandleParsingLib / UefiHandleParsingLib.c
CommitLineData
a405b86d 1/** @file\r
2 Provides interface to advanced shell functionality for parsing both handle and protocol database.\r
3\r
00a6ad1b 4 Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
256aa6d0
SEHM
5 (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
6 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
a405b86d 7 This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include "UefiHandleParsingLib.h"\r
f4f3c6bf 18#include "IndustryStandard/Acpi10.h"\r
a405b86d 19\r
e7e0e42b 20EFI_HANDLE mHandleParsingHiiHandle = NULL;\r
a405b86d 21HANDLE_INDEX_LIST mHandleList = {{{NULL,NULL},0,0},0};\r
6306fd90
JC
22GUID_INFO_BLOCK *GuidList;\r
23UINTN GuidListCount;\r
efb76d1a
JC
24/**\r
25 Function to translate the EFI_MEMORY_TYPE into a string.\r
26\r
27 @param[in] Memory The memory type.\r
28\r
29 @retval A string representation of the type allocated from BS Pool.\r
30**/\r
31CHAR16*\r
32EFIAPI\r
33ConvertMemoryType (\r
34 IN CONST EFI_MEMORY_TYPE Memory\r
35 )\r
36{\r
37 CHAR16 *RetVal;\r
38 RetVal = NULL;\r
39\r
40 switch (Memory) {\r
41 case EfiReservedMemoryType: StrnCatGrow(&RetVal, NULL, L"EfiReservedMemoryType", 0); break;\r
42 case EfiLoaderCode: StrnCatGrow(&RetVal, NULL, L"EfiLoaderCode", 0); break;\r
43 case EfiLoaderData: StrnCatGrow(&RetVal, NULL, L"EfiLoaderData", 0); break;\r
44 case EfiBootServicesCode: StrnCatGrow(&RetVal, NULL, L"EfiBootServicesCode", 0); break;\r
45 case EfiBootServicesData: StrnCatGrow(&RetVal, NULL, L"EfiBootServicesData", 0); break;\r
46 case EfiRuntimeServicesCode: StrnCatGrow(&RetVal, NULL, L"EfiRuntimeServicesCode", 0); break;\r
47 case EfiRuntimeServicesData: StrnCatGrow(&RetVal, NULL, L"EfiRuntimeServicesData", 0); break;\r
48 case EfiConventionalMemory: StrnCatGrow(&RetVal, NULL, L"EfiConventionalMemory", 0); break;\r
49 case EfiUnusableMemory: StrnCatGrow(&RetVal, NULL, L"EfiUnusableMemory", 0); break;\r
50 case EfiACPIReclaimMemory: StrnCatGrow(&RetVal, NULL, L"EfiACPIReclaimMemory", 0); break;\r
51 case EfiACPIMemoryNVS: StrnCatGrow(&RetVal, NULL, L"EfiACPIMemoryNVS", 0); break;\r
52 case EfiMemoryMappedIO: StrnCatGrow(&RetVal, NULL, L"EfiMemoryMappedIO", 0); break;\r
53 case EfiMemoryMappedIOPortSpace: StrnCatGrow(&RetVal, NULL, L"EfiMemoryMappedIOPortSpace", 0); break;\r
54 case EfiPalCode: StrnCatGrow(&RetVal, NULL, L"EfiPalCode", 0); break;\r
55 case EfiMaxMemoryType: StrnCatGrow(&RetVal, NULL, L"EfiMaxMemoryType", 0); break;\r
56 default: ASSERT(FALSE);\r
57 }\r
58 return (RetVal);\r
59}\r
60\r
609e0c58
JC
61/**\r
62 Function to translate the EFI_GRAPHICS_PIXEL_FORMAT into a string.\r
63\r
9145d314 64 @param[in] Fmt The format type.\r
609e0c58
JC
65\r
66 @retval A string representation of the type allocated from BS Pool.\r
67**/\r
68CHAR16*\r
69EFIAPI\r
70ConvertPixelFormat (\r
71 IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt\r
72 )\r
73{\r
74 CHAR16 *RetVal;\r
75 RetVal = NULL;\r
76\r
77 switch (Fmt) {\r
78 case PixelRedGreenBlueReserved8BitPerColor: StrnCatGrow(&RetVal, NULL, L"PixelRedGreenBlueReserved8BitPerColor", 0); break;\r
79 case PixelBlueGreenRedReserved8BitPerColor: StrnCatGrow(&RetVal, NULL, L"PixelBlueGreenRedReserved8BitPerColor", 0); break;\r
80 case PixelBitMask: StrnCatGrow(&RetVal, NULL, L"PixelBitMask", 0); break;\r
81 case PixelBltOnly: StrnCatGrow(&RetVal, NULL, L"PixelBltOnly", 0); break;\r
82 case PixelFormatMax: StrnCatGrow(&RetVal, NULL, L"PixelFormatMax", 0); break;\r
83 default: ASSERT(FALSE);\r
84 }\r
85 return (RetVal);\r
86}\r
87\r
a405b86d 88/**\r
89 Constructor for the library.\r
90\r
91 @param[in] ImageHandle Ignored.\r
92 @param[in] SystemTable Ignored.\r
93\r
94 @retval EFI_SUCCESS The operation was successful.\r
95**/\r
96EFI_STATUS\r
97EFIAPI\r
98HandleParsingLibConstructor (\r
99 IN EFI_HANDLE ImageHandle,\r
100 IN EFI_SYSTEM_TABLE *SystemTable\r
101 )\r
102{\r
6306fd90
JC
103 GuidListCount = 0;\r
104 GuidList = NULL;\r
105\r
e7e0e42b
CP
106 //\r
107 // Do nothing with mHandleParsingHiiHandle. Initialize HII as needed.\r
108 //\r
109 return (EFI_SUCCESS);\r
110}\r
111\r
1a6f74d9 112/**\r
e7e0e42b 113 Initialization function for HII packages.\r
1a6f74d9 114\r
e7e0e42b
CP
115**/\r
116VOID\r
117HandleParsingHiiInit (VOID)\r
118{\r
a405b86d 119 if (mHandleParsingHiiHandle == NULL) {\r
e7e0e42b
CP
120 mHandleParsingHiiHandle = HiiAddPackages (&gHandleParsingHiiGuid, gImageHandle, UefiHandleParsingLibStrings, NULL);\r
121 ASSERT (mHandleParsingHiiHandle != NULL);\r
a405b86d 122 }\r
a405b86d 123}\r
124\r
125/**\r
126 Destructor for the library. free any resources.\r
127\r
128 @param[in] ImageHandle Ignored.\r
129 @param[in] SystemTable Ignored.\r
130\r
131 @retval EFI_SUCCESS The operation was successful.\r
132**/\r
133EFI_STATUS\r
134EFIAPI\r
135HandleParsingLibDestructor (\r
136 IN EFI_HANDLE ImageHandle,\r
137 IN EFI_SYSTEM_TABLE *SystemTable\r
138 )\r
139{\r
6306fd90
JC
140 UINTN LoopCount;\r
141\r
142 for (LoopCount = 0; GuidList != NULL && LoopCount < GuidListCount; LoopCount++) {\r
143 SHELL_FREE_NON_NULL(GuidList[LoopCount].GuidId);\r
144 }\r
145\r
146 SHELL_FREE_NON_NULL(GuidList);\r
a405b86d 147 if (mHandleParsingHiiHandle != NULL) {\r
148 HiiRemovePackages(mHandleParsingHiiHandle);\r
149 }\r
150 return (EFI_SUCCESS);\r
151}\r
152\r
efb76d1a
JC
153/**\r
154 Function to dump information about LoadedImage.\r
155\r
156 This will allocate the return buffer from boot services pool.\r
157\r
158 @param[in] TheHandle The handle that has LoadedImage installed.\r
159 @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
160\r
161 @retval A poitner to a string containing the information.\r
162**/\r
a405b86d 163CHAR16*\r
164EFIAPI\r
165LoadedImageProtocolDumpInformation(\r
166 IN CONST EFI_HANDLE TheHandle,\r
167 IN CONST BOOLEAN Verbose\r
168 )\r
169{\r
efb76d1a 170 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
a405b86d 171 EFI_STATUS Status;\r
efb76d1a
JC
172 CHAR16 *RetVal;\r
173 CHAR16 *Temp;\r
174 CHAR16 *CodeType;\r
175 CHAR16 *DataType;\r
a405b86d 176\r
efb76d1a
JC
177 if (!Verbose) {\r
178 return (CatSPrint(NULL, L"LoadedImage"));\r
a405b86d 179 }\r
180\r
e7e0e42b
CP
181 HandleParsingHiiInit();\r
182\r
efb76d1a 183 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_MAIN), NULL);\r
1a6f74d9 184 if (Temp == NULL) {\r
efb76d1a 185 return NULL;\r
a405b86d 186 }\r
187\r
efb76d1a
JC
188 Status = gBS->OpenProtocol (\r
189 TheHandle,\r
190 &gEfiLoadedImageProtocolGuid,\r
191 (VOID**)&LoadedImage,\r
192 gImageHandle,\r
193 NULL,\r
194 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
195 );\r
196\r
5f119dfc
HL
197 if (EFI_ERROR (Status)) {\r
198 SHELL_FREE_NON_NULL (Temp);\r
5f119dfc
HL
199 return NULL;\r
200 }\r
201\r
efb76d1a
JC
202 DataType = ConvertMemoryType(LoadedImage->ImageDataType);\r
203 CodeType = ConvertMemoryType(LoadedImage->ImageCodeType);\r
204\r
1a6f74d9
CS
205 RetVal = CatSPrint(\r
206 NULL,\r
207 Temp,\r
208 LoadedImage->Revision,\r
209 LoadedImage->ParentHandle,\r
210 LoadedImage->SystemTable,\r
211 LoadedImage->DeviceHandle,\r
212 LoadedImage->FilePath,\r
213 LoadedImage->LoadOptionsSize,\r
214 LoadedImage->LoadOptions,\r
215 LoadedImage->ImageBase,\r
216 LoadedImage->ImageSize,\r
217 CodeType,\r
218 DataType,\r
219 LoadedImage->Unload\r
220 );\r
221\r
222\r
efb76d1a
JC
223 SHELL_FREE_NON_NULL(Temp);\r
224 SHELL_FREE_NON_NULL(CodeType);\r
225 SHELL_FREE_NON_NULL(DataType);\r
226\r
227 return RetVal;\r
a405b86d 228}\r
a405b86d 229\r
609e0c58
JC
230/**\r
231 Function to dump information about GOP.\r
232\r
233 This will allocate the return buffer from boot services pool.\r
234\r
235 @param[in] TheHandle The handle that has LoadedImage installed.\r
236 @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
237\r
238 @retval A poitner to a string containing the information.\r
239**/\r
240CHAR16*\r
241EFIAPI\r
242GraphicsOutputProtocolDumpInformation(\r
243 IN CONST EFI_HANDLE TheHandle,\r
244 IN CONST BOOLEAN Verbose\r
245 )\r
246{\r
247 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
248 EFI_STATUS Status;\r
249 CHAR16 *RetVal;\r
250 CHAR16 *Temp;\r
251 CHAR16 *Fmt;\r
252\r
253 if (!Verbose) {\r
254 return (CatSPrint(NULL, L"GraphicsOutput"));\r
255 }\r
256\r
e7e0e42b
CP
257 HandleParsingHiiInit();\r
258\r
609e0c58 259 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_GOP_DUMP_MAIN), NULL);\r
1a6f74d9 260 if (Temp == NULL) {\r
609e0c58
JC
261 return NULL;\r
262 }\r
263\r
264 Status = gBS->OpenProtocol (\r
265 TheHandle,\r
266 &gEfiGraphicsOutputProtocolGuid,\r
267 (VOID**)&GraphicsOutput,\r
268 gImageHandle,\r
269 NULL,\r
270 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
271 );\r
272\r
273 if (EFI_ERROR (Status)) {\r
274 SHELL_FREE_NON_NULL (Temp);\r
609e0c58
JC
275 return NULL;\r
276 }\r
277\r
278 Fmt = ConvertPixelFormat(GraphicsOutput->Mode->Info->PixelFormat);\r
279\r
1a6f74d9
CS
280 RetVal = CatSPrint(\r
281 NULL,\r
282 Temp,\r
283 GraphicsOutput->Mode->MaxMode,\r
284 GraphicsOutput->Mode->Mode,\r
285 GraphicsOutput->Mode->FrameBufferBase,\r
286 (UINT64)GraphicsOutput->Mode->FrameBufferSize,\r
287 (UINT64)GraphicsOutput->Mode->SizeOfInfo,\r
288 GraphicsOutput->Mode->Info->Version,\r
289 GraphicsOutput->Mode->Info->HorizontalResolution,\r
290 GraphicsOutput->Mode->Info->VerticalResolution,\r
291 Fmt,\r
292 GraphicsOutput->Mode->Info->PixelsPerScanLine,\r
293 GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.RedMask,\r
294 GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.GreenMask,\r
295 GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.BlueMask\r
296 );\r
297\r
609e0c58
JC
298 SHELL_FREE_NON_NULL(Temp);\r
299 SHELL_FREE_NON_NULL(Fmt);\r
300\r
301 return RetVal;\r
302}\r
303\r
f4f3c6bf 304/**\r
305 Function to dump information about PciRootBridgeIo.\r
306\r
307 This will allocate the return buffer from boot services pool.\r
308\r
309 @param[in] TheHandle The handle that has PciRootBridgeIo installed.\r
310 @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
311\r
312 @retval A poitner to a string containing the information.\r
313**/\r
314CHAR16*\r
315EFIAPI\r
316PciRootBridgeIoDumpInformation(\r
317 IN CONST EFI_HANDLE TheHandle,\r
318 IN CONST BOOLEAN Verbose\r
319 )\r
320{\r
321 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r
322 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Configuration;\r
323 UINT64 Supports;\r
324 UINT64 Attributes;\r
325 CHAR16 *Temp;\r
326 CHAR16 *Temp2;\r
327 CHAR16 *RetVal;\r
328 EFI_STATUS Status;\r
329\r
330 RetVal = NULL;\r
331\r
332 if (!Verbose) {\r
333 return (CatSPrint(NULL, L"PciRootBridgeIo"));\r
334 }\r
335\r
e7e0e42b
CP
336 HandleParsingHiiInit();\r
337\r
f4f3c6bf 338 Status = gBS->HandleProtocol(\r
339 TheHandle,\r
340 &gEfiPciRootBridgeIoProtocolGuid,\r
341 (VOID**)&PciRootBridgeIo);\r
342\r
343 if (EFI_ERROR(Status)) {\r
344 return NULL;\r
345 }\r
346\r
347 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_PH), NULL);\r
1d6ccad2
QS
348 if (Temp == NULL) {\r
349 return NULL;\r
350 }\r
f4f3c6bf 351 Temp2 = CatSPrint(L"\r\n", Temp, PciRootBridgeIo->ParentHandle);\r
352 FreePool(Temp);\r
353 RetVal = Temp2;\r
354 Temp2 = NULL;\r
1a6f74d9 355\r
f4f3c6bf 356 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_SEG), NULL);\r
1d6ccad2
QS
357 if (Temp == NULL) {\r
358 SHELL_FREE_NON_NULL(RetVal);\r
359 return NULL;\r
360 }\r
f4f3c6bf 361 Temp2 = CatSPrint(RetVal, Temp, PciRootBridgeIo->SegmentNumber);\r
362 FreePool(Temp);\r
363 FreePool(RetVal);\r
364 RetVal = Temp2;\r
365 Temp2 = NULL;\r
366\r
367 Supports = 0;\r
368 Attributes = 0;\r
369 Status = PciRootBridgeIo->GetAttributes (PciRootBridgeIo, &Supports, &Attributes);\r
370 if (!EFI_ERROR(Status)) {\r
371 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_ATT), NULL);\r
1d6ccad2
QS
372 if (Temp == NULL) {\r
373 SHELL_FREE_NON_NULL(RetVal);\r
374 return NULL;\r
1a6f74d9 375 }\r
f4f3c6bf 376 Temp2 = CatSPrint(RetVal, Temp, Attributes);\r
377 FreePool(Temp);\r
378 FreePool(RetVal);\r
379 RetVal = Temp2;\r
380 Temp2 = NULL;\r
1a6f74d9 381\r
f4f3c6bf 382 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_SUPPORTS), NULL);\r
1d6ccad2
QS
383 if (Temp == NULL) {\r
384 SHELL_FREE_NON_NULL(RetVal);\r
385 return NULL;\r
386 }\r
f4f3c6bf 387 Temp2 = CatSPrint(RetVal, Temp, Supports);\r
388 FreePool(Temp);\r
389 FreePool(RetVal);\r
390 RetVal = Temp2;\r
391 Temp2 = NULL;\r
392 }\r
393\r
394 Configuration = NULL;\r
395 Status = PciRootBridgeIo->Configuration (PciRootBridgeIo, (VOID **) &Configuration);\r
396 if (!EFI_ERROR(Status) && Configuration != NULL) {\r
397 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_TITLE), NULL);\r
1d6ccad2
QS
398 if (Temp == NULL) {\r
399 SHELL_FREE_NON_NULL(RetVal);\r
400 return NULL;\r
401 }\r
f4f3c6bf 402 Temp2 = CatSPrint(RetVal, Temp, Supports);\r
403 FreePool(Temp);\r
404 FreePool(RetVal);\r
405 RetVal = Temp2;\r
406 Temp2 = NULL;\r
407 while (Configuration->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {\r
408 Temp = NULL;\r
409 switch (Configuration->ResType) {\r
410 case ACPI_ADDRESS_SPACE_TYPE_MEM:\r
411 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_MEM), NULL);\r
412 break;\r
413 case ACPI_ADDRESS_SPACE_TYPE_IO:\r
414 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_IO), NULL);\r
415 break;\r
416 case ACPI_ADDRESS_SPACE_TYPE_BUS:\r
417 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_BUS), NULL);\r
418 break;\r
419 }\r
420 if (Temp != NULL) {\r
421 Temp2 = CatSPrint(RetVal, L"%s", Temp);\r
422 FreePool(Temp);\r
423 FreePool(RetVal);\r
424 RetVal = Temp2;\r
425 Temp2 = NULL;\r
426 }\r
427\r
1a6f74d9 428 Temp2 = CatSPrint(RetVal,\r
f4f3c6bf 429 L"%H%02x %016lx %016lx %02x%N\r\n",\r
430 Configuration->SpecificFlag,\r
431 Configuration->AddrRangeMin,\r
432 Configuration->AddrRangeMax,\r
433 Configuration->AddrSpaceGranularity\r
434 );\r
435 FreePool(RetVal);\r
436 RetVal = Temp2;\r
437 Temp2 = NULL;\r
438 Configuration++;\r
439 }\r
440 }\r
441 return (RetVal);\r
442}\r
443\r
a405b86d 444/**\r
445 Function to dump information about SimpleTextOut.\r
446\r
447 This will allocate the return buffer from boot services pool.\r
448\r
449 @param[in] TheHandle The handle that has SimpleTextOut installed.\r
450 @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
451\r
452 @retval A poitner to a string containing the information.\r
453**/\r
454CHAR16*\r
455EFIAPI\r
456TxtOutProtocolDumpInformation(\r
457 IN CONST EFI_HANDLE TheHandle,\r
458 IN CONST BOOLEAN Verbose\r
459 )\r
460{\r
461 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Dev;\r
462 INTN Index;\r
463 UINTN Col;\r
464 UINTN Row;\r
465 EFI_STATUS Status;\r
466 CHAR16 *RetVal;\r
467 UINTN Size;\r
468 CHAR16 *Temp;\r
469 UINTN NewSize;\r
470\r
471 if (!Verbose) {\r
472 return (NULL);\r
473 }\r
474\r
e7e0e42b
CP
475 HandleParsingHiiInit();\r
476\r
a405b86d 477 RetVal = NULL;\r
478 Size = 0;\r
479\r
480 Status = gBS->HandleProtocol(\r
481 TheHandle,\r
482 &gEfiSimpleTextOutProtocolGuid,\r
483 (VOID**)&Dev);\r
484\r
485 ASSERT_EFI_ERROR(Status);\r
486 ASSERT (Dev != NULL && Dev->Mode != NULL);\r
487\r
488 Size = (Dev->Mode->MaxMode + 1) * 80;\r
489 RetVal = AllocateZeroPool(Size);\r
490\r
491 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_TXT_OUT_DUMP_HEADER), NULL);\r
ecae5117 492 if (Temp != NULL) {\r
493 UnicodeSPrint(RetVal, Size, Temp, Dev, Dev->Mode->Attribute);\r
494 FreePool(Temp);\r
495 }\r
a405b86d 496\r
497 //\r
498 // Dump TextOut Info\r
499 //\r
500 Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_TXT_OUT_DUMP_LINE), NULL);\r
501 for (Index = 0; Index < Dev->Mode->MaxMode; Index++) {\r
502 Status = Dev->QueryMode (Dev, Index, &Col, &Row);\r
503 NewSize = Size - StrSize(RetVal);\r
504 UnicodeSPrint(\r
505 RetVal + StrLen(RetVal),\r
506 NewSize,\r
ecae5117 507 Temp == NULL?L"":Temp,\r
a405b86d 508 Index == Dev->Mode->Mode ? L'*' : L' ',\r
509 Index,\r
28981267 510 !EFI_ERROR(Status)?(INTN)Col:-1,\r
511 !EFI_ERROR(Status)?(INTN)Row:-1\r
a405b86d 512 );\r
513 }\r
514 FreePool(Temp);\r
515 return (RetVal);\r
516}\r
517\r
518STATIC CONST UINTN VersionStringSize = 60;\r
519\r
520/**\r
521 Function to dump information about EfiDriverSupportedEfiVersion protocol.\r
522\r
523 This will allocate the return buffer from boot services pool.\r
524\r
525 @param[in] TheHandle The handle that has the protocol installed.\r
526 @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
527\r
528 @retval A poitner to a string containing the information.\r
529**/\r
530CHAR16*\r
531EFIAPI\r
532DriverEfiVersionProtocolDumpInformation(\r
533 IN CONST EFI_HANDLE TheHandle,\r
534 IN CONST BOOLEAN Verbose\r
535 )\r
536{\r
537 EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL *DriverEfiVersion;\r
538 EFI_STATUS Status;\r
539 CHAR16 *RetVal;\r
540\r
541 Status = gBS->HandleProtocol(\r
542 TheHandle,\r
543 &gEfiDriverSupportedEfiVersionProtocolGuid,\r
544 (VOID**)&DriverEfiVersion);\r
545\r
546 ASSERT_EFI_ERROR(Status);\r
547\r
78ed876b 548 RetVal = AllocateZeroPool(VersionStringSize);\r
a405b86d 549 ASSERT(RetVal != NULL);\r
550 UnicodeSPrint(RetVal, VersionStringSize, L"0x%08x", DriverEfiVersion->FirmwareVersion);\r
551 return (RetVal);\r
552}\r
553\r
554/**\r
555 Function to dump information about DevicePath protocol.\r
556\r
557 This will allocate the return buffer from boot services pool.\r
558\r
559 @param[in] TheHandle The handle that has the protocol installed.\r
560 @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
561\r
562 @retval A poitner to a string containing the information.\r
563**/\r
564CHAR16*\r
565EFIAPI\r
566DevicePathProtocolDumpInformation(\r
567 IN CONST EFI_HANDLE TheHandle,\r
568 IN CONST BOOLEAN Verbose\r
569 )\r
570{\r
571 EFI_DEVICE_PATH_PROTOCOL *DevPath;\r
572 CHAR16 *Temp;\r
573 CHAR16 *Temp2;\r
574 EFI_STATUS Status;\r
a405b86d 575 Temp = NULL;\r
576\r
863986b3 577 Status = gBS->OpenProtocol(TheHandle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
a405b86d 578 if (!EFI_ERROR(Status)) {\r
863986b3
RN
579 //\r
580 // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)\r
581 //\r
582 Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);\r
583 gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);\r
a405b86d 584 }\r
78ed876b 585 if (!Verbose && Temp != NULL && StrLen(Temp) > 30) {\r
a405b86d 586 Temp2 = NULL;\r
587 Temp2 = StrnCatGrow(&Temp2, NULL, Temp+(StrLen(Temp) - 30), 30);\r
588 FreePool(Temp);\r
589 Temp = Temp2;\r
590 }\r
591 return (Temp);\r
592}\r
593\r
59febea1
SEHM
594/**\r
595 Function to dump information about EfiAdapterInformation Protocol.\r
596\r
597 @param[in] TheHandle The handle that has the protocol installed.\r
598 @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
599\r
600 @retval A pointer to a string containing the information.\r
601**/\r
602CHAR16*\r
603EFIAPI\r
604AdapterInformationDumpInformation (\r
605 IN CONST EFI_HANDLE TheHandle,\r
606 IN CONST BOOLEAN Verbose\r
607 )\r
608{\r
609 EFI_STATUS Status;\r
610 EFI_ADAPTER_INFORMATION_PROTOCOL *EfiAdptrInfoProtocol;\r
611 UINTN InfoTypesBufferCount;\r
612 UINTN GuidIndex;\r
613 EFI_GUID *InfoTypesBuffer;\r
614 CHAR16 *GuidStr;\r
615 CHAR16 *TempStr;\r
616 CHAR16 *RetVal;\r
1a6f74d9 617 CHAR16 *TempRetVal;\r
59febea1
SEHM
618 VOID *InformationBlock;\r
619 UINTN InformationBlockSize;\r
1a6f74d9 620\r
59febea1
SEHM
621 if (!Verbose) {\r
622 return (CatSPrint(NULL, L"AdapterInfo"));\r
623 }\r
624\r
1d6ccad2
QS
625 InfoTypesBuffer = NULL;\r
626 InformationBlock = NULL;\r
1a6f74d9 627\r
59febea1
SEHM
628\r
629 Status = gBS->OpenProtocol (\r
630 (EFI_HANDLE) (TheHandle),\r
631 &gEfiAdapterInformationProtocolGuid,\r
632 (VOID **) &EfiAdptrInfoProtocol,\r
633 NULL,\r
634 NULL,\r
635 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
636 );\r
637\r
638 if (EFI_ERROR (Status)) {\r
59febea1
SEHM
639 return NULL;\r
640 }\r
641\r
642 //\r
643 // Get a list of supported information types for this instance of the protocol.\r
644 //\r
645 Status = EfiAdptrInfoProtocol->GetSupportedTypes (\r
646 EfiAdptrInfoProtocol,\r
1a6f74d9 647 &InfoTypesBuffer,\r
59febea1
SEHM
648 &InfoTypesBufferCount\r
649 );\r
1a6f74d9 650 RetVal = NULL;\r
59febea1
SEHM
651 if (EFI_ERROR (Status)) {\r
652 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED), NULL);\r
1d6ccad2 653 if (TempStr != NULL) {\r
1a6f74d9 654 RetVal = CatSPrint (NULL, TempStr, Status);\r
1d6ccad2
QS
655 } else {\r
656 goto ERROR_EXIT;\r
1a6f74d9 657 }\r
59febea1
SEHM
658 } else {\r
659 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SUPP_TYPE_HEADER), NULL);\r
1d6ccad2
QS
660 if (TempStr == NULL) {\r
661 goto ERROR_EXIT;\r
662 }\r
1a6f74d9 663 RetVal = CatSPrint (NULL, TempStr);\r
59febea1
SEHM
664 SHELL_FREE_NON_NULL (TempStr);\r
665\r
666 for (GuidIndex = 0; GuidIndex < InfoTypesBufferCount; GuidIndex++) {\r
667 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_NUMBER), NULL);\r
1d6ccad2
QS
668 if (TempStr == NULL) {\r
669 goto ERROR_EXIT;\r
670 }\r
1a6f74d9
CS
671 TempRetVal = CatSPrint (RetVal, TempStr, (GuidIndex + 1), InfoTypesBuffer[GuidIndex]);\r
672 SHELL_FREE_NON_NULL (RetVal);\r
673 RetVal = TempRetVal;\r
59febea1
SEHM
674 SHELL_FREE_NON_NULL (TempStr);\r
675\r
676 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_STRING), NULL);\r
1d6ccad2
QS
677 if (TempStr == NULL) {\r
678 goto ERROR_EXIT;\r
679 }\r
59febea1
SEHM
680\r
681 if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) {\r
1a6f74d9
CS
682 TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoMediaStateGuid");\r
683 SHELL_FREE_NON_NULL (RetVal);\r
684 RetVal = TempRetVal;\r
59febea1 685 } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) {\r
1a6f74d9
CS
686 TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoNetworkBootGuid");\r
687 SHELL_FREE_NON_NULL (RetVal);\r
688 RetVal = TempRetVal;\r
59febea1 689 } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid)) {\r
1a6f74d9
CS
690 TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoSanMacAddressGuid");\r
691 SHELL_FREE_NON_NULL (RetVal);\r
692 RetVal = TempRetVal;\r
256aa6d0
SEHM
693 } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoUndiIpv6SupportGuid)) {\r
694 TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoUndiIpv6SupportGuid");\r
695 SHELL_FREE_NON_NULL (RetVal);\r
696 RetVal = TempRetVal;\r
59febea1
SEHM
697 } else {\r
698\r
699 GuidStr = GetStringNameFromGuid (&InfoTypesBuffer[GuidIndex], NULL);\r
1a6f74d9 700\r
59febea1
SEHM
701 if (GuidStr != NULL) {\r
702 if (StrCmp(GuidStr, L"UnknownDevice") == 0) {\r
1a6f74d9
CS
703 TempRetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType");\r
704 SHELL_FREE_NON_NULL (RetVal);\r
705 RetVal = TempRetVal;\r
706\r
59febea1
SEHM
707 SHELL_FREE_NON_NULL (TempStr);\r
708 SHELL_FREE_NON_NULL(GuidStr);\r
709 //\r
710 // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP\r
711 //\r
1a6f74d9 712 continue;\r
59febea1 713 } else {\r
1a6f74d9
CS
714 TempRetVal = CatSPrint (RetVal, TempStr, GuidStr);\r
715 SHELL_FREE_NON_NULL (RetVal);\r
716 RetVal = TempRetVal;\r
59febea1
SEHM
717 SHELL_FREE_NON_NULL(GuidStr);\r
718 }\r
719 }\r
720 }\r
1a6f74d9 721\r
59febea1
SEHM
722 SHELL_FREE_NON_NULL (TempStr);\r
723\r
724 Status = EfiAdptrInfoProtocol->GetInformation (\r
725 EfiAdptrInfoProtocol,\r
726 &InfoTypesBuffer[GuidIndex],\r
727 &InformationBlock,\r
728 &InformationBlockSize\r
729 );\r
730\r
731 if (EFI_ERROR (Status)) {\r
732 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GETINFO_FAILED), NULL);\r
1d6ccad2
QS
733 if (TempStr == NULL) {\r
734 goto ERROR_EXIT;\r
735 }\r
1a6f74d9
CS
736 TempRetVal = CatSPrint (RetVal, TempStr, Status);\r
737 SHELL_FREE_NON_NULL (RetVal);\r
738 RetVal = TempRetVal;\r
59febea1
SEHM
739 } else {\r
740 if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) {\r
741 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_MEDIA_STATE), NULL);\r
1d6ccad2
QS
742 if (TempStr == NULL) {\r
743 goto ERROR_EXIT;\r
744 }\r
1a6f74d9
CS
745 TempRetVal = CatSPrint (\r
746 RetVal,\r
747 TempStr,\r
748 ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState,\r
749 ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState\r
750 );\r
751 SHELL_FREE_NON_NULL (RetVal);\r
752 RetVal = TempRetVal;\r
59febea1
SEHM
753 } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) {\r
754 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_NETWORK_BOOT_INFO), NULL);\r
1d6ccad2
QS
755 if (TempStr == NULL) {\r
756 goto ERROR_EXIT;\r
757 }\r
1a6f74d9
CS
758 TempRetVal = CatSPrint (\r
759 RetVal,\r
760 TempStr,\r
761 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4BootCapablity,\r
762 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6BootCapablity,\r
763 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBootCapablity,\r
764 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->OffloadCapability,\r
765 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiMpioCapability,\r
766 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4Boot,\r
767 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6Boot,\r
768 ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBoot\r
769 );\r
770 SHELL_FREE_NON_NULL (RetVal);\r
771 RetVal = TempRetVal;\r
772 } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid) == TRUE) {\r
59febea1 773 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO), NULL);\r
1d6ccad2
QS
774 if (TempStr == NULL) {\r
775 goto ERROR_EXIT;\r
776 }\r
1a6f74d9
CS
777 TempRetVal = CatSPrint (\r
778 RetVal,\r
779 TempStr,\r
780 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[0],\r
781 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[1],\r
782 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[2],\r
783 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[3],\r
784 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[4],\r
785 ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[5]\r
786 );\r
787 SHELL_FREE_NON_NULL (RetVal);\r
788 RetVal = TempRetVal;\r
256aa6d0
SEHM
789 } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoUndiIpv6SupportGuid) == TRUE) {\r
790 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_UNDI_IPV6_INFO), NULL);\r
791 if (TempStr == NULL) {\r
792 goto ERROR_EXIT;\r
793 }\r
794\r
795 TempRetVal = CatSPrint (\r
796 RetVal,\r
797 TempStr,\r
798 ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InformationBlock)->Ipv6Support\r
799 ); \r
800 SHELL_FREE_NON_NULL (RetVal);\r
801 RetVal = TempRetVal;\r
59febea1
SEHM
802 } else {\r
803 TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE), NULL);\r
1d6ccad2
QS
804 if (TempStr == NULL) {\r
805 goto ERROR_EXIT;\r
806 }\r
1a6f74d9
CS
807 TempRetVal = CatSPrint (RetVal, TempStr, &InfoTypesBuffer[GuidIndex]);\r
808 SHELL_FREE_NON_NULL (RetVal);\r
809 RetVal = TempRetVal;\r
59febea1
SEHM
810 }\r
811 }\r
812 SHELL_FREE_NON_NULL (TempStr);\r
813 SHELL_FREE_NON_NULL (InformationBlock);\r
814 }\r
815 }\r
816\r
1d6ccad2 817 SHELL_FREE_NON_NULL (InfoTypesBuffer);\r
59febea1 818 return RetVal;\r
1d6ccad2
QS
819\r
820ERROR_EXIT:\r
821 SHELL_FREE_NON_NULL (RetVal);\r
822 SHELL_FREE_NON_NULL (InfoTypesBuffer);\r
823 SHELL_FREE_NON_NULL (InformationBlock);\r
824 return NULL;\r
59febea1 825}\r
a405b86d 826//\r
827// Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg\r
828//\r
829#define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \\r
830 { \\r
ce68d3bc 831 0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \\r
a405b86d 832 }\r
833\r
834#define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \\r
835 { \\r
ce68d3bc 836 0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \\r
a405b86d 837 }\r
838\r
839#define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \\r
840 { \\r
ce68d3bc 841 0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \\r
a405b86d 842 }\r
843STATIC CONST EFI_GUID WinNtThunkProtocolGuid = LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID;\r
844STATIC CONST EFI_GUID WinNtIoProtocolGuid = LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID;\r
845STATIC CONST EFI_GUID WinNtSerialPortGuid = LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID;\r
846\r
2c23ddaa 847//\r
848// Deprecated protocols we dont want to link from IntelFrameworkModulePkg\r
849//\r
850#define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \\r
851 { \\r
852 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \\r
1a6f74d9 853 }\r
2c23ddaa 854#define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \\r
855 { \\r
856 0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \\r
857 }\r
858STATIC CONST EFI_GUID EfiIsaIoProtocolGuid = LOCAL_EFI_ISA_IO_PROTOCOL_GUID;\r
859STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid = LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID;\r
860\r
861\r
dee34318 862STATIC CONST GUID_INFO_BLOCK mGuidStringListNT[] = {\r
a405b86d 863 {STRING_TOKEN(STR_WINNT_THUNK), (EFI_GUID*)&WinNtThunkProtocolGuid, NULL},\r
864 {STRING_TOKEN(STR_WINNT_DRIVER_IO), (EFI_GUID*)&WinNtIoProtocolGuid, NULL},\r
865 {STRING_TOKEN(STR_WINNT_SERIAL_PORT), (EFI_GUID*)&WinNtSerialPortGuid, NULL},\r
866 {STRING_TOKEN(STR_UNKNOWN_DEVICE), NULL, NULL},\r
867};\r
868\r
dee34318 869STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {\r
efb76d1a 870 {STRING_TOKEN(STR_LOADED_IMAGE), &gEfiLoadedImageProtocolGuid, LoadedImageProtocolDumpInformation},\r
a405b86d 871 {STRING_TOKEN(STR_DEVICE_PATH), &gEfiDevicePathProtocolGuid, DevicePathProtocolDumpInformation},\r
872 {STRING_TOKEN(STR_IMAGE_PATH), &gEfiLoadedImageDevicePathProtocolGuid, DevicePathProtocolDumpInformation},\r
873 {STRING_TOKEN(STR_DEVICE_PATH_UTIL), &gEfiDevicePathUtilitiesProtocolGuid, NULL},\r
874 {STRING_TOKEN(STR_DEVICE_PATH_TXT), &gEfiDevicePathToTextProtocolGuid, NULL},\r
875 {STRING_TOKEN(STR_DEVICE_PATH_FTXT), &gEfiDevicePathFromTextProtocolGuid, NULL},\r
876 {STRING_TOKEN(STR_DEVICE_PATH_PC), &gEfiPcAnsiGuid, NULL},\r
877 {STRING_TOKEN(STR_DEVICE_PATH_VT100), &gEfiVT100Guid, NULL},\r
878 {STRING_TOKEN(STR_DEVICE_PATH_VT100P), &gEfiVT100PlusGuid, NULL},\r
879 {STRING_TOKEN(STR_DEVICE_PATH_VTUTF8), &gEfiVTUTF8Guid, NULL},\r
880 {STRING_TOKEN(STR_DRIVER_BINDING), &gEfiDriverBindingProtocolGuid, NULL},\r
881 {STRING_TOKEN(STR_PLATFORM_OVERRIDE), &gEfiPlatformDriverOverrideProtocolGuid, NULL},\r
882 {STRING_TOKEN(STR_BUS_OVERRIDE), &gEfiBusSpecificDriverOverrideProtocolGuid, NULL},\r
883 {STRING_TOKEN(STR_DRIVER_DIAG), &gEfiDriverDiagnosticsProtocolGuid, NULL},\r
884 {STRING_TOKEN(STR_DRIVER_DIAG2), &gEfiDriverDiagnostics2ProtocolGuid, NULL},\r
885 {STRING_TOKEN(STR_DRIVER_CN), &gEfiComponentNameProtocolGuid, NULL},\r
886 {STRING_TOKEN(STR_DRIVER_CN2), &gEfiComponentName2ProtocolGuid, NULL},\r
887 {STRING_TOKEN(STR_PLAT_DRV_CFG), &gEfiPlatformToDriverConfigurationProtocolGuid, NULL},\r
888 {STRING_TOKEN(STR_DRIVER_VERSION), &gEfiDriverSupportedEfiVersionProtocolGuid, DriverEfiVersionProtocolDumpInformation},\r
889 {STRING_TOKEN(STR_TXT_IN), &gEfiSimpleTextInProtocolGuid, NULL},\r
890 {STRING_TOKEN(STR_TXT_IN_EX), &gEfiSimpleTextInputExProtocolGuid, NULL},\r
891 {STRING_TOKEN(STR_TXT_OUT), &gEfiSimpleTextOutProtocolGuid, TxtOutProtocolDumpInformation},\r
892 {STRING_TOKEN(STR_SIM_POINTER), &gEfiSimplePointerProtocolGuid, NULL},\r
893 {STRING_TOKEN(STR_ABS_POINTER), &gEfiAbsolutePointerProtocolGuid, NULL},\r
894 {STRING_TOKEN(STR_SERIAL_IO), &gEfiSerialIoProtocolGuid, NULL},\r
609e0c58 895 {STRING_TOKEN(STR_GRAPHICS_OUTPUT), &gEfiGraphicsOutputProtocolGuid, GraphicsOutputProtocolDumpInformation},\r
a405b86d 896 {STRING_TOKEN(STR_EDID_DISCOVERED), &gEfiEdidDiscoveredProtocolGuid, NULL},\r
897 {STRING_TOKEN(STR_EDID_ACTIVE), &gEfiEdidActiveProtocolGuid, NULL},\r
898 {STRING_TOKEN(STR_EDID_OVERRIDE), &gEfiEdidOverrideProtocolGuid, NULL},\r
899 {STRING_TOKEN(STR_CON_IN), &gEfiConsoleInDeviceGuid, NULL},\r
900 {STRING_TOKEN(STR_CON_OUT), &gEfiConsoleOutDeviceGuid, NULL},\r
901 {STRING_TOKEN(STR_STD_ERR), &gEfiStandardErrorDeviceGuid, NULL},\r
902 {STRING_TOKEN(STR_LOAD_FILE), &gEfiLoadFileProtocolGuid, NULL},\r
903 {STRING_TOKEN(STR_LOAD_FILE2), &gEfiLoadFile2ProtocolGuid, NULL},\r
904 {STRING_TOKEN(STR_SIMPLE_FILE_SYS), &gEfiSimpleFileSystemProtocolGuid, NULL},\r
a405b86d 905 {STRING_TOKEN(STR_TAPE_IO), &gEfiTapeIoProtocolGuid, NULL},\r
906 {STRING_TOKEN(STR_DISK_IO), &gEfiDiskIoProtocolGuid, NULL},\r
907 {STRING_TOKEN(STR_BLK_IO), &gEfiBlockIoProtocolGuid, NULL},\r
908 {STRING_TOKEN(STR_UC), &gEfiUnicodeCollationProtocolGuid, NULL},\r
909 {STRING_TOKEN(STR_UC2), &gEfiUnicodeCollation2ProtocolGuid, NULL},\r
f4f3c6bf 910 {STRING_TOKEN(STR_PCIRB_IO), &gEfiPciRootBridgeIoProtocolGuid, PciRootBridgeIoDumpInformation},\r
a405b86d 911 {STRING_TOKEN(STR_PCI_IO), &gEfiPciIoProtocolGuid, NULL},\r
912 {STRING_TOKEN(STR_SCSI_PT), &gEfiScsiPassThruProtocolGuid, NULL},\r
913 {STRING_TOKEN(STR_SCSI_IO), &gEfiScsiIoProtocolGuid, NULL},\r
914 {STRING_TOKEN(STR_SCSI_PT_EXT), &gEfiExtScsiPassThruProtocolGuid, NULL},\r
915 {STRING_TOKEN(STR_ISCSI), &gEfiIScsiInitiatorNameProtocolGuid, NULL},\r
916 {STRING_TOKEN(STR_USB_IO), &gEfiUsbIoProtocolGuid, NULL},\r
917 {STRING_TOKEN(STR_USB_HC), &gEfiUsbHcProtocolGuid, NULL},\r
918 {STRING_TOKEN(STR_USB_HC2), &gEfiUsb2HcProtocolGuid, NULL},\r
919 {STRING_TOKEN(STR_DEBUG_SUPPORT), &gEfiDebugSupportProtocolGuid, NULL},\r
920 {STRING_TOKEN(STR_DEBUG_PORT), &gEfiDebugPortProtocolGuid, NULL},\r
921 {STRING_TOKEN(STR_DECOMPRESS), &gEfiDecompressProtocolGuid, NULL},\r
922 {STRING_TOKEN(STR_ACPI_TABLE), &gEfiAcpiTableProtocolGuid, NULL},\r
923 {STRING_TOKEN(STR_EBC_INTERPRETER), &gEfiEbcProtocolGuid, NULL},\r
924 {STRING_TOKEN(STR_SNP), &gEfiSimpleNetworkProtocolGuid, NULL},\r
925 {STRING_TOKEN(STR_NII), &gEfiNetworkInterfaceIdentifierProtocolGuid, NULL},\r
926 {STRING_TOKEN(STR_NII_31), &gEfiNetworkInterfaceIdentifierProtocolGuid_31, NULL},\r
927 {STRING_TOKEN(STR_PXE_BC), &gEfiPxeBaseCodeProtocolGuid, NULL},\r
928 {STRING_TOKEN(STR_PXE_CB), &gEfiPxeBaseCodeCallbackProtocolGuid, NULL},\r
929 {STRING_TOKEN(STR_BIS), &gEfiBisProtocolGuid, NULL},\r
930 {STRING_TOKEN(STR_MNP_SB), &gEfiManagedNetworkServiceBindingProtocolGuid, NULL},\r
931 {STRING_TOKEN(STR_MNP), &gEfiManagedNetworkProtocolGuid, NULL},\r
932 {STRING_TOKEN(STR_ARP_SB), &gEfiArpServiceBindingProtocolGuid, NULL},\r
933 {STRING_TOKEN(STR_ARP), &gEfiArpProtocolGuid, NULL},\r
934 {STRING_TOKEN(STR_DHCPV4_SB), &gEfiDhcp4ServiceBindingProtocolGuid, NULL},\r
935 {STRING_TOKEN(STR_DHCPV4), &gEfiDhcp4ProtocolGuid, NULL},\r
936 {STRING_TOKEN(STR_TCPV4_SB), &gEfiTcp4ServiceBindingProtocolGuid, NULL},\r
937 {STRING_TOKEN(STR_TCPV4), &gEfiTcp4ProtocolGuid, NULL},\r
938 {STRING_TOKEN(STR_IPV4_SB), &gEfiIp4ServiceBindingProtocolGuid, NULL},\r
939 {STRING_TOKEN(STR_IPV4), &gEfiIp4ProtocolGuid, NULL},\r
940 {STRING_TOKEN(STR_IPV4_CFG), &gEfiIp4ConfigProtocolGuid, NULL},\r
00a6ad1b 941 {STRING_TOKEN(STR_IPV4_CFG2), &gEfiIp4Config2ProtocolGuid, NULL},\r
a405b86d 942 {STRING_TOKEN(STR_UDPV4_SB), &gEfiUdp4ServiceBindingProtocolGuid, NULL},\r
943 {STRING_TOKEN(STR_UDPV4), &gEfiUdp4ProtocolGuid, NULL},\r
944 {STRING_TOKEN(STR_MTFTPV4_SB), &gEfiMtftp4ServiceBindingProtocolGuid, NULL},\r
945 {STRING_TOKEN(STR_MTFTPV4), &gEfiMtftp4ProtocolGuid, NULL},\r
946 {STRING_TOKEN(STR_AUTH_INFO), &gEfiAuthenticationInfoProtocolGuid, NULL},\r
947 {STRING_TOKEN(STR_HASH_SB), &gEfiHashServiceBindingProtocolGuid, NULL},\r
948 {STRING_TOKEN(STR_HASH), &gEfiHashProtocolGuid, NULL},\r
949 {STRING_TOKEN(STR_HII_FONT), &gEfiHiiFontProtocolGuid, NULL},\r
950 {STRING_TOKEN(STR_HII_STRING), &gEfiHiiStringProtocolGuid, NULL},\r
951 {STRING_TOKEN(STR_HII_IMAGE), &gEfiHiiImageProtocolGuid, NULL},\r
952 {STRING_TOKEN(STR_HII_DATABASE), &gEfiHiiDatabaseProtocolGuid, NULL},\r
953 {STRING_TOKEN(STR_HII_CONFIG_ROUT), &gEfiHiiConfigRoutingProtocolGuid, NULL},\r
954 {STRING_TOKEN(STR_HII_CONFIG_ACC), &gEfiHiiConfigAccessProtocolGuid, NULL},\r
955 {STRING_TOKEN(STR_HII_FORM_BROWSER2), &gEfiFormBrowser2ProtocolGuid, NULL},\r
dee34318 956 {STRING_TOKEN(STR_DRIVER_FAM_OVERRIDE), &gEfiDriverFamilyOverrideProtocolGuid, NULL},\r
957 {STRING_TOKEN(STR_PCD), &gPcdProtocolGuid, NULL},\r
958 {STRING_TOKEN(STR_TCG), &gEfiTcgProtocolGuid, NULL},\r
959 {STRING_TOKEN(STR_HII_PACKAGE_LIST), &gEfiHiiPackageListProtocolGuid, NULL},\r
960\r
961//\r
962// the ones under this are deprecated by the current UEFI Spec, but may be found anyways...\r
963//\r
a405b86d 964 {STRING_TOKEN(STR_SHELL_INTERFACE), &gEfiShellInterfaceGuid, NULL},\r
965 {STRING_TOKEN(STR_SHELL_ENV2), &gEfiShellEnvironment2Guid, NULL},\r
966 {STRING_TOKEN(STR_SHELL_ENV), &gEfiShellEnvironment2Guid, NULL},\r
967 {STRING_TOKEN(STR_DEVICE_IO), &gEfiDeviceIoProtocolGuid, NULL},\r
968 {STRING_TOKEN(STR_UGA_DRAW), &gEfiUgaDrawProtocolGuid, NULL},\r
969 {STRING_TOKEN(STR_UGA_IO), &gEfiUgaIoProtocolGuid, NULL},\r
970 {STRING_TOKEN(STR_ESP), &gEfiPartTypeSystemPartGuid, NULL},\r
971 {STRING_TOKEN(STR_GPT_NBR), &gEfiPartTypeLegacyMbrGuid, NULL},\r
972 {STRING_TOKEN(STR_DRIVER_CONFIG), &gEfiDriverConfigurationProtocolGuid, NULL},\r
973 {STRING_TOKEN(STR_DRIVER_CONFIG2), &gEfiDriverConfiguration2ProtocolGuid, NULL},\r
2c23ddaa 974\r
975//\r
976// these are using local (non-global) definitions to reduce package dependancy.\r
977//\r
978 {STRING_TOKEN(STR_ISA_IO), (EFI_GUID*)&EfiIsaIoProtocolGuid, NULL},\r
979 {STRING_TOKEN(STR_ISA_ACPI), (EFI_GUID*)&EfiIsaAcpiProtocolGuid, NULL},\r
dee34318 980\r
981//\r
982// the ones under this are GUID identified structs, not protocols\r
983//\r
984 {STRING_TOKEN(STR_FILE_INFO), &gEfiFileInfoGuid, NULL},\r
985 {STRING_TOKEN(STR_FILE_SYS_INFO), &gEfiFileSystemInfoGuid, NULL},\r
986\r
987//\r
988// the ones under this are misc GUIDS.\r
989//\r
990 {STRING_TOKEN(STR_EFI_GLOBAL_VARIABLE), &gEfiGlobalVariableGuid, NULL},\r
991\r
992//\r
993// UEFI 2.2\r
994//\r
995 {STRING_TOKEN(STR_IP6_SB), &gEfiIp6ServiceBindingProtocolGuid, NULL},\r
996 {STRING_TOKEN(STR_IP6), &gEfiIp6ProtocolGuid, NULL},\r
997 {STRING_TOKEN(STR_IP6_CONFIG), &gEfiIp6ConfigProtocolGuid, NULL},\r
998 {STRING_TOKEN(STR_MTFTP6_SB), &gEfiMtftp6ServiceBindingProtocolGuid, NULL},\r
999 {STRING_TOKEN(STR_MTFTP6), &gEfiMtftp6ProtocolGuid, NULL},\r
1000 {STRING_TOKEN(STR_DHCP6_SB), &gEfiDhcp6ServiceBindingProtocolGuid, NULL},\r
1001 {STRING_TOKEN(STR_DHCP6), &gEfiDhcp6ProtocolGuid, NULL},\r
1002 {STRING_TOKEN(STR_UDP6_SB), &gEfiUdp6ServiceBindingProtocolGuid, NULL},\r
1003 {STRING_TOKEN(STR_UDP6), &gEfiUdp6ProtocolGuid, NULL},\r
1004 {STRING_TOKEN(STR_TCP6_SB), &gEfiTcp6ServiceBindingProtocolGuid, NULL},\r
1005 {STRING_TOKEN(STR_TCP6), &gEfiTcp6ProtocolGuid, NULL},\r
1006 {STRING_TOKEN(STR_VLAN_CONFIG), &gEfiVlanConfigProtocolGuid, NULL},\r
1007 {STRING_TOKEN(STR_EAP), &gEfiEapProtocolGuid, NULL},\r
1008 {STRING_TOKEN(STR_EAP_MGMT), &gEfiEapManagementProtocolGuid, NULL},\r
1009 {STRING_TOKEN(STR_FTP4_SB), &gEfiFtp4ServiceBindingProtocolGuid, NULL},\r
1010 {STRING_TOKEN(STR_FTP4), &gEfiFtp4ProtocolGuid, NULL},\r
1011 {STRING_TOKEN(STR_IP_SEC_CONFIG), &gEfiIpSecConfigProtocolGuid, NULL},\r
1012 {STRING_TOKEN(STR_DH), &gEfiDriverHealthProtocolGuid, NULL},\r
1013 {STRING_TOKEN(STR_DEF_IMG_LOAD), &gEfiDeferredImageLoadProtocolGuid, NULL},\r
1014 {STRING_TOKEN(STR_USER_CRED), &gEfiUserCredentialProtocolGuid, NULL},\r
1015 {STRING_TOKEN(STR_USER_MNGR), &gEfiUserManagerProtocolGuid, NULL},\r
1016 {STRING_TOKEN(STR_ATA_PASS_THRU), &gEfiAtaPassThruProtocolGuid, NULL},\r
1017\r
1018//\r
1019// UEFI 2.3\r
1020//\r
1021 {STRING_TOKEN(STR_FW_MGMT), &gEfiFirmwareManagementProtocolGuid, NULL},\r
1022 {STRING_TOKEN(STR_IP_SEC), &gEfiIpSecProtocolGuid, NULL},\r
1023 {STRING_TOKEN(STR_IP_SEC2), &gEfiIpSec2ProtocolGuid, NULL},\r
1024\r
1025//\r
1026// UEFI 2.3.1\r
1027//\r
1028 {STRING_TOKEN(STR_KMS), &gEfiKmsProtocolGuid, NULL},\r
1029 {STRING_TOKEN(STR_BLK_IO2), &gEfiBlockIo2ProtocolGuid, NULL},\r
1030 {STRING_TOKEN(STR_SSC), &gEfiStorageSecurityCommandProtocolGuid, NULL},\r
12f1a36c 1031 {STRING_TOKEN(STR_UCRED2), &gEfiUserCredential2ProtocolGuid, NULL},\r
dee34318 1032\r
28cdb62b
CP
1033//\r
1034// UEFI 2.4\r
1035//\r
1036 {STRING_TOKEN(STR_DISK_IO2), &gEfiDiskIo2ProtocolGuid, NULL},\r
59febea1 1037 {STRING_TOKEN(STR_ADAPTER_INFO), &gEfiAdapterInformationProtocolGuid, AdapterInformationDumpInformation},\r
28cdb62b 1038\r
6b640b4a
JC
1039//\r
1040// PI Spec ones\r
1041//\r
1042 {STRING_TOKEN(STR_IDE_CONT_INIT), &gEfiIdeControllerInitProtocolGuid, NULL},\r
4024c116 1043 {STRING_TOKEN(STR_DISK_INFO), &gEfiDiskInfoProtocolGuid, NULL},\r
6b640b4a 1044\r
c2788f1c
JC
1045//\r
1046// PI Spec 1.0\r
1047//\r
1048 {STRING_TOKEN(STR_BDS_ARCH), &gEfiBdsArchProtocolGuid, NULL},\r
1049 {STRING_TOKEN(STR_CPU_ARCH), &gEfiCpuArchProtocolGuid, NULL},\r
1050 {STRING_TOKEN(STR_MET_ARCH), &gEfiMetronomeArchProtocolGuid, NULL},\r
1051 {STRING_TOKEN(STR_MON_ARCH), &gEfiMonotonicCounterArchProtocolGuid, NULL},\r
1052 {STRING_TOKEN(STR_RTC_ARCH), &gEfiRealTimeClockArchProtocolGuid, NULL},\r
1053 {STRING_TOKEN(STR_RESET_ARCH), &gEfiResetArchProtocolGuid, NULL},\r
1054 {STRING_TOKEN(STR_RT_ARCH), &gEfiRuntimeArchProtocolGuid, NULL},\r
1055 {STRING_TOKEN(STR_SEC_ARCH), &gEfiSecurityArchProtocolGuid, NULL},\r
1056 {STRING_TOKEN(STR_TIMER_ARCH), &gEfiTimerArchProtocolGuid, NULL},\r
1057 {STRING_TOKEN(STR_VAR_ARCH), &gEfiVariableWriteArchProtocolGuid, NULL},\r
1058 {STRING_TOKEN(STR_V_ARCH), &gEfiVariableArchProtocolGuid, NULL},\r
1059 {STRING_TOKEN(STR_SECP), &gEfiSecurityPolicyProtocolGuid, NULL},\r
1060 {STRING_TOKEN(STR_WDT_ARCH), &gEfiWatchdogTimerArchProtocolGuid, NULL},\r
1061 {STRING_TOKEN(STR_SCR), &gEfiStatusCodeRuntimeProtocolGuid, NULL},\r
1062 {STRING_TOKEN(STR_SMB_HC), &gEfiSmbusHcProtocolGuid, NULL},\r
1063 {STRING_TOKEN(STR_FV_2), &gEfiFirmwareVolume2ProtocolGuid, NULL},\r
1064 {STRING_TOKEN(STR_FV_BLOCK), &gEfiFirmwareVolumeBlockProtocolGuid, NULL},\r
1065 {STRING_TOKEN(STR_CAP_ARCH), &gEfiCapsuleArchProtocolGuid, NULL},\r
1066 {STRING_TOKEN(STR_MP_SERVICE), &gEfiMpServiceProtocolGuid, NULL},\r
1067 {STRING_TOKEN(STR_HBRAP), &gEfiPciHostBridgeResourceAllocationProtocolGuid, NULL},\r
1068 {STRING_TOKEN(STR_PCIP), &gEfiPciPlatformProtocolGuid, NULL},\r
1069 {STRING_TOKEN(STR_PCIO), &gEfiPciOverrideProtocolGuid, NULL},\r
1070 {STRING_TOKEN(STR_PCIE), &gEfiPciEnumerationCompleteProtocolGuid, NULL},\r
1071 {STRING_TOKEN(STR_IPCID), &gEfiIncompatiblePciDeviceSupportProtocolGuid, NULL},\r
1072 {STRING_TOKEN(STR_PCIHPI), &gEfiPciHotPlugInitProtocolGuid, NULL},\r
1073 {STRING_TOKEN(STR_PCIHPR), &gEfiPciHotPlugRequestProtocolGuid, NULL},\r
1074 {STRING_TOKEN(STR_SMBIOS), &gEfiSmbiosProtocolGuid, NULL},\r
1075 {STRING_TOKEN(STR_S3_SAVE), &gEfiS3SaveStateProtocolGuid, NULL},\r
1076 {STRING_TOKEN(STR_S3_S_SMM), &gEfiS3SmmSaveStateProtocolGuid, NULL},\r
1077 {STRING_TOKEN(STR_RSC), &gEfiRscHandlerProtocolGuid, NULL},\r
1078 {STRING_TOKEN(STR_S_RSC), &gEfiSmmRscHandlerProtocolGuid, NULL},\r
1079 {STRING_TOKEN(STR_ACPI_SDT), &gEfiAcpiSdtProtocolGuid, NULL},\r
1080 {STRING_TOKEN(STR_SIO), &gEfiSioProtocolGuid, NULL},\r
1081 {STRING_TOKEN(STR_S_CPU2), &gEfiSmmCpuIo2ProtocolGuid, NULL},\r
1082 {STRING_TOKEN(STR_S_BASE2), &gEfiSmmBase2ProtocolGuid, NULL},\r
1083 {STRING_TOKEN(STR_S_ACC_2), &gEfiSmmAccess2ProtocolGuid, NULL},\r
1084 {STRING_TOKEN(STR_S_CON_2), &gEfiSmmControl2ProtocolGuid, NULL},\r
1085 {STRING_TOKEN(STR_S_CONFIG), &gEfiSmmConfigurationProtocolGuid, NULL},\r
1086 {STRING_TOKEN(STR_S_RTL), &gEfiSmmReadyToLockProtocolGuid, NULL},\r
1087 {STRING_TOKEN(STR_DS_RTL), &gEfiDxeSmmReadyToLockProtocolGuid, NULL},\r
1088 {STRING_TOKEN(STR_S_COMM), &gEfiSmmCommunicationProtocolGuid, NULL},\r
1089 {STRING_TOKEN(STR_S_STAT), &gEfiSmmStatusCodeProtocolGuid, NULL},\r
1090 {STRING_TOKEN(STR_S_CPU), &gEfiSmmCpuProtocolGuid, NULL},\r
1091 {STRING_TOKEN(STR_S_PCIRBIO), &gEfiPciRootBridgeIoProtocolGuid, NULL},\r
1092 {STRING_TOKEN(STR_S_SWD), &gEfiSmmSwDispatch2ProtocolGuid, NULL},\r
1093 {STRING_TOKEN(STR_S_SXD), &gEfiSmmSxDispatch2ProtocolGuid, NULL},\r
1094 {STRING_TOKEN(STR_S_PTD2), &gEfiSmmPeriodicTimerDispatch2ProtocolGuid, NULL},\r
1095 {STRING_TOKEN(STR_S_UD2), &gEfiSmmUsbDispatch2ProtocolGuid, NULL},\r
1096 {STRING_TOKEN(STR_S_GD2), &gEfiSmmGpiDispatch2ProtocolGuid, NULL},\r
1097 {STRING_TOKEN(STR_S_SBD2), &gEfiSmmStandbyButtonDispatch2ProtocolGuid, NULL},\r
1098 {STRING_TOKEN(STR_S_PBD2), &gEfiSmmPowerButtonDispatch2ProtocolGuid, NULL},\r
1099 {STRING_TOKEN(STR_S_ITD2), &gEfiSmmIoTrapDispatch2ProtocolGuid, NULL},\r
1100 {STRING_TOKEN(STR_PCD), &gEfiPcdProtocolGuid, NULL},\r
1101 {STRING_TOKEN(STR_FVB2), &gEfiFirmwareVolumeBlock2ProtocolGuid, NULL},\r
1102 {STRING_TOKEN(STR_CPUIO2), &gEfiCpuIo2ProtocolGuid, NULL},\r
1103 {STRING_TOKEN(STR_LEGACY_R2), &gEfiLegacyRegion2ProtocolGuid, NULL},\r
1104 {STRING_TOKEN(STR_SAL_MIP), &gEfiSalMcaInitPmiProtocolGuid, NULL},\r
1105 {STRING_TOKEN(STR_ES_BS), &gEfiExtendedSalBootServiceProtocolGuid, NULL},\r
1106 {STRING_TOKEN(STR_ES_BIO), &gEfiExtendedSalBaseIoServicesProtocolGuid, NULL},\r
1107 {STRING_TOKEN(STR_ES_STALL), &gEfiExtendedSalStallServicesProtocolGuid, NULL},\r
1108 {STRING_TOKEN(STR_ES_RTC), &gEfiExtendedSalRtcServicesProtocolGuid, NULL},\r
1109 {STRING_TOKEN(STR_ES_VS), &gEfiExtendedSalVariableServicesProtocolGuid, NULL},\r
1110 {STRING_TOKEN(STR_ES_MTC), &gEfiExtendedSalMtcServicesProtocolGuid, NULL},\r
1111 {STRING_TOKEN(STR_ES_RESET), &gEfiExtendedSalResetServicesProtocolGuid, NULL},\r
1112 {STRING_TOKEN(STR_ES_SC), &gEfiExtendedSalStatusCodeServicesProtocolGuid, NULL},\r
1113 {STRING_TOKEN(STR_ES_FBS), &gEfiExtendedSalFvBlockServicesProtocolGuid, NULL},\r
1114 {STRING_TOKEN(STR_ES_MP), &gEfiExtendedSalMpServicesProtocolGuid, NULL},\r
1115 {STRING_TOKEN(STR_ES_PAL), &gEfiExtendedSalPalServicesProtocolGuid, NULL},\r
1116 {STRING_TOKEN(STR_ES_BASE), &gEfiExtendedSalBaseServicesProtocolGuid, NULL},\r
1117 {STRING_TOKEN(STR_ES_MCA), &gEfiExtendedSalMcaServicesProtocolGuid, NULL},\r
1118 {STRING_TOKEN(STR_ES_PCI), &gEfiExtendedSalPciServicesProtocolGuid, NULL},\r
1119 {STRING_TOKEN(STR_ES_CACHE), &gEfiExtendedSalCacheServicesProtocolGuid, NULL},\r
1120 {STRING_TOKEN(STR_ES_MCA_LOG), &gEfiExtendedSalMcaLogServicesProtocolGuid, NULL},\r
1121 {STRING_TOKEN(STR_S2ARCH), &gEfiSecurity2ArchProtocolGuid, NULL},\r
1122 {STRING_TOKEN(STR_EODXE), &gEfiSmmEndOfDxeProtocolGuid, NULL},\r
1123 {STRING_TOKEN(STR_ISAHC), &gEfiIsaHcProtocolGuid, NULL},\r
1124 {STRING_TOKEN(STR_ISAHC_B), &gEfiIsaHcServiceBindingProtocolGuid, NULL},\r
1125 {STRING_TOKEN(STR_SIO_C), &gEfiSioControlProtocolGuid, NULL},\r
1126 {STRING_TOKEN(STR_GET_PCD), &gEfiGetPcdInfoProtocolGuid, NULL},\r
1127 {STRING_TOKEN(STR_I2C_M), &gEfiI2cMasterProtocolGuid, NULL},\r
1128 {STRING_TOKEN(STR_I2CIO), &gEfiI2cIoProtocolGuid, NULL},\r
1129 {STRING_TOKEN(STR_I2CEN), &gEfiI2cEnumerateProtocolGuid, NULL},\r
1130 {STRING_TOKEN(STR_I2C_H), &gEfiI2cHostProtocolGuid, NULL},\r
1131 {STRING_TOKEN(STR_I2C_BCM), &gEfiI2cBusConfigurationManagementProtocolGuid, NULL},\r
1132 {STRING_TOKEN(STR_TREE), &gEfiTrEEProtocolGuid, NULL},\r
1133 {STRING_TOKEN(STR_TCG2), &gEfiTcg2ProtocolGuid, NULL},\r
1134 {STRING_TOKEN(STR_TIMESTAMP), &gEfiTimestampProtocolGuid, NULL},\r
1135 {STRING_TOKEN(STR_RNG), &gEfiRngProtocolGuid, NULL},\r
1136 {STRING_TOKEN(STR_NVMEPT), &gEfiNvmExpressPassThruProtocolGuid, NULL},\r
1137 {STRING_TOKEN(STR_H2_SB), &gEfiHash2ServiceBindingProtocolGuid, NULL},\r
1138 {STRING_TOKEN(STR_HASH2), &gEfiHash2ProtocolGuid, NULL},\r
1139 {STRING_TOKEN(STR_BIO_C), &gEfiBlockIoCryptoProtocolGuid, NULL},\r
1140 {STRING_TOKEN(STR_SCR), &gEfiSmartCardReaderProtocolGuid, NULL},\r
1141 {STRING_TOKEN(STR_SCE), &gEfiSmartCardEdgeProtocolGuid, NULL},\r
1142 {STRING_TOKEN(STR_USB_FIO), &gEfiUsbFunctionIoProtocolGuid, NULL},\r
1143 {STRING_TOKEN(STR_BC_HC), &gEfiBluetoothHcProtocolGuid, NULL},\r
1144 {STRING_TOKEN(STR_BC_IO_SB), &gEfiBluetoothIoServiceBindingProtocolGuid, NULL},\r
1145 {STRING_TOKEN(STR_BC_IO), &gEfiBluetoothIoProtocolGuid, NULL},\r
1146 {STRING_TOKEN(STR_BC_C), &gEfiBluetoothConfigProtocolGuid, NULL},\r
1147 {STRING_TOKEN(STR_REG_EXP), &gEfiRegularExpressionProtocolGuid, NULL},\r
1148 {STRING_TOKEN(STR_B_MGR_P), &gEfiBootManagerPolicyProtocolGuid, NULL},\r
1149 {STRING_TOKEN(STR_CKH), &gEfiConfigKeywordHandlerProtocolGuid, NULL},\r
1150 {STRING_TOKEN(STR_WIFI), &gEfiWiFiProtocolGuid, NULL},\r
1151 {STRING_TOKEN(STR_EAP_M), &gEfiEapManagement2ProtocolGuid, NULL},\r
1152 {STRING_TOKEN(STR_EAP_C), &gEfiEapConfigurationProtocolGuid, NULL},\r
1153 {STRING_TOKEN(STR_PKCS7), &gEfiPkcs7VerifyProtocolGuid, NULL},\r
1154 {STRING_TOKEN(STR_NET_DNS4_SB), &gEfiDns4ServiceBindingProtocolGuid, NULL},\r
1155 {STRING_TOKEN(STR_NET_DNS4), &gEfiDns4ProtocolGuid, NULL},\r
1156 {STRING_TOKEN(STR_NET_DNS6_SB), &gEfiDns6ServiceBindingProtocolGuid, NULL},\r
1157 {STRING_TOKEN(STR_NET_DNS6), &gEfiDns6ProtocolGuid, NULL},\r
1158 {STRING_TOKEN(STR_NET_HTTP_SB), &gEfiHttpServiceBindingProtocolGuid, NULL},\r
1159 {STRING_TOKEN(STR_NET_HTTP), &gEfiHttpProtocolGuid, NULL},\r
1160 {STRING_TOKEN(STR_NET_HTTP_U), &gEfiHttpUtilitiesProtocolGuid, NULL},\r
1161 {STRING_TOKEN(STR_REST), &gEfiRestProtocolGuid, NULL},\r
1162\r
0a1eb97d
JC
1163//\r
1164// UEFI Shell Spec 2.0\r
1165//\r
1166 {STRING_TOKEN(STR_SHELL_PARAMETERS), &gEfiShellParametersProtocolGuid, NULL},\r
1167 {STRING_TOKEN(STR_SHELL), &gEfiShellProtocolGuid, NULL},\r
1168\r
1169//\r
1170// UEFI Shell Spec 2.1\r
1171//\r
1172 {STRING_TOKEN(STR_SHELL_DYNAMIC), &gEfiShellDynamicCommandProtocolGuid, NULL},\r
1173\r
c2788f1c
JC
1174//\r
1175// Misc\r
1176//\r
1177 {STRING_TOKEN(STR_PCDINFOPROT), &gGetPcdInfoProtocolGuid, NULL},\r
1178\r
dee34318 1179//\r
1180// terminator\r
1181//\r
a405b86d 1182 {STRING_TOKEN(STR_UNKNOWN_DEVICE), NULL, NULL},\r
1183};\r
1184\r
1185/**\r
1186 Function to get the node for a protocol or struct from it's GUID.\r
1187\r
1188 if Guid is NULL, then ASSERT.\r
1189\r
1190 @param[in] Guid The GUID to look for the name of.\r
1191\r
1192 @return The node.\r
1193**/\r
dee34318 1194CONST GUID_INFO_BLOCK *\r
a405b86d 1195EFIAPI\r
1196InternalShellGetNodeFromGuid(\r
1197 IN CONST EFI_GUID* Guid\r
1198 )\r
1199{\r
dee34318 1200 CONST GUID_INFO_BLOCK *ListWalker;\r
6306fd90 1201 UINTN LoopCount;\r
a405b86d 1202\r
1203 ASSERT(Guid != NULL);\r
1204\r
6306fd90
JC
1205 for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) {\r
1206 if (CompareGuid(ListWalker->GuidId, Guid)) {\r
1207 return (ListWalker);\r
1208 }\r
1209 }\r
1210\r
a405b86d 1211 if (PcdGetBool(PcdShellIncludeNtGuids)) {\r
1212 for (ListWalker = mGuidStringListNT ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {\r
1213 if (CompareGuid(ListWalker->GuidId, Guid)) {\r
1214 return (ListWalker);\r
1215 }\r
1216 }\r
1217 }\r
1218 for (ListWalker = mGuidStringList ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {\r
1219 if (CompareGuid(ListWalker->GuidId, Guid)) {\r
1220 return (ListWalker);\r
1221 }\r
1222 }\r
6306fd90
JC
1223 return (NULL);\r
1224}\r
1225\r
1226/**\r
1227Function to add a new GUID/Name mapping.\r
1228\r
1229@param[in] Guid The Guid\r
f5ba4007
QS
1230@param[in] NameID The STRING id of the HII string to use\r
1231@param[in] DumpFunc The pointer to the dump function\r
6306fd90
JC
1232\r
1233\r
1234@retval EFI_SUCCESS The operation was sucessful\r
1235@retval EFI_OUT_OF_RESOURCES A memory allocation failed\r
1236@retval EFI_INVALID_PARAMETER Guid NameId was invalid\r
1237**/\r
6306fd90
JC
1238EFI_STATUS\r
1239EFIAPI\r
1240InsertNewGuidNameMapping(\r
1241 IN CONST EFI_GUID *Guid,\r
1242 IN CONST EFI_STRING_ID NameID,\r
1243 IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL\r
1244 )\r
1245{\r
1246 ASSERT(Guid != NULL);\r
1247 ASSERT(NameID != 0);\r
1248\r
1249 GuidList = ReallocatePool(GuidListCount * sizeof(GUID_INFO_BLOCK), GuidListCount+1 * sizeof(GUID_INFO_BLOCK), GuidList);\r
1250 if (GuidList == NULL) {\r
1251 GuidListCount = 0;\r
1252 return (EFI_OUT_OF_RESOURCES);\r
1253 }\r
1254 GuidListCount++;\r
1255\r
1256 GuidList[GuidListCount - 1].GuidId = AllocateCopyPool(sizeof(EFI_GUID), Guid);\r
1257 GuidList[GuidListCount - 1].StringId = NameID;\r
1258 GuidList[GuidListCount - 1].DumpInfo = DumpFunc;\r
1259\r
1260 if (GuidList[GuidListCount - 1].GuidId == NULL) {\r
1261 return (EFI_OUT_OF_RESOURCES);\r
1262 }\r
1263\r
1264 return (EFI_SUCCESS);\r
1265}\r
1266\r
1267/**\r
1268 Function to add a new GUID/Name mapping.\r
1269\r
1270 This cannot overwrite an existing mapping.\r
1271\r
1272 @param[in] Guid The Guid\r
1273 @param[in] TheName The Guid's name\r
1274 @param[in] Lang RFC4646 language code list or NULL\r
1275\r
1276 @retval EFI_SUCCESS The operation was sucessful\r
1277 @retval EFI_ACCESS_DENIED There was a duplicate\r
1278 @retval EFI_OUT_OF_RESOURCES A memory allocation failed\r
1279 @retval EFI_INVALID_PARAMETER Guid or TheName was NULL\r
1280**/\r
1281EFI_STATUS\r
1282EFIAPI\r
1283AddNewGuidNameMapping(\r
1284 IN CONST EFI_GUID *Guid,\r
1285 IN CONST CHAR16 *TheName,\r
1286 IN CONST CHAR8 *Lang OPTIONAL\r
1287 )\r
1288{\r
6306fd90
JC
1289 EFI_STRING_ID NameID;\r
1290\r
e7e0e42b
CP
1291 HandleParsingHiiInit();\r
1292\r
6306fd90
JC
1293 if (Guid == NULL || TheName == NULL){\r
1294 return (EFI_INVALID_PARAMETER);\r
1295 }\r
1296\r
931b2cff 1297 if ((InternalShellGetNodeFromGuid(Guid)) != NULL) {\r
6306fd90
JC
1298 return (EFI_ACCESS_DENIED);\r
1299 }\r
1300\r
1301 NameID = HiiSetString(mHandleParsingHiiHandle, 0, (CHAR16*)TheName, Lang);\r
1302 if (NameID == 0) {\r
1303 return (EFI_OUT_OF_RESOURCES);\r
1304 }\r
1305\r
1306 return (InsertNewGuidNameMapping(Guid, NameID, NULL));\r
a405b86d 1307}\r
1308\r
1309/**\r
1310 Function to get the name of a protocol or struct from it's GUID.\r
1311\r
1312 if Guid is NULL, then ASSERT.\r
1313\r
1314 @param[in] Guid The GUID to look for the name of.\r
1315 @param[in] Lang The language to use.\r
1316\r
1317 @return pointer to string of the name. The caller\r
1318 is responsible to free this memory.\r
1319**/\r
1320CHAR16*\r
1321EFIAPI\r
1322GetStringNameFromGuid(\r
1323 IN CONST EFI_GUID *Guid,\r
1324 IN CONST CHAR8 *Lang OPTIONAL\r
1325 )\r
1326{\r
dee34318 1327 CONST GUID_INFO_BLOCK *Id;\r
a405b86d 1328\r
e7e0e42b
CP
1329 HandleParsingHiiInit();\r
1330\r
a405b86d 1331 Id = InternalShellGetNodeFromGuid(Guid);\r
6306fd90 1332 return (HiiGetString(mHandleParsingHiiHandle, Id==NULL?STRING_TOKEN(STR_UNKNOWN_DEVICE):Id->StringId, Lang));\r
a405b86d 1333}\r
1334\r
1335/**\r
1336 Function to dump protocol information from a handle.\r
1337\r
1338 This function will return a allocated string buffer containing the\r
1339 information. The caller is responsible for freeing the memory.\r
1340\r
1341 If Guid is NULL, ASSERT().\r
1342 If TheHandle is NULL, ASSERT().\r
1343\r
1344 @param[in] TheHandle The handle to dump information from.\r
1345 @param[in] Guid The GUID of the protocol to dump.\r
1346 @param[in] Verbose TRUE for extra info. FALSE otherwise.\r
1347\r
1348 @return The pointer to string.\r
1349 @retval NULL An error was encountered.\r
1350**/\r
1351CHAR16*\r
1352EFIAPI\r
1353GetProtocolInformationDump(\r
1354 IN CONST EFI_HANDLE TheHandle,\r
1355 IN CONST EFI_GUID *Guid,\r
1356 IN CONST BOOLEAN Verbose\r
1357 )\r
1358{\r
dee34318 1359 CONST GUID_INFO_BLOCK *Id;\r
a405b86d 1360\r
1361 ASSERT(TheHandle != NULL);\r
1362 ASSERT(Guid != NULL);\r
1363\r
1364 if (TheHandle == NULL || Guid == NULL) {\r
1365 return (NULL);\r
1366 }\r
1367\r
1368 Id = InternalShellGetNodeFromGuid(Guid);\r
1369 if (Id != NULL && Id->DumpInfo != NULL) {\r
1370 return (Id->DumpInfo(TheHandle, Verbose));\r
1371 }\r
1372 return (NULL);\r
1373}\r
1374\r
1375/**\r
1376 Function to get the Guid for a protocol or struct based on it's string name.\r
1377\r
0a1eb97d
JC
1378 do not modify the returned Guid.\r
1379\r
a405b86d 1380 @param[in] Name The pointer to the string name.\r
1381 @param[in] Lang The pointer to the language code.\r
0a1eb97d 1382 @param[out] Guid The pointer to the Guid.\r
a405b86d 1383\r
1384 @retval EFI_SUCCESS The operation was sucessful.\r
1385**/\r
1386EFI_STATUS\r
1387EFIAPI\r
1388GetGuidFromStringName(\r
1389 IN CONST CHAR16 *Name,\r
1390 IN CONST CHAR8 *Lang OPTIONAL,\r
0a1eb97d 1391 OUT EFI_GUID **Guid\r
a405b86d 1392 )\r
1393{\r
dee34318 1394 CONST GUID_INFO_BLOCK *ListWalker;\r
a405b86d 1395 CHAR16 *String;\r
6306fd90 1396 UINTN LoopCount;\r
a405b86d 1397\r
e7e0e42b
CP
1398 HandleParsingHiiInit();\r
1399\r
a405b86d 1400 ASSERT(Guid != NULL);\r
1401 if (Guid == NULL) {\r
1402 return (EFI_INVALID_PARAMETER);\r
1403 }\r
1404 *Guid = NULL;\r
1405\r
1406 if (PcdGetBool(PcdShellIncludeNtGuids)) {\r
1407 for (ListWalker = mGuidStringListNT ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {\r
1408 String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);\r
28cdb62b 1409 if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {\r
a405b86d 1410 *Guid = ListWalker->GuidId;\r
1411 }\r
1412 SHELL_FREE_NON_NULL(String);\r
1413 if (*Guid != NULL) {\r
1414 return (EFI_SUCCESS);\r
1415 }\r
1416 }\r
1417 }\r
1418 for (ListWalker = mGuidStringList ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {\r
1419 String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);\r
28cdb62b 1420 if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {\r
a405b86d 1421 *Guid = ListWalker->GuidId;\r
1422 }\r
1423 SHELL_FREE_NON_NULL(String);\r
1424 if (*Guid != NULL) {\r
1425 return (EFI_SUCCESS);\r
1426 }\r
1427 }\r
6306fd90
JC
1428\r
1429 for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) {\r
1430 String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);\r
1431 if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {\r
1432 *Guid = ListWalker->GuidId;\r
1433 }\r
1434 SHELL_FREE_NON_NULL(String);\r
1435 if (*Guid != NULL) {\r
1436 return (EFI_SUCCESS);\r
1437 }\r
1438 }\r
1439\r
a405b86d 1440 return (EFI_NOT_FOUND);\r
1441}\r
1442\r
36384ceb
ED
1443/**\r
1444 Get best support language for this driver.\r
1a6f74d9
CS
1445\r
1446 First base on the user input language to search, second base on the current\r
1447 platform used language to search, third get the first language from the\r
a71003f2 1448 support language list. The caller need to free the buffer of the best language.\r
36384ceb
ED
1449\r
1450 @param[in] SupportedLanguages The support languages for this driver.\r
a71003f2 1451 @param[in] InputLanguage The user input language.\r
36384ceb
ED
1452 @param[in] Iso639Language Whether get language for ISO639.\r
1453\r
1454 @return The best support language for this driver.\r
1455**/\r
1456CHAR8 *\r
a71003f2 1457EFIAPI\r
36384ceb 1458GetBestLanguageForDriver (\r
a71003f2
ED
1459 IN CONST CHAR8 *SupportedLanguages,\r
1460 IN CONST CHAR8 *InputLanguage,\r
36384ceb
ED
1461 IN BOOLEAN Iso639Language\r
1462 )\r
1463{\r
1464 CHAR8 *LanguageVariable;\r
1465 CHAR8 *BestLanguage;\r
1466\r
3cdd434e 1467 GetVariable2 (Iso639Language ? L"Lang" : L"PlatformLang", &gEfiGlobalVariableGuid, (VOID**)&LanguageVariable, NULL);\r
36384ceb
ED
1468\r
1469 BestLanguage = GetBestLanguage(\r
1470 SupportedLanguages,\r
1471 Iso639Language,\r
a71003f2 1472 (InputLanguage != NULL) ? InputLanguage : "",\r
36384ceb 1473 (LanguageVariable != NULL) ? LanguageVariable : "",\r
a71003f2 1474 SupportedLanguages,\r
36384ceb
ED
1475 NULL\r
1476 );\r
1477\r
1478 if (LanguageVariable != NULL) {\r
1479 FreePool (LanguageVariable);\r
1480 }\r
1481\r
1482 return BestLanguage;\r
1483}\r
1484\r
a405b86d 1485/**\r
1486 Function to retrieve the driver name (if possible) from the ComponentName or\r
1487 ComponentName2 protocol\r
1488\r
1489 @param[in] TheHandle The driver handle to get the name of.\r
1490 @param[in] Language The language to use.\r
1491\r
1492 @retval NULL The name could not be found.\r
1493 @return A pointer to the string name. Do not de-allocate the memory.\r
1494**/\r
1495CONST CHAR16*\r
1496EFIAPI\r
1497GetStringNameFromHandle(\r
1498 IN CONST EFI_HANDLE TheHandle,\r
1499 IN CONST CHAR8 *Language\r
1500 )\r
1501{\r
1502 EFI_COMPONENT_NAME2_PROTOCOL *CompNameStruct;\r
1503 EFI_STATUS Status;\r
1504 CHAR16 *RetVal;\r
36384ceb
ED
1505 CHAR8 *BestLang;\r
1506\r
1507 BestLang = NULL;\r
a405b86d 1508\r
1509 Status = gBS->OpenProtocol(\r
1510 TheHandle,\r
1511 &gEfiComponentName2ProtocolGuid,\r
1512 (VOID**)&CompNameStruct,\r
1513 gImageHandle,\r
1514 NULL,\r
1515 EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
1516 if (!EFI_ERROR(Status)) {\r
a71003f2
ED
1517 BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);\r
1518 Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);\r
36384ceb
ED
1519 if (BestLang != NULL) {\r
1520 FreePool (BestLang);\r
1521 BestLang = NULL;\r
1522 }\r
a405b86d 1523 if (!EFI_ERROR(Status)) {\r
1524 return (RetVal);\r
1525 }\r
1526 }\r
1527 Status = gBS->OpenProtocol(\r
1528 TheHandle,\r
1529 &gEfiComponentNameProtocolGuid,\r
1530 (VOID**)&CompNameStruct,\r
1531 gImageHandle,\r
1532 NULL,\r
1533 EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
1534 if (!EFI_ERROR(Status)) {\r
a71003f2
ED
1535 BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);\r
1536 Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);\r
36384ceb
ED
1537 if (BestLang != NULL) {\r
1538 FreePool (BestLang);\r
1539 }\r
a405b86d 1540 if (!EFI_ERROR(Status)) {\r
1541 return (RetVal);\r
1542 }\r
1543 }\r
1544 return (NULL);\r
1545}\r
1546\r
1547/**\r
1548 Function to initialize the file global mHandleList object for use in\r
1549 vonverting handles to index and index to handle.\r
1550\r
1551 @retval EFI_SUCCESS The operation was successful.\r
1552**/\r
1553EFI_STATUS\r
1554EFIAPI\r
1555InternalShellInitHandleList(\r
1556 VOID\r
1557 )\r
1558{\r
1559 EFI_STATUS Status;\r
1560 EFI_HANDLE *HandleBuffer;\r
1561 UINTN HandleCount;\r
1562 HANDLE_LIST *ListWalker;\r
1563\r
1564 if (mHandleList.NextIndex != 0) {\r
1565 return EFI_SUCCESS;\r
1566 }\r
1567 InitializeListHead(&mHandleList.List.Link);\r
1568 mHandleList.NextIndex = 1;\r
1569 Status = gBS->LocateHandleBuffer (\r
1570 AllHandles,\r
1571 NULL,\r
1572 NULL,\r
1573 &HandleCount,\r
1574 &HandleBuffer\r
1575 );\r
1576 ASSERT_EFI_ERROR(Status);\r
1577 if (EFI_ERROR(Status)) {\r
1578 return (Status);\r
1579 }\r
1580 for (mHandleList.NextIndex = 1 ; mHandleList.NextIndex <= HandleCount ; mHandleList.NextIndex++){\r
78ed876b 1581 ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));\r
a405b86d 1582 ASSERT(ListWalker != NULL);\r
1583 ListWalker->TheHandle = HandleBuffer[mHandleList.NextIndex-1];\r
1584 ListWalker->TheIndex = mHandleList.NextIndex;\r
1585 InsertTailList(&mHandleList.List.Link,&ListWalker->Link);\r
1586 }\r
1587 FreePool(HandleBuffer);\r
1588 return (EFI_SUCCESS);\r
1589}\r
1590\r
1591/**\r
1592 Function to retrieve the human-friendly index of a given handle. If the handle\r
1593 does not have a index one will be automatically assigned. The index value is valid\r
1594 until the termination of the shell application.\r
1595\r
1596 @param[in] TheHandle The handle to retrieve an index for.\r
1597\r
1598 @retval 0 A memory allocation failed.\r
1599 @return The index of the handle.\r
1600\r
1601**/\r
1602UINTN\r
1603EFIAPI\r
1604ConvertHandleToHandleIndex(\r
1605 IN CONST EFI_HANDLE TheHandle\r
1606 )\r
1607{\r
f330ff35 1608 EFI_STATUS Status;\r
1609 EFI_GUID **ProtocolBuffer;\r
1610 UINTN ProtocolCount;\r
1611 HANDLE_LIST *ListWalker;\r
1612\r
78ed876b 1613 if (TheHandle == NULL) {\r
1614 return 0;\r
1615 }\r
a405b86d 1616\r
1617 InternalShellInitHandleList();\r
1618\r
1619 for (ListWalker = (HANDLE_LIST*)GetFirstNode(&mHandleList.List.Link)\r
1620 ; !IsNull(&mHandleList.List.Link,&ListWalker->Link)\r
1621 ; ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)\r
1622 ){\r
1623 if (ListWalker->TheHandle == TheHandle) {\r
f330ff35 1624 //\r
1625 // Verify that TheHandle is still present in the Handle Database\r
1626 //\r
1627 Status = gBS->ProtocolsPerHandle(TheHandle, &ProtocolBuffer, &ProtocolCount);\r
1628 if (EFI_ERROR (Status)) {\r
1629 //\r
1630 // TheHandle is not present in the Handle Database, so delete from the handle list\r
1631 //\r
1632 RemoveEntryList (&ListWalker->Link);\r
1633 return 0;\r
1634 }\r
1635 FreePool (ProtocolBuffer);\r
a405b86d 1636 return (ListWalker->TheIndex);\r
1637 }\r
1638 }\r
f330ff35 1639\r
1640 //\r
1641 // Verify that TheHandle is valid handle\r
1642 //\r
1643 Status = gBS->ProtocolsPerHandle(TheHandle, &ProtocolBuffer, &ProtocolCount);\r
1644 if (EFI_ERROR (Status)) {\r
1645 //\r
1646 // TheHandle is not valid, so do not add to handle list\r
1647 //\r
1648 return 0;\r
1649 }\r
1650 FreePool (ProtocolBuffer);\r
1651\r
78ed876b 1652 ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));\r
a405b86d 1653 ASSERT(ListWalker != NULL);\r
1654 ListWalker->TheHandle = TheHandle;\r
1655 ListWalker->TheIndex = mHandleList.NextIndex++;\r
1656 InsertTailList(&mHandleList.List.Link,&ListWalker->Link);\r
1657 return (ListWalker->TheIndex);\r
1658}\r
1659\r
1660\r
1661\r
1662/**\r
1663 Function to retrieve the EFI_HANDLE from the human-friendly index.\r
1664\r
1665 @param[in] TheIndex The index to retrieve the EFI_HANDLE for.\r
1666\r
1667 @retval NULL The index was invalid.\r
1668 @return The EFI_HANDLE that index represents.\r
1669\r
1670**/\r
1671EFI_HANDLE\r
1672EFIAPI\r
1673ConvertHandleIndexToHandle(\r
1674 IN CONST UINTN TheIndex\r
1675 )\r
1676{\r
f330ff35 1677 EFI_STATUS Status;\r
1678 EFI_GUID **ProtocolBuffer;\r
1679 UINTN ProtocolCount;\r
a405b86d 1680 HANDLE_LIST *ListWalker;\r
1681\r
1682 InternalShellInitHandleList();\r
1683\r
1684 if (TheIndex >= mHandleList.NextIndex) {\r
f330ff35 1685 return NULL;\r
a405b86d 1686 }\r
1687\r
1688 for (ListWalker = (HANDLE_LIST*)GetFirstNode(&mHandleList.List.Link)\r
1689 ; !IsNull(&mHandleList.List.Link,&ListWalker->Link)\r
1690 ; ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)\r
1691 ){\r
f330ff35 1692 if (ListWalker->TheIndex == TheIndex && ListWalker->TheHandle != NULL) {\r
1693 //\r
1694 // Verify that LinkWalker->TheHandle is valid handle\r
1695 //\r
1696 Status = gBS->ProtocolsPerHandle(ListWalker->TheHandle, &ProtocolBuffer, &ProtocolCount);\r
1697 if (EFI_ERROR (Status)) {\r
1698 //\r
1699 // TheHandle is not valid, so do not add to handle list\r
1700 //\r
1701 ListWalker->TheHandle = NULL;\r
1702 }\r
a405b86d 1703 return (ListWalker->TheHandle);\r
1704 }\r
1705 }\r
f330ff35 1706 return NULL;\r
a405b86d 1707}\r
1708\r
1709/**\r
1710 Gets all the related EFI_HANDLEs based on the mask supplied.\r
1711\r
1712 This function scans all EFI_HANDLES in the UEFI environment's handle database\r
1713 and returns the ones with the specified relationship (Mask) to the specified\r
1714 controller handle.\r
1715\r
1716 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.\r
1717 If MatchingHandleCount is NULL, then ASSERT.\r
1718\r
1719 If MatchingHandleBuffer is not NULL upon a successful return the memory must be\r
1720 caller freed.\r
1721\r
1722 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.\r
1723 @param[in] ControllerHandle The handle with Device Path protocol on it.\r
1724 @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in\r
1725 MatchingHandleBuffer.\r
1726 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount\r
1727 EFI_HANDLEs with a terminating NULL EFI_HANDLE.\r
1728 @param[out] HandleType An array of type information.\r
1729\r
1730 @retval EFI_SUCCESS The operation was successful, and any related handles\r
1731 are in MatchingHandleBuffer.\r
1732 @retval EFI_NOT_FOUND No matching handles were found.\r
1733 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.\r
1734**/\r
1735EFI_STATUS\r
1736EFIAPI\r
1737ParseHandleDatabaseByRelationshipWithType (\r
1738 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,\r
1739 IN CONST EFI_HANDLE ControllerHandle OPTIONAL,\r
1740 IN UINTN *HandleCount,\r
1741 OUT EFI_HANDLE **HandleBuffer,\r
1742 OUT UINTN **HandleType\r
1743 )\r
1744{\r
1745 EFI_STATUS Status;\r
1746 UINTN HandleIndex;\r
1747 EFI_GUID **ProtocolGuidArray;\r
1748 UINTN ArrayCount;\r
1749 UINTN ProtocolIndex;\r
1750 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;\r
1751 UINTN OpenInfoCount;\r
1752 UINTN OpenInfoIndex;\r
1753 UINTN ChildIndex;\r
f330ff35 1754 INTN DriverBindingHandleIndex;\r
a405b86d 1755\r
1756 ASSERT(HandleCount != NULL);\r
1757 ASSERT(HandleBuffer != NULL);\r
1758 ASSERT(HandleType != NULL);\r
1759 ASSERT(DriverBindingHandle != NULL || ControllerHandle != NULL);\r
1760\r
1761 *HandleCount = 0;\r
1762 *HandleBuffer = NULL;\r
1763 *HandleType = NULL;\r
1764\r
1765 //\r
1766 // Retrieve the list of all handles from the handle database\r
1767 //\r
1768 Status = gBS->LocateHandleBuffer (\r
1769 AllHandles,\r
1770 NULL,\r
1771 NULL,\r
1772 HandleCount,\r
1773 HandleBuffer\r
1774 );\r
1775 if (EFI_ERROR (Status)) {\r
1776 return (Status);\r
1777 }\r
1778\r
1779 *HandleType = AllocateZeroPool (*HandleCount * sizeof (UINTN));\r
1780 ASSERT(*HandleType != NULL);\r
1781\r
f330ff35 1782 DriverBindingHandleIndex = -1;\r
1783 for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {\r
1784 if (DriverBindingHandle != NULL && (*HandleBuffer)[HandleIndex] == DriverBindingHandle) {\r
1785 DriverBindingHandleIndex = (INTN)HandleIndex;\r
1786 }\r
1787 }\r
1788\r
a405b86d 1789 for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {\r
1790 //\r
1791 // Retrieve the list of all the protocols on each handle\r
1792 //\r
1793 Status = gBS->ProtocolsPerHandle (\r
1794 (*HandleBuffer)[HandleIndex],\r
1795 &ProtocolGuidArray,\r
1796 &ArrayCount\r
1797 );\r
f330ff35 1798 if (EFI_ERROR (Status)) {\r
1799 continue;\r
1800 }\r
a405b86d 1801\r
f330ff35 1802 for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {\r
a405b86d 1803\r
f330ff35 1804 //\r
1805 // Set the bit describing what this handle has\r
1806 //\r
1807 if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiLoadedImageProtocolGuid) ) {\r
7aae3c35 1808 (*HandleType)[HandleIndex] |= (UINTN)HR_IMAGE_HANDLE;\r
f330ff35 1809 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverBindingProtocolGuid) ) {\r
7aae3c35 1810 (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_BINDING_HANDLE;\r
f330ff35 1811 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfiguration2ProtocolGuid)) {\r
7aae3c35 1812 (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_CONFIGURATION_HANDLE;\r
f330ff35 1813 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid) ) {\r
7aae3c35 1814 (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_CONFIGURATION_HANDLE;\r
f330ff35 1815 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnostics2ProtocolGuid) ) {\r
7aae3c35 1816 (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_DIAGNOSTICS_HANDLE;\r
f330ff35 1817 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid) ) {\r
7aae3c35 1818 (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_DIAGNOSTICS_HANDLE;\r
f330ff35 1819 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentName2ProtocolGuid) ) {\r
7aae3c35 1820 (*HandleType)[HandleIndex] |= (UINTN)HR_COMPONENT_NAME_HANDLE;\r
f330ff35 1821 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentNameProtocolGuid) ) {\r
7aae3c35 1822 (*HandleType)[HandleIndex] |= (UINTN)HR_COMPONENT_NAME_HANDLE;\r
f330ff35 1823 } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDevicePathProtocolGuid) ) {\r
7aae3c35 1824 (*HandleType)[HandleIndex] |= (UINTN)HR_DEVICE_HANDLE;\r
f330ff35 1825 } else {\r
1826 DEBUG_CODE_BEGIN();\r
1827 ASSERT((*HandleType)[HandleIndex] == (*HandleType)[HandleIndex]);\r
1828 DEBUG_CODE_END();\r
1829 }\r
1830 //\r
1831 // Retrieve the list of agents that have opened each protocol\r
1832 //\r
1833 Status = gBS->OpenProtocolInformation (\r
a405b86d 1834 (*HandleBuffer)[HandleIndex],\r
1835 ProtocolGuidArray[ProtocolIndex],\r
1836 &OpenInfo,\r
1837 &OpenInfoCount\r
1838 );\r
f330ff35 1839 if (EFI_ERROR (Status)) {\r
1840 continue;\r
1841 }\r
1842\r
1843 if (ControllerHandle == NULL) {\r
1844 //\r
1a6f74d9 1845 // ControllerHandle == NULL and DriverBindingHandle != NULL.\r
f330ff35 1846 // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing\r
1847 //\r
1848 for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {\r
1849 if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {\r
7aae3c35 1850 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);\r
f330ff35 1851 if (DriverBindingHandleIndex != -1) {\r
7aae3c35 1852 (*HandleType)[DriverBindingHandleIndex] |= (UINTN)HR_DEVICE_DRIVER;\r
f330ff35 1853 }\r
1854 }\r
1855 if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
7aae3c35 1856 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);\r
f330ff35 1857 if (DriverBindingHandleIndex != -1) {\r
7aae3c35 1858 (*HandleType)[DriverBindingHandleIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER);\r
f330ff35 1859 }\r
1860 for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {\r
1861 if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {\r
7aae3c35 1862 (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE);\r
f330ff35 1863 }\r
1864 }\r
1865 }\r
1866 }\r
1867 }\r
1868 if (DriverBindingHandle == NULL && ControllerHandle != NULL) {\r
1869 if (ControllerHandle == (*HandleBuffer)[HandleIndex]) {\r
7aae3c35 1870 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);\r
a405b86d 1871 for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {\r
f330ff35 1872 if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {\r
1873 for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {\r
1874 if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {\r
7aae3c35 1875 (*HandleType)[ChildIndex] |= (UINTN)HR_DEVICE_DRIVER;\r
f330ff35 1876 }\r
a405b86d 1877 }\r
f330ff35 1878 }\r
1879 if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
1880 for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {\r
1881 if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {\r
7aae3c35 1882 (*HandleType)[ChildIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER);\r
f330ff35 1883 }\r
1884 if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {\r
7aae3c35 1885 (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE);\r
a405b86d 1886 }\r
1887 }\r
1888 }\r
f330ff35 1889 }\r
1890 } else {\r
1891 for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {\r
1892 if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
1893 if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {\r
7aae3c35 1894 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_PARENT_HANDLE);\r
f330ff35 1895 }\r
1896 }\r
1897 }\r
1898 }\r
1899 }\r
1900 if (DriverBindingHandle != NULL && ControllerHandle != NULL) {\r
1901 if (ControllerHandle == (*HandleBuffer)[HandleIndex]) {\r
7aae3c35 1902 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);\r
f330ff35 1903 for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {\r
1904 if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {\r
1905 if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {\r
1906 if (DriverBindingHandleIndex != -1) {\r
7aae3c35 1907 (*HandleType)[DriverBindingHandleIndex] |= (UINTN)HR_DEVICE_DRIVER;\r
a405b86d 1908 }\r
1909 }\r
f330ff35 1910 }\r
1911 if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
1912 if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {\r
a405b86d 1913 for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {\r
f330ff35 1914 if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {\r
7aae3c35 1915 (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE);\r
a405b86d 1916 }\r
1917 }\r
1918 }\r
f330ff35 1919\r
1920 for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {\r
1921 if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {\r
7aae3c35 1922 (*HandleType)[ChildIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER);\r
f330ff35 1923 }\r
1924 }\r
1925 }\r
1926 }\r
1927 } else {\r
1928 for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {\r
1929 if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
1930 if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {\r
7aae3c35 1931 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_PARENT_HANDLE);\r
f330ff35 1932 }\r
a405b86d 1933 }\r
1934 }\r
a405b86d 1935 }\r
1936 }\r
f330ff35 1937 FreePool (OpenInfo);\r
a405b86d 1938 }\r
f330ff35 1939 FreePool (ProtocolGuidArray);\r
a405b86d 1940 }\r
f330ff35 1941 return EFI_SUCCESS;\r
a405b86d 1942}\r
1943\r
1944/**\r
1945 Gets all the related EFI_HANDLEs based on the single EFI_HANDLE and the mask\r
1946 supplied.\r
1947\r
1948 This function will scan all EFI_HANDLES in the UEFI environment's handle database\r
1949 and return all the ones with the specified relationship (Mask) to the specified\r
1950 controller handle.\r
1951\r
1952 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.\r
1953 If MatchingHandleCount is NULL, then ASSERT.\r
1954\r
1955 If MatchingHandleBuffer is not NULL upon a sucessful return the memory must be\r
1956 caller freed.\r
1957\r
1958 @param[in] DriverBindingHandle Handle to a object with Driver Binding protocol\r
1959 on it.\r
1960 @param[in] ControllerHandle Handle to a device with Device Path protocol on it.\r
1961 @param[in] Mask Mask of what relationship(s) is desired.\r
1962 @param[in] MatchingHandleCount Poitner to UINTN specifying number of HANDLES in\r
1963 MatchingHandleBuffer.\r
1964 @param[out] MatchingHandleBuffer On a sucessful return a buffer of MatchingHandleCount\r
1965 EFI_HANDLEs and a terminating NULL EFI_HANDLE.\r
1966\r
1967 @retval EFI_SUCCESS The operation was sucessful and any related handles\r
1968 are in MatchingHandleBuffer;\r
1969 @retval EFI_NOT_FOUND No matching handles were found.\r
1970 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.\r
1971**/\r
1972EFI_STATUS\r
1973EFIAPI\r
1974ParseHandleDatabaseByRelationship (\r
1975 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,\r
1976 IN CONST EFI_HANDLE ControllerHandle OPTIONAL,\r
1977 IN CONST UINTN Mask,\r
1978 IN UINTN *MatchingHandleCount,\r
1979 OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL\r
1980 )\r
1981{\r
1982 EFI_STATUS Status;\r
1983 UINTN HandleCount;\r
1984 EFI_HANDLE *HandleBuffer;\r
1985 UINTN *HandleType;\r
1986 UINTN HandleIndex;\r
1987\r
1988 ASSERT(MatchingHandleCount != NULL);\r
1989 ASSERT(DriverBindingHandle != NULL || ControllerHandle != NULL);\r
1990\r
1991 if ((Mask & HR_VALID_MASK) != Mask) {\r
1992 return (EFI_INVALID_PARAMETER);\r
1993 }\r
1994\r
1995 if ((Mask & HR_CHILD_HANDLE) != 0 && DriverBindingHandle == NULL) {\r
1996 return (EFI_INVALID_PARAMETER);\r
1997 }\r
1998\r
1999 *MatchingHandleCount = 0;\r
2000 if (MatchingHandleBuffer != NULL) {\r
2001 *MatchingHandleBuffer = NULL;\r
2002 }\r
2003\r
2004 HandleBuffer = NULL;\r
2005 HandleType = NULL;\r
2006\r
2007 Status = ParseHandleDatabaseByRelationshipWithType (\r
2008 DriverBindingHandle,\r
2009 ControllerHandle,\r
2010 &HandleCount,\r
2011 &HandleBuffer,\r
2012 &HandleType\r
2013 );\r
2014 if (!EFI_ERROR (Status)) {\r
2015 //\r
2016 // Count the number of handles that match the attributes in Mask\r
2017 //\r
2018 for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {\r
2019 if ((HandleType[HandleIndex] & Mask) == Mask) {\r
2020 (*MatchingHandleCount)++;\r
2021 }\r
2022 }\r
2023 //\r
2024 // If no handles match the attributes in Mask then return EFI_NOT_FOUND\r
2025 //\r
2026 if (*MatchingHandleCount == 0) {\r
2027 Status = EFI_NOT_FOUND;\r
2028 } else {\r
2029\r
2030 if (MatchingHandleBuffer == NULL) {\r
2031 //\r
2032 // Someone just wanted the count...\r
2033 //\r
2034 Status = EFI_SUCCESS;\r
2035 } else {\r
2036 //\r
2037 // Allocate a handle buffer for the number of handles that matched the attributes in Mask\r
2038 //\r
78ed876b 2039 *MatchingHandleBuffer = AllocateZeroPool ((*MatchingHandleCount +1)* sizeof (EFI_HANDLE));\r
a405b86d 2040 ASSERT(*MatchingHandleBuffer != NULL);\r
2041\r
2042 for (HandleIndex = 0,*MatchingHandleCount = 0\r
2043 ; HandleIndex < HandleCount\r
2044 ; HandleIndex++\r
2045 ){\r
2046 //\r
2047 // Fill the allocated buffer with the handles that matched the attributes in Mask\r
2048 //\r
2049 if ((HandleType[HandleIndex] & Mask) == Mask) {\r
2050 (*MatchingHandleBuffer)[(*MatchingHandleCount)++] = HandleBuffer[HandleIndex];\r
2051 }\r
2052 }\r
2053\r
2054 //\r
2055 // Make the last one NULL\r
2056 //\r
2057 (*MatchingHandleBuffer)[*MatchingHandleCount] = NULL;\r
2058\r
2059 Status = EFI_SUCCESS;\r
2060 } // MacthingHandleBuffer == NULL (ELSE)\r
2061 } // *MatchingHandleCount == 0 (ELSE)\r
2062 } // no error on ParseHandleDatabaseByRelationshipWithType\r
2063\r
2064 if (HandleBuffer != NULL) {\r
2065 FreePool (HandleBuffer);\r
2066 }\r
2067\r
2068 if (HandleType != NULL) {\r
2069 FreePool (HandleType);\r
2070 }\r
2071\r
2072 return Status;\r
2073}\r
2074\r
2075/**\r
2076 Gets handles for any child controllers of the passed in controller.\r
2077\r
2078 @param[in] ControllerHandle The handle of the "parent controller"\r
2079 @param[in] MatchingHandleCount Pointer to the number of handles in\r
2080 MatchingHandleBuffer on return.\r
2081 @param[out] MatchingHandleBuffer Buffer containing handles on a successful\r
2082 return.\r
2083\r
2084\r
2085 @retval EFI_SUCCESS The operation was sucessful.\r
2086**/\r
2087EFI_STATUS\r
2088EFIAPI\r
2089ParseHandleDatabaseForChildControllers(\r
2090 IN CONST EFI_HANDLE ControllerHandle,\r
2091 IN UINTN *MatchingHandleCount,\r
2092 OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL\r
2093 )\r
2094{\r
2095 EFI_STATUS Status;\r
f330ff35 2096 UINTN HandleIndex;\r
a405b86d 2097 UINTN DriverBindingHandleCount;\r
2098 EFI_HANDLE *DriverBindingHandleBuffer;\r
2099 UINTN DriverBindingHandleIndex;\r
2100 UINTN ChildControllerHandleCount;\r
2101 EFI_HANDLE *ChildControllerHandleBuffer;\r
2102 UINTN ChildControllerHandleIndex;\r
a405b86d 2103 EFI_HANDLE *HandleBufferForReturn;\r
2104\r
ff51746b 2105 if (MatchingHandleCount == NULL) {\r
2106 return (EFI_INVALID_PARAMETER);\r
2107 }\r
64d753f1 2108 *MatchingHandleCount = 0;\r
a405b86d 2109\r
2110 Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (\r
2111 ControllerHandle,\r
2112 &DriverBindingHandleCount,\r
2113 &DriverBindingHandleBuffer\r
2114 );\r
2115 if (EFI_ERROR (Status)) {\r
2116 return Status;\r
2117 }\r
2118\r
ff51746b 2119 //\r
2120 // Get a buffer big enough for all the controllers.\r
2121 //\r
f330ff35 2122 HandleBufferForReturn = GetHandleListByProtocol(NULL);\r
a405b86d 2123 if (HandleBufferForReturn == NULL) {\r
2124 FreePool (DriverBindingHandleBuffer);\r
ff51746b 2125 return (EFI_NOT_FOUND);\r
a405b86d 2126 }\r
2127\r
a405b86d 2128 for (DriverBindingHandleIndex = 0; DriverBindingHandleIndex < DriverBindingHandleCount; DriverBindingHandleIndex++) {\r
2129 Status = PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (\r
2130 DriverBindingHandleBuffer[DriverBindingHandleIndex],\r
2131 ControllerHandle,\r
2132 &ChildControllerHandleCount,\r
2133 &ChildControllerHandleBuffer\r
2134 );\r
2135 if (EFI_ERROR (Status)) {\r
2136 continue;\r
2137 }\r
2138\r
2139 for (ChildControllerHandleIndex = 0;\r
2140 ChildControllerHandleIndex < ChildControllerHandleCount;\r
2141 ChildControllerHandleIndex++\r
2142 ) {\r
f330ff35 2143 for (HandleIndex = 0; HandleIndex < *MatchingHandleCount; HandleIndex++) {\r
2144 if (HandleBufferForReturn[HandleIndex] == ChildControllerHandleBuffer[ChildControllerHandleIndex]) {\r
2145 break;\r
2146 }\r
2147 }\r
2148 if (HandleIndex >= *MatchingHandleCount) {\r
2149 HandleBufferForReturn[(*MatchingHandleCount)++] = ChildControllerHandleBuffer[ChildControllerHandleIndex];\r
2150 }\r
a405b86d 2151 }\r
2152\r
2153 FreePool (ChildControllerHandleBuffer);\r
2154 }\r
2155\r
2156 FreePool (DriverBindingHandleBuffer);\r
2157\r
2158 if (MatchingHandleBuffer != NULL) {\r
2159 *MatchingHandleBuffer = HandleBufferForReturn;\r
2160 } else {\r
2161 FreePool(HandleBufferForReturn);\r
2162 }\r
2163\r
2164 return (EFI_SUCCESS);\r
2165}\r
2166\r
2167/**\r
2168 Appends 1 buffer to another buffer. This will re-allocate the destination buffer\r
2169 if necessary to fit all of the data.\r
2170\r
2171 If DestinationBuffer is NULL, then ASSERT().\r
2172\r
4ff7e37b
ED
2173 @param[in, out] DestinationBuffer The pointer to the pointer to the buffer to append onto.\r
2174 @param[in, out] DestinationSize The pointer to the size of DestinationBuffer.\r
2175 @param[in] SourceBuffer The pointer to the buffer to append onto DestinationBuffer.\r
2176 @param[in] SourceSize The number of bytes of SourceBuffer to append.\r
a405b86d 2177\r
2178 @retval NULL A memory allocation failed.\r
2179 @retval NULL A parameter was invalid.\r
2180 @return A pointer to (*DestinationBuffer).\r
2181**/\r
2182VOID*\r
2183EFIAPI\r
2184BuffernCatGrow (\r
2185 IN OUT VOID **DestinationBuffer,\r
2186 IN OUT UINTN *DestinationSize,\r
2187 IN VOID *SourceBuffer,\r
2188 IN UINTN SourceSize\r
2189 )\r
2190{\r
2191 UINTN LocalDestinationSize;\r
2192 UINTN LocalDestinationFinalSize;\r
2193\r
2194 ASSERT(DestinationBuffer != NULL);\r
2195\r
2196 if (SourceSize == 0 || SourceBuffer == NULL) {\r
2197 return (*DestinationBuffer);\r
2198 }\r
2199\r
2200 if (DestinationSize == NULL) {\r
2201 LocalDestinationSize = 0;\r
2202 } else {\r
2203 LocalDestinationSize = *DestinationSize;\r
2204 }\r
2205\r
2206 LocalDestinationFinalSize = LocalDestinationSize + SourceSize;\r
2207\r
2208 if (DestinationSize != NULL) {\r
2209 *DestinationSize = LocalDestinationSize;\r
2210 }\r
2211\r
2212 if (LocalDestinationSize == 0) {\r
2213 // allcoate\r
78ed876b 2214 *DestinationBuffer = AllocateZeroPool(LocalDestinationFinalSize);\r
a405b86d 2215 } else {\r
2216 // reallocate\r
2217 *DestinationBuffer = ReallocatePool(LocalDestinationSize, LocalDestinationFinalSize, *DestinationBuffer);\r
2218 }\r
2219\r
2220 ASSERT(*DestinationBuffer != NULL);\r
2221\r
2222 // copy\r
2223 return (CopyMem(((UINT8*)(*DestinationBuffer)) + LocalDestinationSize, SourceBuffer, SourceSize));\r
2224}\r
2225\r
2226/**\r
2227 Gets handles for any child devices produced by the passed in driver.\r
2228\r
2229 @param[in] DriverHandle The handle of the driver.\r
2230 @param[in] MatchingHandleCount Pointer to the number of handles in\r
2231 MatchingHandleBuffer on return.\r
2232 @param[out] MatchingHandleBuffer Buffer containing handles on a successful\r
2233 return.\r
2234 @retval EFI_SUCCESS The operation was sucessful.\r
2235 @sa ParseHandleDatabaseByRelationship\r
2236**/\r
2237EFI_STATUS\r
2238EFIAPI\r
2239ParseHandleDatabaseForChildDevices(\r
2240 IN CONST EFI_HANDLE DriverHandle,\r
2241 IN UINTN *MatchingHandleCount,\r
2242 OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL\r
2243 )\r
2244{\r
2245 EFI_HANDLE *Buffer;\r
2246 EFI_HANDLE *Buffer2;\r
2247 UINTN Count1;\r
2248 UINTN Count2;\r
2249 UINTN HandleIndex;\r
2250 EFI_STATUS Status;\r
2251 UINTN HandleBufferSize;\r
2252\r
2253 ASSERT(MatchingHandleCount != NULL);\r
2254\r
2255 HandleBufferSize = 0;\r
2256 Buffer = NULL;\r
2257 Buffer2 = NULL;\r
2258 *MatchingHandleCount = 0;\r
2259\r
2260 Status = PARSE_HANDLE_DATABASE_DEVICES (\r
2261 DriverHandle,\r
2262 &Count1,\r
2263 &Buffer\r
2264 );\r
2265 if (!EFI_ERROR (Status)) {\r
2266 for (HandleIndex = 0; HandleIndex < Count1; HandleIndex++) {\r
2267 //\r
2268 // now find the children\r
2269 //\r
2270 Status = PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (\r
2271 DriverHandle,\r
2272 Buffer[HandleIndex],\r
2273 &Count2,\r
2274 &Buffer2\r
2275 );\r
2276 if (EFI_ERROR(Status)) {\r
2277 break;\r
2278 }\r
2279 //\r
2280 // save out required and optional data elements\r
2281 //\r
2282 *MatchingHandleCount += Count2;\r
2283 if (MatchingHandleBuffer != NULL) {\r
2284 *MatchingHandleBuffer = BuffernCatGrow((VOID**)MatchingHandleBuffer, &HandleBufferSize, Buffer2, Count2 * sizeof(Buffer2[0]));\r
2285 }\r
2286\r
2287 //\r
2288 // free the memory\r
2289 //\r
2290 if (Buffer2 != NULL) {\r
2291 FreePool(Buffer2);\r
2292 }\r
2293 }\r
2294 }\r
2295\r
2296 if (Buffer != NULL) {\r
2297 FreePool(Buffer);\r
2298 }\r
2299 return (Status);\r
2300}\r
2301\r
2302/**\r
2303 Function to get all handles that support a given protocol or all handles.\r
2304\r
2305 @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL\r
2306 then the function will return all handles.\r
2307\r
2308 @retval NULL A memory allocation failed.\r
2309 @return A NULL terminated list of handles.\r
2310**/\r
2311EFI_HANDLE*\r
2312EFIAPI\r
40d7a9cf 2313GetHandleListByProtocol (\r
a405b86d 2314 IN CONST EFI_GUID *ProtocolGuid OPTIONAL\r
2315 )\r
2316{\r
2317 EFI_HANDLE *HandleList;\r
2318 UINTN Size;\r
2319 EFI_STATUS Status;\r
2320\r
2321 Size = 0;\r
2322 HandleList = NULL;\r
2323\r
2324 //\r
2325 // We cannot use LocateHandleBuffer since we need that NULL item on the ends of the list!\r
2326 //\r
2327 if (ProtocolGuid == NULL) {\r
2328 Status = gBS->LocateHandle(AllHandles, NULL, NULL, &Size, HandleList);\r
2329 if (Status == EFI_BUFFER_TOO_SMALL) {\r
78ed876b 2330 HandleList = AllocateZeroPool(Size + sizeof(EFI_HANDLE));\r
40d7a9cf 2331 if (HandleList == NULL) {\r
2332 return (NULL);\r
2333 }\r
a405b86d 2334 Status = gBS->LocateHandle(AllHandles, NULL, NULL, &Size, HandleList);\r
2335 HandleList[Size/sizeof(EFI_HANDLE)] = NULL;\r
2336 }\r
2337 } else {\r
2338 Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)ProtocolGuid, NULL, &Size, HandleList);\r
2339 if (Status == EFI_BUFFER_TOO_SMALL) {\r
78ed876b 2340 HandleList = AllocateZeroPool(Size + sizeof(EFI_HANDLE));\r
40d7a9cf 2341 if (HandleList == NULL) {\r
2342 return (NULL);\r
2343 }\r
a405b86d 2344 Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)ProtocolGuid, NULL, &Size, HandleList);\r
2345 HandleList[Size/sizeof(EFI_HANDLE)] = NULL;\r
2346 }\r
2347 }\r
2348 if (EFI_ERROR(Status)) {\r
2349 if (HandleList != NULL) {\r
2350 FreePool(HandleList);\r
2351 }\r
2352 return (NULL);\r
2353 }\r
2354 return (HandleList);\r
2355}\r
2356\r
2357/**\r
2358 Function to get all handles that support some protocols.\r
2359\r
2360 @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.\r
2361\r
2362 @retval NULL A memory allocation failed.\r
ff51746b 2363 @retval NULL ProtocolGuids was NULL.\r
2364 @return A NULL terminated list of EFI_HANDLEs.\r
a405b86d 2365**/\r
2366EFI_HANDLE*\r
2367EFIAPI\r
40d7a9cf 2368GetHandleListByProtocolList (\r
a405b86d 2369 IN CONST EFI_GUID **ProtocolGuids\r
2370 )\r
2371{\r
2372 EFI_HANDLE *HandleList;\r
2373 UINTN Size;\r
2374 UINTN TotalSize;\r
40d7a9cf 2375 UINTN TempSize;\r
a405b86d 2376 EFI_STATUS Status;\r
2377 CONST EFI_GUID **GuidWalker;\r
2378 EFI_HANDLE *HandleWalker1;\r
2379 EFI_HANDLE *HandleWalker2;\r
2380\r
2381 Size = 0;\r
2382 HandleList = NULL;\r
2383 TotalSize = sizeof(EFI_HANDLE);\r
2384\r
2385 for (GuidWalker = ProtocolGuids ; GuidWalker != NULL && *GuidWalker != NULL ; GuidWalker++,Size = 0){\r
2386 Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)(*GuidWalker), NULL, &Size, NULL);\r
2387 if (Status == EFI_BUFFER_TOO_SMALL) {\r
2388 TotalSize += Size;\r
2389 }\r
2390 }\r
40d7a9cf 2391\r
2392 //\r
2393 // No handles were found... \r
2394 //\r
2395 if (TotalSize == sizeof(EFI_HANDLE)) {\r
2396 return (NULL);\r
2397 }\r
2398\r
2399 HandleList = AllocateZeroPool(TotalSize);\r
a405b86d 2400 if (HandleList == NULL) {\r
2401 return (NULL);\r
2402 }\r
2403\r
2404 Size = 0;\r
2405 for (GuidWalker = ProtocolGuids ; GuidWalker != NULL && *GuidWalker != NULL ; GuidWalker++){\r
40d7a9cf 2406 TempSize = TotalSize - Size;\r
ff51746b 2407 Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)(*GuidWalker), NULL, &TempSize, HandleList+(Size/sizeof(EFI_HANDLE)));\r
40d7a9cf 2408\r
2409 //\r
2410 // Allow for missing protocols... Only update the 'used' size upon success.\r
2411 //\r
2412 if (!EFI_ERROR(Status)) {\r
ff51746b 2413 Size += TempSize;\r
40d7a9cf 2414 }\r
a405b86d 2415 }\r
ff51746b 2416 ASSERT(HandleList[(TotalSize/sizeof(EFI_HANDLE))-1] == NULL);\r
a405b86d 2417\r
2418 for (HandleWalker1 = HandleList ; HandleWalker1 != NULL && *HandleWalker1 != NULL ; HandleWalker1++) {\r
2419 for (HandleWalker2 = HandleWalker1 + 1; HandleWalker2 != NULL && *HandleWalker2 != NULL ; HandleWalker2++) {\r
2420 if (*HandleWalker1 == *HandleWalker2) {\r
2421 //\r
2422 // copy memory back 1 handle width.\r
2423 //\r
2424 CopyMem(HandleWalker2, HandleWalker2 + 1, TotalSize - ((HandleWalker2-HandleList+1)*sizeof(EFI_HANDLE)));\r
2425 }\r
2426 }\r
2427 }\r
2428\r
2429 return (HandleList);\r
2430}\r
2431\r
2432\r
2433\r
2434\r
2435\r
2436\r
2437\r
2438\r
2439\r
2440\r