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