From nobody Thu Dec 26 00:35:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1507699919278645.9645981173036; Tue, 10 Oct 2017 22:31:59 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 14EF921F3C1B1; Tue, 10 Oct 2017 22:28:26 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 8B4E021EA15D8 for ; Tue, 10 Oct 2017 22:28:24 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2017 22:31:52 -0700 Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.57]) by orsmga002.jf.intel.com with ESMTP; 10 Oct 2017 22:31:51 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,360,1503385200"; d="scan'208";a="145120358" From: Eric Dong To: edk2-devel@lists.01.org Date: Wed, 11 Oct 2017 13:31:46 +0800 Message-Id: <1507699907-7448-3-git-send-email-eric.dong@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1507699907-7448-1-git-send-email-eric.dong@intel.com> References: <1507699907-7448-1-git-send-email-eric.dong@intel.com> Subject: [edk2] [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: , Cc: Ruiyu Ni , Jiewen Yao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 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(+) 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 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() =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 com= municate buffer. + // Detect whether DXE is 64 bits mode. + // if (sizeof(UINTN) =3D=3D sizeof(UINT64), PEI already 64 bits, assume = DXE also 64 bits. + // or (FeaturePcdGet (PcdDxeIplSwitchToLongMode)), Dxe will switch to 64= bits. + // + if ((sizeof(UINTN) =3D=3D sizeof(UINT64)) || (FeaturePcdGet (PcdDxeIplSw= itchToLongMode))) { + 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 status = 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/Uefi= CpuPkg/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 ## CONS= UMES --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel