From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: zailiang.sun@intel.com) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by groups.io with SMTP; Sun, 30 Jun 2019 21:08:36 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jun 2019 21:08:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,437,1557212400"; d="scan'208";a="165692933" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 30 Jun 2019 21:08:35 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 30 Jun 2019 21:08:35 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 30 Jun 2019 21:08:34 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.110]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.109]) with mapi id 14.03.0439.000; Mon, 1 Jul 2019 12:08:32 +0800 From: "Sun, Zailiang" To: "devel@edk2.groups.io" , "Kinney, Michael D" CC: "Qian, Yi" Subject: Re: [edk2-devel] [edk2-platforms Patch 12/14] Vlv2TbltDevicePkg/PlatformSmm: Switch to PI SMM Protocols Thread-Topic: [edk2-devel] [edk2-platforms Patch 12/14] Vlv2TbltDevicePkg/PlatformSmm: Switch to PI SMM Protocols Thread-Index: AQHVL7ibsOk0ajUh4kKn2apyBt8R7aa1JdNQ Date: Mon, 1 Jul 2019 04:08:31 +0000 Message-ID: <7CB7EF03E15B5D48981329A508747A9850C905A8@SHSMSX104.ccr.corp.intel.com> References: <20190701025553.18596-1-michael.d.kinney@intel.com> <20190701025553.18596-13-michael.d.kinney@intel.com> In-Reply-To: <20190701025553.18596-13-michael.d.kinney@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: zailiang.sun@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-By: Zailiang Sun -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Mich= ael D Kinney Sent: Monday, July 01, 2019 10:56 AM To: devel@edk2.groups.io Cc: Sun, Zailiang ; Qian, Yi Subject: [edk2-devel] [edk2-platforms Patch 12/14] Vlv2TbltDevicePkg/Platf= ormSmm: Switch to PI SMM Protocols Change use of Intel Framework SMM Protocols to PI SMM Protocols. This remo= ves Intel Framework dependencies. The PI SMM Protocols added are: * gEfiSmmPowerButtonDispatch2ProtocolGuid * gEfiSmmSxDispatch2ProtocolGuid * gEfiSmmSwDispatch2ProtocolGuid Cc: Zailiang Sun Cc: Yi Qian Signed-off-by: Michael D Kinney --- .../Vlv2TbltDevicePkg/PlatformSmm/Platform.c | 112 +++++++++++------- .../PlatformSmm/PlatformSmm.inf | 16 +-- .../PlatformSmm/SmmPlatform.h | 104 +++++++--------- 3 files changed, 114 insertions(+), 118 deletions(-) diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformSmm/Platform.c b/Pla= tform/Intel/Vlv2TbltDevicePkg/PlatformSmm/Platform.c index fb9d090ada..c78174ed08 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformSmm/Platform.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformSmm/Platform.c @@ -101,14 +101,14 @@ InitializePlatformSmm ( EFI_STATUS Status; UINT8 Index; EFI_HANDLE Handle; - EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT PowerButtonContext; - EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL *PowerButtonDispatch; + EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT PowerButtonContext; + EFI_SMM_POWER_BUTTON_DISPATCH2_PROTOCOL *PowerButtonDispatch; EFI_SMM_ICHN_DISPATCH_CONTEXT IchnContext; EFI_SMM_ICHN_DISPATCH_PROTOCOL *IchnDispatch; - EFI_SMM_SX_DISPATCH_PROTOCOL *SxDispatch; - EFI_SMM_SX_DISPATCH_CONTEXT EntryDispatchContext; - EFI_SMM_SW_DISPATCH_PROTOCOL *SwDispatch; - EFI_SMM_SW_DISPATCH_CONTEXT SwContext; + EFI_SMM_SX_DISPATCH2_PROTOCOL *SxDispatch; + EFI_SMM_SX_REGISTER_CONTEXT EntryDispatchContext; + EFI_SMM_SW_DISPATCH2_PROTOCOL *SwDispatch; + EFI_SMM_SW_REGISTER_CONTEXT SwContext; UINTN VarSize; EFI_BOOT_MODE BootMode; =20 @@ -171,18 +171,18 @@ InitializePlatformSmm ( // // Get the Power Button protocol // - Status =3D gBS->LocateProtocol( - &gEfiSmmPowerButtonDispatchProtocolGuid, - NULL, - (void **)&PowerButtonDispatch - ); + Status =3D gSmst->SmmLocateProtocol( + &gEfiSmmPowerButtonDispatch2ProtocolGuid, + NULL, + (VOID **)&PowerButtonDispatch + ); ASSERT_EFI_ERROR(Status); =20 if (BootMode !=3D BOOT_ON_FLASH_UPDATE) { // // Register for the power button event // - PowerButtonContext.Phase =3D PowerButtonEntry; + PowerButtonContext.Phase =3D EfiPowerButtonEntry; Status =3D PowerButtonDispatch->Register( PowerButtonDispatch, PowerButtonCallback, @@ -194,11 +194,= 11 @@ InitializePlatformSmm ( // // Get the Sx dispatch protocol // - Status =3D gBS->LocateProtocol ( - &gEfiSmmSxDispatchProtocolGuid, - NULL, - (void **)&SxDispatch - ); + Status =3D gSmst->SmmLocateProtocol( + &gEfiSmmSxDispatch2ProtocolGuid, + NULL, + (VOID **)&SxDispatch + ); ASSERT_EFI_ERROR(Status); =20 // @@ -209,7 +209,7 @@ InitializePlatformSmm ( =20 Status =3D SxDispatch->Register ( SxDispatch, - (EFI_SMM_SX_DISPATCH)SxSleepEntryCallBack, + SxSleepEntryCallBack, &EntryDispatchContext, &Handle ); @@ -247,11 +247,11 @@ InitializePlatformSmm ( // // Get the Sw dispatch protocol // - Status =3D gBS->LocateProtocol ( - &gEfiSmmSwDispatchProtocolGuid, - NULL, - (void **)&SwDispatch - ); + Status =3D gSmst->SmmLocateProtocol ( + &gEfiSmmSwDispatch2ProtocolGuid, + NULL, + (VOID **)&SwDispatch + ); ASSERT_EFI_ERROR(Status); =20 // @@ -341,11 +341,13 @@ InitializePlatformSmm ( return EFI_SUCCESS; } =20 -VOID +EFI_STATUS EFIAPI SmmReadyToBootCallback ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ) { EFI_STATUS Status; @@ -371,6 +373,7 @@ SmmReadyToBootCallback ( mSetSmmVariableProtocolSmiAllowed =3D FALSE; } =20 + return EFI_SUCCESS; } =20 /** @@ -385,8 +388,10 @@ SmmReadyToBootCallback ( EFI_STATUS EFIAPI SxSleepEntryCallBack ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SX_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ) { EFI_STATUS Status; @@ -479,11 +484,13 @@ SetAfterG3On ( When a power button event happens, it shuts off the machine =20 **/ -VOID +EFI_STATUS EFIAPI PowerButtonCallback ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ) { // @@ -538,6 +545,8 @@ PowerButtonCallback ( // Should not return // CpuDeadLoop(); + + return EFI_SUCCESS; } =20 =20 @@ -547,11 +556,13 @@ PowerButtonCallback ( @param DispatchContext - The predefined context which contained sleep t= ype and phase =20 **/ -VOID +EFI_STATUS EFIAPI S5SleepAcLossCallBack ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SX_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ) { // @@ -561,6 +572,7 @@ S5SleepAcLossCallBack ( if (mAcLossVariable =3D=3D 1) { SetAfterG3On (TRUE); } + return EFI_SUCCESS; } =20 /** @@ -571,11 +583,13 @@ S5SleepAcLossCallBack ( @retval Clears the Save State bit in the clock. =20 **/ -VOID +EFI_STATUS EFIAPI S4S5CallBack ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SX_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ) { =20 @@ -590,6 +604,7 @@ S4S5CallBack ( IoWrite32(GPIO_BASE_ADDRESS + R_PCH_GPIO_SC_LVL, Data32); } =20 + return EFI_SUCCESS; } =20 =20 @@ -624,16 +639,18 @@ S4S5ProgClock() Enable SCI =20 @param DispatchHandle - EFI Handle - @param DispatchContext - Pointer to the EFI_SMM_SW_DISPATCH_CONTEXT + @param DispatchContext - Pointer to the EFI_SMM_SW_REGISTER_CONTEXT =20 @retval Nothing =20 **/ -VOID +EFI_STATUS EFIAPI EnableAcpiCallback ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ) { UINT32 SmiEn; @@ -690,7 +707,7 @@ EnableAcpiCallback ( Pm1Cnt |=3D B_PCH_ACPI_PM1_CNT_SCI_EN; IoWrite16(mAcpiBaseAddr + R_PCH_ACPI_PM1_CNT, Pm1Cnt); =20 - + return EFI_SUCCESS; } =20 /** @@ -710,16 +727,18 @@ EnableAcpiCallback ( Disable SCI =20 @param DispatchHandle - EFI Handle - @param DispatchContext - Pointer to the EFI_SMM_SW_DISPATCH_CONTEXT + @param DispatchContext - Pointer to the EFI_SMM_SW_REGISTER_CONTEXT =20 @retval Nothing =20 **/ -VOID +EFI_STATUS EFIAPI DisableAcpiCallback ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ) { UINT16 Pm1Cnt; @@ -737,6 +756,7 @@ DisableAcpiCallback ( Pm1Cnt &=3D ~B_PCH_ACPI_PM1_CNT_SCI_EN; IoWrite16(mAcpiBaseAddr + R_PCH_ACPI_PM1_CNT, Pm1Cnt); =20 + return EFI_SUCCESS; } =20 /** diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformSmm/PlatformSmm.inf = b/Platform/Intel/Vlv2TbltDevicePkg/PlatformSmm/PlatformSmm.inf index 73c3b6f2d0..9aff4a4895 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformSmm/PlatformSmm.inf +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformSmm/PlatformSmm.inf @@ -36,6 +36,7 @@ [Sources] [LibraryClasses] UefiDriverEntryPoint UefiBootServicesTableLib + SmmServicesTableLib DebugLib IoLib BaseLib @@ -52,15 +53,14 @@ [Guids] [Protocols] gEfiSmmIchnDispatchProtocolGuid gEfiGlobalNvsAreaProtocolGuid - gEfiSmmSwDispatchProtocolGuid - gEfiSmmPowerButtonDispatchProtocolGuid - gEfiSmmSxDispatchProtocolGuid + gEfiSmmSwDispatch2ProtocolGuid + gEfiSmmPowerButtonDispatch2ProtocolGuid + gEfiSmmSxDispatch2ProtocolGuid gEfiSmmVariableProtocolGuid =20 [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec - IntelFrameworkPkg/IntelFrameworkPkg.dec Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec Vlv2TbltDevicePkg/PlatformPkg.dec =20 @@ -68,11 +68,11 @@ [Pcd.common] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress =20 [Depex] - gEfiSmmAccess2ProtocolGuid AND - gEfiSmmPowerButtonDispatchProtocolGuid AND - gEfiSmmSxDispatchProtocolGuid AND + gEfiSmmAccess2ProtocolGuid AND + gEfiSmmPowerButtonDispatch2ProtocolGuid AND + gEfiSmmSxDispatch2ProtocolGuid AND gEfiSmmIchnDispatchProtocolGuid AND - gEfiSmmSwDispatchProtocolGuid AND + gEfiSmmSwDispatch2ProtocolGuid AND gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid AND gEfiGlobalNvsAreaProtocolGuid diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformSmm/SmmPlatform.h b/= Platform/Intel/Vlv2TbltDevicePkg/PlatformSmm/SmmPlatform.h index bcb1d8ae92..735a562e3e 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformSmm/SmmPlatform.h +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformSmm/SmmPlatform.h @@ -21,18 +21,16 @@ Abstract: =20 =20 =20 -#include -#include -#include -#include -#include +#include +#include +#include #include #include -#include +#include #include #include #include -#include "Protocol/GlobalNvsArea.h" +#include #include #include #include @@ -42,6 +40,7 @@ Abstract: #include "PlatformBaseAddresses.h" =20 #include +#include #include #include #include @@ -130,53 +129,59 @@ extern EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *mPciRootBrid= geIo; // // Callback function prototypes // -VOID +EFI_STATUS EFIAPI PowerButtonCallback ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ); =20 -VOID -S5SleepWakeOnLanCallBack ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SX_DISPATCH_CONTEXT *DispatchContext - ); - -VOID +EFI_STATUS EFIAPI S5SleepAcLossCallBack ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SX_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ); =20 =20 -VOID +EFI_STATUS EFIAPI S4S5CallBack ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SX_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ); =20 -VOID +EFI_STATUS EFIAPI EnableAcpiCallback ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ); =20 -VOID +EFI_STATUS EFIAPI DisableAcpiCallback ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ); =20 -VOID +EFI_STATUS EFIAPI SmmReadyToBootCallback ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ); =20 VOID @@ -185,46 +190,18 @@ DummyTco1Callback ( IN EFI_SMM_ICHN_DISPATCH_CONTEXT *DispatchContext ); =20 - -VOID -PerrSerrCallback ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_ICHN_DISPATCH_CONTEXT *DispatchContext - ); - -VOID -RiCallback ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_ICHN_DISPATCH_CONTEXT *DispatchContext - ); - - VOID SetAfterG3On ( BOOLEAN Enable ); =20 -VOID -TurnOffVregUsb ( - ); - -VOID -PStateSupportCallback ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext - ); - -VOID -PStateTransitionCallback ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SW_DISPATCH_CONTEXT *DispatchContext - ); - EFI_STATUS EFIAPI SxSleepEntryCallBack ( - IN EFI_HANDLE DispatchHandle, - IN EFI_SMM_SX_DISPATCH_CONTEXT *DispatchContext + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context OPTIONAL, + IN OUT VOID *CommBuffer OPTIONAL, + IN OUT UINTN *CommBufferSize OPTIONAL ); =20 EFI_STATUS @@ -232,6 +209,5 @@ SaveRuntimeScriptTable ( VOID ); =20 - #endif =20 -- 2.21.0.windows.1