]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Universal/BdsDxe/DeviceMngr/DeviceManager.h
c706f55d92e56b61e5c5a17f5d4891b77149cd9e
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / DeviceMngr / DeviceManager.h
1 /** @file
2 The platform device manager reference implement
3
4 Copyright (c) 2004 - 2010, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _DEVICE_MANAGER_H_
16 #define _DEVICE_MANAGER_H_
17
18 #include "Bds.h"
19 #include "FrontPage.h"
20
21 //
22 // These are defined as the same with vfr file
23 //
24 #define DEVICE_MANAGER_FORMSET_GUID \
25 { \
26 0x3ebfa8e6, 0x511d, 0x4b5b, {0xa9, 0x5f, 0xfb, 0x38, 0x26, 0xf, 0x1c, 0x27} \
27 }
28
29 #define DRIVER_HEALTH_FORMSET_GUID \
30 { \
31 0xf76e0a70, 0xb5ed, 0x4c38, {0xac, 0x9a, 0xe5, 0xf5, 0x4b, 0xf1, 0x6e, 0x34} \
32 }
33
34 #define LABEL_DEVICES_LIST 0x0080
35 #define LABEL_END 0xffff
36
37 #define LABEL_DRIVER_HEALTH 0x2000
38 #define LABEL_DRIVER_HEALTH_END 0x2001
39
40 #define LABEL_DRIVER_HEALTH_REAPIR_ALL 0x3000
41 #define LABEL_DRIVER_HEALTH_REAPIR_ALL_END 0x3001
42
43 #define LABEL_VBIOS 0x0040
44
45 #define DEVICE_MANAGER_FORM_ID 0x1000
46 #define DRIVER_HEALTH_FORM_ID 0x1001
47
48 #define DEVICE_KEY_OFFSET 0x1000
49 #define DEVICE_MANAGER_KEY_VBIOS 0x2000
50
51 #define DEVICE_MANAGER_KEY_DRIVER_HEALTH 0x1111
52 #define DRIVER_HEALTH_KEY_OFFSET 0x2000
53 #define DRIVER_HEALTH_REPAIR_ALL_KEY 0x3000
54 #define DRIVER_HEALTH_RETURN_KEY 0x4000
55
56 //
57 // These are the VFR compiler generated data representing our VFR data.
58 //
59 extern UINT8 DeviceManagerVfrBin[];
60 extern UINT8 DriverHealthVfrBin[];
61
62 #define DEVICE_MANAGER_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('D', 'M', 'C', 'B')
63 #define DEVICE_MANAGER_DRIVER_HEALTH_INFO_SIGNATURE SIGNATURE_32 ('D', 'M', 'D', 'H')
64
65
66 typedef struct {
67 UINTN Signature;
68
69 ///
70 /// Device Manager HII relative handles
71 ///
72 EFI_HII_HANDLE HiiHandle;
73
74 ///
75 /// Driver Health HII relative handles
76 ///
77 EFI_HII_HANDLE DriverHealthHiiHandle;
78
79 EFI_HANDLE DriverHandle;
80 EFI_HANDLE DriverHealthHandle;
81
82 ///
83 /// Device Manager Produced protocols
84 ///
85 EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
86
87 ///
88 /// Driver Health Produced protocols
89 ///
90 EFI_HII_CONFIG_ACCESS_PROTOCOL DriverHealthConfigAccess;
91
92 ///
93 /// Configuration data
94 ///
95 UINT8 VideoBios;
96 } DEVICE_MANAGER_CALLBACK_DATA;
97
98
99 typedef struct {
100 UINTN Signature;
101 LIST_ENTRY Link;
102
103 ///
104 /// HII relative handles
105 ///
106 EFI_HII_HANDLE HiiHandle;
107
108 ///
109 /// Driver relative handles
110 ///
111 EFI_HANDLE DriverHandle;
112 EFI_HANDLE ControllerHandle;
113 EFI_HANDLE ChildHandle;
114
115 EFI_DRIVER_HEALTH_PROTOCOL *DriverHealth;
116 ///
117 /// Driver health messages of the specify Driver
118 ///
119 EFI_DRIVER_HEALTH_HII_MESSAGE *MessageList;
120
121 ///
122 /// Driver Health status
123 ///
124 EFI_DRIVER_HEALTH_STATUS HealthStatus;
125 } DRIVER_HEALTH_INFO;
126
127 #define DEVICE_MANAGER_HEALTH_INFO_FROM_LINK(a) \
128 CR (a, \
129 DRIVER_HEALTH_INFO, \
130 Link, \
131 DEVICE_MANAGER_DRIVER_HEALTH_INFO_SIGNATURE \
132 )
133
134 #define DEVICE_MANAGER_CALLBACK_DATA_FROM_THIS(a) \
135 CR (a, \
136 DEVICE_MANAGER_CALLBACK_DATA, \
137 ConfigAccess, \
138 DEVICE_MANAGER_CALLBACK_DATA_SIGNATURE \
139 )
140 typedef struct {
141 EFI_STRING_ID StringId;
142 UINT16 Class;
143 } DEVICE_MANAGER_MENU_ITEM;
144
145 /**
146 This function is invoked if user selected a interactive opcode from Device Manager's
147 Formset. The decision by user is saved to gCallbackKey for later processing. If
148 user set VBIOS, the new value is saved to EFI variable.
149
150
151 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
152 @param Action Specifies the type of action taken by the browser.
153 @param QuestionId A unique value which is sent to the original exporting driver
154 so that it can identify the type of data to expect.
155 @param Type The type of value for the question.
156 @param Value A pointer to the data being sent to the original exporting driver.
157 @param ActionRequest On return, points to the action requested by the callback function.
158
159 @retval EFI_SUCCESS The callback successfully handled the action.
160 @retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
161
162 **/
163 EFI_STATUS
164 EFIAPI
165 DeviceManagerCallback (
166 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
167 IN EFI_BROWSER_ACTION Action,
168 IN EFI_QUESTION_ID QuestionId,
169 IN UINT8 Type,
170 IN EFI_IFR_TYPE_VALUE *Value,
171 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
172 );
173
174 /**
175 This function is invoked if user selected a interactive opcode from Driver Health's
176 Formset. The decision by user is saved to gCallbackKey for later processing.
177
178
179 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
180 @param Action Specifies the type of action taken by the browser.
181 @param QuestionId A unique value which is sent to the original exporting driver
182 so that it can identify the type of data to expect.
183 @param Type The type of value for the question.
184 @param Value A pointer to the data being sent to the original exporting driver.
185 @param ActionRequest On return, points to the action requested by the callback function.
186
187 @retval EFI_SUCCESS The callback successfully handled the action.
188 @retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
189
190 **/
191 EFI_STATUS
192 EFIAPI
193 DriverHealthCallback (
194 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
195 IN EFI_BROWSER_ACTION Action,
196 IN EFI_QUESTION_ID QuestionId,
197 IN UINT8 Type,
198 IN EFI_IFR_TYPE_VALUE *Value,
199 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
200 );
201
202
203 /**
204
205 This function registers HII packages to HII database.
206
207 @retval EFI_SUCCESS HII packages for the Device Manager were registered successfully.
208 @retval EFI_OUT_OF_RESOURCES HII packages for the Device Manager failed to be registered.
209
210 **/
211 EFI_STATUS
212 InitializeDeviceManager (
213 VOID
214 );
215
216 /**
217
218 Call the browser and display the device manager to allow user
219 to configure the platform.
220
221 This function create the dynamic content for device manager. It includes
222 section header for all class of devices, one-of opcode to set VBIOS.
223
224 @retval EFI_SUCCESS Operation is successful.
225 @retval Other values if failed to clean up the dynamic content from HII
226 database.
227
228 **/
229 EFI_STATUS
230 CallDeviceManager (
231 VOID
232 );
233
234
235 /**
236 Check the Driver Health status of a single controller and try to process it if not healthy.
237
238 This function called by CheckAllControllersHealthStatus () function in order to process a specify
239 contoller's health state.
240
241 @param DriverHealthList A Pointer to the list contain all of the platform driver health information.
242 @param DriverHandle The handle of driver.
243 @param ControllerHandle The class guid specifies which form set will be displayed.
244 @param ChildHandle The handle of the child controller to retrieve the health
245 status on. This is an optional parameter that may be NULL.
246 @param DriverHealth A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.
247 @param HealthStatus The health status of the controller.
248
249 @retval EFI_INVALID_PARAMETER HealthStatus or DriverHealth is NULL.
250 @retval HealthStatus The Health status of specify controller.
251 @retval EFI_OUT_OF_RESOURCES The list of Driver Health Protocol handles can not be retrieved.
252 @retval EFI_NOT_FOUND No controller in the platform install Driver Health Protocol.
253 @retval EFI_SUCCESS The Health related operation has been taken successfully.
254
255 **/
256 EFI_STATUS
257 EFIAPI
258 GetSingleControllerHealthStatus (
259 IN OUT LIST_ENTRY *DriverHealthList,
260 IN EFI_HANDLE DriverHandle,
261 IN EFI_HANDLE ControllerHandle, OPTIONAL
262 IN EFI_HANDLE ChildHandle, OPTIONAL
263 IN EFI_DRIVER_HEALTH_PROTOCOL *DriverHealth,
264 IN EFI_DRIVER_HEALTH_STATUS *HealthStatus
265 );
266
267 /**
268 Collects all the EFI Driver Health Protocols currently present in the EFI Handle Database,
269 and queries each EFI Driver Health Protocol to determine if one or more of the controllers
270 managed by each EFI Driver Health Protocol instance are not healthy.
271
272 @param DriverHealthList A Pointer to the list contain all of the platform driver health
273 information.
274
275 @retval EFI_NOT_FOUND No controller in the platform install Driver Health Protocol.
276 @retval EFI_SUCCESS All the controllers in the platform are healthy.
277 @retval EFI_OUT_OF_RESOURCES The list of Driver Health Protocol handles can not be retrieved.
278
279 **/
280 EFI_STATUS
281 GetAllControllersHealthStatus (
282 IN OUT LIST_ENTRY *DriverHealthList
283 );
284
285 /**
286 Check the healthy status of the platform, this function will return immediately while found one driver
287 in the platform are not healthy.
288
289 @retval FALSE at least one driver in the platform are not healthy.
290 @retval TRUE No controller install Driver Health Protocol,
291 or all controllers in the platform are in healthy status.
292 **/
293 BOOLEAN
294 PlaformHealthStatusCheck (
295 VOID
296 );
297
298 /**
299 Repair the whole platform.
300
301 This function is the main entry for user choose "Repair All" in the front page.
302 It will try to do recovery job till all the driver health protocol installed modules
303 reach a terminal state.
304
305 @param DriverHealthList A Pointer to the list contain all of the platform driver health
306 information.
307
308 **/
309 VOID
310 PlatformRepairAll (
311 IN LIST_ENTRY *DriverHealthList
312 );
313
314 /**
315 Processes a single controller using the EFI Driver Health Protocol associated with
316 that controller. This algorithm continues to query the GetHealthStatus() service until
317 one of the legal terminal states of the EFI Driver Health Protocol is reached. This may
318 require the processing of HII Messages, HII Form, and invocation of repair operations.
319
320 @param DriverHealth A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.
321 @param ControllerHandle The class guid specifies which form set will be displayed.
322 @param ChildHandle The handle of the child controller to retrieve the health
323 status on. This is an optional parameter that may be NULL.
324 @param HealthStatus The health status of the controller.
325 @param MessageList An array of warning or error messages associated
326 with the controller specified by ControllerHandle and
327 ChildHandle. This is an optional parameter that may be NULL.
328 @param FormHiiHandle The HII handle for an HII form associated with the
329 controller specified by ControllerHandle and ChildHandle.
330
331 **/
332 VOID
333 ProcessSingleControllerHealth (
334 IN EFI_DRIVER_HEALTH_PROTOCOL *DriverHealth,
335 IN EFI_HANDLE ControllerHandle, OPTIONAL
336 IN EFI_HANDLE ChildHandle, OPTIONAL
337 IN EFI_DRIVER_HEALTH_STATUS HealthStatus,
338 IN EFI_DRIVER_HEALTH_HII_MESSAGE **MessageList, OPTIONAL
339 IN EFI_HII_HANDLE FormHiiHandle
340 );
341
342 /**
343 Repair notification function, simply print the repair progress.
344
345 @param Value The value of part has been repaired.
346 @param Limit Total value need to be repaired.
347
348 **/
349 VOID
350 RepairNotify (
351 IN UINTN Value,
352 IN UINTN Limit
353 );
354
355 /**
356 Processes a set of messages returned by the GetHealthStatus ()
357 service of the EFI Driver Health Protocol
358
359 @param MessageList The MessageList point to messages need to processed.
360
361 **/
362 VOID
363 ProcessMessages (
364 IN EFI_DRIVER_HEALTH_HII_MESSAGE *MessageList
365 );
366
367
368 /**
369 Collect and display the platform's driver health relative information, allow user to do interactive
370 operation while the platform is unhealthy.
371
372 This function display a form which divided into two parts. The one list all modules which has installed
373 driver health protocol. The list usually contain driver name, controller name, and it's health info.
374 While the driver name can't be retrieved, will use device path as backup. The other part of the form provide
375 a choice to the user to repair all platform.
376
377 **/
378 VOID
379 CallDriverHealth (
380 VOID
381 );
382
383 /**
384
385 Select the best matching language according to front page policy for best user experience.
386
387 This function supports both ISO 639-2 and RFC 4646 language codes, but language
388 code types may not be mixed in a single call to this function.
389
390 @param SupportedLanguages A pointer to a Null-terminated ASCII string that
391 contains a set of language codes in the format
392 specified by Iso639Language.
393 @param Iso639Language If TRUE, then all language codes are assumed to be
394 in ISO 639-2 format. If FALSE, then all language
395 codes are assumed to be in RFC 4646 language format.
396
397 @retval NULL The best matching language could not be found in SupportedLanguages.
398 @retval NULL There are not enough resources available to return the best matching
399 language.
400 @retval Other A pointer to a Null-terminated ASCII string that is the best matching
401 language in SupportedLanguages.
402 **/
403 CHAR8 *
404 DriverHealthSelectBestLanguage (
405 IN CHAR8 *SupportedLanguages,
406 IN BOOLEAN Iso639Language
407 );
408
409 /**
410
411 This is an internal worker function to get the Component Name (2) protocol interface
412 and the language it supports.
413
414 @param ProtocolGuid A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.
415 @param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
416 @param ComponentName A pointer to the Component Name (2) protocol interface.
417 @param SupportedLanguage The best suitable language that matches the SupportedLangues interface for the
418 located Component Name (2) instance.
419
420 @retval EFI_SUCCESS The Component Name (2) protocol instance is successfully located and we find
421 the best matching language it support.
422 @retval EFI_UNSUPPORTED The input Language is not supported by the Component Name (2) protocol.
423 @retval Other Some error occurs when locating Component Name (2) protocol instance or finding
424 the supported language.
425
426 **/
427 EFI_STATUS
428 GetComponentNameWorker (
429 IN EFI_GUID *ProtocolGuid,
430 IN EFI_HANDLE DriverBindingHandle,
431 OUT EFI_COMPONENT_NAME_PROTOCOL **ComponentName,
432 OUT CHAR8 **SupportedLanguage
433 );
434
435 /**
436
437 This is an internal worker function to get driver name from Component Name (2) protocol interface.
438
439
440 @param ProtocolGuid A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.
441 @param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
442 @param DriverName A pointer to the Unicode string to return. This Unicode string is the name
443 of the driver specified by This.
444
445 @retval EFI_SUCCESS The driver name is successfully retrieved from Component Name (2) protocol
446 interface.
447 @retval Other The driver name cannot be retrieved from Component Name (2) protocol
448 interface.
449
450 **/
451 EFI_STATUS
452 GetDriverNameWorker (
453 IN EFI_GUID *ProtocolGuid,
454 IN EFI_HANDLE DriverBindingHandle,
455 OUT CHAR16 **DriverName
456 );
457
458 /**
459
460 This function gets driver name from Component Name 2 protocol interface and Component Name protocol interface
461 in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the driver name.
462 If the attempt fails, it then gets the driver name from EFI 1.1 Component Name protocol for backward
463 compatibility support.
464
465 @param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
466 @param DriverName A pointer to the Unicode string to return. This Unicode string is the name
467 of the driver specified by This.
468
469 @retval EFI_SUCCESS The driver name is successfully retrieved from Component Name (2) protocol
470 interface.
471 @retval Other The driver name cannot be retrieved from Component Name (2) protocol
472 interface.
473
474 **/
475 EFI_STATUS
476 DriverHealthGetDriverName (
477 IN EFI_HANDLE DriverBindingHandle,
478 OUT CHAR16 **DriverName
479 );
480
481 /**
482 This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface
483 in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.
484 If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward
485 compatibility support.
486
487 @param ProtocolGuid A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.
488 @param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
489 @param ControllerHandle The handle of a controller that the driver specified by This is managing.
490 This handle specifies the controller whose name is to be returned.
491 @param ChildHandle The handle of the child controller to retrieve the name of. This is an
492 optional parameter that may be NULL. It will be NULL for device drivers.
493 It will also be NULL for bus drivers that attempt to retrieve the name
494 of the bus controller. It will not be NULL for a bus driver that attempts
495 to retrieve the name of a child controller.
496 @param ControllerName A pointer to the Unicode string to return. This Unicode string
497 is the name of the controller specified by ControllerHandle and ChildHandle.
498
499 @retval EFI_SUCCESS The controller name is successfully retrieved from Component Name (2) protocol
500 interface.
501 @retval Other The controller name cannot be retrieved from Component Name (2) protocol.
502
503 **/
504 EFI_STATUS
505 GetControllerNameWorker (
506 IN EFI_GUID *ProtocolGuid,
507 IN EFI_HANDLE DriverBindingHandle,
508 IN EFI_HANDLE ControllerHandle,
509 IN EFI_HANDLE ChildHandle,
510 OUT CHAR16 **ControllerName
511 );
512
513 /**
514 This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface
515 in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.
516 If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward
517 compatibility support.
518
519 @param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
520 @param ControllerHandle The handle of a controller that the driver specified by This is managing.
521 This handle specifies the controller whose name is to be returned.
522 @param ChildHandle The handle of the child controller to retrieve the name of. This is an
523 optional parameter that may be NULL. It will be NULL for device drivers.
524 It will also be NULL for bus drivers that attempt to retrieve the name
525 of the bus controller. It will not be NULL for a bus driver that attempts
526 to retrieve the name of a child controller.
527 @param ControllerName A pointer to the Unicode string to return. This Unicode string
528 is the name of the controller specified by ControllerHandle and ChildHandle.
529
530 @retval EFI_SUCCESS The controller name is successfully retrieved from Component Name (2) protocol
531 interface.
532 @retval Other The controller name cannot be retrieved from Component Name (2) protocol.
533
534 **/
535 EFI_STATUS
536 DriverHealthGetControllerName (
537 IN EFI_HANDLE DriverBindingHandle,
538 IN EFI_HANDLE ControllerHandle,
539 IN EFI_HANDLE ChildHandle,
540 OUT CHAR16 **ControllerName
541 );
542
543 #endif