diff options
Diffstat (limited to 'Chipset/SB/Smm2')
-rw-r--r-- | Chipset/SB/Smm2/SmiHandlerGeneric2.c | 1644 | ||||
-rw-r--r-- | Chipset/SB/Smm2/SmiHandlerPorting2.c | 1565 | ||||
-rw-r--r-- | Chipset/SB/Smm2/SmmChildDispatch2.h | 333 | ||||
-rw-r--r-- | Chipset/SB/Smm2/SmmChildDispatch2Main.c | 510 | ||||
-rw-r--r-- | Chipset/SB/Smm2/SmmChildDispatch2Protocol.c | 679 | ||||
-rw-r--r-- | Chipset/SB/Smm2/SmmChildDispatch2Protocol.h | 204 | ||||
-rw-r--r-- | Chipset/SB/Smm2/SmmChildDispatcher2.cif | 16 | ||||
-rw-r--r-- | Chipset/SB/Smm2/SmmChildDispatcher2.dxs | 58 | ||||
-rw-r--r-- | Chipset/SB/Smm2/SmmChildDispatcher2.mak | 85 | ||||
-rw-r--r-- | Chipset/SB/Smm2/SmmChildDispatcher2.sdl | 135 |
10 files changed, 5229 insertions, 0 deletions
diff --git a/Chipset/SB/Smm2/SmiHandlerGeneric2.c b/Chipset/SB/Smm2/SmiHandlerGeneric2.c new file mode 100644 index 0000000..d476784 --- /dev/null +++ b/Chipset/SB/Smm2/SmiHandlerGeneric2.c @@ -0,0 +1,1644 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* + +//************************************************************************* +// $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmiHandlerGeneric2.c 7 8/17/14 11:55p Mirayang $ +// +// $Revision: 7 $ +// +// $Date: 8/17/14 11:55p $ +//************************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmiHandlerGeneric2.c $ +// +// 7 8/17/14 11:55p Mirayang +// Fix Build Error when token "PI_0_9_CHILD_DISPATCHER_SUPPORT" = 0 +// +// 6 3/25/13 4:59a Wesleychen +// [TAG] None +// [Category] Improvement +// [Description] Refine GPI SMM2 related routines. +// [Files] SmiHandlerGeneric2.c; SmiHandlerPorting2.c; +// SmmChildDispatch2.h +// +// 5 3/15/13 2:25a Scottyang +// [TAG] None +// [Category] Improvement +// [Description] Support ULT GPISMI. +// [Files] SmiHandlerGeneric2.c +// +// 4 1/03/13 7:00a Scottyang +// [TAG] None +// [Category] Bug Fix +// [Severity] Important +// [Symptom] GPISMI cannot use. +// [RootCause] GPISMI2 will clear status before GPISMI. +// [Solution] GPISMI2 do not clear status when GPISMI has register. +// [Files] SmmChildDispatcher2.sdl; SmiHandlerGeneric2.c +// +// 3 8/30/12 9:50a Victortu +// [TAG] None +// [Category] Improvement +// [Description] Implement EIP#73211 and EIP#79156 for OA 3.0 function. +// [Files] SmiHandlerGeneric2.c, SmmChildDispatch2Main.c +// +// 2 4/25/12 9:32a Victortu +// [TAG] None +// [Category] Improvement +// [Description] Reprogram SMM ChildDispatcher drivers. +// [Files] SmiHandlerGeneric.c; SmiHandlerPorting.c; +// SmiHandlerGeneric2.c; SmmChildDispatch2Main.c; SmmChildDispatcher2.mak; +// SmmChildDispatcher2.sdl; SmmChildDispatch.h; SmmChildDispatchMain.c; +// SmmChildDispatchProtocol.c; SmmChildDispatcher.dxs; +// PchSmiDispatcher.sdl +// +// 1 2/08/12 8:28a Yurenlai +// Intel Lynx Point/SB eChipset initially releases. +// +//************************************************************************* +//<AMI_FHDR_START> +// +// Name: SmiHandlerGeneric2.c +// +// Description: This file contains implementation of generic SMI handler II +// functions +// +//<AMI_FHDR_END> +//************************************************************************* + +//--------------------------------------------------------------------------- +// Include(s) +//--------------------------------------------------------------------------- + +#include <Token.h> +#include <AmiDxeLib.h> +#include <AmiCspLib.h> +#include "SmmChildDispatch2.h" +#include <AmiSmm.h> + +//--------------------------------------------------------------------------- +// Constant, Macro and Type Definition(s) +//--------------------------------------------------------------------------- +// Constant Definition(s) + +// Macro Definition(s) + +// Type Definition(s) + +// Function Prototype(s) + +//--------------------------------------------------------------------------- +// Variable and External Declaration(s) +//--------------------------------------------------------------------------- +// Variable Declaration(s) + +static UINT64 gCurrentInterval = 0xffffffffffffffff; +static UINT16 gEnabledUsbSmi = 0; +static UINT16 gActiveUsbSmi = 0; +static UINT32 gEnabledGpiSmi = 0; +static UINT32 gEnabledTcoSmi = 0; +static UINT32 gEnabledIoTrapSmi = 0; +static UINT32 gIoTrapWriteData = 0; + +BOOLEAN gIsLastState = FALSE; + +// GUID Definition(s) + +// Protocol Definition(s) + +// External Declaration(s) + +extern EFI_SMM_SYSTEM_TABLE2 *gSmst2; +extern SMM_CHILD_DISPATCHER2 Smm2Handler[]; +extern EFI_SMM_SMI_CONTEXT2 SmiContext; + +extern UINT64 gSupportedIntervals[]; + +// Function Definition(s) + +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// Software SMI II Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSwAddHandler2 +// +// Description: This function adds SW SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_SW_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmSwAddHandler2 ( + IN VOID *Context ) +{ + if (Smm2Handler[EfiSmmSwSmi2].RegisteredCallbacks.Size == 1) SwSmiEnable(); + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSwRemoveHandler2 +// +// Description: This function removes SW SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_SW_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmSwRemoveHandler2 ( + IN VOID *Context ) +{ +#if (PI_0_9_CHILD_DISPATCHER_SUPPORT == 0) + if (Smm2Handler[EfiSmmSwSmi2].RegisteredCallbacks.Size == 1) SwSmiDisable(); +#endif + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSwVerifyContext2 +// +// Description: This function verifies SW SMI II context +// +// Input: *Context - Pointer to SMI II context +// +// Output: EFI_STATUS +// EFI_INVALID_PARAMETER - Given context is invalid +// EFI_SUCCESS - Context verified +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmSwVerifyContext2 ( + IN VOID *Context ) +{ + HANDLER_LINK2 *Handler = (HANDLER_LINK2 *)\ + Smm2Handler[EfiSmmSwSmi2].RegisteredCallbacks.pHead; + EFI_SMM_SW_REGISTER_CONTEXT *SwContext; + EFI_SMM_SW_REGISTER_CONTEXT *RegisteredSwContext; + + SwContext = (EFI_SMM_SW_REGISTER_CONTEXT *)Context; + // First check if we already registered handler for this value + while (Handler != NULL) { + RegisteredSwContext = (EFI_SMM_SW_REGISTER_CONTEXT *)Handler->Context; + if(SwContext->SwSmiInputValue == RegisteredSwContext->SwSmiInputValue) + // Handler with this value already registered + return EFI_INVALID_PARAMETER; + + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + + // Second check if given value is extended SMI value, + // check the lowest byte + if ((SwContext->SwSmiInputValue & 0xff) == EXTENDED_SMI) + return EFI_SUCCESS; // Accept value of UINTN size + + // Third check if given value is in default range + return (SwContext->SwSmiInputValue > MAX_SW_SMI_INPUT_VALUE) ? \ + EFI_INVALID_PARAMETER : EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSwGetContext2 +// +// Description: This function verifies SW SMI II event and sets SW SMI II +// context +// +// Input: None +// +// Output: BOOLEAN +// TRUE - SW SMI occured, context saved +// FALSE - There was no SW SMI II +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN SmmSwGetContext2 (VOID) +{ + UINT16 SwSmiNumber; + BOOLEAN SwSmiDetected; + + SwSmiDetected = SwSmiDetect( &SwSmiNumber ); + + if (SwSmiDetected) { + if(SwSmiNumber == EXTENDED_SMI) { + // Get the actual number from EAX register + SmiContext.SwContext.SwSmiInputValue = GetEAX(); + } else { + SmiContext.SwContext.SwSmiInputValue = SwSmiNumber; + } + } + + return SwSmiDetected; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSwDispatchSmi2 +// +// Description: This function dispatches SW SMI II event based on context +// +// Input: None +// +// Output: EFI_STATUS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmSwDispatchSmi2 ( VOID ) +{ + EFI_STATUS Status = EFI_WARN_INTERRUPT_SOURCE_QUIESCED; + HANDLER_LINK2 *Handler; + EFI_SMM_SW_REGISTER_CONTEXT *SwRegisterContext; + + EFI_SMM_SW_CONTEXT SwContext; + UINTN SwContextSize; + UINT16 i; + EFI_GUID SwSmiCpuTriggerGuid = SW_SMI_CPU_TRIGGER_GUID; + SW_SMI_CPU_TRIGGER *SwSmiCpuTrigger; + UINTN Cpu = pSmst->CurrentlyExecutingCpu - 1; //default cpu # + + for (i = 0; i < pSmst->NumberOfTableEntries; i++) + { + if (guidcmp(&(pSmst->SmmConfigurationTable[i].VendorGuid), &SwSmiCpuTriggerGuid) == 0) + break; + } + + //If found table, check for the CPU that caused the software Smi. + if (i != pSmst->NumberOfTableEntries) + { + SwSmiCpuTrigger = pSmst->SmmConfigurationTable[i].VendorTable; + Cpu = SwSmiCpuTrigger->Cpu; + } + + SwContext.SwSmiCpuIndex = Cpu; + SwContext.CommandPort = IoRead8(SW_SMI_IO_ADDRESS); + SwContext.DataPort = IoRead8(SW_SMI_IO_ADDRESS + 1); + SwContextSize = sizeof(SwContext); + + Handler = \ + (HANDLER_LINK2 *)Smm2Handler[EfiSmmSwSmi2].RegisteredCallbacks.pHead; + while (Handler != NULL) { + SwRegisterContext = (EFI_SMM_SW_REGISTER_CONTEXT *)Handler->Context; + if(SwRegisterContext->SwSmiInputValue == SmiContext.SwContext.SwSmiInputValue) + Status = Handler->Callback(Handler, SwRegisterContext, &SwContext, &SwContextSize); + + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + +/*#if (CHILD_DISPATCHER_SUPPORT != 0) + if (!EFI_ERROR(Status)) +#endif*/ +if (Status != EFI_WARN_INTERRUPT_SOURCE_QUIESCED) + SwSmiClear(); + + return EFI_WARN_INTERRUPT_SOURCE_QUIESCED; +} + +//--------------------------------------------------------------------------- +// Sleep SMI II Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSxAddHandler2 +// +// Description: This function adds Sx SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_SX_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmSxAddHandler2 ( + IN VOID *Context ) +{ +#if SLP_SMI_ENABLE_ON_REGISTER + if (Smm2Handler[EfiSmmSxSmi2].RegisteredCallbacks.Size == 1) SxSmiEnable(); +#endif + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSxRemoveHandler2 +// +// Description: This function removes Sx SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_SX_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmSxRemoveHandler2 ( + IN VOID *Context ) +{ +#if SLP_SMI_ENABLE_ON_REGISTER && (PI_0_9_CHILD_DISPATCHER_SUPPORT == 0) + if (Smm2Handler[EfiSmmSxSmi2].RegisteredCallbacks.Size == 1) SxSmiDisable(); +#endif + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSxVerifyContext2 +// +// Description: This function verifies Sx SMI II context +// +// Input: *Context - Pointer to SMI II context +// +// Output: EFI_STATUS +// EFI_SUCCESS - Context verified +// EFI_INVALID_PARAMETER - Given context is invalid +// EFI_UNSUPPORTED - Context is not supported +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmSxVerifyContext2 ( + IN VOID *Context ) +{ + EFI_SMM_SX_REGISTER_CONTEXT *SxContext; + + SxContext = (EFI_SMM_SX_REGISTER_CONTEXT *)Context; + if ((SxContext->Type >= EfiMaximumSleepType) || \ + (SxContext->Phase >= EfiMaximumPhase)) + return EFI_INVALID_PARAMETER; + + return ((SxContext->Phase) != SxEntry) ? EFI_UNSUPPORTED : EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSxGetContext2 +// +// Description: This function verifies Sx SMI II event and sets SX SMI II +// context +// +// Input: None +// +// Output: BOOLEAN +// TRUE - Sx SMI occured, context saved +// FALSE - There was no SX SMI II +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN SmmSxGetContext2 (VOID) +{ + UINT16 SxSleepState; + BOOLEAN SxSmiDetected; + + SxSmiDetected = SxSmiDetect( &SxSleepState ); + + SmiContext.SxContext.Type = SxSleepState; + SmiContext.SxContext.Phase = SxEntry; + + return SxSmiDetected; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSxDispatchSmi2 +// +// Description: This function dispatches Sx SMI II event based on context +// +// Input: None +// +// Output: EFI_STATUS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmSxDispatchSmi2 (VOID) +{ + EFI_STATUS Status = EFI_WARN_INTERRUPT_SOURCE_QUIESCED; + HANDLER_LINK2 *Handler; + EFI_SMM_SX_REGISTER_CONTEXT *SxContext; + + Handler = \ + (HANDLER_LINK2 *)Smm2Handler[EfiSmmSxSmi2].RegisteredCallbacks.pHead; + while (Handler != NULL) { + SxContext = (EFI_SMM_SX_REGISTER_CONTEXT *)Handler->Context; + + if ((SxContext->Type == SmiContext.SxContext.Type) && \ + (SxContext->Phase == SmiContext.SxContext.Phase)) + Status = Handler->Callback(Handler, SxContext, NULL, NULL); + + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + +#if (PI_0_9_CHILD_DISPATCHER_SUPPORT == 0) + SxSmiClear(); + + if (SmiContext.SxContext.Type == SxS0) return Status; + + PutToSleep( &(SmiContext.SxContext) ); + + // Control returns here on S1. + + SxSmiClear(); + + return Status; +#else + return EFI_WARN_INTERRUPT_SOURCE_QUIESCED; +#endif +} + +//--------------------------------------------------------------------------- +// Periodic timer SMI II Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmTimerAddHandler2 +// +// Description: This function adds Periodic timer SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmTimerAddHandler2 ( + IN VOID *Context ) +{ + EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT *TimerContext; + + TimerContext = (EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT *)Context; + + if (Smm2Handler[EfiSmmPeriodicTimerSmi2].RegisteredCallbacks.Size == 1) { + gCurrentInterval = TimerContext->OrgContext.SmiTickInterval; + TimerSetInterval2( TimerContext->OrgContext.SmiTickInterval ); + TimerSmiClear2(); + TimerSmiEnable2(); + return EFI_SUCCESS; + } + + if (gCurrentInterval > TimerContext->OrgContext.SmiTickInterval) { + gCurrentInterval = TimerContext->OrgContext.SmiTickInterval; + TimerSetInterval2( TimerContext->OrgContext.SmiTickInterval ); + } + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmTimerRemoveHandler2 +// +// Description: This function removes Periodic timer SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmTimerRemoveHandler2 ( + IN VOID *Context ) +{ + HANDLER_LINK2 *Handler = (HANDLER_LINK2 *)\ + Smm2Handler[EfiSmmPeriodicTimerSmi2].RegisteredCallbacks.pHead; + EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT *TimerContext; + EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT *CurrentTimerContext; + UINT64 Interval = 0xffffffffffffffff; + + UINT16 CurrentIntervalCounter = 0; + UINT64 *SupportedIntervals = gSupportedIntervals; + + if (Smm2Handler[EfiSmmPeriodicTimerSmi2].RegisteredCallbacks.Size == 1) { + gCurrentInterval = 0xffffffffffffffff; + TimerSmiDisable2(); + return EFI_SUCCESS; + } + + CurrentTimerContext = \ + (EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT *)Context; + while (Handler != NULL) { + TimerContext = \ + (EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT *)Handler->Context; + if (Interval > TimerContext->OrgContext.SmiTickInterval) + Interval = TimerContext->OrgContext.SmiTickInterval; + if (TimerContext->OrgContext.SmiTickInterval == \ + CurrentTimerContext->OrgContext.SmiTickInterval) + CurrentIntervalCounter++; + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + + if ((Interval == CurrentTimerContext->OrgContext.SmiTickInterval) && \ + (CurrentIntervalCounter == 1)) { + Interval = 0xffffffffffffffff; + while (*SupportedIntervals != 0) { + if (*SupportedIntervals != \ + CurrentTimerContext->OrgContext.SmiTickInterval) + if (*SupportedIntervals < Interval) + Interval = *SupportedIntervals; + SupportedIntervals++; + } + } + + // This means lowest rate timer no longer active + if (gCurrentInterval < Interval) { + gCurrentInterval = Interval; + TimerSetInterval2( Interval ); + } + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmTimerVerifyContext2 +// +// Description: This function verifies Periodic timer SMI II context +// +// Input: *Context - Pointer to SMI II context +// +// Output: EFI_STATUS +// EFI_INVALID_PARAMETER - Given context is invalid +// EFI_SUCCESS - Context verified +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmTimerVerifyContext2 ( + IN VOID *Context ) +{ + EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT *TimerContext; + UINT64 *Interval = gSupportedIntervals; + + TimerContext = (EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT *)Context; + while (*Interval != 0) { + if (*Interval == TimerContext->OrgContext.SmiTickInterval) + return EFI_SUCCESS; + Interval++; + } + + return EFI_INVALID_PARAMETER; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmTimerGetContext2 +// +// Description: This function verifies Periodic timer SMI II event and sets +// Periodic timer SMI II context +// +// Input: None +// +// Output: BOOLEAN +// TRUE - Periodic timer SMI occured, context saved +// FALSE - There was no Periodic timer SMI +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN SmmTimerGetContext2 (VOID) +{ + UINT16 TimerType; + BOOLEAN TimerSmiDetected; + + TimerSmiDetected = TimerSmiDetect2( &TimerType ); + SmiContext.TimerContext.OrgContext.SmiTickInterval = gCurrentInterval; + + return TimerSmiDetected; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmTimerDispatchSmi2 +// +// Description: This function dispatches Periodic timer SMI event based on +// context +// +// Input: None +// +// Output: EFI_STATUS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmTimerDispatchSmi2 (VOID) +{ + EFI_STATUS Status = EFI_WARN_INTERRUPT_SOURCE_QUIESCED; + HANDLER_LINK2 *Handler = (HANDLER_LINK2 *)\ + Smm2Handler[EfiSmmPeriodicTimerSmi2].RegisteredCallbacks.pHead; + EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT *TimerContext; + + while (Handler != NULL) { + TimerContext = \ + (EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT *)Handler->Context; + + TimerContext->ElapsedTime += \ + SmiContext.TimerContext.OrgContext.SmiTickInterval; + if (TimerContext->ElapsedTime >= TimerContext->OrgContext.Period){ + Status = Handler->Callback(Handler, TimerContext, NULL, NULL); + TimerContext->ElapsedTime = 0; + } + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + +#if (PI_0_9_CHILD_DISPATCHER_SUPPORT == 0) + TimerSmiClear2(); + return Status; +#else + return EFI_WARN_INTERRUPT_SOURCE_QUIESCED; +#endif + +} + +//--------------------------------------------------------------------------- +// USB SMI II Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmUsbAddHandler2 +// +// Description: This function adds USB SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_USB_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmUsbAddHandler2 ( + IN VOID *Context +) +{ + EFI_STATUS Status; + EFI_SMM_USB_REGISTER_CONTEXT *UsbContext; + UINT16 ControllerType; + VOID *NewDp; + UINTN Length; + + UsbContext = (EFI_SMM_USB_REGISTER_CONTEXT *)Context; + + // Save USB device path protocol into SMM memory + Length = DPLength( UsbContext->Device ); + Status = gSmst2->SmmAllocatePool( 0, Length, &NewDp ); + if (EFI_ERROR(Status)) return Status; + MemCpy( NewDp, UsbContext->Device, Length ); + UsbContext->Device = (EFI_DEVICE_PATH_PROTOCOL *)NewDp; + + ControllerType = GetControllerType( UsbContext->Device ); + if((ControllerType & gEnabledUsbSmi) == 0) { + gEnabledUsbSmi |= ControllerType; + UsbSmiSet( gEnabledUsbSmi ); + } + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmUsbRemoveHandler2 +// +// Description: This function removes USB SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_USB_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmUsbRemoveHandler2 ( + IN VOID *Context ) +{ + HANDLER_LINK2 *Handler = (HANDLER_LINK2 *)\ + Smm2Handler[EfiSmmUsbSmi2].RegisteredCallbacks.pHead; + EFI_SMM_USB_REGISTER_CONTEXT *UsbContext; + UINT16 ControllerType = 0; + + UsbContext = (EFI_SMM_USB_REGISTER_CONTEXT *)Context; + + gSmst2->SmmFreePool( UsbContext->Device ); + + if (Smm2Handler[EfiSmmUsbSmi2].RegisteredCallbacks.Size == 1) { + gEnabledUsbSmi = 0; + UsbSmiSet( gEnabledUsbSmi ); + return EFI_SUCCESS; + } + + while (Handler != NULL) { + UsbContext = (EFI_SMM_USB_REGISTER_CONTEXT *)Handler->Context; + ControllerType |= GetControllerType( UsbContext->Device ); + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + + if (ControllerType != gEnabledUsbSmi) { + gEnabledUsbSmi = ControllerType; + UsbSmiSet( gEnabledUsbSmi ); + } + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmUsbVerifyContext2 +// +// Description: This function verifies USB SMI II context +// +// Input: *Context - Pointer to SMI II context +// +// Output: EFI_STATUS +// EFI_INVALID_PARAMETER - Given context is invalid +// EFI_SUCCESS - Context verified +// EFI_UNSUPPORTED - Context is not supported +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmUsbVerifyContext2 ( + IN VOID *Context ) +{ + EFI_SMM_USB_REGISTER_CONTEXT *UsbContext; + UINT16 ControllerType; + + UsbContext = (EFI_SMM_USB_REGISTER_CONTEXT *)Context; + ControllerType = GetControllerType( UsbContext->Device ); + if (((ControllerType & 7) == 0) || (UsbContext->Type > UsbWake)) + return EFI_INVALID_PARAMETER; + + return ((UsbContext->Type) > UsbLegacy) ? EFI_UNSUPPORTED : EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmUsbGetContext2 +// +// Description: This function verifies USB SMI II event and sets USB SMI II +// context +// +// Input: None +// +// Output: BOOLEAN +// TRUE - USB SMI occured, context saved +// FALSE - There was no USB SMI +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN SmmUsbGetContext2 (VOID) +{ + BOOLEAN UsbSmiDetected; + + UsbSmiDetected = UsbSmiDetect( &gActiveUsbSmi ); + SmiContext.UsbContext.Type = UsbLegacy; + + return UsbSmiDetected; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmUsbDispatchSmi2 +// +// Description: This function dispatches USB SMI II event based on context +// +// Input: None +// +// Output: EFI_STATUS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmUsbDispatchSmi2 (VOID) +{ + EFI_STATUS Status = EFI_WARN_INTERRUPT_SOURCE_QUIESCED; + HANDLER_LINK2 *Handler = (HANDLER_LINK2 *)\ + Smm2Handler[EfiSmmUsbSmi2].RegisteredCallbacks.pHead; + EFI_SMM_USB_REGISTER_CONTEXT *UsbContext; + UINT16 ControllerType; + + while (Handler != NULL) { + UsbContext = (EFI_SMM_USB_REGISTER_CONTEXT *)Handler->Context; + ControllerType = GetControllerType( UsbContext->Device ); + + if (((ControllerType & gActiveUsbSmi) != 0) && \ + (UsbContext->Type == SmiContext.UsbContext.Type)) + Status = Handler->Callback(Handler, UsbContext, NULL, NULL); + + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + +#if (PI_0_9_CHILD_DISPATCHER_SUPPORT == 0) + UsbSmiClear( gActiveUsbSmi ); + gActiveUsbSmi = 0; + return Status; +#else + gActiveUsbSmi = 0; + return EFI_WARN_INTERRUPT_SOURCE_QUIESCED; +#endif + +} + +//--------------------------------------------------------------------------- +// GPI SMI II Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmGpiAddHandler2 +// +// Description: This function adds GPI SMI II handler +// +// Input: VOID *Context - Pointer to EFI_SMM_GPI_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmGpiAddHandler2 ( + IN VOID *Context ) +{ + EFI_SMM_GPI_REGISTER_CONTEXT *GpiContext; + UINT32 GpiBitMap = 0; + + GpiContext = (EFI_SMM_GPI_REGISTER_CONTEXT *)Context; + + GpiBitMap = ConvertGpi (GpiContext->GpiNum); + + if ((GpiBitMap & gEnabledGpiSmi) == 0) { + gEnabledGpiSmi |= GpiBitMap; + GpiSmiSet( GpiBitMap ); + } + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmGpiRemoveHandler2 +// +// Description: This function removes GPI SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_GPI_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmGpiRemoveHandler2 ( + IN VOID *Context ) +{ + EFI_SMM_GPI_REGISTER_CONTEXT *GpiContext; + UINT32 GpiBitMap = 0; + + GpiContext = (EFI_SMM_GPI_REGISTER_CONTEXT *)Context; + + GpiBitMap = ConvertGpi (GpiContext->GpiNum); + + gEnabledGpiSmi &= ~(GpiBitMap); + + GpiSmiReset( GpiBitMap ); + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmGpiVerifyContext2 +// +// Description: This function verifies GPI SMI II context +// +// Input: *Context - Pointer to SMI II context +// +// Output: EFI_STATUS +// EFI_INVALID_PARAMETER - Given context is invalid +// EFI_SUCCESS - Context verified +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmGpiVerifyContext2 ( + IN VOID *Context ) +{ + EFI_SMM_GPI_REGISTER_CONTEXT *GpiContext; + UINT32 GpiBitMap = 0; + + GpiContext = (EFI_SMM_GPI_REGISTER_CONTEXT *)Context; + + GpiBitMap = ConvertGpi (GpiContext->GpiNum); + + if ((GpiBitMap & SUPPORTED_GPIS2) == 0) + return EFI_INVALID_PARAMETER; + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmGpiGetContext2 +// +// Description: This function verifies GPI SMI II event and sets GPI SMI II +// context +// +// Input: None +// +// Output: BOOLEAN +// TRUE - GPI SMI occured, context saved +// FALSE - There was no GPI SMI +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN SmmGpiGetContext2 (VOID) +{ + BOOLEAN GpiSmiDetected; + UINT32 GpiSmiNum; + + GpiSmiDetected = GpiSmiDetect( &GpiSmiNum ); + SmiContext.GpiContext.GpiNum = GpiSmiNum; + + return GpiSmiDetected; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmGpiDispatchSmi2 +// +// Description: This function dispatches GPI SMI event based on context +// +// Input: None +// +// Output: EFI_STATUS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmGpiDispatchSmi2 (VOID) +{ + EFI_STATUS Status = EFI_WARN_INTERRUPT_SOURCE_QUIESCED; + HANDLER_LINK2 *Handler = (HANDLER_LINK2 *)\ + Smm2Handler[EfiSmmGpiSmi2].RegisteredCallbacks.pHead; + EFI_SMM_GPI_REGISTER_CONTEXT *GpiContext; + UINT32 GpiBitMap = 0; + BOOLEAN GpiSmiServiced = FALSE; + + while (Handler != NULL) { + GpiContext = (EFI_SMM_GPI_REGISTER_CONTEXT *)Handler->Context; + + GpiBitMap = ConvertGpi (GpiContext->GpiNum); + + GpiSmiServiced = FALSE; + if ((SmiContext.GpiContext.GpiNum & GpiBitMap) != 0) { + Status = Handler->Callback( Handler, GpiContext, NULL, NULL ); + GpiSmiServiced = TRUE; + } + + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + + if (GpiSmiServiced) + GpiSmiClear( (UINT16)SmiContext.GpiContext.GpiNum ); + +#if (PI_0_9_CHILD_DISPATCHER_SUPPORT == 0) + return Status; +#else + return EFI_WARN_INTERRUPT_SOURCE_QUIESCED; +#endif + +} + +//--------------------------------------------------------------------------- +// Standby button SMI II Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSButtonAddHandler2 +// +// Description: This function adds Standby button SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmSButtonAddHandler2 ( + IN VOID *Context ) +{ + if (Smm2Handler[EfiSmmStandbyButtonSmi2].RegisteredCallbacks.Size == 1) + SButtonSmiEnable(); + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSButtonRemoveHandler2 +// +// Description: This function removes Standby button SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmSButtonRemoveHandler2 ( + IN VOID *Context ) +{ + if (Smm2Handler[EfiSmmStandbyButtonSmi2].RegisteredCallbacks.Size == 1) + SButtonSmiDisable(); + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSButtonVerifyContext2 +// +// Description: This function verifies Standby button SMI II context +// +// Input: VOID *Context - Pointer to SMI II context +// +// Output: EFI_STATUS +// EFI_INVALID_PARAMETER - Given context is invalid +// EFI_SUCCESS - Context verified +// EFI_UNSUPPORTED - Context is not supported +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmSButtonVerifyContext2 ( + IN VOID *Context ) +{ + EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT *SButtonContext; + + SButtonContext = (EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT *)Context; + if (SButtonContext->Phase >= EfiStandbyButtonMax) + return EFI_INVALID_PARAMETER; + + return (SButtonContext->Phase > EfiStandbyButtonEntry) \ + ? EFI_UNSUPPORTED : EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSButtonGetContext2 +// +// Description: This function verifies Standby button SMI II event and sets +// Standby button SMI II context +// +// Input: None +// +// Output: BOOLEAN +// TRUE - Standby button SMI occured, context saved +// FALSE - There was no Standby button SMI +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN SmmSButtonGetContext2 (VOID) +{ + UINT16 Dummy = 0; + BOOLEAN SButtonSmiDetected; + + SButtonSmiDetected = SButtonSmiDetect( &Dummy ); + + SmiContext.SBtnContext.Phase = EfiStandbyButtonEntry; + + return SButtonSmiDetected; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmSButtonDispatchSmi2 +// +// Description: This function dispatches Standby button SMI II event based on +// context +// +// Input: None +// +// Output: EFI_STATUS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmSButtonDispatchSmi2 (VOID) +{ + EFI_STATUS Status = EFI_WARN_INTERRUPT_SOURCE_QUIESCED; + HANDLER_LINK2 *Handler = (HANDLER_LINK2 *)\ + Smm2Handler[EfiSmmStandbyButtonSmi2].RegisteredCallbacks.pHead; + EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT *SButtonContext; + + while (Handler != NULL) { + SButtonContext = \ + (EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT *)Handler->Context; + + if (SButtonContext->Phase == SmiContext.SBtnContext.Phase) + Status = Handler->Callback( Handler, SButtonContext, NULL, NULL ); + + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + +#if (PI_0_9_CHILD_DISPATCHER_SUPPORT == 0) + SButtonSmiClear(); + + return Status; +#else + return EFI_WARN_INTERRUPT_SOURCE_QUIESCED; +#endif +} + +//--------------------------------------------------------------------------- +// Power button SMI II Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmPButtonAddHandler2 +// +// Description: This function adds Power button SMI II handler +// +// Input: *Context - pointer to EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmPButtonAddHandler2 ( + IN VOID *Context ) +{ + if (Smm2Handler[EfiSmmPowerButtonSmi2].RegisteredCallbacks.Size == 1) + PButtonSmiEnable(); + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmPButtonRemoveHandler2 +// +// Description: This function removes Power button SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS; +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmPButtonRemoveHandler2 ( + IN VOID *Context ) +{ + if (Smm2Handler[EfiSmmPowerButtonSmi2].RegisteredCallbacks.Size == 1) + PButtonSmiDisable(); + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmPButtonVerifyContext2 +// +// Description: This function verifies Power button SMI II context +// +// Input: *Context - Pointer to SMI II context +// +// Output: EFI_STATUS +// EFI_INVALID_PARAMETER - Given context is invalid +// EFI_SUCCESS - Context verified +// EFI_UNSUPPORTED - Context is not supported +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmPButtonVerifyContext2 ( + IN VOID *Context ) +{ + EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT *PButtonContext; + + PButtonContext = (EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT *)Context; + if (PButtonContext->Phase >= EfiPowerButtonMax) + return EFI_INVALID_PARAMETER; + + return (PButtonContext->Phase > EfiPowerButtonEntry) ? \ + EFI_UNSUPPORTED : EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmPButtonGetContext2 +// +// Description: This function verifies Power button SMI II event and sets +// Power button SMI II context +// +// Input: None +// +// Output: BOOLEAN +// TRUE - Power button SMI occured, context saved +// FALSE - There was no Power button SMI +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN SmmPButtonGetContext2 (VOID) +{ + UINT16 Dummy = 0; + BOOLEAN PButtonSmiDetected; + + PButtonSmiDetected = PButtonSmiDetect( &Dummy ); + + SmiContext.PBtnContext.Phase = EfiPowerButtonEntry; + + return PButtonSmiDetected; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmPButtonDispatchSmi2 +// +// Description: This function dispatches Power button SMI II event based on +// context +// +// Input: None +// +// Output: EFI_STATUS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmPButtonDispatchSmi2 (VOID) +{ + EFI_STATUS Status = EFI_WARN_INTERRUPT_SOURCE_QUIESCED; + HANDLER_LINK2 *Handler = (HANDLER_LINK2 *)\ + Smm2Handler[EfiSmmPowerButtonSmi2].RegisteredCallbacks.pHead; + EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT *PButtonContext; + + while (Handler != NULL) { + PButtonContext = \ + (EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT *)Handler->Context; + + if (PButtonContext->Phase == SmiContext.PBtnContext.Phase) + Status = Handler->Callback( Handler, PButtonContext, NULL, NULL ); + + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + +#if (PI_0_9_CHILD_DISPATCHER_SUPPORT == 0) + PButtonSmiClear(); + SBLib_Shutdown(); + + return Status; +#else + return EFI_WARN_INTERRUPT_SOURCE_QUIESCED; +#endif +} + +//--------------------------------------------------------------------------- +// I/O Trap SMI II Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmIoTrapAddHandler2 +// +// Description: This function adds I/O Trap SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_IO_TRAP_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS - The context has been registerd successfully. +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmIoTrapAddHandler2 ( + IN VOID *Context ) +{ + HANDLER_LINK2 *Handler; + EFI_SMM_IO_TRAP_REGISTER_CONTEXT *RegedContext; + EFI_SMM_IO_TRAP_REGISTER_CONTEXT *IoTrapContext; + UINT32 TrapRegIndex = 0; + UINT32 i = 0; + + IoTrapContext = (EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context; + + Handler = \ + (HANDLER_LINK2 *)Smm2Handler[EfiSmmIoTrapSmi2].RegisteredCallbacks.pHead; + + while (Handler != NULL) { + RegedContext = (EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Handler->Context; + if ((RegedContext->Address == IoTrapContext->Address) && \ + (RegedContext->Type == IoTrapContext->Type) && \ + (RegedContext->Length == IoTrapContext->Length)) { + i++; + } + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + + if (i > 1) return EFI_SUCCESS; + + IoTrapSmiSet2( IoTrapContext, &TrapRegIndex ); + + gEnabledIoTrapSmi |= (UINT32)(1 << TrapRegIndex); + + if (Smm2Handler[EfiSmmIoTrapSmi2].RegisteredCallbacks.Size == 1) + IoTrapSmiEnable2(); + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmIoTrapRemoveHandler2 +// +// Description: This function removes I/O Trap SMI II handler +// +// Input: *Context - Pointer to EFI_SMM_IO_TRAP_REGISTER_CONTEXT +// +// Output: EFI_SUCCESS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmIoTrapRemoveHandler2 ( + IN VOID *Context ) +{ + HANDLER_LINK2 *Handler; + EFI_SMM_IO_TRAP_REGISTER_CONTEXT *RegedContext; + EFI_SMM_IO_TRAP_REGISTER_CONTEXT *RemoveContext; + UINT32 i = 0; + UINT32 TrapRegIndex = 0; + + RemoveContext = (EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context; + + Handler = \ + (HANDLER_LINK2 *)Smm2Handler[EfiSmmIoTrapSmi2].RegisteredCallbacks.pHead; + + while (Handler != NULL) { + RegedContext = (EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Handler->Context; + if ((RegedContext->Address == RemoveContext->Address) && \ + (RegedContext->Type == RemoveContext->Type) && \ + (RegedContext->Length == RemoveContext->Length)) i++; + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + + if (i > 1) return EFI_SUCCESS; + + IoTrapSmiReset2( Context, &TrapRegIndex ); + + gEnabledIoTrapSmi &= ~(1 << TrapRegIndex); + + if (gEnabledIoTrapSmi == 0) IoTrapSmiDisable2(); + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmIoTrapVerifyContext2 +// +// Description: This function verifies I/O Trap SMI II context +// +// Input: *Context - Pointer to SMI II context +// +// Output: EFI_STATUS +// EFI_SUCCESS - Context verified +// EFI_INVALID_PARAMETER - Given context is invalid +// EFI_UNSUPPORTED - Context is not supported +// EFI_OUT_OF_RESOURCES - There is no I/O Trap register +// available +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmIoTrapVerifyContext2 ( + IN VOID *Context ) +{ + HANDLER_LINK2 *Handler; + EFI_SMM_IO_TRAP_REGISTER_CONTEXT *RegedContext; + EFI_SMM_IO_TRAP_REGISTER_CONTEXT *IoTrapContext; + + Handler = \ + (HANDLER_LINK2 *)Smm2Handler[EfiSmmIoTrapSmi2].RegisteredCallbacks.pHead; + + IoTrapContext = (EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context; + + while (Handler != NULL) { + RegedContext = (EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Handler->Context; + if ((RegedContext->Address == IoTrapContext->Address) && \ + (RegedContext->Type == IoTrapContext->Type)) { + if ( IoTrapContext->Length > MAX_SUPPORTED_IOTRAP_LENGTH) + return EFI_INVALID_PARAMETER; + return EFI_SUCCESS; + } + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } + + if (gEnabledIoTrapSmi >= ((1 << MAX_SUPPORTED_IOTRAP_REGS) - 1)) + return EFI_OUT_OF_RESOURCES; + + if (IoTrapContext->Length > MAX_SUPPORTED_IOTRAP_LENGTH) + return EFI_INVALID_PARAMETER; + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmIoTrapGetContext2 +// +// Description: This function verifies I/O Trap SMI II event and sets +// I/O Trap SMI II context. +// +// Input: None +// +// Output: BOOLEAN +// TRUE - I/O Trap SMI occured, context saved +// FALSE - There was no I/O Trap SMI +// The global variable gIoTrapWriteData will save the data from +// I/O write cycle. +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN SmmIoTrapGetContext2 (VOID) +{ + return IoTrapSmiDetect2( &SmiContext.IoTrapContext, &gIoTrapWriteData ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmIoTrapDispatchSmi2 +// +// Description: This function dispatches I/O Trap SMI II event based on +// context. +// +// Input: None +// +// Output: EFI_STATUS +// +// Notes: GENERALLY NO PORTING REQUIRED +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmIoTrapDispatchSmi2 (VOID) +{ + EFI_STATUS Status = EFI_WARN_INTERRUPT_SOURCE_QUIESCED; + HANDLER_LINK2 *Handler; + EFI_SMM_IO_TRAP_REGISTER_CONTEXT *IoTrapContext; + volatile UINT16 MaxAddress; + + Handler = \ + (HANDLER_LINK2 *)Smm2Handler[EfiSmmIoTrapSmi2].RegisteredCallbacks.pHead; + while (Handler != NULL) { + IoTrapContext = (EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Handler->Context; + MaxAddress = IoTrapContext->Address + IoTrapContext->Length; + if ((IoTrapContext->Address <= SmiContext.IoTrapContext.Address) && \ + (MaxAddress > SmiContext.IoTrapContext.Address)) { + if ((IoTrapContext->Type == ReadWriteTrap) || \ + (IoTrapContext->Type == SmiContext.IoTrapContext.Type)) { + Status = Handler->Callback( \ + Handler, \ + (EFI_SMM_IO_TRAP_CONTEXT*)&gIoTrapWriteData, \ + NULL, \ + NULL ); + } + } + Handler = (HANDLER_LINK2 *)Handler->Link.pNext; + } +#if (PI_0_9_CHILD_DISPATCHER_SUPPORT == 0) + if (Status != EFI_WARN_INTERRUPT_SOURCE_QUIESCED) IoTrapSmiClear2(); + return Status; +#else + return EFI_WARN_INTERRUPT_SOURCE_QUIESCED; +#endif +} + +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* diff --git a/Chipset/SB/Smm2/SmiHandlerPorting2.c b/Chipset/SB/Smm2/SmiHandlerPorting2.c new file mode 100644 index 0000000..12fb095 --- /dev/null +++ b/Chipset/SB/Smm2/SmiHandlerPorting2.c @@ -0,0 +1,1565 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* + +//************************************************************************* +// $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmiHandlerPorting2.c 9 5/22/15 9:13a Dennisliu $ +// +// $Revision: 9 $ +// +// $Date: 5/22/15 9:13a $ +//************************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmiHandlerPorting2.c $ +// +// 9 5/22/15 9:13a Dennisliu +// [TAG] EIP215945 +// [Category] Improvement +// [Description] [SharkBay][PCH] Executing code outside TSEG check in +// SMM +// +// 8 3/25/13 5:00a Wesleychen +// [TAG] None +// [Category] Improvement +// [Description] Refine GPI SMM2 related routines. +// [Files] SmiHandlerGeneric2.c; SmiHandlerPorting2.c; +// SmmChildDispatch2.h +// +// 7 3/19/13 8:21a Scottyang +// [TAG] EIP118158 +// [Category] Improvement +// [Description] Correct SBLib_CmosRead () offset. +// [Files] SmiHandlerPorting2.c, SBDxe.c, SBGeneric.c, SBSmm.c, +// SmiHandlerPorting.c +// +// 6 11/06/12 8:11a Scottyang +// [TAG] None +// [Category] Improvement +// [Description] Reduce function "GetPchSeries()". +// [Files] SBPEI.c, SBDxe.c, SmiHandlerPorting.c, SmiHandlerPorting2.c +// +// 5 10/19/12 2:52a Scottyang +// [TAG] EIP93461 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] System halt when AFUDOS is running with /N /ME command. +// [RootCause] An unexpected BIOSWR_STS is set, it causes BIOS stuck +// at SMM dispatcher. +// [Solution] Clear BIOSWR_STS if BIOS Lock Enable is not set. +// [Files] SmiHandlerPorting2.c; SmmChildDispatch2Main.c +// SmmChildDispatcher2.sdl; SmmChildDispatch2.h +// SB\SBGeneric.c +// +// 4 9/26/12 3:56a Victortu +// [TAG] None +// [Category] Improvement +// [Description] Update for PCH LP GPIO compatible. +// [Files] SB.sdl, SB.H, AcpiModeEnable.c, AcpiModeEnable.sdl, +// SBDxe.c, SBGeneric.c, SBPEI.c, SBSMI.c, SleepSmi.c, +// SmiHandlerPorting.c, SmiHandlerPorting2.c +// +// 3 7/27/12 6:16a Victortu +// [TAG] None +// [Category] Improvement +// [Description] Update to support ULT Platform. +// [Files] SB.H, SB.mak, SB.sdl, SB.sd, SBSetup.c, +// AcpiModeEnable.c, SBDxe.c, SBPEI.c, SBSMI.c, SleepSmi.c, +// SmiHandlerPorting.c, SmiHandlerPorting2.c, SBPPI.h, Pch.sdl +// +// 2 4/25/12 9:30a Victortu +// [TAG] EIP73033 +// [Category] Improvement +// [Description] 'PciDevicePath' used in GetControllerType(), +// conditionally not set. +// [Files] SmiHandlerPorting.c; SmiHandlerPorting2.c +// +// 1 2/08/12 8:28a Yurenlai +// Intel Lynx Point/SB eChipset initially releases. +// +//************************************************************************* +//<AMI_FHDR_START> +// +// Name: SmiHandlerPorting2.c +// +// Description: This file contains SMM Child Dispatcher II porting +// functions +// +//<AMI_FHDR_END> +//************************************************************************* + +//--------------------------------------------------------------------------- +// Include(s) +//--------------------------------------------------------------------------- + +#include <Token.h> +#include <AmiDxeLib.h> +#include <AmiCspLib.h> +#include <AmiSmm.h> +#include <Protocol\SmmCpu.h> +#include "SmmChildDispatch2.h" + +//--------------------------------------------------------------------------- +// Constant, Macro and Type Definition(s) +//--------------------------------------------------------------------------- +// Constant Definition(s) + +// Macro Definition(s) + +// Type Definition(s) + +// Function Prototype(s) + +//--------------------------------------------------------------------------- +// Variable and External Declaration(s) +//--------------------------------------------------------------------------- +// Variable Declaration(s) + +UINT64 gSupportedIntervals[] = { + // Porting required - put all available intervals here (in 100Nanoseconds) +#if SWSMI_TIMER_INSTEAD +// [ EIP215677 ] +// 15000, // 1.5ms +// 160000, // 16 ms +// 320000, // 32 ms +// 640000, // 64 ms + 640000, // 64 ms + 320000, // 32 ms + 160000, // 16 ms + 15000, // 1.5ms +#else + 600000000, // 60 Seconds + 320000000, // 32 Seconds + 160000000, // 16 Seconds + 80000000, // 8 Seconds +#endif + + // Terminator record + 0 +}; + +// GUID Definition(s) + +// Protocol Definition(s) + +// External Declaration(s) + +extern EFI_SMM_SYSTEM_TABLE2 *gSmst2; +extern EFI_SMM_CPU_PROTOCOL *gEfiSmmCpuProtocol; + +// Function Definition(s) + +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// All purpose SMI Porting hooks +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: IsAcpi +// +// Description: This function determines if the system is in ACPI mode. +// +// Input: None +// +// Output: BOOLEAN +// TRUE - It is in ACPI mode +// FALSE - It is not in ACPI mode +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN IsAcpi (VOID) +{ + return (READ_IO16_PM(ACPI_IOREG_PM1_CNTL) & 1) ? TRUE : FALSE; // 0x04 +}; + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: IsMe +// +// Description: This function checks whether the specific SMI event is raised +// +// Input: CheckBitNo - The bit number for the specific SMI. +// +// Output: BOOLEAN +// TRUE - It is the specific SMI event +// FALSE - It is not the specific SMI event +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN IsMe ( + IN UINT8 CheckBitNo ) +{ + volatile UINT32 Buffer32 = READ_IO32_PM(ACPI_IOREG_SMI_EN); // 0x30 + + Buffer32 &= READ_IO32_PM(ACPI_IOREG_SMI_STS); // 0x34 + return (Buffer32 & (UINT32)(1 << CheckBitNo)) ? TRUE : FALSE; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: ClearAllSmi +// +// Description: This function clears all SMI's and issues an EOS (End of SMI). +// +// Input: None +// +// Output: None +// +// Notes: If you are porting INTEL chipset and have to support SWSMI +// Timer SMI, you must be unable to clear the SWSMI status in +// this routine. +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID ClearAllSmi (VOID) +{ + // Porting Required. Program to clear ALL SMI status bit + if ( !IsAcpi() ) { + if (READ_IO16_PM(ACPI_IOREG_PM1_EN) & 0x400) + if (READ_IO16_PM(ACPI_IOREG_PM1_STS) & 0x400) + SBLib_CmosRead(0x0C); + WRITE_IO16_PM(ACPI_IOREG_PM1_STS, 0xcc31); // 0x00 + if (GetPchSeries() == PchLp) { + WRITE_IO32_PM(ACPI_PCHLP_IOREG_GPE0_STS+0x0c, 0xffffffff); // 0x8C + WRITE_IO32(GPIO_BASE_ADDRESS + GP_IOREG_ALTGP_SMI_STS, 0xffffffff); // 0x50 + } else { + WRITE_IO32_PM(ACPI_IOREG_GPE0_STS, 0xffffffff); // 0x20 + WRITE_IO32_PM(ACPI_IOREG_GPE0_STS+4, 0xffffffff); // 0x24 + WRITE_IO16_PM(ACPI_IOREG_ALTGP_SMI_STS, 0xffff); // 0x3A + } + WRITE_IO16_PM(ACPI_IOREG_DEVACT_STS, 0xffff); // 0x44 + WRITE_IO16_TCO(TCO_IOREG_STS1, 0xffff); // 0x04 + WRITE_IO16_TCO(TCO_IOREG_STS2, 0xfffe); // 0x06 (Except Intruder Det) + WRITE_IO32_PM(ACPI_IOREG_SMI_STS, 0xffffffbf); // 0x34 (Except SWSMI) + if ((READ_IO16_TCO(TCO_IOREG_CNT1) & 0x300) == 0x300) { // 0x08 + SET_IO16_TCO(TCO_IOREG_CNT1, 0x100); // Clear NMI_NOW if needed. + } + } + // EOS + SET_IO8_PM(ACPI_IOREG_SMI_EN, 0x02); // 0x30 + if ((READ_IO8_PM(ACPI_IOREG_SMI_EN) & 0x02) == 0) { + // Reset GBL_SMI_EN + RESET_IO8_PM(ACPI_IOREG_SMI_EN, 0x01); // 0x30 + // Set EOS Again + SET_IO8_PM(ACPI_IOREG_SMI_EN, 0x02); // 0x30 + // Set GBL_SMI_EN + SET_IO8_PM(ACPI_IOREG_SMI_EN, 0x01); // 0x30 + } +} + +//--------------------------------------------------------------------------- +// SW SMI Handler Porting hooks +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SwSmiEnable +// +// Description: This function enables SW SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID SwSmiEnable (VOID) +{ + // Porting required + SET_IO32_PM(ACPI_IOREG_SMI_EN, 0x20); // 0x30 +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SwSmiDisable +// +// Description: This function disables SW SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID SwSmiDisable (VOID) +{ + // Porting required + RESET_IO32_PM(ACPI_IOREG_SMI_EN, 0x20); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SwSmiClear +// +// Description: This function clears SW SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID SwSmiClear (VOID) +{ + // Porting required + WRITE_IO32_PM(ACPI_IOREG_SMI_STS, 0x20); // 0x34 +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SwSmiDetect +// +// Description: This function detects SW SMI event +// +// Input: *Type - Pointer to store SW SMI number +// +// Output: TRUE - SW SMI occured, FALSE otherwise +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN SwSmiDetect ( + OUT UINT16 *Type ) +{ + // Porting required + if ( IsMe(5) ) { // SW_SMI + *Type = IoRead8(SW_SMI_IO_ADDRESS); + return TRUE; + } + + return FALSE; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: GetEAX +// +// Description: This function returns EAX saved value from CPU that caused +// SW SMI. +// +// Input: None +// +// Output: EAX saved value +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +UINTN GetEAX (VOID) +{ + // Porting required for different CPU + EFI_STATUS Status; + EFI_GUID SwSmiCpuTriggerGuid = SW_SMI_CPU_TRIGGER_GUID; + SW_SMI_CPU_TRIGGER *SwSmiCpuTrigger; + UINTN Cpu = gSmst2->CurrentlyExecutingCpu - 1; // CPU # + UINT16 i; + UINT32 RegEAX; + + for (i = 0; i < gSmst2->NumberOfTableEntries; i++) { + if (guidcmp(&(gSmst2->SmmConfigurationTable[i].VendorGuid), \ + &SwSmiCpuTriggerGuid) == 0) + break; + } + + // If found table, check for the CPU that caused the software Smi. + if (i != gSmst2->NumberOfTableEntries) { + SwSmiCpuTrigger = gSmst2->SmmConfigurationTable[i].VendorTable; + Cpu = SwSmiCpuTrigger->Cpu; + } + + Status = gEfiSmmCpuProtocol->ReadSaveState ( \ + gEfiSmmCpuProtocol, \ + 4, \ + EFI_SMM_SAVE_STATE_REGISTER_RAX, \ + Cpu, \ + &RegEAX ); + return RegEAX; +} + +//--------------------------------------------------------------------------- +// SX SMI Handler Porting hooks +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SxSmiEnable +// +// Description: This function enables SX SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID SxSmiEnable (VOID) +{ + // Porting required + SET_IO32_PM(ACPI_IOREG_SMI_EN, 0x10); // 0x30 +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SxSmiDisable +// +// Description: This function disables SX SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID SxSmiDisable (VOID) +{ + // Porting required + RESET_IO32_PM(ACPI_IOREG_SMI_EN, 0x10); // 0x30 +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SxSmiClear +// +// Description: This function clears SX SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID SxSmiClear (VOID) +{ + // Porting required + WRITE_IO32_PM(ACPI_IOREG_SMI_STS, 0x10); // 0x34 +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SxSmiDetect +// +// Description: This function detects SX SMI event +// +// Input: *Type - Pointer to store value of Sleep type +// +// Output: TRUE - SX SMI occured, FALSE otherwise +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN SxSmiDetect ( + OUT UINT16 *Type ) +{ + // Porting required + if (IsMe(4)) { // SLP_SMI + switch (READ_IO16_PM(ACPI_IOREG_PM1_CNTL) & (7 << 10)) { // SLP_TYP + case (0 << 10): + *Type = SxS0; + break; + case (1 << 10): + *Type = SxS1; + break; + case (5 << 10): + *Type = SxS3; + break; + case (6 << 10): + *Type = SxS4; + break; + case (7 << 10): + *Type = SxS5; + break; + default: + return FALSE; // Unknown Error. + } + return TRUE; + } + return FALSE; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: PutToSleep +// +// Description: Disable Smi sleep and put to sleep. +// +// Input: *Context - Pointer to Sleep SMI context +// +// Output: None +// +// Referrals: SxSmiDisable +// +// Notes: Here is the control flow of this function: +// 1. Disable Smi sleep. +// 2. Set to go to sleep if you want to sleep in SMI. otherwise +// set IORestart to 0xFF in CPU SMM dump area. +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID PutToSleep ( + IN EFI_SMM_SX_REGISTER_CONTEXT *SxContext ) +{ +// TODO YODO TODO +//#### EFI_SMM_CPU_SAVE_STATE *pCpuSaveState = gSmst2->CpuSaveState; +//#### UINTN Cpu = gSmst2->CurrentlyExecutingCpu - 1; +//#### UINT32 CacheFlush = 0; + + SxSmiDisable(); // Disable sleep SMI. + +//#### if (SxContext->Type == SxS5) +//#### SBLib_BeforeShutdown(); + +//#####if ACPI_SLEEP_IN_SMM + SET_IO16_PM(ACPI_IOREG_PM1_CNTL, 0x2000); // Set to sleep. +//#####else +//#### CacheFlush = pCpuSaveState[Cpu].Ia32SaveState.IORestart; +//#### pCpuSaveState[Cpu].Ia32SaveState.IORestart = 0xff; +//#####endif + +} + +//--------------------------------------------------------------------------- +// Periodic timer SMI Handler Porting hooks +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: TimerSmiEnable2 +// +// Description: This function enables Periodic timer SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID TimerSmiEnable2 (VOID) +{ + // Porting required +#if SWSMI_TIMER_INSTEAD + SET_IO32_PM(ACPI_IOREG_SMI_EN, 0x40); // 0x30 +#else + SET_IO32_PM(ACPI_IOREG_SMI_EN, 0x4000); // 0x30 +#endif +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: TimerSmiDisable2 +// +// Description: This function disables Periodic timer SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID TimerSmiDisable2 (VOID) +{ + // Porting required +#if SWSMI_TIMER_INSTEAD + RESET_IO32_PM(ACPI_IOREG_SMI_EN, 0x40); // 0x30 +#else + RESET_IO32_PM(ACPI_IOREG_SMI_EN, 0x4000); // 0x30 +#endif +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: TimerSmiClear2 +// +// Description: This function clears Periodic timer SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID TimerSmiClear2 (VOID) +{ + + // Porting required +#if SWSMI_TIMER_INSTEAD + // SWSMI has to be disabled before clear the status + volatile UINT32 Buffer32 = READ_IO32_PM(ACPI_IOREG_SMI_EN); // 0x30 + WRITE_IO32_PM(ACPI_IOREG_SMI_EN, Buffer32 & (UINT32)(~0x40)); // 0x30 + WRITE_IO32_PM(ACPI_IOREG_SMI_STS, 0x40); // 0x34 + WRITE_IO32_PM(ACPI_IOREG_SMI_EN, Buffer32); // 0x30 +#else + WRITE_IO32_PM(ACPI_IOREG_SMI_STS, 0x4000); // 0x34 +#endif +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: TimerSmiDetect2 +// +// Description: This function detects Periodic timer SMI event +// +// Input: *Type - Added for compatibility, not used +// +// Output: TRUE - Periodic timer SMI occured, FALSE otherwise +// +// Notes: Return TRUE if Timer SMI detected, Type ignored +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN TimerSmiDetect2 ( + OUT UINT16 *Type ) +{ + // Porting required + *Type = 0; +#if SWSMI_TIMER_INSTEAD + return (IsMe(6)) ? TRUE : FALSE; +#else + return (IsMe(14)) ? TRUE : FALSE; +#endif +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: TimerSetInterval2 +// +// Description: This function programs Periodic timer to given interval +// +// Input: Interval - Interval to program +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID TimerSetInterval2 ( + IN UINT64 Interval ) +{ + + // Porting required + UINT16 RateIndex; + UINT16 AvailTimer = sizeof(gSupportedIntervals) / sizeof(UINT64) - 1; + + TimerSmiDisable2(); + TimerSmiClear2(); + + for (RateIndex = 0; RateIndex < AvailTimer ; RateIndex++) + if (Interval == gSupportedIntervals[RateIndex]) break; +#if SWSMI_TIMER_INSTEAD + RW_PCI16_SB(SB_REG_GEN_PMCON_3, RateIndex << 6, 0xc0); // 0xA4 +#else + RW_PCI16_SB(SB_REG_GEN_PMCON_1, RateIndex, 3); // 0xA0 +#endif + + TimerSmiEnable2(); +} + +//--------------------------------------------------------------------------- +// Usb SMI Handler Porting hooks +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: UsbSmiSet +// +// Description: This function enables/disables USB SMI based on given +// Controller type +// +// Input: ControllerType - USB controller type variable +// +// Output: None +// +// Notes: This function implements logic as follows: +// Three lowest bits of ControllerType: +// 000 - All USB controllers SMI are disabled +// 001 - UHCI/OHCI enabled, EHCI/XHCI - disabled +// 010 - EHCI enabled, UHCI/OHCI/XHCI - disabled +// 011 - UHCI/OHCI/EHCI enabled, XHCI - disabled +// 100 - XHCI enabled, UHCI/OHCI/EHCI - disabled +// 101 - UHCI/OHCI/XHCI enabled, EHCI - disabled +// 110 - EHCI/XHCI enabled, UHCI/OHCI - disabled +// 111 - All USB controllers SMI are enabled +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID UsbSmiSet( + IN UINT16 ControllerType ) +{ + // Porting required + switch (ControllerType & 7) { + + case 0 : // All USB controllers SMI are disabled + RESET_PCI32_EHCI(EHCI_REG_SPECIAL_SMI, 1); + RESET_PCI32_EHCI2(EHCI_REG_SPECIAL_SMI, 1); + RESET_IO32_PM(ACPI_IOREG_SMI_EN, 0x80060008); // 0x30 + break; + + case 1 : // UHCI/OHCI enabled, EHCI/XHCI - disabled + RESET_PCI32_EHCI(EHCI_REG_SPECIAL_SMI, 1); + RESET_PCI32_EHCI2(EHCI_REG_SPECIAL_SMI, 1); + RW_IO32_PM(ACPI_IOREG_SMI_EN, 0x08, 0x80060008); // 0x30 + break; + + case 2 : // EHCI enabled, UHCI/OHCI/XHCI - disabled + RW_IO32_PM(ACPI_IOREG_SMI_EN, 0x60000, 0x80060008); // 0x30 + SET_PCI32_EHCI(EHCI_REG_SPECIAL_SMI, 1); + SET_PCI32_EHCI2(EHCI_REG_SPECIAL_SMI, 1); + break; + + case 3 : // UHCI/OHCI/EHCI enabled, XHCI - disabled + RW_IO32_PM(ACPI_IOREG_SMI_EN, 0x60008, 0x80060008); // 0x30 + SET_PCI32_EHCI(EHCI_REG_SPECIAL_SMI, 1); + SET_PCI32_EHCI2(EHCI_REG_SPECIAL_SMI, 1); + break; + + case 4 : // XHCI enabled, UHCI/OHCI/EHCI - disabled + RESET_PCI32_EHCI(EHCI_REG_SPECIAL_SMI, 1); + RESET_PCI32_EHCI2(EHCI_REG_SPECIAL_SMI, 1); + RW_IO32_PM(ACPI_IOREG_SMI_EN, 0x80000000, 0x80060008); // 0x30 + break; + + case 5 : // UHCI/OHCI/XHCI enabled, EHCI - disabled + RESET_PCI32_EHCI(EHCI_REG_SPECIAL_SMI, 1); + RESET_PCI32_EHCI2(EHCI_REG_SPECIAL_SMI, 1); + RW_IO32_PM(ACPI_IOREG_SMI_EN, 0x80000008, 0x80060008); // 0x30 + break; + + case 6 : // EHCI/XHCI enabled, UHCI/OHCI - disabled + RW_IO32_PM(ACPI_IOREG_SMI_EN, 0x80060000, 0x80060008); // 0x30 + SET_PCI32_EHCI(EHCI_REG_SPECIAL_SMI, 1); + SET_PCI32_EHCI2(EHCI_REG_SPECIAL_SMI, 1); + break; + + default: // All USB controllers SMI are enabled + SET_IO32_PM(ACPI_IOREG_SMI_EN, 0x80060008); // 0x30 + SET_PCI32_EHCI(EHCI_REG_SPECIAL_SMI, 1); + SET_PCI32_EHCI2(EHCI_REG_SPECIAL_SMI, 1); + break; + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UsbSmiClear +// +// Description: This function clears USB SMI status based on given Controller +// type. +// +// Input: UINT16 ControllerType - USB controller type variable +// +// Output: None +// +// Notes: This function implements logic as follows: +// Three lowest bits of ControllerType: +// Bit 0 - Clear UHCI/OHCI USB SMI status +// Bit 1 - Clear EHCI USB SMI status +// Bit 2 - Clear XHCI USB SMI status +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID UsbSmiClear ( + IN UINT16 ControllerType ) +{ + // Porting required + + if (ControllerType & 1) // Clear UHCI/OHCI USB SMI status + WRITE_IO32_PM(ACPI_IOREG_SMI_STS, 0x08); // 0x34 + + if (ControllerType & 2) // Clear EHCI USB SMI status + WRITE_IO32_PM(ACPI_IOREG_SMI_STS, 0x20000); // 0x34 + if (ControllerType & 4) // Clear XHCI USB SMI status + WRITE_IO32_PM(ACPI_IOREG_SMI_STS, 0x80000000); // 0x34 +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: UsbSmiDetect +// +// Description: This function detects USB SMI event +// +// Input: *Type - Pointer to store USB controller type, source of event +// +// Output: TRUE - USB SMI occured, FALSE otherwise +// +// Notes: This function implements logic as follows: +// *Type will be set to +// 000 - There is no SMI occured +// Bit 0 - If UHCI/OHCI USB SMI is occured +// Bit 1 - If EHCI USB SMI is occured +// Bit 2 - If XHCI USB SMI is occured +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN UsbSmiDetect ( + OUT UINT16 *Type ) +{ + // Porting required + *Type = 0; + if (IsMe(03)) *Type |= 1; // USB_SMI (USB 1.1) + if (IsMe(17)) *Type |= 2; // USB_SMI (USB 2.0) + if (IsMe(31)) *Type |= 4; // USB_SMI (USB 3.0) + + return (*Type) ? TRUE : FALSE; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: GetControllerType +// +// Description: This function returns USB controller type, based on given +// device path +// +// Input: *Device - Pointer USB device path protocol +// +// Output: UINT16 - USB controller type +// +// Notes: The USB controller type will be retuened by the follow value: +// 0 - If there is no matche. +// 1 - It is an UHCI/OHCI (USB 1.1) controller +// 2 - It is an EHCI (USB 2.0) controller +// 4 - It is a XHCI (USB 3.0) controller +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +UINT16 GetControllerType ( + IN EFI_DEVICE_PATH_PROTOCOL *Device) +{ + // Porting required + EFI_DEVICE_PATH_PROTOCOL *DevicePath = Device; + PCI_DEVICE_PATH *PciDevicePath = NULL; // [EIP73033] + UINT16 ControllerType = 0; + + while (!isEndNode( DevicePath )) { + if ((DevicePath->Type == HARDWARE_DEVICE_PATH) && \ + (DevicePath->SubType == HW_PCI_DP)) { + PciDevicePath = (PCI_DEVICE_PATH *) DevicePath; + break; + } + DevicePath = NEXT_NODE (DevicePath); + } + +// [ EIP215945 ] +// if (PciDevicePath->Device == EHCI_DEV) { +// ControllerType = 1; +// if (PciDevicePath->Function == 0x07) ControllerType = 2; +// + if ((PciDevicePath->Device == EHCI_DEV) || (PciDevicePath->Device == EHCI2_DEV)) + { + ControllerType = 2; + } else { + if (PciDevicePath->Device == XHCI_DEV) + if (PciDevicePath->Function == XHCI_FUN) ControllerType = 4; + } + + return ControllerType; +} + +//--------------------------------------------------------------------------- +// GPI SMI Handler Porting hooks +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: GpiSmiSet +// +// Description: This function enables GPI SMI based on given bit field. +// +// Input: GpiEnableBit - GPI enabled bit field +// +// Output: None +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID GpiSmiSet ( + IN UINT32 GpiEnableBit ) +{ + // Porting required + + UINT8 GpiNum = 0; + PCH_SERIES PchSeries = GetPchSeries(); + + if (PchSeries == PchLp) { + SET_IO16(GPIO_BASE_ADDRESS + GP_IOREG_ALTGP_SMI_EN, (UINT16)GpiEnableBit); + } else { + SET_IO16_PM(ACPI_IOREG_ALTGP_SMI_EN, (UINT16)GpiEnableBit); + } + + while ((GpiEnableBit % 2) == 0) { + GpiEnableBit /= 2; + GpiNum++; + } + GpiNum *= 2; + + if (PchSeries == PchLp) { + //Only GPI[47:32] are capable of SMI# generation. + SET_IO16(GPIO_BASE_ADDRESS + GP_IOREG_GPI_ROUT2, (UINT16)GpiEnableBit); + } else { + RW_PCI32_SB(SB_REG_GPI_ROUT, 1 << GpiNum, 3 << GpiNum); // 0xB8 + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: GpiSmiReset +// +// Description: This function disables GPI SMI based on given bit field. +// +// Input: GpiDisableBit - GPI disabled bit field +// +// Output: None +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID GpiSmiReset ( + IN UINT32 GpiDisableBit ) +{ + // Porting required + + UINT8 GpiNum = 0; + PCH_SERIES PchSeries = GetPchSeries(); + + if (PchSeries == PchLp) { + RESET_IO16(GPIO_BASE_ADDRESS + GP_IOREG_ALTGP_SMI_EN, (UINT16)GpiDisableBit); + } else { + RESET_IO16_PM(ACPI_IOREG_ALTGP_SMI_EN, (UINT16)GpiDisableBit); + } + + while ((GpiDisableBit % 2) == 0) { + GpiDisableBit /= 2; + GpiNum++; + } + GpiNum *= 2; + + if (PchSeries == PchLp) { + //Only GPI[47:32] are capable of SMI# generation. + RESET_IO16(GPIO_BASE_ADDRESS+GP_IOREG_GPI_ROUT2, (UINT16)GpiDisableBit); + } else { + RESET_PCI32_SB(SB_REG_GPI_ROUT, 3 << GpiNum); // 0xB8 + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GpiSmiClear +// +// Description: This function clears GPI SMI status based on given bit field +// +// Input: Type - GPI Disabled bit field +// +// Output: None +// +// Notes: All GPIs which correspondent bit in Type set to 1 should +// be cleared +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID GpiSmiClear ( + IN UINT32 GpiClearBit ) +{ + // Porting required + if (GetPchSeries() == PchLp) { + WRITE_IO32(GPIO_BASE_ADDRESS + GP_IOREG_ALTGP_SMI_EN, GpiClearBit); + } else { + WRITE_IO16_PM(ACPI_IOREG_ALTGP_SMI_STS, (UINT16)GpiClearBit); + } +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: GpiSmiDetect +// +// Description: This function detects GPI SMI event +// +// Input: *Gpi - Pointer to store source of GPI SMI +// +// Output: TRUE - GPI SMI occured, FALSE otherwise +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN GpiSmiDetect ( + OUT UINT32 *Gpi ) +{ + // Porting required + if (GetPchSeries() == PchLp) { + *Gpi = READ_IO32(GPIO_BASE_ADDRESS + GP_IOREG_ALTGP_SMI_EN) & READ_IO32(GPIO_BASE_ADDRESS + GP_IOREG_ALTGP_SMI_STS); + } else { + *Gpi = READ_IO16_PM(ACPI_IOREG_ALTGP_SMI_EN) & READ_IO16_PM(ACPI_IOREG_ALTGP_SMI_STS); + } + + return (*Gpi) ? TRUE : FALSE; +} + + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: ConvertGpi +// +// Description: This function converts GPI to bitmap in 32 bit. +// +// Input: Gpi - GPI Pin number or bitmap +// +// Output: Converted GPI bitmap in 32 bit. +// GpiBitMap[16:0] = ALT_GPI_SMI_EN[15:0] = LPT-H GPI[15:0] +// GpiBitMap[16:0] = ALT_GPI_SMI_EN[15:0] = LPT-LP GPI[47:32] +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT32 ConvertGpi ( + IN UINTN Gpi +) +{ + UINT32 GpiBitMap = 0; + PCH_SERIES PchSeries = GetPchSeries(); + + if (GPI_DISPATCH2_BY_BITMAP) { + if (PchSeries == PchLp) + GpiBitMap = (UINT32)(Shr64((UINT64)Gpi, 32)); + else + GpiBitMap = (UINT32)Gpi; + } else { + if (PchSeries == PchLp) + GpiBitMap |= Shl64(1, (UINT8)(Gpi - 32)); + else + GpiBitMap |= Shl64(1, (UINT8)Gpi); + } + return GpiBitMap; +} + +//--------------------------------------------------------------------------- +// Standby button SMI Handler Porting hooks +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SButtonSmiEnable +// +// Description: This function enables Standby button SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID SButtonSmiEnable (VOID) +{ + // Porting required +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SButtonSmiDisable +// +// Description: This function disables Standby button SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID SButtonSmiDisable (VOID) +{ + // Porting required +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SButtonSmiClear +// +// Description: This function clears Standby button SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID SButtonSmiClear (VOID) +{ + // Porting required +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SButtonSmiDetect +// +// Description: This function detects Standby button SMI event +// +// Input: *Type - Pointer to store value of Standby button phase, +// not used. +// +// Output: TRUE - Standby button SMI occured, FALSE otherwise +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN SButtonSmiDetect ( + OUT UINT16 *Type ) +{ + // Porting required + return FALSE; +} + +//--------------------------------------------------------------------------- +// Power button SMI Handler Porting hooks +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: PButtonSmiEnable +// +// Description: This function enables Power button SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID PButtonSmiEnable (VOID) +{ + // Porting required + SET_IO16_PM(ACPI_IOREG_PM1_EN, 0x100); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: PButtonSmiDisable +// +// Description: This function disables Power button SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID PButtonSmiDisable (VOID) +{ + // Porting required + RESET_IO16_PM(ACPI_IOREG_PM1_EN, 0x100); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: PButtonSmiClear +// +// Description: This function clears Power button SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID PButtonSmiClear (VOID) +{ + // Porting required + WRITE_IO16_PM(ACPI_IOREG_PM1_STS, 0x100); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: PButtonSmiDetect +// +// Description: This function detects Power button SMI event +// +// Input: *Type - pointer to store value of Power button phase +// not used. +// +// Output: TRUE - Power button SMI occured, FALSE - otherwise +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN PButtonSmiDetect ( + OUT UINT16 *Type ) +{ + // Porting Required + UINT16 Buffer16; + + if ( IsAcpi() ) { + return FALSE; + } else { + Buffer16 = READ_IO16_PM(ACPI_IOREG_PM1_STS) & \ + READ_IO16_PM(ACPI_IOREG_PM1_EN) & 0x100; + return (Buffer16) ? TRUE : FALSE; + } +} + +//--------------------------------------------------------------------------- +// I/O Trap SMI Handler Porting hooks +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: IoTrapSmiSet +// +// Description: This function sets I/O Trap functon based on given the +// context +// +// Input: IoTrapContext - Pointer to the context +// EFI_SMM_IO_TRAP_REGISTER_CONTEXT +// +// Output: TrapRegIndex - Pointer to the index of I/O Trap register +// that I/O Trap register will be enabled. +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID IoTrapSmiSet2 ( + IN EFI_SMM_IO_TRAP_REGISTER_CONTEXT *IoTrapContext, + OUT UINT32 *TrapRegIndex ) +{ + // Porting required if needed. + UINT32 IoTrapAddr = RCRB_MMIO_IO_TRAP_0; // 0x1E80 + UINT32 i; + UINT32 Buffer32 = 0; + UINT16 Length = IoTrapContext->Length; + + // Find an available I/O trap register + for (i = 0; i < MAX_SUPPORTED_IOTRAP_REGS; i++) { + if ((READ_MEM32_RCRB(IoTrapAddr) & 1) == 0) break; + IoTrapAddr += 8; + } + + *TrapRegIndex = i; + + if (*TrapRegIndex == MAX_SUPPORTED_IOTRAP_REGS) return; + + if (Length < 4) Length = 4; + Buffer32 = Length; + for (i = 0; Buffer32 != 1; Buffer32 >>= 1, i++); + if (Length > (1 << i)) i++; + + Length = 1 << i; // Length is always 2^n + + Buffer32 = IoTrapContext->Address & 0xfffc; + Buffer32 |= ((Length - 1) & 0xfffc) << 16; + WRITE_MEM32_RCRB(IoTrapAddr, Buffer32); + + Buffer32 = 0xf0; // Byte Access +// if (IoTrapContext->TrapWidth == AccessWord) Buffer32 = 0x03; +// if (IoTrapContext->TrapWidth == AccessDWord) Buffer32 = 0x0f; + + if (IoTrapContext->Type == ReadWriteTrap) { + Buffer32 |= (1 << 17); // Both Read/Write Cycles. + } else { + if (IoTrapContext->Type == ReadTrap) + Buffer32 |= (1 << 16); // Read Cycle Only + } + + WRITE_MEM32_RCRB(IoTrapAddr + 4, Buffer32); + SET_MEM32_RCRB(IoTrapAddr, 1); // Enable Trap and SMI. +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: IoTrapSmiReset +// +// Description: This function resets I/O Trap functon based on given the +// context +// +// Input: IoTrapContext - Pointer to the context that I/O trap register +// will be disabled. +// +// Output: None +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID IoTrapSmiReset2 ( + IN EFI_SMM_IO_TRAP_REGISTER_CONTEXT *IoTrapContext, + OUT UINT32 *TrapRegIndex ) +{ + // Porting required if needed. + + UINT32 IoTrapAddr = RCRB_MMIO_IO_TRAP_0; // 0x1E80 + UINT32 i; + UINT32 TrapContext32 = 0; + + for (i = 0; i < MAX_SUPPORTED_IOTRAP_REGS; i++) { + TrapContext32 = READ_MEM32_RCRB(IoTrapAddr); + if (TrapContext32 & 1) + if ((UINT16)(TrapContext32 & 0xfffc) == IoTrapContext->Address) { + TrapContext32 = READ_MEM32_RCRB(IoTrapAddr + 4); + if (TrapContext32 & 0x20000) { + if (IoTrapContext->Type == ReadWriteTrap) break; + } else { + if (TrapContext32 & 0x10000) { + if (IoTrapContext->Type == ReadTrap) break; + } else { + if (IoTrapContext->Type == WriteTrap) break; + } + } + } + IoTrapAddr += 8; + } + + WRITE_MEM32_RCRB(IoTrapAddr, 0); + WRITE_MEM32_RCRB(IoTrapAddr + 4, 0); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: IoTrapSmiEnable +// +// Description: This function enables I/O Trap SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID IoTrapSmiEnable2 (VOID) +{ + // Porting required if needed. +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: IoTrapSmiDisable +// +// Description: This function disables I/O Trap SMI +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID IoTrapSmiDisable2 (VOID) +{ + // Porting required if needed. +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: IoTrapSmiClear +// +// Description: This function clears all I/O Trap SMI status. +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID IoTrapSmiClear2 (VOID) +{ + // Porting required + SET_MEM32_RCRB(RCRB_MMIO_TRSR, 0); // 0x1E00 +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: IoTrapSmiDetect2 +// +// Description: This function detects I/O Trap SMI event. +// +// Input: *IoTrapContext - Pointer to EFI_SMM_IO_TRAP_REGISTER_CONTEXT +// +// Output: TRUE - I/O Trap SMI occured, the SMI context IoTrapContext +// should be updated according to the traped H/W +// information. +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN IoTrapSmiDetect2 ( + OUT EFI_SMM_IO_TRAP_REGISTER_CONTEXT *IoTrapContext, + OUT UINT32 *IoTrapWriteData ) +{ + // Porting required + + UINT32 Buffer32; + UINT16 Offset = 0; + UINT16 i; + + if (READ_MEM32_RCRB(RCRB_MMIO_TRSR) & 15) { // 0x1E00 + + Buffer32 = READ_MEM32_RCRB(RCRB_MMIO_TRCR); // 0x1E10 + IoTrapContext->Address = Buffer32 & 0xfffc; + for (i = 0; i < 4; i++) { + if (Buffer32 & (1 << (16 + i))) break; + Offset++; + } + IoTrapContext->Address += Offset; + if (Buffer32 & (1 << 24)) { + IoTrapContext->Type = ReadTrap; + } else { + IoTrapContext->Type = WriteTrap; + *IoTrapWriteData = READ_MEM32_RCRB(RCRB_MMIO_TWDR); // 0x1E18 + } + return TRUE; + } + + return FALSE; +} + // [EIP93461]> +#if BIOS_WRITE_SMI_PATCH_ENABLE +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: PchBiosWritePatch +// +// Description: This function clears unexpected BIOSWR_STS. +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID BiosWriteSmiPatch ( VOID ) +{ + // Clear BIOSWR_STS(TCO_BASE + 04h[8]) if BIOS Lock Enable + // (B0:D31:F0 Reg#DCh[1]) is not set. + if (((READ_PCI8_SB(SB_REG_BIOS_CNTL) & BIT01) == 0) && \ + (READ_IO16_TCO(TCO_IOREG_STS1) & BIT08)) { + + // Clear BIOSWR_STS + WRITE_IO16_TCO(TCO_IOREG_STS1, BIT08); + // Clear TCO_STS + WRITE_IO16_PM(ACPI_IOREG_SMI_STS, BIT13); + + } +} +#endif + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SbSmiWorkaround2 +// +// Description: This hook is used for all south bridge workaround in SMI. +// +// Input: None +// +// Output: None +// +// Notes: Porting required +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID SbSmiWorkaround2 (VOID) +{ + +#if BIOS_WRITE_SMI_PATCH_ENABLE + BiosWriteSmiPatch(); +#endif + +} + // <[EIP93461] +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* diff --git a/Chipset/SB/Smm2/SmmChildDispatch2.h b/Chipset/SB/Smm2/SmmChildDispatch2.h new file mode 100644 index 0000000..7e557f2 --- /dev/null +++ b/Chipset/SB/Smm2/SmmChildDispatch2.h @@ -0,0 +1,333 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* + +//************************************************************************* +// $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatch2.h 3 3/25/13 5:00a Wesleychen $ +// +// $Revision: 3 $ +// +// $Date: 3/25/13 5:00a $ +//************************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatch2.h $ +// +// 3 3/25/13 5:00a Wesleychen +// [TAG] None +// [Category] Improvement +// [Description] Refine GPI SMM2 related routines. +// [Files] SmiHandlerGeneric2.c; SmiHandlerPorting2.c; +// SmmChildDispatch2.h +// +// 2 10/19/12 2:52a Scottyang +// [TAG] EIP93461 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] System halt when AFUDOS is running with /N /ME command. +// [RootCause] An unexpected BIOSWR_STS is set, it causes BIOS stuck +// at SMM dispatcher. +// [Solution] Clear BIOSWR_STS if BIOS Lock Enable is not set. +// [Files] SmiHandlerPorting2.c; SmmChildDispatch2Main.c +// SmmChildDispatcher2.sdl; SmmChildDispatch2.h +// SB\SBGeneric.c +// +// 1 2/08/12 8:28a Yurenlai +// Intel Lynx Point/SB eChipset initially releases. +// +//************************************************************************* +//<AMI_FHDR_START> +// +// Name: SmmChildDispatch2.h +// +// Description: SMM Child dispatcher II functions and data structures +// definition. +// +//<AMI_FHDR_END> +//************************************************************************* + +#ifndef __SMM_CHILD_DISPATCH2__H__ +#define __SMM_CHILD_DISPATCH2__H__ +#ifdef __cplusplus +extern "C" { +#endif + +#include <AmiDxeLib.h> + +#include <Protocol\SmmSwDispatch2.h> +#include <Protocol\SmmSxDispatch2.h> +#include <Protocol\SmmPeriodicTimerDispatch2.h> +#include <Protocol\SmmUsbDispatch2.h> +#include <Protocol\SmmGpiDispatch2.h> +#include <Protocol\SmmStandbyButtonDispatch2.h> +#include <Protocol\SmmPowerButtonDispatch2.h> +#include <Protocol\SmmIoTrapDispatch2.h> + +#define SMM_CHILD_DISPATCHER2_GUID \ + {0x950c3a26, 0xe0c2, 0x491c, 0xb6, 0xb2, 0x3, 0x74, 0xf5, 0xc7, 0x3b, 0x96} + +#pragma pack(push, 1) + +typedef enum { + EfiSmmSwSmi2, + EfiSmmSxSmi2, + EfiSmmPeriodicTimerSmi2, + EfiSmmUsbSmi2, + EfiSmmGpiSmi2, + EfiSmmStandbyButtonSmi2, + EfiSmmPowerButtonSmi2, + EfiSmmIoTrapSmi2, + EfiSmmMaxSmi2 +} EFI_SMM_SMI2; + +typedef struct { + EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT OrgContext; + UINT64 ElapsedTime; +} EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT; + +typedef union { + EFI_SMM_SW_REGISTER_CONTEXT SwContext; + EFI_SMM_SX_REGISTER_CONTEXT SxContext; + EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT TimerContext; + EFI_SMM_USB_REGISTER_CONTEXT UsbContext; + EFI_SMM_GPI_REGISTER_CONTEXT GpiContext; + EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT SBtnContext; + EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT PBtnContext; + EFI_SMM_IO_TRAP_REGISTER_CONTEXT IoTrapContext; +} EFI_SMM_SMI_CONTEXT2; + +typedef EFI_STATUS ( *SMI_GENERIC_CALLBACK2 ) ( + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *DispatchContext OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL +); + +typedef struct { + DLINK Link; + UINT32 Signature; + SMI_GENERIC_CALLBACK2 Callback; + UINT8 Context[1]; +} HANDLER_LINK2; + +//--------------------------------------------------------------------------- +// SMI Handler protocol functions prototypes +//--------------------------------------------------------------------------- + +typedef EFI_STATUS ( *ADD_HANDLER2 ) ( + IN VOID *Context +); + +typedef EFI_STATUS ( *REMOVE_HANDLER2 ) ( + IN VOID *Context +); + +typedef EFI_STATUS ( *VERIFY_CONTEXT2) ( + IN VOID *Context +); + +typedef BOOLEAN ( *GET_CONTEXT2 ) ( + VOID +); + +typedef EFI_STATUS ( *DISPATCH_SMI2 ) ( + VOID +); + +typedef struct { + ADD_HANDLER2 AddHandler; + REMOVE_HANDLER2 RemoveHandler; + VERIFY_CONTEXT2 VerifyContext; + GET_CONTEXT2 GetContext; + DISPATCH_SMI2 DispatchSmi; +} SMI_HANDLER_PROTOCOL2; + +typedef struct { + EFI_SMM_SMI2 SmiType; + SMI_HANDLER_PROTOCOL2 HandlerProtocol; + DLIST RegisteredCallbacks; +} SMM_CHILD_DISPATCHER2; + +#pragma pack(pop) + +//--------------------------------------------------------------------------- +// SW SMI Handler functions +//--------------------------------------------------------------------------- + +EFI_STATUS SmmSwAddHandler2( IN VOID *Context ); +EFI_STATUS SmmSwRemoveHandler2( IN VOID *Context ); +EFI_STATUS SmmSwVerifyContext2( IN VOID *Context ); +BOOLEAN SmmSwGetContext2( VOID ); +EFI_STATUS SmmSwDispatchSmi2( VOID ); + +//---------------------- SW SMI Handler Porting hooks ----------------------- + +VOID SwSmiEnable( VOID ); +VOID SwSmiDisable( VOID ); +VOID SwSmiClear( VOID ); +BOOLEAN SwSmiDetect( OUT UINT16 *Type ); +UINTN GetEAX( VOID ); + +//--------------------------------------------------------------------------- +// SX SMI Handler functions +//--------------------------------------------------------------------------- + +EFI_STATUS SmmSxAddHandler2( IN VOID *Context ); +EFI_STATUS SmmSxRemoveHandler2( IN VOID *Context ); +EFI_STATUS SmmSxVerifyContext2( IN VOID *Context ); +BOOLEAN SmmSxGetContext2( VOID ); +EFI_STATUS SmmSxDispatchSmi2( VOID ); + +//---------------------- SX SMI Handler Porting hooks ----------------------- + +VOID SxSmiEnable( VOID ); +VOID SxSmiDisable( VOID ); +VOID SxSmiClear( VOID ); +VOID PutToSleep( IN VOID *Context ); +BOOLEAN SxSmiDetect( OUT UINT16 *Type ); + +//--------------------------------------------------------------------------- +// Periodic timer SMI Handler functions +//--------------------------------------------------------------------------- + +EFI_STATUS SmmTimerAddHandler2( IN VOID *Context ); +EFI_STATUS SmmTimerRemoveHandler2( IN VOID *Context ); +EFI_STATUS SmmTimerVerifyContext2( IN VOID *Context ); +BOOLEAN SmmTimerGetContext2( VOID ); +EFI_STATUS SmmTimerDispatchSmi2( VOID ); + +//---------------- Periodic timer SMI Handler Porting hooks ----------------- + +VOID TimerSmiEnable2( VOID ); +VOID TimerSmiDisable2( VOID ); +VOID TimerSmiClear2( VOID ); +BOOLEAN TimerSmiDetect2( OUT UINT16 *Type ); +VOID TimerSetInterval2( IN UINT64 Interval); + +//--------------------------------------------------------------------------- +// USB SMI Handler functions +//--------------------------------------------------------------------------- + +EFI_STATUS SmmUsbAddHandler2( IN VOID *Context ); +EFI_STATUS SmmUsbRemoveHandler2( IN VOID *Context ); +EFI_STATUS SmmUsbVerifyContext2( IN VOID *Context ); +BOOLEAN SmmUsbGetContext2( VOID ); +EFI_STATUS SmmUsbDispatchSmi2( VOID ); + +//---------------------- USB SMI Handler Porting hooks ---------------------- + +VOID UsbSmiSet( IN UINT16 ControllerType ); +VOID UsbSmiClear( IN UINT16 ControllerType ); +BOOLEAN UsbSmiDetect( OUT UINT16 *Type ); +UINT16 GetControllerType( OUT EFI_DEVICE_PATH_PROTOCOL *Device ); + +//--------------------------------------------------------------------------- +// GPI SMI Handler functions +//--------------------------------------------------------------------------- + +EFI_STATUS SmmGpiAddHandler2( IN VOID *Context ); +EFI_STATUS SmmGpiRemoveHandler2( IN VOID *Context ); +EFI_STATUS SmmGpiVerifyContext2( IN VOID *Context ); +BOOLEAN SmmGpiGetContext2( VOID ); +EFI_STATUS SmmGpiDispatchSmi2( VOID ); + +//---------------------- GPI SMI Handler Porting hooks ---------------------- + +VOID GpiSmiSet( IN UINT32 GpiEnableBit ); +VOID GpiSmiReset( IN UINT32 GpiDisableBit ); +VOID GpiSmiClear( IN UINT32 GpiClearBit ); +BOOLEAN GpiSmiDetect( OUT UINT32 *Gpi ); +UINT32 ConvertGpi ( IN UINTN Gpi ); + +//--------------------------------------------------------------------------- +// Standby button SMI Handler functions +//--------------------------------------------------------------------------- + +EFI_STATUS SmmSButtonAddHandler2( IN VOID *Context ); +EFI_STATUS SmmSButtonRemoveHandler2( IN VOID *Context ); +EFI_STATUS SmmSButtonVerifyContext2( IN VOID *Context ); +BOOLEAN SmmSButtonGetContext2( VOID ); +EFI_STATUS SmmSButtonDispatchSmi2( VOID ); + +//---------------- Standby button SMI Handler Porting hooks ----------------- + +VOID SButtonSmiEnable( VOID ); +VOID SButtonSmiDisable( VOID ); +VOID SButtonSmiClear( VOID ); +BOOLEAN SButtonSmiDetect( OUT UINT16 *Type ); + +//--------------------------------------------------------------------------- +// Power button SMI Handler functions +//--------------------------------------------------------------------------- + +EFI_STATUS SmmPButtonAddHandler2( IN VOID *Context ); +EFI_STATUS SmmPButtonRemoveHandler2( IN VOID *Context ); +EFI_STATUS SmmPButtonVerifyContext2( IN VOID *Context ); +BOOLEAN SmmPButtonGetContext2( VOID ); +EFI_STATUS SmmPButtonDispatchSmi2( VOID ); + +//---------------- Power button SMI Handler Porting hooks ------------------- + +VOID PButtonSmiEnable( VOID ); +VOID PButtonSmiDisable( VOID ); +VOID PButtonSmiClear( VOID ); +BOOLEAN PButtonSmiDetect( OUT UINT16 *Type ); + +//--------------------------------------------------------------------------- +// I/O Trap SMI Handler functions +//--------------------------------------------------------------------------- + +EFI_STATUS SmmIoTrapAddHandler2( IN VOID *Context ); +EFI_STATUS SmmIoTrapRemoveHandler2( IN VOID *Context ); +EFI_STATUS SmmIoTrapVerifyContext2( IN VOID *Context ); +BOOLEAN SmmIoTrapGetContext2( VOID ); +EFI_STATUS SmmIoTrapDispatchSmi2( VOID ); + +//------------------ I/O Trap SMI Handler Porting hooks --------------------- + +VOID IoTrapSmiSet2( IN EFI_SMM_IO_TRAP_REGISTER_CONTEXT *Context, \ + OUT UINT32 *TrapRegIndex ); +VOID IoTrapSmiReset2( IN EFI_SMM_IO_TRAP_REGISTER_CONTEXT *Context, \ + OUT UINT32 *TrapRegIndex ); +VOID IoTrapSmiEnable2( VOID ); +VOID IoTrapSmiDisable2( VOID ); +VOID IoTrapSmiClear2( VOID ); +BOOLEAN IoTrapSmiDetect2( OUT EFI_SMM_IO_TRAP_REGISTER_CONTEXT *Context, \ + OUT UINT32 *IoTrapWriteDara ); + +//--------------------------------------------------------------------------- +// All purpose SMI Porting hooks +//--------------------------------------------------------------------------- +VOID ClearAllSmi( VOID ); + // [EIP93461]> +VOID SbSmiWorkaround2( VOID ); + // <[EIP93461] +/****** DO NOT WRITE BELOW THIS LINE *******/ +#ifdef __cplusplus +} +#endif +#endif + +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* diff --git a/Chipset/SB/Smm2/SmmChildDispatch2Main.c b/Chipset/SB/Smm2/SmmChildDispatch2Main.c new file mode 100644 index 0000000..bae5efc --- /dev/null +++ b/Chipset/SB/Smm2/SmmChildDispatch2Main.c @@ -0,0 +1,510 @@ +#pragma optimize ("", off) +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* + +//************************************************************************* +// $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatch2Main.c 4 10/19/12 2:52a Scottyang $ +// +// $Revision: 4 $ +// +// $Date: 10/19/12 2:52a $ +//************************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatch2Main.c $ +// +// 4 10/19/12 2:52a Scottyang +// [TAG] EIP93461 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] System halt when AFUDOS is running with /N /ME command. +// [RootCause] An unexpected BIOSWR_STS is set, it causes BIOS stuck +// at SMM dispatcher. +// [Solution] Clear BIOSWR_STS if BIOS Lock Enable is not set. +// [Files] SmiHandlerPorting2.c; SmmChildDispatch2Main.c +// SmmChildDispatcher2.sdl; SmmChildDispatch2.h +// SB\SBGeneric.c +// +// 3 8/30/12 9:50a Victortu +// [TAG] None +// [Category] Improvement +// [Description] Implement EIP#73211 and EIP#79156 for OA 3.0 function. +// [Files] SmiHandlerGeneric2.c, SmmChildDispatch2Main.c +// +// 2 4/25/12 9:32a Victortu +// [TAG] None +// [Category] Improvement +// [Description] Reprogram SMM ChildDispatcher drivers. +// [Files] SmiHandlerGeneric.c; SmiHandlerPorting.c; +// SmiHandlerGeneric2.c; SmmChildDispatch2Main.c; SmmChildDispatcher2.mak; +// SmmChildDispatcher2.sdl; SmmChildDispatch.h; SmmChildDispatchMain.c; +// SmmChildDispatchProtocol.c; SmmChildDispatcher.dxs; +// PchSmiDispatcher.sdl +// +// 1 2/08/12 8:28a Yurenlai +// Intel Lynx Point/SB eChipset initially releases. +// +//************************************************************************* +//<AMI_FHDR_START> +// +// Name: SmmChildDispatch2Main.c +// +// Description: This file contains implementation of module entry point, +// generic RegisterHandler and UnregisterHandler routines +// and main dispatcher loop. +// +//<AMI_FHDR_END> +//************************************************************************* + +//--------------------------------------------------------------------------- +// Include(s) +//--------------------------------------------------------------------------- + +#include <AmiCspLib.h> +#include <Smm.h> +#include <Protocol\SmmBase2.h> +#include <Protocol\SmmCpu.h> +#include "SmmChildDispatch2.h" +#include "SmmChildDispatch2Protocol.h" + +//--------------------------------------------------------------------------- +// Constant, Macro and Type Definition(s) +//--------------------------------------------------------------------------- +// Constant Definition(s) + +#define SMI_HANDLER_SIGNATURE 0x48494d53 //SMIH + +// Macro Definition(s) + +// Type Definition(s) + +// Function Prototype(s) + +//--------------------------------------------------------------------------- +// Variable and External Declaration(s) +//--------------------------------------------------------------------------- +// Variable Declaration(s) + +EFI_SMM_SMI_CONTEXT2 SmiContext; +EFI_SMM_BASE2_PROTOCOL *gSmmBase2; +EFI_SMM_SYSTEM_TABLE2 *gSmst2; +EFI_SMM_CPU_PROTOCOL *gEfiSmmCpuProtocol; + +// GUID Definition(s) + +EFI_GUID gEfiSmmChildDispatcher2Guid = SMM_CHILD_DISPATCHER2_GUID; + +// Protocol Definition(s) + +// External Declaration(s) + +extern SMM_CHILD_DISPATCHER2 Smm2Handler[]; + +extern EFI_SMM_SW_DISPATCH2_PROTOCOL gEfiSmmSwDispatch2Protocol; +extern EFI_SMM_SX_DISPATCH2_PROTOCOL gEfiSmmSxDispatch2Protocol; +extern EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL gEfiSmmPeriodicTimerDispatch2Protocol; +extern EFI_SMM_USB_DISPATCH2_PROTOCOL gEfiSmmUsbDispatch2Protocol; +extern EFI_SMM_GPI_DISPATCH2_PROTOCOL gEfiSmmGpiDispatch2Protocol; +extern EFI_SMM_STANDBY_BUTTON_DISPATCH2_PROTOCOL gEfiSmmStandbyButtonDispatch2Protocol; +extern EFI_SMM_POWER_BUTTON_DISPATCH2_PROTOCOL gEfiSmmPowerButonDispatch2Protocol; +extern EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL gEfiSmmIoTrapDispatch2Protocol; + +// Function Definition(s) + +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: RegisterHandler2 +// +// Description: This function registers SMI II handler and returns registered +// handle +// +// Input: Type - Type of SMI handler +// Function - Pointer to callback function +// *Context - Pointer to callback context +// ContextSize - Callback context size +// *Handle - Pointer to store registered handle +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS RegisterHandler2 ( + IN EFI_SMM_SMI2 Type, + IN SMI_GENERIC_CALLBACK2 Function, + IN VOID *Context, + IN UINTN ContextSize, + OUT EFI_HANDLE *Handle ) +{ + EFI_STATUS Status; + HANDLER_LINK2 *HandlerLink; + + Status = Smm2Handler[Type].HandlerProtocol.VerifyContext( Context ); + if(EFI_ERROR(Status)) return Status; + + Status = gSmst2->SmmAllocatePool( 0, + sizeof(HANDLER_LINK2) + ContextSize - 1, + &HandlerLink ); + if(EFI_ERROR(Status)) return Status; + + HandlerLink->Callback = Function; + HandlerLink->Signature = SMI_HANDLER_SIGNATURE; + MemCpy( HandlerLink->Context, Context, ContextSize ); + + DListAdd(&(Smm2Handler[Type].RegisteredCallbacks), (DLINK *)HandlerLink); + + Smm2Handler[Type].HandlerProtocol.AddHandler( HandlerLink->Context ); + *Handle = HandlerLink; + + return EFI_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: FindHandler +// +// Description: This function find the handle in the Type of SMI hander list. +// +// Input: Type - Type of SMI handler +// Handle - Handle of found handler +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS FindHandler( + IN EFI_SMM_SMI2 Type, + IN EFI_HANDLE Handle) +{ + HANDLER_LINK2 *HandlerLink = (HANDLER_LINK2 *)Handle; + HANDLER_LINK2 *NodeLink = NULL; + + if (HandlerLink->Signature != SMI_HANDLER_SIGNATURE) + return EFI_INVALID_PARAMETER; + + if (Smm2Handler[Type].RegisteredCallbacks.Size <= 0) + return EFI_UNSUPPORTED; + + NodeLink = (HANDLER_LINK2 *)Smm2Handler[Type].RegisteredCallbacks.pHead; + for (; NodeLink != NULL; NodeLink = (HANDLER_LINK2 *)NodeLink->Link.pNext) + { + if (NodeLink == HandlerLink) + return EFI_SUCCESS; + } + + return EFI_UNSUPPORTED; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: UnregisterHandler2 +// +// Description: This function unregisters SMI II handler with given handle +// +// Input: Type - Type of SMI handler +// Handle - Handle of registered handler +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS UnregisterHandler2 ( + IN EFI_SMM_SMI2 Type, + IN EFI_HANDLE Handle ) +{ + EFI_STATUS Status; + HANDLER_LINK2 *HandlerLink = (HANDLER_LINK2 *)Handle; + + Status = FindHandler(Type, Handle); + if (Status == EFI_SUCCESS) + { + Smm2Handler[Type].HandlerProtocol.RemoveHandler( HandlerLink->Context ); + DListDelete( &(Smm2Handler[Type].RegisteredCallbacks), (DLINK *)HandlerLink ); + gSmst2->SmmFreePool( HandlerLink ); + } + + return Status; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: ChildDispatcher2 +// +// Description: This function implements main SMI II dispatcher. +// +// Input: DispatchHandle - SMM dispatch handle +// *Context - Pointer to the dispatched context +// CommBuffer - Pointer to a collection of data in memory +// that will be conveyed from a non-SMM +// environment into an SMM environment. +// CommBufferSize - Pointer to the size of the CommBuffer +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS ChildDispatcher2 ( + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + UINT32 Index; + BOOLEAN HandledSmi; + + do + { + HandledSmi = FALSE; + for (Index = EfiSmmSwSmi2; Index < EfiSmmMaxSmi2; Index++) + { + if (Smm2Handler[Index].HandlerProtocol.GetContext != 0 && + Smm2Handler[Index].HandlerProtocol.GetContext()) + { + Status = Smm2Handler[Index].HandlerProtocol.DispatchSmi(); + if (Status != EFI_WARN_INTERRUPT_SOURCE_QUIESCED) + { + HandledSmi = TRUE; + } + } + } + } while (HandledSmi); + // [EIP93461]> + SbSmiWorkaround2(); + // <[EIP93461] + return EFI_HANDLER_SUCCESS; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: InSmmFunction +// +// Description: This function initializes Child dispatcher in SMM mode +// +// Input: ImageHandle - Image handle +// *SystemTable - Pointer to system table +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS InSmmFunction ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle = NULL; + EFI_HANDLE BsHandle = NULL; + EFI_HANDLE RootHandle; + +#if (CHILD_DISPATCHER_SUPPORT == 0) + ClearAllSmi(); +#endif + + // Locate SMM CPU Protocols + Status = gSmst2->SmmLocateProtocol( &gEfiCpuProtocolGuid, + NULL, + &gEfiSmmCpuProtocol); + + // Install Protocols + Status = gSmst2->SmmInstallProtocolInterface( + &Handle, + &gEfiSmmSwDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &gEfiSmmSwDispatch2Protocol); + ASSERT_EFI_ERROR(Status); + + Status = pBS->InstallProtocolInterface( + &BsHandle, + &gEfiSmmSwDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + NULL); + ASSERT_EFI_ERROR(Status); + + Status = gSmst2->SmmInstallProtocolInterface( + &Handle, + &gEfiSmmSxDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &gEfiSmmSxDispatch2Protocol); + ASSERT_EFI_ERROR(Status); + + Status = pBS->InstallProtocolInterface( + &BsHandle, + &gEfiSmmSxDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + NULL); + ASSERT_EFI_ERROR(Status); + + Status = gSmst2->SmmInstallProtocolInterface( + &Handle, + &gEfiSmmPeriodicTimerDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &gEfiSmmPeriodicTimerDispatch2Protocol); + ASSERT_EFI_ERROR(Status); + + Status = pBS->InstallProtocolInterface( + &BsHandle, + &gEfiSmmPeriodicTimerDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + NULL); + ASSERT_EFI_ERROR(Status); + + Status = gSmst2->SmmInstallProtocolInterface( + &Handle, + &gEfiSmmUsbDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &gEfiSmmUsbDispatch2Protocol); + ASSERT_EFI_ERROR(Status); + + Status = pBS->InstallProtocolInterface( + &BsHandle, + &gEfiSmmUsbDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + NULL); + ASSERT_EFI_ERROR(Status); + + Status = gSmst2->SmmInstallProtocolInterface( + &Handle, + &gEfiSmmGpiDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &gEfiSmmGpiDispatch2Protocol); + ASSERT_EFI_ERROR(Status); + + Status = pBS->InstallProtocolInterface( + &BsHandle, + &gEfiSmmGpiDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + NULL); + ASSERT_EFI_ERROR(Status); + + Status = gSmst2->SmmInstallProtocolInterface( + &Handle, + &gEfiSmmStandbyButtonDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &gEfiSmmStandbyButtonDispatch2Protocol); + ASSERT_EFI_ERROR(Status); + + Status = pBS->InstallProtocolInterface( + &BsHandle, + &gEfiSmmStandbyButtonDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + NULL); + ASSERT_EFI_ERROR(Status); + + Status = gSmst2->SmmInstallProtocolInterface( + &Handle, + &gEfiSmmPowerButtonDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &gEfiSmmPowerButonDispatch2Protocol); + ASSERT_EFI_ERROR(Status); + + Status = pBS->InstallProtocolInterface( + &BsHandle, + &gEfiSmmPowerButtonDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + NULL); + ASSERT_EFI_ERROR(Status); + + Status = gSmst2->SmmInstallProtocolInterface( + &Handle, + &gEfiSmmIoTrapDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &gEfiSmmIoTrapDispatch2Protocol); + ASSERT_EFI_ERROR(Status); + + Status = pBS->InstallProtocolInterface( + &BsHandle, + &gEfiSmmIoTrapDispatch2ProtocolGuid, + EFI_NATIVE_INTERFACE, + NULL); + ASSERT_EFI_ERROR(Status); + + Status = gSmst2->SmiHandlerRegister(ChildDispatcher2, NULL, &RootHandle); + + return Status; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: SmmChildDispatch2EntryPoint +// +// Description: SMM Child Dispatcher II module entry point +// +// Input: ImageHandle - Image handle +// *SystemTable - Pointer to system table +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS SmmChildDispatch2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) +{ + EFI_STATUS Status; + BOOLEAN InSmram = FALSE; + + InitAmiLib( ImageHandle, SystemTable ); + + Status = pBS->LocateProtocol(&gEfiSmmBase2ProtocolGuid, NULL, &gSmmBase2); + if (!EFI_ERROR(Status)) + { + Status = gSmmBase2->InSmm(gSmmBase2, &InSmram); + if ((!EFI_ERROR(Status)) && + (InSmram)) + { + Status = InitAmiSmmLib( ImageHandle, SystemTable ); + if (EFI_ERROR(Status)) + return Status; + + Status = gSmmBase2->GetSmstLocation(gSmmBase2, &gSmst2); + if (!EFI_ERROR(Status)) + { + Status = InSmmFunction(ImageHandle, SystemTable); + return Status; + } + else + { + gSmst2 = NULL; + } + } + else + { + // DXE initialize. + } + } + + return EFI_SUCCESS; +} + +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* diff --git a/Chipset/SB/Smm2/SmmChildDispatch2Protocol.c b/Chipset/SB/Smm2/SmmChildDispatch2Protocol.c new file mode 100644 index 0000000..2fc7edc --- /dev/null +++ b/Chipset/SB/Smm2/SmmChildDispatch2Protocol.c @@ -0,0 +1,679 @@ +#pragma optimize ("", off) +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* + +//************************************************************************* +// $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatch2Protocol.c 1 2/08/12 8:28a Yurenlai $ +// +// $Revision: 1 $ +// +// $Date: 2/08/12 8:28a $ +//************************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatch2Protocol.c $ +// +// 1 2/08/12 8:28a Yurenlai +// Intel Lynx Point/SB eChipset initially releases. +// +//************************************************************************* +//<AMI_FHDR_START> +// +// Name: SmmChildDispatch2Protocol.c +// +// Description: This file contains SMM Child dispatcher II Protocols +// +//<AMI_FHDR_END> +//************************************************************************* + +//--------------------------------------------------------------------------- +// Include(s) +//--------------------------------------------------------------------------- + +#include <Token.h> +#include <AmiDxeLib.h> +#include "SmmChildDispatch2.h" +#include "SmmChildDispatch2Protocol.h" + +//--------------------------------------------------------------------------- +// Constant, Macro and Type Definition(s) +//--------------------------------------------------------------------------- +// Constant Definition(s) + +// Macro Definition(s) + +// Type Definition(s) + +// Function Prototype(s) + +//--------------------------------------------------------------------------- +// Variable and External Declaration(s) +//--------------------------------------------------------------------------- +// Variable Declaration(s) + +SMM_CHILD_DISPATCHER2 Smm2Handler[] = { + // SwSmmHandler + EfiSmmSwSmi2, + { SmmSwAddHandler2, \ + SmmSwRemoveHandler2, \ + SmmSwVerifyContext2, \ + SmmSwGetContext2, \ + SmmSwDispatchSmi2 }, + { 0, NULL, NULL }, + + // SxSmmHandler + EfiSmmSxSmi2, + { SmmSxAddHandler2, \ + SmmSxRemoveHandler2, \ + SmmSxVerifyContext2, \ + SmmSxGetContext2, \ + SmmSxDispatchSmi2 }, + { 0, NULL, NULL }, + + // PeriodicTimerSmmHandler + EfiSmmPeriodicTimerSmi2, + { SmmTimerAddHandler2, \ + SmmTimerRemoveHandler2, \ + SmmTimerVerifyContext2, \ + SmmTimerGetContext2, \ + SmmTimerDispatchSmi2 }, + { 0, NULL, NULL }, + + // UsbSmmHandler + EfiSmmUsbSmi2, + { SmmUsbAddHandler2, \ + SmmUsbRemoveHandler2, \ + SmmUsbVerifyContext2, \ + SmmUsbGetContext2, \ + SmmUsbDispatchSmi2 }, + { 0, NULL, NULL }, + + // GpiSmmHandler + EfiSmmGpiSmi2, + { SmmGpiAddHandler2, \ + SmmGpiRemoveHandler2, \ + SmmGpiVerifyContext2, \ + SmmGpiGetContext2, \ + SmmGpiDispatchSmi2 }, + { 0, NULL, NULL }, + + // SButtonSmmHandler + EfiSmmStandbyButtonSmi2, + { SmmSButtonAddHandler2, \ + SmmSButtonRemoveHandler2, \ + SmmSButtonVerifyContext2, \ + SmmSButtonGetContext2, \ + SmmSButtonDispatchSmi2 }, + { 0, NULL, NULL }, + + // PButtonSmmHandler + EfiSmmPowerButtonSmi2, + { SmmPButtonAddHandler2, \ + SmmPButtonRemoveHandler2, \ + SmmPButtonVerifyContext2, \ + SmmPButtonGetContext2, \ + SmmPButtonDispatchSmi2 }, + { 0, NULL, NULL }, + + // IoTrapSmmHandler + EfiSmmIoTrapSmi2, + { SmmIoTrapAddHandler2, \ + SmmIoTrapRemoveHandler2, \ + SmmIoTrapVerifyContext2, \ + SmmIoTrapGetContext2, \ + SmmIoTrapDispatchSmi2 }, + { 0, NULL, NULL }, + +//********************** PUT ADDITIONAL HANDLERS HERE *********************** +//********************** PUT ADDITIONAL HANDLERS HERE *********************** +//********************** PUT ADDITIONAL HANDLERS HERE *********************** + + // Terminator record + EfiSmmMaxSmi2, + { NULL, NULL, NULL, NULL, NULL }, + { 0, NULL, NULL } +}; + +EFI_SMM_SW_DISPATCH2_PROTOCOL gEfiSmmSwDispatch2Protocol = \ + { EfiSmmSwRegister2, \ + EfiSmmSwUnregister2, \ + MAX_SW_SMI_INPUT_VALUE }; + +EFI_SMM_SX_DISPATCH2_PROTOCOL gEfiSmmSxDispatch2Protocol = \ + { EfiSmmSxRegister2, EfiSmmSxUnregister2 }; + +EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL \ + gEfiSmmPeriodicTimerDispatch2Protocol = \ + { EfiSmmTimerRegister2, \ + EfiSmmTimerUnregister2, \ + EfiSmmTimerGetNextShorterInterval2 }; + +EFI_SMM_USB_DISPATCH2_PROTOCOL gEfiSmmUsbDispatch2Protocol = \ + { EfiSmmUsbRegister2, EfiSmmUsbUnregister2 }; + +EFI_SMM_GPI_DISPATCH2_PROTOCOL gEfiSmmGpiDispatch2Protocol = \ + { EfiSmmGpiRegister2, \ + EfiSmmGpiUnregister2, \ + SUPPORTED_GPIS }; + +EFI_SMM_STANDBY_BUTTON_DISPATCH2_PROTOCOL \ + gEfiSmmStandbyButtonDispatch2Protocol = \ + { EfiSmmSButtonRegister2, EfiSmmSButtonUnregister2 }; + +EFI_SMM_POWER_BUTTON_DISPATCH2_PROTOCOL gEfiSmmPowerButonDispatch2Protocol = \ + { EfiSmmPButtonRegister2, EfiSmmPButtonUnregister2 }; + + +EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL gEfiSmmIoTrapDispatch2Protocol = \ + { EfiSmmIoTrapRegister2, EfiSmmIoTrapUnregister2 }; + + +// GUID Definition(s) + +// Protocol Definition(s) + +// External Declaration(s) + +extern UINT64 gSupportedIntervals[]; + +// Function Definition(s) + +//--------------------------------------------------------------------------- +// S/W SMI Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmSwRegister2 +// +// Description: EFI_SMM_SW_DISPATCH2_PROTOCOL Register function. +// +// Input: *This - Pointer to EFI_SMM_SW_DISPATCH2_PROTOCOL +// Function - Pointer to callback function +// *Context - Pointer to callback context +// *Handle - Pointer to store registered handle +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmSwRegister2 ( + IN CONST EFI_SMM_SW_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_SW_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle ) +{ + return RegisterHandler2( EfiSmmSwSmi2, \ + Function, \ + Context, \ + sizeof(EFI_SMM_SW_REGISTER_CONTEXT), \ + Handle ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmSwUnregister2 +// +// Description: EFI_SMM_SW_DISPATCH2_PROTOCOL Unregister function. +// +// Input: *This - Pointer to the EFI_SMM_SW_DISPATCH2_PROTOCOL +// Handle - Handle to unregister +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmSwUnregister2 ( + IN CONST EFI_SMM_SW_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle ) +{ + return UnregisterHandler2( EfiSmmSwSmi2, Handle ); +} + +//--------------------------------------------------------------------------- +// Sleep SMI Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmSxRegister2 +// +// Description: EFI_SMM_SX_DISPATCH2_PROTOCOL Register function. +// +// Input: *This - Pointer to EFI_SMM_SX_DISPATCH2_PROTOCOL +// Function - Pointer to callback function +// *Context - Pointer to callback context +// *Handle - Pointer to store registered handle +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmSxRegister2 ( + IN CONST EFI_SMM_SX_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_SX_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle ) +{ + return RegisterHandler2( EfiSmmSxSmi2, \ + Function, \ + Context, \ + sizeof(EFI_SMM_SX_REGISTER_CONTEXT), \ + Handle ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmSxUnregister2 +// +// Description: EFI_SMM_SW_DISPATCH2_PROTOCOL Unregister function. +// +// Input: *This - Pointer to the EFI_SMM_SX_DISPATCH2_PROTOCOL +// Handle - Handle to unregister +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmSxUnregister2 ( + IN CONST EFI_SMM_SX_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle ) +{ + return UnregisterHandler2( EfiSmmSxSmi2, Handle ); +} + +//--------------------------------------------------------------------------- +// Periodic timer SMI Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmTimerRegister2 +// +// Description: EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL Register function. +// +// Input: *This - Pointer to +// EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL +// Function - Pointer to callback function +// *Context - Pointer to callback context +// *Handle - Pointer to store registered handle +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmTimerRegister2 ( + IN CONST EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle ) +{ + EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT ExContext; + TRACE ((TRACE_ALWAYS, "EfiSmmTimerRegister2 \n")); + ExContext.OrgContext = *Context; + ExContext.ElapsedTime = 0; + + return RegisterHandler2( EfiSmmPeriodicTimerSmi2, \ + Function, \ + &ExContext, \ + sizeof(EFI_SMM_PERIODIC_TIMER_EXT_REGISTER_CONTEXT), \ + Handle ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmTimerUnregister2 +// +// Description: EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL Unregister function. +// +// Input: *This - Pointer to the +// EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL +// Handle - Handle to unregister +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmTimerUnregister2 ( + IN CONST EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle ) +{ + TRACE ((TRACE_ALWAYS, "EfiSmmTimerUnregister2 \n")); + return UnregisterHandler2( EfiSmmPeriodicTimerSmi2, Handle ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmTimerGetNextShorterInterval2 +// +// Description: EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL +// GetNextShorterInterval function. +// +// Input: *This - Pointer to the +// EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL +// **SmiTickInterval - Pointer to store pointer to next interval +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmTimerGetNextShorterInterval2 ( + IN CONST EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL *This, + IN OUT UINT64 **SmiTickInterval ) +{ + UINT64 *Result = *SmiTickInterval; + TRACE ((TRACE_ALWAYS, "EfiSmmTimerGetNextShorterInterval2 \n")); + if (Result == NULL) { + Result = gSupportedIntervals; + } else { + Result++; + } + *SmiTickInterval = (*Result == 0) ? NULL : Result; + + return EFI_SUCCESS; +} + +//--------------------------------------------------------------------------- +// USB SMI Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmUsbRegister2 +// +// Description: EFI_SMM_USB_DISPATCH2_PROTOCOL Register function. +// +// Input: *This - Pointer to EFI_SMM_USB_DISPATCH2_PROTOCOL +// Function - Pointer to callback function +// *Context - Pointer to callback context +// *Handle - Pointer to store registered handle +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmUsbRegister2 ( + IN CONST EFI_SMM_USB_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_USB_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle ) +{ + return RegisterHandler2( EfiSmmUsbSmi2, \ + Function, \ + Context, \ + sizeof(EFI_SMM_USB_REGISTER_CONTEXT), \ + Handle ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmUsbUnregister2 +// +// Description: EFI_SMM_USB_DISPATCH2_PROTOCOL Unregister function. +// +// Input: *This - Pointer to the EFI_SMM_USB_DISPATCH2_PROTOCOL +// Handle - Handle to unregister +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmUsbUnregister2 ( + IN CONST EFI_SMM_USB_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle ) +{ + return UnregisterHandler2( EfiSmmUsbSmi2, Handle ); +} + +//--------------------------------------------------------------------------- +// GPI SMI Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmGpiRegister2 +// +// Description: EFI_SMM_GPI_DISPATCH2_PROTOCOL Register function. +// +// Input: *This - Pointer to EFI_SMM_GPI_DISPATCH2_PROTOCOL +// Function - Pointer to callback function +// *Context - Pointer to callback context +// *Handle - Pointer to store registered handle +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmGpiRegister2 ( + IN CONST EFI_SMM_GPI_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_GPI_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle ) +{ + return RegisterHandler2( EfiSmmGpiSmi2, \ + Function, \ + Context, \ + sizeof(EFI_SMM_GPI_REGISTER_CONTEXT), \ + Handle ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmGpiUnregister2 +// +// Description: EFI_SMM_GPI_DISPATCH2_PROTOCOL Unregister function. +// +// Input: *This - Pointer to the EFI_SMM_GPI_DISPATCH2_PROTOCOL +// Handle - Handle to unregister +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmGpiUnregister2 ( + IN CONST EFI_SMM_GPI_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle ) +{ + return UnregisterHandler2( EfiSmmGpiSmi2, Handle ); +} + +//--------------------------------------------------------------------------- +// Standby button SMI Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmSButtonRegister2 +// +// Description: EFI_SMM_STANDBY_BUTTON_DISPATCH2_PROTOCOL Register function. +// +// Input: *This - Pointer to +// EFI_SMM_STANDBY_BUTTON_DISPATCH2_PROTOCOL +// Function - Pointer to callback function +// *Context - Pointer to callback context +// *Handle - Pointer to store registered handle +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmSButtonRegister2 ( + IN CONST EFI_SMM_STANDBY_BUTTON_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle ) +{ + return RegisterHandler2( EfiSmmStandbyButtonSmi2, \ + Function, \ + Context, \ + sizeof(EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT),\ + Handle ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmSButtonUnregister2 +// +// Description: EFI_SMM_STANDBY_BUTTON_DISPATCH2_PROTOCOL Unregister function. +// +// Input: *This - Pointer to the +// EFI_SMM_STANDBY_BUTTON_DISPATCH2_PROTOCOL +// Handle - Handle to unregister +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmSButtonUnregister2 ( + IN CONST EFI_SMM_STANDBY_BUTTON_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle ) +{ + return UnregisterHandler2( EfiSmmStandbyButtonSmi2, Handle ); +} + +//--------------------------------------------------------------------------- +// Power button SMI Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmPButtonRegister2 +// +// Description: EFI_SMM_POWER_BUTTON_DISPATCH2_PROTOCOL Register function. +// +// Input: *This - Pointer to EFI_SMM_POWER_BUTTON_DISPATCH2_PROTOCOL +// Function - Pointer to callback function +// *Context - Pointer to callback context +// *Handle - Pointer to store registered handle +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmPButtonRegister2 ( + IN CONST EFI_SMM_POWER_BUTTON_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle ) +{ + return RegisterHandler2( EfiSmmPowerButtonSmi2, \ + Function, \ + Context, \ + sizeof(EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT), \ + Handle ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmPButtonUnregister2 +// +// Description: EFI_SMM_POWER_BUTTON_DISPATCH2_PROTOCOL Unregister function. +// +// Input: *This - Pointer to the +// EFI_SMM_POWER_BUTTON_DISPATCH2_PROTOCOL +// Handle - Handle to unregister +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmPButtonUnregister2 ( + IN CONST EFI_SMM_POWER_BUTTON_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle ) +{ + return UnregisterHandler2( EfiSmmPowerButtonSmi2, Handle ); +} + +//--------------------------------------------------------------------------- +// I/O Trap SMI Handler functions +//--------------------------------------------------------------------------- + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmIoTrapRegister2 +// +// Description: EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL Register function. +// +// Input: *This - Pointer to EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL +// Function - Pointer to callback function +// *Context - Pointer to register context +// *Handle - Pointer to store registered handle +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmIoTrapRegister2 ( + IN CONST EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN OUT EFI_SMM_IO_TRAP_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle) +{ + return RegisterHandler2( EfiSmmIoTrapSmi2, \ + Function, \ + Context, \ + sizeof(EFI_SMM_IO_TRAP_REGISTER_CONTEXT), \ + Handle ); +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: EfiSmmIoTrapUnregister2 +// +// Description: EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL Unregister function. +// +// Input: *This - Pointer to the EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL +// Handle - Handle to unregister +// +// Output: EFI_STATUS +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS EfiSmmIoTrapUnregister2 ( + IN CONST EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle ) +{ + return UnregisterHandler2( EfiSmmIoTrapSmi2, Handle ); +} + +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* diff --git a/Chipset/SB/Smm2/SmmChildDispatch2Protocol.h b/Chipset/SB/Smm2/SmmChildDispatch2Protocol.h new file mode 100644 index 0000000..39d7bd4 --- /dev/null +++ b/Chipset/SB/Smm2/SmmChildDispatch2Protocol.h @@ -0,0 +1,204 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* + +//************************************************************************* +// $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatch2Protocol.h 1 2/08/12 8:28a Yurenlai $ +// +// $Revision: 1 $ +// +// $Date: 2/08/12 8:28a $ +//************************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatch2Protocol.h $ +// +// 1 2/08/12 8:28a Yurenlai +// Intel Lynx Point/SB eChipset initially releases. +// +//************************************************************************* +//<AMI_FHDR_START> +// +// Name: SmmChildDispatch2Protocol.h +// +// Description: SMM Child dispatcher II protocols functions definition +// +//<AMI_FHDR_END> +//************************************************************************* + +#ifndef __SMM_CHILD_DISPATCH2_PROTOCOL__H__ +#define __SMM_CHILD_DISPATCH2_PROTOCOL__H__ +#ifdef __cplusplus +extern "C" { +#endif + +#include <Protocol\SmmSwDispatch2.h> +#include <Protocol\SmmSxDispatch2.h> +#include <Protocol\SmmPeriodicTimerDispatch2.h> +#include <Protocol\SmmUsbDispatch2.h> +#include <Protocol\SmmGpiDispatch2.h> +#include <Protocol\SmmStandbyButtonDispatch2.h> +#include <Protocol\SmmPowerButtonDispatch2.h> +#include <Protocol\SmmIoTrapDispatch2.h> + +//-------------- Generic register/unregister handler functions -------------- + +EFI_STATUS RegisterHandler2( + IN EFI_SMM_SMI2 Type, + IN SMI_GENERIC_CALLBACK2 Function, + IN CONST VOID *Context, + IN UINTN ContextSize, + OUT EFI_HANDLE *Handle +); + +EFI_STATUS UnregisterHandler2 ( + IN EFI_SMM_SMI2 Type, + IN EFI_HANDLE Handle +); + +//------------------------ Sw SMI protocol functions ------------------------ + +EFI_STATUS EfiSmmSwRegister2 ( + IN CONST EFI_SMM_SW_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_SW_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle +); + +EFI_STATUS EfiSmmSwUnregister2 ( + IN CONST EFI_SMM_SW_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle +); + +//------------------------ Sx SMI protocol functions ------------------------ + +EFI_STATUS EfiSmmSxRegister2 ( + IN CONST EFI_SMM_SX_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_SX_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle +); + +EFI_STATUS EfiSmmSxUnregister2 ( + IN CONST EFI_SMM_SX_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle +); + +//------------------ Periodic timer SMI protocol functions ------------------ + +EFI_STATUS EfiSmmTimerRegister2 ( + IN CONST EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle +); + +EFI_STATUS EfiSmmTimerUnregister2 ( + IN CONST EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle +); + +EFI_STATUS EfiSmmTimerGetNextShorterInterval2 ( + IN CONST EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL *This, + IN OUT UINT64 **SmiTickInterval +); + +//----------------------- Usb SMI protocol functions ------------------------ + +EFI_STATUS EfiSmmUsbRegister2 ( + IN CONST EFI_SMM_USB_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_USB_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle +); + +EFI_STATUS EfiSmmUsbUnregister2 ( + IN CONST EFI_SMM_USB_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle +); + +//----------------------- Gpi SMI protocol functions ------------------------ + +EFI_STATUS EfiSmmGpiRegister2 ( + IN CONST EFI_SMM_GPI_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_GPI_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle +); + +EFI_STATUS EfiSmmGpiUnregister2 ( + IN CONST EFI_SMM_GPI_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle +); + +//------------------ Standby button SMI protocol functions ------------------ + +EFI_STATUS EfiSmmSButtonRegister2 ( + IN CONST EFI_SMM_STANDBY_BUTTON_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle +); + +EFI_STATUS EfiSmmSButtonUnregister2 ( + IN CONST EFI_SMM_STANDBY_BUTTON_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle +); + +//------------------- Power button SMI protocol functions ------------------- + +EFI_STATUS EfiSmmPButtonRegister2 ( + IN CONST EFI_SMM_POWER_BUTTON_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN CONST EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle +); + +EFI_STATUS EfiSmmPButtonUnregister2 ( + IN CONST EFI_SMM_POWER_BUTTON_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle +); + +//--------------------- I/O Trap SMI protocol functions --------------------- + +EFI_STATUS EfiSmmIoTrapRegister2 ( + IN CONST EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL *This, + IN EFI_SMM_HANDLER_ENTRY_POINT2 Function, + IN OUT EFI_SMM_IO_TRAP_REGISTER_CONTEXT *Context, + OUT EFI_HANDLE *Handle +); + +EFI_STATUS EfiSmmIoTrapUnregister2 ( + IN CONST EFI_SMM_IO_TRAP_DISPATCH2_PROTOCOL *This, + IN EFI_HANDLE Handle +); + +/****** DO NOT WRITE BELOW THIS LINE *******/ +#ifdef __cplusplus +} +#endif +#endif + +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* diff --git a/Chipset/SB/Smm2/SmmChildDispatcher2.cif b/Chipset/SB/Smm2/SmmChildDispatcher2.cif new file mode 100644 index 0000000..c02d46b --- /dev/null +++ b/Chipset/SB/Smm2/SmmChildDispatcher2.cif @@ -0,0 +1,16 @@ +<component> + name = "SmmChildDispatcher2" + category = ModulePart + LocalRoot = "Chipset\SB\Smm2" + RefName = "SmmChildDispatcher2" +[files] +"SmmChildDispatcher2.mak" +"SmmChildDispatcher2.sdl" +"SmmChildDispatcher2.dxs" +"SmiHandlerGeneric2.c" +"SmiHandlerPorting2.c" +"SmmChildDispatch2.h" +"SmmChildDispatch2Main.c" +"SmmChildDispatch2Protocol.c" +"SmmChildDispatch2Protocol.h" +<endComponent> diff --git a/Chipset/SB/Smm2/SmmChildDispatcher2.dxs b/Chipset/SB/Smm2/SmmChildDispatcher2.dxs new file mode 100644 index 0000000..2d6cd56 --- /dev/null +++ b/Chipset/SB/Smm2/SmmChildDispatcher2.dxs @@ -0,0 +1,58 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* + +//************************************************************************* +// $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatcher2.dxs 1 2/08/12 8:28a Yurenlai $ +// +// $Revision: 1 $ +// +// $Date: 2/08/12 8:28a $ +//************************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatcher2.dxs $ +// +// 1 2/08/12 8:28a Yurenlai +// Intel Lynx Point/SB eChipset initially releases. +// +//************************************************************************* +//<AMI_FHDR_START> +// +// Name: SmmChildDispatcher2.DXS +// +// Description: This file contains the dependency expression for the SMM +// Child Dispatcher II driver +// +//<AMI_FHDR_END> +//************************************************************************* + +#include <Protocol\SmmBase2.h> + +DEPENDENCY_START + EFI_SMM_BASE2_PROTOCOL_GUID +DEPENDENCY_END + +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* diff --git a/Chipset/SB/Smm2/SmmChildDispatcher2.mak b/Chipset/SB/Smm2/SmmChildDispatcher2.mak new file mode 100644 index 0000000..18e5cd7 --- /dev/null +++ b/Chipset/SB/Smm2/SmmChildDispatcher2.mak @@ -0,0 +1,85 @@ +# MAK file for the ModulePart:SmmChildDispatcher II +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* + +#************************************************************************* +# $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatcher2.mak 2 4/25/12 9:32a Victortu $ +# +# $Revision: 2 $ +# +# $Date: 4/25/12 9:32a $ +#************************************************************************* +# Revision History +# ---------------- +# $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatcher2.mak $ +# +# 2 4/25/12 9:32a Victortu +# [TAG] None +# [Category] Improvement +# [Description] Reprogram SMM ChildDispatcher drivers. +# [Files] SmiHandlerGeneric.c; SmiHandlerPorting.c; +# SmiHandlerGeneric2.c; SmmChildDispatch2Main.c; SmmChildDispatcher2.mak; +# SmmChildDispatcher2.sdl; SmmChildDispatch.h; SmmChildDispatchMain.c; +# SmmChildDispatchProtocol.c; SmmChildDispatcher.dxs; +# PchSmiDispatcher.sdl +# +# 1 2/08/12 8:28a Yurenlai +# Intel Lynx Point/SB eChipset initially releases. +# +#************************************************************************* +#<AMI_FHDR_START> +# +# Name: SmmChildDispatcher2.mak +# +# Description: Make file for the SMM Child Dispatcher II driver. +# +#<AMI_FHDR_END> +#************************************************************************* +!IFNDEF BACKWARD_COMPATIBLE_MODE +BACKWARD_COMPATIBLE_MODE = 1 +!ENDIF + +all : SmmChildDispatcher2 + +SmmChildDispatcher2 : $(BUILD_DIR)\SmmChildDispatcher2.mak SmmChildDispatcher2Bin + +$(BUILD_DIR)\SmmChildDispatcher2.mak : $(SMM_CHILD_DISP2_DIR)\SmmChildDispatcher2.cif $(SMM_CHILD_DISP2_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(SMM_CHILD_DISP2_DIR)\SmmChildDispatcher2.cif $(CIF2MAK_DEFAULTS) + +SmmChildDispatcher2Bin : $(AMICSPLib) $(AMIDXELIB) + $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\ + /f $(BUILD_DIR)\SmmChildDispatcher2.mak all\ + "CFLAGS=$(CFLAGS) /I$(SB_BOARD_DIR)"\ + GUID=E53734A3-E594-4c25-B1A2-081445650F7F\ + ENTRY_POINT=SmmChildDispatch2EntryPoint\ + TYPE=DXESMM_DRIVER \ + DEPEX1=$(SMM_CHILD_DISP2_DIR)\SmmChildDispatcher2.dxs \ + DEPEX1_TYPE=EFI_SECTION_SMM_DEPEX \ + DEPEX2=$(SMM_CHILD_DISP2_DIR)\SmmChildDispatcher2.dxs \ + DEPEX2_TYPE=EFI_SECTION_DXE_DEPEX \ + COMPRESS=1 + +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* diff --git a/Chipset/SB/Smm2/SmmChildDispatcher2.sdl b/Chipset/SB/Smm2/SmmChildDispatcher2.sdl new file mode 100644 index 0000000..5540394 --- /dev/null +++ b/Chipset/SB/Smm2/SmmChildDispatcher2.sdl @@ -0,0 +1,135 @@ +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* + +#************************************************************************* +# $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatcher2.sdl 4 1/03/13 7:00a Scottyang $ +# +# $Revision: 4 $ +# +# $Date: 1/03/13 7:00a $ +#************************************************************************* +# Revision History +# ---------------- +# $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher2/SmmChildDispatcher2.sdl $ +# +# 4 1/03/13 7:00a Scottyang +# [TAG] None +# [Category] Bug Fix +# [Severity] Important +# [Symptom] GPISMI cannot use. +# [RootCause] GPISMI2 will clear status before GPISMI. +# [Solution] GPISMI2 do not clear status when GPISMI has register. +# [Files] SmmChildDispatcher2.sdl +# SmiHandlerGeneric2.c +# +# 3 10/19/12 2:52a Scottyang +# [TAG] EIP93461 +# [Category] Bug Fix +# [Severity] Normal +# [Symptom] System halt when AFUDOS is running with /N /ME command. +# [RootCause] An unexpected BIOSWR_STS is set, it causes BIOS stuck +# at SMM dispatcher. +# [Solution] Clear BIOSWR_STS if BIOS Lock Enable is not set. +# [Files] SmiHandlerPorting2.c; SmmChildDispatch2Main.c +# SmmChildDispatcher2.sdl; SmmChildDispatch2.h +# SB\SBGeneric.c +# +# 2 4/25/12 9:32a Victortu +# [TAG] None +# [Category] Improvement +# [Description] Reprogram SMM ChildDispatcher drivers. +# [Files] SmiHandlerGeneric.c; SmiHandlerPorting.c; +# SmiHandlerGeneric2.c; SmmChildDispatch2Main.c; SmmChildDispatcher2.mak; +# SmmChildDispatcher2.sdl; SmmChildDispatch.h; SmmChildDispatchMain.c; +# SmmChildDispatchProtocol.c; SmmChildDispatcher.dxs; +# PchSmiDispatcher.sdl +# +# 1 2/08/12 8:28a Yurenlai +# Intel Lynx Point/SB eChipset initially releases. +# +#************************************************************************* +TOKEN + Name = "SmmChildDispatcher2_SUPPORT" + Value = "1" + Help = "Main switch to enable SmmChildDispatcher II support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes + Token = "PI_SPECIFICATION_VERSION" ">" "0x10000" +End + +TOKEN + Name = "PI_0_9_CHILD_DISPATCHER_SUPPORT" + Value = "1" + Help = "Enable SmmChildDispatcher I support" + TokenType = Boolean + TargetH = Yes +End + + # [EIP93461]> +TOKEN + Name = "BIOS_WRITE_SMI_PATCH_ENABLE" + Value = "1" + Help = "Clear unexpected BIOSWR_STS." + TokenType = Boolean + TargetH = Yes +End + # <[EIP93461] + +TOKEN + Name = "GPI_DISPATCH2_BY_BITMAP" + Value = "0" + Help = "ON = The registered parameter of SMM GPI dispatcher II is using bitmapped.\OFF = The registered parameter of SMM GPI disatcher is using index based" + TokenType = Boolean + TargetH = Yes + Lock = Yes +End + +TOKEN + Name = "SUPPORTED_GPIS2" + Value = "0xFFFF" + Help = "This is a supported GPI SMI mask, 1 = supported, 16 bits maximum" + TokenType = Integer + TargetH = Yes +End + +PATH + Name = "SMM_CHILD_DISP2_DIR" +End + +MODULE + Help = "Includes SmmChildDispatcher2.mak to Project" + File = "SmmChildDispatcher2.mak" +End + +ELINK + Name = "$(BUILD_DIR)\SmmChildDispatcher2.ffs" + Parent = "FV_MAIN" + InvokeOrder = AfterParent +End + +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#*************************************************************************
\ No newline at end of file |