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