From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: michael.d.kinney@intel.com) Received: from mga18.intel.com (mga18.intel.com []) by groups.io with SMTP; Sun, 30 Jun 2019 19:56:09 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jun 2019 19:56:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,437,1557212400"; d="scan'208";a="338480250" Received: from mdkinney-mobl2.amr.corp.intel.com ([10.251.143.61]) by orsmga005.jf.intel.com with ESMTP; 30 Jun 2019 19:56:08 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Zailiang Sun , Yi Qian Subject: [edk2-platforms Patch 12/14] Vlv2TbltDevicePkg/PlatformSmm: Switch to PI SMM Protocols Date: Sun, 30 Jun 2019 19:55:51 -0700 Message-Id: <20190701025553.18596-13-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190701025553.18596-1-michael.d.kinney@intel.com> References: <20190701025553.18596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Change use of Intel Framework SMM Protocols to PI SMM Protocols. This removes 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/Platform/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; @@ -171,18 +171,18 @@ InitializePlatformSmm ( // // Get the Power Button protocol // - Status = gBS->LocateProtocol( - &gEfiSmmPowerButtonDispatchProtocolGuid, - NULL, - (void **)&PowerButtonDispatch - ); + Status = gSmst->SmmLocateProtocol( + &gEfiSmmPowerButtonDispatch2ProtocolGuid, + NULL, + (VOID **)&PowerButtonDispatch + ); ASSERT_EFI_ERROR(Status); if (BootMode != BOOT_ON_FLASH_UPDATE) { // // Register for the power button event // - PowerButtonContext.Phase = PowerButtonEntry; + PowerButtonContext.Phase = EfiPowerButtonEntry; Status = PowerButtonDispatch->Register( PowerButtonDispatch, PowerButtonCallback, @@ -194,11 +194,11 @@ InitializePlatformSmm ( // // Get the Sx dispatch protocol // - Status = gBS->LocateProtocol ( - &gEfiSmmSxDispatchProtocolGuid, - NULL, - (void **)&SxDispatch - ); + Status = gSmst->SmmLocateProtocol( + &gEfiSmmSxDispatch2ProtocolGuid, + NULL, + (VOID **)&SxDispatch + ); ASSERT_EFI_ERROR(Status); // @@ -209,7 +209,7 @@ InitializePlatformSmm ( Status = SxDispatch->Register ( SxDispatch, - (EFI_SMM_SX_DISPATCH)SxSleepEntryCallBack, + SxSleepEntryCallBack, &EntryDispatchContext, &Handle ); @@ -247,11 +247,11 @@ InitializePlatformSmm ( // // Get the Sw dispatch protocol // - Status = gBS->LocateProtocol ( - &gEfiSmmSwDispatchProtocolGuid, - NULL, - (void **)&SwDispatch - ); + Status = gSmst->SmmLocateProtocol ( + &gEfiSmmSwDispatch2ProtocolGuid, + NULL, + (VOID **)&SwDispatch + ); ASSERT_EFI_ERROR(Status); // @@ -341,11 +341,13 @@ InitializePlatformSmm ( return EFI_SUCCESS; } -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 = FALSE; } + return EFI_SUCCESS; } /** @@ -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 **/ -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; } @@ -547,11 +556,13 @@ PowerButtonCallback ( @param DispatchContext - The predefined context which contained sleep type and phase **/ -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 == 1) { SetAfterG3On (TRUE); } + return EFI_SUCCESS; } /** @@ -571,11 +583,13 @@ S5SleepAcLossCallBack ( @retval Clears the Save State bit in the clock. **/ -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 ) { @@ -590,6 +604,7 @@ S4S5CallBack ( IoWrite32(GPIO_BASE_ADDRESS + R_PCH_GPIO_SC_LVL, Data32); } + return EFI_SUCCESS; } @@ -624,16 +639,18 @@ S4S5ProgClock() Enable SCI @param DispatchHandle - EFI Handle - @param DispatchContext - Pointer to the EFI_SMM_SW_DISPATCH_CONTEXT + @param DispatchContext - Pointer to the EFI_SMM_SW_REGISTER_CONTEXT @retval Nothing **/ -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 |= B_PCH_ACPI_PM1_CNT_SCI_EN; IoWrite16(mAcpiBaseAddr + R_PCH_ACPI_PM1_CNT, Pm1Cnt); - + return EFI_SUCCESS; } /** @@ -710,16 +727,18 @@ EnableAcpiCallback ( Disable SCI @param DispatchHandle - EFI Handle - @param DispatchContext - Pointer to the EFI_SMM_SW_DISPATCH_CONTEXT + @param DispatchContext - Pointer to the EFI_SMM_SW_REGISTER_CONTEXT @retval Nothing **/ -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 &= ~B_PCH_ACPI_PM1_CNT_SCI_EN; IoWrite16(mAcpiBaseAddr + R_PCH_ACPI_PM1_CNT, Pm1Cnt); + return EFI_SUCCESS; } /** 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 [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec - IntelFrameworkPkg/IntelFrameworkPkg.dec Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec Vlv2TbltDevicePkg/PlatformPkg.dec @@ -68,11 +68,11 @@ [Pcd.common] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress [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: -#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" #include +#include #include #include #include @@ -130,53 +129,59 @@ extern EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *mPciRootBridgeIo; // // 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 ); -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 ); -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 ); -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 ); -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 ); -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 ); VOID @@ -185,46 +190,18 @@ DummyTco1Callback ( IN EFI_SMM_ICHN_DISPATCH_CONTEXT *DispatchContext ); - -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 ); -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 ); EFI_STATUS @@ -232,6 +209,5 @@ SaveRuntimeScriptTable ( VOID ); - #endif -- 2.21.0.windows.1