b7b0246ac93af5cadb5a5c1b994d5143247893df
[mirror_edk2.git] / ShellPkg / Library / UefiHandleParsingLib / UefiHandleParsingLib.c
1 /** @file\r
2   Provides interface to advanced shell functionality for parsing both handle and protocol database.\r
3 \r
4   Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>\r
5   (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
6   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
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
18 #include "IndustryStandard/Acpi10.h"\r
19 #include "IndustryStandard/Pci.h"\r
20 #include <PiDxe.h>\r
21 #include <Protocol/FirmwareVolume2.h>\r
22 \r
23 EFI_HANDLE        mHandleParsingHiiHandle = NULL;\r
24 HANDLE_INDEX_LIST mHandleList = {{{NULL,NULL},0,0},0};\r
25 GUID_INFO_BLOCK   *mGuidList;\r
26 UINTN             mGuidListCount;\r
27 \r
28 /**\r
29   Function to find the file name associated with a LoadedImageProtocol.\r
30 \r
31   @param[in] LoadedImage     An instance of LoadedImageProtocol.\r
32 \r
33   @retval                    A string representation of the file name associated\r
34                              with LoadedImage, or NULL if no name can be found.\r
35 **/\r
36 CHAR16*\r
37 FindLoadedImageFileName (\r
38   IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage\r
39   )\r
40 {\r
41   EFI_GUID                       *NameGuid;\r
42   EFI_STATUS                     Status;\r
43   EFI_FIRMWARE_VOLUME2_PROTOCOL  *Fv;\r
44   VOID                           *Buffer;\r
45   UINTN                          BufferSize;\r
46   UINT32                         AuthenticationStatus;\r
47 \r
48   if ((LoadedImage == NULL) || (LoadedImage->FilePath == NULL)) {\r
49     return NULL;\r
50   }\r
51 \r
52   NameGuid = EfiGetNameGuidFromFwVolDevicePathNode((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)LoadedImage->FilePath);\r
53 \r
54   if (NameGuid == NULL) {\r
55     return NULL;\r
56   }\r
57 \r
58   //\r
59   // Get the FirmwareVolume2Protocol of the device handle that this image was loaded from.\r
60   //\r
61   Status = gBS->HandleProtocol (LoadedImage->DeviceHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID**) &Fv);\r
62 \r
63   //\r
64   // FirmwareVolume2Protocol is PI, and is not required to be available.\r
65   //\r
66   if (EFI_ERROR (Status)) {\r
67     return NULL;\r
68   }\r
69 \r
70   //\r
71   // Read the user interface section of the image.\r
72   //\r
73   Buffer = NULL;\r
74   Status = Fv->ReadSection(Fv, NameGuid, EFI_SECTION_USER_INTERFACE, 0, &Buffer, &BufferSize, &AuthenticationStatus);\r
75 \r
76   if (EFI_ERROR (Status)) {\r
77     return NULL;\r
78   }\r
79 \r
80   //\r
81   // ReadSection returns just the section data, without any section header. For\r
82   // a user interface section, the only data is the file name.\r
83   //\r
84   return Buffer;\r
85 }\r
86 \r
87 /**\r
88   Function to translate the EFI_MEMORY_TYPE into a string.\r
89 \r
90   @param[in] Memory     The memory type.\r
91 \r
92   @retval               A string representation of the type allocated from BS Pool.\r
93 **/\r
94 CHAR16*\r
95 ConvertMemoryType (\r
96   IN CONST EFI_MEMORY_TYPE Memory\r
97   )\r
98 {\r
99   CHAR16 *RetVal;\r
100   RetVal = NULL;\r
101 \r
102   switch (Memory) {\r
103   case EfiReservedMemoryType:       StrnCatGrow(&RetVal, NULL, L"EfiReservedMemoryType", 0);        break;\r
104   case EfiLoaderCode:               StrnCatGrow(&RetVal, NULL, L"EfiLoaderCode", 0);                break;\r
105   case EfiLoaderData:               StrnCatGrow(&RetVal, NULL, L"EfiLoaderData", 0);                break;\r
106   case EfiBootServicesCode:         StrnCatGrow(&RetVal, NULL, L"EfiBootServicesCode", 0);          break;\r
107   case EfiBootServicesData:         StrnCatGrow(&RetVal, NULL, L"EfiBootServicesData", 0);          break;\r
108   case EfiRuntimeServicesCode:      StrnCatGrow(&RetVal, NULL, L"EfiRuntimeServicesCode", 0);       break;\r
109   case EfiRuntimeServicesData:      StrnCatGrow(&RetVal, NULL, L"EfiRuntimeServicesData", 0);       break;\r
110   case EfiConventionalMemory:       StrnCatGrow(&RetVal, NULL, L"EfiConventionalMemory", 0);        break;\r
111   case EfiUnusableMemory:           StrnCatGrow(&RetVal, NULL, L"EfiUnusableMemory", 0);            break;\r
112   case EfiACPIReclaimMemory:        StrnCatGrow(&RetVal, NULL, L"EfiACPIReclaimMemory", 0);         break;\r
113   case EfiACPIMemoryNVS:            StrnCatGrow(&RetVal, NULL, L"EfiACPIMemoryNVS", 0);             break;\r
114   case EfiMemoryMappedIO:           StrnCatGrow(&RetVal, NULL, L"EfiMemoryMappedIO", 0);            break;\r
115   case EfiMemoryMappedIOPortSpace:  StrnCatGrow(&RetVal, NULL, L"EfiMemoryMappedIOPortSpace", 0);   break;\r
116   case EfiPalCode:                  StrnCatGrow(&RetVal, NULL, L"EfiPalCode", 0);                   break;\r
117   case EfiMaxMemoryType:            StrnCatGrow(&RetVal, NULL, L"EfiMaxMemoryType", 0);             break;\r
118   default: ASSERT(FALSE);\r
119   }\r
120   return (RetVal);\r
121 }\r
122 \r
123 /**\r
124   Function to translate the EFI_GRAPHICS_PIXEL_FORMAT into a string.\r
125 \r
126   @param[in] Fmt     The format type.\r
127 \r
128   @retval               A string representation of the type allocated from BS Pool.\r
129 **/\r
130 CHAR16*\r
131 ConvertPixelFormat (\r
132   IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt\r
133   )\r
134 {\r
135   CHAR16 *RetVal;\r
136   RetVal = NULL;\r
137 \r
138   switch (Fmt) {\r
139   case PixelRedGreenBlueReserved8BitPerColor: StrnCatGrow(&RetVal, NULL, L"PixelRedGreenBlueReserved8BitPerColor", 0);  break;\r
140   case PixelBlueGreenRedReserved8BitPerColor: StrnCatGrow(&RetVal, NULL, L"PixelBlueGreenRedReserved8BitPerColor", 0);  break;\r
141   case PixelBitMask:                          StrnCatGrow(&RetVal, NULL, L"PixelBitMask", 0);                           break;\r
142   case PixelBltOnly:                          StrnCatGrow(&RetVal, NULL, L"PixelBltOnly", 0);                           break;\r
143   case PixelFormatMax:                        StrnCatGrow(&RetVal, NULL, L"PixelFormatMax", 0);                         break;\r
144   default: ASSERT(FALSE);\r
145   }\r
146   return (RetVal);\r
147 }\r
148 \r
149 /**\r
150   Constructor for the library.\r
151 \r
152   @param[in] ImageHandle    Ignored.\r
153   @param[in] SystemTable    Ignored.\r
154 \r
155   @retval EFI_SUCCESS   The operation was successful.\r
156 **/\r
157 EFI_STATUS\r
158 EFIAPI\r
159 HandleParsingLibConstructor (\r
160   IN EFI_HANDLE        ImageHandle,\r
161   IN EFI_SYSTEM_TABLE  *SystemTable\r
162   )\r
163 {\r
164   mGuidListCount = 0;\r
165   mGuidList      = NULL;\r
166 \r
167   //\r
168   // Do nothing with mHandleParsingHiiHandle.  Initialize HII as needed.\r
169   //\r
170   return (EFI_SUCCESS);\r
171 }\r
172 \r
173 /**\r
174   Initialization function for HII packages.\r
175 \r
176 **/\r
177 VOID\r
178 HandleParsingHiiInit (VOID)\r
179 {\r
180   if (mHandleParsingHiiHandle == NULL) {\r
181     mHandleParsingHiiHandle = HiiAddPackages (&gHandleParsingHiiGuid, gImageHandle, UefiHandleParsingLibStrings, NULL);\r
182     ASSERT (mHandleParsingHiiHandle != NULL);\r
183   }\r
184 }\r
185 \r
186 /**\r
187   Destructor for the library.  free any resources.\r
188 \r
189   @param[in] ImageHandle    Ignored.\r
190   @param[in] SystemTable    Ignored.\r
191 \r
192   @retval EFI_SUCCESS   The operation was successful.\r
193 **/\r
194 EFI_STATUS\r
195 EFIAPI\r
196 HandleParsingLibDestructor (\r
197   IN EFI_HANDLE        ImageHandle,\r
198   IN EFI_SYSTEM_TABLE  *SystemTable\r
199   )\r
200 {\r
201   UINTN                 LoopCount;\r
202 \r
203   for (LoopCount = 0; mGuidList != NULL && LoopCount < mGuidListCount; LoopCount++) {\r
204     SHELL_FREE_NON_NULL(mGuidList[LoopCount].GuidId);\r
205   }\r
206 \r
207   SHELL_FREE_NON_NULL(mGuidList);\r
208   if (mHandleParsingHiiHandle != NULL) {\r
209     HiiRemovePackages(mHandleParsingHiiHandle);\r
210   }\r
211   return (EFI_SUCCESS);\r
212 }\r
213 \r
214 /**\r
215   Function to dump information about LoadedImage.\r
216 \r
217   This will allocate the return buffer from boot services pool.\r
218 \r
219   @param[in] TheHandle      The handle that has LoadedImage installed.\r
220   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
221 \r
222   @retval A poitner to a string containing the information.\r
223 **/\r
224 CHAR16*\r
225 EFIAPI\r
226 LoadedImageProtocolDumpInformation(\r
227   IN CONST EFI_HANDLE TheHandle,\r
228   IN CONST BOOLEAN    Verbose\r
229   )\r
230 {\r
231   EFI_LOADED_IMAGE_PROTOCOL         *LoadedImage;\r
232   EFI_STATUS                        Status;\r
233   CHAR16                            *RetVal;\r
234   CHAR16                            *Temp;\r
235   CHAR16                            *FileName;\r
236   CHAR8                             *PdbFileName;\r
237   CHAR16                            *FilePath;\r
238   CHAR16                            *CodeType;\r
239   CHAR16                            *DataType;\r
240 \r
241   Status = gBS->OpenProtocol (\r
242                 TheHandle,\r
243                 &gEfiLoadedImageProtocolGuid,\r
244                 (VOID**)&LoadedImage,\r
245                 gImageHandle,\r
246                 NULL,\r
247                 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
248                );\r
249 \r
250   if (EFI_ERROR (Status)) {\r
251     return NULL;\r
252   }\r
253 \r
254   FileName = FindLoadedImageFileName(LoadedImage);\r
255   FilePath = ConvertDevicePathToText(LoadedImage->FilePath, TRUE, TRUE);\r
256   if (!Verbose) {\r
257     if (FileName == NULL) {\r
258       FileName = FilePath;\r
259     } else {\r
260       SHELL_FREE_NON_NULL(FilePath);\r
261     }\r
262     return FileName;\r
263   }\r
264 \r
265   HandleParsingHiiInit();\r
266   RetVal = NULL;\r
267   if (FileName != NULL) {\r
268     Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_NAME), NULL);\r
269 \r
270     if (Temp != NULL) {\r
271       RetVal = CatSPrint(NULL, Temp, FileName);\r
272     }\r
273 \r
274     SHELL_FREE_NON_NULL(Temp);\r
275     SHELL_FREE_NON_NULL(FileName);\r
276   }\r
277 \r
278   Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_MAIN), NULL);\r
279   if (Temp == NULL) {\r
280     return NULL;\r
281   }\r
282   PdbFileName = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);\r
283   DataType = ConvertMemoryType(LoadedImage->ImageDataType);\r
284   CodeType = ConvertMemoryType(LoadedImage->ImageCodeType);\r
285 \r
286   RetVal = CatSPrint(\r
287              RetVal,\r
288              Temp,\r
289              LoadedImage->Revision,\r
290              LoadedImage->ParentHandle,\r
291              LoadedImage->SystemTable,\r
292              LoadedImage->DeviceHandle,\r
293              FilePath,\r
294              PdbFileName,\r
295              LoadedImage->LoadOptionsSize,\r
296              LoadedImage->LoadOptions,\r
297              LoadedImage->ImageBase,\r
298              LoadedImage->ImageSize,\r
299              CodeType,\r
300              DataType,\r
301              LoadedImage->Unload\r
302              );\r
303 \r
304 \r
305   SHELL_FREE_NON_NULL(Temp);\r
306   SHELL_FREE_NON_NULL(FilePath);\r
307   SHELL_FREE_NON_NULL(CodeType);\r
308   SHELL_FREE_NON_NULL(DataType);\r
309 \r
310   return RetVal;\r
311 }\r
312 \r
313 /**\r
314   Function to dump information about GOP.\r
315 \r
316   This will allocate the return buffer from boot services pool.\r
317 \r
318   @param[in] TheHandle      The handle that has LoadedImage installed.\r
319   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
320 \r
321   @retval A poitner to a string containing the information.\r
322 **/\r
323 CHAR16*\r
324 EFIAPI\r
325 GraphicsOutputProtocolDumpInformation(\r
326   IN CONST EFI_HANDLE TheHandle,\r
327   IN CONST BOOLEAN    Verbose\r
328   )\r
329 {\r
330   EFI_GRAPHICS_OUTPUT_PROTOCOL          *GraphicsOutput;\r
331   EFI_STATUS                            Status;\r
332   CHAR16                                *RetVal;\r
333   CHAR16                                *Temp;\r
334   CHAR16                                *Fmt;\r
335   CHAR16                                *TempRetVal;\r
336   UINTN                                 GopInfoSize;\r
337   UINT32                                Mode;\r
338   EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *GopInfo;\r
339 \r
340   if (!Verbose) {\r
341     return (CatSPrint(NULL, L"GraphicsOutput"));\r
342   }\r
343 \r
344   HandleParsingHiiInit();\r
345 \r
346   Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_GOP_DUMP_MAIN), NULL);\r
347   if (Temp == NULL) {\r
348     return NULL;\r
349   }\r
350 \r
351   Status = gBS->OpenProtocol (\r
352                 TheHandle,\r
353                 &gEfiGraphicsOutputProtocolGuid,\r
354                 (VOID**)&GraphicsOutput,\r
355                 gImageHandle,\r
356                 NULL,\r
357                 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
358                );\r
359 \r
360   if (EFI_ERROR (Status)) {\r
361     SHELL_FREE_NON_NULL (Temp);\r
362     return NULL;\r
363   }\r
364 \r
365   Fmt = ConvertPixelFormat(GraphicsOutput->Mode->Info->PixelFormat);\r
366 \r
367   RetVal = CatSPrint(\r
368              NULL,\r
369              Temp,\r
370              GraphicsOutput->Mode->MaxMode,\r
371              GraphicsOutput->Mode->Mode,\r
372              GraphicsOutput->Mode->FrameBufferBase,\r
373              (UINT64)GraphicsOutput->Mode->FrameBufferSize,\r
374              (UINT64)GraphicsOutput->Mode->SizeOfInfo,\r
375              GraphicsOutput->Mode->Info->Version,\r
376              GraphicsOutput->Mode->Info->HorizontalResolution,\r
377              GraphicsOutput->Mode->Info->VerticalResolution,\r
378              Fmt,\r
379              GraphicsOutput->Mode->Info->PixelsPerScanLine,\r
380              GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.RedMask,\r
381              GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.GreenMask,\r
382              GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.BlueMask\r
383              );\r
384 \r
385   SHELL_FREE_NON_NULL (Temp);\r
386 \r
387   Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_GOP_RES_LIST_MAIN), NULL);\r
388   if (Temp == NULL) {\r
389     SHELL_FREE_NON_NULL (RetVal);\r
390     goto EXIT;\r
391   }\r
392 \r
393   TempRetVal = CatSPrint (RetVal, Temp);\r
394   SHELL_FREE_NON_NULL (RetVal);\r
395   if (TempRetVal == NULL) {\r
396     goto EXIT;\r
397   }\r
398   RetVal = TempRetVal;\r
399   SHELL_FREE_NON_NULL (Temp);\r
400 \r
401   Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_GOP_RES_LIST_ENTRY), NULL);\r
402   if (Temp == NULL) {\r
403     SHELL_FREE_NON_NULL (RetVal);\r
404     goto EXIT;\r
405   }\r
406 \r
407 \r
408   for (Mode = 0; Mode < GraphicsOutput->Mode->MaxMode; Mode++) {\r
409     Status = GraphicsOutput->QueryMode (\r
410                                GraphicsOutput,\r
411                                Mode,\r
412                                &GopInfoSize,\r
413                                &GopInfo\r
414                                );\r
415     if (EFI_ERROR (Status)) {\r
416       continue;\r
417     }\r
418 \r
419     TempRetVal = CatSPrint (\r
420                    RetVal,\r
421                    Temp,\r
422                    Mode,\r
423                    GopInfo->HorizontalResolution,\r
424                    GopInfo->VerticalResolution\r
425                    );\r
426 \r
427     SHELL_FREE_NON_NULL (GopInfo);\r
428     SHELL_FREE_NON_NULL (RetVal);\r
429     RetVal = TempRetVal;\r
430   }\r
431 \r
432 \r
433 EXIT:\r
434   SHELL_FREE_NON_NULL(Temp);\r
435   SHELL_FREE_NON_NULL(Fmt);\r
436 \r
437   return RetVal;\r
438 }\r
439 \r
440 /**\r
441   Function to dump information about EDID Discovered Protocol.\r
442 \r
443   This will allocate the return buffer from boot services pool.\r
444 \r
445   @param[in] TheHandle      The handle that has LoadedImage installed.\r
446   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
447 \r
448   @retval A pointer to a string containing the information.\r
449 **/\r
450 CHAR16*\r
451 EFIAPI\r
452 EdidDiscoveredProtocolDumpInformation (\r
453   IN CONST EFI_HANDLE TheHandle,\r
454   IN CONST BOOLEAN    Verbose\r
455   )\r
456 {\r
457   EFI_EDID_DISCOVERED_PROTOCOL          *EdidDiscovered;\r
458   EFI_STATUS                            Status;\r
459   CHAR16                                *RetVal;\r
460   CHAR16                                *Temp;\r
461   CHAR16                                *TempRetVal;\r
462 \r
463   if (!Verbose) {\r
464     return (CatSPrint (NULL, L"EDIDDiscovered"));\r
465   }\r
466 \r
467   Status = gBS->OpenProtocol (\r
468                   TheHandle,\r
469                   &gEfiEdidDiscoveredProtocolGuid,\r
470                   (VOID**)&EdidDiscovered,\r
471                   NULL,\r
472                   NULL,\r
473                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
474                   );\r
475 \r
476   if (EFI_ERROR (Status)) {\r
477     return NULL;\r
478   }\r
479 \r
480   Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_EDID_DISCOVERED_MAIN), NULL);\r
481   if (Temp == NULL) {\r
482     return NULL;\r
483   }\r
484 \r
485   RetVal = CatSPrint (NULL, Temp, EdidDiscovered->SizeOfEdid);\r
486   SHELL_FREE_NON_NULL (Temp);\r
487 \r
488   if (EdidDiscovered->SizeOfEdid != 0) {\r
489     Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_EDID_DISCOVERED_DATA), NULL);\r
490     if (Temp == NULL) {\r
491       SHELL_FREE_NON_NULL (RetVal);\r
492       return NULL;\r
493     }\r
494     TempRetVal = CatSPrint (RetVal, Temp);\r
495     SHELL_FREE_NON_NULL (RetVal);\r
496     RetVal = TempRetVal;\r
497 \r
498     TempRetVal = CatSDumpHex (RetVal, 4, 0, EdidDiscovered->SizeOfEdid, EdidDiscovered->Edid);\r
499     RetVal = TempRetVal;\r
500   }\r
501   return RetVal;\r
502 }\r
503 \r
504 /**\r
505   Function to dump information about EDID Active Protocol.\r
506 \r
507   This will allocate the return buffer from boot services pool.\r
508 \r
509   @param[in] TheHandle      The handle that has LoadedImage installed.\r
510   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
511 \r
512   @retval A pointer to a string containing the information.\r
513 **/\r
514 CHAR16*\r
515 EFIAPI\r
516 EdidActiveProtocolDumpInformation (\r
517   IN CONST EFI_HANDLE TheHandle,\r
518   IN CONST BOOLEAN    Verbose\r
519   )\r
520 {\r
521   EFI_EDID_ACTIVE_PROTOCOL  *EdidActive;\r
522   EFI_STATUS                Status;\r
523   CHAR16                    *RetVal;\r
524   CHAR16                    *Temp;\r
525   CHAR16                    *TempRetVal;\r
526 \r
527   if (!Verbose) {\r
528     return (CatSPrint (NULL, L"EDIDActive"));\r
529   }\r
530 \r
531   Status = gBS->OpenProtocol (\r
532                   TheHandle,\r
533                   &gEfiEdidActiveProtocolGuid,\r
534                   (VOID**)&EdidActive,\r
535                   NULL,\r
536                   NULL,\r
537                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
538                   );\r
539 \r
540   if (EFI_ERROR (Status)) {\r
541     return NULL;\r
542   }\r
543 \r
544   Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_EDID_ACTIVE_MAIN), NULL);\r
545   if (Temp == NULL) {\r
546     return NULL;\r
547   }\r
548 \r
549   RetVal = CatSPrint (NULL, Temp, EdidActive->SizeOfEdid);\r
550   SHELL_FREE_NON_NULL (Temp);\r
551 \r
552   if (EdidActive->SizeOfEdid != 0) {\r
553     Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_EDID_ACTIVE_DATA), NULL);\r
554     if (Temp == NULL) {\r
555       SHELL_FREE_NON_NULL (RetVal);\r
556       return NULL;\r
557     }\r
558     TempRetVal = CatSPrint (RetVal, Temp);\r
559     SHELL_FREE_NON_NULL (RetVal);\r
560     RetVal = TempRetVal;\r
561 \r
562     TempRetVal = CatSDumpHex (RetVal, 4, 0, EdidActive->SizeOfEdid, EdidActive->Edid);\r
563     RetVal = TempRetVal;\r
564   }\r
565   return RetVal;\r
566 }\r
567 \r
568 /**\r
569   Function to dump information about PciRootBridgeIo.\r
570 \r
571   This will allocate the return buffer from boot services pool.\r
572 \r
573   @param[in] TheHandle      The handle that has PciRootBridgeIo installed.\r
574   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
575 \r
576   @retval A poitner to a string containing the information.\r
577 **/\r
578 CHAR16*\r
579 EFIAPI\r
580 PciRootBridgeIoDumpInformation(\r
581   IN CONST EFI_HANDLE TheHandle,\r
582   IN CONST BOOLEAN    Verbose\r
583   )\r
584 {\r
585   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL   *PciRootBridgeIo;\r
586   EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Configuration;\r
587   UINT64                            Supports;\r
588   UINT64                            Attributes;\r
589   CHAR16                            *Temp;\r
590   CHAR16                            *Temp2;\r
591   CHAR16                            *RetVal;\r
592   EFI_STATUS                        Status;\r
593 \r
594   RetVal  = NULL;\r
595 \r
596   if (!Verbose) {\r
597     return (CatSPrint(NULL, L"PciRootBridgeIo"));\r
598   }\r
599 \r
600   HandleParsingHiiInit();\r
601 \r
602   Status = gBS->HandleProtocol(\r
603     TheHandle,\r
604     &gEfiPciRootBridgeIoProtocolGuid,\r
605     (VOID**)&PciRootBridgeIo);\r
606 \r
607   if (EFI_ERROR(Status)) {\r
608     return NULL;\r
609   }\r
610 \r
611   Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_PH), NULL);\r
612   if (Temp == NULL) {\r
613     return NULL;\r
614   }\r
615   Temp2 = CatSPrint(NULL, Temp, PciRootBridgeIo->ParentHandle);\r
616   FreePool(Temp);\r
617   RetVal = Temp2;\r
618   Temp2 = NULL;\r
619 \r
620   Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_SEG), NULL);\r
621   if (Temp == NULL) {\r
622     SHELL_FREE_NON_NULL(RetVal);\r
623     return NULL;\r
624   }\r
625   Temp2 = CatSPrint(RetVal, Temp, PciRootBridgeIo->SegmentNumber);\r
626   FreePool(Temp);\r
627   FreePool(RetVal);\r
628   RetVal = Temp2;\r
629   Temp2 = NULL;\r
630 \r
631   Supports   = 0;\r
632   Attributes = 0;\r
633   Status = PciRootBridgeIo->GetAttributes (PciRootBridgeIo, &Supports, &Attributes);\r
634   if (!EFI_ERROR(Status)) {\r
635     Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_ATT), NULL);\r
636     if (Temp == NULL) {\r
637       SHELL_FREE_NON_NULL(RetVal);\r
638       return NULL;\r
639     }\r
640     Temp2 = CatSPrint(RetVal, Temp, Attributes);\r
641     FreePool(Temp);\r
642     FreePool(RetVal);\r
643     RetVal = Temp2;\r
644     Temp2 = NULL;\r
645 \r
646     Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_SUPPORTS), NULL);\r
647     if (Temp == NULL) {\r
648       SHELL_FREE_NON_NULL(RetVal);\r
649       return NULL;\r
650     }\r
651     Temp2 = CatSPrint(RetVal, Temp, Supports);\r
652     FreePool(Temp);\r
653     FreePool(RetVal);\r
654     RetVal = Temp2;\r
655     Temp2 = NULL;\r
656   }\r
657 \r
658   Configuration   = NULL;\r
659   Status = PciRootBridgeIo->Configuration (PciRootBridgeIo, (VOID **) &Configuration);\r
660   if (!EFI_ERROR(Status) && Configuration != NULL) {\r
661     Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_TITLE), NULL);\r
662     if (Temp == NULL) {\r
663       SHELL_FREE_NON_NULL(RetVal);\r
664       return NULL;\r
665     }\r
666     Temp2 = CatSPrint(RetVal, Temp, Supports);\r
667     FreePool(Temp);\r
668     FreePool(RetVal);\r
669     RetVal = Temp2;\r
670     Temp2 = NULL;\r
671     while (Configuration->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {\r
672       Temp = NULL;\r
673       switch (Configuration->ResType) {\r
674       case ACPI_ADDRESS_SPACE_TYPE_MEM:\r
675         Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_MEM), NULL);\r
676         break;\r
677       case ACPI_ADDRESS_SPACE_TYPE_IO:\r
678         Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_IO), NULL);\r
679         break;\r
680       case ACPI_ADDRESS_SPACE_TYPE_BUS:\r
681         Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIRB_DUMP_BUS), NULL);\r
682         break;\r
683       }\r
684       if (Temp != NULL) {\r
685         Temp2 = CatSPrint(RetVal, L"\r\n%s", Temp);\r
686         FreePool(Temp);\r
687         FreePool(RetVal);\r
688         RetVal = Temp2;\r
689         Temp2 = NULL;\r
690       }\r
691 \r
692       Temp2 = CatSPrint(RetVal,\r
693         L"%%H%02x    %016lx  %016lx  %02x%%N",\r
694         Configuration->SpecificFlag,\r
695         Configuration->AddrRangeMin,\r
696         Configuration->AddrRangeMax,\r
697         Configuration->AddrSpaceGranularity\r
698         );\r
699       FreePool(RetVal);\r
700       RetVal = Temp2;\r
701       Temp2 = NULL;\r
702       Configuration++;\r
703     }\r
704   }\r
705   return (RetVal);\r
706 }\r
707 \r
708 /**\r
709   Function to dump information about SimpleTextOut.\r
710 \r
711   This will allocate the return buffer from boot services pool.\r
712 \r
713   @param[in] TheHandle      The handle that has SimpleTextOut installed.\r
714   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
715 \r
716   @retval A poitner to a string containing the information.\r
717 **/\r
718 CHAR16*\r
719 EFIAPI\r
720 TxtOutProtocolDumpInformation(\r
721   IN CONST EFI_HANDLE TheHandle,\r
722   IN CONST BOOLEAN    Verbose\r
723   )\r
724 {\r
725   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Dev;\r
726   INTN                            Index;\r
727   UINTN                           Col;\r
728   UINTN                           Row;\r
729   EFI_STATUS                      Status;\r
730   CHAR16                          *RetVal;\r
731   UINTN                           Size;\r
732   CHAR16                          *Temp;\r
733   UINTN                           NewSize;\r
734 \r
735   if (!Verbose) {\r
736     return (NULL);\r
737   }\r
738 \r
739   HandleParsingHiiInit();\r
740 \r
741   RetVal  = NULL;\r
742   Size    = 0;\r
743 \r
744   Status = gBS->HandleProtocol(\r
745     TheHandle,\r
746     &gEfiSimpleTextOutProtocolGuid,\r
747     (VOID**)&Dev);\r
748 \r
749   ASSERT_EFI_ERROR(Status);\r
750   ASSERT (Dev != NULL && Dev->Mode != NULL);\r
751 \r
752   Size = (Dev->Mode->MaxMode + 1) * 80;\r
753   RetVal = AllocateZeroPool(Size);\r
754 \r
755   Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_TXT_OUT_DUMP_HEADER), NULL);\r
756   if (Temp != NULL) {\r
757     UnicodeSPrint(RetVal, Size, Temp, Dev, Dev->Mode->Attribute);\r
758     FreePool(Temp);\r
759   }\r
760 \r
761   //\r
762   // Dump TextOut Info\r
763   //\r
764   Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_TXT_OUT_DUMP_LINE), NULL);\r
765   for (Index = 0; Index < Dev->Mode->MaxMode; Index++) {\r
766     Status = Dev->QueryMode (Dev, Index, &Col, &Row);\r
767     NewSize = Size - StrSize(RetVal);\r
768     UnicodeSPrint(\r
769       RetVal + StrLen(RetVal),\r
770       NewSize,\r
771       Temp == NULL?L"":Temp,\r
772       Index == Dev->Mode->Mode ? L'*' : L' ',\r
773       Index,\r
774       !EFI_ERROR(Status)?(INTN)Col:-1,\r
775       !EFI_ERROR(Status)?(INTN)Row:-1\r
776      );\r
777   }\r
778   FreePool(Temp);\r
779   return (RetVal);\r
780 }\r
781 \r
782 STATIC CONST UINTN VersionStringSize = 60;\r
783 \r
784 /**\r
785   Function to dump information about EfiDriverSupportedEfiVersion protocol.\r
786 \r
787   This will allocate the return buffer from boot services pool.\r
788 \r
789   @param[in] TheHandle      The handle that has the protocol installed.\r
790   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
791 \r
792   @retval A poitner to a string containing the information.\r
793 **/\r
794 CHAR16*\r
795 EFIAPI\r
796 DriverEfiVersionProtocolDumpInformation(\r
797   IN CONST EFI_HANDLE TheHandle,\r
798   IN CONST BOOLEAN    Verbose\r
799   )\r
800 {\r
801   EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL *DriverEfiVersion;\r
802   EFI_STATUS                                Status;\r
803   CHAR16                                    *RetVal;\r
804 \r
805   Status = gBS->HandleProtocol(\r
806     TheHandle,\r
807     &gEfiDriverSupportedEfiVersionProtocolGuid,\r
808     (VOID**)&DriverEfiVersion);\r
809 \r
810   ASSERT_EFI_ERROR(Status);\r
811 \r
812   RetVal = AllocateZeroPool(VersionStringSize);\r
813   if (RetVal != NULL) {\r
814     UnicodeSPrint (RetVal, VersionStringSize, L"0x%08x", DriverEfiVersion->FirmwareVersion);\r
815   }\r
816   return (RetVal);\r
817 }\r
818 /**\r
819   Function to convert device path to string.\r
820 \r
821   This will allocate the return buffer from boot services pool.\r
822 \r
823   @param[in] DevPath        Pointer to device path instance.\r
824   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
825   @param[in] Length         Maximum allowed text length of the device path.\r
826 \r
827   @retval A pointer to a string containing the information.\r
828 **/\r
829 CHAR16*\r
830 ConvertDevicePathToShortText(\r
831   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath,\r
832   IN CONST BOOLEAN                  Verbose,\r
833   IN CONST UINTN                    Length\r
834   )\r
835 {\r
836   CHAR16                            *Temp;\r
837   CHAR16                            *Temp2;\r
838   UINTN                             Size;\r
839 \r
840   //\r
841   // I cannot decide whether to allow shortcuts here (the second BOOLEAN on the next line)\r
842   //\r
843   Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);\r
844   if (!Verbose && Temp != NULL && StrLen(Temp) > Length) {\r
845     Temp2 = NULL;\r
846     Size  = 0;\r
847     Temp2 = StrnCatGrow(&Temp2, &Size, L"..", 0);\r
848     Temp2 = StrnCatGrow(&Temp2, &Size, Temp+(StrLen(Temp) - (Length - 2)), 0);\r
849     FreePool(Temp);\r
850     Temp = Temp2;\r
851   }\r
852   return (Temp);\r
853 }\r
854 \r
855 /**\r
856   Function to dump protocol information.\r
857 \r
858   This will allocate the return buffer from boot services pool.\r
859 \r
860   @param[in] TheHandle      The handle that has the protocol installed.\r
861   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
862   @param[in] Protocol       The protocol is needed to dump.\r
863 \r
864   @retval A pointer to a string containing the information.\r
865 **/\r
866 STATIC CHAR16*\r
867 EFIAPI\r
868 DevicePathProtocolDumpInformationEx (\r
869   IN CONST EFI_HANDLE   TheHandle,\r
870   IN CONST BOOLEAN      Verbose,\r
871   IN       EFI_GUID     *Protocol\r
872 )\r
873 {\r
874   EFI_DEVICE_PATH_PROTOCOL          *DevPath;\r
875   CHAR16                            *DevPathStr;\r
876   CHAR16                            *DevPathStrTemp;\r
877   UINTN                             Size;\r
878   EFI_STATUS                        Status;\r
879   DevPathStr     = NULL;\r
880   DevPathStrTemp = NULL;\r
881   Status = gBS->OpenProtocol(TheHandle, Protocol, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
882   if (!EFI_ERROR(Status)) {\r
883     DevPathStr = ConvertDevicePathToShortText (DevPath, Verbose, 30);\r
884     if (Verbose) {\r
885       Size = StrSize(DevPathStr) + sizeof(CHAR16) * 2;\r
886       DevPathStrTemp = AllocateZeroPool (Size);\r
887       if (DevPathStrTemp != NULL) {\r
888         StrnCatS (DevPathStrTemp, Size/sizeof(CHAR16), L"  ", 2);\r
889         StrnCatS (DevPathStrTemp, Size/sizeof(CHAR16), DevPathStr, StrLen (DevPathStr));\r
890       }\r
891       FreePool (DevPathStr);\r
892       DevPathStr = DevPathStrTemp;\r
893     }\r
894     gBS->CloseProtocol(TheHandle, Protocol, gImageHandle, NULL);\r
895   }\r
896   return DevPathStr;\r
897 }\r
898 \r
899 /**\r
900   Function to dump information about DevicePath protocol.\r
901 \r
902   This will allocate the return buffer from boot services pool.\r
903 \r
904   @param[in] TheHandle      The handle that has the protocol installed.\r
905   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
906 \r
907   @retval A pointer to a string containing the information.\r
908 **/\r
909 CHAR16*\r
910 EFIAPI\r
911 DevicePathProtocolDumpInformation(\r
912   IN CONST EFI_HANDLE TheHandle,\r
913   IN CONST BOOLEAN    Verbose\r
914   )\r
915 {\r
916   return DevicePathProtocolDumpInformationEx (TheHandle, Verbose, &gEfiDevicePathProtocolGuid);\r
917 }\r
918 \r
919 /**\r
920   Function to dump information about LoadedImageDevicePath protocol.\r
921 \r
922   This will allocate the return buffer from boot services pool.\r
923 \r
924   @param[in] TheHandle      The handle that has the protocol installed.\r
925   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
926 \r
927   @retval A pointer to a string containing the information.\r
928 **/\r
929 CHAR16*\r
930 EFIAPI\r
931 LoadedImageDevicePathProtocolDumpInformation(\r
932   IN CONST EFI_HANDLE TheHandle,\r
933   IN CONST BOOLEAN    Verbose\r
934   )\r
935 {\r
936   return DevicePathProtocolDumpInformationEx (TheHandle, Verbose, &gEfiLoadedImageDevicePathProtocolGuid);\r
937 }\r
938 \r
939 /**\r
940   Function to dump information about BusSpecificDriverOverride protocol.\r
941 \r
942   This will allocate the return buffer from boot services pool.\r
943 \r
944   @param[in] TheHandle      The handle that has the protocol installed.\r
945   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
946 \r
947   @retval A pointer to a string containing the information.\r
948 **/\r
949 CHAR16*\r
950 EFIAPI\r
951 BusSpecificDriverOverrideProtocolDumpInformation (\r
952   IN CONST EFI_HANDLE TheHandle,\r
953   IN CONST BOOLEAN    Verbose\r
954   )\r
955 {\r
956   EFI_STATUS                                Status;\r
957   CHAR16                                    *GetString;\r
958   CHAR16                                    *RetVal;\r
959   CHAR16                                    *TempRetVal;\r
960   EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;\r
961   EFI_LOADED_IMAGE_PROTOCOL                 *LoadedImage;\r
962   EFI_HANDLE                                ImageHandle;\r
963   UINTN                                     Size;\r
964 \r
965   if (!Verbose) {\r
966     return NULL;\r
967   }\r
968   Size        = 0;\r
969   GetString   = NULL;\r
970   RetVal      = NULL;\r
971   TempRetVal  = NULL;\r
972   ImageHandle = 0;\r
973 \r
974   Status = gBS->OpenProtocol (\r
975                   TheHandle,\r
976                   &gEfiBusSpecificDriverOverrideProtocolGuid,\r
977                   (VOID**)&BusSpecificDriverOverride,\r
978                   gImageHandle,\r
979                   NULL,\r
980                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
981                   );\r
982   if (EFI_ERROR (Status)) {\r
983     return NULL;\r
984   }\r
985   HandleParsingHiiInit ();\r
986   GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_BSDO_DUMP_MAIN), NULL);\r
987   if (GetString == NULL) {\r
988     return NULL;\r
989   }\r
990   do {\r
991     Status = BusSpecificDriverOverride->GetDriver (\r
992                                           BusSpecificDriverOverride,\r
993                                           &ImageHandle\r
994                                           );\r
995     if (!EFI_ERROR (Status)) {\r
996       Status = gBS->HandleProtocol (\r
997                       ImageHandle,\r
998                       &gEfiLoadedImageProtocolGuid,\r
999                       (VOID **) &LoadedImage\r
1000                       );\r
1001       if(!EFI_ERROR (Status)) {\r
1002         TempRetVal = CatSPrint (\r
1003                        TempRetVal,\r
1004                        GetString,\r
1005                        ConvertHandleToHandleIndex (ImageHandle),\r
1006                        ConvertDevicePathToText (LoadedImage->FilePath, TRUE, TRUE)\r
1007                        );\r
1008         StrnCatGrow (&RetVal, &Size, TempRetVal, 0);\r
1009         SHELL_FREE_NON_NULL (TempRetVal);\r
1010       }\r
1011     }\r
1012   } while (!EFI_ERROR (Status));\r
1013 \r
1014   SHELL_FREE_NON_NULL (GetString);\r
1015   return RetVal;\r
1016 }\r
1017 \r
1018 /**\r
1019   Function to dump information about BlockIo protocol.\r
1020 \r
1021   This will allocate the return buffer from boot services pool.\r
1022 \r
1023   @param[in] TheHandle      The handle that has the protocol installed.\r
1024   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
1025 \r
1026   @retval A pointer to a string containing the information.\r
1027 **/\r
1028 CHAR16*\r
1029 EFIAPI\r
1030 BlockIoProtocolDumpInformation (\r
1031   IN CONST EFI_HANDLE TheHandle,\r
1032   IN CONST BOOLEAN    Verbose\r
1033   )\r
1034 {\r
1035   EFI_STATUS            Status;\r
1036   EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
1037   EFI_BLOCK_IO_MEDIA    *BlockMedia;\r
1038   CHAR16                *GetString;\r
1039   CHAR16                *RetVal;\r
1040 \r
1041   if (!Verbose) {\r
1042     return NULL;\r
1043   }\r
1044   GetString   = NULL;\r
1045   RetVal = NULL;\r
1046 \r
1047   Status = gBS->OpenProtocol (\r
1048                 TheHandle,\r
1049                 &gEfiBlockIoProtocolGuid,\r
1050                 (VOID**)&BlockIo,\r
1051                 gImageHandle,\r
1052                 NULL,\r
1053                 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
1054                 );\r
1055   if (EFI_ERROR (Status)) {\r
1056     return NULL;\r
1057   }\r
1058   BlockMedia = BlockIo->Media;\r
1059   //\r
1060   // Per spec:\r
1061   //   The function (ReadBlocks) must return EFI_NO_MEDIA or\r
1062   //   EFI_MEDIA_CHANGED even if LBA, BufferSize, or Buffer are invalid so the caller can probe\r
1063   //   for changes in media state.\r
1064   //\r
1065   BlockIo->ReadBlocks (\r
1066              BlockIo,\r
1067              BlockIo->Media->MediaId,\r
1068              0,\r
1069              0,\r
1070              NULL\r
1071              );\r
1072 \r
1073   HandleParsingHiiInit ();\r
1074   GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_BLOCKIO_INFO), NULL);\r
1075   if (GetString == NULL) {\r
1076     return NULL;\r
1077   }\r
1078   RetVal = CatSPrint (\r
1079             RetVal,\r
1080             GetString,\r
1081             BlockMedia->RemovableMedia ? L"Removable " : L"Fixed ",\r
1082             BlockMedia->MediaPresent ? L"" : L"not-present ",\r
1083             BlockMedia->MediaId,\r
1084             BlockMedia->BlockSize,\r
1085             BlockMedia->LastBlock,\r
1086             MultU64x32 (BlockMedia->LastBlock + 1, BlockMedia->BlockSize),\r
1087             BlockMedia->LogicalPartition ? L"partition" : L"raw",\r
1088             BlockMedia->ReadOnly ? L"ro" : L"rw",\r
1089             BlockMedia->WriteCaching ? L"cached" : L"!cached"\r
1090             );\r
1091 \r
1092   SHELL_FREE_NON_NULL (GetString);\r
1093   return RetVal;\r
1094 }\r
1095 \r
1096 /**\r
1097   Function to dump information about DebugSupport Protocol.\r
1098 \r
1099   @param[in] TheHandle      The handle that has the protocol installed.\r
1100   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
1101 \r
1102   @retval A pointer to a string containing the information.\r
1103 **/\r
1104 CHAR16*\r
1105 EFIAPI\r
1106 DebugSupportProtocolDumpInformation (\r
1107   IN CONST EFI_HANDLE TheHandle,\r
1108   IN CONST BOOLEAN    Verbose\r
1109   )\r
1110 {\r
1111   EFI_STATUS                  Status;\r
1112   EFI_DEBUG_SUPPORT_PROTOCOL  *DebugSupport;\r
1113   CHAR16                      *GetString;\r
1114   CHAR16                      *RetVal;\r
1115 \r
1116   if (!Verbose) {\r
1117     return NULL;\r
1118   }\r
1119   GetString = NULL;\r
1120   RetVal = NULL;\r
1121   Status = gBS->OpenProtocol (\r
1122                 TheHandle,\r
1123                 &gEfiDebugSupportProtocolGuid,\r
1124                 (VOID**)&DebugSupport,\r
1125                 gImageHandle,\r
1126                 NULL,\r
1127                 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
1128                 );\r
1129   if (EFI_ERROR (Status)) {\r
1130     return NULL;\r
1131   }\r
1132   HandleParsingHiiInit ();\r
1133   GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_DEBUGSUPPORT_INFO), NULL);\r
1134   if (GetString == NULL) {\r
1135     return NULL;\r
1136   }\r
1137   //\r
1138   // Dump Debug support info\r
1139   //\r
1140   switch (DebugSupport->Isa) {\r
1141   case (IsaIa32):\r
1142     RetVal = CatSPrint (RetVal, GetString, L"IA-32");\r
1143     break;\r
1144   case (IsaIpf):\r
1145     RetVal = CatSPrint (RetVal, GetString, L"IPF");\r
1146     break;\r
1147   case (IsaEbc):\r
1148     RetVal = CatSPrint (RetVal, GetString, L"EBC");\r
1149     break;\r
1150   default:\r
1151     SHELL_FREE_NON_NULL (GetString);\r
1152     GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_DEBUGSUPPORT_UNKNOWN), NULL);\r
1153     RetVal = GetString != NULL ? CatSPrint (RetVal, GetString, DebugSupport->Isa) : NULL;\r
1154     break;\r
1155   }\r
1156 \r
1157   SHELL_FREE_NON_NULL (GetString);\r
1158   return RetVal;\r
1159 }\r
1160 \r
1161 /**\r
1162   Function to dump information about PciIoProtocol.\r
1163 \r
1164   This will allocate the return buffer from boot services pool.\r
1165 \r
1166   @param[in] TheHandle      The handle that has PciRootBridgeIo installed.\r
1167   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
1168 \r
1169   @retval A poitner to a string containing the information.\r
1170 **/\r
1171 CHAR16*\r
1172 EFIAPI\r
1173 PciIoProtocolDumpInformation (\r
1174   IN CONST EFI_HANDLE TheHandle,\r
1175   IN CONST BOOLEAN    Verbose\r
1176   )\r
1177 {\r
1178   EFI_STATUS              Status;\r
1179   EFI_PCI_IO_PROTOCOL     *PciIo;\r
1180   PCI_TYPE00              Pci;\r
1181   UINTN                   Segment;\r
1182   UINTN                   Bus;\r
1183   UINTN                   Device;\r
1184   UINTN                   Function;\r
1185   UINTN                   Index;\r
1186   CHAR16                  *GetString;\r
1187   CHAR16                  *TempRetVal;\r
1188   CHAR16                  *RetVal;\r
1189 \r
1190   if (!Verbose) {\r
1191     return (NULL);\r
1192   }\r
1193   RetVal = NULL;\r
1194   GetString   = NULL;\r
1195   TempRetVal  = NULL;\r
1196   Status = gBS->OpenProtocol (\r
1197                   TheHandle,\r
1198                   &gEfiPciIoProtocolGuid,\r
1199                   (VOID**)&PciIo,\r
1200                   gImageHandle,\r
1201                   NULL,\r
1202                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
1203                   );\r
1204 \r
1205   if (EFI_ERROR(Status)) {\r
1206     return NULL;\r
1207   }\r
1208   PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0, sizeof (Pci), &Pci);\r
1209   PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);\r
1210   HandleParsingHiiInit ();\r
1211   GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIIO_DUMP_MAIN), NULL);\r
1212   if (GetString == NULL) {\r
1213     return NULL;\r
1214   }\r
1215   RetVal = CatSPrint (\r
1216             NULL,\r
1217             GetString,\r
1218             Segment,\r
1219             Bus,\r
1220             Device,\r
1221             Function,\r
1222             PciIo->RomSize,\r
1223             PciIo->RomImage,\r
1224             Pci.Hdr.VendorId,\r
1225             Pci.Hdr.DeviceId,\r
1226             Pci.Hdr.ClassCode[0],\r
1227             Pci.Hdr.ClassCode[1],\r
1228             Pci.Hdr.ClassCode[2]\r
1229             );\r
1230   for (Index = 0; Index < sizeof (Pci); Index ++) {\r
1231     if ((Index % 0x10) == 0) {\r
1232       TempRetVal = CatSPrint (RetVal, L"\r\n       %02x", *((UINT8 *) (&Pci) + Index));\r
1233     } else {\r
1234       TempRetVal = CatSPrint (RetVal, L"%02x", *((UINT8 *) (&Pci) + Index));\r
1235     }\r
1236     FreePool (RetVal);\r
1237     RetVal = TempRetVal;\r
1238     TempRetVal = NULL;\r
1239   }\r
1240 \r
1241   FreePool(GetString);\r
1242   return RetVal;\r
1243 }\r
1244 \r
1245 /**\r
1246   Function to dump information about UsbIoProtocol.\r
1247 \r
1248   This will allocate the return buffer from boot services pool.\r
1249 \r
1250   @param[in] TheHandle      The handle that has PciRootBridgeIo installed.\r
1251   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
1252 \r
1253   @retval A poitner to a string containing the information.\r
1254 **/\r
1255 CHAR16*\r
1256 EFIAPI\r
1257 UsbIoProtocolDumpInformation (\r
1258   IN CONST EFI_HANDLE TheHandle,\r
1259   IN CONST BOOLEAN    Verbose\r
1260   )\r
1261 {\r
1262   EFI_STATUS                    Status;\r
1263   EFI_USB_IO_PROTOCOL           *UsbIo;\r
1264   EFI_USB_INTERFACE_DESCRIPTOR  InterfaceDesc;\r
1265   CHAR16                        *GetString;\r
1266   CHAR16                        *RetVal;\r
1267 \r
1268   if (!Verbose) {\r
1269     return (NULL);\r
1270   }\r
1271   RetVal = NULL;\r
1272   GetString = NULL;\r
1273   Status = gBS->OpenProtocol (\r
1274                   TheHandle,\r
1275                   &gEfiUsbIoProtocolGuid,\r
1276                   (VOID**)&UsbIo,\r
1277                   gImageHandle,\r
1278                   NULL,\r
1279                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
1280                   );\r
1281 \r
1282   if (EFI_ERROR(Status)) {\r
1283     return NULL;\r
1284   }\r
1285   UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDesc);\r
1286   HandleParsingHiiInit ();\r
1287   GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_USBIO_DUMP_MAIN), NULL);\r
1288   if (GetString == NULL) {\r
1289     return NULL;\r
1290   }\r
1291   RetVal = CatSPrint (\r
1292             NULL,\r
1293             GetString,\r
1294             InterfaceDesc.InterfaceNumber,\r
1295             InterfaceDesc.InterfaceClass,\r
1296             InterfaceDesc.InterfaceSubClass,\r
1297             InterfaceDesc.InterfaceProtocol\r
1298             );\r
1299 \r
1300   FreePool (GetString);\r
1301   return RetVal;\r
1302 }\r
1303 \r
1304 /**\r
1305   Function to dump information about EfiAdapterInformation Protocol.\r
1306 \r
1307   @param[in] TheHandle      The handle that has the protocol installed.\r
1308   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
1309 \r
1310   @retval A pointer to a string containing the information.\r
1311 **/\r
1312 CHAR16*\r
1313 EFIAPI\r
1314 AdapterInformationDumpInformation (\r
1315   IN CONST EFI_HANDLE TheHandle,\r
1316   IN CONST BOOLEAN    Verbose\r
1317   )\r
1318 {\r
1319   EFI_STATUS                        Status;\r
1320   EFI_ADAPTER_INFORMATION_PROTOCOL  *EfiAdptrInfoProtocol;\r
1321   UINTN                             InfoTypesBufferCount;\r
1322   UINTN                             GuidIndex;\r
1323   EFI_GUID                          *InfoTypesBuffer;\r
1324   CHAR16                            *GuidStr;\r
1325   CHAR16                            *TempStr;\r
1326   CHAR16                            *RetVal;\r
1327   CHAR16                            *TempRetVal;\r
1328   VOID                              *InformationBlock;\r
1329   UINTN                             InformationBlockSize;\r
1330 \r
1331   if (!Verbose) {\r
1332     return (CatSPrint(NULL, L"AdapterInfo"));\r
1333   }\r
1334 \r
1335   InfoTypesBuffer   = NULL;\r
1336   InformationBlock  = NULL;\r
1337 \r
1338 \r
1339   Status = gBS->OpenProtocol (\r
1340                   (EFI_HANDLE) (TheHandle),\r
1341                   &gEfiAdapterInformationProtocolGuid,\r
1342                   (VOID **) &EfiAdptrInfoProtocol,\r
1343                   NULL,\r
1344                   NULL,\r
1345                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
1346                   );\r
1347 \r
1348   if (EFI_ERROR (Status)) {\r
1349     return NULL;\r
1350   }\r
1351 \r
1352   //\r
1353   // Get a list of supported information types for this instance of the protocol.\r
1354   //\r
1355   Status = EfiAdptrInfoProtocol->GetSupportedTypes (\r
1356                                    EfiAdptrInfoProtocol,\r
1357                                    &InfoTypesBuffer,\r
1358                                    &InfoTypesBufferCount\r
1359                                    );\r
1360   RetVal = NULL;\r
1361   if (EFI_ERROR (Status)) {\r
1362     TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED), NULL);\r
1363     if (TempStr != NULL) {\r
1364       RetVal = CatSPrint (NULL, TempStr, Status);\r
1365     } else {\r
1366       goto ERROR_EXIT;\r
1367     }\r
1368   } else {\r
1369     TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SUPP_TYPE_HEADER), NULL);\r
1370     if (TempStr == NULL) {\r
1371       goto ERROR_EXIT;\r
1372     }\r
1373     RetVal = CatSPrint (NULL, TempStr);\r
1374     SHELL_FREE_NON_NULL (TempStr);\r
1375 \r
1376     for (GuidIndex = 0; GuidIndex < InfoTypesBufferCount; GuidIndex++) {\r
1377       TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_NUMBER), NULL);\r
1378       if (TempStr == NULL) {\r
1379         goto ERROR_EXIT;\r
1380       }\r
1381       TempRetVal = CatSPrint (RetVal, TempStr, (GuidIndex + 1), &InfoTypesBuffer[GuidIndex]);\r
1382       SHELL_FREE_NON_NULL (RetVal);\r
1383       RetVal = TempRetVal;\r
1384       SHELL_FREE_NON_NULL (TempStr);\r
1385 \r
1386       TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_STRING), NULL);\r
1387       if (TempStr == NULL) {\r
1388         goto ERROR_EXIT;\r
1389       }\r
1390 \r
1391       if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) {\r
1392         TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoMediaStateGuid");\r
1393         SHELL_FREE_NON_NULL (RetVal);\r
1394         RetVal = TempRetVal;\r
1395       } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) {\r
1396         TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoNetworkBootGuid");\r
1397         SHELL_FREE_NON_NULL (RetVal);\r
1398         RetVal = TempRetVal;\r
1399       } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid)) {\r
1400         TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoSanMacAddressGuid");\r
1401         SHELL_FREE_NON_NULL (RetVal);\r
1402         RetVal = TempRetVal;\r
1403       } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoUndiIpv6SupportGuid)) {\r
1404         TempRetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoUndiIpv6SupportGuid");\r
1405         SHELL_FREE_NON_NULL (RetVal);\r
1406         RetVal = TempRetVal;\r
1407       } else {\r
1408 \r
1409         GuidStr = GetStringNameFromGuid (&InfoTypesBuffer[GuidIndex], NULL);\r
1410         if (GuidStr == NULL) {\r
1411           TempRetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType");\r
1412           SHELL_FREE_NON_NULL (RetVal);\r
1413           RetVal = TempRetVal;\r
1414 \r
1415           SHELL_FREE_NON_NULL (TempStr);\r
1416           SHELL_FREE_NON_NULL(GuidStr);\r
1417           //\r
1418           // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP\r
1419           //\r
1420           continue;\r
1421         } else {\r
1422           TempRetVal = CatSPrint (RetVal, TempStr, GuidStr);\r
1423           SHELL_FREE_NON_NULL (RetVal);\r
1424           RetVal = TempRetVal;\r
1425           SHELL_FREE_NON_NULL(GuidStr);\r
1426         }\r
1427       }\r
1428 \r
1429       SHELL_FREE_NON_NULL (TempStr);\r
1430 \r
1431       Status = EfiAdptrInfoProtocol->GetInformation (\r
1432                                        EfiAdptrInfoProtocol,\r
1433                                        &InfoTypesBuffer[GuidIndex],\r
1434                                        &InformationBlock,\r
1435                                        &InformationBlockSize\r
1436                                        );\r
1437 \r
1438       if (EFI_ERROR (Status)) {\r
1439         TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GETINFO_FAILED), NULL);\r
1440         if (TempStr == NULL) {\r
1441           goto ERROR_EXIT;\r
1442         }\r
1443         TempRetVal = CatSPrint (RetVal, TempStr, Status);\r
1444         SHELL_FREE_NON_NULL (RetVal);\r
1445         RetVal = TempRetVal;\r
1446       } else {\r
1447         if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) {\r
1448           TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_MEDIA_STATE), NULL);\r
1449           if (TempStr == NULL) {\r
1450             goto ERROR_EXIT;\r
1451           }\r
1452           TempRetVal = CatSPrint (\r
1453                          RetVal,\r
1454                          TempStr,\r
1455                          ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState,\r
1456                          ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState\r
1457                          );\r
1458           SHELL_FREE_NON_NULL (RetVal);\r
1459           RetVal = TempRetVal;\r
1460         } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) {\r
1461           TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_NETWORK_BOOT_INFO), NULL);\r
1462           if (TempStr == NULL) {\r
1463             goto ERROR_EXIT;\r
1464           }\r
1465           TempRetVal = CatSPrint (\r
1466                          RetVal,\r
1467                          TempStr,\r
1468                          ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4BootCapablity,\r
1469                          ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6BootCapablity,\r
1470                          ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBootCapablity,\r
1471                          ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->OffloadCapability,\r
1472                          ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiMpioCapability,\r
1473                          ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4Boot,\r
1474                          ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6Boot,\r
1475                          ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBoot\r
1476                          );\r
1477           SHELL_FREE_NON_NULL (RetVal);\r
1478           RetVal = TempRetVal;\r
1479         } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid) == TRUE) {\r
1480           TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO), NULL);\r
1481           if (TempStr == NULL) {\r
1482             goto ERROR_EXIT;\r
1483           }\r
1484           TempRetVal = CatSPrint (\r
1485                          RetVal,\r
1486                          TempStr,\r
1487                          ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[0],\r
1488                          ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[1],\r
1489                          ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[2],\r
1490                          ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[3],\r
1491                          ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[4],\r
1492                          ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[5]\r
1493                          );\r
1494           SHELL_FREE_NON_NULL (RetVal);\r
1495           RetVal = TempRetVal;\r
1496         } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoUndiIpv6SupportGuid) == TRUE) {\r
1497           TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_UNDI_IPV6_INFO), NULL);\r
1498           if (TempStr == NULL) {\r
1499             goto ERROR_EXIT;\r
1500           }\r
1501 \r
1502           TempRetVal = CatSPrint (\r
1503                          RetVal,\r
1504                          TempStr,\r
1505                          ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InformationBlock)->Ipv6Support\r
1506                          );\r
1507           SHELL_FREE_NON_NULL (RetVal);\r
1508           RetVal = TempRetVal;\r
1509         } else {\r
1510           TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE), NULL);\r
1511           if (TempStr == NULL) {\r
1512             goto ERROR_EXIT;\r
1513           }\r
1514           TempRetVal = CatSPrint (RetVal, TempStr, &InfoTypesBuffer[GuidIndex]);\r
1515           SHELL_FREE_NON_NULL (RetVal);\r
1516           RetVal = TempRetVal;\r
1517         }\r
1518       }\r
1519       SHELL_FREE_NON_NULL (TempStr);\r
1520       SHELL_FREE_NON_NULL (InformationBlock);\r
1521     }\r
1522   }\r
1523 \r
1524   SHELL_FREE_NON_NULL (InfoTypesBuffer);\r
1525   return RetVal;\r
1526 \r
1527 ERROR_EXIT:\r
1528   SHELL_FREE_NON_NULL (RetVal);\r
1529   SHELL_FREE_NON_NULL (InfoTypesBuffer);\r
1530   SHELL_FREE_NON_NULL (InformationBlock);\r
1531   return NULL;\r
1532 }\r
1533 \r
1534 /**\r
1535   Function to dump information about EFI_FIRMWARE_MANAGEMENT_PROTOCOL Protocol.\r
1536 \r
1537   @param[in] TheHandle      The handle that has the protocol installed.\r
1538   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
1539 \r
1540   @retval A pointer to a string containing the information.\r
1541 **/\r
1542 CHAR16*\r
1543 EFIAPI\r
1544 FirmwareManagementDumpInformation (\r
1545   IN CONST EFI_HANDLE TheHandle,\r
1546   IN CONST BOOLEAN    Verbose\r
1547   )\r
1548 {\r
1549   EFI_STATUS                          Status;\r
1550   EFI_FIRMWARE_MANAGEMENT_PROTOCOL    *EfiFwMgmtProtocol;\r
1551   EFI_FIRMWARE_IMAGE_DESCRIPTOR       *ImageInfo;\r
1552   EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1    *ImageInfoV1;\r
1553   EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2    *ImageInfoV2;\r
1554   UINT64                              AttributeSetting;\r
1555   UINTN                               ImageInfoSize;\r
1556   UINTN                               DescriptorSize;\r
1557   UINT32                              DescriptorVersion;\r
1558   UINT32                              PackageVersion;\r
1559   UINT8                               DescriptorCount;\r
1560   UINT8                               Index;\r
1561   UINT8                               Index1;\r
1562   UINT8                               ImageCount;\r
1563   CHAR16                              *PackageVersionName;\r
1564   CHAR16                              *TempStr;\r
1565   CHAR16                              *RetVal;\r
1566   CHAR16                              *TempRetVal;\r
1567   CHAR16                              *AttributeSettingStr;\r
1568   BOOLEAN                             Found;\r
1569   BOOLEAN                             AttributeSupported;\r
1570 \r
1571   //\r
1572   // Initialize local variables\r
1573   //\r
1574   ImageCount             = 0;\r
1575   ImageInfoSize          = 1;\r
1576   AttributeSetting       = 0;\r
1577   Found                  = FALSE;\r
1578   AttributeSupported     = FALSE;\r
1579   ImageInfo              = NULL;\r
1580   ImageInfoV1            = NULL;\r
1581   ImageInfoV2            = NULL;\r
1582   PackageVersionName     = NULL;\r
1583   RetVal                 = NULL;\r
1584   TempRetVal             = NULL;\r
1585   TempStr                = NULL;\r
1586   AttributeSettingStr    = NULL;\r
1587 \r
1588   if (!Verbose) {\r
1589     return (CatSPrint(NULL, L"FirmwareManagement"));\r
1590   }\r
1591 \r
1592   Status = gBS->OpenProtocol (\r
1593                   (EFI_HANDLE) (TheHandle),\r
1594                   &gEfiFirmwareManagementProtocolGuid,\r
1595                   (VOID **) &EfiFwMgmtProtocol,\r
1596                   NULL,\r
1597                   NULL,\r
1598                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
1599                   );\r
1600 \r
1601   if (EFI_ERROR (Status)) {\r
1602     return NULL;\r
1603   }\r
1604 \r
1605   Status = EfiFwMgmtProtocol->GetImageInfo (\r
1606                                 EfiFwMgmtProtocol,\r
1607                                 &ImageInfoSize,\r
1608                                 ImageInfo,\r
1609                                 &DescriptorVersion,\r
1610                                 &DescriptorCount,\r
1611                                 &DescriptorSize,\r
1612                                 &PackageVersion,\r
1613                                 &PackageVersionName\r
1614                                 );\r
1615 \r
1616   if (Status == EFI_BUFFER_TOO_SMALL) {\r
1617     ImageInfo = AllocateZeroPool (ImageInfoSize);\r
1618 \r
1619     if (ImageInfo == NULL) {\r
1620       Status = EFI_OUT_OF_RESOURCES;\r
1621     } else {\r
1622       Status = EfiFwMgmtProtocol->GetImageInfo (\r
1623                                     EfiFwMgmtProtocol,\r
1624                                     &ImageInfoSize,\r
1625                                     ImageInfo,\r
1626                                     &DescriptorVersion,\r
1627                                     &DescriptorCount,\r
1628                                     &DescriptorSize,\r
1629                                     &PackageVersion,\r
1630                                     &PackageVersionName\r
1631                                     );\r
1632     }\r
1633   }\r
1634 \r
1635   if (EFI_ERROR (Status)) {\r
1636     goto ERROR_EXIT;\r
1637   }\r
1638 \r
1639   //\r
1640   // Decode Image Descriptor data only if its version is supported\r
1641   //\r
1642   if (DescriptorVersion <= EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION) {\r
1643 \r
1644     if (ImageInfo == NULL) {\r
1645       goto ERROR_EXIT;\r
1646     }\r
1647 \r
1648     ImageInfoV1 = (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1 *)ImageInfo;\r
1649     ImageInfoV2 = (EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2 *)ImageInfo;\r
1650 \r
1651     //\r
1652     // Set ImageInfoSize in return buffer\r
1653     //\r
1654     TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_IMAGE_INFO_SIZE), NULL);\r
1655     if (TempStr == NULL) {\r
1656       goto ERROR_EXIT;\r
1657     }\r
1658     RetVal = CatSPrint (NULL, TempStr, ImageInfoSize);\r
1659     SHELL_FREE_NON_NULL (TempStr);\r
1660 \r
1661     //\r
1662     // Set DescriptorVersion in return buffer\r
1663     //\r
1664     TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_DESCRIPTOR_VERSION), NULL);\r
1665     if (TempStr == NULL) {\r
1666       goto ERROR_EXIT;\r
1667     }\r
1668     TempRetVal = CatSPrint (RetVal, TempStr, DescriptorVersion);\r
1669     SHELL_FREE_NON_NULL (RetVal);\r
1670     RetVal = TempRetVal;\r
1671     SHELL_FREE_NON_NULL (TempStr);\r
1672 \r
1673     //\r
1674     // Set DescriptorCount in return buffer\r
1675     //\r
1676     TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_DESCRIPTOR_COUNT), NULL);\r
1677     if (TempStr == NULL) {\r
1678       goto ERROR_EXIT;\r
1679     }\r
1680     TempRetVal = CatSPrint (RetVal, TempStr, DescriptorCount);\r
1681     SHELL_FREE_NON_NULL (RetVal);\r
1682     RetVal = TempRetVal;\r
1683     SHELL_FREE_NON_NULL (TempStr);\r
1684 \r
1685 \r
1686     //\r
1687     // Set DescriptorSize in return buffer\r
1688     //\r
1689     TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_DESCRIPTOR_SIZE), NULL);\r
1690     if (TempStr == NULL) {\r
1691       goto ERROR_EXIT;\r
1692     }\r
1693     TempRetVal = CatSPrint (RetVal, TempStr, DescriptorSize);\r
1694     SHELL_FREE_NON_NULL (RetVal);\r
1695     RetVal = TempRetVal;\r
1696     SHELL_FREE_NON_NULL (TempStr);\r
1697 \r
1698     //\r
1699     // Set PackageVersion in return buffer\r
1700     //\r
1701     TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_PACKAGE_VERSION), NULL);\r
1702     if (TempStr == NULL) {\r
1703       goto ERROR_EXIT;\r
1704     }\r
1705     TempRetVal = CatSPrint (RetVal, TempStr, PackageVersion);\r
1706     SHELL_FREE_NON_NULL (RetVal);\r
1707     RetVal = TempRetVal;\r
1708     SHELL_FREE_NON_NULL (TempStr);\r
1709 \r
1710     //\r
1711     // Set PackageVersionName in return buffer\r
1712     //\r
1713     TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_PACKAGE_VERSION_NAME), NULL);\r
1714     if (TempStr == NULL) {\r
1715       goto ERROR_EXIT;\r
1716     }\r
1717     TempRetVal = CatSPrint (RetVal, TempStr, PackageVersionName);\r
1718     SHELL_FREE_NON_NULL (RetVal);\r
1719     RetVal = TempRetVal;\r
1720     SHELL_FREE_NON_NULL (TempStr);\r
1721 \r
1722     for (Index = 0; Index < DescriptorCount; Index++) {\r
1723       //\r
1724       // First check if Attribute is supported\r
1725       // and generate a string for AttributeSetting field\r
1726       //\r
1727       SHELL_FREE_NON_NULL (AttributeSettingStr);\r
1728       AttributeSupported = FALSE;\r
1729       AttributeSetting   = 0;\r
1730       if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1) {\r
1731         if (ImageInfoV1[Index].AttributesSupported != 0x0) {\r
1732           AttributeSupported = TRUE;\r
1733           AttributeSetting   = ImageInfoV1[Index].AttributesSetting;\r
1734         }\r
1735       } else if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2) {\r
1736         if (ImageInfoV2[Index].AttributesSupported != 0x0) {\r
1737           AttributeSupported = TRUE;\r
1738           AttributeSetting   = ImageInfoV2[Index].AttributesSetting;\r
1739         }\r
1740       } else {\r
1741         if (ImageInfo[Index].AttributesSupported != 0x0) {\r
1742           AttributeSupported = TRUE;\r
1743           AttributeSetting   = ImageInfo[Index].AttributesSetting;\r
1744         }\r
1745       }\r
1746 \r
1747       if (!AttributeSupported) {\r
1748         AttributeSettingStr = CatSPrint (NULL, L"None");\r
1749       } else {\r
1750         AttributeSettingStr = CatSPrint (NULL, L"(");\r
1751 \r
1752         if ((AttributeSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != 0x0) {\r
1753           TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_IMAGE_UPDATABLE");\r
1754           SHELL_FREE_NON_NULL (AttributeSettingStr);\r
1755           AttributeSettingStr = TempRetVal;\r
1756         }\r
1757         if ((AttributeSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED) != 0x0) {\r
1758           TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_RESET_REQUIRED");\r
1759           SHELL_FREE_NON_NULL (AttributeSettingStr);\r
1760           AttributeSettingStr = TempRetVal;\r
1761         }\r
1762         if ((AttributeSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != 0x0) {\r
1763           TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED");\r
1764           SHELL_FREE_NON_NULL (AttributeSettingStr);\r
1765           AttributeSettingStr = TempRetVal;\r
1766         }\r
1767         if ((AttributeSetting & IMAGE_ATTRIBUTE_IN_USE) != 0x0) {\r
1768           TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_IN_USE");\r
1769           SHELL_FREE_NON_NULL (AttributeSettingStr);\r
1770           AttributeSettingStr = TempRetVal;\r
1771         }\r
1772         if ((AttributeSetting & IMAGE_ATTRIBUTE_UEFI_IMAGE) != 0x0) {\r
1773           TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_UEFI_IMAGE");\r
1774           SHELL_FREE_NON_NULL (AttributeSettingStr);\r
1775           AttributeSettingStr = TempRetVal;\r
1776         }\r
1777         TempRetVal = CatSPrint (AttributeSettingStr, L" )");\r
1778         SHELL_FREE_NON_NULL (AttributeSettingStr);\r
1779         AttributeSettingStr = TempRetVal;\r
1780       }\r
1781 \r
1782       if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1) {\r
1783         if (ImageInfoV1[Index].ImageIndex != 0x0) {\r
1784           ImageCount++;\r
1785         }\r
1786 \r
1787         TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V1), NULL);\r
1788         if (TempStr == NULL) {\r
1789           goto ERROR_EXIT;\r
1790         }\r
1791         TempRetVal = CatSPrint (\r
1792                        RetVal,\r
1793                        TempStr,\r
1794                        Index,\r
1795                        ImageInfoV1[Index].ImageIndex,\r
1796                        &ImageInfoV1[Index].ImageTypeId,\r
1797                        ImageInfoV1[Index].ImageId,\r
1798                        ImageInfoV1[Index].ImageIdName,\r
1799                        ImageInfoV1[Index].Version,\r
1800                        ImageInfoV1[Index].VersionName,\r
1801                        ImageInfoV1[Index].Size,\r
1802                        ImageInfoV1[Index].AttributesSupported,\r
1803                        AttributeSettingStr,\r
1804                        ImageInfoV1[Index].Compatibilities\r
1805                        );\r
1806         SHELL_FREE_NON_NULL (RetVal);\r
1807         RetVal = TempRetVal;\r
1808         SHELL_FREE_NON_NULL (TempStr);\r
1809       } else if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2) {\r
1810         if (ImageInfoV2[Index].ImageIndex != 0x0) {\r
1811           ImageCount++;\r
1812         }\r
1813 \r
1814         TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO_V2), NULL);\r
1815         if (TempStr == NULL) {\r
1816           goto ERROR_EXIT;\r
1817         }\r
1818         TempRetVal = CatSPrint (\r
1819                        RetVal,\r
1820                        TempStr,\r
1821                        Index,\r
1822                        ImageInfoV2[Index].ImageIndex,\r
1823                        &ImageInfoV2[Index].ImageTypeId,\r
1824                        ImageInfoV2[Index].ImageId,\r
1825                        ImageInfoV2[Index].ImageIdName,\r
1826                        ImageInfoV2[Index].Version,\r
1827                        ImageInfoV2[Index].VersionName,\r
1828                        ImageInfoV2[Index].Size,\r
1829                        ImageInfoV2[Index].AttributesSupported,\r
1830                        AttributeSettingStr,\r
1831                        ImageInfoV2[Index].Compatibilities,\r
1832                        ImageInfoV2[Index].LowestSupportedImageVersion\r
1833                        );\r
1834         SHELL_FREE_NON_NULL (RetVal);\r
1835         RetVal = TempRetVal;\r
1836         SHELL_FREE_NON_NULL (TempStr);\r
1837       } else {\r
1838         if (ImageInfo[Index].ImageIndex != 0x0) {\r
1839           ImageCount++;\r
1840         }\r
1841 \r
1842         TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_IMAGE_DESCRIPTOR_INFO), NULL);\r
1843         if (TempStr == NULL) {\r
1844           goto ERROR_EXIT;\r
1845         }\r
1846         TempRetVal = CatSPrint (\r
1847                        RetVal,\r
1848                        TempStr,\r
1849                        Index,\r
1850                        ImageInfo[Index].ImageIndex,\r
1851                        &ImageInfo[Index].ImageTypeId,\r
1852                        ImageInfo[Index].ImageId,\r
1853                        ImageInfo[Index].ImageIdName,\r
1854                        ImageInfo[Index].Version,\r
1855                        ImageInfo[Index].VersionName,\r
1856                        ImageInfo[Index].Size,\r
1857                        ImageInfo[Index].AttributesSupported,\r
1858                        AttributeSettingStr,\r
1859                        ImageInfo[Index].Compatibilities,\r
1860                        ImageInfo[Index].LowestSupportedImageVersion,\r
1861                        ImageInfo[Index].LastAttemptVersion,\r
1862                        ImageInfo[Index].LastAttemptStatus,\r
1863                        ImageInfo[Index].HardwareInstance\r
1864                        );\r
1865         SHELL_FREE_NON_NULL (RetVal);\r
1866         RetVal = TempRetVal;\r
1867         SHELL_FREE_NON_NULL (TempStr);\r
1868       }\r
1869     }\r
1870   }\r
1871 \r
1872   if (ImageCount > 0) {\r
1873     for (Index=0; Index<DescriptorCount; Index++) {\r
1874       for (Index1=Index+1; Index1<DescriptorCount; Index1++) {\r
1875         if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1) {\r
1876           if (ImageInfoV1[Index].ImageId == ImageInfoV1[Index1].ImageId) {\r
1877             Found = TRUE;\r
1878             //\r
1879             // At least one match found indicating presense of non unique ImageId values so no more comparisons needed\r
1880             //\r
1881             goto ENDLOOP;\r
1882           }\r
1883         } else if (DescriptorVersion == EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2) {\r
1884           if (ImageInfoV2[Index].ImageId == ImageInfoV2[Index1].ImageId) {\r
1885             Found = TRUE;\r
1886             //\r
1887             // At least one match found indicating presense of non unique ImageId values so no more comparisons needed\r
1888             //\r
1889             goto ENDLOOP;\r
1890           }\r
1891         } else {\r
1892           if (ImageInfo[Index].ImageId == ImageInfo[Index1].ImageId) {\r
1893             Found = TRUE;\r
1894             //\r
1895             // At least one match found indicating presense of non unique ImageId values so no more comparisons needed\r
1896             //\r
1897             goto ENDLOOP;\r
1898           }\r
1899         }\r
1900       }\r
1901     }\r
1902   }\r
1903 \r
1904 ENDLOOP:\r
1905   //\r
1906   // Check if ImageId with duplicate value was found\r
1907   //\r
1908   if (Found) {\r
1909     TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_FMP_IMAGEID_NON_UNIQUE), NULL);\r
1910     if (TempStr == NULL) {\r
1911       goto ERROR_EXIT;\r
1912     }\r
1913     TempRetVal = CatSPrint (RetVal, TempStr);\r
1914     SHELL_FREE_NON_NULL (RetVal);\r
1915     RetVal = TempRetVal;\r
1916     SHELL_FREE_NON_NULL (TempStr);\r
1917   }\r
1918 \r
1919   SHELL_FREE_NON_NULL (ImageInfo);\r
1920   SHELL_FREE_NON_NULL (PackageVersionName);\r
1921   SHELL_FREE_NON_NULL (AttributeSettingStr);\r
1922 \r
1923   return RetVal;\r
1924 \r
1925 ERROR_EXIT:\r
1926   SHELL_FREE_NON_NULL (RetVal);\r
1927   SHELL_FREE_NON_NULL (ImageInfo);\r
1928   SHELL_FREE_NON_NULL (PackageVersionName);\r
1929   SHELL_FREE_NON_NULL (AttributeSettingStr);\r
1930 \r
1931   return NULL;\r
1932 }\r
1933 \r
1934 /**\r
1935   Function to dump information about Partition Information protocol.\r
1936 \r
1937   This will allocate the return buffer from boot services pool.\r
1938 \r
1939   @param[in] TheHandle      The handle that has the protocol installed.\r
1940   @param[in] Verbose        TRUE for additional information, FALSE otherwise.\r
1941 \r
1942   @retval A pointer to a string containing the information.\r
1943 **/\r
1944 CHAR16*\r
1945 EFIAPI\r
1946 PartitionInfoProtocolDumpInformation (\r
1947   IN CONST EFI_HANDLE TheHandle,\r
1948   IN CONST BOOLEAN    Verbose\r
1949   )\r
1950 {\r
1951   EFI_STATUS                      Status;\r
1952   EFI_PARTITION_INFO_PROTOCOL     *PartitionInfo;\r
1953   CHAR16                          *PartitionType;\r
1954   CHAR16                          *EfiSystemPartition;\r
1955   CHAR16                          *RetVal;\r
1956 \r
1957   if (!Verbose) {\r
1958     return NULL;\r
1959   }\r
1960 \r
1961   Status = gBS->OpenProtocol (\r
1962                 TheHandle,\r
1963                 &gEfiPartitionInfoProtocolGuid,\r
1964                 (VOID**)&PartitionInfo,\r
1965                 gImageHandle,\r
1966                 NULL,\r
1967                 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
1968                 );\r
1969   if (EFI_ERROR (Status)) {\r
1970     return NULL;\r
1971   }\r
1972 \r
1973   HandleParsingHiiInit ();\r
1974 \r
1975   switch (PartitionInfo->Type) {\r
1976   case PARTITION_TYPE_OTHER:\r
1977     PartitionType = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_OTHER), NULL);\r
1978     break;\r
1979   case PARTITION_TYPE_MBR:\r
1980     PartitionType = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_MBR), NULL);\r
1981     break;\r
1982   case PARTITION_TYPE_GPT:\r
1983     PartitionType = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_GPT), NULL);\r
1984     break;\r
1985   default:\r
1986     PartitionType = NULL;\r
1987     break;\r
1988   }\r
1989   if (PartitionType == NULL) {\r
1990     return NULL;\r
1991   }\r
1992 \r
1993   if (PartitionInfo->System == 1) {\r
1994     EfiSystemPartition = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_EFI_SYS_PART), NULL);\r
1995   } else {\r
1996     EfiSystemPartition = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PARTINFO_DUMP_NOT_EFI_SYS_PART), NULL);\r
1997   }\r
1998   if (EfiSystemPartition == NULL) {\r
1999     SHELL_FREE_NON_NULL (PartitionType);\r
2000     return NULL;\r
2001   }\r
2002 \r
2003   RetVal = CatSPrint (\r
2004              NULL,\r
2005              L"%s\r\n%s",\r
2006              PartitionType,\r
2007              EfiSystemPartition\r
2008              );\r
2009 \r
2010   SHELL_FREE_NON_NULL (EfiSystemPartition);\r
2011   SHELL_FREE_NON_NULL (PartitionType);\r
2012   return RetVal;\r
2013 }\r
2014 \r
2015 //\r
2016 // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg\r
2017 //\r
2018 #define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \\r
2019   { \\r
2020     0x58c518b1, 0x76f3, 0x11d4, { 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \\r
2021   }\r
2022 \r
2023 #define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \\r
2024   { \\r
2025     0x96eb4ad6, 0xa32a, 0x11d4, { 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \\r
2026   }\r
2027 \r
2028 #define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \\r
2029   { \\r
2030     0xc95a93d, 0xa006, 0x11d4, { 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \\r
2031   }\r
2032 STATIC CONST EFI_GUID WinNtThunkProtocolGuid = LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID;\r
2033 STATIC CONST EFI_GUID WinNtIoProtocolGuid    = LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID;\r
2034 STATIC CONST EFI_GUID WinNtSerialPortGuid    = LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID;\r
2035 \r
2036 //\r
2037 // Deprecated protocols we dont want to link from IntelFrameworkModulePkg\r
2038 //\r
2039 #define LOCAL_EFI_ISA_IO_PROTOCOL_GUID \\r
2040   { \\r
2041   0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \\r
2042   }\r
2043 #define LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID \\r
2044   { \\r
2045   0x64a892dc, 0x5561, 0x4536, { 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55 } \\r
2046   }\r
2047 STATIC CONST EFI_GUID EfiIsaIoProtocolGuid = LOCAL_EFI_ISA_IO_PROTOCOL_GUID;\r
2048 STATIC CONST EFI_GUID EfiIsaAcpiProtocolGuid = LOCAL_EFI_ISA_ACPI_PROTOCOL_GUID;\r
2049 \r
2050 \r
2051 STATIC CONST GUID_INFO_BLOCK mGuidStringListNT[] = {\r
2052   {STRING_TOKEN(STR_WINNT_THUNK),           (EFI_GUID*)&WinNtThunkProtocolGuid,               NULL},\r
2053   {STRING_TOKEN(STR_WINNT_DRIVER_IO),       (EFI_GUID*)&WinNtIoProtocolGuid,                  NULL},\r
2054   {STRING_TOKEN(STR_WINNT_SERIAL_PORT),     (EFI_GUID*)&WinNtSerialPortGuid,                  NULL},\r
2055   {0,                                       NULL,                                             NULL},\r
2056 };\r
2057 \r
2058 STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {\r
2059   {STRING_TOKEN(STR_LOADED_IMAGE),          &gEfiLoadedImageProtocolGuid,                     LoadedImageProtocolDumpInformation},\r
2060   {STRING_TOKEN(STR_DEVICE_PATH),           &gEfiDevicePathProtocolGuid,                      DevicePathProtocolDumpInformation},\r
2061   {STRING_TOKEN(STR_IMAGE_PATH),            &gEfiLoadedImageDevicePathProtocolGuid,           LoadedImageDevicePathProtocolDumpInformation},\r
2062   {STRING_TOKEN(STR_DEVICE_PATH_UTIL),      &gEfiDevicePathUtilitiesProtocolGuid,             NULL},\r
2063   {STRING_TOKEN(STR_DEVICE_PATH_TXT),       &gEfiDevicePathToTextProtocolGuid,                NULL},\r
2064   {STRING_TOKEN(STR_DEVICE_PATH_FTXT),      &gEfiDevicePathFromTextProtocolGuid,              NULL},\r
2065   {STRING_TOKEN(STR_DEVICE_PATH_PC),        &gEfiPcAnsiGuid,                                  NULL},\r
2066   {STRING_TOKEN(STR_DEVICE_PATH_VT100),     &gEfiVT100Guid,                                   NULL},\r
2067   {STRING_TOKEN(STR_DEVICE_PATH_VT100P),    &gEfiVT100PlusGuid,                               NULL},\r
2068   {STRING_TOKEN(STR_DEVICE_PATH_VTUTF8),    &gEfiVTUTF8Guid,                                  NULL},\r
2069   {STRING_TOKEN(STR_DRIVER_BINDING),        &gEfiDriverBindingProtocolGuid,                   NULL},\r
2070   {STRING_TOKEN(STR_PLATFORM_OVERRIDE),     &gEfiPlatformDriverOverrideProtocolGuid,          NULL},\r
2071   {STRING_TOKEN(STR_BUS_OVERRIDE),          &gEfiBusSpecificDriverOverrideProtocolGuid,       BusSpecificDriverOverrideProtocolDumpInformation},\r
2072   {STRING_TOKEN(STR_DRIVER_DIAG),           &gEfiDriverDiagnosticsProtocolGuid,               NULL},\r
2073   {STRING_TOKEN(STR_DRIVER_DIAG2),          &gEfiDriverDiagnostics2ProtocolGuid,              NULL},\r
2074   {STRING_TOKEN(STR_DRIVER_CN),             &gEfiComponentNameProtocolGuid,                   NULL},\r
2075   {STRING_TOKEN(STR_DRIVER_CN2),            &gEfiComponentName2ProtocolGuid,                  NULL},\r
2076   {STRING_TOKEN(STR_PLAT_DRV_CFG),          &gEfiPlatformToDriverConfigurationProtocolGuid,   NULL},\r
2077   {STRING_TOKEN(STR_DRIVER_VERSION),        &gEfiDriverSupportedEfiVersionProtocolGuid,       DriverEfiVersionProtocolDumpInformation},\r
2078   {STRING_TOKEN(STR_TXT_IN),                &gEfiSimpleTextInProtocolGuid,                    NULL},\r
2079   {STRING_TOKEN(STR_TXT_IN_EX),             &gEfiSimpleTextInputExProtocolGuid,               NULL},\r
2080   {STRING_TOKEN(STR_TXT_OUT),               &gEfiSimpleTextOutProtocolGuid,                   TxtOutProtocolDumpInformation},\r
2081   {STRING_TOKEN(STR_SIM_POINTER),           &gEfiSimplePointerProtocolGuid,                   NULL},\r
2082   {STRING_TOKEN(STR_ABS_POINTER),           &gEfiAbsolutePointerProtocolGuid,                 NULL},\r
2083   {STRING_TOKEN(STR_SERIAL_IO),             &gEfiSerialIoProtocolGuid,                        NULL},\r
2084   {STRING_TOKEN(STR_GRAPHICS_OUTPUT),       &gEfiGraphicsOutputProtocolGuid,                  GraphicsOutputProtocolDumpInformation},\r
2085   {STRING_TOKEN(STR_EDID_DISCOVERED),       &gEfiEdidDiscoveredProtocolGuid,                  EdidDiscoveredProtocolDumpInformation},\r
2086   {STRING_TOKEN(STR_EDID_ACTIVE),           &gEfiEdidActiveProtocolGuid,                      EdidActiveProtocolDumpInformation},\r
2087   {STRING_TOKEN(STR_EDID_OVERRIDE),         &gEfiEdidOverrideProtocolGuid,                    NULL},\r
2088   {STRING_TOKEN(STR_CON_IN),                &gEfiConsoleInDeviceGuid,                         NULL},\r
2089   {STRING_TOKEN(STR_CON_OUT),               &gEfiConsoleOutDeviceGuid,                        NULL},\r
2090   {STRING_TOKEN(STR_STD_ERR),               &gEfiStandardErrorDeviceGuid,                     NULL},\r
2091   {STRING_TOKEN(STR_LOAD_FILE),             &gEfiLoadFileProtocolGuid,                        NULL},\r
2092   {STRING_TOKEN(STR_LOAD_FILE2),            &gEfiLoadFile2ProtocolGuid,                       NULL},\r
2093   {STRING_TOKEN(STR_SIMPLE_FILE_SYS),       &gEfiSimpleFileSystemProtocolGuid,                NULL},\r
2094   {STRING_TOKEN(STR_TAPE_IO),               &gEfiTapeIoProtocolGuid,                          NULL},\r
2095   {STRING_TOKEN(STR_DISK_IO),               &gEfiDiskIoProtocolGuid,                          NULL},\r
2096   {STRING_TOKEN(STR_BLK_IO),                &gEfiBlockIoProtocolGuid,                         BlockIoProtocolDumpInformation},\r
2097   {STRING_TOKEN(STR_UC),                    &gEfiUnicodeCollationProtocolGuid,                NULL},\r
2098   {STRING_TOKEN(STR_UC2),                   &gEfiUnicodeCollation2ProtocolGuid,               NULL},\r
2099   {STRING_TOKEN(STR_PCIRB_IO),              &gEfiPciRootBridgeIoProtocolGuid,                 PciRootBridgeIoDumpInformation},\r
2100   {STRING_TOKEN(STR_PCI_IO),                &gEfiPciIoProtocolGuid,                           PciIoProtocolDumpInformation},\r
2101   {STRING_TOKEN(STR_SCSI_PT),               &gEfiScsiPassThruProtocolGuid,                    NULL},\r
2102   {STRING_TOKEN(STR_SCSI_IO),               &gEfiScsiIoProtocolGuid,                          NULL},\r
2103   {STRING_TOKEN(STR_SCSI_PT_EXT),           &gEfiExtScsiPassThruProtocolGuid,                 NULL},\r
2104   {STRING_TOKEN(STR_ISCSI),                 &gEfiIScsiInitiatorNameProtocolGuid,              NULL},\r
2105   {STRING_TOKEN(STR_USB_IO),                &gEfiUsbIoProtocolGuid,                           UsbIoProtocolDumpInformation},\r
2106   {STRING_TOKEN(STR_USB_HC),                &gEfiUsbHcProtocolGuid,                           NULL},\r
2107   {STRING_TOKEN(STR_USB_HC2),               &gEfiUsb2HcProtocolGuid,                          NULL},\r
2108   {STRING_TOKEN(STR_DEBUG_SUPPORT),         &gEfiDebugSupportProtocolGuid,                    DebugSupportProtocolDumpInformation},\r
2109   {STRING_TOKEN(STR_DEBUG_PORT),            &gEfiDebugPortProtocolGuid,                       NULL},\r
2110   {STRING_TOKEN(STR_DECOMPRESS),            &gEfiDecompressProtocolGuid,                      NULL},\r
2111   {STRING_TOKEN(STR_ACPI_TABLE),            &gEfiAcpiTableProtocolGuid,                       NULL},\r
2112   {STRING_TOKEN(STR_EBC_INTERPRETER),       &gEfiEbcProtocolGuid,                             NULL},\r
2113   {STRING_TOKEN(STR_SNP),                   &gEfiSimpleNetworkProtocolGuid,                   NULL},\r
2114   {STRING_TOKEN(STR_NII),                   &gEfiNetworkInterfaceIdentifierProtocolGuid,      NULL},\r
2115   {STRING_TOKEN(STR_NII_31),                &gEfiNetworkInterfaceIdentifierProtocolGuid_31,   NULL},\r
2116   {STRING_TOKEN(STR_PXE_BC),                &gEfiPxeBaseCodeProtocolGuid,                     NULL},\r
2117   {STRING_TOKEN(STR_PXE_CB),                &gEfiPxeBaseCodeCallbackProtocolGuid,             NULL},\r
2118   {STRING_TOKEN(STR_BIS),                   &gEfiBisProtocolGuid,                             NULL},\r
2119   {STRING_TOKEN(STR_MNP_SB),                &gEfiManagedNetworkServiceBindingProtocolGuid,    NULL},\r
2120   {STRING_TOKEN(STR_MNP),                   &gEfiManagedNetworkProtocolGuid,                  NULL},\r
2121   {STRING_TOKEN(STR_ARP_SB),                &gEfiArpServiceBindingProtocolGuid,               NULL},\r
2122   {STRING_TOKEN(STR_ARP),                   &gEfiArpProtocolGuid,                             NULL},\r
2123   {STRING_TOKEN(STR_DHCPV4_SB),             &gEfiDhcp4ServiceBindingProtocolGuid,             NULL},\r
2124   {STRING_TOKEN(STR_DHCPV4),                &gEfiDhcp4ProtocolGuid,                           NULL},\r
2125   {STRING_TOKEN(STR_TCPV4_SB),              &gEfiTcp4ServiceBindingProtocolGuid,              NULL},\r
2126   {STRING_TOKEN(STR_TCPV4),                 &gEfiTcp4ProtocolGuid,                            NULL},\r
2127   {STRING_TOKEN(STR_IPV4_SB),               &gEfiIp4ServiceBindingProtocolGuid,               NULL},\r
2128   {STRING_TOKEN(STR_IPV4),                  &gEfiIp4ProtocolGuid,                             NULL},\r
2129   {STRING_TOKEN(STR_IPV4_CFG),              &gEfiIp4ConfigProtocolGuid,                       NULL},\r
2130   {STRING_TOKEN(STR_IPV4_CFG2),             &gEfiIp4Config2ProtocolGuid,                      NULL},\r
2131   {STRING_TOKEN(STR_UDPV4_SB),              &gEfiUdp4ServiceBindingProtocolGuid,              NULL},\r
2132   {STRING_TOKEN(STR_UDPV4),                 &gEfiUdp4ProtocolGuid,                            NULL},\r
2133   {STRING_TOKEN(STR_MTFTPV4_SB),            &gEfiMtftp4ServiceBindingProtocolGuid,            NULL},\r
2134   {STRING_TOKEN(STR_MTFTPV4),               &gEfiMtftp4ProtocolGuid,                          NULL},\r
2135   {STRING_TOKEN(STR_AUTH_INFO),             &gEfiAuthenticationInfoProtocolGuid,              NULL},\r
2136   {STRING_TOKEN(STR_HASH_SB),               &gEfiHashServiceBindingProtocolGuid,              NULL},\r
2137   {STRING_TOKEN(STR_HASH),                  &gEfiHashProtocolGuid,                            NULL},\r
2138   {STRING_TOKEN(STR_HII_FONT),              &gEfiHiiFontProtocolGuid,                         NULL},\r
2139   {STRING_TOKEN(STR_HII_STRING),            &gEfiHiiStringProtocolGuid,                       NULL},\r
2140   {STRING_TOKEN(STR_HII_IMAGE),             &gEfiHiiImageProtocolGuid,                        NULL},\r
2141   {STRING_TOKEN(STR_HII_DATABASE),          &gEfiHiiDatabaseProtocolGuid,                     NULL},\r
2142   {STRING_TOKEN(STR_HII_CONFIG_ROUT),       &gEfiHiiConfigRoutingProtocolGuid,                NULL},\r
2143   {STRING_TOKEN(STR_HII_CONFIG_ACC),        &gEfiHiiConfigAccessProtocolGuid,                 NULL},\r
2144   {STRING_TOKEN(STR_HII_FORM_BROWSER2),     &gEfiFormBrowser2ProtocolGuid,                    NULL},\r
2145   {STRING_TOKEN(STR_DRIVER_FAM_OVERRIDE),   &gEfiDriverFamilyOverrideProtocolGuid,            NULL},\r
2146   {STRING_TOKEN(STR_PCD),                   &gPcdProtocolGuid,                                NULL},\r
2147   {STRING_TOKEN(STR_TCG),                   &gEfiTcgProtocolGuid,                             NULL},\r
2148   {STRING_TOKEN(STR_HII_PACKAGE_LIST),      &gEfiHiiPackageListProtocolGuid,                  NULL},\r
2149 \r
2150 //\r
2151 // the ones under this are deprecated by the current UEFI Spec, but may be found anyways...\r
2152 //\r
2153   {STRING_TOKEN(STR_SHELL_INTERFACE),       &gEfiShellInterfaceGuid,                          NULL},\r
2154   {STRING_TOKEN(STR_SHELL_ENV2),            &gEfiShellEnvironment2Guid,                       NULL},\r
2155   {STRING_TOKEN(STR_SHELL_ENV),             &gEfiShellEnvironment2Guid,                       NULL},\r
2156   {STRING_TOKEN(STR_DEVICE_IO),             &gEfiDeviceIoProtocolGuid,                        NULL},\r
2157   {STRING_TOKEN(STR_UGA_DRAW),              &gEfiUgaDrawProtocolGuid,                         NULL},\r
2158   {STRING_TOKEN(STR_UGA_IO),                &gEfiUgaIoProtocolGuid,                           NULL},\r
2159   {STRING_TOKEN(STR_ESP),                   &gEfiPartTypeSystemPartGuid,                      NULL},\r
2160   {STRING_TOKEN(STR_GPT_NBR),               &gEfiPartTypeLegacyMbrGuid,                       NULL},\r
2161   {STRING_TOKEN(STR_DRIVER_CONFIG),         &gEfiDriverConfigurationProtocolGuid,             NULL},\r
2162   {STRING_TOKEN(STR_DRIVER_CONFIG2),        &gEfiDriverConfiguration2ProtocolGuid,            NULL},\r
2163 \r
2164 //\r
2165 // these are using local (non-global) definitions to reduce package dependancy.\r
2166 //\r
2167   {STRING_TOKEN(STR_ISA_IO),                (EFI_GUID*)&EfiIsaIoProtocolGuid,                 NULL},\r
2168   {STRING_TOKEN(STR_ISA_ACPI),              (EFI_GUID*)&EfiIsaAcpiProtocolGuid,               NULL},\r
2169 \r
2170 //\r
2171 // the ones under this are GUID identified structs, not protocols\r
2172 //\r
2173   {STRING_TOKEN(STR_FILE_INFO),             &gEfiFileInfoGuid,                                NULL},\r
2174   {STRING_TOKEN(STR_FILE_SYS_INFO),         &gEfiFileSystemInfoGuid,                          NULL},\r
2175 \r
2176 //\r
2177 // the ones under this are misc GUIDS.\r
2178 //\r
2179   {STRING_TOKEN(STR_EFI_GLOBAL_VARIABLE),   &gEfiGlobalVariableGuid,                          NULL},\r
2180 \r
2181 //\r
2182 // UEFI 2.2\r
2183 //\r
2184   {STRING_TOKEN(STR_IP6_SB),                &gEfiIp6ServiceBindingProtocolGuid,               NULL},\r
2185   {STRING_TOKEN(STR_IP6),                   &gEfiIp6ProtocolGuid,                             NULL},\r
2186   {STRING_TOKEN(STR_IP6_CONFIG),            &gEfiIp6ConfigProtocolGuid,                       NULL},\r
2187   {STRING_TOKEN(STR_MTFTP6_SB),             &gEfiMtftp6ServiceBindingProtocolGuid,            NULL},\r
2188   {STRING_TOKEN(STR_MTFTP6),                &gEfiMtftp6ProtocolGuid,                          NULL},\r
2189   {STRING_TOKEN(STR_DHCP6_SB),              &gEfiDhcp6ServiceBindingProtocolGuid,             NULL},\r
2190   {STRING_TOKEN(STR_DHCP6),                 &gEfiDhcp6ProtocolGuid,                           NULL},\r
2191   {STRING_TOKEN(STR_UDP6_SB),               &gEfiUdp6ServiceBindingProtocolGuid,              NULL},\r
2192   {STRING_TOKEN(STR_UDP6),                  &gEfiUdp6ProtocolGuid,                            NULL},\r
2193   {STRING_TOKEN(STR_TCP6_SB),               &gEfiTcp6ServiceBindingProtocolGuid,              NULL},\r
2194   {STRING_TOKEN(STR_TCP6),                  &gEfiTcp6ProtocolGuid,                            NULL},\r
2195   {STRING_TOKEN(STR_VLAN_CONFIG),           &gEfiVlanConfigProtocolGuid,                      NULL},\r
2196   {STRING_TOKEN(STR_EAP),                   &gEfiEapProtocolGuid,                             NULL},\r
2197   {STRING_TOKEN(STR_EAP_MGMT),              &gEfiEapManagementProtocolGuid,                   NULL},\r
2198   {STRING_TOKEN(STR_FTP4_SB),               &gEfiFtp4ServiceBindingProtocolGuid,              NULL},\r
2199   {STRING_TOKEN(STR_FTP4),                  &gEfiFtp4ProtocolGuid,                            NULL},\r
2200   {STRING_TOKEN(STR_IP_SEC_CONFIG),         &gEfiIpSecConfigProtocolGuid,                     NULL},\r
2201   {STRING_TOKEN(STR_DH),                    &gEfiDriverHealthProtocolGuid,                    NULL},\r
2202   {STRING_TOKEN(STR_DEF_IMG_LOAD),          &gEfiDeferredImageLoadProtocolGuid,               NULL},\r
2203   {STRING_TOKEN(STR_USER_CRED),             &gEfiUserCredentialProtocolGuid,                  NULL},\r
2204   {STRING_TOKEN(STR_USER_MNGR),             &gEfiUserManagerProtocolGuid,                     NULL},\r
2205   {STRING_TOKEN(STR_ATA_PASS_THRU),         &gEfiAtaPassThruProtocolGuid,                     NULL},\r
2206 \r
2207 //\r
2208 // UEFI 2.3\r
2209 //\r
2210   {STRING_TOKEN(STR_FW_MGMT),               &gEfiFirmwareManagementProtocolGuid,              FirmwareManagementDumpInformation},\r
2211   {STRING_TOKEN(STR_IP_SEC),                &gEfiIpSecProtocolGuid,                           NULL},\r
2212   {STRING_TOKEN(STR_IP_SEC2),               &gEfiIpSec2ProtocolGuid,                          NULL},\r
2213 \r
2214 //\r
2215 // UEFI 2.3.1\r
2216 //\r
2217   {STRING_TOKEN(STR_KMS),                   &gEfiKmsProtocolGuid,                             NULL},\r
2218   {STRING_TOKEN(STR_BLK_IO2),               &gEfiBlockIo2ProtocolGuid,                        NULL},\r
2219   {STRING_TOKEN(STR_SSC),                   &gEfiStorageSecurityCommandProtocolGuid,          NULL},\r
2220   {STRING_TOKEN(STR_UCRED2),                &gEfiUserCredential2ProtocolGuid,                 NULL},\r
2221 \r
2222 //\r
2223 // UEFI 2.4\r
2224 //\r
2225   {STRING_TOKEN(STR_DISK_IO2),              &gEfiDiskIo2ProtocolGuid,                         NULL},\r
2226   {STRING_TOKEN(STR_ADAPTER_INFO),          &gEfiAdapterInformationProtocolGuid,              AdapterInformationDumpInformation},\r
2227 \r
2228 //\r
2229 // UEFI2.5\r
2230 //\r
2231   {STRING_TOKEN(STR_TLS_SB),                &gEfiTlsServiceBindingProtocolGuid,              NULL},\r
2232   {STRING_TOKEN(STR_TLS),                   &gEfiTlsProtocolGuid,                            NULL},\r
2233   {STRING_TOKEN(STR_TLS_CONFIG),            &gEfiTlsConfigurationProtocolGuid,               NULL},\r
2234   {STRING_TOKEN(STR_SUPPLICANT_SB),         &gEfiSupplicantServiceBindingProtocolGuid,       NULL},\r
2235   {STRING_TOKEN(STR_SUPPLICANT),            &gEfiSupplicantProtocolGuid,                     NULL},\r
2236 \r
2237 //\r
2238 // UEFI2.6\r
2239 //\r
2240   {STRING_TOKEN(STR_WIFI2),                 &gEfiWiFi2ProtocolGuid,                          NULL},\r
2241   {STRING_TOKEN(STR_RAMDISK),               &gEfiRamDiskProtocolGuid,                        NULL},\r
2242   {STRING_TOKEN(STR_HII_ID),                &gEfiHiiImageDecoderProtocolGuid,                NULL},\r
2243   {STRING_TOKEN(STR_HII_IE),                &gEfiHiiImageExProtocolGuid,                     NULL},\r
2244   {STRING_TOKEN(STR_SD_MPT),                &gEfiSdMmcPassThruProtocolGuid,                  NULL},\r
2245   {STRING_TOKEN(STR_ERASE_BLOCK),           &gEfiEraseBlockProtocolGuid,                     NULL},\r
2246 \r
2247 //\r
2248 // UEFI2.7\r
2249 //\r
2250   {STRING_TOKEN(STR_BLUETOOTH_ATTR),        &gEfiBluetoothAttributeProtocolGuid,               NULL},\r
2251   {STRING_TOKEN(STR_BLUETOOTH_ATTR_SB),     &gEfiBluetoothAttributeServiceBindingProtocolGuid, NULL},\r
2252   {STRING_TOKEN(STR_BLUETOOTH_LE_CONFIG),   &gEfiBluetoothLeConfigProtocolGuid,                NULL},\r
2253   {STRING_TOKEN(STR_UFS_DEV_CONFIG),        &gEfiUfsDeviceConfigProtocolGuid,                  NULL},\r
2254   {STRING_TOKEN(STR_HTTP_BOOT_CALL),        &gEfiHttpBootCallbackProtocolGuid,                 NULL},\r
2255   {STRING_TOKEN(STR_RESET_NOTI),            &gEfiResetNotificationProtocolGuid,                NULL},\r
2256   {STRING_TOKEN(STR_PARTITION_INFO),        &gEfiPartitionInfoProtocolGuid,                    PartitionInfoProtocolDumpInformation},\r
2257   {STRING_TOKEN(STR_HII_POPUP),             &gEfiHiiPopupProtocolGuid,                         NULL},\r
2258 \r
2259 //\r
2260 // PI Spec ones\r
2261 //\r
2262   {STRING_TOKEN(STR_IDE_CONT_INIT),         &gEfiIdeControllerInitProtocolGuid,               NULL},\r
2263   {STRING_TOKEN(STR_DISK_INFO),             &gEfiDiskInfoProtocolGuid,                        NULL},\r
2264 \r
2265 //\r
2266 // PI Spec 1.0\r
2267 //\r
2268   {STRING_TOKEN(STR_BDS_ARCH),              &gEfiBdsArchProtocolGuid,                         NULL},\r
2269   {STRING_TOKEN(STR_CPU_ARCH),              &gEfiCpuArchProtocolGuid,                         NULL},\r
2270   {STRING_TOKEN(STR_MET_ARCH),              &gEfiMetronomeArchProtocolGuid,                   NULL},\r
2271   {STRING_TOKEN(STR_MON_ARCH),              &gEfiMonotonicCounterArchProtocolGuid,            NULL},\r
2272   {STRING_TOKEN(STR_RTC_ARCH),              &gEfiRealTimeClockArchProtocolGuid,               NULL},\r
2273   {STRING_TOKEN(STR_RESET_ARCH),            &gEfiResetArchProtocolGuid,                       NULL},\r
2274   {STRING_TOKEN(STR_RT_ARCH),               &gEfiRuntimeArchProtocolGuid,                     NULL},\r
2275   {STRING_TOKEN(STR_SEC_ARCH),              &gEfiSecurityArchProtocolGuid,                    NULL},\r
2276   {STRING_TOKEN(STR_TIMER_ARCH),            &gEfiTimerArchProtocolGuid,                       NULL},\r
2277   {STRING_TOKEN(STR_VAR_ARCH),              &gEfiVariableWriteArchProtocolGuid,               NULL},\r
2278   {STRING_TOKEN(STR_V_ARCH),                &gEfiVariableArchProtocolGuid,                    NULL},\r
2279   {STRING_TOKEN(STR_SECP),                  &gEfiSecurityPolicyProtocolGuid,                  NULL},\r
2280   {STRING_TOKEN(STR_WDT_ARCH),              &gEfiWatchdogTimerArchProtocolGuid,               NULL},\r
2281   {STRING_TOKEN(STR_SCR),                   &gEfiStatusCodeRuntimeProtocolGuid,               NULL},\r
2282   {STRING_TOKEN(STR_SMB_HC),                &gEfiSmbusHcProtocolGuid,                         NULL},\r
2283   {STRING_TOKEN(STR_FV_2),                  &gEfiFirmwareVolume2ProtocolGuid,                 NULL},\r
2284   {STRING_TOKEN(STR_FV_BLOCK),              &gEfiFirmwareVolumeBlockProtocolGuid,             NULL},\r
2285   {STRING_TOKEN(STR_CAP_ARCH),              &gEfiCapsuleArchProtocolGuid,                     NULL},\r
2286   {STRING_TOKEN(STR_MP_SERVICE),            &gEfiMpServiceProtocolGuid,                       NULL},\r
2287   {STRING_TOKEN(STR_HBRAP),                 &gEfiPciHostBridgeResourceAllocationProtocolGuid, NULL},\r
2288   {STRING_TOKEN(STR_PCIP),                  &gEfiPciPlatformProtocolGuid,                     NULL},\r
2289   {STRING_TOKEN(STR_PCIO),                  &gEfiPciOverrideProtocolGuid,                     NULL},\r
2290   {STRING_TOKEN(STR_PCIE),                  &gEfiPciEnumerationCompleteProtocolGuid,          NULL},\r
2291   {STRING_TOKEN(STR_IPCID),                 &gEfiIncompatiblePciDeviceSupportProtocolGuid,    NULL},\r
2292   {STRING_TOKEN(STR_PCIHPI),                &gEfiPciHotPlugInitProtocolGuid,                  NULL},\r
2293   {STRING_TOKEN(STR_PCIHPR),                &gEfiPciHotPlugRequestProtocolGuid,               NULL},\r
2294   {STRING_TOKEN(STR_SMBIOS),                &gEfiSmbiosProtocolGuid,                          NULL},\r
2295   {STRING_TOKEN(STR_S3_SAVE),               &gEfiS3SaveStateProtocolGuid,                     NULL},\r
2296   {STRING_TOKEN(STR_S3_S_SMM),              &gEfiS3SmmSaveStateProtocolGuid,                  NULL},\r
2297   {STRING_TOKEN(STR_RSC),                   &gEfiRscHandlerProtocolGuid,                      NULL},\r
2298   {STRING_TOKEN(STR_S_RSC),                 &gEfiSmmRscHandlerProtocolGuid,                   NULL},\r
2299   {STRING_TOKEN(STR_ACPI_SDT),              &gEfiAcpiSdtProtocolGuid,                         NULL},\r
2300   {STRING_TOKEN(STR_SIO),                   &gEfiSioProtocolGuid,                             NULL},\r
2301   {STRING_TOKEN(STR_S_CPU2),                &gEfiSmmCpuIo2ProtocolGuid,                       NULL},\r
2302   {STRING_TOKEN(STR_S_BASE2),               &gEfiSmmBase2ProtocolGuid,                        NULL},\r
2303   {STRING_TOKEN(STR_S_ACC_2),               &gEfiSmmAccess2ProtocolGuid,                      NULL},\r
2304   {STRING_TOKEN(STR_S_CON_2),               &gEfiSmmControl2ProtocolGuid,                     NULL},\r
2305   {STRING_TOKEN(STR_S_CONFIG),              &gEfiSmmConfigurationProtocolGuid,                NULL},\r
2306   {STRING_TOKEN(STR_S_RTL),                 &gEfiSmmReadyToLockProtocolGuid,                  NULL},\r
2307   {STRING_TOKEN(STR_DS_RTL),                &gEfiDxeSmmReadyToLockProtocolGuid,               NULL},\r
2308   {STRING_TOKEN(STR_S_COMM),                &gEfiSmmCommunicationProtocolGuid,                NULL},\r
2309   {STRING_TOKEN(STR_S_STAT),                &gEfiSmmStatusCodeProtocolGuid,                   NULL},\r
2310   {STRING_TOKEN(STR_S_CPU),                 &gEfiSmmCpuProtocolGuid,                          NULL},\r
2311   {STRING_TOKEN(STR_S_PCIRBIO),             &gEfiSmmPciRootBridgeIoProtocolGuid,              NULL},\r
2312   {STRING_TOKEN(STR_S_SWD),                 &gEfiSmmSwDispatch2ProtocolGuid,                  NULL},\r
2313   {STRING_TOKEN(STR_S_SXD),                 &gEfiSmmSxDispatch2ProtocolGuid,                  NULL},\r
2314   {STRING_TOKEN(STR_S_PTD2),                &gEfiSmmPeriodicTimerDispatch2ProtocolGuid,       NULL},\r
2315   {STRING_TOKEN(STR_S_UD2),                 &gEfiSmmUsbDispatch2ProtocolGuid,                 NULL},\r
2316   {STRING_TOKEN(STR_S_GD2),                 &gEfiSmmGpiDispatch2ProtocolGuid,                 NULL},\r
2317   {STRING_TOKEN(STR_S_SBD2),                &gEfiSmmStandbyButtonDispatch2ProtocolGuid,       NULL},\r
2318   {STRING_TOKEN(STR_S_PBD2),                &gEfiSmmPowerButtonDispatch2ProtocolGuid,         NULL},\r
2319   {STRING_TOKEN(STR_S_ITD2),                &gEfiSmmIoTrapDispatch2ProtocolGuid,              NULL},\r
2320   {STRING_TOKEN(STR_PCD),                   &gEfiPcdProtocolGuid,                             NULL},\r
2321   {STRING_TOKEN(STR_FVB2),                  &gEfiFirmwareVolumeBlock2ProtocolGuid,            NULL},\r
2322   {STRING_TOKEN(STR_CPUIO2),                &gEfiCpuIo2ProtocolGuid,                          NULL},\r
2323   {STRING_TOKEN(STR_LEGACY_R2),             &gEfiLegacyRegion2ProtocolGuid,                   NULL},\r
2324   {STRING_TOKEN(STR_SAL_MIP),               &gEfiSalMcaInitPmiProtocolGuid,                   NULL},\r
2325   {STRING_TOKEN(STR_ES_BS),                 &gEfiExtendedSalBootServiceProtocolGuid,          NULL},\r
2326   {STRING_TOKEN(STR_ES_BIO),                &gEfiExtendedSalBaseIoServicesProtocolGuid,       NULL},\r
2327   {STRING_TOKEN(STR_ES_STALL),              &gEfiExtendedSalStallServicesProtocolGuid,        NULL},\r
2328   {STRING_TOKEN(STR_ES_RTC),                &gEfiExtendedSalRtcServicesProtocolGuid,          NULL},\r
2329   {STRING_TOKEN(STR_ES_VS),                 &gEfiExtendedSalVariableServicesProtocolGuid,     NULL},\r
2330   {STRING_TOKEN(STR_ES_MTC),                &gEfiExtendedSalMtcServicesProtocolGuid,          NULL},\r
2331   {STRING_TOKEN(STR_ES_RESET),              &gEfiExtendedSalResetServicesProtocolGuid,        NULL},\r
2332   {STRING_TOKEN(STR_ES_SC),                 &gEfiExtendedSalStatusCodeServicesProtocolGuid,   NULL},\r
2333   {STRING_TOKEN(STR_ES_FBS),                &gEfiExtendedSalFvBlockServicesProtocolGuid,      NULL},\r
2334   {STRING_TOKEN(STR_ES_MP),                 &gEfiExtendedSalMpServicesProtocolGuid,           NULL},\r
2335   {STRING_TOKEN(STR_ES_PAL),                &gEfiExtendedSalPalServicesProtocolGuid,          NULL},\r
2336   {STRING_TOKEN(STR_ES_BASE),               &gEfiExtendedSalBaseServicesProtocolGuid,         NULL},\r
2337   {STRING_TOKEN(STR_ES_MCA),                &gEfiExtendedSalMcaServicesProtocolGuid,          NULL},\r
2338   {STRING_TOKEN(STR_ES_PCI),                &gEfiExtendedSalPciServicesProtocolGuid,          NULL},\r
2339   {STRING_TOKEN(STR_ES_CACHE),              &gEfiExtendedSalCacheServicesProtocolGuid,        NULL},\r
2340   {STRING_TOKEN(STR_ES_MCA_LOG),            &gEfiExtendedSalMcaLogServicesProtocolGuid,       NULL},\r
2341   {STRING_TOKEN(STR_S2ARCH),                &gEfiSecurity2ArchProtocolGuid,                   NULL},\r
2342   {STRING_TOKEN(STR_EODXE),                 &gEfiSmmEndOfDxeProtocolGuid,                     NULL},\r
2343   {STRING_TOKEN(STR_ISAHC),                 &gEfiIsaHcProtocolGuid,                           NULL},\r
2344   {STRING_TOKEN(STR_ISAHC_B),               &gEfiIsaHcServiceBindingProtocolGuid,             NULL},\r
2345   {STRING_TOKEN(STR_SIO_C),                 &gEfiSioControlProtocolGuid,                      NULL},\r
2346   {STRING_TOKEN(STR_GET_PCD),               &gEfiGetPcdInfoProtocolGuid,                      NULL},\r
2347   {STRING_TOKEN(STR_I2C_M),                 &gEfiI2cMasterProtocolGuid,                       NULL},\r
2348   {STRING_TOKEN(STR_I2CIO),                 &gEfiI2cIoProtocolGuid,                           NULL},\r
2349   {STRING_TOKEN(STR_I2CEN),                 &gEfiI2cEnumerateProtocolGuid,                    NULL},\r
2350   {STRING_TOKEN(STR_I2C_H),                 &gEfiI2cHostProtocolGuid,                         NULL},\r
2351   {STRING_TOKEN(STR_I2C_BCM),               &gEfiI2cBusConfigurationManagementProtocolGuid,   NULL},\r
2352   {STRING_TOKEN(STR_TREE),                  &gEfiTrEEProtocolGuid,                            NULL},\r
2353   {STRING_TOKEN(STR_TCG2),                  &gEfiTcg2ProtocolGuid,                            NULL},\r
2354   {STRING_TOKEN(STR_TIMESTAMP),             &gEfiTimestampProtocolGuid,                       NULL},\r
2355   {STRING_TOKEN(STR_RNG),                   &gEfiRngProtocolGuid,                             NULL},\r
2356   {STRING_TOKEN(STR_NVMEPT),                &gEfiNvmExpressPassThruProtocolGuid,              NULL},\r
2357   {STRING_TOKEN(STR_H2_SB),                 &gEfiHash2ServiceBindingProtocolGuid,             NULL},\r
2358   {STRING_TOKEN(STR_HASH2),                 &gEfiHash2ProtocolGuid,                           NULL},\r
2359   {STRING_TOKEN(STR_BIO_C),                 &gEfiBlockIoCryptoProtocolGuid,                   NULL},\r
2360   {STRING_TOKEN(STR_SCR),                   &gEfiSmartCardReaderProtocolGuid,                 NULL},\r
2361   {STRING_TOKEN(STR_SCE),                   &gEfiSmartCardEdgeProtocolGuid,                   NULL},\r
2362   {STRING_TOKEN(STR_USB_FIO),               &gEfiUsbFunctionIoProtocolGuid,                   NULL},\r
2363   {STRING_TOKEN(STR_BC_HC),                 &gEfiBluetoothHcProtocolGuid,                     NULL},\r
2364   {STRING_TOKEN(STR_BC_IO_SB),              &gEfiBluetoothIoServiceBindingProtocolGuid,       NULL},\r
2365   {STRING_TOKEN(STR_BC_IO),                 &gEfiBluetoothIoProtocolGuid,                     NULL},\r
2366   {STRING_TOKEN(STR_BC_C),                  &gEfiBluetoothConfigProtocolGuid,                 NULL},\r
2367   {STRING_TOKEN(STR_REG_EXP),               &gEfiRegularExpressionProtocolGuid,               NULL},\r
2368   {STRING_TOKEN(STR_B_MGR_P),               &gEfiBootManagerPolicyProtocolGuid,               NULL},\r
2369   {STRING_TOKEN(STR_CKH),                   &gEfiConfigKeywordHandlerProtocolGuid,            NULL},\r
2370   {STRING_TOKEN(STR_WIFI),                  &gEfiWiFiProtocolGuid,                            NULL},\r
2371   {STRING_TOKEN(STR_EAP_M),                 &gEfiEapManagement2ProtocolGuid,                  NULL},\r
2372   {STRING_TOKEN(STR_EAP_C),                 &gEfiEapConfigurationProtocolGuid,                NULL},\r
2373   {STRING_TOKEN(STR_PKCS7),                 &gEfiPkcs7VerifyProtocolGuid,                     NULL},\r
2374   {STRING_TOKEN(STR_NET_DNS4_SB),           &gEfiDns4ServiceBindingProtocolGuid,              NULL},\r
2375   {STRING_TOKEN(STR_NET_DNS4),              &gEfiDns4ProtocolGuid,                            NULL},\r
2376   {STRING_TOKEN(STR_NET_DNS6_SB),           &gEfiDns6ServiceBindingProtocolGuid,              NULL},\r
2377   {STRING_TOKEN(STR_NET_DNS6),              &gEfiDns6ProtocolGuid,                            NULL},\r
2378   {STRING_TOKEN(STR_NET_HTTP_SB),           &gEfiHttpServiceBindingProtocolGuid,              NULL},\r
2379   {STRING_TOKEN(STR_NET_HTTP),              &gEfiHttpProtocolGuid,                            NULL},\r
2380   {STRING_TOKEN(STR_NET_HTTP_U),            &gEfiHttpUtilitiesProtocolGuid,                   NULL},\r
2381   {STRING_TOKEN(STR_REST),                  &gEfiRestProtocolGuid,                            NULL},\r
2382 \r
2383 //\r
2384 // PI 1.5\r
2385 //\r
2386   {STRING_TOKEN(STR_MM_EOD),                &gEfiMmEndOfDxeProtocolGuid,                      NULL},\r
2387   {STRING_TOKEN(STR_MM_ITD),                &gEfiMmIoTrapDispatchProtocolGuid,                NULL},\r
2388   {STRING_TOKEN(STR_MM_PBD),                &gEfiMmPowerButtonDispatchProtocolGuid,           NULL},\r
2389   {STRING_TOKEN(STR_MM_SBD),                &gEfiMmStandbyButtonDispatchProtocolGuid,         NULL},\r
2390   {STRING_TOKEN(STR_MM_GD),                 &gEfiMmGpiDispatchProtocolGuid,                   NULL},\r
2391   {STRING_TOKEN(STR_MM_UD),                 &gEfiMmUsbDispatchProtocolGuid,                   NULL},\r
2392   {STRING_TOKEN(STR_MM_PTD),                &gEfiMmPeriodicTimerDispatchProtocolGuid,         NULL},\r
2393   {STRING_TOKEN(STR_MM_SXD),                &gEfiMmSxDispatchProtocolGuid,                    NULL},\r
2394   {STRING_TOKEN(STR_MM_SWD),                &gEfiMmSwDispatchProtocolGuid,                    NULL},\r
2395   {STRING_TOKEN(STR_MM_PRBI),               &gEfiMmPciRootBridgeIoProtocolGuid,               NULL},\r
2396   {STRING_TOKEN(STR_MM_CPU),                &gEfiMmCpuProtocolGuid,                           NULL},\r
2397   {STRING_TOKEN(STR_MM_STACODE),            &gEfiMmStatusCodeProtocolGuid,                    NULL},\r
2398   {STRING_TOKEN(STR_DXEMM_RTL),             &gEfiDxeMmReadyToLockProtocolGuid,                NULL},\r
2399   {STRING_TOKEN(STR_MM_CONFIG),             &gEfiMmConfigurationProtocolGuid,                 NULL},\r
2400   {STRING_TOKEN(STR_MM_RTL),                &gEfiMmReadyToLockProtocolGuid,                   NULL},\r
2401   {STRING_TOKEN(STR_MM_CONTROL),            &gEfiMmControlProtocolGuid,                       NULL},\r
2402   {STRING_TOKEN(STR_MM_ACCESS),             &gEfiMmAccessProtocolGuid,                        NULL},\r
2403   {STRING_TOKEN(STR_MM_BASE),               &gEfiMmBaseProtocolGuid,                          NULL},\r
2404   {STRING_TOKEN(STR_MM_CPUIO),              &gEfiMmCpuIoProtocolGuid,                         NULL},\r
2405   {STRING_TOKEN(STR_MM_RH),                 &gEfiMmRscHandlerProtocolGuid,                    NULL},\r
2406   {STRING_TOKEN(STR_MM_COM),                &gEfiMmCommunicationProtocolGuid,                 NULL},\r
2407 \r
2408 //\r
2409 // UEFI Shell Spec 2.0\r
2410 //\r
2411   {STRING_TOKEN(STR_SHELL_PARAMETERS),      &gEfiShellParametersProtocolGuid,                 NULL},\r
2412   {STRING_TOKEN(STR_SHELL),                 &gEfiShellProtocolGuid,                           NULL},\r
2413 \r
2414 //\r
2415 // UEFI Shell Spec 2.1\r
2416 //\r
2417   {STRING_TOKEN(STR_SHELL_DYNAMIC),         &gEfiShellDynamicCommandProtocolGuid,             NULL},\r
2418 \r
2419 //\r
2420 // Misc\r
2421 //\r
2422   {STRING_TOKEN(STR_PCDINFOPROT),           &gGetPcdInfoProtocolGuid,                         NULL},\r
2423 \r
2424 //\r
2425 // terminator\r
2426 //\r
2427   {0,                                       NULL,                                             NULL},\r
2428 };\r
2429 \r
2430 /**\r
2431   Function to get the node for a protocol or struct from it's GUID.\r
2432 \r
2433   if Guid is NULL, then ASSERT.\r
2434 \r
2435   @param[in] Guid               The GUID to look for the name of.\r
2436 \r
2437   @return                       The node.\r
2438 **/\r
2439 CONST GUID_INFO_BLOCK *\r
2440 InternalShellGetNodeFromGuid(\r
2441   IN CONST EFI_GUID* Guid\r
2442   )\r
2443 {\r
2444   CONST GUID_INFO_BLOCK *ListWalker;\r
2445   UINTN                 LoopCount;\r
2446 \r
2447   ASSERT(Guid != NULL);\r
2448 \r
2449   for (LoopCount = 0, ListWalker = mGuidList; mGuidList != NULL && LoopCount < mGuidListCount; LoopCount++, ListWalker++) {\r
2450     if (CompareGuid(ListWalker->GuidId, Guid)) {\r
2451       return (ListWalker);\r
2452     }\r
2453   }\r
2454 \r
2455   if (PcdGetBool(PcdShellIncludeNtGuids)) {\r
2456     for (ListWalker = mGuidStringListNT ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {\r
2457       if (CompareGuid(ListWalker->GuidId, Guid)) {\r
2458         return (ListWalker);\r
2459       }\r
2460     }\r
2461   }\r
2462   for (ListWalker = mGuidStringList ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {\r
2463     if (CompareGuid(ListWalker->GuidId, Guid)) {\r
2464       return (ListWalker);\r
2465     }\r
2466   }\r
2467   return (NULL);\r
2468 }\r
2469 \r
2470 /**\r
2471 Function to add a new GUID/Name mapping.\r
2472 \r
2473 @param[in] Guid       The Guid\r
2474 @param[in] NameID     The STRING id of the HII string to use\r
2475 @param[in] DumpFunc   The pointer to the dump function\r
2476 \r
2477 \r
2478 @retval EFI_SUCCESS           The operation was sucessful\r
2479 @retval EFI_OUT_OF_RESOURCES  A memory allocation failed\r
2480 @retval EFI_INVALID_PARAMETER Guid NameId was invalid\r
2481 **/\r
2482 EFI_STATUS\r
2483 InsertNewGuidNameMapping(\r
2484   IN CONST EFI_GUID           *Guid,\r
2485   IN CONST EFI_STRING_ID      NameID,\r
2486   IN CONST DUMP_PROTOCOL_INFO DumpFunc OPTIONAL\r
2487   )\r
2488 {\r
2489   ASSERT(Guid   != NULL);\r
2490   ASSERT(NameID != 0);\r
2491 \r
2492   mGuidList = ReallocatePool(mGuidListCount * sizeof(GUID_INFO_BLOCK), mGuidListCount+1 * sizeof(GUID_INFO_BLOCK), mGuidList);\r
2493   if (mGuidList == NULL) {\r
2494     mGuidListCount = 0;\r
2495     return (EFI_OUT_OF_RESOURCES);\r
2496   }\r
2497   mGuidListCount++;\r
2498 \r
2499   mGuidList[mGuidListCount - 1].GuidId   = AllocateCopyPool(sizeof(EFI_GUID), Guid);\r
2500   mGuidList[mGuidListCount - 1].StringId = NameID;\r
2501   mGuidList[mGuidListCount - 1].DumpInfo = DumpFunc;\r
2502 \r
2503   if (mGuidList[mGuidListCount - 1].GuidId == NULL) {\r
2504     return (EFI_OUT_OF_RESOURCES);\r
2505   }\r
2506 \r
2507   return (EFI_SUCCESS);\r
2508 }\r
2509 \r
2510 /**\r
2511   Function to add a new GUID/Name mapping.\r
2512 \r
2513   This cannot overwrite an existing mapping.\r
2514 \r
2515   @param[in] Guid       The Guid\r
2516   @param[in] TheName    The Guid's name\r
2517   @param[in] Lang       RFC4646 language code list or NULL\r
2518 \r
2519   @retval EFI_SUCCESS           The operation was sucessful\r
2520   @retval EFI_ACCESS_DENIED     There was a duplicate\r
2521   @retval EFI_OUT_OF_RESOURCES  A memory allocation failed\r
2522   @retval EFI_INVALID_PARAMETER Guid or TheName was NULL\r
2523 **/\r
2524 EFI_STATUS\r
2525 EFIAPI\r
2526 AddNewGuidNameMapping(\r
2527   IN CONST EFI_GUID *Guid,\r
2528   IN CONST CHAR16   *TheName,\r
2529   IN CONST CHAR8    *Lang OPTIONAL\r
2530   )\r
2531 {\r
2532   EFI_STRING_ID         NameID;\r
2533 \r
2534   HandleParsingHiiInit();\r
2535 \r
2536   if (Guid == NULL || TheName == NULL){\r
2537     return (EFI_INVALID_PARAMETER);\r
2538   }\r
2539 \r
2540   if ((InternalShellGetNodeFromGuid(Guid)) != NULL) {\r
2541     return (EFI_ACCESS_DENIED);\r
2542   }\r
2543 \r
2544   NameID = HiiSetString(mHandleParsingHiiHandle, 0, (CHAR16*)TheName, Lang);\r
2545   if (NameID == 0) {\r
2546     return (EFI_OUT_OF_RESOURCES);\r
2547   }\r
2548 \r
2549   return (InsertNewGuidNameMapping(Guid, NameID, NULL));\r
2550 }\r
2551 \r
2552 /**\r
2553   Function to get the name of a protocol or struct from it's GUID.\r
2554 \r
2555   if Guid is NULL, then ASSERT.\r
2556 \r
2557   @param[in] Guid               The GUID to look for the name of.\r
2558   @param[in] Lang               The language to use.\r
2559 \r
2560   @return                       pointer to string of the name.  The caller\r
2561                                 is responsible to free this memory.\r
2562 **/\r
2563 CHAR16*\r
2564 EFIAPI\r
2565 GetStringNameFromGuid(\r
2566   IN CONST EFI_GUID *Guid,\r
2567   IN CONST CHAR8    *Lang OPTIONAL\r
2568   )\r
2569 {\r
2570   CONST GUID_INFO_BLOCK *Id;\r
2571 \r
2572   HandleParsingHiiInit();\r
2573 \r
2574   Id = InternalShellGetNodeFromGuid(Guid);\r
2575   if (Id == NULL) {\r
2576     return NULL;\r
2577   }\r
2578   return HiiGetString (mHandleParsingHiiHandle, Id->StringId, Lang);\r
2579 }\r
2580 \r
2581 /**\r
2582   Function to dump protocol information from a handle.\r
2583 \r
2584   This function will return a allocated string buffer containing the\r
2585   information.  The caller is responsible for freeing the memory.\r
2586 \r
2587   If Guid is NULL, ASSERT().\r
2588   If TheHandle is NULL, ASSERT().\r
2589 \r
2590   @param[in] TheHandle      The handle to dump information from.\r
2591   @param[in] Guid           The GUID of the protocol to dump.\r
2592   @param[in] Verbose        TRUE for extra info.  FALSE otherwise.\r
2593 \r
2594   @return                   The pointer to string.\r
2595   @retval NULL              An error was encountered.\r
2596 **/\r
2597 CHAR16*\r
2598 EFIAPI\r
2599 GetProtocolInformationDump(\r
2600   IN CONST EFI_HANDLE TheHandle,\r
2601   IN CONST EFI_GUID   *Guid,\r
2602   IN CONST BOOLEAN    Verbose\r
2603   )\r
2604 {\r
2605   CONST GUID_INFO_BLOCK *Id;\r
2606 \r
2607   ASSERT(TheHandle  != NULL);\r
2608   ASSERT(Guid       != NULL);\r
2609 \r
2610   if (TheHandle == NULL || Guid == NULL) {\r
2611     return (NULL);\r
2612   }\r
2613 \r
2614   Id = InternalShellGetNodeFromGuid(Guid);\r
2615   if (Id != NULL && Id->DumpInfo != NULL) {\r
2616     return (Id->DumpInfo(TheHandle, Verbose));\r
2617   }\r
2618   return (NULL);\r
2619 }\r
2620 \r
2621 /**\r
2622   Function to get the Guid for a protocol or struct based on it's string name.\r
2623 \r
2624   do not modify the returned Guid.\r
2625 \r
2626   @param[in] Name           The pointer to the string name.\r
2627   @param[in] Lang           The pointer to the language code.\r
2628   @param[out] Guid          The pointer to the Guid.\r
2629 \r
2630   @retval EFI_SUCCESS       The operation was sucessful.\r
2631 **/\r
2632 EFI_STATUS\r
2633 EFIAPI\r
2634 GetGuidFromStringName(\r
2635   IN CONST CHAR16 *Name,\r
2636   IN CONST CHAR8  *Lang OPTIONAL,\r
2637   OUT EFI_GUID    **Guid\r
2638   )\r
2639 {\r
2640   CONST GUID_INFO_BLOCK  *ListWalker;\r
2641   CHAR16                     *String;\r
2642   UINTN                  LoopCount;\r
2643 \r
2644   HandleParsingHiiInit();\r
2645 \r
2646   ASSERT(Guid != NULL);\r
2647   if (Guid == NULL) {\r
2648     return (EFI_INVALID_PARAMETER);\r
2649   }\r
2650   *Guid = NULL;\r
2651 \r
2652   if (PcdGetBool(PcdShellIncludeNtGuids)) {\r
2653     for (ListWalker = mGuidStringListNT ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {\r
2654       String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);\r
2655       if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {\r
2656         *Guid = ListWalker->GuidId;\r
2657       }\r
2658       SHELL_FREE_NON_NULL(String);\r
2659       if (*Guid != NULL) {\r
2660         return (EFI_SUCCESS);\r
2661       }\r
2662     }\r
2663   }\r
2664   for (ListWalker = mGuidStringList ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {\r
2665     String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);\r
2666     if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {\r
2667       *Guid = ListWalker->GuidId;\r
2668     }\r
2669     SHELL_FREE_NON_NULL(String);\r
2670     if (*Guid != NULL) {\r
2671       return (EFI_SUCCESS);\r
2672     }\r
2673   }\r
2674 \r
2675   for (LoopCount = 0, ListWalker = mGuidList; mGuidList != NULL && LoopCount < mGuidListCount; LoopCount++, ListWalker++) {\r
2676     String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);\r
2677     if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {\r
2678       *Guid = ListWalker->GuidId;\r
2679     }\r
2680     SHELL_FREE_NON_NULL(String);\r
2681     if (*Guid != NULL) {\r
2682       return (EFI_SUCCESS);\r
2683     }\r
2684   }\r
2685 \r
2686   return (EFI_NOT_FOUND);\r
2687 }\r
2688 \r
2689 /**\r
2690   Get best support language for this driver.\r
2691 \r
2692   First base on the user input language  to search, second base on the current\r
2693   platform used language to search, third get the first language from the\r
2694   support language list. The caller need to free the buffer of the best language.\r
2695 \r
2696   @param[in] SupportedLanguages      The support languages for this driver.\r
2697   @param[in] InputLanguage           The user input language.\r
2698   @param[in] Iso639Language          Whether get language for ISO639.\r
2699 \r
2700   @return                            The best support language for this driver.\r
2701 **/\r
2702 CHAR8 *\r
2703 EFIAPI\r
2704 GetBestLanguageForDriver (\r
2705   IN CONST CHAR8  *SupportedLanguages,\r
2706   IN CONST CHAR8  *InputLanguage,\r
2707   IN BOOLEAN      Iso639Language\r
2708   )\r
2709 {\r
2710   CHAR8                         *LanguageVariable;\r
2711   CHAR8                         *BestLanguage;\r
2712 \r
2713   GetVariable2 (Iso639Language ? L"Lang" : L"PlatformLang", &gEfiGlobalVariableGuid, (VOID**)&LanguageVariable, NULL);\r
2714 \r
2715   BestLanguage = GetBestLanguage(\r
2716                    SupportedLanguages,\r
2717                    Iso639Language,\r
2718                    (InputLanguage != NULL) ? InputLanguage : "",\r
2719                    (LanguageVariable != NULL) ? LanguageVariable : "",\r
2720                    SupportedLanguages,\r
2721                    NULL\r
2722                    );\r
2723 \r
2724   if (LanguageVariable != NULL) {\r
2725     FreePool (LanguageVariable);\r
2726   }\r
2727 \r
2728   return BestLanguage;\r
2729 }\r
2730 \r
2731 /**\r
2732   Function to retrieve the driver name (if possible) from the ComponentName or\r
2733   ComponentName2 protocol\r
2734 \r
2735   @param[in] TheHandle      The driver handle to get the name of.\r
2736   @param[in] Language       The language to use.\r
2737 \r
2738   @retval NULL              The name could not be found.\r
2739   @return                   A pointer to the string name.  Do not de-allocate the memory.\r
2740 **/\r
2741 CONST CHAR16*\r
2742 EFIAPI\r
2743 GetStringNameFromHandle(\r
2744   IN CONST EFI_HANDLE TheHandle,\r
2745   IN CONST CHAR8      *Language\r
2746   )\r
2747 {\r
2748   EFI_COMPONENT_NAME2_PROTOCOL  *CompNameStruct;\r
2749   EFI_STATUS                    Status;\r
2750   CHAR16                        *RetVal;\r
2751   CHAR8                         *BestLang;\r
2752 \r
2753   BestLang = NULL;\r
2754 \r
2755   Status = gBS->OpenProtocol(\r
2756     TheHandle,\r
2757     &gEfiComponentName2ProtocolGuid,\r
2758     (VOID**)&CompNameStruct,\r
2759     gImageHandle,\r
2760     NULL,\r
2761     EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
2762   if (!EFI_ERROR(Status)) {\r
2763     BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);\r
2764     Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);\r
2765     if (BestLang != NULL) {\r
2766       FreePool (BestLang);\r
2767       BestLang = NULL;\r
2768     }\r
2769     if (!EFI_ERROR(Status)) {\r
2770       return (RetVal);\r
2771     }\r
2772   }\r
2773   Status = gBS->OpenProtocol(\r
2774     TheHandle,\r
2775     &gEfiComponentNameProtocolGuid,\r
2776     (VOID**)&CompNameStruct,\r
2777     gImageHandle,\r
2778     NULL,\r
2779     EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
2780   if (!EFI_ERROR(Status)) {\r
2781     BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);\r
2782     Status = CompNameStruct->GetDriverName(CompNameStruct, BestLang, &RetVal);\r
2783     if (BestLang != NULL) {\r
2784       FreePool (BestLang);\r
2785     }\r
2786     if (!EFI_ERROR(Status)) {\r
2787       return (RetVal);\r
2788     }\r
2789   }\r
2790   return (NULL);\r
2791 }\r
2792 \r
2793 /**\r
2794   Function to initialize the file global mHandleList object for use in\r
2795   vonverting handles to index and index to handle.\r
2796 \r
2797   @retval EFI_SUCCESS     The operation was successful.\r
2798 **/\r
2799 EFI_STATUS\r
2800 InternalShellInitHandleList(\r
2801   VOID\r
2802   )\r
2803 {\r
2804   EFI_STATUS   Status;\r
2805   EFI_HANDLE   *HandleBuffer;\r
2806   UINTN        HandleCount;\r
2807   HANDLE_LIST  *ListWalker;\r
2808 \r
2809   if (mHandleList.NextIndex != 0) {\r
2810     return EFI_SUCCESS;\r
2811   }\r
2812   InitializeListHead(&mHandleList.List.Link);\r
2813   mHandleList.NextIndex = 1;\r
2814   Status = gBS->LocateHandleBuffer (\r
2815                 AllHandles,\r
2816                 NULL,\r
2817                 NULL,\r
2818                 &HandleCount,\r
2819                 &HandleBuffer\r
2820                );\r
2821   ASSERT_EFI_ERROR(Status);\r
2822   if (EFI_ERROR(Status)) {\r
2823     return (Status);\r
2824   }\r
2825   for (mHandleList.NextIndex = 1 ; mHandleList.NextIndex <= HandleCount ; mHandleList.NextIndex++){\r
2826     ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));\r
2827     if (ListWalker != NULL) {\r
2828       ListWalker->TheHandle = HandleBuffer[mHandleList.NextIndex - 1];\r
2829       ListWalker->TheIndex = mHandleList.NextIndex;\r
2830       InsertTailList (&mHandleList.List.Link, &ListWalker->Link);\r
2831     }\r
2832   }\r
2833   FreePool(HandleBuffer);\r
2834   return (EFI_SUCCESS);\r
2835 }\r
2836 \r
2837 /**\r
2838   Function to retrieve the human-friendly index of a given handle.  If the handle\r
2839   does not have a index one will be automatically assigned.  The index value is valid\r
2840   until the termination of the shell application.\r
2841 \r
2842   @param[in] TheHandle    The handle to retrieve an index for.\r
2843 \r
2844   @retval 0               A memory allocation failed.\r
2845   @return                 The index of the handle.\r
2846 \r
2847 **/\r
2848 UINTN\r
2849 EFIAPI\r
2850 ConvertHandleToHandleIndex(\r
2851   IN CONST EFI_HANDLE TheHandle\r
2852   )\r
2853 {\r
2854   EFI_STATUS   Status;\r
2855   EFI_GUID     **ProtocolBuffer;\r
2856   UINTN        ProtocolCount;\r
2857   HANDLE_LIST  *ListWalker;\r
2858 \r
2859   if (TheHandle == NULL) {\r
2860     return 0;\r
2861   }\r
2862 \r
2863   InternalShellInitHandleList();\r
2864 \r
2865   for (ListWalker = (HANDLE_LIST*)GetFirstNode(&mHandleList.List.Link)\r
2866     ;  !IsNull(&mHandleList.List.Link,&ListWalker->Link)\r
2867     ;  ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)\r
2868    ){\r
2869     if (ListWalker->TheHandle == TheHandle) {\r
2870       //\r
2871       // Verify that TheHandle is still present in the Handle Database\r
2872       //\r
2873       Status = gBS->ProtocolsPerHandle(TheHandle, &ProtocolBuffer, &ProtocolCount);\r
2874       if (EFI_ERROR (Status)) {\r
2875         //\r
2876         // TheHandle is not present in the Handle Database, so delete from the handle list\r
2877         //\r
2878         RemoveEntryList (&ListWalker->Link);\r
2879         return 0;\r
2880       }\r
2881       FreePool (ProtocolBuffer);\r
2882       return (ListWalker->TheIndex);\r
2883     }\r
2884   }\r
2885 \r
2886   //\r
2887   // Verify that TheHandle is valid handle\r
2888   //\r
2889   Status = gBS->ProtocolsPerHandle(TheHandle, &ProtocolBuffer, &ProtocolCount);\r
2890   if (EFI_ERROR (Status)) {\r
2891     //\r
2892     // TheHandle is not valid, so do not add to handle list\r
2893     //\r
2894     return 0;\r
2895   }\r
2896   FreePool (ProtocolBuffer);\r
2897 \r
2898   ListWalker = AllocateZeroPool(sizeof(HANDLE_LIST));\r
2899   if (ListWalker == NULL) {\r
2900     return 0;\r
2901   }\r
2902   ListWalker->TheHandle = TheHandle;\r
2903   ListWalker->TheIndex  = mHandleList.NextIndex++;\r
2904   InsertTailList(&mHandleList.List.Link,&ListWalker->Link);\r
2905   return (ListWalker->TheIndex);\r
2906 }\r
2907 \r
2908 \r
2909 \r
2910 /**\r
2911   Function to retrieve the EFI_HANDLE from the human-friendly index.\r
2912 \r
2913   @param[in] TheIndex     The index to retrieve the EFI_HANDLE for.\r
2914 \r
2915   @retval NULL            The index was invalid.\r
2916   @return                 The EFI_HANDLE that index represents.\r
2917 \r
2918 **/\r
2919 EFI_HANDLE\r
2920 EFIAPI\r
2921 ConvertHandleIndexToHandle(\r
2922   IN CONST UINTN TheIndex\r
2923   )\r
2924 {\r
2925   EFI_STATUS   Status;\r
2926   EFI_GUID     **ProtocolBuffer;\r
2927   UINTN        ProtocolCount;\r
2928   HANDLE_LIST *ListWalker;\r
2929 \r
2930   InternalShellInitHandleList();\r
2931 \r
2932   if (TheIndex >= mHandleList.NextIndex) {\r
2933     return NULL;\r
2934   }\r
2935 \r
2936   for (ListWalker = (HANDLE_LIST*)GetFirstNode(&mHandleList.List.Link)\r
2937     ;  !IsNull(&mHandleList.List.Link,&ListWalker->Link)\r
2938     ;  ListWalker = (HANDLE_LIST*)GetNextNode(&mHandleList.List.Link,&ListWalker->Link)\r
2939    ){\r
2940     if (ListWalker->TheIndex == TheIndex && ListWalker->TheHandle != NULL) {\r
2941       //\r
2942       // Verify that LinkWalker->TheHandle is valid handle\r
2943       //\r
2944       Status = gBS->ProtocolsPerHandle(ListWalker->TheHandle, &ProtocolBuffer, &ProtocolCount);\r
2945       if (!EFI_ERROR (Status)) {\r
2946         FreePool (ProtocolBuffer);\r
2947       } else {\r
2948         //\r
2949         // TheHandle is not valid, so do not add to handle list\r
2950         //\r
2951         ListWalker->TheHandle = NULL;\r
2952       }\r
2953       return (ListWalker->TheHandle);\r
2954     }\r
2955   }\r
2956   return NULL;\r
2957 }\r
2958 \r
2959 /**\r
2960   Gets all the related EFI_HANDLEs based on the mask supplied.\r
2961 \r
2962   This function scans all EFI_HANDLES in the UEFI environment's handle database\r
2963   and returns the ones with the specified relationship (Mask) to the specified\r
2964   controller handle.\r
2965 \r
2966   If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.\r
2967   If MatchingHandleCount is NULL, then ASSERT.\r
2968 \r
2969   If MatchingHandleBuffer is not NULL upon a successful return the memory must be\r
2970   caller freed.\r
2971 \r
2972   @param[in] DriverBindingHandle    The handle with Driver Binding protocol on it.\r
2973   @param[in] ControllerHandle       The handle with Device Path protocol on it.\r
2974   @param[in] MatchingHandleCount    The pointer to UINTN that specifies the number of HANDLES in\r
2975                                     MatchingHandleBuffer.\r
2976   @param[out] MatchingHandleBuffer  On a successful return, a buffer of MatchingHandleCount\r
2977                                     EFI_HANDLEs with a terminating NULL EFI_HANDLE.\r
2978   @param[out] HandleType            An array of type information.\r
2979 \r
2980   @retval EFI_SUCCESS               The operation was successful, and any related handles\r
2981                                     are in MatchingHandleBuffer.\r
2982   @retval EFI_NOT_FOUND             No matching handles were found.\r
2983   @retval EFI_INVALID_PARAMETER     A parameter was invalid or out of range.\r
2984 **/\r
2985 EFI_STATUS\r
2986 EFIAPI\r
2987 ParseHandleDatabaseByRelationshipWithType (\r
2988   IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,\r
2989   IN CONST EFI_HANDLE ControllerHandle OPTIONAL,\r
2990   IN UINTN            *HandleCount,\r
2991   OUT EFI_HANDLE      **HandleBuffer,\r
2992   OUT UINTN           **HandleType\r
2993   )\r
2994 {\r
2995   EFI_STATUS                          Status;\r
2996   UINTN                               HandleIndex;\r
2997   EFI_GUID                            **ProtocolGuidArray;\r
2998   UINTN                               ArrayCount;\r
2999   UINTN                               ProtocolIndex;\r
3000   EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;\r
3001   UINTN                               OpenInfoCount;\r
3002   UINTN                               OpenInfoIndex;\r
3003   UINTN                               ChildIndex;\r
3004   INTN                                DriverBindingHandleIndex;\r
3005 \r
3006   ASSERT(HandleCount  != NULL);\r
3007   ASSERT(HandleBuffer != NULL);\r
3008   ASSERT(HandleType   != NULL);\r
3009   ASSERT(DriverBindingHandle != NULL || ControllerHandle != NULL);\r
3010 \r
3011   *HandleCount                  = 0;\r
3012   *HandleBuffer                 = NULL;\r
3013   *HandleType                   = NULL;\r
3014 \r
3015   //\r
3016   // Retrieve the list of all handles from the handle database\r
3017   //\r
3018   Status = gBS->LocateHandleBuffer (\r
3019                 AllHandles,\r
3020                 NULL,\r
3021                 NULL,\r
3022                 HandleCount,\r
3023                 HandleBuffer\r
3024                );\r
3025   if (EFI_ERROR (Status)) {\r
3026     return (Status);\r
3027   }\r
3028 \r
3029   *HandleType = AllocateZeroPool (*HandleCount * sizeof (UINTN));\r
3030   if (*HandleType == NULL) {\r
3031     SHELL_FREE_NON_NULL (*HandleBuffer);\r
3032     *HandleCount = 0;\r
3033     return EFI_OUT_OF_RESOURCES;\r
3034   }\r
3035 \r
3036   DriverBindingHandleIndex = -1;\r
3037   for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {\r
3038     if (DriverBindingHandle != NULL && (*HandleBuffer)[HandleIndex] == DriverBindingHandle) {\r
3039       DriverBindingHandleIndex = (INTN)HandleIndex;\r
3040     }\r
3041   }\r
3042 \r
3043   for (HandleIndex = 0; HandleIndex < *HandleCount; HandleIndex++) {\r
3044     //\r
3045     // Retrieve the list of all the protocols on each handle\r
3046     //\r
3047     Status = gBS->ProtocolsPerHandle (\r
3048                   (*HandleBuffer)[HandleIndex],\r
3049                   &ProtocolGuidArray,\r
3050                   &ArrayCount\r
3051                  );\r
3052     if (EFI_ERROR (Status)) {\r
3053       continue;\r
3054     }\r
3055 \r
3056     for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {\r
3057 \r
3058       //\r
3059       // Set the bit describing what this handle has\r
3060       //\r
3061       if        (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiLoadedImageProtocolGuid)         ) {\r
3062         (*HandleType)[HandleIndex] |= (UINTN)HR_IMAGE_HANDLE;\r
3063       } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverBindingProtocolGuid)       ) {\r
3064         (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_BINDING_HANDLE;\r
3065       } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfiguration2ProtocolGuid)) {\r
3066         (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_CONFIGURATION_HANDLE;\r
3067       } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid) ) {\r
3068         (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_CONFIGURATION_HANDLE;\r
3069       } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnostics2ProtocolGuid)  ) {\r
3070         (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_DIAGNOSTICS_HANDLE;\r
3071       } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid)   ) {\r
3072         (*HandleType)[HandleIndex] |= (UINTN)HR_DRIVER_DIAGNOSTICS_HANDLE;\r
3073       } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentName2ProtocolGuid)      ) {\r
3074         (*HandleType)[HandleIndex] |= (UINTN)HR_COMPONENT_NAME_HANDLE;\r
3075       } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiComponentNameProtocolGuid)       ) {\r
3076         (*HandleType)[HandleIndex] |= (UINTN)HR_COMPONENT_NAME_HANDLE;\r
3077       } else if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDevicePathProtocolGuid)          ) {\r
3078         (*HandleType)[HandleIndex] |= (UINTN)HR_DEVICE_HANDLE;\r
3079       }\r
3080       //\r
3081       // Retrieve the list of agents that have opened each protocol\r
3082       //\r
3083       Status = gBS->OpenProtocolInformation (\r
3084                       (*HandleBuffer)[HandleIndex],\r
3085                       ProtocolGuidArray[ProtocolIndex],\r
3086                       &OpenInfo,\r
3087                       &OpenInfoCount\r
3088                      );\r
3089       if (EFI_ERROR (Status)) {\r
3090         continue;\r
3091       }\r
3092 \r
3093       if (ControllerHandle == NULL) {\r
3094         //\r
3095         // ControllerHandle == NULL and DriverBindingHandle != NULL.\r
3096         // Return information on all the controller handles that the driver specified by DriverBindingHandle is managing\r
3097         //\r
3098         for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {\r
3099           if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {\r
3100             (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);\r
3101             if (DriverBindingHandleIndex != -1) {\r
3102               (*HandleType)[DriverBindingHandleIndex] |= (UINTN)HR_DEVICE_DRIVER;\r
3103             }\r
3104           }\r
3105           if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle && (OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
3106             (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);\r
3107             if (DriverBindingHandleIndex != -1) {\r
3108               (*HandleType)[DriverBindingHandleIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER);\r
3109             }\r
3110             for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {\r
3111               if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {\r
3112                 (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE);\r
3113               }\r
3114             }\r
3115           }\r
3116         }\r
3117       }\r
3118       if (DriverBindingHandle == NULL && ControllerHandle != NULL) {\r
3119         if (ControllerHandle == (*HandleBuffer)[HandleIndex]) {\r
3120           (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);\r
3121           for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {\r
3122             if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {\r
3123               for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {\r
3124                 if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {\r
3125                   (*HandleType)[ChildIndex] |= (UINTN)HR_DEVICE_DRIVER;\r
3126                 }\r
3127               }\r
3128             }\r
3129             if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
3130               for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {\r
3131                 if (OpenInfo[OpenInfoIndex].AgentHandle == (*HandleBuffer)[ChildIndex]) {\r
3132                   (*HandleType)[ChildIndex] |= (UINTN)(HR_BUS_DRIVER | HR_DEVICE_DRIVER);\r
3133                 }\r
3134                 if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {\r
3135                   (*HandleType)[ChildIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CHILD_HANDLE);\r
3136                 }\r
3137               }\r
3138             }\r
3139           }\r
3140         } else {\r
3141           for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {\r
3142             if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
3143               if (OpenInfo[OpenInfoIndex].ControllerHandle == ControllerHandle) {\r
3144                 (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_PARENT_HANDLE);\r
3145               }\r
3146             }\r
3147           }\r
3148         }\r
3149       }\r
3150       if (DriverBindingHandle != NULL && ControllerHandle != NULL) {\r
3151         if (ControllerHandle == (*HandleBuffer)[HandleIndex]) {\r
3152           (*HandleType)[HandleIndex] |= (UINTN)(HR_DEVICE_HANDLE | HR_CONTROLLER_HANDLE);\r
3153           for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {\r
3154             if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {\r
3155               if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {\r
3156                 if (DriverBindingHandleIndex != -1) {\r
3157                   (*HandleType)[DriverBindingHandleIndex] |= (UINTN)HR_DEVICE_DRIVER;\r
3158                 }\r
3159               }\r
3160             }\r
3161             if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
3162               if (OpenInfo[OpenInfoIndex].AgentHandle == DriverBindingHandle) {\r
3163                 for (ChildIndex = 0; ChildIndex < *HandleCount; ChildIndex++) {\r
3164                   if (OpenInfo[OpenInfoIndex].ControllerHandle == (*HandleBuffer)[ChildIndex]) {\r