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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2025 Red Hat, Inc.