]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Library/HandleParsingLib.h
fix a misspelling.
[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
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
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
41 @param[in] Name The pointer to the string name.\r
42 @param[in] Lang The pointer to the language code (string).\r
43 @param[in] Guid The pointer to the pointer to the Guid.\r
44\r
45 @retval EFI_SUCCESS The operation was successful.\r
46**/\r
47EFI_STATUS\r
48EFIAPI\r
49GetGuidFromStringName(\r
50 IN CONST CHAR16 *Name,\r
51 IN CONST CHAR8 *Lang OPTIONAL,\r
52 IN EFI_GUID **Guid\r
53 );\r
54\r
55/**\r
56 Function to dump protocol information from a handle.\r
57\r
58 This function will return a allocated string buffer containing the\r
59 information. The caller is responsible for freeing the memory.\r
60\r
61 If Guid is NULL, ASSERT().\r
62 If TheHandle is NULL, ASSERT().\r
63\r
64 @param[in] TheHandle The handle to dump information from.\r
65 @param[in] Guid The GUID of the protocol to dump.\r
66 @param[in] Verbose TRUE for extra info. FALSE otherwise.\r
67\r
68 @return The pointer to string.\r
69 @retval NULL An error was encountered.\r
70**/\r
71CHAR16*\r
72EFIAPI\r
73GetProtocolInformationDump(\r
74 IN CONST EFI_HANDLE TheHandle,\r
75 IN CONST EFI_GUID *Guid,\r
76 IN CONST BOOLEAN Verbose\r
77 );\r
78\r
79/**\r
80 Function to retrieve the driver name (if possible) from the ComponentName or\r
81 ComponentName2 protocol.\r
82\r
83 The string returned must be callee freed.\r
84\r
85 @param[in] TheHandle The driver handle to get the name of.\r
86 @param[in] Language The language to use.\r
87\r
88 @retval NULL The name could not be found.\r
89 @return A pointer to the string name. Do not de-allocate the memory.\r
90**/\r
91CONST CHAR16*\r
92EFIAPI\r
93GetStringNameFromHandle(\r
94 IN CONST EFI_HANDLE TheHandle,\r
95 IN CONST CHAR8 *Language\r
96 );\r
97\r
98#define HR_UNKNOWN 0\r
99#define HR_IMAGE_HANDLE BIT1\r
100#define HR_DRIVER_BINDING_HANDLE BIT2 // has driver binding\r
101#define HR_DEVICE_DRIVER BIT3 // device driver (hybrid?)\r
102#define HR_BUS_DRIVER BIT4 // a bus driver (hybrid?)\r
103#define HR_DRIVER_CONFIGURATION_HANDLE BIT5\r
104#define HR_DRIVER_DIAGNOSTICS_HANDLE BIT6\r
105#define HR_COMPONENT_NAME_HANDLE BIT7\r
106#define HR_DEVICE_HANDLE BIT8\r
107#define HR_PARENT_HANDLE BIT9\r
108#define HR_CONTROLLER_HANDLE BIT10\r
109#define HR_CHILD_HANDLE BIT11\r
110#define HR_VALID_MASK (BIT1|BIT2|BIT3|BIT4|BIT5|BIT6|BIT7|BIT8|BIT9|BIT10|BIT11)\r
111\r
112/**\r
113 Gets all the related EFI_HANDLEs based on the mask supplied.\r
114\r
115 This function will scan all EFI_HANDLES in the UEFI environment's handle database\r
116 and return all the ones with the specified relationship (Mask) to the specified\r
117 controller handle.\r
118\r
119 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.\r
120 If MatchingHandleCount is NULL, then ASSERT.\r
121\r
122 If MatchingHandleBuffer is not NULL upon a successful return, the memory must be\r
123 caller freed.\r
124\r
125 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.\r
126 @param[in] ControllerHandle The handle with Device Path protocol on it.\r
127 @param[in] Mask The mask of what relationship(s) is desired.\r
128 @param[in] MatchingHandleCount The pointer to UINTN specifying number of HANDLES in\r
129 MatchingHandleBuffer.\r
130 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount\r
131 EFI_HANDLEs with a terminating NULL EFI_HANDLE.\r
132\r
133 @retval EFI_SUCCESS The operation was successful, and any related handles\r
134 are in MatchingHandleBuffer.\r
135 @retval EFI_NOT_FOUND No matching handles were found.\r
136 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.\r
137 @sa ParseHandleDatabaseByRelationshipWithType\r
138**/\r
139EFI_STATUS\r
140EFIAPI\r
141ParseHandleDatabaseByRelationship (\r
142 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,\r
143 IN CONST EFI_HANDLE ControllerHandle OPTIONAL,\r
144 IN CONST UINTN Mask,\r
145 IN UINTN *MatchingHandleCount,\r
146 OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL\r
147 );\r
148\r
149/**\r
150 Gets all the related EFI_HANDLEs based on the mask supplied.\r
151\r
152 This function scans all EFI_HANDLES in the UEFI environment's handle database\r
153 and returns the ones with the specified relationship (Mask) to the specified\r
154 controller handle.\r
155\r
156 If both DriverBindingHandle and ControllerHandle are NULL, then ASSERT.\r
157 If MatchingHandleCount is NULL, then ASSERT.\r
158\r
159 If MatchingHandleBuffer is not NULL upon a successful return the memory must be\r
160 caller freed.\r
161\r
162 @param[in] DriverBindingHandle The handle with Driver Binding protocol on it.\r
163 @param[in] ControllerHandle The handle with Device Path protocol on it.\r
164 @param[in] MatchingHandleCount The pointer to UINTN that specifies the number of HANDLES in\r
165 MatchingHandleBuffer.\r
166 @param[out] MatchingHandleBuffer On a successful return, a buffer of MatchingHandleCount\r
167 EFI_HANDLEs with a terminating NULL EFI_HANDLE.\r
168 @param[out] HandleType An array of type information.\r
169\r
170 @retval EFI_SUCCESS The operation was successful, and any related handles\r
171 are in MatchingHandleBuffer.\r
172 @retval EFI_NOT_FOUND No matching handles were found.\r
173 @retval EFI_INVALID_PARAMETER A parameter was invalid or out of range.\r
174**/\r
175EFI_STATUS\r
176EFIAPI\r
177ParseHandleDatabaseByRelationshipWithType (\r
178 IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL,\r
179 IN CONST EFI_HANDLE ControllerHandle OPTIONAL,\r
180 IN UINTN *HandleCount,\r
181 OUT EFI_HANDLE **HandleBuffer,\r
182 OUT UINTN **HandleType\r
183 );\r
184\r
185/**\r
186 Gets handles for any parents of the passed in controller.\r
187\r
188 @param[in] ControllerHandle The handle of the controller.\r
189 @param[in] Count The pointer to the number of handles in\r
190 MatchingHandleBuffer on return.\r
191 @param[out] Buffer The buffer containing handles on a successful\r
192 return.\r
193 @retval EFI_SUCCESS The operation was successful.\r
194 @sa ParseHandleDatabaseByRelationship\r
195**/\r
196#define PARSE_HANDLE_DATABASE_PARENTS(ControllerHandle, Count, Buffer) \\r
197 ParseHandleDatabaseByRelationship(NULL, ControllerHandle, HR_PARENT_HANDLE, Count, Buffer)\r
198\r
199/**\r
200 Gets handles for any UEFI drivers of the passed in controller.\r
201\r
202 @param[in] ControllerHandle The handle of the controller.\r
203 @param[in] Count The pointer to the number of handles in\r
204 MatchingHandleBuffer on return.\r
205 @param[out] Buffer The buffer containing handles on a successful\r
206 return.\r
207 @retval EFI_SUCCESS The operation was successful.\r
208 @sa ParseHandleDatabaseByRelationship\r
209**/\r
210#define PARSE_HANDLE_DATABASE_UEFI_DRIVERS(ControllerHandle, Count, Buffer) \\r
211 ParseHandleDatabaseByRelationship(NULL, ControllerHandle, HR_DRIVER_BINDING_HANDLE|HR_DEVICE_DRIVER, Count, Buffer)\r
212\r
213/**\r
214 Gets handles for any children of the passed in controller by the passed in driver handle.\r
215\r
216 @param[in] DriverHandle The handle of the driver.\r
217 @param[in] ControllerHandle The handle of the controller.\r
218 @param[in] Count The pointer to the number of handles in\r
219 MatchingHandleBuffer on return.\r
220 @param[out] Buffer The buffer containing handles on a successful\r
221 return.\r
222 @retval EFI_SUCCESS The operation was successful.\r
223 @sa ParseHandleDatabaseByRelationship\r
224**/\r
225#define PARSE_HANDLE_DATABASE_MANAGED_CHILDREN(DriverHandle, ControllerHandle, Count, Buffer) \\r
226 ParseHandleDatabaseByRelationship(DriverHandle, ControllerHandle, HR_CHILD_HANDLE|HR_DEVICE_HANDLE, Count, Buffer)\r
227\r
228/**\r
229 Gets handles for any devices managed by the passed in driver.\r
230\r
231 @param[in] DriverHandle The handle of the driver.\r
232 @param[in] Count The pointer to the number of handles in\r
233 MatchingHandleBuffer on return.\r
234 @param[out] Buffer The buffer containing handles on a successful\r
235 return.\r
236 @retval EFI_SUCCESS The operation was successful.\r
237 @sa ParseHandleDatabaseByRelationship\r
238**/\r
239#define PARSE_HANDLE_DATABASE_DEVICES(DriverHandle, Count, Buffer) \\r
240 ParseHandleDatabaseByRelationship(DriverHandle, NULL, HR_CONTROLLER_HANDLE|HR_DEVICE_HANDLE, Count, Buffer)\r
241\r
242/**\r
243 Gets handles for any child devices produced by the passed in driver.\r
244\r
245 @param[in] DriverHandle The handle of the driver.\r
246 @param[in] MatchingHandleCount The pointer to the number of handles in\r
247 MatchingHandleBuffer on return.\r
248 @param[out] MatchingHandleBuffer The buffer containing handles on a successful\r
249 return.\r
250 @retval EFI_SUCCESS The operation was successful.\r
251 @sa ParseHandleDatabaseByRelationship\r
252**/\r
253EFI_STATUS\r
254EFIAPI\r
255ParseHandleDatabaseForChildDevices(\r
256 IN CONST EFI_HANDLE DriverHandle,\r
257 IN UINTN *MatchingHandleCount,\r
258 OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL\r
259 );\r
260\r
261/**\r
262 Gets handles for any child controllers of the passed in controller.\r
263\r
264 @param[in] ControllerHandle The handle of the "parent controller".\r
265 @param[in] MatchingHandleCount The pointer to the number of handles in\r
266 MatchingHandleBuffer on return.\r
267 @param[out] MatchingHandleBuffer The buffer containing handles on a successful\r
268 return.\r
269 @retval EFI_SUCCESS The operation was successful.\r
270 @sa ParseHandleDatabaseByRelationship\r
271**/\r
272EFI_STATUS\r
273EFIAPI\r
274ParseHandleDatabaseForChildControllers(\r
275 IN CONST EFI_HANDLE ControllerHandle,\r
276 IN UINTN *MatchingHandleCount,\r
277 OUT EFI_HANDLE **MatchingHandleBuffer OPTIONAL\r
278 );\r
279\r
280\r
281/**\r
282 Function to retrieve the human-friendly index of a given handle. If the handle\r
283 does not have a index one will be automatically assigned. The index value is valid\r
284 until the termination of the shell application.\r
285\r
286 @param[in] TheHandle The handle to retrieve an index for.\r
287\r
288 @retval 0 A memory allocation failed.\r
289 @return The index of the handle.\r
290\r
291**/\r
292UINTN\r
293EFIAPI\r
294ConvertHandleToHandleIndex(\r
295 IN CONST EFI_HANDLE TheHandle\r
296 );\r
297\r
298/**\r
299 Function to retrieve the EFI_HANDLE from the human-friendly index.\r
300\r
301 @param[in] TheIndex The index to retrieve the EFI_HANDLE for.\r
302\r
303 @retval NULL The index was invalid.\r
304 @return The EFI_HANDLE that index represents.\r
305\r
306**/\r
307EFI_HANDLE\r
308EFIAPI\r
309ConvertHandleIndexToHandle(\r
310 IN CONST UINTN TheIndex\r
311 );\r
312\r
313/**\r
314 Function to get all handles that support a given protocol or all handles.\r
315\r
316 @param[in] ProtocolGuid The guid of the protocol to get handles for. If NULL\r
317 then the function will return all handles.\r
318\r
319 @retval NULL A memory allocation failed.\r
320 @return A NULL terminated list of handles.\r
321**/\r
322EFI_HANDLE*\r
323EFIAPI\r
40d7a9cf 324GetHandleListByProtocol (\r
a405b86d 325 IN CONST EFI_GUID *ProtocolGuid OPTIONAL\r
326 );\r
327\r
328/**\r
329 Function to get all handles that support some protocols.\r
330\r
331 @param[in] ProtocolGuids A NULL terminated list of protocol GUIDs.\r
332\r
333 @retval NULL A memory allocation failed.\r
334 @return A NULL terminated list of handles.\r
335**/\r
336EFI_HANDLE*\r
337EFIAPI\r
40d7a9cf 338GetHandleListByProtocolList (\r
a405b86d 339 IN CONST EFI_GUID **ProtocolGuids\r
340 );\r
341\r
342#endif // __HANDLE_PARSING_LIB__\r