From nobody Thu Dec 26 00:25:41 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 1507710149282818.9785559302516; Wed, 11 Oct 2017 01:22:29 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 81EAE21F3C18B; Wed, 11 Oct 2017 01:18:55 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 D2E9721EA15C4 for ; Wed, 11 Oct 2017 01:18:52 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2017 01:22:22 -0700 Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.57]) by orsmga005.jf.intel.com with ESMTP; 11 Oct 2017 01:22:20 -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=134.134.136.65; helo=mga03.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="159221085" From: Eric Dong To: edk2-devel@lists.01.org Date: Wed, 11 Oct 2017 16:22:10 +0800 Message-Id: <1507710130-3044-4-git-send-email-eric.dong@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1507710130-3044-1-git-send-email-eric.dong@intel.com> References: <1507710130-3044-1-git-send-email-eric.dong@intel.com> Subject: [edk2] [Patch v3 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished. 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" Install EdkiiSmmEndOfS3ResumeProtocol when S3 resume finished. S3ResumePei will send S3 resume finished event to SmmCore through communication buffer. V2 change: None. V3 change: 1. Uninstall the protocol right after install it to avoid run out of memory. Cc: Ruiyu Ni Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong --- MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 69 +++++++++++++++++++++++++++= ---- MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 24 +++++++++++ MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 1 + 3 files changed, 87 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c b/MdeModulePkg/Core/Pi= SmmCore/PiSmmCore.c index 9e4390e..b833763 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c @@ -75,13 +75,14 @@ BOOLEAN mInLegacyBoot =3D FALSE; // Table of SMI Handlers that are registered by the SMM Core when it is in= itialized // SMM_CORE_SMI_HANDLERS mSmmCoreSmiHandlers[] =3D { - { SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, NULL, = TRUE }, - { SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, NULL, = TRUE },=20 - { 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 },=20 + { SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, NULL,= FALSE }, + { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NULL,= FALSE }, + { SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, NULL,= FALSE }, + { SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL,= TRUE }, + { SmmEndOfS3ResumeHandler, &gEdkiiSmmEndOfS3ResumeProtocolGuid, NULL,= FALSE }, + { NULL, NULL, NULL,= FALSE } }; =20 UINTN mFullSmramRangeCount; @@ -383,6 +384,60 @@ SmmEndOfDxeHandler ( } =20 /** + Software SMI handler that is called when the EndOfS3Resume event is trig= ged. + 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 Sm= iHandlerRegister(). + @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 S= MM 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 EndOfS3Resume protocol + // + SmmHandle =3D NULL; + Status =3D SmmInstallProtocolInterface ( + &SmmHandle, + &gEdkiiSmmEndOfS3ResumeProtocolGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); + + // + // Uninstall the protocol here because the comsume just hook the + // installation event. + // + Status =3D SmmUninstallProtocolInterface ( + SmmHandle, + &gEdkiiSmmEndOfS3ResumeProtocolGuid, + NULL + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +/** Determine if two buffers overlap in memory. =20 @param[in] Buff1 Pointer to first buffer diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h b/MdeModulePkg/Core/Pi= SmmCore/PiSmmCore.h index b6f815c..6cc824b 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h @@ -32,6 +32,7 @@ #include #include #include +#include =20 #include #include @@ -802,6 +803,29 @@ SmmReadyToBootHandler ( ); =20 /** + Software SMI handler that is called when the EndOfS3Resume event is trig= ged. + 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 Sm= iHandlerRegister(). + @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 S= MM 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 availab= le. =20 @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 =20 gEfiSmmSwDispatch2ProtocolGuid ## SOMETIMES_CONSUMES gEfiSmmSxDispatch2ProtocolGuid ## SOMETIMES_CONSUMES --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel