From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3A5F121EA15DA for ; Tue, 10 Oct 2017 23:22:06 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP; 10 Oct 2017 23:25:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,360,1503385200"; d="scan'208";a="1204540988" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga001.fm.intel.com with ESMTP; 10 Oct 2017 23:25:28 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 10 Oct 2017 23:25:28 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 10 Oct 2017 23:25:27 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Wed, 11 Oct 2017 14:25:25 +0800 From: "Yao, Jiewen" To: "Dong, Eric" , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" Thread-Topic: [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. Thread-Index: AQHTQlJGaspZ/KEr2kGAHbrUloD9cqLeLhOQ Date: Wed, 11 Oct 2017 06:25:25 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A9D9AEA@shsmsx102.ccr.corp.intel.com> References: <1507699907-7448-1-git-send-email-eric.dong@intel.com> <1507699907-7448-3-git-send-email-eric.dong@intel.com> In-Reply-To: <1507699907-7448-3-git-send-email-eric.dong@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Oct 2017 06:22:07 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Eric I do not think IA64 is a good term. Traditionally, IA64 means the IPF platf= orm, 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_H= EADER_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 ; Yao, Jiewen > Subject: [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished > event to SmmCore. >=20 > Driver will send S3 resume finished event to SmmCore through communicate > buffer after it signals EndOfPei event. >=20 > V2 Changes: > 1. Change structures name to avoid they start with EFI_. > 2. Base on DXE phase bits to provide communication buffer, current implem= ent > check both PEI and DXE phase. >=20 > Cc: Ruiyu Ni > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong > --- > UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 87 > ++++++++++++++++++++++ > .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 4 + > 2 files changed, 91 insertions(+) >=20 > 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 > #include > #include > +#include > + > +#include >=20 > #include > #include > @@ -151,6 +154,22 @@ typedef union { > UINT64 Uint64; > } PAGE_TABLE_1G_ENTRY; >=20 > +// > +// Define two type of smm communicate headers. > +// One for 32 bits PEI + 64 bits DXE, the other for 32 bits PEI + 32 bi= ts 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() >=20 > // > @@ -430,6 +449,68 @@ IsLongModeWakingVector ( > } >=20 > /** > + 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) =3D=3D sizeof(UINT64), PEI already 64 bits, assum= e DXE also 64 > bits. > + // or (FeaturePcdGet (PcdDxeIplSwitchToLongMode)), Dxe will switch to = 64 > bits. > + // > + if ((sizeof(UINTN) =3D=3D sizeof(UINT64)) || (FeaturePcdGet > (PcdDxeIplSwitchToLongMode))) { > + CommBuffer =3D &Header64; > + Header64.MessageLength =3D 0; > + CommSize =3D sizeof (IA64_EFI_SMM_COMMUNICATE_HEADER); > + } else { > + CommBuffer =3D &Header32; > + Header32.MessageLength =3D 0; > + CommSize =3D sizeof (IA32_EFI_SMM_COMMUNICATE_HEADER); > + } > + CopyGuid (CommBuffer, &gEdkiiSmmEndOfS3ResumeProtocolGuid); > + > + // > + // Get needed resource > + // > + Status =3D PeiServicesLocatePpi ( > + &gEfiPeiSmmCommunicationPpiGuid, > + 0, > + NULL, > + (VOID **)&SmmCommunicationPpi > + ); > + ASSERT_EFI_ERROR (Status); > + > + // > + // Send command > + // > + Status =3D 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 statu= s code, > and then jump to OS waking vector. >=20 > @@ -504,6 +585,12 @@ S3ResumeBootOs ( > ASSERT_EFI_ERROR (Status); >=20 > // > + // Signal EndOfS3Resume event. > + // > + Status =3D 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 >=20 > [FeaturePcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode > ## CONSUMES > -- > 2.7.0.windows.1