* [Patch 0/3] Add SmmEndOfS3Resume event. @ 2017-10-11 2:22 Eric Dong 2017-10-11 2:22 ` [Patch 1/3] MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition Eric Dong ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Eric Dong @ 2017-10-11 2:22 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. 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] 6+ messages in thread
* [Patch 1/3] MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition. 2017-10-11 2:22 [Patch 0/3] Add SmmEndOfS3Resume event Eric Dong @ 2017-10-11 2:22 ` Eric Dong 2017-10-11 2:22 ` [Patch 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore Eric Dong 2017-10-11 2:22 ` [Patch 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished Eric Dong 2 siblings, 0 replies; 6+ messages in thread From: Eric Dong @ 2017-10-11 2:22 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] 6+ messages in thread
* [Patch 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. 2017-10-11 2:22 [Patch 0/3] Add SmmEndOfS3Resume event Eric Dong 2017-10-11 2:22 ` [Patch 1/3] MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition Eric Dong @ 2017-10-11 2:22 ` Eric Dong 2017-10-11 3:24 ` Ni, Ruiyu 2017-10-11 2:22 ` [Patch 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished Eric Dong 2 siblings, 1 reply; 6+ messages in thread From: Eric Dong @ 2017-10-11 2:22 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. 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 | 85 ++++++++++++++++++++++ .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 4 + 2 files changed, 89 insertions(+) diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c index e53ed21..8350eb9 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,23 @@ 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]; +} EFI_SMM_COMMUNICATE_HEADER_IA32; + +typedef struct { + EFI_GUID HeaderGuid; + UINT64 MessageLength; + UINT8 Data[1]; +} EFI_SMM_COMMUNICATE_HEADER_IA64; + #pragma pack() // @@ -430,6 +450,65 @@ 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; + EFI_SMM_COMMUNICATE_HEADER_IA32 Header32; + EFI_SMM_COMMUNICATE_HEADER_IA64 Header64; + VOID *CommBuffer; + + DEBUG ((EFI_D_INFO, "SignalEndOfS3Resume - Enter\n")); + + // + // Detect whether current is 32 bits PEI + 64 bits DXE case. + // + if ((sizeof(UINTN) == sizeof(UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode))) { + CommBuffer = &Header64; + Header64.MessageLength = 0; + CommSize = sizeof (EFI_SMM_COMMUNICATE_HEADER_IA64); + } else { + CommBuffer = &Header32; + Header32.MessageLength = 0; + CommSize = sizeof (EFI_SMM_COMMUNICATE_HEADER_IA32); + } + 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 +583,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] 6+ messages in thread
* Re: [Patch 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. 2017-10-11 2:22 ` [Patch 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore Eric Dong @ 2017-10-11 3:24 ` Ni, Ruiyu 2017-10-11 5:54 ` Dong, Eric 0 siblings, 1 reply; 6+ messages in thread From: Ni, Ruiyu @ 2017-10-11 3:24 UTC (permalink / raw) To: Dong, Eric, edk2-devel@lists.01.org; +Cc: Yao, Jiewen Eric, We may have 4 combinations for PEI DXE CPU architecture: 1. 32bit PEI + 32bit DXE: sizeof (UINTN) == sizeof (UINT32) && NOT PcdDxeIplSwitchToLongMode 2. 32bit PEI + 64bit DXE: sizeof (UINTN) == sizeof (UINT32) && PcdDxeIplSwitchToLongMode 3. 64bit PEI + 32bit DXE: NA!!! 4. 64bit PEI + 64bit DXE: sizeof (UINTN) != sizeof (UINT32) && NOT PcdDxeIplSwitchToLongMode For #4, your code treats MessageLength as 4-byte, but actually it should be 8-byte. So how about we just check PcdDxeIplSwitchToLongMode, when it's FALSE, sizeof (MessageLength) equals to sizeof (UINTN). Otherwise, sizeof (MessageLength) equals to 8. So you only need to define: > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT64 MessageLength; > + UINT8 Data[1]; > +} EFI_SMM_COMMUNICATE_HEADER_IA64; And I recommend to change the structure name to X64_EFI_SMM_COMMUNICATE_HEADER or IA64_EFI_SMM_COMMUNICATE_HEADER. I am neutral using X64 or IA64, but don't want to have EFI_ in the beginning. Thanks/Ray > -----Original Message----- > From: Dong, Eric > Sent: Wednesday, October 11, 2017 10:23 AM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> > Subject: [Patch 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. > > 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 | 85 > ++++++++++++++++++++++ > .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 4 + > 2 files changed, 89 insertions(+) > > diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > index e53ed21..8350eb9 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,23 @@ 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]; > +} EFI_SMM_COMMUNICATE_HEADER_IA32; > + > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT64 MessageLength; > + UINT8 Data[1]; > +} EFI_SMM_COMMUNICATE_HEADER_IA64; > + > #pragma pack() > > // > @@ -430,6 +450,65 @@ 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; > + EFI_SMM_COMMUNICATE_HEADER_IA32 Header32; > + EFI_SMM_COMMUNICATE_HEADER_IA64 Header64; > + VOID *CommBuffer; > + > + DEBUG ((EFI_D_INFO, "SignalEndOfS3Resume - Enter\n")); > + > + // > + // Detect whether current is 32 bits PEI + 64 bits DXE case. > + // > + if ((sizeof(UINTN) == sizeof(UINT32)) && (FeaturePcdGet > (PcdDxeIplSwitchToLongMode))) { > + CommBuffer = &Header64; > + Header64.MessageLength = 0; > + CommSize = sizeof (EFI_SMM_COMMUNICATE_HEADER_IA64); > + } else { > + CommBuffer = &Header32; > + Header32.MessageLength = 0; > + CommSize = sizeof (EFI_SMM_COMMUNICATE_HEADER_IA32); > + } > + 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 +583,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] 6+ messages in thread
* Re: [Patch 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. 2017-10-11 3:24 ` Ni, Ruiyu @ 2017-10-11 5:54 ` Dong, Eric 0 siblings, 0 replies; 6+ messages in thread From: Dong, Eric @ 2017-10-11 5:54 UTC (permalink / raw) To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Yao, Jiewen Hi Ray, I think we can just base on DXE phase bits to prepare the communication buffer. I send new patches base on it. please check them. Thanks, Eric -----Original Message----- From: Ni, Ruiyu Sent: Wednesday, October 11, 2017 11:25 AM To: Dong, Eric <eric.dong@intel.com>; edk2-devel@lists.01.org Cc: Yao, Jiewen <jiewen.yao@intel.com> Subject: RE: [Patch 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. Eric, We may have 4 combinations for PEI DXE CPU architecture: 1. 32bit PEI + 32bit DXE: sizeof (UINTN) == sizeof (UINT32) && NOT PcdDxeIplSwitchToLongMode 2. 32bit PEI + 64bit DXE: sizeof (UINTN) == sizeof (UINT32) && PcdDxeIplSwitchToLongMode 3. 64bit PEI + 32bit DXE: NA!!! 4. 64bit PEI + 64bit DXE: sizeof (UINTN) != sizeof (UINT32) && NOT PcdDxeIplSwitchToLongMode For #4, your code treats MessageLength as 4-byte, but actually it should be 8-byte. So how about we just check PcdDxeIplSwitchToLongMode, when it's FALSE, sizeof (MessageLength) equals to sizeof (UINTN). Otherwise, sizeof (MessageLength) equals to 8. So you only need to define: > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT64 MessageLength; > + UINT8 Data[1]; > +} EFI_SMM_COMMUNICATE_HEADER_IA64; And I recommend to change the structure name to X64_EFI_SMM_COMMUNICATE_HEADER or IA64_EFI_SMM_COMMUNICATE_HEADER. I am neutral using X64 or IA64, but don't want to have EFI_ in the beginning. Thanks/Ray > -----Original Message----- > From: Dong, Eric > Sent: Wednesday, October 11, 2017 10:23 AM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> > Subject: [Patch 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. > > 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 | 85 > ++++++++++++++++++++++ > .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 4 + > 2 files changed, 89 insertions(+) > > diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c > index e53ed21..8350eb9 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,23 @@ 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]; > +} EFI_SMM_COMMUNICATE_HEADER_IA32; > + > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT64 MessageLength; > + UINT8 Data[1]; > +} EFI_SMM_COMMUNICATE_HEADER_IA64; > + > #pragma pack() > > // > @@ -430,6 +450,65 @@ 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; > + EFI_SMM_COMMUNICATE_HEADER_IA32 Header32; > + EFI_SMM_COMMUNICATE_HEADER_IA64 Header64; > + VOID *CommBuffer; > + > + DEBUG ((EFI_D_INFO, "SignalEndOfS3Resume - Enter\n")); > + > + // > + // Detect whether current is 32 bits PEI + 64 bits DXE case. > + // > + if ((sizeof(UINTN) == sizeof(UINT32)) && (FeaturePcdGet > (PcdDxeIplSwitchToLongMode))) { > + CommBuffer = &Header64; > + Header64.MessageLength = 0; > + CommSize = sizeof (EFI_SMM_COMMUNICATE_HEADER_IA64); > + } else { > + CommBuffer = &Header32; > + Header32.MessageLength = 0; > + CommSize = sizeof (EFI_SMM_COMMUNICATE_HEADER_IA32); > + } > + 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 +583,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] 6+ messages in thread
* [Patch 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished. 2017-10-11 2:22 [Patch 0/3] Add SmmEndOfS3Resume event Eric Dong 2017-10-11 2:22 ` [Patch 1/3] MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition Eric Dong 2017-10-11 2:22 ` [Patch 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore Eric Dong @ 2017-10-11 2:22 ` Eric Dong 2 siblings, 0 replies; 6+ messages in thread From: Eric Dong @ 2017-10-11 2:22 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] 6+ messages in thread
end of thread, other threads:[~2017-10-11 5:51 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-10-11 2:22 [Patch 0/3] Add SmmEndOfS3Resume event Eric Dong 2017-10-11 2:22 ` [Patch 1/3] MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition Eric Dong 2017-10-11 2:22 ` [Patch 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore Eric Dong 2017-10-11 3:24 ` Ni, Ruiyu 2017-10-11 5:54 ` Dong, Eric 2017-10-11 2:22 ` [Patch 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished Eric Dong
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox