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