2 The platform device manager reference implement
4 Copyright (c) 2004 - 2009, 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
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.
15 #ifndef _DEVICE_MANAGER_H_
16 #define _DEVICE_MANAGER_H_
19 #include "FrontPage.h"
22 // These are defined as the same with vfr file
24 #define DEVICE_MANAGER_FORMSET_GUID \
26 0x3ebfa8e6, 0x511d, 0x4b5b, {0xa9, 0x5f, 0xfb, 0x38, 0x26, 0xf, 0x1c, 0x27} \
29 #define DRIVER_HEALTH_FORMSET_GUID \
31 0xf76e0a70, 0xb5ed, 0x4c38, {0xac, 0x9a, 0xe5, 0xf5, 0x4b, 0xf1, 0x6e, 0x34} \
34 #define LABEL_DEVICES_LIST 0x0080
35 #define LABEL_END 0xffff
37 #define LABEL_DRIVER_HEALTH 0x2000
38 #define LABEL_DRIVER_HEALTH_END 0x2001
40 #define LABEL_DRIVER_HEALTH_REAPIR_ALL 0x3000
41 #define LABEL_DRIVER_HEALTH_REAPIR_ALL_END 0x3001
43 #define LABEL_VBIOS 0x0040
45 #define DEVICE_MANAGER_FORM_ID 0x1000
46 #define DRIVER_HEALTH_FORM_ID 0x1001
48 #define DEVICE_KEY_OFFSET 0x1000
49 #define DEVICE_MANAGER_KEY_VBIOS 0x2000
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
57 // These are the VFR compiler generated data representing our VFR data.
59 extern UINT8 DeviceManagerVfrBin
[];
60 extern UINT8 DriverHealthVfrBin
[];
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')
70 /// Device Manager HII relative handles
72 EFI_HII_HANDLE HiiHandle
;
75 /// Driver Health HII relative handles
77 EFI_HII_HANDLE DriverHealthHiiHandle
;
79 EFI_HANDLE DriverHandle
;
80 EFI_HANDLE DriverHealthHandle
;
83 /// Device Manager Produced protocols
85 EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess
;
88 /// Driver Health Produced protocols
90 EFI_HII_CONFIG_ACCESS_PROTOCOL DriverHealthConfigAccess
;
93 /// Configuration data
96 } DEVICE_MANAGER_CALLBACK_DATA
;
104 /// HII relative handles
106 EFI_HII_HANDLE HiiHandle
;
109 /// Driver relative handles
111 EFI_HANDLE DriverHandle
;
112 EFI_HANDLE ControllerHandle
;
113 EFI_HANDLE ChildHandle
;
115 EFI_DRIVER_HEALTH_PROTOCOL
*DriverHealth
;
117 /// Driver health messages of the specify Driver
119 EFI_DRIVER_HEALTH_HII_MESSAGE
*MessageList
;
122 /// Driver Health status
124 EFI_DRIVER_HEALTH_STATUS HealthStatus
;
125 } DRIVER_HEALTH_INFO
;
127 #define DEVICE_MANAGER_HEALTH_INFO_FROM_LINK(a) \
129 DRIVER_HEALTH_INFO, \
131 DEVICE_MANAGER_DRIVER_HEALTH_INFO_SIGNATURE \
134 #define DEVICE_MANAGER_CALLBACK_DATA_FROM_THIS(a) \
136 DEVICE_MANAGER_CALLBACK_DATA, \
138 DEVICE_MANAGER_CALLBACK_DATA_SIGNATURE \
141 EFI_STRING_ID StringId
;
143 } DEVICE_MANAGER_MENU_ITEM
;
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.
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.
159 @retval EFI_SUCCESS The callback successfully handled the action.
160 @retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
165 DeviceManagerCallback (
166 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
167 IN EFI_BROWSER_ACTION Action
,
168 IN EFI_QUESTION_ID QuestionId
,
170 IN EFI_IFR_TYPE_VALUE
*Value
,
171 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
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.
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.
187 @retval EFI_SUCCESS The callback successfully handled the action.
188 @retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
193 DriverHealthCallback (
194 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
195 IN EFI_BROWSER_ACTION Action
,
196 IN EFI_QUESTION_ID QuestionId
,
198 IN EFI_IFR_TYPE_VALUE
*Value
,
199 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
205 This function registers HII packages to HII database.
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.
212 InitializeDeviceManager (
218 Call the browser and display the device manager to allow user
219 to configure the platform.
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.
224 @retval EFI_SUCCESS Operation is successful.
225 @retval Other values if failed to clean up the dynamic content from HII
236 Check the Driver Health status of a single controller and try to process it if not healthy.
238 This function called by CheckAllControllersHealthStatus () function in order to process a specify
239 contoller's health state.
241 @param DriverHealth A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.
242 @param ControllerHandle The class guid specifies which form set will be displayed.
243 @param ChildHandle The handle of the child controller to retrieve the health
244 status on. This is an optional parameter that may be NULL.
245 @param HealthStatus The health status of the controller.
246 @param MessageList An array of warning or error messages associated
247 with the controller specified by ControllerHandle and
248 ChildHandle. This is an optional parameter that may be NULL.
249 @param FormHiiHandle The HII handle for an HII form associated with the
250 controller specified by ControllerHandle and ChildHandle.
252 @retval EFI_INVALID_PARAMETER HealthStatus or DriverHealth is NULL.
253 @retval HealthStatus The Health status of specify controller.
254 @retval EFI_OUT_OF_RESOURCES The list of Driver Health Protocol handles can not be retrieved.
255 @retval EFI_NOT_FOUND No controller in the platform install Driver Health Protocol.
256 @retval EFI_SUCCESS The Health related operation has been taken successfully.
261 GetSingleControllerHealthStatus (
262 IN OUT LIST_ENTRY
*DriverHealthList
,
263 IN EFI_HANDLE DriverHandle
,
264 IN EFI_HANDLE ControllerHandle
, OPTIONAL
265 IN EFI_HANDLE ChildHandle
, OPTIONAL
266 IN EFI_DRIVER_HEALTH_PROTOCOL
*DriverHealth
,
267 IN EFI_DRIVER_HEALTH_STATUS
*HealthStatus
271 Collects all the EFI Driver Health Protocols currently present in the EFI Handle Database,
272 and queries each EFI Driver Health Protocol to determine if one or more of the controllers
273 managed by each EFI Driver Health Protocol instance are not healthy.
275 @param DriverHealthList A Pointer to the list contain all of the platform driver health
278 @retval EFI_NOT_FOUND No controller in the platform install Driver Health Protocol.
279 @retval EFI_SUCCESS All the controllers in the platform are healthy.
280 @retval EFI_OUT_OF_RESOURCES The list of Driver Health Protocol handles can not be retrieved.
284 GetAllControllersHealthStatus (
285 IN OUT LIST_ENTRY
*DriverHealthList
289 Check the healthy status of the platform, this function will return immediately while found one driver
290 in the platform are not healthy.
292 @retval FALSE at least one driver in the platform are not healthy.
293 @retval TRUE No controller install Driver Health Protocol,
294 or all controllers in the platform are in healthy status.
297 PlaformHealthStatusCheck (
302 Repair the whole platform.
304 This function is the main entry for user choose "Repair All" in the front page.
305 It will try to do recovery job till all the driver health protocol installed modules
306 reach a terminal state.
308 @param DriverHealthList A Pointer to the list contain all of the platform driver health
314 IN LIST_ENTRY
*DriverHealthList
318 Processes a single controller using the EFI Driver Health Protocol associated with
319 that controller. This algorithm continues to query the GetHealthStatus() service until
320 one of the legal terminal states of the EFI Driver Health Protocol is reached. This may
321 require the processing of HII Messages, HII Form, and invocation of repair operations.
323 @param DriverHealth A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.
324 @param ControllerHandle The class guid specifies which form set will be displayed.
325 @param ChildHandle The handle of the child controller to retrieve the health
326 status on. This is an optional parameter that may be NULL.
327 @param HealthStatus The health status of the controller.
328 @param MessageList An array of warning or error messages associated
329 with the controller specified by ControllerHandle and
330 ChildHandle. This is an optional parameter that may be NULL.
331 @param FormHiiHandle The HII handle for an HII form associated with the
332 controller specified by ControllerHandle and ChildHandle.
336 ProcessSingleControllerHealth (
337 IN EFI_DRIVER_HEALTH_PROTOCOL
*DriverHealth
,
338 IN EFI_HANDLE ControllerHandle
, OPTIONAL
339 IN EFI_HANDLE ChildHandle
, OPTIONAL
340 IN EFI_DRIVER_HEALTH_STATUS HealthStatus
,
341 IN EFI_DRIVER_HEALTH_HII_MESSAGE
**MessageList
, OPTIONAL
342 IN EFI_HII_HANDLE FormHiiHandle
346 Repair notification function, simply print the repair progress.
348 @param Value The value of part has been repaired.
349 @param Limit Total value need to be repaired.
359 Processes a set of messages returned by the GetHealthStatus ()
360 service of the EFI Driver Health Protocol
362 @param MessageList The MessageList point to messages need to processed.
367 IN EFI_DRIVER_HEALTH_HII_MESSAGE
*MessageList
372 Collect and display the platform's driver health relative information, allow user to do interactive
373 operation while the platform is unhealthy.
375 This function display a form which divided into two parts. The one list all modules which has installed
376 driver health protocol. The list usually contain driver name, controller name, and it's health info.
377 While the driver name can't be retrieved, will use device path as backup. The other part of the form provide
378 a choice to the user to repair all platform.
388 Select the best matching language according to front page policy for best user experience.
390 This function supports both ISO 639-2 and RFC 4646 language codes, but language
391 code types may not be mixed in a single call to this function.
393 @param SupportedLanguages A pointer to a Null-terminated ASCII string that
394 contains a set of language codes in the format
395 specified by Iso639Language.
396 @param Iso639Language If TRUE, then all language codes are assumed to be
397 in ISO 639-2 format. If FALSE, then all language
398 codes are assumed to be in RFC 4646 language format.
400 @retval NULL The best matching language could not be found in SupportedLanguages.
401 @retval NULL There are not enough resources available to return the best matching
403 @retval Other A pointer to a Null-terminated ASCII string that is the best matching
404 language in SupportedLanguages.
407 DriverHealthSelectBestLanguage (
408 IN CHAR8
*SupportedLanguages
,
409 IN BOOLEAN Iso639Language
414 This is an internal worker function to get the Component Name (2) protocol interface
415 and the language it supports.
417 @param ProtocolGuid A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.
418 @param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
419 @param ComponentName A pointer to the Component Name (2) protocol interface.
420 @param SupportedLanguage The best suitable language that matches the SupportedLangues interface for the
421 located Component Name (2) instance.
423 @param EFI_SUCCESS The Component Name (2) protocol instance is successfully located and we find
424 the best matching language it support.
425 @param EFI_UNSUPPORTED The input Language is not supported by the Component Name (2) protocol.
426 @param Other Some error occurs when locating Component Name (2) protocol instance or finding
427 the supported language.
431 GetComponentNameWorker (
432 IN EFI_GUID
*ProtocolGuid
,
433 IN EFI_HANDLE DriverBindingHandle
,
434 OUT EFI_COMPONENT_NAME_PROTOCOL
**ComponentName
,
435 OUT CHAR8
**SupportedLanguage
440 This is an internal worker function to get driver name from Component Name (2) protocol interface.
443 @param ProtocolGuid A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.
444 @param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
445 @param DriverName A pointer to the Unicode string to return. This Unicode string is the name
446 of the driver specified by This.
448 @retval EFI_SUCCESS The driver name is successfully retrieved from Component Name (2) protocol
450 @retval Other The driver name cannot be retrieved from Component Name (2) protocol
455 GetDriverNameWorker (
456 IN EFI_GUID
*ProtocolGuid
,
457 IN EFI_HANDLE DriverBindingHandle
,
458 OUT CHAR16
**DriverName
463 This function gets driver name from Component Name 2 protocol interface and Component Name protocol interface
464 in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the driver name.
465 If the attempt fails, it then gets the driver name from EFI 1.1 Component Name protocol for backward
466 compatibility support.
468 @param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
469 @param DriverName A pointer to the Unicode string to return. This Unicode string is the name
470 of the driver specified by This.
472 @retval EFI_SUCCESS The driver name is successfully retrieved from Component Name (2) protocol
474 @retval Other The driver name cannot be retrieved from Component Name (2) protocol
479 DriverHealthGetDriverName (
480 IN EFI_HANDLE DriverBindingHandle
,
481 OUT CHAR16
**DriverName
485 This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface
486 in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.
487 If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward
488 compatibility support.
490 @param ProtocolGuid A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.
491 @param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
492 @param ControllerHandle The handle of a controller that the driver specified by This is managing.
493 This handle specifies the controller whose name is to be returned.
494 @param ChildHandle The handle of the child controller to retrieve the name of. This is an
495 optional parameter that may be NULL. It will be NULL for device drivers.
496 It will also be NULL for bus drivers that attempt to retrieve the name
497 of the bus controller. It will not be NULL for a bus driver that attempts
498 to retrieve the name of a child controller.
499 @param ControllerName A pointer to the Unicode string to return. This Unicode string
500 is the name of the controller specified by ControllerHandle and ChildHandle.
502 @retval EFI_SUCCESS The controller name is successfully retrieved from Component Name (2) protocol
504 @retval Other The controller name cannot be retrieved from Component Name (2) protocol.
509 GetControllerNameWorker (
510 IN EFI_GUID
*ProtocolGuid
,
511 IN EFI_HANDLE DriverBindingHandle
,
512 IN EFI_HANDLE ControllerHandle
,
513 IN EFI_HANDLE ChildHandle
,
514 OUT CHAR16
**ControllerName
518 This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface
519 in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.
520 If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward
521 compatibility support.
523 @param DriverBindingHandle The handle on which the Component Name (2) protocol instance is retrieved.
524 @param ControllerHandle The handle of a controller that the driver specified by This is managing.
525 This handle specifies the controller whose name is to be returned.
526 @param ChildHandle The handle of the child controller to retrieve the name of. This is an
527 optional parameter that may be NULL. It will be NULL for device drivers.
528 It will also be NULL for bus drivers that attempt to retrieve the name
529 of the bus controller. It will not be NULL for a bus driver that attempts
530 to retrieve the name of a child controller.
531 @param ControllerName A pointer to the Unicode string to return. This Unicode string
532 is the name of the controller specified by ControllerHandle and ChildHandle.
534 @retval EFI_SUCCESS The controller name is successfully retrieved from Component Name (2) protocol
536 @retval Other The controller name cannot be retrieved from Component Name (2) protocol.
540 DriverHealthGetControllerName (
541 IN EFI_HANDLE DriverBindingHandle
,
542 IN EFI_HANDLE ControllerHandle
,
543 IN EFI_HANDLE ChildHandle
,
544 OUT CHAR16
**ControllerName