19#define SMM_DATA_PORT 0xB3
20#define SMM_CONTROL_PORT 0xB2
52 IN OUT UINT8 *CommandPort OPTIONAL,
53 IN OUT UINT8 *DataPort OPTIONAL,
54 IN BOOLEAN Periodic OPTIONAL,
55 IN EFI_SMM_PERIOD ActivationInterval OPTIONAL
62 return EFI_INVALID_PARAMETER;
65 SmiEn =
IoRead32 (mSmiCtrlReg.Address);
66 SmiEnableBits = (1 << mSmiCtrlReg.GblBitOffset) | (1 << mSmiCtrlReg.ApmBitOffset);
67 if ((SmiEn & SmiEnableBits) != SmiEnableBits) {
71 IoWrite32 (mSmiCtrlReg.Address, SmiEn | SmiEnableBits);
74 IoWrite8 (SMM_DATA_PORT, DataPort ==
NULL ? 0 : *DataPort);
75 IoWrite8 (SMM_CONTROL_PORT, CommandPort ==
NULL ? 0 : *CommandPort);
96 return EFI_INVALID_PARAMETER;
134 for (Index = 0; Index < SmmRegister->Count; Index++) {
135 if (SmmRegister->Registers[Index].Id == Id) {
136 PldReg = &SmmRegister->Registers[Index];
141 if (PldReg ==
NULL) {
142 DEBUG ((DEBUG_INFO,
"Register %d not found.\n", Id));
149 if ((PldReg->Address.AccessSize != EFI_ACPI_3_0_DWORD) ||
150 (PldReg->Address.Address == 0) ||
151 (PldReg->Address.RegisterBitWidth != 1) ||
152 (PldReg->Address.AddressSpaceId != EFI_ACPI_3_0_SYSTEM_IO) ||
153 (PldReg->Value != 1))
155 DEBUG ((DEBUG_INFO,
"Unexpected SMM register.\n"));
156 DEBUG ((DEBUG_INFO,
"AddressSpaceId= 0x%x\n", PldReg->Address.AddressSpaceId));
157 DEBUG ((DEBUG_INFO,
"RegBitWidth = 0x%x\n", PldReg->Address.RegisterBitWidth));
158 DEBUG ((DEBUG_INFO,
"RegBitOffset = 0x%x\n", PldReg->Address.RegisterBitOffset));
159 DEBUG ((DEBUG_INFO,
"AccessSize = 0x%x\n", PldReg->Address.AccessSize));
160 DEBUG ((DEBUG_INFO,
"Address = 0x%lx\n", PldReg->Address.Address));
210 if (GuidHob ==
NULL) {
211 return EFI_UNSUPPORTED;
216 if (SmiGblEnReg ==
NULL) {
217 DEBUG ((DEBUG_ERROR,
"SMI global enable reg not found.\n"));
218 return EFI_NOT_FOUND;
221 mSmiCtrlReg.Address = (UINT32)SmiGblEnReg->Address.Address;
222 mSmiCtrlReg.GblBitOffset = SmiGblEnReg->Address.RegisterBitOffset;
225 if (SmiApmEnReg ==
NULL) {
226 DEBUG ((DEBUG_ERROR,
"SMI APM enable reg not found.\n"));
227 return EFI_NOT_FOUND;
230 if (SmiApmEnReg->Address.Address != mSmiCtrlReg.Address) {
231 DEBUG ((DEBUG_ERROR,
"SMI APM EN and SMI GBL EN are expected to have same register base\n"));
232 DEBUG ((DEBUG_ERROR,
"APM:0x%x, GBL:0x%x\n", SmiApmEnReg->Address.Address, mSmiCtrlReg.Address));
233 return EFI_UNSUPPORTED;
236 mSmiCtrlReg.ApmBitOffset = SmiApmEnReg->Address.RegisterBitOffset;
241 Status =
gBS->InstallMultipleProtocolInterfaces (
243 &gEfiSmmControl2ProtocolGuid,
249 Status =
gBS->CreateEventEx (
254 &gEfiEventVirtualAddressChangeGuid,
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
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 ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
PLD_GENERIC_REGISTER * GetSmmCtrlRegById(IN PLD_SMM_REGISTERS *SmmRegister, IN UINT32 Id)
EFI_STATUS EFIAPI SmmControlEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_SMM_CONTROL2_PROTOCOL mSmmControl2
EFI_STATUS EFIAPI Activate(IN CONST EFI_SMM_CONTROL2_PROTOCOL *This, IN OUT UINT8 *CommandPort OPTIONAL, IN OUT UINT8 *DataPort OPTIONAL, IN BOOLEAN Periodic OPTIONAL, IN EFI_SMM_PERIOD ActivationInterval OPTIONAL)
VOID EFIAPI SmmControlVirtualAddressChangeEvent(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI Deactivate(IN CONST EFI_SMM_CONTROL2_PROTOCOL *This, IN BOOLEAN Periodic)
EFI_GUID gSmmRegisterInfoGuid
EFI_STATUS EFIAPI EfiConvertPointer(IN UINTN DebugDisposition, IN OUT VOID **Address)