* [Patch v2 0/3] Add SmmEndOfS3Resume event. @ 2017-10-11 5:31 Eric Dong 2017-10-11 5:31 ` [Patch v2 1/3] MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition Eric Dong ` (3 more replies) 0 siblings, 4 replies; 9+ messages in thread From: Eric Dong @ 2017-10-11 5:31 UTC (permalink / raw) To: edk2-devel; +Cc: Ruiyu Ni, Jiewen Yao This patch series add new SmmEndOfS3Resume event which required by some SMM drivers. It will implmented by SmmCore to install the gEdkiiSmmEndOfS3ResumeProtocolGuid Protocol. Smm drivers can install this protocol's notification functions to hoot this envet. It will be trigged right after the EndOfPei event in S3 resume phase. V2 Changes: Only change patch 2/3 1. Change structures name to avoid they start with EFI_. 2. Base on DXE phase bits to provide communication buffer, current implement check both PEI and DXE phase. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong <eric.dong@intel.com> Eric Dong (3): MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition. UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished. MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 55 ++++++++++++-- MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 24 ++++++ MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 1 + MdeModulePkg/Include/Protocol/SmmEndOfS3Resume.h | 31 ++++++++ MdeModulePkg/MdeModulePkg.dec | 3 + UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 85 ++++++++++++++++++++++ .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 4 + 7 files changed, 196 insertions(+), 7 deletions(-) create mode 100644 MdeModulePkg/Include/Protocol/SmmEndOfS3Resume.h -- 2.7.0.windows.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Patch v2 1/3] MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition. 2017-10-11 5:31 [Patch v2 0/3] Add SmmEndOfS3Resume event Eric Dong @ 2017-10-11 5:31 ` Eric Dong 2017-10-11 5:31 ` [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore Eric Dong ` (2 subsequent siblings) 3 siblings, 0 replies; 9+ messages in thread From: Eric Dong @ 2017-10-11 5:31 UTC (permalink / raw) To: edk2-devel; +Cc: Ruiyu Ni, Jiewen Yao Add gEdkiiSmmEndOfS3ResumeProtocolGuid which used by SmmCore to notify smm drives that S3 resume has finished. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong <eric.dong@intel.com> --- MdeModulePkg/Include/Protocol/SmmEndOfS3Resume.h | 26 ++++++++++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 3 +++ 2 files changed, 29 insertions(+) create mode 100644 MdeModulePkg/Include/Protocol/SmmEndOfS3Resume.h diff --git a/MdeModulePkg/Include/Protocol/SmmEndOfS3Resume.h b/MdeModulePkg/Include/Protocol/SmmEndOfS3Resume.h new file mode 100644 index 0000000..9716f6a --- /dev/null +++ b/MdeModulePkg/Include/Protocol/SmmEndOfS3Resume.h @@ -0,0 +1,26 @@ +/** @file + This Protocol will be installed at the end of S3 resume phase in SMM environment. + It allows for smm drivers to hook this point and do the requried tasks. + + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __SMM_END_OF_S3_RESUME_H__ +#define __SMM_END_OF_S3_RESUME_H__ + +#define EDKII_SMM_END_OF_S3_RESUME_PROTOCOL_GUID \ + { \ + 0x96f5296d, 0x05f7, 0x4f3c, {0x84, 0x67, 0xe4, 0x56, 0x89, 0x0e, 0x0c, 0xb5 } \ + } + +extern EFI_GUID gEdkiiSmmEndOfS3ResumeProtocolGuid; + +#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index a3c0633..216e4f9 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -556,6 +556,9 @@ ## Include/Protocol/IoMmu.h gEdkiiIoMmuProtocolGuid = { 0x4e939de9, 0xd948, 0x4b0f, { 0x88, 0xed, 0xe6, 0xe1, 0xce, 0x51, 0x7c, 0x1e } } + ## Include/Protocol/SmmEndofS3Resume.h + gEdkiiSmmEndOfS3ResumeProtocolGuid = { 0x96f5296d, 0x05f7, 0x4f3c, {0x84, 0x67, 0xe4, 0x56, 0x89, 0x0e, 0x0c, 0xb5 } } + # # [Error.gEfiMdeModulePkgTokenSpaceGuid] # 0x80000001 | Invalid value provided. -- 2.7.0.windows.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. 2017-10-11 5:31 [Patch v2 0/3] Add SmmEndOfS3Resume event Eric Dong 2017-10-11 5:31 ` [Patch v2 1/3] MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition Eric Dong @ 2017-10-11 5:31 ` Eric Dong 2017-10-11 6:25 ` Yao, Jiewen 2017-10-11 5:31 ` [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished Eric Dong 2017-10-11 7:09 ` [Patch v2 0/3] Add SmmEndOfS3Resume event Ni, Ruiyu 3 siblings, 1 reply; 9+ messages in thread From: Eric Dong @ 2017-10-11 5:31 UTC (permalink / raw) To: edk2-devel; +Cc: Ruiyu Ni, Jiewen Yao Driver will send S3 resume finished event to SmmCore through communicate buffer after it signals EndOfPei event. V2 Changes: 1. Change structures name to avoid they start with EFI_. 2. Base on DXE phase bits to provide communication buffer, current implement check both PEI and DXE phase. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong <eric.dong@intel.com> --- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 87 ++++++++++++++++++++++ .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 4 + 2 files changed, 91 insertions(+) diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c index e53ed21..56f7b37 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -28,6 +28,9 @@ #include <Ppi/SmmAccess.h> #include <Ppi/PostBootScriptTable.h> #include <Ppi/EndOfPeiPhase.h> +#include <Ppi/SmmCommunication.h> + +#include <Protocol/SmmEndOfS3Resume.h> #include <Library/DebugLib.h> #include <Library/BaseLib.h> @@ -151,6 +154,22 @@ typedef union { UINT64 Uint64; } PAGE_TABLE_1G_ENTRY; +// +// Define two type of smm communicate headers. +// One for 32 bits PEI + 64 bits DXE, the other for 32 bits PEI + 32 bits DXE case. +// +typedef struct { + EFI_GUID HeaderGuid; + UINT32 MessageLength; + UINT8 Data[1]; +} IA32_EFI_SMM_COMMUNICATE_HEADER; + +typedef struct { + EFI_GUID HeaderGuid; + UINT64 MessageLength; + UINT8 Data[1]; +} IA64_EFI_SMM_COMMUNICATE_HEADER; + #pragma pack() // @@ -430,6 +449,68 @@ IsLongModeWakingVector ( } /** + Send EndOfS3Resume event to SmmCore through communication buffer way. + + @retval EFI_SUCCESS Return send the event success. +**/ +EFI_STATUS +SignalEndOfS3Resume ( + VOID + ) +{ + EFI_STATUS Status; + EFI_PEI_SMM_COMMUNICATION_PPI *SmmCommunicationPpi; + UINTN CommSize; + IA32_EFI_SMM_COMMUNICATE_HEADER Header32; + IA64_EFI_SMM_COMMUNICATE_HEADER Header64; + VOID *CommBuffer; + + DEBUG ((EFI_D_INFO, "SignalEndOfS3Resume - Enter\n")); + + // + // This buffer consumed in DXE phase, so base on DXE mode to prepare communicate buffer. + // Detect whether DXE is 64 bits mode. + // if (sizeof(UINTN) == sizeof(UINT64), PEI already 64 bits, assume DXE also 64 bits. + // or (FeaturePcdGet (PcdDxeIplSwitchToLongMode)), Dxe will switch to 64 bits. + // + if ((sizeof(UINTN) == sizeof(UINT64)) || (FeaturePcdGet (PcdDxeIplSwitchToLongMode))) { + CommBuffer = &Header64; + Header64.MessageLength = 0; + CommSize = sizeof (IA64_EFI_SMM_COMMUNICATE_HEADER); + } else { + CommBuffer = &Header32; + Header32.MessageLength = 0; + CommSize = sizeof (IA32_EFI_SMM_COMMUNICATE_HEADER); + } + CopyGuid (CommBuffer, &gEdkiiSmmEndOfS3ResumeProtocolGuid); + + // + // Get needed resource + // + Status = PeiServicesLocatePpi ( + &gEfiPeiSmmCommunicationPpiGuid, + 0, + NULL, + (VOID **)&SmmCommunicationPpi + ); + ASSERT_EFI_ERROR (Status); + + // + // Send command + // + Status = SmmCommunicationPpi->Communicate ( + SmmCommunicationPpi, + (VOID *)CommBuffer, + &CommSize + ); + ASSERT_EFI_ERROR (Status); + + DEBUG ((EFI_D_INFO, "SignalEndOfS3Resume - Exit (%r)\n", Status)); + + return Status; +} + +/** Jump to OS waking vector. The function will install boot script done PPI, report S3 resume status code, and then jump to OS waking vector. @@ -504,6 +585,12 @@ S3ResumeBootOs ( ASSERT_EFI_ERROR (Status); // + // Signal EndOfS3Resume event. + // + Status = SignalEndOfS3Resume (); + ASSERT_EFI_ERROR (Status); + + // // report status code on S3 resume // REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_OS_WAKE); diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf index d514523..943f114 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf @@ -85,6 +85,10 @@ gPeiSmmAccessPpiGuid ## SOMETIMES_CONSUMES gPeiPostScriptTablePpiGuid ## SOMETIMES_PRODUCES gEfiEndOfPeiSignalPpiGuid ## SOMETIMES_PRODUCES + gEfiPeiSmmCommunicationPpiGuid ## SOMETIMES_CONSUMES + +[Protocols] + gEdkiiSmmEndOfS3ResumeProtocolGuid ## SOMETIMES_CONSUMES [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES -- 2.7.0.windows.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. 2017-10-11 5:31 ` [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore Eric Dong @ 2017-10-11 6:25 ` Yao, Jiewen 2017-10-11 6:28 ` Dong, Eric 0 siblings, 1 reply; 9+ messages in thread From: Yao, Jiewen @ 2017-10-11 6:25 UTC (permalink / raw) To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu Hi Eric I do not think IA64 is a good term. Traditionally, IA64 means the IPF platform, which is deprecated. We use X64 to indicate it is Intel 64bit platform. If it is just a general 64bit indicator, I suggest we use SMM_COMMUNICATE_HEADER_64 and SMM_COMMUNICATE_HEADER_32. Thank you Yao Jiewen > -----Original Message----- > From: Dong, Eric > Sent: Wednesday, October 11, 2017 1:32 PM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> > Subject: [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished > event to SmmCore. > > Driver will send S3 resume finished event to SmmCore through communicate > buffer after it signals EndOfPei event. > > V2 Changes: > 1. Change structures name to avoid they start with EFI_. > 2. Base on DXE phase bits to provide communication buffer, current implement > check both PEI and DXE phase. > > Cc: Ruiyu Ni <ruiyu.ni@intel.com> > Cc: Jiewen Yao <jiewen.yao@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong <eric.dong@intel.com> > --- > UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 87 > ++++++++++++++++++++++ > .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 4 + > 2 files changed, 91 insertions(+) > > diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > index e53ed21..56f7b37 100644 > --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > @@ -28,6 +28,9 @@ > #include <Ppi/SmmAccess.h> > #include <Ppi/PostBootScriptTable.h> > #include <Ppi/EndOfPeiPhase.h> > +#include <Ppi/SmmCommunication.h> > + > +#include <Protocol/SmmEndOfS3Resume.h> > > #include <Library/DebugLib.h> > #include <Library/BaseLib.h> > @@ -151,6 +154,22 @@ typedef union { > UINT64 Uint64; > } PAGE_TABLE_1G_ENTRY; > > +// > +// Define two type of smm communicate headers. > +// One for 32 bits PEI + 64 bits DXE, the other for 32 bits PEI + 32 bits DXE case. > +// > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT32 MessageLength; > + UINT8 Data[1]; > +} IA32_EFI_SMM_COMMUNICATE_HEADER; > + > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT64 MessageLength; > + UINT8 Data[1]; > +} IA64_EFI_SMM_COMMUNICATE_HEADER; > + > #pragma pack() > > // > @@ -430,6 +449,68 @@ IsLongModeWakingVector ( > } > > /** > + Send EndOfS3Resume event to SmmCore through communication buffer > way. > + > + @retval EFI_SUCCESS Return send the event success. > +**/ > +EFI_STATUS > +SignalEndOfS3Resume ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + EFI_PEI_SMM_COMMUNICATION_PPI *SmmCommunicationPpi; > + UINTN CommSize; > + IA32_EFI_SMM_COMMUNICATE_HEADER Header32; > + IA64_EFI_SMM_COMMUNICATE_HEADER Header64; > + VOID *CommBuffer; > + > + DEBUG ((EFI_D_INFO, "SignalEndOfS3Resume - Enter\n")); > + > + // > + // This buffer consumed in DXE phase, so base on DXE mode to prepare > communicate buffer. > + // Detect whether DXE is 64 bits mode. > + // if (sizeof(UINTN) == sizeof(UINT64), PEI already 64 bits, assume DXE also 64 > bits. > + // or (FeaturePcdGet (PcdDxeIplSwitchToLongMode)), Dxe will switch to 64 > bits. > + // > + if ((sizeof(UINTN) == sizeof(UINT64)) || (FeaturePcdGet > (PcdDxeIplSwitchToLongMode))) { > + CommBuffer = &Header64; > + Header64.MessageLength = 0; > + CommSize = sizeof (IA64_EFI_SMM_COMMUNICATE_HEADER); > + } else { > + CommBuffer = &Header32; > + Header32.MessageLength = 0; > + CommSize = sizeof (IA32_EFI_SMM_COMMUNICATE_HEADER); > + } > + CopyGuid (CommBuffer, &gEdkiiSmmEndOfS3ResumeProtocolGuid); > + > + // > + // Get needed resource > + // > + Status = PeiServicesLocatePpi ( > + &gEfiPeiSmmCommunicationPpiGuid, > + 0, > + NULL, > + (VOID **)&SmmCommunicationPpi > + ); > + ASSERT_EFI_ERROR (Status); > + > + // > + // Send command > + // > + Status = SmmCommunicationPpi->Communicate ( > + SmmCommunicationPpi, > + (VOID *)CommBuffer, > + &CommSize > + ); > + ASSERT_EFI_ERROR (Status); > + > + DEBUG ((EFI_D_INFO, "SignalEndOfS3Resume - Exit (%r)\n", Status)); > + > + return Status; > +} > + > +/** > Jump to OS waking vector. > The function will install boot script done PPI, report S3 resume status code, > and then jump to OS waking vector. > > @@ -504,6 +585,12 @@ S3ResumeBootOs ( > ASSERT_EFI_ERROR (Status); > > // > + // Signal EndOfS3Resume event. > + // > + Status = SignalEndOfS3Resume (); > + ASSERT_EFI_ERROR (Status); > + > + // > // report status code on S3 resume > // > REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE > | EFI_SW_PEI_PC_OS_WAKE); > diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > index d514523..943f114 100644 > --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > @@ -85,6 +85,10 @@ > gPeiSmmAccessPpiGuid ## > SOMETIMES_CONSUMES > gPeiPostScriptTablePpiGuid ## > SOMETIMES_PRODUCES > gEfiEndOfPeiSignalPpiGuid ## > SOMETIMES_PRODUCES > + gEfiPeiSmmCommunicationPpiGuid ## > SOMETIMES_CONSUMES > + > +[Protocols] > + gEdkiiSmmEndOfS3ResumeProtocolGuid ## > SOMETIMES_CONSUMES > > [FeaturePcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode > ## CONSUMES > -- > 2.7.0.windows.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. 2017-10-11 6:25 ` Yao, Jiewen @ 2017-10-11 6:28 ` Dong, Eric 0 siblings, 0 replies; 9+ messages in thread From: Dong, Eric @ 2017-10-11 6:28 UTC (permalink / raw) To: Yao, Jiewen, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu Jiewen, Got it. If just change structure name, I prefer to do it when I push the code. Thanks, Eric -----Original Message----- From: Yao, Jiewen Sent: Wednesday, October 11, 2017 2:25 PM To: Dong, Eric <eric.dong@intel.com>; edk2-devel@lists.01.org Cc: Ni, Ruiyu <ruiyu.ni@intel.com> Subject: RE: [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. Hi Eric I do not think IA64 is a good term. Traditionally, IA64 means the IPF platform, which is deprecated. We use X64 to indicate it is Intel 64bit platform. If it is just a general 64bit indicator, I suggest we use SMM_COMMUNICATE_HEADER_64 and SMM_COMMUNICATE_HEADER_32. Thank you Yao Jiewen > -----Original Message----- > From: Dong, Eric > Sent: Wednesday, October 11, 2017 1:32 PM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> > Subject: [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume > finished event to SmmCore. > > Driver will send S3 resume finished event to SmmCore through > communicate buffer after it signals EndOfPei event. > > V2 Changes: > 1. Change structures name to avoid they start with EFI_. > 2. Base on DXE phase bits to provide communication buffer, current > implement check both PEI and DXE phase. > > Cc: Ruiyu Ni <ruiyu.ni@intel.com> > Cc: Jiewen Yao <jiewen.yao@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong <eric.dong@intel.com> > --- > UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 87 > ++++++++++++++++++++++ > .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 4 + > 2 files changed, 91 insertions(+) > > diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > index e53ed21..56f7b37 100644 > --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > @@ -28,6 +28,9 @@ > #include <Ppi/SmmAccess.h> > #include <Ppi/PostBootScriptTable.h> > #include <Ppi/EndOfPeiPhase.h> > +#include <Ppi/SmmCommunication.h> > + > +#include <Protocol/SmmEndOfS3Resume.h> > > #include <Library/DebugLib.h> > #include <Library/BaseLib.h> > @@ -151,6 +154,22 @@ typedef union { > UINT64 Uint64; > } PAGE_TABLE_1G_ENTRY; > > +// > +// Define two type of smm communicate headers. > +// One for 32 bits PEI + 64 bits DXE, the other for 32 bits PEI + 32 bits DXE case. > +// > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT32 MessageLength; > + UINT8 Data[1]; > +} IA32_EFI_SMM_COMMUNICATE_HEADER; > + > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT64 MessageLength; > + UINT8 Data[1]; > +} IA64_EFI_SMM_COMMUNICATE_HEADER; > + > #pragma pack() > > // > @@ -430,6 +449,68 @@ IsLongModeWakingVector ( } > > /** > + Send EndOfS3Resume event to SmmCore through communication buffer > way. > + > + @retval EFI_SUCCESS Return send the event success. > +**/ > +EFI_STATUS > +SignalEndOfS3Resume ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + EFI_PEI_SMM_COMMUNICATION_PPI *SmmCommunicationPpi; > + UINTN CommSize; > + IA32_EFI_SMM_COMMUNICATE_HEADER Header32; > + IA64_EFI_SMM_COMMUNICATE_HEADER Header64; > + VOID *CommBuffer; > + > + DEBUG ((EFI_D_INFO, "SignalEndOfS3Resume - Enter\n")); > + > + // > + // This buffer consumed in DXE phase, so base on DXE mode to > + prepare > communicate buffer. > + // Detect whether DXE is 64 bits mode. > + // if (sizeof(UINTN) == sizeof(UINT64), PEI already 64 bits, assume > + DXE also 64 > bits. > + // or (FeaturePcdGet (PcdDxeIplSwitchToLongMode)), Dxe will switch > + to 64 > bits. > + // > + if ((sizeof(UINTN) == sizeof(UINT64)) || (FeaturePcdGet > (PcdDxeIplSwitchToLongMode))) { > + CommBuffer = &Header64; > + Header64.MessageLength = 0; > + CommSize = sizeof (IA64_EFI_SMM_COMMUNICATE_HEADER); > + } else { > + CommBuffer = &Header32; > + Header32.MessageLength = 0; > + CommSize = sizeof (IA32_EFI_SMM_COMMUNICATE_HEADER); > + } > + CopyGuid (CommBuffer, &gEdkiiSmmEndOfS3ResumeProtocolGuid); > + > + // > + // Get needed resource > + // > + Status = PeiServicesLocatePpi ( > + &gEfiPeiSmmCommunicationPpiGuid, > + 0, > + NULL, > + (VOID **)&SmmCommunicationPpi > + ); > + ASSERT_EFI_ERROR (Status); > + > + // > + // Send command > + // > + Status = SmmCommunicationPpi->Communicate ( > + SmmCommunicationPpi, > + (VOID *)CommBuffer, > + &CommSize > + ); > + ASSERT_EFI_ERROR (Status); > + > + DEBUG ((EFI_D_INFO, "SignalEndOfS3Resume - Exit (%r)\n", Status)); > + > + return Status; > +} > + > +/** > Jump to OS waking vector. > The function will install boot script done PPI, report S3 resume > status code, and then jump to OS waking vector. > > @@ -504,6 +585,12 @@ S3ResumeBootOs ( > ASSERT_EFI_ERROR (Status); > > // > + // Signal EndOfS3Resume event. > + // > + Status = SignalEndOfS3Resume (); > + ASSERT_EFI_ERROR (Status); > + > + // > // report status code on S3 resume > // > REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE > | EFI_SW_PEI_PC_OS_WAKE); > diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > index d514523..943f114 100644 > --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > @@ -85,6 +85,10 @@ > gPeiSmmAccessPpiGuid ## > SOMETIMES_CONSUMES > gPeiPostScriptTablePpiGuid ## > SOMETIMES_PRODUCES > gEfiEndOfPeiSignalPpiGuid ## > SOMETIMES_PRODUCES > + gEfiPeiSmmCommunicationPpiGuid ## > SOMETIMES_CONSUMES > + > +[Protocols] > + gEdkiiSmmEndOfS3ResumeProtocolGuid ## > SOMETIMES_CONSUMES > > [FeaturePcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode > ## CONSUMES > -- > 2.7.0.windows.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished. 2017-10-11 5:31 [Patch v2 0/3] Add SmmEndOfS3Resume event Eric Dong 2017-10-11 5:31 ` [Patch v2 1/3] MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition Eric Dong 2017-10-11 5:31 ` [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore Eric Dong @ 2017-10-11 5:31 ` Eric Dong 2017-10-11 7:13 ` Yao, Jiewen 2017-10-11 7:09 ` [Patch v2 0/3] Add SmmEndOfS3Resume event Ni, Ruiyu 3 siblings, 1 reply; 9+ messages in thread From: Eric Dong @ 2017-10-11 5:31 UTC (permalink / raw) To: edk2-devel; +Cc: Ruiyu Ni, Jiewen Yao Install EdkiiSmmEndOfS3ResumeProtocol when S3 resume finished. S3ResumePei will send S3 resume finished event to SmmCore through communication buffer. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong <eric.dong@intel.com> --- MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 55 +++++++++++++++++++++++++++---- MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 24 ++++++++++++++ MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 1 + 3 files changed, 73 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c index 9e4390e..aa44933 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c @@ -75,13 +75,14 @@ BOOLEAN mInLegacyBoot = FALSE; // Table of SMI Handlers that are registered by the SMM Core when it is initialized // SMM_CORE_SMI_HANDLERS mSmmCoreSmiHandlers[] = { - { SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, NULL, TRUE }, - { SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, NULL, TRUE }, - { SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, NULL, FALSE }, - { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NULL, FALSE }, - { SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, NULL, FALSE }, - { SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, TRUE }, - { NULL, NULL, NULL, FALSE } + { SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, NULL, TRUE }, + { SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, NULL, TRUE }, + { SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, NULL, FALSE }, + { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NULL, FALSE }, + { SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, NULL, FALSE }, + { SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, TRUE }, + { SmmEndOfS3ResumeHandler, &gEdkiiSmmEndOfS3ResumeProtocolGuid, NULL, FALSE }, + { NULL, NULL, NULL, FALSE } }; UINTN mFullSmramRangeCount; @@ -383,6 +384,46 @@ SmmEndOfDxeHandler ( } /** + Software SMI handler that is called when the EndOfS3Resume event is trigged. + This function installs the SMM EndOfS3Resume Protocol so SMM Drivers are informed that + S3 resume has finished. + + @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister(). + @param Context Points to an optional handler context which was specified when the handler was registered. + @param CommBuffer A pointer to a collection of data in memory that will + be conveyed from a non-SMM environment into an SMM environment. + @param CommBufferSize The size of the CommBuffer. + + @return Status Code + +**/ +EFI_STATUS +EFIAPI +SmmEndOfS3ResumeHandler ( + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context, OPTIONAL + IN OUT VOID *CommBuffer, OPTIONAL + IN OUT UINTN *CommBufferSize OPTIONAL + ) +{ + EFI_STATUS Status; + EFI_HANDLE SmmHandle; + + DEBUG ((EFI_D_INFO, "SmmEndOfS3ResumeHandler\n")); + // + // Install SMM EndOfDxe protocol + // + SmmHandle = NULL; + Status = SmmInstallProtocolInterface ( + &SmmHandle, + &gEdkiiSmmEndOfS3ResumeProtocolGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + return Status; +} + +/** Determine if two buffers overlap in memory. @param[in] Buff1 Pointer to first buffer diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h index b6f815c..6cc824b 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h @@ -32,6 +32,7 @@ #include <Protocol/SmmExitBootServices.h> #include <Protocol/SmmLegacyBoot.h> #include <Protocol/SmmReadyToBoot.h> +#include <Protocol/SmmEndOfS3Resume.h> #include <Guid/Apriori.h> #include <Guid/EventGroup.h> @@ -802,6 +803,29 @@ SmmReadyToBootHandler ( ); /** + Software SMI handler that is called when the EndOfS3Resume event is trigged. + This function installs the SMM EndOfS3Resume Protocol so SMM Drivers are informed that + S3 resume has finished. + + @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister(). + @param Context Points to an optional handler context which was specified when the handler was registered. + @param CommBuffer A pointer to a collection of data in memory that will + be conveyed from a non-SMM environment into an SMM environment. + @param CommBufferSize The size of the CommBuffer. + + @return Status Code + +**/ +EFI_STATUS +EFIAPI +SmmEndOfS3ResumeHandler ( + IN EFI_HANDLE DispatchHandle, + IN CONST VOID *Context, OPTIONAL + IN OUT VOID *CommBuffer, OPTIONAL + IN OUT UINTN *CommBufferSize OPTIONAL + ); + +/** Place holder function until all the SMM System Table Service are available. @param Arg1 Undefined diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf index 95e34bd..a724189 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf @@ -79,6 +79,7 @@ gEdkiiSmmExitBootServicesProtocolGuid ## SOMETIMES_PRODUCES gEdkiiSmmLegacyBootProtocolGuid ## SOMETIMES_PRODUCES gEdkiiSmmReadyToBootProtocolGuid ## PRODUCES + gEdkiiSmmEndOfS3ResumeProtocolGuid ## SOMETIMES_PRODUCES gEfiSmmSwDispatch2ProtocolGuid ## SOMETIMES_CONSUMES gEfiSmmSxDispatch2ProtocolGuid ## SOMETIMES_CONSUMES -- 2.7.0.windows.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished. 2017-10-11 5:31 ` [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished Eric Dong @ 2017-10-11 7:13 ` Yao, Jiewen 2017-10-11 8:24 ` Dong, Eric 0 siblings, 1 reply; 9+ messages in thread From: Yao, Jiewen @ 2017-10-11 7:13 UTC (permalink / raw) To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu I have a question for below: > + SmmHandle = NULL; > + Status = SmmInstallProtocolInterface ( > + &SmmHandle, > + &gEdkiiSmmEndOfS3ResumeProtocolGuid, > + EFI_NATIVE_INTERFACE, > + NULL > + ); A platform may do S3 multiple times. What happen if the SmmInstallProtocolInterface() called twice? Will the system has 2 handle and 2 protocol? Thank you Yao Jiewen > -----Original Message----- > From: Dong, Eric > Sent: Wednesday, October 11, 2017 1:32 PM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> > Subject: [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 > resume finished. > > Install EdkiiSmmEndOfS3ResumeProtocol when S3 resume finished. > S3ResumePei will send S3 resume finished event to SmmCore through > communication buffer. > > Cc: Ruiyu Ni <ruiyu.ni@intel.com> > Cc: Jiewen Yao <jiewen.yao@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong <eric.dong@intel.com> > --- > MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 55 > +++++++++++++++++++++++++++---- > MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 24 ++++++++++++++ > MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 1 + > 3 files changed, 73 insertions(+), 7 deletions(-) > > diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c > b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c > index 9e4390e..aa44933 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c > @@ -75,13 +75,14 @@ BOOLEAN mInLegacyBoot = FALSE; > // Table of SMI Handlers that are registered by the SMM Core when it is > initialized > // > SMM_CORE_SMI_HANDLERS mSmmCoreSmiHandlers[] = { > - { SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, > NULL, TRUE }, > - { SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, > NULL, TRUE }, > - { SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, > NULL, FALSE }, > - { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NULL, > FALSE }, > - { SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, > NULL, FALSE }, > - { SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, > NULL, TRUE }, > - { NULL, NULL, > NULL, FALSE } > + { SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, > NULL, TRUE }, > + { SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, > NULL, TRUE }, > + { SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, > NULL, FALSE }, > + { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NULL, > FALSE }, > + { SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, > NULL, FALSE }, > + { SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, > NULL, TRUE }, > + { SmmEndOfS3ResumeHandler, > &gEdkiiSmmEndOfS3ResumeProtocolGuid, NULL, FALSE }, > + { NULL, NULL, > NULL, FALSE } > }; > > UINTN mFullSmramRangeCount; > @@ -383,6 +384,46 @@ SmmEndOfDxeHandler ( > } > > /** > + Software SMI handler that is called when the EndOfS3Resume event is > trigged. > + This function installs the SMM EndOfS3Resume Protocol so SMM Drivers are > informed that > + S3 resume has finished. > + > + @param DispatchHandle The unique handle assigned to this handler by > SmiHandlerRegister(). > + @param Context Points to an optional handler context which was > specified when the handler was registered. > + @param CommBuffer A pointer to a collection of data in memory > that will > + be conveyed from a non-SMM environment into > an SMM environment. > + @param CommBufferSize The size of the CommBuffer. > + > + @return Status Code > + > +**/ > +EFI_STATUS > +EFIAPI > +SmmEndOfS3ResumeHandler ( > + IN EFI_HANDLE DispatchHandle, > + IN CONST VOID *Context, OPTIONAL > + IN OUT VOID *CommBuffer, OPTIONAL > + IN OUT UINTN *CommBufferSize OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + EFI_HANDLE SmmHandle; > + > + DEBUG ((EFI_D_INFO, "SmmEndOfS3ResumeHandler\n")); > + // > + // Install SMM EndOfDxe protocol > + // > + SmmHandle = NULL; > + Status = SmmInstallProtocolInterface ( > + &SmmHandle, > + &gEdkiiSmmEndOfS3ResumeProtocolGuid, > + EFI_NATIVE_INTERFACE, > + NULL > + ); > + return Status; > +} > + > +/** > Determine if two buffers overlap in memory. > > @param[in] Buff1 Pointer to first buffer > diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > index b6f815c..6cc824b 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > @@ -32,6 +32,7 @@ > #include <Protocol/SmmExitBootServices.h> > #include <Protocol/SmmLegacyBoot.h> > #include <Protocol/SmmReadyToBoot.h> > +#include <Protocol/SmmEndOfS3Resume.h> > > #include <Guid/Apriori.h> > #include <Guid/EventGroup.h> > @@ -802,6 +803,29 @@ SmmReadyToBootHandler ( > ); > > /** > + Software SMI handler that is called when the EndOfS3Resume event is > trigged. > + This function installs the SMM EndOfS3Resume Protocol so SMM Drivers are > informed that > + S3 resume has finished. > + > + @param DispatchHandle The unique handle assigned to this handler by > SmiHandlerRegister(). > + @param Context Points to an optional handler context which was > specified when the handler was registered. > + @param CommBuffer A pointer to a collection of data in memory > that will > + be conveyed from a non-SMM environment into > an SMM environment. > + @param CommBufferSize The size of the CommBuffer. > + > + @return Status Code > + > +**/ > +EFI_STATUS > +EFIAPI > +SmmEndOfS3ResumeHandler ( > + IN EFI_HANDLE DispatchHandle, > + IN CONST VOID *Context, OPTIONAL > + IN OUT VOID *CommBuffer, OPTIONAL > + IN OUT UINTN *CommBufferSize OPTIONAL > + ); > + > +/** > Place holder function until all the SMM System Table Service are available. > > @param Arg1 Undefined > diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > index 95e34bd..a724189 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > @@ -79,6 +79,7 @@ > gEdkiiSmmExitBootServicesProtocolGuid ## > SOMETIMES_PRODUCES > gEdkiiSmmLegacyBootProtocolGuid ## > SOMETIMES_PRODUCES > gEdkiiSmmReadyToBootProtocolGuid ## PRODUCES > + gEdkiiSmmEndOfS3ResumeProtocolGuid ## > SOMETIMES_PRODUCES > > gEfiSmmSwDispatch2ProtocolGuid ## > SOMETIMES_CONSUMES > gEfiSmmSxDispatch2ProtocolGuid ## > SOMETIMES_CONSUMES > -- > 2.7.0.windows.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished. 2017-10-11 7:13 ` Yao, Jiewen @ 2017-10-11 8:24 ` Dong, Eric 0 siblings, 0 replies; 9+ messages in thread From: Dong, Eric @ 2017-10-11 8:24 UTC (permalink / raw) To: Yao, Jiewen, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu Jiewen, Yes, it will always install new protocol and may cause run out of memory. I have updated code to uninstall this protocol right after install it. please check the V3 patch which fix your two comments. Thanks, Eric -----Original Message----- From: Yao, Jiewen Sent: Wednesday, October 11, 2017 3:13 PM To: Dong, Eric <eric.dong@intel.com>; edk2-devel@lists.01.org Cc: Ni, Ruiyu <ruiyu.ni@intel.com> Subject: RE: [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished. I have a question for below: > + SmmHandle = NULL; > + Status = SmmInstallProtocolInterface ( > + &SmmHandle, > + &gEdkiiSmmEndOfS3ResumeProtocolGuid, > + EFI_NATIVE_INTERFACE, > + NULL > + ); A platform may do S3 multiple times. What happen if the SmmInstallProtocolInterface() called twice? Will the system has 2 handle and 2 protocol? Thank you Yao Jiewen > -----Original Message----- > From: Dong, Eric > Sent: Wednesday, October 11, 2017 1:32 PM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> > Subject: [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when > S3 resume finished. > > Install EdkiiSmmEndOfS3ResumeProtocol when S3 resume finished. > S3ResumePei will send S3 resume finished event to SmmCore through > communication buffer. > > Cc: Ruiyu Ni <ruiyu.ni@intel.com> > Cc: Jiewen Yao <jiewen.yao@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong <eric.dong@intel.com> > --- > MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 55 > +++++++++++++++++++++++++++---- > MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 24 ++++++++++++++ > MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 1 + > 3 files changed, 73 insertions(+), 7 deletions(-) > > diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c > b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c > index 9e4390e..aa44933 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c > @@ -75,13 +75,14 @@ BOOLEAN mInLegacyBoot = FALSE; // Table of SMI > Handlers that are registered by the SMM Core when it is initialized > // SMM_CORE_SMI_HANDLERS mSmmCoreSmiHandlers[] = { > - { SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, > NULL, TRUE }, > - { SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, > NULL, TRUE }, > - { SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, > NULL, FALSE }, > - { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NULL, > FALSE }, > - { SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, > NULL, FALSE }, > - { SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, > NULL, TRUE }, > - { NULL, NULL, > NULL, FALSE } > + { SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, > NULL, TRUE }, > + { SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, > NULL, TRUE }, > + { SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, > NULL, FALSE }, > + { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NULL, > FALSE }, > + { SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, > NULL, FALSE }, > + { SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, > NULL, TRUE }, > + { SmmEndOfS3ResumeHandler, > &gEdkiiSmmEndOfS3ResumeProtocolGuid, NULL, FALSE }, > + { NULL, NULL, > NULL, FALSE } > }; > > UINTN mFullSmramRangeCount; > @@ -383,6 +384,46 @@ SmmEndOfDxeHandler ( } > > /** > + Software SMI handler that is called when the EndOfS3Resume event is > trigged. > + This function installs the SMM EndOfS3Resume Protocol so SMM > + Drivers are > informed that > + S3 resume has finished. > + > + @param DispatchHandle The unique handle assigned to this handler > + by > SmiHandlerRegister(). > + @param Context Points to an optional handler context which was > specified when the handler was registered. > + @param CommBuffer A pointer to a collection of data in memory > that will > + be conveyed from a non-SMM environment into > an SMM environment. > + @param CommBufferSize The size of the CommBuffer. > + > + @return Status Code > + > +**/ > +EFI_STATUS > +EFIAPI > +SmmEndOfS3ResumeHandler ( > + IN EFI_HANDLE DispatchHandle, > + IN CONST VOID *Context, OPTIONAL > + IN OUT VOID *CommBuffer, OPTIONAL > + IN OUT UINTN *CommBufferSize OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + EFI_HANDLE SmmHandle; > + > + DEBUG ((EFI_D_INFO, "SmmEndOfS3ResumeHandler\n")); > + // > + // Install SMM EndOfDxe protocol > + // > + SmmHandle = NULL; > + Status = SmmInstallProtocolInterface ( > + &SmmHandle, > + &gEdkiiSmmEndOfS3ResumeProtocolGuid, > + EFI_NATIVE_INTERFACE, > + NULL > + ); > + return Status; > +} > + > +/** > Determine if two buffers overlap in memory. > > @param[in] Buff1 Pointer to first buffer diff --git > a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > index b6f815c..6cc824b 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > @@ -32,6 +32,7 @@ > #include <Protocol/SmmExitBootServices.h> #include > <Protocol/SmmLegacyBoot.h> #include <Protocol/SmmReadyToBoot.h> > +#include <Protocol/SmmEndOfS3Resume.h> > > #include <Guid/Apriori.h> > #include <Guid/EventGroup.h> > @@ -802,6 +803,29 @@ SmmReadyToBootHandler ( > ); > > /** > + Software SMI handler that is called when the EndOfS3Resume event is > trigged. > + This function installs the SMM EndOfS3Resume Protocol so SMM > + Drivers are > informed that > + S3 resume has finished. > + > + @param DispatchHandle The unique handle assigned to this handler > + by > SmiHandlerRegister(). > + @param Context Points to an optional handler context which was > specified when the handler was registered. > + @param CommBuffer A pointer to a collection of data in memory > that will > + be conveyed from a non-SMM environment into > an SMM environment. > + @param CommBufferSize The size of the CommBuffer. > + > + @return Status Code > + > +**/ > +EFI_STATUS > +EFIAPI > +SmmEndOfS3ResumeHandler ( > + IN EFI_HANDLE DispatchHandle, > + IN CONST VOID *Context, OPTIONAL > + IN OUT VOID *CommBuffer, OPTIONAL > + IN OUT UINTN *CommBufferSize OPTIONAL > + ); > + > +/** > Place holder function until all the SMM System Table Service are available. > > @param Arg1 Undefined > diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > index 95e34bd..a724189 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > @@ -79,6 +79,7 @@ > gEdkiiSmmExitBootServicesProtocolGuid ## > SOMETIMES_PRODUCES > gEdkiiSmmLegacyBootProtocolGuid ## > SOMETIMES_PRODUCES > gEdkiiSmmReadyToBootProtocolGuid ## PRODUCES > + gEdkiiSmmEndOfS3ResumeProtocolGuid ## > SOMETIMES_PRODUCES > > gEfiSmmSwDispatch2ProtocolGuid ## > SOMETIMES_CONSUMES > gEfiSmmSxDispatch2ProtocolGuid ## > SOMETIMES_CONSUMES > -- > 2.7.0.windows.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Patch v2 0/3] Add SmmEndOfS3Resume event. 2017-10-11 5:31 [Patch v2 0/3] Add SmmEndOfS3Resume event Eric Dong ` (2 preceding siblings ...) 2017-10-11 5:31 ` [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished Eric Dong @ 2017-10-11 7:09 ` Ni, Ruiyu 3 siblings, 0 replies; 9+ messages in thread From: Ni, Ruiyu @ 2017-10-11 7:09 UTC (permalink / raw) To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Yao, Jiewen Please don't forget to change the structure name as proposed by Jiewen. Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Thanks/Ray > -----Original Message----- > From: Dong, Eric > Sent: Wednesday, October 11, 2017 1:32 PM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> > Subject: [Patch v2 0/3] Add SmmEndOfS3Resume event. > > This patch series add new SmmEndOfS3Resume event which required by > some SMM drivers. > It will implmented by SmmCore to install the > gEdkiiSmmEndOfS3ResumeProtocolGuid > Protocol. Smm drivers can install this protocol's notification functions to hoot > this envet. > It will be trigged right after the EndOfPei event in S3 resume phase. > > V2 Changes: Only change patch 2/3 > 1. Change structures name to avoid they start with EFI_. > 2. Base on DXE phase bits to provide communication buffer, current > implement check both PEI and DXE phase. > > Cc: Ruiyu Ni <ruiyu.ni@intel.com> > Cc: Jiewen Yao <jiewen.yao@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong <eric.dong@intel.com> > > Eric Dong (3): > MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition. > UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. > MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished. > > MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 55 ++++++++++++-- > MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 24 ++++++ > MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 1 + > MdeModulePkg/Include/Protocol/SmmEndOfS3Resume.h | 31 ++++++++ > MdeModulePkg/MdeModulePkg.dec | 3 + > UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 85 > ++++++++++++++++++++++ > .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 4 + > 7 files changed, 196 insertions(+), 7 deletions(-) create mode 100644 > MdeModulePkg/Include/Protocol/SmmEndOfS3Resume.h > > -- > 2.7.0.windows.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-10-11 8:21 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-10-11 5:31 [Patch v2 0/3] Add SmmEndOfS3Resume event Eric Dong 2017-10-11 5:31 ` [Patch v2 1/3] MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition Eric Dong 2017-10-11 5:31 ` [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore Eric Dong 2017-10-11 6:25 ` Yao, Jiewen 2017-10-11 6:28 ` Dong, Eric 2017-10-11 5:31 ` [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished Eric Dong 2017-10-11 7:13 ` Yao, Jiewen 2017-10-11 8:24 ` Dong, Eric 2017-10-11 7:09 ` [Patch v2 0/3] Add SmmEndOfS3Resume event Ni, Ruiyu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox