58STATIC BOOLEAN mSmiFeatureNegotiation;
91 IN OUT UINT8 *CommandPort OPTIONAL,
92 IN OUT UINT8 *DataPort OPTIONAL,
93 IN BOOLEAN Periodic OPTIONAL,
94 IN UINTN ActivationInterval OPTIONAL
100 if (Periodic || (ActivationInterval > 0)) {
101 return EFI_DEVICE_ERROR;
115 IoWrite8 (ICH9_APM_STS, DataPort ==
NULL ? 0 : *DataPort);
116 IoWrite8 (ICH9_APM_CNT, CommandPort ==
NULL ? 0 : *CommandPort);
140 IN BOOLEAN Periodic OPTIONAL
144 return EFI_INVALID_PARAMETER;
175SmmControl2DxeEntryPoint (
194 PmBase =
PciRead32 (POWER_MGMT_REGISTER_Q35 (ICH9_PMBASE)) &
196 mSmiEnable = PmBase + ICH9_PMBASE_OFS_SMI_EN;
203 SmiEnableVal =
IoRead32 (mSmiEnable);
204 if ((SmiEnableVal & ICH9_SMI_EN_APMC_EN) != 0) {
207 "%a: this Q35 implementation lacks SMI\n",
217 SmiEnableVal |= ICH9_SMI_EN_APMC_EN | ICH9_SMI_EN_GBL_SMI_EN;
224 POWER_MGMT_REGISTER_Q35 (ICH9_GEN_PMCON_1),
225 ICH9_GEN_PMCON_1_SMI_LOCK
232 IoWrite32 (mSmiEnable, SmiEnableVal & ~(UINT32)ICH9_SMI_EN_GBL_SMI_EN);
233 if (
IoRead32 (mSmiEnable) != SmiEnableVal) {
236 "%a: failed to lock down GBL_SMI_EN\n",
255 Status =
gBS->CreateEvent (
260 &mS3SaveStateInstalled
262 if (EFI_ERROR (Status)) {
263 DEBUG ((DEBUG_ERROR,
"%a: CreateEvent: %r\n", __func__, Status));
267 Status =
gBS->RegisterProtocolNotify (
268 &gEfiS3SaveStateProtocolGuid,
269 mS3SaveStateInstalled,
272 if (EFI_ERROR (Status)) {
275 "%a: RegisterProtocolNotify: %r\n",
285 Status =
gBS->SignalEvent (mS3SaveStateInstalled);
286 if (EFI_ERROR (Status)) {
287 DEBUG ((DEBUG_ERROR,
"%a: SignalEvent: %r\n", __func__, Status));
296 Status =
gBS->InstallMultipleProtocolInterfaces (
298 &gEfiSmmControl2ProtocolGuid,
302 if (EFI_ERROR (Status)) {
305 "%a: InstallMultipleProtocolInterfaces: %r\n",
315 if (mS3SaveStateInstalled !=
NULL) {
316 gBS->CloseEvent (mS3SaveStateInstalled);
325 return EFI_UNSUPPORTED;
346 UINT32 SmiEnOrMask, SmiEnAndMask;
347 UINT64 GenPmCon1Address;
348 UINT16 GenPmCon1OrMask, GenPmCon1AndMask;
350 ASSERT (Event == mS3SaveStateInstalled);
352 Status =
gBS->LocateProtocol (
353 &gEfiS3SaveStateProtocolGuid,
355 (VOID **)&S3SaveState
357 if (EFI_ERROR (Status)) {
365 SmiEnOrMask = ICH9_SMI_EN_APMC_EN | ICH9_SMI_EN_GBL_SMI_EN;
366 SmiEnAndMask = MAX_UINT32;
367 Status = S3SaveState->Write (
369 EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE,
370 EfiBootScriptWidthUint32,
375 if (EFI_ERROR (Status)) {
378 "%a: EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE: %r\n",
386 GenPmCon1Address = POWER_MGMT_REGISTER_Q35_EFI_PCI_ADDRESS (
389 GenPmCon1OrMask = ICH9_GEN_PMCON_1_SMI_LOCK;
390 GenPmCon1AndMask = MAX_UINT16;
391 Status = S3SaveState->Write (
393 EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE,
394 EfiBootScriptWidthUint16,
399 if (EFI_ERROR (Status)) {
402 "%a: EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE: %r\n",
410 DEBUG ((DEBUG_VERBOSE,
"%a: chipset boot script saved\n", __func__));
415 if (mSmiFeatureNegotiation) {
419 gBS->CloseEvent (Event);
420 mS3SaveStateInstalled =
NULL;
VOID EFIAPI CpuDeadLoop(VOID)
UINT8 EFIAPI IoWrite8(IN UINTN Port, IN UINT8 Value)
UINT32 EFIAPI IoRead32(IN UINTN Port)
UINT32 EFIAPI IoWrite32(IN UINTN Port, IN UINT32 Value)
#define DEBUG(Expression)
UINT32 EFIAPI PciRead32(IN UINTN Address)
UINT16 EFIAPI PciOr16(IN UINTN Address, IN UINT16 OrData)
#define PcdGetBool(TokenName)
#define FeaturePcdGet(TokenName)
BOOLEAN NegotiateSmiFeatures(VOID)
VOID SaveSmiFeatures(VOID)
STATIC EFI_STATUS EFIAPI SmmControl2DxeClear(IN CONST EFI_SMM_CONTROL2_PROTOCOL *This, IN BOOLEAN Periodic OPTIONAL)
STATIC EFI_STATUS EFIAPI SmmControl2DxeTrigger(IN CONST EFI_SMM_CONTROL2_PROTOCOL *This, IN OUT UINT8 *CommandPort OPTIONAL, IN OUT UINT8 *DataPort OPTIONAL, IN BOOLEAN Periodic OPTIONAL, IN UINTN ActivationInterval OPTIONAL)
STATIC VOID EFIAPI OnS3SaveStateInstalled(IN EFI_EVENT Event, IN VOID *Context)