1 /** @file
2   Provides interface to advanced shell functionality for parsing both handle and protocol database.
3 
4   Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
5   (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6   (C) Copyright 2013-2016 Hewlett-Packard Development Company, L.P.<BR>
7   SPDX-License-Identifier: BSD-2-Clause-Patent
8 
9 **/
10 
11 #ifndef _UEFI_HANDLE_PARSING_LIB_INTERNAL_H_
12 #define _UEFI_HANDLE_PARSING_LIB_INTERNAL_H_
13 
14 #include <Uefi.h>
15 
16 #include <Guid/FileInfo.h>
17 #include <Guid/ConsoleInDevice.h>
18 #include <Guid/ConsoleOutDevice.h>
19 #include <Guid/StandardErrorDevice.h>
20 #include <Guid/GlobalVariable.h>
21 #include <Guid/Gpt.h>
22 #include <Guid/FileSystemInfo.h>
23 #include <Guid/ShellLibHiiGuid.h>
24 
25 #include <Protocol/SimpleFileSystem.h>
26 #include <Protocol/LoadedImage.h>
27 #include <Protocol/EfiShellInterface.h>
28 #include <Protocol/EfiShellEnvironment2.h>
29 #include <Protocol/Shell.h>
30 #include <Protocol/ShellParameters.h>
31 #include <Protocol/DevicePathToText.h>
32 #include <Protocol/DriverBinding.h>
33 #include <Protocol/DriverConfiguration2.h>
34 #include <Protocol/DriverConfiguration.h>
35 #include <Protocol/DriverDiagnostics2.h>
36 #include <Protocol/DriverDiagnostics.h>
37 #include <Protocol/ComponentName2.h>
38 #include <Protocol/ComponentName.h>
39 #include <Protocol/PlatformDriverOverride.h>
40 #include <Protocol/DevicePathUtilities.h>
41 #include <Protocol/DevicePathFromText.h>
42 #include <Protocol/BusSpecificDriverOverride.h>
43 #include <Protocol/PlatformToDriverConfiguration.h>
44 #include <Protocol/DriverSupportedEfiVersion.h>
45 #include <Protocol/SimpleTextInEx.h>
46 #include <Protocol/SimplePointer.h>
47 #include <Protocol/SerialIo.h>
48 #include <Protocol/AbsolutePointer.h>
49 #include <Protocol/GraphicsOutput.h>
50 #include <Protocol/EdidDiscovered.h>
51 #include <Protocol/EdidActive.h>
52 #include <Protocol/EdidOverride.h>
53 #include <Protocol/LoadFile.h>
54 #include <Protocol/LoadFile2.h>
55 #include <Protocol/TapeIo.h>
56 #include <Protocol/DiskIo.h>
57 #include <Protocol/BlockIo.h>
58 #include <Protocol/UnicodeCollation.h>
59 #include <Protocol/PciRootBridgeIo.h>
60 #include <Protocol/PciIo.h>
61 #include <Protocol/ScsiPassThru.h>
62 #include <Protocol/ScsiPassThruExt.h>
63 #include <Protocol/ScsiIo.h>
64 #include <Protocol/IScsiInitiatorName.h>
65 #include <Protocol/UsbIo.h>
66 #include <Protocol/UsbHostController.h>
67 #include <Protocol/Usb2HostController.h>
68 #include <Protocol/DebugSupport.h>
69 #include <Protocol/DebugPort.h>
70 #include <Protocol/Decompress.h>
71 #include <Protocol/AcpiTable.h>
72 #include <Protocol/Ebc.h>
73 #include <Protocol/SimpleNetwork.h>
74 #include <Protocol/NetworkInterfaceIdentifier.h>
75 #include <Protocol/PxeBaseCode.h>
76 #include <Protocol/PxeBaseCodeCallBack.h>
77 #include <Protocol/Bis.h>
78 #include <Protocol/ManagedNetwork.h>
79 #include <Protocol/Arp.h>
80 #include <Protocol/Dhcp4.h>
81 #include <Protocol/Tcp4.h>
82 #include <Protocol/Ip4.h>
83 #include <Protocol/Ip4Config.h>
84 #include <Protocol/Ip4Config2.h>
85 #include <Protocol/Udp4.h>
86 #include <Protocol/Mtftp4.h>
87 #include <Protocol/AuthenticationInfo.h>
88 #include <Protocol/Hash.h>
89 #include <Protocol/HiiFont.h>
90 #include <Protocol/HiiString.h>
91 #include <Protocol/HiiImage.h>
92 #include <Protocol/HiiDatabase.h>
93 #include <Protocol/HiiConfigRouting.h>
94 #include <Protocol/HiiConfigAccess.h>
95 #include <Protocol/FormBrowser2.h>
96 #include <Protocol/DeviceIo.h>
97 #include <Protocol/UgaDraw.h>
98 #include <Protocol/UgaIo.h>
99 #include <Protocol/DriverConfiguration.h>
100 #include <Protocol/DriverConfiguration2.h>
101 #include <Protocol/DevicePathUtilities.h>
102 //#include <Protocol/FirmwareVolume.h>
103 //#include <Protocol/FirmwareVolume2.h>
104 #include <Protocol/DriverFamilyOverride.h>
105 #include <Protocol/Pcd.h>
106 #include <Protocol/TcgService.h>
107 #include <Protocol/HiiPackageList.h>
108 #include <Protocol/Ip6.h>
109 #include <Protocol/Ip6Config.h>
110 #include <Protocol/Mtftp6.h>
111 #include <Protocol/Dhcp6.h>
112 #include <Protocol/Udp6.h>
113 #include <Protocol/Tcp6.h>
114 #include <Protocol/VlanConfig.h>
115 #include <Protocol/Eap.h>
116 #include <Protocol/EapManagement.h>
117 #include <Protocol/Ftp4.h>
118 #include <Protocol/IpSecConfig.h>
119 #include <Protocol/DriverHealth.h>
120 #include <Protocol/DeferredImageLoad.h>
121 #include <Protocol/UserCredential.h>
122 #include <Protocol/UserManager.h>
123 #include <Protocol/AtaPassThru.h>
124 #include <Protocol/FirmwareManagement.h>
125 #include <Protocol/IpSec.h>
126 #include <Protocol/Kms.h>
127 #include <Protocol/BlockIo2.h>
128 #include <Protocol/StorageSecurityCommand.h>
129 #include <Protocol/UserCredential2.h>
130 #include <Protocol/IdeControllerInit.h>
131 #include <Protocol/DiskIo2.h>
132 #include <Protocol/AdapterInformation.h>
133 #include <Protocol/ShellDynamicCommand.h>
134 #include <Protocol/DiskInfo.h>
135 #include <Protocol/PartitionInfo.h>
136 
137 #include <Library/HandleParsingLib.h>
138 #include <Library/UefiBootServicesTableLib.h>
139 #include <Library/BaseLib.h>
140 #include <Library/BaseMemoryLib.h>
141 #include <Library/DebugLib.h>
142 #include <Library/MemoryAllocationLib.h>
143 #include <Library/DevicePathLib.h>
144 #include <Library/PcdLib.h>
145 #include <Library/PrintLib.h>
146 #include <Library/UefiLib.h>
147 #include <Library/HiiLib.h>
148 #include <Library/ShellLib.h>
149 #include <Library/SortLib.h>
150 #include <Library/ShellCommandLib.h>
151 #include <Library/PeCoffGetEntryPointLib.h>
152 
153 #define   EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1   1
154 #define   EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2   2
155 
156 ///
157 /// EFI_FIRMWARE_IMAGE_DESCRIPTOR in UEFI spec < 2.4a
158 ///
159 typedef struct {
160   ///
161   /// A unique number identifying the firmware image within the device.  The number is
162   /// between 1 and DescriptorCount.
163   ///
164   UINT8                            ImageIndex;
165   ///
166   /// A unique number identifying the firmware image type.
167   ///
168   EFI_GUID                         ImageTypeId;
169   ///
170   /// A unique number identifying the firmware image.
171   ///
172   UINT64                           ImageId;
173   ///
174   /// A pointer to a null-terminated string representing the firmware image name.
175   ///
176   CHAR16                           *ImageIdName;
177   ///
178   /// Identifies the version of the device firmware. The format is vendor specific and new
179   /// version must have a greater value than an old version.
180   ///
181   UINT32                           Version;
182   ///
183   /// A pointer to a null-terminated string representing the firmware image version name.
184   ///
185   CHAR16                           *VersionName;
186   ///
187   /// Size of the image in bytes.  If size=0, then only ImageIndex and ImageTypeId are valid.
188   ///
189   UINTN                            Size;
190   ///
191   /// Image attributes that are supported by this device.  See 'Image Attribute Definitions'
192   /// for possible returned values of this parameter.  A value of 1 indicates the attribute is
193   /// supported and the current setting value is indicated in AttributesSetting.  A
194   /// value of 0 indicates the attribute is not supported and the current setting value in
195   /// AttributesSetting is meaningless.
196   ///
197   UINT64                           AttributesSupported;
198   ///
199   /// Image attributes.  See 'Image Attribute Definitions' for possible returned values of
200   /// this parameter.
201   ///
202   UINT64                           AttributesSetting;
203   ///
204   /// Image compatibilities.  See 'Image Compatibility Definitions' for possible returned
205   /// values of this parameter.
206   ///
207   UINT64                           Compatibilities;
208 } EFI_FIRMWARE_IMAGE_DESCRIPTOR_V1;
209 
210 
211 ///
212 /// EFI_FIRMWARE_IMAGE_DESCRIPTOR in UEFI spec > 2.4a and < 2.5
213 ///
214 typedef struct {
215   ///
216   /// A unique number identifying the firmware image within the device.  The number is
217   /// between 1 and DescriptorCount.
218   ///
219   UINT8                            ImageIndex;
220   ///
221   /// A unique number identifying the firmware image type.
222   ///
223   EFI_GUID                         ImageTypeId;
224   ///
225   /// A unique number identifying the firmware image.
226   ///
227   UINT64                           ImageId;
228   ///
229   /// A pointer to a null-terminated string representing the firmware image name.
230   ///
231   CHAR16                           *ImageIdName;
232   ///
233   /// Identifies the version of the device firmware. The format is vendor specific and new
234   /// version must have a greater value than an old version.
235   ///
236   UINT32                           Version;
237   ///
238   /// A pointer to a null-terminated string representing the firmware image version name.
239   ///
240   CHAR16                           *VersionName;
241   ///
242   /// Size of the image in bytes.  If size=0, then only ImageIndex and ImageTypeId are valid.
243   ///
244   UINTN                            Size;
245   ///
246   /// Image attributes that are supported by this device.  See 'Image Attribute Definitions'
247   /// for possible returned values of this parameter.  A value of 1 indicates the attribute is
248   /// supported and the current setting value is indicated in AttributesSetting.  A
249   /// value of 0 indicates the attribute is not supported and the current setting value in
250   /// AttributesSetting is meaningless.
251   ///
252   UINT64                           AttributesSupported;
253   ///
254   /// Image attributes.  See 'Image Attribute Definitions' for possible returned values of
255   /// this parameter.
256   ///
257   UINT64                           AttributesSetting;
258   ///
259   /// Image compatibilities.  See 'Image Compatibility Definitions' for possible returned
260   /// values of this parameter.
261   ///
262   UINT64                           Compatibilities;
263   ///
264   /// Describes the lowest ImageDescriptor version that the device will accept. Only
265   /// present in version 2 or higher.
266   UINT32                           LowestSupportedImageVersion;
267 } EFI_FIRMWARE_IMAGE_DESCRIPTOR_V2;
268 
269 typedef struct {
270   LIST_ENTRY  Link;
271   EFI_HANDLE  TheHandle;
272   UINTN       TheIndex;
273 }HANDLE_LIST;
274 
275 typedef struct {
276   HANDLE_LIST   List;
277   UINTN         NextIndex;
278 } HANDLE_INDEX_LIST;
279 
280 typedef
281 CHAR16 *
282 (EFIAPI *DUMP_PROTOCOL_INFO)(
283   IN CONST EFI_HANDLE TheHandle,
284   IN CONST BOOLEAN    Verbose
285   );
286 
287 typedef struct _GUID_INFO_BLOCK{
288   EFI_STRING_ID                 StringId;
289   EFI_GUID                      *GuidId;
290   DUMP_PROTOCOL_INFO            DumpInfo;
291 } GUID_INFO_BLOCK;
292 
293 #endif
294 
295