]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Library/HandleParsingLib.h
This adds the new APIs for UEFI Shell 2.1 and makes a new structure for shell impleme...
[mirror_edk2.git] / ShellPkg / Include / Library / HandleParsingLib.h
CommitLineData
a405b86d 1/** @file\r
2 Provides interface to advanced shell functionality for parsing both handle and protocol database.\r
3\r
9a6ac65d 4 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
a405b86d 5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __HANDLE_PARSING_LIB__\r
16#define __HANDLE_PARSING_LIB__\r
17\r
18#include <Uefi.h>\r
19\r
20/**\r
21 Function to get the name of a protocol or struct from it's GUID.\r
22\r
23 If Guid is NULL, then ASSERT.\r
24\r
25 @param[in] Guid The GUID to look for the name of.\r
26 @param[in] Lang The language to use.\r
27\r
28 @return The pointer to a string of the name. The caller\r
29 is responsible to free this memory.\r
30**/\r
31CHAR16*\r
32EFIAPI\r
33GetStringNameFromGuid(\r
34 IN CONST EFI_GUID *Guid,\r
35 IN CONST CHAR8 *Lang OPTIONAL\r
36 );\r
37\r
38/**\r
39 Function to get the Guid for a protocol or struct based on it's string name.\r
40\r
9a6ac65d
JC
41 Do not free or modify the returned GUID.\r
42\r
a405b86d 43 @param[in] Name The pointer to the string name.\r
44 @param[in] Lang The pointer to the language code (string).\r
9a6ac65d 45 @param[out] Guid The pointer to the pointer to the Guid.\r
a405b86d 46\r
47 @retval EFI_SUCCESS The operation was successful.\r
48**/\r
49EFI_STATUS\r
50EFIAPI\r
51GetGuidFromStringName(\r
52 IN CONST CHAR16 *Name,\r
53 IN CONST CHAR8 *Lang OPTIONAL,\r
9a6ac65d 54 OUT EFI_GUID **Guid\r
a405b86d 55 );\r
56\r
57/**\r
58 Function to dump protocol information from a handle.\r
59\r
60 This function will return a allocated string buffer containing the\r
61 information. The caller is responsible for freeing the memory.\r
62\r
63 If Guid is NULL, ASSERT().\r
64 If TheHandle is NULL, ASSERT().\r
65\r
66 @param[in] TheHandle The handle to dump information from.\r
67 @param[in] Guid The GUID of the protocol to dump.\r
68 @param[in] Verbose TRUE for extra info. FALSE otherwise.\r
69\r
70 @return The pointer to string.\r
71 @retval NULL An error was encountered.\r
72**/\r
73CHAR16*\r
74EFIAPI\r
75GetProtocolInformationDump(\r
76 IN CONST EFI_HANDLE TheHandle,\r
77 IN CONST EFI_GUID *Guid,\r
78 IN CONST BOOLEAN Verbose\r
79 );\r
80\r
81/**\r
82 Function to retrieve the driver name (if possible) from the ComponentName or\r
83 ComponentName2 protocol.\r
84\r
85 The string returned must be callee freed.\r
86\r
87 @param[in] TheHandle The driver handle to get the name of.\r
88 @param[in] Language The language to use.\r
89\r
90 @retval NULL The name could not be found.\r
91 @return A pointer to the string name. Do not de-allocate the memory.\r
92**/\r
93CONST CHAR16*\r
94EFIAPI\r
95GetStringNameFromHandle(\r
96 IN CONST EFI_HANDLE TheHandle,\r
97 IN CONST CHAR8 *Language\r
98 );\r
99\r
a71003f2
ED
100/**\r
101 Get best support language for this driver.\r
102 \r
103 First base on the user input language to search, second base on the current \r
104 platform used language to search, third get the first language from the \r
105 support language list. The caller need to free the buffer of the best language.\r
106\r
107 @param[in] SupportedLanguages The support languages for this driver.\r
108 @param[in] InputLanguage The user input language.\r
109 @param[in] Iso639Language Whether get language for ISO639.\r
110\r
111 @return The best support language for this driver.\r
112**/\r
113CHAR8 *\r
114EFIAPI\r
115GetBestLanguageForDriver (\r
116 IN CONST CHAR8 *SupportedLanguages,\r
117 IN CONST CHAR8 *InputLanguage,\r
118 IN BOOLEAN Iso639Language\r
119 );\r
120\r
a405b86d 121#define HR_UNKNOWN 0\r
122#define HR_IMAGE_HANDLE BIT1\r
123#define HR_DRIVER_BINDING_HANDLE BIT2 // has driver binding\r
124#define HR_DEVICE_DRIVER BIT3 // device driver (hybrid?)\r
125#define HR_BUS_DRIVER BIT4 // a bus driver (hybrid?)\r
126#define HR_DRIVER_CONFIGURATION_HANDLE BIT5\r
127#define HR_DRIVER_DIAGNOSTICS_HANDLE BIT6\r
128#define HR_COMPONENT_NAME_HANDLE BIT7\r
129#define HR_DEVICE_HANDLE BIT8\r
130#define HR_PARENT_HANDLE BIT9\r
131#define HR_CONTROLLER_HANDLE BIT10\r
132#define HR_CHILD_HANDLE BIT11\r
133#define HR_VALID_MASK (BIT1|BIT2|BIT3|BIT4|BIT5|BIT6|BIT7|BIT8|BIT9|BIT10|BIT11)\r
134\r
135/**\r
136 Gets all the related EFI_HANDLEs based on the mask supplied.\r
137\r
138 This function will scan all EFI_HANDLES in the UEFI environment's handle database\r
139 and return all the ones with the specified relationship (Mask) to the specified\r
140 controller handle.\r
141\r
142 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.\r
143 If MatchingHandleCount is NULL, then ASSERT.\r
144\r
145 If MatchingHandleBuffer is not NULL upon a successful return, the memory must be\r
146 caller freed.\r
147\r
148 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.\r
149 @param[in] ControllerHandle The handle with Device Path protocol on it.\r
150 @param[in] Mask The mask of what relationship(s) is desired.\r
151 @param[in] MatchingHandleCount The pointer to UINTN specifying number of HANDLES in\r
152 MatchingHandleBuffer.\r
153 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount\r
154 EFI_HANDLEs with a terminating NULL EFI_HANDLE.\r
155\r
156 @retval EFI_SUCCESS The operation was successful, and any related handles\r
157 are in MatchingHandleBuffer.\r
158 @retval EFI_NOT_FOUND No matching handles were found.\r
159 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.\r
160 @sa ParseHandleDatabaseByRelationshipWithType\r
161**/\r
162EFI_STATUS\r
163EFIAPI\r
164ParseHandleDatabaseByRelationship (\r
165 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,\r
166 IN CONST EFI_HANDLE ControllerHandle OPTIONAL,\r
167 IN CONST UINTN Mask,\r
168 IN UINTN *MatchingHandleCount,\r
169 OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL\r
170 );\r
171\r
172/**\r
173 Gets all the related EFI_HANDLEs based on the mask supplied.\r
174\r
175 This function scans all EFI_HANDLES in the UEFI environment's handle database\r
176 and returns the ones with the specified relationship (Mask) to the specified\r
177 controller handle.\r
178\r
179 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.\r
180 If MatchingHandleCount is NULL, then ASSERT.\r
181\r
182 If MatchingHandleBuffer is not NULL upon a successful return the memory must be\r
183 caller freed.\r
184\r
185 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.\r
186 @param[in] ControllerHandle The handle with Device Path protocol on it.\r
187 @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in\r
188 MatchingHandleBuffer.\r
189 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount\r
190 EFI_HANDLEs with a terminating NULL EFI_HANDLE.\r
191 @param[out] HandleType An array of type information.\r
192\r
193 @retval EFI_SUCCESS The operation was successful, and any related handles\r
194 are in MatchingHandleBuffer.\r
195 @retval EFI_NOT_FOUND No matching handles were found.\r
196 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.\r
197**/\r
198EFI_STATUS\r
199EFIAPI\r
200ParseHandleDatabaseByRelationshipWithType (\r
201 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,\r
202 IN CONST EFI_HANDLE ControllerHandle OPTIONAL,\r
203 IN UINTN *HandleCount,\r
204 OUT EFI_HANDLE **HandleBuffer,\r
205 OUT UINTN **HandleType\r
206 );\r
207\r
208/**\r
209 Gets handles for any parents of the passed in controller.\r
210\r
211 @param[in] ControllerHandle The handle of the controller.\r
212 @param[in] Count The pointer to the number of handles in\r
213 MatchingHandleBuffer on return.\r
214 @param[out] Buffer The buffer containing handles on a successful\r
215 return.\r
216 @retval EFI_SUCCESS The operation was successful.\r
217 @sa ParseHandleDatabaseByRelationship\r
218**/\r
219#define PARSE_HANDLE_DATABASE_PARENTS(ControllerHandle, Count, Buffer) \\r
220 ParseHandleDatabaseByRelationship(NULL, ControllerHandle, HR_PARENT_HANDLE, Count, Buffer)\r
221\r
222/**\r
223 Gets handles for any UEFI drivers of the passed in controller.\r
224\r
225 @param[in] ControllerHandle The handle of the controller.\r
226 @param[in] Count The pointer to the number of handles in\r
227 MatchingHandleBuffer on return.\r
228 @param[out] Buffer The buffer containing handles on a successful\r
229 return.\r
230 @retval EFI_SUCCESS The operation was successful.\r
231 @sa ParseHandleDatabaseByRelationship\r
232**/\r
233#define PARSE_HANDLE_DATABASE_UEFI_DRIVERS(ControllerHandle, Count, Buffer) \\r
234 ParseHandleDatabaseByRelationship(NULL, ControllerHandle, HR_DRIVER_BINDING_HANDLE|HR_DEVICE_DRIVER, Count, Buffer)\r
235\r
236/**\r
237 Gets handles for any children of the passed in controller by the passed in driver handle.\r
238\r
239 @param[in] DriverHandle The handle of the driver.\r
240 @param[in] ControllerHandle The handle of the controller.\r
241 @param[in] Count The pointer to the number of handles in\r
242 MatchingHandleBuffer on return.\r
243 @param[out] Buffer The buffer containing handles on a successful\r
244 return.\r
245 @retval EFI_SUCCESS The operation was successful.\r
246 @sa ParseHandleDatabaseByRelationship\r
247**/\r
248#define PARSE_HANDLE_DATABASE_MANAGED_CHILDREN(DriverHandle, ControllerHandle, Count, Buffer) \\r
249 ParseHandleDatabaseByRelationship(DriverHandle, ControllerHandle, HR_CHILD_HANDLE|HR_DEVICE_HANDLE, Count, Buffer)\r
250\r
251/**\r
252 Gets handles for any devices managed by the passed in driver.\r
253\r
254 @param[in] DriverHandle The handle of the driver.\r
255 @param[in] Count The pointer to the number of handles in\r
256 MatchingHandleBuffer on return.\r
257 @param[out] Buffer The buffer containing handles on a successful\r
258 return.\r
259 @retval EFI_SUCCESS The operation was successful.\r
260 @sa ParseHandleDatabaseByRelationship\r
261**/\r
262#define PARSE_HANDLE_DATABASE_DEVICES(DriverHandle, Count, Buffer) \\r
263 ParseHandleDatabaseByRelationship(DriverHandle, NULL, HR_CONTROLLER_HANDLE|HR_DEVICE_HANDLE, Count, Buffer)\r
264\r
265/**\r
266 Gets handles for any child devices produced by the passed in driver.\r
267\r
268 @param[in] DriverHandle The handle of the driver.\r
269 @param[in] MatchingHandleCount The pointer to the number of handles in\r
270 MatchingHandleBuffer on return.\r
271 @param[out] MatchingHandleBuffer The buffer containing handles on a successful\r
272 return.\r
273 @retval EFI_SUCCESS The operation was successful.\r
274 @sa ParseHandleDatabaseByRelationship\r
275**/\r
276EFI_STATUS\r
277EFIAPI\r
278ParseHandleDatabaseForChildDevices(\r
279 IN CONST EFI_HANDLE DriverHandle,\r
280 IN UINTN *MatchingHandleCount,\r
281 OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL\r
282 );\r
283\r
284/**\r
285 Gets handles for any child controllers of the passed in controller.\r
286\r
287 @param[in] ControllerHandle The handle of the "parent controller".\r
288 @param[in] MatchingHandleCount The pointer to the number of handles in\r
289 MatchingHandleBuffer on return.\r
290 @param[out] MatchingHandleBuffer The buffer containing handles on a successful\r
291 return.\r
292 @retval EFI_SUCCESS The operation was successful.\r
293 @sa ParseHandleDatabaseByRelationship\r
294**/\r
295EFI_STATUS\r
296EFIAPI\r
297ParseHandleDatabaseForChildControllers(\r
298 IN CONST EFI_HANDLE ControllerHandle,\r
299 IN UINTN *MatchingHandleCount,\r
300 OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL\r
301 );\r
302\r
303\r
304/**\r
305 Function to retrieve the human-friendly index of a given handle. If the handle\r
306 does not have a index one will be automatically assigned. The index value is valid\r
307 until the termination of the shell application.\r
308\r
309 @param[in] TheHandle The handle to retrieve an index for.\r
310\r
311 @retval 0 A memory allocation failed.\r
312 @return The index of the handle.\r
313\r
314**/\r
315UINTN\r
316EFIAPI\r
317ConvertHandleToHandleIndex(\r
318 IN CONST EFI_HANDLE TheHandle\r
319 );\r
320\r
321/**\r
322 Function to retrieve the EFI_HANDLE from the human-friendly index.\r
323\r
324 @param[in] TheIndex The index to retrieve the EFI_HANDLE for.\r
325\r
326 @retval NULL The index was invalid.\r
327 @return The EFI_HANDLE that index represents.\r
328\r
329**/\r
330EFI_HANDLE\r
331EFIAPI\r
332ConvertHandleIndexToHandle(\r
333 IN CONST UINTN TheIndex\r
334 );\r
335\r
336/**\r
337 Function to get all handles that support a given protocol or all handles.\r
338\r
339 @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL\r
340 then the function will return all handles.\r
341\r
342 @retval NULL A memory allocation failed.\r
343 @return A NULL terminated list of handles.\r
344**/\r
345EFI_HANDLE*\r
346EFIAPI\r
40d7a9cf 347GetHandleListByProtocol (\r
a405b86d 348 IN CONST EFI_GUID *ProtocolGuid OPTIONAL\r
349 );\r
350\r
351/**\r
352 Function to get all handles that support some protocols.\r
353\r
354 @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.\r
355\r
356 @retval NULL A memory allocation failed.\r
ff51746b 357 @retval NULL ProtocolGuids was NULL.\r
358 @return A NULL terminated list of EFI_HANDLEs.\r
a405b86d 359**/\r
360EFI_HANDLE*\r
361EFIAPI\r
40d7a9cf 362GetHandleListByProtocolList (\r
a405b86d 363 IN CONST EFI_GUID **ProtocolGuids\r
364 );\r
365\r
366#endif // __HANDLE_PARSING_LIB__\r