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
544
545
546
547
548
549
550
551
552
553
|
/** @file
Defines and prototypes for the ActiveManagement driver.
This driver implements the ActiveManagement protocol for iAMT.
It provides some functions to get Boot Options from ASF.
@copyright
Copyright (c) 2004 - 2012 Intel Corporation. All rights
reserved This software and associated documentation (if any)
is furnished under a license and may only be used or copied in
accordance with the terms of the license. Except as permitted
by such license, no part of this software or documentation may
be reproduced, stored in a retrieval system, or transmitted in
any form or by any means without the express written consent
of Intel Corporation.
This file contains an 'Intel Peripheral Driver' and uniquely
identified as "Intel Reference Module" and is
licensed for Intel CPUs and chipsets under the terms of your
license agreement with Intel or your vendor. This file may
be modified by the user, subject to additional terms of the
license agreement
**/
//
// External include files do NOT need to be explicitly specified in real EDKII
// environment
//
#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
#include "EdkIIGlueDxe.h"
#include "ActiveManagement.h"
#include "MeLib.h"
#include "MeAccess.h"
#endif
//
// Global variables
//
EFI_ASF_BOOT_OPTIONS *mAsfBootOptions;
ACTIVE_MANAGEMENT_INSTANCE ActiveManagementInstance = {
ACTIVE_MANAGEMENT_PRIVATE_DATA_SIGNATURE,
NULL,
{
(EFI_ACTIVE_MANAGEMENT_BOOT_OPTIONS_STATE) GetIderState,
(EFI_ACTIVE_MANAGEMENT_BOOT_OPTIONS_STATE) GetEnforceSecureBootState,
(EFI_ACTIVE_MANAGEMENT_BOOT_OPTIONS_STATE) GetSolState,
(EFI_ACTIVE_MANAGEMENT_BOOT_OPTIONS_STATE) GetRemoteFlashState,
(EFI_ACTIVE_MANAGEMENT_BOOT_OPTIONS_STATE) GetBiosSetupState,
(EFI_ACTIVE_MANAGEMENT_BOOT_OPTIONS_STATE) GetBiosPauseState,
(EFI_ACTIVE_MANAGEMENT_BOOT_OPTIONS_STATE) GetConsoleLockState,
(EFI_ACTIVE_MANAGEMENT_BOOT_OPTIONS_STATE) GetKvmState,
(EFI_ACTIVE_MANAGEMENT_IDER_BOOT_DEVICE_SELECTED) GetIderBootDeviceSelectd,
(EFI_ACTIVE_MANAGEMENT_ASF_BOOT_OPTIONS_GET) GetAsfBootOptions,
(EFI_ACTIVE_MANAGEMENT_BOOT_OPTIONS_STATE) GetProgressMsgRequest
},
NULL
};
//
// Function implementations
//
/**
Check if ASF boot options is present.
@param[in] None.
@retval True ASF boot option is present.
@retval False ASF boot option is not present
**/
BOOLEAN
IsBootOptionsPresent (
VOID
)
{
return mAsfBootOptions->SubCommand == ASF_BOOT_OPTIONS_PRESENT;
}
/**
Check if LANA ID of ASF boot options is Industry ID.
@param[in] None.
@retval True IANA ID of ASF boot options is Industry ID.
@retval False IANA ID of ASF boot options is not Industry ID.
**/
BOOLEAN
IsIndustryIanaId (
VOID
)
{
volatile BOOLEAN RetVal;
RetVal = FALSE;
if (IsBootOptionsPresent ()) {
if (mAsfBootOptions->IanaId == ASF_INDUSTRY_CONVERTED_IANA) {
RetVal = TRUE;
}
}
return RetVal;
}
/**
Check if LANA ID of ASF boot options is Intel ID.
@param[in] None.
@retval True IANA ID of ASF boot options is Intel ID.
@retval False IANA ID of ASF boot options is not Intel ID.
**/
BOOLEAN
IsIntelIanaId (
VOID
)
{
volatile BOOLEAN RetVal;
RetVal = FALSE;
if (IsBootOptionsPresent ()) {
if (mAsfBootOptions->IanaId == ASF_INTEL_CONVERTED_IANA) {
RetVal = TRUE;
}
}
return RetVal;
}
/**
Check if it is Intel ASF boot options.
@param[in] None.
@retval True It is Intel ASF boot options.
@retval False It is not Intel ASF boot options.
**/
BOOLEAN
IsIntelAmtBootOptions (
VOID
)
{
BOOLEAN RetVal;
RetVal = FALSE;
if (IsIntelIanaId ()) {
if (mAsfBootOptions->SpecialCommand == ASF_INTEL_OEM_CMD) {
RetVal = TRUE;
}
}
return RetVal;
}
/**
Check the Special Command Parameter of Intel ASF boot options
@param[in] Options Special Command Parameter bit we want to check
Bit 0: Set if IDER is to be used on the next boot. Parameter 2 is set
to the driver number to be used.
Bit 1: Set if Secure Boot is enforced over IDER
Bit 2: Set if the BIOS is to be re-flashed on the next boot
Bit 3: Set if the BIOS is to boot into the BIOS set-up screen.
Bit 4: Boot into BIOS Pause on the next boot is supported
Bit 5: Set if the BIOS is to participate in KVM session
@param[in] CurrentState Return the state of result
True - Special Command Parameter bit in Options is enabled.
False - Special Command Parameter bit in Options is disabled.
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
GetSpecialParamState (
IN UINT16 Options,
IN OUT BOOLEAN *CurrentState
)
{
*CurrentState = FALSE;
if (IsIntelAmtBootOptions ()) {
if ((mAsfBootOptions->SpecialCommandParam & Options) == Options) {
*CurrentState = TRUE;
}
}
return EFI_SUCCESS;
}
/**
Check the OEM Parameter of Intel ASF boot options
@param[in] Options OEM Parameter bit we want to check
Bit 0: Set if SOL is to be used on the next boot.
@param[in] CurrentState Return the state of result
True : OEM Parameter bit in Options is enabled.
False : OEM Parameter bit in Options is disabled.
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
GetOemParamatersState (
IN UINT16 Options,
IN OUT BOOLEAN *CurrentState
)
{
*CurrentState = FALSE;
if (IsIntelAmtBootOptions ()) {
if ((mAsfBootOptions->OemParameters & Options) == Options) {
*CurrentState = TRUE;
}
}
return EFI_SUCCESS;
}
/**
Check the OEM Parameter of Intel ASF boot options
@param[in] Options OEM Parameter bit we want to check
Bit 0: Set if SOL is to be used on the next boot.
@param[in] CurrentState Return the state of result
True : OEM Parameter bit in Options is enabled.
False : OEM Parameter bit in Options is disabled.
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
GetBootOptionsMaskState (
IN UINT16 Options,
IN OUT BOOLEAN *CurrentState
)
{
*CurrentState = FALSE;
if (IsBootOptionsPresent ()) {
if ((mAsfBootOptions->BootOptions & Options) == Options) {
*CurrentState = TRUE;
}
}
return EFI_SUCCESS;
}
/**
This will return IDE Redirection Boot Option.
True if the option is enabled.
@param[in] This The address of protocol
@param[in] CurrentState Return the state of IDE Redireciton Boot Opiton
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
EFIAPI
GetIderState (
IN EFI_ACTIVE_MANAGEMENT_PROTOCOL *This,
IN OUT BOOLEAN *CurrentState
)
{
GetSpecialParamState (USE_IDER, CurrentState);
return EFI_SUCCESS;
}
/**
This will return IDE Redirection boot device to boot
@param[in] This The address of protocol
@param[in] IdeBootDevice Return the boot device number to boot
Bits 0-1: If IDER boot is selected in Perimeter 1 then Bits 1,2 define the drive on the IDER controller to be used as the boot driver.
Bit 1 Bit0
0 0 Primary Master Drive
0 1 Primary Slave Drive
1 0 Secondary Master Drive
1 1 Secondary Slave Drive
Bits 2-7: Reserved set to 0
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
EFIAPI
GetIderBootDeviceSelectd (
IN EFI_ACTIVE_MANAGEMENT_PROTOCOL *This,
IN OUT UINT8 *IdeBootDevice
)
{
*IdeBootDevice = (UINT8) ((mAsfBootOptions->SpecialCommandParam & IDER_BOOT_DEVICE_MASK) >> IDER_BOOT_DEVICE_SHIFT);
return EFI_SUCCESS;
}
/**
This will return Enforce Secure Boot over IDER Boot Option.
True if the option is enabled.
@param[in] This The address of protocol
@param[in] CurrentState Return the state of Enforce Secure Boot over IDER Boot Option
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
EFIAPI
GetEnforceSecureBootState (
IN EFI_ACTIVE_MANAGEMENT_PROTOCOL *This,
IN OUT BOOLEAN *CurrentState
)
{
GetSpecialParamState (ENFORCE_SECURE_BOOT, CurrentState);
return EFI_SUCCESS;
}
/**
This will return Serial-over-Lan Boot Option.
True if the option is enabled.
@param[in] This The address of protocol
@param[in] CurrentState Return the state of Serial-over-Lan Boot Opiton
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
EFIAPI
GetSolState (
IN EFI_ACTIVE_MANAGEMENT_PROTOCOL *This,
IN OUT BOOLEAN *CurrentState
)
{
GetOemParamatersState (USE_SOL, CurrentState);
return EFI_SUCCESS;
}
/**
This will return Remote Flash Boot Option.
True if the option is enabled.
@param[in] This The address of protocol
@param[in] CurrentState Return the state of Remote Flash Boot Opiton
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
EFIAPI
GetRemoteFlashState (
IN EFI_ACTIVE_MANAGEMENT_PROTOCOL *This,
IN OUT BOOLEAN *CurrentState
)
{
GetSpecialParamState (REFLASH_BIOS, CurrentState);
return EFI_SUCCESS;
}
/**
This will return BIOS Setup Boot Option.
True if the option is enabled.
@param[in] This The address of protocol
@param[in] CurrentState Return the state of BIOS Setup Boot Opiton
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
EFIAPI
GetBiosSetupState (
IN EFI_ACTIVE_MANAGEMENT_PROTOCOL *This,
IN OUT BOOLEAN *CurrentState
)
{
GetSpecialParamState (BIOS_SETUP, CurrentState);
return EFI_SUCCESS;
}
/**
This will return BIOS Pause Boot Option.
True if the option is enabled.
@param[in] This The address of protocol
@param[in] CurrentState Return the state of BIOS Pause Boot Opiton
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
EFIAPI
GetBiosPauseState (
IN EFI_ACTIVE_MANAGEMENT_PROTOCOL *This,
IN OUT BOOLEAN *CurrentState
)
{
GetSpecialParamState (BIOS_PAUSE, CurrentState);
return EFI_SUCCESS;
}
/**
This will return Console Lock Boot Option.
True if the option is enabled.
@param[in] This The address of protocol
@param[in] CurrentState Return the state of BIOS Pause Boot Opiton
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
EFIAPI
GetConsoleLockState (
IN EFI_ACTIVE_MANAGEMENT_PROTOCOL *This,
IN OUT BOOLEAN *CurrentState
)
{
GetBootOptionsMaskState (LOCK_KEYBOARD, CurrentState);
return EFI_SUCCESS;
}
/**
This will return KVM Boot Option.
True if the option is enabled.
@param[in] This The address of protocol
@param[in] CurrentState Return the state of KVM Boot Opiton
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
EFIAPI
GetKvmState (
IN EFI_ACTIVE_MANAGEMENT_PROTOCOL *This,
IN OUT BOOLEAN *CurrentState
)
{
GetSpecialParamState (USE_KVM, CurrentState);
return EFI_SUCCESS;
}
/**
Return current ASF Boot Options
@param[in] This Pointer to the EFI_ACTIVE_MANAGEMENT_PROTOCOL instance.
@param[in] AsfBootOptions ASF Boot Options
@retval EFI_SUCCESS Boot options updated
**/
EFI_STATUS
EFIAPI
GetAsfBootOptions (
IN EFI_ACTIVE_MANAGEMENT_PROTOCOL *This,
IN OUT EFI_ASF_BOOT_OPTIONS **AsfBootOptions
)
{
*AsfBootOptions = mAsfBootOptions;
return EFI_SUCCESS;
}
/**
Disable these two driver of Sol & Ider
@param[in] None
**/
VOID
SolIderDisable (
VOID
)
{
IderDisable ();
SolDisable ();
}
/**
Disable Usbr
@param[in] None
**/
VOID
UsbrDisable (
VOID
)
{
Usbr1Disable ();
Usbr2Disable ();
}
/**
This will return progress event Option.
True if the option is enabled.
@param[in] This The address of protocol
@param[in] CurrentState Return the state of progress event Opiton
@retval EFI_SUCCESS The function completed successfully.
**/
EFI_STATUS
EFIAPI
GetProgressMsgRequest (
IN EFI_ACTIVE_MANAGEMENT_PROTOCOL *This,
IN OUT BOOLEAN *CurrentState
)
{
GetBootOptionsMaskState (FORCE_PROGRESS_EVENTS, CurrentState);
return EFI_SUCCESS;
}
/**
Entry point for the Active Management Driver.
@param[in] ImageHandle Image handle of this driver.
@param[in] SystemTable Global system service table.
@retval EFI_SUCCESS Initialization complete.
@exception EFI_UNSUPPORTED The chipset is unsupported by this driver.
@retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
@retval EFI_DEVICE_ERROR Device error, driver exits abnormally.
**/
EFI_STATUS
EFIAPI
ActiveManagementEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
///
/// Check policy if AMT is supported
///
if (!AmtSupported () || !AsfSupported ()) {
SolIderDisable ();
UsbrDisable ();
return EFI_UNSUPPORTED;
}
///
/// Get Protocol for ASF
///
Status = gBS->LocateProtocol (
&gEfiAlertStandardFormatProtocolGuid,
NULL,
(VOID **) &(ActiveManagementInstance.Asf)
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
///
/// Get ASF Boot Options
///
Status = ActiveManagementInstance.Asf->GetBootOptions (ActiveManagementInstance.Asf, &mAsfBootOptions);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
///
/// Install the EFI_ACTIVE_MANAGEMENT_PROTOCOL interface
///
Status = gBS->InstallMultipleProtocolInterfaces (
&(ActiveManagementInstance.Handle),
&gEfiActiveManagementProtocolGuid,
&(ActiveManagementInstance.ActiveManagementProtocol),
NULL
);
return Status;
}
|