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