标签:Status SMI 067 ++ EFI JSP 注册 EcRegOrValue 模板
sdl文件
TOKEN
Name = "OemExtendFuncSmm_SUPPORT"
Value = "1"
Help = "Main switch to enable OemExtendFuncSmm support in Project"
TokenType = Boolean
TargetEQU = Yes
TargetMAK = Yes
Master = Yes
Token = "AMI_FSP_BIN_SUPPORT" "=" "0" #JSP_028+
End
INFComponent
Name = "OemExtendFuncSmm"
File = "OemExtendFuncSmm.inf"
Package = "OemIp3Pkg"
ModuleTypes = "DXE_SMM_DRIVER"
End
inf文件
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = OemExtendFuncSmm
FILE_GUID = DDB637EB-1763-4B21-832F-3B5C07EB4165
MODULE_TYPE = DXE_SMM_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = OemExtendFuncSmmEntryPoint
PI_SPECIFICATION_VERSION = 0x0001000A
[Sources]
OemExtendFuncSmm.c
[Packages]
MdePkg/MdePkg.dec
ClientOneSiliconPkg/SiPkg.dec
AmiChipsetPkg/AmiChipsetPkg.dec
AmiCompatibilityPkg/AmiCompatibilityPkg.dec
AmiChipsetModulePkg/AmiChipsetModulePkg.dec
OemIp3Pkg/OemIp3Pkg.dec #JSP_017+
#JSP_067++ >>
ClientOneSiliconPkg/SiPkg.dec
JasperLakePlatSamplePkg/PlatformPkg.dec
#JSP_067++ <<
[LibraryClasses]
AmiDxeLib
SmmServicesTableLib
UefiDriverEntryPoint
OemIp3EcLib #JSP_017+
PmcLib #JSP_067+
[Protocols]
gEfiSmmSwDispatch2ProtocolGuid
gEfiSmmSxDispatch2ProtocolGuid
gEfiSmmPowerButtonDispatch2ProtocolGuid
gEfiSmmVariableProtocolGuid
#JSP_067++ >>
[Guids]
gSetupVariableGuid
gPchSetupVariableGuid
#JSP_067++ <<
[Depex]
gEfiSmmSwDispatch2ProtocolGuid AND
gEfiSmmSxDispatch2ProtocolGuid AND
gEfiSmmPowerButtonDispatch2ProtocolGuid
C文件
#include <Token.h>
#include <Setup.h>
#include <AmiDxeLib.h>
#include <Protocol/SmmBase2.h>
#include <Protocol/SmmSwDispatch2.h>
#include <Protocol/SmmSxDispatch2.h>
#include <Protocol/SmmPowerButtonDispatch2.h>
#include <Protocol/SmmVariable.h>
#include <Library/SmmServicesTableLib.h>
#include <OemIp3EcLib.h> //JSP_017+
//JSP_067++ >>
#include <Protocol/SmmCpuIo2.h>
#include <Register/PmcRegs.h>
#include <Library/PmcLib.h>
#include <SetupVariable.h>
GLOBAL_REMOVE_IF_UNREFERENCED UINT16 mAcpiBaseAddr;
GLOBAL_REMOVE_IF_UNREFERENCED SETUP_DATA mSystemConfiguration;
GLOBAL_REMOVE_IF_UNREFERENCED PCH_SETUP mPchSetup;
/**
Routine to get Setup variable
@param[in] VOID
@retval Status - EFI_SUCCESS
@retval Assert, otherwise.
**/
EFI_STATUS
SmmGetGlobalVariables(
VOID
)
{
EFI_STATUS Status;
UINTN DataSize;
mAcpiBaseAddr = PmcGetAcpiBase ();
DataSize = sizeof (SETUP_DATA);
Status = pRS->GetVariable (
L"Setup",
&gSetupVariableGuid,
NULL,
&DataSize,
&mSystemConfiguration
);
if (EFI_ERROR(Status)) {
return Status;
}
DataSize = sizeof (PCH_SETUP);
Status = pRS->GetVariable (
L"PchSetup",
&gPchSetupVariableGuid,
NULL,
&DataSize,
&mPchSetup
);
return Status;
}
/**
Routine to enable GBE LAN wake support.
@param[in] VOID
@retval VOID
**/
VOID
EnableGbeLanWakesupport(
VOID
)
{
UINT32 Data32;
if ((mSystemConfiguration.OemWol)) {
pSmst->SmmIo.Io.Read(
&pSmst->SmmIo,
SMM_IO_UINT32,
mAcpiBaseAddr + R_ACPI_IO_GPE0_EN_127_96,
1,
&Data32
);
Data32 = Data32 | (UINT32)B_ACPI_IO_GPE0_EN_127_96_LAN_WAKE;
pSmst->SmmIo.Io.Write(
&pSmst->SmmIo,
SMM_IO_UINT32,
mAcpiBaseAddr + R_ACPI_IO_GPE0_EN_127_96,
1,
&Data32
);
}
}
//JSP_067++ <<
/**
This is a template OEM Sw SMI Handler for Porting.
@param DispatchHandle - EFI Handle
DispatchContext - Pointer to the EFI_SMM_SX_DISPATCH_CONTEXT
@retval EFI_STATUS
**/
EFI_STATUS
EFIAPI
OemSwSmiHandler (
IN EFI_HANDLE DispatchHandle,
IN CONST VOID *DispatchContext OPTIONAL,
IN OUT VOID *CommBuffer OPTIONAL,
IN OUT UINTN *CommBufferSize OPTIONAL)
{
return EFI_SUCCESS;
}
/**
This is a template OEM Sx SMI Handler for Porting.
@param DispatchHandle - EFI Handle
DispatchContext - Pointer to the EFI_SMM_SX_DISPATCH_CONTEXT
@retval EFI_STATUS
**/
EFI_STATUS
EFIAPI
OemSxSmiHandler (
IN EFI_HANDLE DispatchHandle,
IN CONST VOID *DispatchContext OPTIONAL,
IN OUT VOID *CommBuffer OPTIONAL,
IN OUT UINTN *CommBufferSize OPTIONAL )
{
return EFI_SUCCESS;
}
//JSP_017++ <<
/**
This function is to backup all Keypart state for EC.
@param VOID
@retval VOID
**/
VOID
OemSmmBackupKeypartState4Ec (
VOID
)
{
EFI_STATUS ReadEcRamStatus;
UINT8 EcRegOrValue;
ReadEcRamStatus = EFI_SUCCESS;
EcRegOrValue = 0x80;
OemSvcEcReadEcRam (&ReadEcRamStatus, &EcRegOrValue);
if (!(EcRegOrValue & BIT0)) { //Adaptor out
//
//Backup Fn lock flag(EC space 0x07) to extend CMOS register 0x20
//
EcRegOrValue = 0x07;
OemSvcEcReadEcRam (&ReadEcRamStatus, &EcRegOrValue);
IoWrite8 (0x72, 0x20);
IoWrite8 (0x73, EcRegOrValue);
//
//Backup keyboard backlight level(EC space 0x08) to extend CMOS register 0x21
//
EcRegOrValue = 0x08;
OemSvcEcReadEcRam (&ReadEcRamStatus, &EcRegOrValue);
IoWrite8 (0x72, 0x21);
IoWrite8 (0x73, EcRegOrValue);
//
//Backup touch pad state(EC space 0x0B) to extend CMOS register 0x22
//
EcRegOrValue = 0x0B;
OemSvcEcReadEcRam (&ReadEcRamStatus, &EcRegOrValue);
IoWrite8 (0x72, 0x22);
IoWrite8 (0x73, EcRegOrValue);
//
//Backup WIFI state(EC space 0x0D) to extend CMOS register 0x23
//
EcRegOrValue = 0x0D;
OemSvcEcReadEcRam (&ReadEcRamStatus, &EcRegOrValue);
IoWrite8 (0x72, 0x23);
IoWrite8 (0x73, EcRegOrValue);
// JSP_069++>>
//Backup Flag
IoWrite8 (0x72, 0xF0);
IoWrite8 (0x73, 0x55);
// JSP_069++>>
}
}
//JSP_067++ >>
/**
This function will be called by EfiSmmSxDispatch when a Sleep
SMI occurs and the sleep state is S3.
@param DispatchHandle - SMI dispatcher handle
@param *DispatchContext- Points to an optional Sx SMI context
@param CommBuffer - Points to the optional communication buffer
@param CommBufferSize - Points to the size of the optional communication buffer
@retval EFI_STATUS
**/
EFI_STATUS
EFIAPI
OemS3SmiHandler (
IN EFI_HANDLE DispatchHandle,
IN CONST VOID *DispatchContext OPTIONAL,
IN OUT VOID *CommBuffer OPTIONAL,
IN OUT UINTN *CommBufferSize OPTIONAL )
{
#if defined(OemExtendFuncSetup_SUPPORT) && (OemExtendFuncSetup_SUPPORT == 1)
EnableGbeLanWakesupport ();
#endif
return EFI_SUCCESS;
}
//JSP_067++ <<
/**
This function will be called by EfiSmmSxDispatch when a Sleep
SMI occurs and the sleep state is S4.
@param DispatchHandle - SMI dispatcher handle
@param *DispatchContext- Points to an optional Sx SMI context
@param CommBuffer - Points to the optional communication buffer
@param CommBufferSize - Points to the size of the optional communication buffer
@retval EFI_STATUS
**/
EFI_STATUS
EFIAPI
OemS4SmiHandler (
IN EFI_HANDLE DispatchHandle,
IN CONST VOID *DispatchContext OPTIONAL,
IN OUT VOID *CommBuffer OPTIONAL,
IN OUT UINTN *CommBufferSize OPTIONAL )
{
OemSmmBackupKeypartState4Ec();
//JSP_067++ >>
#if defined(OemExtendFuncSetup_SUPPORT) && (OemExtendFuncSetup_SUPPORT == 1)
EnableGbeLanWakesupport ();
#endif
//JSP_067++ <<
return EFI_SUCCESS;
}
/**
This function will be called by EfiSmmSxDispatch when a Sleep
SMI occurs and the sleep state is S5.
@param DispatchHandle - SMI dispatcher handle
@param *DispatchContext- Points to an optional Sx SMI context
@param CommBuffer - Points to the optional communication buffer
@param CommBufferSize - Points to the size of the optional communication buffer
@retval EFI_STATUS
**/
EFI_STATUS
EFIAPI
OemS5SmiHandler (
IN EFI_HANDLE DispatchHandle,
IN CONST VOID *DispatchContext OPTIONAL,
IN OUT VOID *CommBuffer OPTIONAL,
IN OUT UINTN *CommBufferSize OPTIONAL )
{
OemSmmBackupKeypartState4Ec();
//JSP_067++ >>
#if defined(OemExtendFuncSetup_SUPPORT) && (OemExtendFuncSetup_SUPPORT == 1)
EnableGbeLanWakesupport ();
#endif
//JSP_067++ <<
return EFI_SUCCESS;
}
//JSP_017++ <<
/**
This is a template OEM Power Button SMI Handler for Porting.
@param DispatchHandle - EFI Handle
DispatchContext - Pointer to the EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT
@retval EFI_STATUS
**/
EFI_STATUS
EFIAPI
OemPowerButtonSmiHandler (
IN EFI_HANDLE DispatchHandle,
IN CONST VOID *Context OPTIONAL,
IN OUT VOID *CommBuffer OPTIONAL,
IN OUT UINTN *CommBufferSize OPTIONAL)
{
OemSmmBackupKeypartState4Ec(); //JSP_017+
//JSP_067++ >>
#if defined(OemExtendFuncSetup_SUPPORT) && (OemExtendFuncSetup_SUPPORT == 1)
EnableGbeLanWakesupport ();
#endif
//JSP_067++ <<
return EFI_SUCCESS;
}
/**
Register Oem SMM Child Dispatcher Handler.
@param ImageHandle - Image handle
*SystemTable - Pointer to EFI_SYSTEM_TABLE
@retval EFI_STATUS.
**/
EFI_STATUS InSmmFunction (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable )
{
EFI_STATUS Status;
EFI_SMM_SW_DISPATCH2_PROTOCOL *pSwDispatch;
EFI_SMM_SX_DISPATCH2_PROTOCOL *pSxDispatch;
EFI_SMM_POWER_BUTTON_DISPATCH2_PROTOCOL *pPwrDispatch;
EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT PwrContext = {EfiPowerButtonEntry};
EFI_SMM_SW_REGISTER_CONTEXT SwContext = {CRB_SWSMI};
EFI_SMM_SX_REGISTER_CONTEXT SxContext = {SxS3, SxEntry};
EFI_HANDLE Handle;
Status = InitAmiSmmLib (ImageHandle, SystemTable);
if (EFI_ERROR(Status))
return Status;
//JSP_067++ >>
Status = SmmGetGlobalVariables ();
if (EFI_ERROR(Status))
return Status;
//JSP_067++ <<
Status = pSmst->SmmLocateProtocol (&gEfiSmmSwDispatch2ProtocolGuid, NULL, (VOID **)&pSwDispatch);
if (!EFI_ERROR(Status)) {
Status = pSwDispatch->Register (pSwDispatch, \
OemSwSmiHandler, \
&SwContext, \
&Handle);
}
Status = pSmst->SmmLocateProtocol (&gEfiSmmSxDispatch2ProtocolGuid, NULL, (VOID **)&pSxDispatch);
if (!EFI_ERROR(Status)) {
//JSP_067++ >>
//
// Register S3 entry phase call back function
//
SxContext.Type = SxS3;
SxContext.Phase = SxEntry;
Status = pSxDispatch->Register (pSxDispatch, \
OemS3SmiHandler, \
&SxContext, \
&Handle);
ASSERT_EFI_ERROR(Status);
//JSP_067++ <<
//JSP_017++ <<
//
// Register S4 entry phase call back function
//
SxContext.Type = SxS4;
SxContext.Phase = SxEntry;
Status = pSxDispatch->Register (pSxDispatch, \
OemS4SmiHandler, \
&SxContext, \
&Handle);
ASSERT_EFI_ERROR(Status);
//
// Register S5 entry phase call back function
//
SxContext.Type = SxS5;
SxContext.Phase = SxEntry;
Status = pSxDispatch->Register (pSxDispatch, \
OemS5SmiHandler, \
&SxContext, \
&Handle);
ASSERT_EFI_ERROR(Status);
//JSP_017++ >>
}
Status = pSmst->SmmLocateProtocol (
&gEfiSmmPowerButtonDispatch2ProtocolGuid,
NULL,
(VOID **)&pPwrDispatch);
if (!EFI_ERROR(Status)) {
Status = pPwrDispatch->Register(pPwrDispatch, \
OemPowerButtonSmiHandler, \
&PwrContext, \
&Handle);
ASSERT_EFI_ERROR(Status);
}
return EFI_SUCCESS;
}
/**
This function is the entry point for this SMM driver.
@param ImageHandle - Image handle
SystemTable - Pointer to EFI_SYSTEM_TABLE
@retval EFI_STATUS.
**/
EFI_STATUS EFIAPI OemExtendFuncSmmEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable )
{
InitAmiLib(ImageHandle, SystemTable);
return InitSmmHandler(ImageHandle, SystemTable, InSmmFunction, NULL);
}
标签:Status,SMI,067,++,EFI,JSP,注册,EcRegOrValue,模板 来源: https://blog.csdn.net/qq_40569221/article/details/121937301
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。