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