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.115; helo=mga14.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 940F121F30410 for ; Tue, 10 Oct 2017 19:19:12 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2017 19:22:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,359,1503385200"; d="scan'208";a="1180746151" Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.57]) by orsmga001.jf.intel.com with ESMTP; 10 Oct 2017 19:22:40 -0700 From: Eric Dong To: edk2-devel@lists.01.org Cc: Ruiyu Ni , Jiewen Yao Date: Wed, 11 Oct 2017 10:22:33 +0800 Message-Id: <1507688554-10264-3-git-send-email-eric.dong@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1507688554-10264-1-git-send-email-eric.dong@intel.com> References: <1507688554-10264-1-git-send-email-eric.dong@intel.com> Subject: [Patch 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 02:19:12 -0000 Driver will send S3 resume finished event to SmmCore through communicate buffer after it signals EndOfPei event. Cc: Ruiyu Ni Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong --- 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 #include #include +#include + +#include #include #include @@ -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