Specifications
154
mSmmBase->GetSmstLocation(mSmmBase, &mSmst);
// Locate SwDispatch protocol
Status = gBS->LocateProtocol(&gEfiSmmSwDispatchProtocolGuid, NULL,
&mSwDispatch);
if (EFI_ERROR(Status)) {
DEBUG(( EFI_D_ERROR, "Couldn't find SmmSwDispatch protocol: %r\n",
Status));
return Status;
}
//
// Register for callbacks
//
// Pick a value for the context and register for it
SwContext.SwSmiInputValue = your value written to software SMI port;
Status = mSwDispatch->Register( mSwDispatch, SwCallback, &SwContext,
&SwHandle );
ASSERT_EFI_ERROR( Status );
// If your SMM handler can be entered via multiple soft SMM values
// then repeat the above 3 lines per additional value,
}
return EFI_SUCCESS;
}
////////////////////////////////////////////
// Callback functions
VOID
SwCallback (
IN EFI_HANDLE DispatchHandle,
IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext
)
{
DEBUG(( EFI_D_ERROR, " Sw SMI captured w/ context
0x%02x\n", DispatchContext->SwSmiInputValue));
// place your SMM code here
}
////////////////////////////////////////////










