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