40 Node = mSmmSwDispatch2Queue.ForwardLink;
41 for ( ; Node != &mSmmSwDispatch2Queue; Node = Node->ForwardLink) {
43 if (Dispatch2Context->SwSmiInputValue == SwSmiInputValue) {
44 return Dispatch2Context;
66 Node = mSmmSwDispatch2Queue.ForwardLink;
67 for ( ; Node != &mSmmSwDispatch2Queue; Node = Node->ForwardLink) {
69 if (Dispatch2Context->DispatchHandle == DispatchHandle) {
70 return Dispatch2Context;
93 IN OUT VOID *CommBuffer,
101 EFI_SMM_HANDLER_ENTRY_POINT2 DispatchFunction;
117 Status = mSmmCpuProtocol->ReadSaveState (
120 EFI_SMM_SAVE_STATE_REGISTER_IO,
124 if (EFI_ERROR (Status)) {
128 if (IoInfo.
IoPort == SMM_CONTROL_PORT) {
139 DEBUG ((DEBUG_VERBOSE,
"NOT SW SMI\n"));
148 if (Context ==
NULL) {
149 DEBUG ((DEBUG_INFO,
"No handler for SMI value 0x%x\n", SwContext.
CommandPort));
154 DEBUG ((DEBUG_VERBOSE,
"Prepare to call handler for 0x%x\n", SwContext.
CommandPort));
159 DispatchContext.SwSmiInputValue = SwContext.
CommandPort;
160 Size =
sizeof (SwContext);
161 DispatchFunction = (EFI_SMM_HANDLER_ENTRY_POINT2)Context->DispatchFunction;
162 Status = DispatchFunction (DispatchHandle, &DispatchContext, &SwContext, &Size);
168 IoOr32 (mSmiPchReg.SmiApmStsAddr, 1 << mSmiPchReg.ApmBitOffset);
173 IoOr32 (mSmiPchReg.SmiEosAddr, 1 << mSmiPchReg.EosBitOffset);
195 Node = mSmmSwDispatch2Queue.ForwardLink;
196 for ( ; Node != &mSmmSwDispatch2Queue; Node = Node->ForwardLink) {
198 if (Dispatch2Context->SwSmiInputValue == SwSmiInputValue) {
199 return EFI_INVALID_PARAMETER;
238 IN EFI_SMM_HANDLER_ENTRY_POINT2 DispatchFunction,
247 if (RegContext->SwSmiInputValue == (
UINTN)-1) {
252 Status = EFI_NOT_FOUND;
253 for (Index = 1; Index < MAXIMUM_SWI_VALUE; Index++) {
255 if (!EFI_ERROR (Status)) {
256 RegContext->SwSmiInputValue = Index;
261 if (RegContext->SwSmiInputValue == (
UINTN)-1) {
262 return EFI_OUT_OF_RESOURCES;
266 if ((RegContext->SwSmiInputValue > MAXIMUM_SWI_VALUE) || (RegContext->SwSmiInputValue == 0)) {
267 DEBUG ((DEBUG_ERROR,
"ERROR: SMI value range (1 ~ 0x%x)\n", MAXIMUM_SWI_VALUE));
268 return EFI_INVALID_PARAMETER;
276 if (EFI_ERROR (Status)) {
277 return EFI_OUT_OF_RESOURCES;
281 Context->Signature = SMI_SW_HANDLER_SIGNATURE;
282 Context->SwSmiInputValue = RegContext->SwSmiInputValue;
283 Context->DispatchFunction = (
UINTN)DispatchFunction;
284 Context->DispatchHandle = *DispatchHandle;
315 ASSERT (Context !=
NULL);
316 if (Context !=
NULL) {
318 gSmst->SmmFreePool (Context);
350 for (Index = 0; Index < SmmRegister->Count; Index++) {
351 if (SmmRegister->Registers[Index].Id == Id) {
352 PldReg = &SmmRegister->Registers[Index];
357 if (PldReg ==
NULL) {
358 DEBUG ((DEBUG_INFO,
"Register %d not found.\n", Id));
365 if ((PldReg->Address.AccessSize != EFI_ACPI_3_0_DWORD) ||
366 (PldReg->Address.Address == 0) ||
367 (PldReg->Address.RegisterBitWidth != 1) ||
368 (PldReg->Address.AddressSpaceId != EFI_ACPI_3_0_SYSTEM_IO) ||
369 (PldReg->Value != 1))
371 DEBUG ((DEBUG_INFO,
"Unexpected SMM register.\n"));
372 DEBUG ((DEBUG_INFO,
"AddressSpaceId= 0x%x\n", PldReg->Address.AddressSpaceId));
373 DEBUG ((DEBUG_INFO,
"RegBitWidth = 0x%x\n", PldReg->Address.RegisterBitWidth));
374 DEBUG ((DEBUG_INFO,
"RegBitOffset = 0x%x\n", PldReg->Address.RegisterBitOffset));
375 DEBUG ((DEBUG_INFO,
"AccessSize = 0x%x\n", PldReg->Address.AccessSize));
376 DEBUG ((DEBUG_INFO,
"Address = 0x%lx\n", PldReg->Address.Address));
407 if (GuidHob ==
NULL) {
408 return EFI_UNSUPPORTED;
413 if (SmiEosReg ==
NULL) {
414 DEBUG ((DEBUG_ERROR,
"SMI EOS reg not found.\n"));
415 return EFI_NOT_FOUND;
418 mSmiPchReg.SmiEosAddr = (UINT32)SmiEosReg->Address.Address;
419 mSmiPchReg.EosBitOffset = SmiEosReg->Address.RegisterBitOffset;
422 if (SmiApmStsReg ==
NULL) {
423 DEBUG ((DEBUG_ERROR,
"SMI APM status reg not found.\n"));
424 return EFI_NOT_FOUND;
427 mSmiPchReg.SmiApmStsAddr = (UINT32)SmiApmStsReg->Address.Address;
428 mSmiPchReg.ApmBitOffset = SmiApmStsReg->Address.RegisterBitOffset;
433 Status =
gSmst->SmmLocateProtocol (&gEfiSmmCpuProtocolGuid,
NULL, (VOID **)&mSmmCpuProtocol);
448 &gEfiSmmSwDispatch2ProtocolGuid,
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
UINT32 EFIAPI IoOr32(IN UINTN Port, IN UINT32 OrData)
UINT8 EFIAPI IoRead8(IN UINTN Port)
#define BASE_CR(Record, TYPE, Field)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
EFI_STATUS SmmSwDispatcher(IN EFI_HANDLE DispatchHandle, IN CONST VOID *RegisterContext, IN OUT VOID *CommBuffer, IN OUT UINTN *CommBufferSize)
PLD_GENERIC_REGISTER * GetSmmCtrlRegById(IN PLD_SMM_REGISTERS *SmmRegister, IN UINT32 Id)
EFI_SMM_SW_DISPATCH2_CONTEXT * FindContextBySwSmiInputValue(IN UINTN SwSmiInputValue)
EFI_STATUS EFIAPI PchSmiDispatchEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_SMM_SW_DISPATCH2_CONTEXT * FindContextByDispatchHandle(IN EFI_HANDLE DispatchHandle)
EFI_STATUS EFIAPI SmmSwDispatch2UnRegister(IN CONST EFI_SMM_SW_DISPATCH2_PROTOCOL *This, IN EFI_HANDLE DispatchHandle)
EFI_STATUS SmiInputValueCheck(IN UINTN SwSmiInputValue)
EFI_STATUS EFIAPI SmmSwDispatch2Register(IN CONST EFI_SMM_SW_DISPATCH2_PROTOCOL *This, IN EFI_SMM_HANDLER_ENTRY_POINT2 DispatchFunction, IN OUT EFI_SMM_SW_REGISTER_CONTEXT *RegContext, OUT EFI_HANDLE *DispatchHandle)
EFI_STATUS(EFIAPI * EFI_MM_HANDLER_ENTRY_POINT)(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
EFI_SMM_SYSTEM_TABLE2 * gSmst
EFI_GUID gSmmRegisterInfoGuid
EFI_INSTALL_PROTOCOL_INTERFACE SmmInstallProtocolInterface
EFI_ALLOCATE_POOL SmmAllocatePool