From nobody Mon Dec 23 09:14:36 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 1517553937900216.5488755626858; Thu, 1 Feb 2018 22:45:37 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 577CC22393643; Thu, 1 Feb 2018 22:39:57 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 B226322393634 for ; Thu, 1 Feb 2018 22:39:55 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 22:45:33 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 01 Feb 2018 22:45:33 -0800 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.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,447,1511856000"; d="scan'208";a="14900481" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Feb 2018 14:45:21 +0800 Message-Id: <20180202064530.407028-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180202064530.407028-1-ruiyu.ni@intel.com> References: <20180202064530.407028-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 01/10] MdePkg/PeiServicesLib: Add PeiServicesResetSystem2() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Liming Gao 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" From: Michael D Kinney Add the PeiServicesResetSytstem2() function to the PeiServiesLib to call the ResetSystem2() services in the PEI Services Table. Cc: Liming Gao Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Signed-off-by: Ruiyu Ni Reviewed-by: Star Zeng --- MdePkg/Include/Library/PeiServicesLib.h | 24 ++++++++++++++++++++++= ++ MdePkg/Library/PeiServicesLib/PeiServicesLib.c | 26 ++++++++++++++++++++++= ++++ 2 files changed, 50 insertions(+) diff --git a/MdePkg/Include/Library/PeiServicesLib.h b/MdePkg/Include/Libra= ry/PeiServicesLib.h index 9fc22a10c1..0be72237f2 100644 --- a/MdePkg/Include/Library/PeiServicesLib.h +++ b/MdePkg/Include/Library/PeiServicesLib.h @@ -540,4 +540,28 @@ PeiServicesInstallFvInfo2Ppi ( IN UINT32 AuthenticationStatus ); =20 +/** + Resets the entire platform. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatus The status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm,= or EfiResetShutdown + the data buffer starts with a Null-terminated = string, optionally + followed by additional binary data. The string= is a description + that the caller may use to further indicate th= e reason for the + system reset. ResetData is only valid if Reset= Status is something + other than EFI_SUCCESS unless the ResetType is= EfiResetPlatformSpecific + where a minimum amount of ResetData is always = required. + +**/ +VOID +EFIAPI +PeiServicesResetSystem2 ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL + ); + #endif diff --git a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c b/MdePkg/Librar= y/PeiServicesLib/PeiServicesLib.c index 89166ccd38..d0838ed709 100644 --- a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c +++ b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c @@ -789,3 +789,29 @@ PeiServicesInstallFvInfo2Ppi ( InternalPeiServicesInstallFvInfoPpi (FALSE, FvFormat, FvInfo, FvInfoSize= , ParentFvName, ParentFileName, AuthenticationStatus); } =20 +/** + Resets the entire platform. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatus The status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm,= or EfiResetShutdown + the data buffer starts with a Null-terminated = string, optionally + followed by additional binary data. The string= is a description + that the caller may use to further indicate th= e reason for the + system reset. ResetData is only valid if Reset= Status is something + other than EFI_SUCCESS unless the ResetType is= EfiResetPlatformSpecific + where a minimum amount of ResetData is always = required. + +**/ +VOID +EFIAPI +PeiServicesResetSystem2 ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL + ) +{ + (*GetPeiServicesTablePointer())->ResetSystem2 (ResetType, ResetStatus, D= ataSize, ResetData); +} --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 09:14:36 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 1517553940595443.5885484374728; Thu, 1 Feb 2018 22:45:40 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BDC2222393647; Thu, 1 Feb 2018 22:39:58 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 B666E22393634 for ; Thu, 1 Feb 2018 22:39:56 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 22:45:34 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 01 Feb 2018 22:45:33 -0800 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.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,447,1511856000"; d="scan'208";a="14900485" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Feb 2018 14:45:22 +0800 Message-Id: <20180202064530.407028-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180202064530.407028-1-ruiyu.ni@intel.com> References: <20180202064530.407028-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 02/10] MdeModulePkg/PeiMain: Always attempt to use Reset2 PPI first X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng , Liming Gao 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" From: Michael D Kinney Update PEI Service ResetSystem() to always attempt to use the Reset2 PPI before looking for the Reset PPI. Cc: Liming Gao Reviewed-by: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-by: Star Zeng --- MdeModulePkg/Core/Pei/Reset/Reset.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Core/Pei/Reset/Reset.c b/MdeModulePkg/Core/Pei/Re= set/Reset.c index 7440eefd78..cd36c526b5 100644 --- a/MdeModulePkg/Core/Pei/Reset/Reset.c +++ b/MdeModulePkg/Core/Pei/Reset/Reset.c @@ -35,16 +35,21 @@ PeiResetSystem ( EFI_STATUS Status; EFI_PEI_RESET_PPI *ResetPpi; =20 - Status =3D PeiServicesLocatePpi ( - &gEfiPeiResetPpiGuid, =20 - 0, =20 - NULL, =20 - (VOID **)&ResetPpi =20 - ); + // + // Attempt to use newer ResetSystem2(). If this returns, then ResetSyst= em2() + // is not available. + // + PeiResetSystem2 (EfiResetCold, EFI_SUCCESS, 0, NULL); =20 // - // LocatePpi returns EFI_NOT_FOUND on error + // Look for PEI Reset System PPI // + Status =3D PeiServicesLocatePpi ( + &gEfiPeiResetPpiGuid, + 0, + NULL, + (VOID **)&ResetPpi + ); if (!EFI_ERROR (Status)) { return ResetPpi->ResetSystem (PeiServices); }=20 @@ -55,6 +60,10 @@ PeiResetSystem ( EFI_ERROR_CODE | EFI_ERROR_MINOR, (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE) ); + + // + // No reset PPIs are available yet. + // return EFI_NOT_AVAILABLE_YET; } =20 @@ -85,6 +94,9 @@ PeiResetSystem2 ( EFI_STATUS Status; EFI_PEI_RESET2_PPI *Reset2Ppi; =20 + // + // Look for PEI Reset System 2 PPI + // Status =3D PeiServicesLocatePpi ( &gEfiPeiReset2PpiGuid, 0, --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 09:14:36 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 1517553974059997.2075502903367; Thu, 1 Feb 2018 22:46:14 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 354D22239364E; Thu, 1 Feb 2018 22:39:59 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 EFB2A22393642 for ; Thu, 1 Feb 2018 22:39:57 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 22:45:35 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 01 Feb 2018 22:45:34 -0800 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.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,447,1511856000"; d="scan'208";a="14900491" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Feb 2018 14:45:23 +0800 Message-Id: <20180202064530.407028-4-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180202064530.407028-1-ruiyu.ni@intel.com> References: <20180202064530.407028-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 03/10] MdeModulePkg/PeiMain: Cleanup whitespace in Reset.c X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng , Liming Gao 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" From: Michael D Kinney Cc: Liming Gao Reviewed-by: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-by: Star Zeng --- MdeModulePkg/Core/Pei/Reset/Reset.c | 41 ++++++++++++++++++---------------= ---- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/MdeModulePkg/Core/Pei/Reset/Reset.c b/MdeModulePkg/Core/Pei/Re= set/Reset.c index cd36c526b5..e6d7899ef7 100644 --- a/MdeModulePkg/Core/Pei/Reset/Reset.c +++ b/MdeModulePkg/Core/Pei/Reset/Reset.c @@ -1,14 +1,14 @@ /** @file Pei Core Reset System Support - =20 + Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-This program and the accompanying materials =20 -are licensed and made available under the terms and conditions of the BSD = License =20 -which accompanies this distribution. The full text of the license may be = found at =20 -http://opensource.org/licenses/bsd-license.php = =20 - = =20 -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, = =20 -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. =20 +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD = License +which accompanies this distribution. The full text of the license may be = found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. =20 **/ =20 @@ -29,11 +29,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. EFI_STATUS EFIAPI PeiResetSystem ( - IN CONST EFI_PEI_SERVICES **PeiServices + IN CONST EFI_PEI_SERVICES **PeiServices ) { - EFI_STATUS Status; - EFI_PEI_RESET_PPI *ResetPpi; + EFI_STATUS Status; + EFI_PEI_RESET_PPI *ResetPpi; =20 // // Attempt to use newer ResetSystem2(). If this returns, then ResetSyst= em2() @@ -52,9 +52,10 @@ PeiResetSystem ( ); if (!EFI_ERROR (Status)) { return ResetPpi->ResetSystem (PeiServices); - }=20 + } + // - // Report Status Code that Reset PPI is not available + // Report Status Code that Reset PPI is not available. // REPORT_STATUS_CODE ( EFI_ERROR_CODE | EFI_ERROR_MINOR, @@ -85,14 +86,14 @@ PeiResetSystem ( VOID EFIAPI PeiResetSystem2 ( - IN EFI_RESET_TYPE ResetType, - IN EFI_STATUS ResetStatus, - IN UINTN DataSize, - IN VOID *ResetData OPTIONAL + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL ) { - EFI_STATUS Status; - EFI_PEI_RESET2_PPI *Reset2Ppi; + EFI_STATUS Status; + EFI_PEI_RESET2_PPI *Reset2Ppi; =20 // // Look for PEI Reset System 2 PPI @@ -103,7 +104,6 @@ PeiResetSystem2 ( NULL, (VOID **)&Reset2Ppi ); - if (!EFI_ERROR (Status)) { Reset2Ppi->ResetSystem (ResetType, ResetStatus, DataSize, ResetData); return; @@ -117,4 +117,3 @@ PeiResetSystem2 ( (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE) ); } - --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 09:14:36 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 1517553946306119.86157207826602; Thu, 1 Feb 2018 22:45:46 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9A7812239363B; Thu, 1 Feb 2018 22:40:01 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 0600D2239363B for ; Thu, 1 Feb 2018 22:39:59 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 22:45:38 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 01 Feb 2018 22:45:36 -0800 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.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,447,1511856000"; d="scan'208";a="14900495" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Feb 2018 14:45:24 +0800 Message-Id: <20180202064530.407028-5-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180202064530.407028-1-ruiyu.ni@intel.com> References: <20180202064530.407028-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 04/10] MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng , Liming Gao 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" From: Michael D Kinney Add support for platform specific reset filters and platform specific reset handlers to ResetSystem(). A filter may modify the reset type and reset data and call ResetSystem() with the modified parameters. A handler performs the reset action. The support for platform specific filters and platform specific handlers is based on the Reset Notification feature added to the UEFI 2.7 Specification. Platform specific reset filters are processed first so the final reset type and reset data can be determined. In the DXE Phase The UEFI Reset Notifications are processed second so all UEFI Drivers that have registered for a Reset Notification can perform any required clean up actions. The platform specific reset handlers are processed third. If there are no registered platform specific reset handlers or none of them reset the platform, then the default reset action based on the ResetSystemLib is performed. In the PEI Phase, filters are handlers are registered through the folloiwng 2 PPIs that are based on EFI_RESET_NOTIFICATION_PROTOCOL. * gEdkiiPlatformSpecificResetFilterPpiGuid * gEdkiiPlatformSpecificResetFilterPpiGuid In the DXE Phase, filters are handlers are registered through the folloiwng 2 Protocols that are based on EFI_RESET_NOTIFICATION_PROTOCOL. * gEdkiiPlatformSpecificResetFilterProtocolGuid * gEdkiiPlatformSpecificResetFilterProtocolGuid Cc: Liming Gao Reviewed-by: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney --- .../Include/Ppi/PlatformSpecificResetFilter.h | 31 +++++++++ .../Include/Ppi/PlatformSpecificResetHandler.h | 29 +++++++++ .../Include/Protocol/PlatformSpecificResetFilter.h | 31 +++++++++ .../Protocol/PlatformSpecificResetHandler.h | 29 +++++++++ MdeModulePkg/MdeModulePkg.dec | 10 +++ .../Universal/ResetSystemRuntimeDxe/ResetSystem.c | 75 ++++++++++++++++++= ++-- .../Universal/ResetSystemRuntimeDxe/ResetSystem.h | 7 ++ .../ResetSystemRuntimeDxe.inf | 7 +- 8 files changed, 212 insertions(+), 7 deletions(-) create mode 100644 MdeModulePkg/Include/Ppi/PlatformSpecificResetFilter.h create mode 100644 MdeModulePkg/Include/Ppi/PlatformSpecificResetHandler.h create mode 100644 MdeModulePkg/Include/Protocol/PlatformSpecificResetFilt= er.h create mode 100644 MdeModulePkg/Include/Protocol/PlatformSpecificResetHand= ler.h diff --git a/MdeModulePkg/Include/Ppi/PlatformSpecificResetFilter.h b/MdeMo= dulePkg/Include/Ppi/PlatformSpecificResetFilter.h new file mode 100644 index 0000000000..0f1432f5f8 --- /dev/null +++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetFilter.h @@ -0,0 +1,31 @@ +/** @file + This PPI provides services to register a platform specific reset filter + for ResetSystem(). A reset filter evaluates the parameters passed to + ResetSystem() and converts a ResetType of EfiResetPlatformSpecific to a + non-platform specific reset type. The registered filters are processed = before + EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI handlers. + + Copyright (c) 2017 Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made availa= ble under + the terms and conditions of the BSD License that accompanies this distri= bution. + The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#ifndef _PLATFORM_SPECIFIC_RESET_FILTER_PPI_H_ +#define _PLATFORM_SPECIFIC_RESET_FILTER_PPI_H_ + +#include + +#define EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI_GUID \ + { 0x8c9f4de3, 0x7b90, 0x47ef, { 0x93, 0x8, 0x28, 0x7c, 0xec, 0xd6, 0x6d,= 0xe8 } } + +typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_FIL= TER_PPI; + +extern EFI_GUID gEdkiiPlatformSpecificResetFilterPpiGuid; + +#endif diff --git a/MdeModulePkg/Include/Ppi/PlatformSpecificResetHandler.h b/MdeM= odulePkg/Include/Ppi/PlatformSpecificResetHandler.h new file mode 100644 index 0000000000..d5f1350c69 --- /dev/null +++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetHandler.h @@ -0,0 +1,29 @@ +/** @file + This PPI provides services to register a platform specific handler for + ResetSystem(). The registered handlers are processed after + EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI notifications. + + Copyright (c) 2017 Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made availa= ble under + the terms and conditions of the BSD License that accompanies this distri= bution. + The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#ifndef _PLATFORM_SPECIFIC_RESET_HANDLER_PPI_H_ +#define _PLATFORM_SPECIFIC_RESET_HANDLER_PPI_H_ + +#include + +#define EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI_GUID \ + { 0x75cf14ae, 0x3441, 0x49dc, { 0xaa, 0x10, 0xbb, 0x35, 0xa7, 0xba, 0x8b= , 0xab } } + +typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_HAN= DLER_PPI; + +extern EFI_GUID gEdkiiPlatformSpecificResetHandlerPpiGuid; + +#endif diff --git a/MdeModulePkg/Include/Protocol/PlatformSpecificResetFilter.h b/= MdeModulePkg/Include/Protocol/PlatformSpecificResetFilter.h new file mode 100644 index 0000000000..ff5ca48fdd --- /dev/null +++ b/MdeModulePkg/Include/Protocol/PlatformSpecificResetFilter.h @@ -0,0 +1,31 @@ +/** @file + This Protocol provides services to register a platform specific reset fi= lter + for ResetSystem(). A reset filter evaluates the parameters passed to + ResetSystem() and converts a ResetType of EfiResetPlatformSpecific to a + non-platform specific reset type. The registered filters are processed = before + the UEFI 2.7 Reset Notifications. + + Copyright (c) 2017 Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made availa= ble under + the terms and conditions of the BSD License that accompanies this distri= bution. + The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#ifndef _PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL_H_ +#define _PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL_H_ + +#include + +#define EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL_GUID \ + { 0x695d7835, 0x8d47, 0x4c11, { 0xab, 0x22, 0xfa, 0x8a, 0xcc, 0xe7, 0xae= , 0x7a } } + +typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_FIL= TER_PROTOCOL; + +extern EFI_GUID gEdkiiPlatformSpecificResetFilterProtocolGuid; + +#endif diff --git a/MdeModulePkg/Include/Protocol/PlatformSpecificResetHandler.h b= /MdeModulePkg/Include/Protocol/PlatformSpecificResetHandler.h new file mode 100644 index 0000000000..8a44e860b2 --- /dev/null +++ b/MdeModulePkg/Include/Protocol/PlatformSpecificResetHandler.h @@ -0,0 +1,29 @@ +/** @file + This protocol provides services to register a platform specific handler = for + ResetSystem(). The registered handlers are called after the UEFI 2.7 Re= set + Notifications are processed + + Copyright (c) 2017 Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made availa= ble under + the terms and conditions of the BSD License that accompanies this distri= bution. + The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#ifndef _PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL_H_ +#define _PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL_H_ + +#include + +#define EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL_GUID \ + { 0x2df6ba0b, 0x7092, 0x440d, { 0xbd, 0x4, 0xfb, 0x9, 0x1e, 0xc3, 0xf3, = 0xc1 } } + +typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_HAN= DLER_PROTOCOL; + +extern EFI_GUID gEdkiiPlatformSpecificResetHandlerProtocolGuid; + +#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 61d034fba8..1cc9bc8ea1 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -441,6 +441,12 @@ [Ppis] ## Include/Ppi/IoMmu.h gEdkiiIoMmuPpiGuid =3D { 0x70b0af26, 0xf847, 0x4bb6, { 0xaa, 0xb9, 0xcd,= 0xe8, 0x4f, 0xc6, 0x14, 0x31 } } =20 + ## Include/Ppi/PlatformSpecificResetFilter.h + gEdkiiPlatformSpecificResetFilterPpiGuid =3D { 0x8c9f4de3, 0x7b90, 0x47e= f, { 0x93, 0x8, 0x28, 0x7c, 0xec, 0xd6, 0x6d, 0xe8 } } + + ## Include/Ppi/PlatformSpecificResetHandler.h + gEdkiiPlatformSpecificResetHandlerPpiGuid =3D { 0x75cf14ae, 0x3441, 0x49= dc, { 0xaa, 0x10, 0xbb, 0x35, 0xa7, 0xba, 0x8b, 0xab } } + [Protocols] ## Load File protocol provides capability to load and unload EFI image i= nto memory and execute it. # Include/Protocol/LoadPe32Image.h @@ -565,6 +571,10 @@ [Protocols] ## Include/Protocol/SdMmcOverride.h gEdkiiSdMmcOverrideProtocolGuid =3D { 0xeaf9e3c1, 0xc9cd, 0x46db, { 0xa5= , 0xe5, 0x5a, 0x12, 0x4c, 0x83, 0x23, 0x23 } } =20 + ## Include/Protocol/PlatformSpecificResetFilter.h + gEdkiiPlatformSpecificResetFilterProtocolGuid =3D { 0x695d7835, 0x8d47,= 0x4c11, { 0xab, 0x22, 0xfa, 0x8a, 0xcc, 0xe7, 0xae, 0x7a } } + ## Include/Protocol/PlatformSpecificResetHandler.h + gEdkiiPlatformSpecificResetHandlerProtocolGuid =3D { 0x2df6ba0b, 0x7092,= 0x440d, { 0xbd, 0x4, 0xfb, 0x9, 0x1e, 0xc3, 0xf3, 0xc1 } } # # [Error.gEfiMdeModulePkgTokenSpaceGuid] # 0x80000001 | Invalid value provided. diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c b/M= deModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c index 75cff37773..43400e1338 100644 --- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c +++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c @@ -15,6 +15,11 @@ =20 #include "ResetSystem.h" =20 +// +// The current ResetSystem() notification recursion depth +// +UINTN mResetNotifyDepth =3D 0; + /** Register a notification function to be called when ResetSystem() is call= ed. =20 @@ -130,6 +135,24 @@ RESET_NOTIFICATION_INSTANCE mResetNotification =3D { INITIALIZE_LIST_HEAD_VARIABLE (mResetNotification.ResetNotifies) }; =20 +RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetFilter =3D { + RESET_NOTIFICATION_INSTANCE_SIGNATURE, + { + RegisterResetNotify, + UnregisterResetNotify + }, + INITIALIZE_LIST_HEAD_VARIABLE (mPlatformSpecificResetFilter.ResetNotifie= s) +}; + +RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetHandler =3D { + RESET_NOTIFICATION_INSTANCE_SIGNATURE, + { + RegisterResetNotify, + UnregisterResetNotify + }, + INITIALIZE_LIST_HEAD_VARIABLE (mPlatformSpecificResetHandler.ResetNotifi= es) +}; + /** The driver's entry point. =20 @@ -170,6 +193,8 @@ InitializeResetSystem ( &Handle, &gEfiResetArchProtocolGuid, NULL, &gEfiResetNotificationProtocolGuid, &mResetNotification.= ResetNotification, + &gEdkiiPlatformSpecificResetFilterProtocolGuid, &mPlatfo= rmSpecificResetFilter.ResetNotification, + &gEdkiiPlatformSpecificResetHandlerProtocolGuid, &mPlatf= ormSpecificResetHandler.ResetNotification, NULL ); ASSERT_EFI_ERROR (Status); @@ -225,13 +250,44 @@ ResetSystem ( UINTN CapsuleDataPtr; LIST_ENTRY *Link; RESET_NOTIFY_ENTRY *Entry; - =20 + + // + // Above the maximum recursion depth, so do the smallest amount of + // work to perform a cold reset. + // + if (mResetNotifyDepth >=3D MAX_RESET_NOTIFY_DEPTH) { + ResetCold (); + ASSERT (FALSE); + return; + } + // - // Indicate reset system runtime service is called. + // Only do REPORT_STATUS_CODE() on first call to ResetSystem() // - REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVICE= | EFI_SW_RS_PC_RESET_SYSTEM)); + if (mResetNotifyDepth =3D=3D 0) { + // + // Indicate reset system runtime service is called. + // + REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVI= CE | EFI_SW_RS_PC_RESET_SYSTEM)); + } =20 - if (!EfiAtRuntime ()) { + mResetNotifyDepth++; + if (!EfiAtRuntime () && mResetNotifyDepth < MAX_RESET_NOTIFY_DEPTH) { + // + // Call reset notification functions registered through the + // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL. + // + for ( Link =3D GetFirstNode (&mPlatformSpecificResetFilter.ResetNotifi= es) + ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link) + ; Link =3D GetNextNode (&mPlatformSpecificResetFilter.ResetNotifie= s, Link) + ) { + Entry =3D RESET_NOTIFY_ENTRY_FROM_LINK (Link); + Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData); + } + // + // Call reset notification functions registered through the + // EFI_RESET_NOTIFICATION_PROTOCOL. + // for ( Link =3D GetFirstNode (&mResetNotification.ResetNotifies) ; !IsNull (&mResetNotification.ResetNotifies, Link) ; Link =3D GetNextNode (&mResetNotification.ResetNotifies, Link) @@ -239,6 +295,17 @@ ResetSystem ( Entry =3D RESET_NOTIFY_ENTRY_FROM_LINK (Link); Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData); } + // + // call reset notification functions registered through the=20 + // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL. + // + for ( Link =3D GetFirstNode (&mPlatformSpecificResetHandler.ResetNotif= ies) + ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link) + ; Link =3D GetNextNode (&mPlatformSpecificResetHandler.ResetNotifi= es, Link) + ) { + Entry =3D RESET_NOTIFY_ENTRY_FROM_LINK (Link); + Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData); + } } =20 switch (ResetType) { diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h b/M= deModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h index 75cdd88896..ea5660274b 100644 --- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h +++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h @@ -20,6 +20,8 @@ =20 #include #include +#include +#include #include =20 #include @@ -34,6 +36,11 @@ #include #include =20 +// +// The maximum recurstion depth to ResetSystem() by reset notification han= dlers +// +#define MAX_RESET_NOTIFY_DEPTH 10 + typedef struct { UINT32 Signature; LIST_ENTRY Link; diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntim= eDxe.inf b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeD= xe.inf index 11233757c2..da9e8e118b 100644 --- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf +++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf @@ -55,9 +55,10 @@ [Guids] =20 =20 [Protocols] - gEfiResetArchProtocolGuid ## PRODUCES - gEfiResetNotificationProtocolGuid ## PRODUCES - + gEfiResetArchProtocolGuid ## PRODUCES + gEfiResetNotificationProtocolGuid ## PRODUCES + gEdkiiPlatformSpecificResetFilterProtocolGuid ## PRODUCES + gEdkiiPlatformSpecificResetHandlerProtocolGuid ## PRODUCES =20 [Depex] TRUE --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 09:14:36 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 1517553949584120.53634147062041; Thu, 1 Feb 2018 22:45:49 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 067272239364B; Thu, 1 Feb 2018 22:40:03 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 037202239363B for ; Thu, 1 Feb 2018 22:40:00 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 22:45:39 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 01 Feb 2018 22:45:38 -0800 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.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,447,1511856000"; d="scan'208";a="14900500" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Feb 2018 14:45:25 +0800 Message-Id: <20180202064530.407028-6-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180202064530.407028-1-ruiyu.ni@intel.com> References: <20180202064530.407028-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 05/10] MdeModulePkg/ResetSystemRuntimeDxe: Add more debug message X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng , Liming Gao 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" The patch adds more debug message in ResetSystem(). It also removes unnecessary check of mResetNotifyDepth. Cc: Liming Gao Cc: Michael D Kinney Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni --- .../Universal/ResetSystemRuntimeDxe/ResetSystem.c | 88 +++++++++++-------= ---- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c b/M= deModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c index 43400e1338..4b5af76999 100644 --- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c +++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c @@ -15,6 +15,10 @@ =20 #include "ResetSystem.h" =20 +GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] =3D { + L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific" +}; + // // The current ResetSystem() notification recursion depth // @@ -251,16 +255,6 @@ ResetSystem ( LIST_ENTRY *Link; RESET_NOTIFY_ENTRY *Entry; =20 - // - // Above the maximum recursion depth, so do the smallest amount of - // work to perform a cold reset. - // - if (mResetNotifyDepth >=3D MAX_RESET_NOTIFY_DEPTH) { - ResetCold (); - ASSERT (FALSE); - return; - } - // // Only do REPORT_STATUS_CODE() on first call to ResetSystem() // @@ -272,40 +266,47 @@ ResetSystem ( } =20 mResetNotifyDepth++; - if (!EfiAtRuntime () && mResetNotifyDepth < MAX_RESET_NOTIFY_DEPTH) { - // - // Call reset notification functions registered through the - // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL. - // - for ( Link =3D GetFirstNode (&mPlatformSpecificResetFilter.ResetNotifi= es) - ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link) - ; Link =3D GetNextNode (&mPlatformSpecificResetFilter.ResetNotifie= s, Link) - ) { - Entry =3D RESET_NOTIFY_ENTRY_FROM_LINK (Link); - Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData); - } - // - // Call reset notification functions registered through the - // EFI_RESET_NOTIFICATION_PROTOCOL. - // - for ( Link =3D GetFirstNode (&mResetNotification.ResetNotifies) - ; !IsNull (&mResetNotification.ResetNotifies, Link) - ; Link =3D GetNextNode (&mResetNotification.ResetNotifies, Link) - ) { - Entry =3D RESET_NOTIFY_ENTRY_FROM_LINK (Link); - Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData); - } - // - // call reset notification functions registered through the=20 - // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL. - // - for ( Link =3D GetFirstNode (&mPlatformSpecificResetHandler.ResetNotif= ies) - ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link) - ; Link =3D GetNextNode (&mPlatformSpecificResetHandler.ResetNotifi= es, Link) - ) { - Entry =3D RESET_NOTIFY_ENTRY_FROM_LINK (Link); - Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData); + DEBUG ((DEBUG_INFO, "DXE ResetSystem2: Reset call depth =3D %d.\n", mRes= etNotifyDepth)); + + if (mResetNotifyDepth <=3D MAX_RESET_NOTIFY_DEPTH) { + if (!EfiAtRuntime ()) { + // + // Call reset notification functions registered through the + // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL. + // + for ( Link =3D GetFirstNode (&mPlatformSpecificResetFilter.ResetNoti= fies) + ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link) + ; Link =3D GetNextNode (&mPlatformSpecificResetFilter.ResetNotif= ies, Link) + ) { + Entry =3D RESET_NOTIFY_ENTRY_FROM_LINK (Link); + Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData); + } + // + // Call reset notification functions registered through the + // EFI_RESET_NOTIFICATION_PROTOCOL. + // + for ( Link =3D GetFirstNode (&mResetNotification.ResetNotifies) + ; !IsNull (&mResetNotification.ResetNotifies, Link) + ; Link =3D GetNextNode (&mResetNotification.ResetNotifies, Link) + ) { + Entry =3D RESET_NOTIFY_ENTRY_FROM_LINK (Link); + Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData); + } + // + // call reset notification functions registered through the=20 + // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL. + // + for ( Link =3D GetFirstNode (&mPlatformSpecificResetHandler.ResetNot= ifies) + ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link) + ; Link =3D GetNextNode (&mPlatformSpecificResetHandler.ResetNoti= fies, Link) + ) { + Entry =3D RESET_NOTIFY_ENTRY_FROM_LINK (Link); + Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData); + } } + } else { + ASSERT (ResetType < ARRAY_SIZE (mResetTypeStr)); + DEBUG ((DEBUG_ERROR, "DXE ResetSystem2: Maximum reset call depth is me= t. Use the current reset type: %s!\n", mResetTypeStr[ResetType])); } =20 switch (ResetType) { @@ -331,7 +332,6 @@ ResetSystem ( } =20 ResetWarm (); - break; =20 case EfiResetCold: --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 09:14:36 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 1517553952427588.6843828135733; Thu, 1 Feb 2018 22:45:52 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 62926223AF816; Thu, 1 Feb 2018 22:40:03 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 0F0822239364B for ; Thu, 1 Feb 2018 22:40:02 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 22:45:40 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 01 Feb 2018 22:45:39 -0800 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.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,447,1511856000"; d="scan'208";a="14900505" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Feb 2018 14:45:26 +0800 Message-Id: <20180202064530.407028-7-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180202064530.407028-1-ruiyu.ni@intel.com> References: <20180202064530.407028-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 06/10] MdeModulePkg: Add ResetSystemLib instances that call core services X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng , Liming Gao 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" From: Michael D Kinney Add a PEI instance of ResetSystemLib that calls the ResetSystem2() service in the PEI Services Table. Add a DXE instance of ResetSystemLib that calls the ResetSystem() service in the UEFI Runtime Services Table. These 2 library instances should be the default ResetSystemLib mapping for most PEIMs and DXE drivers so all reset system requests go through the core service. Only the implementation of the core servies should use the platform specific instance of the ResetSystemLib that actually performs the hardware actions to reset the platform. Cc: Liming Gao Reviewed-by: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney --- .../Library/DxeResetSystemLib/DxeResetSystemLib.c | 100 +++++++++++++++++= ++++ .../DxeResetSystemLib/DxeResetSystemLib.inf | 40 +++++++++ .../DxeResetSystemLib/DxeResetSystemLib.uni | 21 +++++ .../Library/PeiResetSystemLib/PeiResetSystemLib.c | 100 +++++++++++++++++= ++++ .../PeiResetSystemLib/PeiResetSystemLib.inf | 40 +++++++++ .../PeiResetSystemLib/PeiResetSystemLib.uni | 21 +++++ 6 files changed, 322 insertions(+) create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLi= b.c create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLi= b.inf create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLi= b.uni create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLi= b.c create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLi= b.inf create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLi= b.uni diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c b/M= deModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c new file mode 100644 index 0000000000..70ee1175d5 --- /dev/null +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c @@ -0,0 +1,100 @@ +/** @file + DXE Reset System Library instance that calls gRT->ResetSystem(). + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include + +#include +#include +#include + +/** + This function causes a system-wide reset (cold reset), in which + all circuitry within the system returns to its initial state. This type = of reset=20 + is asynchronous to system operation and operates without regard to + cycle boundaries. + + If this function returns, it means that the system does not support cold= reset.=20 +**/ +VOID +EFIAPI +ResetCold ( + VOID + ) +{ + EfiResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); +} + +/** + This function causes a system-wide initialization (warm reset), in which= all processors=20 + are set to their initial state. Pending cycles are not corrupted. + + If this function returns, it means that the system does not support warm= reset. +**/ +VOID +EFIAPI +ResetWarm ( + VOID + ) +{ + EfiResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL); +} + +/** + This function causes the system to enter a power state equivalent=20 + to the ACPI G2/S5 or G3 states. + + If this function returns, it means that the system does not support shut= down reset. +**/ +VOID +EFIAPI +ResetShutdown ( + VOID + ) +{ + EfiResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL); +} + +/** + This function causes the system to enter S3 and then wake up immediately. + + If this function returns, it means that the system does not support S3 f= eature. +**/ +VOID +EFIAPI +EnterS3WithImmediateWake ( + VOID + ) +{ +} + +/** + This function causes a systemwide reset. The exact type of the reset is + defined by the EFI_GUID that follows the Null-terminated Unicode string = passed + into ResetData. If the platform does not recognize the EFI_GUID in Reset= Data + the platform must pick a supported reset type to perform.The platform may + optionally log the parameters from any non-normal reset that occurs. + + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData The data buffer starts with a Null-terminated str= ing, + followed by the EFI_GUID. +**/ +VOID +EFIAPI +ResetPlatformSpecific ( + IN UINTN DataSize, + IN VOID *ResetData + ) +{ + EfiResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetDa= ta); +} diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf b= /MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf new file mode 100644 index 0000000000..f2e04cfd00 --- /dev/null +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf @@ -0,0 +1,40 @@ +## @file +# DXE Reset System Library instance that calls gRT->ResetSystem(). +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may b= e found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D DxeResetSystemLib + MODULE_UNI_FILE =3D DxeResetSystemLib.uni + FILE_GUID =3D C2BDE4F6-65EE-440B-87B5-83ABF10EF45B + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ResetSystemLib|DXE_CORE DXE_DRIVER DX= E_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC +# + +[Sources] + DxeResetSystemLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + DebugLib + UefiRuntimeLib + diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni b= /MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni new file mode 100644 index 0000000000..7c51ce0713 --- /dev/null +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni @@ -0,0 +1,21 @@ +// /** @file +// DXE Reset System Library instance that calls gRT->ResetSystem(). +// +// DXE Reset System Library instance that calls gRT->ResetSystem(). +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the B= SD License +// which accompanies this distribution. The full text of the license may b= e found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "DXE Reset System = Library instance that calls gRT->ResetSystem()" + +#string STR_MODULE_DESCRIPTION #language en-US "DXE Reset System = Library instance that calls gRT->ResetSystem()." + diff --git a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c b/M= deModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c new file mode 100644 index 0000000000..b7e10110b0 --- /dev/null +++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c @@ -0,0 +1,100 @@ +/** @file + PEI Reset System Library instance that calls the ResetSystem2() PEI Serv= ice. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include + +#include +#include +#include + +/** + This function causes a system-wide reset (cold reset), in which + all circuitry within the system returns to its initial state. This type = of reset=20 + is asynchronous to system operation and operates without regard to + cycle boundaries. + + If this function returns, it means that the system does not support cold= reset.=20 +**/ +VOID +EFIAPI +ResetCold ( + VOID + ) +{ + PeiServicesResetSystem2 (EfiResetCold, EFI_SUCCESS, 0, NULL); +} + +/** + This function causes a system-wide initialization (warm reset), in which= all processors=20 + are set to their initial state. Pending cycles are not corrupted. + + If this function returns, it means that the system does not support warm= reset. +**/ +VOID +EFIAPI +ResetWarm ( + VOID + ) +{ + PeiServicesResetSystem2 (EfiResetWarm, EFI_SUCCESS, 0, NULL); +} + +/** + This function causes the system to enter a power state equivalent=20 + to the ACPI G2/S5 or G3 states. + + If this function returns, it means that the system does not support shut= down reset. +**/ +VOID +EFIAPI +ResetShutdown ( + VOID + ) +{ + PeiServicesResetSystem2 (EfiResetShutdown, EFI_SUCCESS, 0, NULL); +} + +/** + This function causes the system to enter S3 and then wake up immediately. + + If this function returns, it means that the system does not support S3 f= eature. +**/ +VOID +EFIAPI +EnterS3WithImmediateWake ( + VOID + ) +{ +} + +/** + This function causes a systemwide reset. The exact type of the reset is + defined by the EFI_GUID that follows the Null-terminated Unicode string = passed + into ResetData. If the platform does not recognize the EFI_GUID in Reset= Data + the platform must pick a supported reset type to perform.The platform may + optionally log the parameters from any non-normal reset that occurs. + + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData The data buffer starts with a Null-terminated str= ing, + followed by the EFI_GUID. +**/ +VOID +EFIAPI +ResetPlatformSpecific ( + IN UINTN DataSize, + IN VOID *ResetData + ) +{ + PeiServicesResetSystem2 (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize= , ResetData); +} diff --git a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf b= /MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf new file mode 100644 index 0000000000..e82ec6b2b6 --- /dev/null +++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf @@ -0,0 +1,40 @@ +## @file +# PEI Reset System Library instance that calls the ResetSystem2() PEI Ser= vice. +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may b= e found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiResetSystemLib + MODULE_UNI_FILE =3D PeiResetSystemLib.uni + FILE_GUID =3D 3198FF36-FC72-42E7-B98A-A080D823AFBF + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ResetSystemLib|PEI_CORE PEIM + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC +# + +[Sources] + PeiResetSystemLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + DebugLib + PeiServicesLib + diff --git a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni b= /MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni new file mode 100644 index 0000000000..ac996b3cc8 --- /dev/null +++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni @@ -0,0 +1,21 @@ +// /** @file +// PEI Reset System Library instance that calls the ResetSystem2() PEI Ser= vice. +// +// PEI Reset System Library instance that calls the ResetSystem2() PEI Ser= vice. +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the B= SD License +// which accompanies this distribution. The full text of the license may b= e found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "PEI Reset System = Library instance that calls the ResetSystem2() PEI Service" + +#string STR_MODULE_DESCRIPTION #language en-US "PEI Reset System = Library instance that calls the ResetSystem2() PEI Service." + --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 09:14:36 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 1517553955472813.5426031811581; Thu, 1 Feb 2018 22:45:55 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CDF86223AF814; Thu, 1 Feb 2018 22:40:05 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 15C53223AF812 for ; Thu, 1 Feb 2018 22:40:03 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 22:45:41 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 01 Feb 2018 22:45:40 -0800 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.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,447,1511856000"; d="scan'208";a="14900510" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Feb 2018 14:45:27 +0800 Message-Id: <20180202064530.407028-8-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180202064530.407028-1-ruiyu.ni@intel.com> References: <20180202064530.407028-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 07/10] MdeModulePkg: Add ResetUtility librray class and BASE instance X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng , Liming Gao 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" From: Michael D Kinney The library class that provides services to generate a GUID specific reset, parse the GUID from a GUID specific reset, and build the ResetData buffer for any type of reset that requires extra data. Cc: Liming Gao Reviewed-by: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Signed-off-by: Ruiyu Ni --- MdeModulePkg/Include/Library/ResetUtilityLib.h | 111 +++++++++++ .../Library/ResetUtilityLib/ResetUtility.c | 221 +++++++++++++++++= ++++ .../Library/ResetUtilityLib/ResetUtilityLib.inf | 43 ++++ MdeModulePkg/MdeModulePkg.dsc | 7 + 4 files changed, 382 insertions(+) create mode 100644 MdeModulePkg/Include/Library/ResetUtilityLib.h create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf diff --git a/MdeModulePkg/Include/Library/ResetUtilityLib.h b/MdeModulePkg/= Include/Library/ResetUtilityLib.h new file mode 100644 index 0000000000..94828785e2 --- /dev/null +++ b/MdeModulePkg/Include/Library/ResetUtilityLib.h @@ -0,0 +1,111 @@ +/** @file + This header describes various helper functions for resetting the system. + + Copyright (c) 2017 Intel Corporation. All rights reserved.
+ Copyright (c) 2016 Microsoft Corporation. All rights reserved.
+ + This program and the accompanying materials are licensed and made availa= ble under + the terms and conditions of the BSD License that accompanies this distri= bution. + The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ +#ifndef _RESET_UTILITY_LIB_H_ +#define _RESET_UTILITY_LIB_H_ + +/** + This is a shorthand helper function to reset with a subtype so that + the caller doesn't have to bother with a function that has half a dozen + parameters. + + This will generate a reset with status EFI_SUCCESS, a NULL string, and + no custom data. The subtype will be formatted in such a way that it can = be + picked up by notification registrations and custom handlers. + + NOTE: This call will fail if the architectural ResetSystem underpinnings + are not initialized. For DXE, you can add gEfiResetArchProtocolGuid + to your DEPEX. + + @param[in] ResetType Base reset type as defined in UEFI spec. + @param[in] ResetSubtype GUID pointer for the reset subtype to be used. + +**/ +VOID +EFIAPI +ResetPlatformSpecificGuid ( + IN CONST GUID *ResetSubtype + ); + +/** + This function examines the DataSize and ResetData parameters passed to + to ResetSystem() and detemrines if the ResetData contains a Null-termina= ted + Unicode string followed by a GUID specific subtype. If the GUID specifi= c=20 + subtype is present, then a pointer to the GUID value in ResetData is ret= urned. + + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData Pointer to the data buffer passed into ResetSyst= em(). + + @retval Pointer Pointer to the GUID value in ResetData. + @retval NULL ResetData is NULL. + @retval NULL ResetData does not start with a Null-terminated + Unicode string. + @retval NULL A Null-terminated Unicode string is present, but= there + are less than sizeof (GUID) bytes after the stri= ng. + @retval NULL No subtype is found. + +**/ +GUID * +EFIAPI +GetResetPlatformSpecificGuid ( + IN UINTN DataSize, + IN CONST VOID *ResetData + ); + +/** + This is a helper function that creates the reset data buffer that can be=20 + passed into ResetSystem(). + + The reset data buffer is returned in ResetData and contains ResetString + followed by the ResetSubtype GUID followed by the ExtraData. + + NOTE: Strings are internally limited by MAX_UINT16. + + @param[in, out] ResetDataSize On input, the size of the ResetData buffe= r. On + output, either the total number of bytes + copied, or the required buffer size. + @param[in, out] ResetData A pointer to the buffer in which to place= the + final structure. + @param[in] ResetSubtype Pointer to the GUID specific subtype. Th= is + parameter is optional and may be NULL. + @param[in] ResetString Pointer to a Null-terminated Unicode stri= ng + that describes the reset. This parameter= is + optional and may be NULL. + @param[in] ExtraDataSize The size, in bytes, of ExtraData buffer. + @param[in] ExtraData Pointer to a buffer of extra data. This + parameter is optional and may be NULL. + + @retval RETURN_SUCCESS ResetDataSize and ResetData are u= pdated. + @retval RETURN_INVALID_PARAMETER ResetDataSize is NULL. + @retval RETURN_INVALID_PARAMETER ResetData is NULL. + @retval RETURN_INVALID_PARAMETER ExtraData was provided without a + ResetSubtype. This is not support= ed by the + UEFI spec. + @retval RETURN_BUFFER_TOO_SMALL An insufficient buffer was provid= ed. + ResetDataSize is updated with min= imum size + required. +**/ +RETURN_STATUS +EFIAPI +BuildResetData ( + IN OUT UINTN *ResetDataSize, + IN OUT VOID *ResetData, + IN CONST GUID *ResetSubtype OPTIONAL, + IN CONST CHAR16 *ResetString OPTIONAL, + IN UINTN ExtraDataSize OPTIONAL, + IN CONST VOID *ExtraData OPTIONAL + ); + +#endif // _RESET_UTILITY_LIB_H_ diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c b/MdeModul= ePkg/Library/ResetUtilityLib/ResetUtility.c new file mode 100644 index 0000000000..5bbe002be0 --- /dev/null +++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c @@ -0,0 +1,221 @@ +/** @file + This contains the business logic for the module-specific Reset Helper fu= nctions. + + Copyright (c) 2017 Intel Corporation. All rights reserved.
+ Copyright (c) 2016 Microsoft Corporation. All rights reserved.
+ + This program and the accompanying materials are licensed and made availa= ble under + the terms and conditions of the BSD License that accompanies this distri= bution. + The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ +#include +#include +#include +#include +#include + +typedef struct { + CHAR16 NullTerminator; + GUID ResetSubtype; +} RESET_UTILITY_GUID_SPECIFIC_RESET_DATA; + +/** + This is a shorthand helper function to reset with a subtype so that + the caller doesn't have to bother with a function that has half a dozen + parameters. + + This will generate a reset with status EFI_SUCCESS, a NULL string, and + no custom data. The subtype will be formatted in such a way that it can = be + picked up by notification registrations and custom handlers. + + NOTE: This call will fail if the architectural ResetSystem underpinnings + are not initialized. For DXE, you can add gEfiResetArchProtocolGuid + to your DEPEX. + + @param[in] ResetType Base reset type as defined in UEFI spec. + @param[in] ResetSubtype GUID pointer for the reset subtype to be used. + +**/ +VOID +EFIAPI +ResetPlatformSpecificGuid ( + IN CONST GUID *ResetSubtype + ) +{ + RESET_UTILITY_GUID_SPECIFIC_RESET_DATA ResetData; + + ResetData.NullTerminator =3D CHAR_NULL; + CopyGuid (&ResetData.ResetSubtype, ResetSubtype); + ResetPlatformSpecific (sizeof (ResetData), &ResetData); +} + +/** + This function examines the DataSize and ResetData parameters passed to + to ResetSystem() and detemrines if the ResetData contains a Null-termina= ted + Unicode string followed by a GUID specific subtype. If the GUID specifi= c=20 + subtype is present, then a pointer to the GUID value in ResetData is ret= urned. + + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData Pointer to the data buffer passed into ResetSyst= em(). + + @retval Pointer Pointer to the GUID value in ResetData. + @retval NULL ResetData is NULL. + @retval NULL ResetData does not start with a Null-terminated + Unicode string. + @retval NULL A Null-terminated Unicode string is present, but= there + are less than sizeof (GUID) bytes after the stri= ng. + @retval NULL No subtype is found. + +**/ +GUID * +EFIAPI +GetResetPlatformSpecificGuid ( + IN UINTN DataSize, + IN CONST VOID *ResetData + ) +{ + UINTN ResetDataStringSize; + GUID *ResetSubtypeGuid; + + // + // Make sure parameters are valid + // + if ((ResetData =3D=3D NULL) || (DataSize < sizeof (GUID))) { + return NULL; + } + + // + // Determine the number of bytes in in the Null-terminated Unicode string + // at the beginning of ResetData including the Null terminator. + // + ResetDataStringSize =3D StrnSizeS (ResetData, (DataSize / sizeof (CHAR16= ))); + + // + // Now, assuming that we have enough data for a GUID after the string, t= he + // GUID should be immediately after the string itself. + // + if ((ResetDataStringSize < DataSize) && (DataSize - ResetDataStringSize)= >=3D sizeof (GUID)) { + ResetSubtypeGuid =3D (GUID *)((UINT8 *)ResetData + ResetDataStringSize= ); + DEBUG ((DEBUG_VERBOSE, __FUNCTION__" - Detected reset subtype %g...\n"= , ResetSubtypeGuid)); + return ResetSubtypeGuid; + } + return NULL; +} + +/** + This is a helper function that creates the reset data buffer that can be=20 + passed into ResetSystem(). + + The reset data buffer is returned in ResetData and contains ResetString + followed by the ResetSubtype GUID followed by the ExtraData. + + NOTE: Strings are internally limited by MAX_UINT16. + + @param[in, out] ResetDataSize On input, the size of the ResetData buffe= r. On + output, either the total number of bytes + copied, or the required buffer size. + @param[in, out] ResetData A pointer to the buffer in which to place= the + final structure. + @param[in] ResetSubtype Pointer to the GUID specific subtype. Th= is + parameter is optional and may be NULL. + @param[in] ResetString Pointer to a Null-terminated Unicode stri= ng + that describes the reset. This parameter= is + optional and may be NULL. + @param[in] ExtraDataSize The size, in bytes, of ExtraData buffer. + @param[in] ExtraData Pointer to a buffer of extra data. This + parameter is optional and may be NULL. + + @retval RETURN_SUCCESS ResetDataSize and ResetData are u= pdated. + @retval RETURN_INVALID_PARAMETER ResetDataSize is NULL. + @retval RETURN_INVALID_PARAMETER ResetData is NULL. + @retval RETURN_INVALID_PARAMETER ExtraData was provided without a + ResetSubtype. This is not support= ed by the + UEFI spec. + @retval RETURN_BUFFER_TOO_SMALL An insufficient buffer was provid= ed. + ResetDataSize is updated with min= imum size + required. +**/ +RETURN_STATUS +EFIAPI +BuildResetData ( + IN OUT UINTN *ResetDataSize, + IN OUT VOID *ResetData, + IN CONST GUID *ResetSubtype OPTIONAL, + IN CONST CHAR16 *ResetString OPTIONAL, + IN UINTN ExtraDataSize OPTIONAL, + IN CONST VOID *ExtraData OPTIONAL + ) +{ + UINTN ResetStringSize; + UINTN ResetDataBufferSize; + UINT8 *Data; + + // + // If the size return pointer is NULL. + // + if (ResetDataSize =3D=3D NULL) { + return RETURN_INVALID_PARAMETER; + } + // + // If extra data is indicated, but pointer is NULL. + // + if (ExtraDataSize > 0 && ExtraData =3D=3D NULL) { + return RETURN_INVALID_PARAMETER; + } + // + // If extra data is indicated, but no subtype GUID is supplied. + // + if (ResetSubtype =3D=3D NULL && ExtraDataSize > 0) { + return RETURN_INVALID_PARAMETER; + } + + // + // Determine the final string. + // + if (ResetString =3D=3D NULL) { + ResetString =3D L""; // Use an empty string. + } + =20 + // + // Calculate the total buffer required for ResetData. + // + ResetStringSize =3D StrnSizeS (ResetString, MAX_UINT16); + ResetDataBufferSize =3D ResetStringSize + ExtraDataSize; + if (ResetSubtype !=3D NULL) { + ResetDataBufferSize +=3D sizeof (GUID); + } + + // + // At this point, if the buffer isn't large enough (or if + // the buffer is NULL) we cannot proceed. + // + if (*ResetDataSize < ResetDataBufferSize) { + *ResetDataSize =3D ResetDataBufferSize; + return RETURN_BUFFER_TOO_SMALL; + } + *ResetDataSize =3D ResetDataBufferSize; + if (ResetData =3D=3D NULL) { + return RETURN_INVALID_PARAMETER; + } + + // + // Fill in ResetData with ResetString, the ResetSubtype GUID, and extra = data + // + Data =3D (UINT8 *)ResetData; + CopyMem (Data, ResetString, ResetStringSize); + Data +=3D ResetStringSize; + if (ResetSubtype !=3D NULL) { + CopyMem (Data, ResetSubtype, sizeof (GUID)); + Data +=3D sizeof (GUID); + } + if (ExtraDataSize > 0) { + CopyMem (Data, ExtraData, ExtraDataSize); + } + =20 + return RETURN_SUCCESS; +} diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf b/Mde= ModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf new file mode 100644 index 0000000000..7a403749c5 --- /dev/null +++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf @@ -0,0 +1,43 @@ +## @file +# This file contains the Reset Utility functions. +# +# The application pops up a menu showing all the boot options referenced = by +# BootOrder NV variable and user can choose to boot from one of them. +# =20 +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2016, Microsoft Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# =20 +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# =20 +## +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D ResetUtilityLib + FILE_GUID =3D CAFC3CA1-3E32-449F-9B0E-40BA3CB73A12 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D ResetUtilityLib + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + ResetUtility.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + BaseLib + DebugLib + BaseMemoryLib + ResetSystemLib diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index dd7e9d5988..d96bff90b0 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -285,13 +285,16 @@ [Components] MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf + MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol= .inf MdeModulePkg/Library/PeiCrc32GuidedSectionExtractLib/PeiCrc32GuidedSecti= onExtractLib.inf MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf + MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf + MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.i= nf MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.i= nf @@ -358,6 +361,10 @@ [Components] MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf MdeModulePkg/Universal/Metronome/Metronome.inf MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf + MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf { + + ResetSystemLib|MdeModulePkg/Library/BaseResetSystemLibNull/BaseReset= SystemLibNull.inf + } MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 09:14:36 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 1517553958297927.9035517744034; Thu, 1 Feb 2018 22:45:58 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 346A8223AF81A; Thu, 1 Feb 2018 22:40:06 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 11C6C223AF814 for ; Thu, 1 Feb 2018 22:40:04 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 22:45:42 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 01 Feb 2018 22:45:41 -0800 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.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,447,1511856000"; d="scan'208";a="14900520" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Feb 2018 14:45:28 +0800 Message-Id: <20180202064530.407028-9-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180202064530.407028-1-ruiyu.ni@intel.com> References: <20180202064530.407028-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 08/10] MdePkg/UefiRuntimeLib: Support more module types. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng , Liming Gao 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" Because DxeResetSystemLib links to this library to provide reset system services, change UefiRuntimeLib to support the same set of module types as what DxeResetSystemLib does. Cc: Liming Gao Cc: Michael D Kinney Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni --- MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf b/MdePkg/Libr= ary/UefiRuntimeLib/UefiRuntimeLib.inf index 8f46495fc5..d053da545a 100644 --- a/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf +++ b/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf @@ -5,7 +5,7 @@ # EVT_SIGNAL_EXIT_BOOT_SERVICES event, to provide runtime services. # This instance also supports SAL drivers for better performance. # -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License @@ -24,7 +24,7 @@ [Defines] FILE_GUID =3D b1ee6c28-54aa-4d17-b705-3e28ccb27b2e MODULE_TYPE =3D DXE_RUNTIME_DRIVER VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D UefiRuntimeLib|DXE_RUNTIME_DRIVER DXE= _SAL_DRIVER + LIBRARY_CLASS =3D UefiRuntimeLib|DXE_RUNTIME_DRIVER DXE= _SAL_DRIVER DXE_CORE DXE_DRIVER DXE_SMM_DRIVER=20 =20 CONSTRUCTOR =3D RuntimeDriverLibConstruct DESTRUCTOR =3D RuntimeDriverLibDeconstruct --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 09:14:36 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 1517553961134642.2310873700072; Thu, 1 Feb 2018 22:46:01 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9F42D223AF81F; Thu, 1 Feb 2018 22:40:06 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 1B3032238B5BF for ; Thu, 1 Feb 2018 22:40:05 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 22:45:43 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 01 Feb 2018 22:45:42 -0800 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.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,447,1511856000"; d="scan'208";a="14900529" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Feb 2018 14:45:29 +0800 Message-Id: <20180202064530.407028-10-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180202064530.407028-1-ruiyu.ni@intel.com> References: <20180202064530.407028-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 09/10] MdeModulePkg: Add ResetSystemPei PEIM X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng , Liming Gao 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" This driver implements Reset2, ResetFilter and ResetHandler PPIs. Cc: Liming Gao Cc: Michael D Kinney Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni --- MdeModulePkg/MdeModulePkg.dec | 4 + .../Universal/ResetSystemPei/ResetSystem.c | 355 +++++++++++++++++= ++++ .../Universal/ResetSystemPei/ResetSystem.h | 129 ++++++++ .../Universal/ResetSystemPei/ResetSystemPei.inf | 62 ++++ .../Universal/ResetSystemPei/ResetSystemPei.uni | 20 ++ .../ResetSystemPei/ResetSystemPeiExtra.uni | 20 ++ 6 files changed, 590 insertions(+) create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExt= ra.uni diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 1cc9bc8ea1..1b971d599f 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1419,6 +1419,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule] # @Prompt CapsuleMax value in capsule report variable. gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax|0xFFFF|UINT16|0x00000107 =20 + ## Indicates the allowable maximum number of Reset Filters or Reset Hand= lers in PEI phase. + # @Prompt Maximum Number of PEI Reset Filters or Reset Handlers. + gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies|0x10|UINT32|0x= 00000109 + [PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] ## This PCD defines the Console output row. The default value is 25 acco= rding to UEFI spec. # This PCD could be set to 0 then console output would be at max column= and max row. diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c b/MdeModul= ePkg/Universal/ResetSystemPei/ResetSystem.c new file mode 100644 index 0000000000..720593de6a --- /dev/null +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c @@ -0,0 +1,355 @@ +/** @file + Implementation of Reset2, ResetFilter and ResetHandler PPIs. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include "ResetSystem.h" + +GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] =3D { + L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific" +}; + +EFI_PEI_RESET2_PPI mPpiReset2 =3D { + ResetSystem2 +}; + +EFI_GUID *mProcessingOrder[] =3D { + &gEdkiiPlatformSpecificResetFilterPpiGuid, + &gEdkiiPlatformSpecificResetHandlerPpiGuid +}; + +RESET_FILTER_INSTANCE mResetFilter =3D { + { + RegisterResetNotify, + UnregisterResetNotify + }, + &gEdkiiPlatformSpecificResetFilterPpiGuid +}; + +RESET_FILTER_INSTANCE mResetHandler =3D { + { + RegisterResetNotify, + UnregisterResetNotify + }, + &gEdkiiPlatformSpecificResetHandlerPpiGuid +}; + +EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] =3D { + { + EFI_PEI_PPI_DESCRIPTOR_PPI, + &gEfiPeiReset2PpiGuid, + &mPpiReset2 + }, + { + EFI_PEI_PPI_DESCRIPTOR_PPI, + &gEdkiiPlatformSpecificResetFilterPpiGuid, + &mResetFilter.ResetFilter + }, + { + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, + &gEdkiiPlatformSpecificResetHandlerPpiGuid, + &mResetHandler.ResetFilter + } +}; + +/** + Register a notification function to be called when ResetSystem() is call= ed. + + The RegisterResetNotify() function registers a notification function tha= t is called when + ResetSystem()is called and prior to completing the reset of the platform. + The registered functions must not perform a platform reset themselves. T= hese + notifications are intended only for the notification of components which= may need some + special-purpose maintenance prior to the platform resetting. + The list of registered reset notification functions are processed if Res= etSystem()is called + before ExitBootServices(). The list of registered reset notification fun= ctions is ignored if + ResetSystem()is called after ExitBootServices(). + + @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PR= OTOCOL instance. + @param[in] ResetFunction Points to the function to be called when a= ResetSystem() is executed. + + @retval EFI_SUCCESS The reset notification function was succes= sfully registered. + @retval EFI_INVALID_PARAMETER ResetFunction is NULL. + @retval EFI_OUT_OF_RESOURCES There are not enough resources available t= o register the reset notification function. + @retval EFI_ALREADY_STARTED The reset notification function specified = by ResetFunction has already been registered. + +**/ +EFI_STATUS +EFIAPI +RegisterResetNotify ( + IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This, + IN EFI_RESET_SYSTEM ResetFunction + ) +{ + RESET_FILTER_INSTANCE *ResetFilter; + RESET_FILTER_LIST *List; + VOID *Hob; + UINTN Index; + + if (ResetFunction =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + ResetFilter =3D (RESET_FILTER_INSTANCE *) This; + ASSERT (CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetFilt= erPpiGuid) || + CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetHand= lerPpiGuid) + ); + + Hob =3D GetFirstGuidHob (ResetFilter->Guid); + if (Hob =3D=3D NULL) { + // + // When the GUIDed HOB doesn't exist, create it. + // + List =3D (RESET_FILTER_LIST *)BuildGuidHob ( + ResetFilter->Guid, + sizeof (RESET_FILTER_LIST) + sizeof (EFI= _RESET_SYSTEM) * PcdGet32 (PcdMaximumPeiResetNotifies) + ); + if (List =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + List->Signature =3D RESET_FILTER_LIST_SIGNATURE; + List->Count =3D PcdGet32 (PcdMaximumPeiResetNotifies); + ZeroMem (List->ResetFilters, sizeof (EFI_RESET_SYSTEM) * List->Count); + List->ResetFilters[0] =3D ResetFunction; + return EFI_SUCCESS; + } else { + List =3D (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob); + ASSERT (List->Signature =3D=3D RESET_FILTER_LIST_SIGNATURE); + // + // Firstly check whether the ResetFunction is already registerred. + // + for (Index =3D 0; Index < List->Count; Index++) { + if (List->ResetFilters[Index] =3D=3D ResetFunction) { + break; + } + } + if (Index !=3D List->Count) { + return EFI_ALREADY_STARTED; + } + + // + // Secondly find the first free slot. + // + for (Index =3D 0; Index < List->Count; Index++) { + if (List->ResetFilters[Index] =3D=3D NULL) { + break; + } + } + + if (Index =3D=3D List->Count) { + return EFI_OUT_OF_RESOURCES; + } + List->ResetFilters[Index] =3D ResetFunction; + return EFI_SUCCESS; + } +} + +/** + Unregister a notification function. + + The UnregisterResetNotify() function removes the previously registered + notification using RegisterResetNotify(). + + @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PR= OTOCOL instance. + @param[in] ResetFunction The pointer to the ResetFunction being unr= egistered. + + @retval EFI_SUCCESS The reset notification function was unregi= stered. + @retval EFI_INVALID_PARAMETER ResetFunction is NULL. + @retval EFI_INVALID_PARAMETER The reset notification function specified = by ResetFunction was not previously + registered using RegisterResetNotify(). + +**/ +EFI_STATUS +EFIAPI +UnregisterResetNotify ( + IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This, + IN EFI_RESET_SYSTEM ResetFunction + ) +{ + + RESET_FILTER_INSTANCE *ResetFilter; + RESET_FILTER_LIST *List; + VOID *Hob; + UINTN Index; + + if (ResetFunction =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + ResetFilter =3D (RESET_FILTER_INSTANCE *)This; + ASSERT (CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetFilt= erPpiGuid) || + CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetHandlerPpi= Guid) + ); + + Hob =3D GetFirstGuidHob (ResetFilter->Guid); + if (Hob =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + List =3D (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob); + ASSERT (List->Signature =3D=3D RESET_FILTER_LIST_SIGNATURE); + for (Index =3D 0; Index < List->Count; Index++) { + if (List->ResetFilters[Index] =3D=3D ResetFunction) { + break; + } + } + + if (Index =3D=3D List->Count) { + return EFI_INVALID_PARAMETER; + } + + List->ResetFilters[Index] =3D NULL; + return EFI_SUCCESS; +} + + +/** + The PEIM's entry point. + + It initializes the Reset2, ResetFilter and ResetHandler PPIs. + + @param[in] FileHandle Handle of the file being invoked. + @param[in] PeiServices Describes the list of possible PEI Services. + =20 + @retval EFI_SUCCESS The entry point is executed successfully. + @retval EFI_ALREADY_STARTED The Reset2 PPI was already installed. + @retval others Status code returned from PeiServicesInstall= Ppi(). + +**/ +EFI_STATUS +EFIAPI +InitializeResetSystem ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + VOID *Ppi; + + Status =3D PeiServicesLocatePpi (&gEfiPeiReset2PpiGuid, 0, NULL, (VOID *= *)&Ppi); + if (Status !=3D EFI_NOT_FOUND) { + return EFI_ALREADY_STARTED; + } + + PeiServicesInstallPpi (mPpiListReset); + + return Status; +} + +/** + Resets the entire platform. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatus The status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetW= arm, or + EfiResetShutdown the data buffer starts wi= th a Null-terminated + string, optionally followed by additional = binary data. + The string is a description that the calle= r may use to further + indicate the reason for the system reset. = ResetData is only + valid if ResetStatus is something other th= an EFI_SUCCESS + unless the ResetType is EfiResetPlatformSp= ecific + where a minimum amount of ResetData is alw= ays required. + For a ResetType of EfiResetPlatformSpecifi= c the data buffer + also starts with a Null-terminated string = that is followed + by an EFI_GUID that describes the specific= type of reset to perform. +**/ +VOID +EFIAPI +ResetSystem2 ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL + ) +{ + VOID *Hob; + UINTN Index; + RESET_FILTER_LIST *List; + UINTN OrderIndex; + UINT8 RecursionDepth; + UINT8 *RecursionDepthPointer; + + // + // The recursion depth is stored in GUIDed HOB using gEfiCallerIdGuid. + // + Hob =3D GetFirstGuidHob (&gEfiCallerIdGuid); + if (Hob =3D=3D NULL) { + RecursionDepth =3D 0; + RecursionDepthPointer =3D BuildGuidDataHob (&gEfiCallerIdGuid, &Recurs= ionDepth, sizeof (RecursionDepth)); + } else { + RecursionDepthPointer =3D (UINT8 *)GET_GUID_HOB_DATA (Hob); + } + // + // Only do REPORT_STATUS_CODE() on first call to ResetSystem() + // + if (*RecursionDepthPointer =3D=3D 0) { + // + // Indicate reset system runtime service is called. + // + REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVI= CE | EFI_SW_RS_PC_RESET_SYSTEM)); + } + + // + // Increase the call depth + // + (*RecursionDepthPointer)++; + DEBUG ((DEBUG_INFO, "PEI ResetSystem2: Reset call depth =3D %d.\n", *Rec= ursionDepthPointer)); + + if (*RecursionDepthPointer <=3D MAX_RESET_NOTIFY_DEPTH) { + // + // Iteratively call Reset Filters and Reset Handlers. + // + for (OrderIndex =3D 0; OrderIndex < ARRAY_SIZE (mProcessingOrder); Ord= erIndex++) { + Hob =3D GetFirstGuidHob (mProcessingOrder[OrderIndex]); + if (Hob !=3D NULL) { + List =3D (RESET_FILTER_LIST *)GET_GUID_HOB_DATA (Hob); + ASSERT (List->Signature =3D=3D RESET_FILTER_LIST_SIGNATURE); + + for (Index =3D 0; Index < List->Count; Index++) { + if (List->ResetFilters[Index] !=3D NULL) { + List->ResetFilters[Index] (ResetType, ResetStatus, DataSize, R= esetData); + } + } + } + } + } else { + ASSERT (ResetType < ARRAY_SIZE (mResetTypeStr)); + DEBUG ((DEBUG_ERROR, "PEI ResetSystem2: Maximum reset call depth is me= t. Use the current reset type: %s!\n", mResetTypeStr[ResetType])); + } + + switch (ResetType) { + case EfiResetWarm: + ResetWarm (); + break; + + case EfiResetCold: + ResetCold (); + break; + + case EfiResetShutdown: + ResetShutdown (); + return ; + + case EfiResetPlatformSpecific: + ResetPlatformSpecific (DataSize, ResetData); + return; + + default: + return ; + } + + // + // Given we should have reset getting here would be bad + // + ASSERT (FALSE); +} diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h b/MdeModul= ePkg/Universal/ResetSystemPei/ResetSystem.h new file mode 100644 index 0000000000..2fcc3592b6 --- /dev/null +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h @@ -0,0 +1,129 @@ +/** @file + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#ifndef _RESET_SYSTEM2_H_ +#define _RESET_SYSTEM2_H_ + + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +// +// The maximum recurstion depth to ResetSystem() by reset notification han= dlers +// +#define MAX_RESET_NOTIFY_DEPTH 10 + +// +// Data to put in GUIDed HOB +// +typedef struct { + UINT32 Signature; + UINT32 Count; + EFI_RESET_SYSTEM ResetFilters[0]; // ResetFilters[PcdGet3= 2 (PcdMaximumResetNotifies)] +} RESET_FILTER_LIST; +#define RESET_FILTER_LIST_SIGNATURE SIGNATURE_32('r', 's', 't', 'l') + + +typedef struct { + EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI ResetFilter; + EFI_GUID *Guid; +} RESET_FILTER_INSTANCE; + +/** + Resets the entire platform. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatus The status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetW= arm, or + EfiResetShutdown the data buffer starts wi= th a Null-terminated + string, optionally followed by additional = binary data. + The string is a description that the calle= r may use to further + indicate the reason for the system reset. = ResetData is only + valid if ResetStatus is something other th= an EFI_SUCCESS + unless the ResetType is EfiResetPlatformSp= ecific + where a minimum amount of ResetData is alw= ays required. + For a ResetType of EfiResetPlatformSpecifi= c the data buffer + also starts with a Null-terminated string = that is followed + by an EFI_GUID that describes the specific= type of reset to perform. + +**/ +VOID +EFIAPI +ResetSystem2 ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL + ); +/** + Register a notification function to be called when ResetSystem() is call= ed. + + The RegisterResetNotify() function registers a notification function tha= t is called when + ResetSystem()is called and prior to completing the reset of the platform. + The registered functions must not perform a platform reset themselves. T= hese + notifications are intended only for the notification of components which= may need some + special-purpose maintenance prior to the platform resetting. + + @param[in] This A pointer to the EDKII_PLATFORM_SPECIFIC_R= ESET_FILTER_PPI instance. + @param[in] ResetFunction Points to the function to be called when a= ResetSystem() is executed. + + @retval EFI_SUCCESS The reset notification function was succes= sfully registered. + @retval EFI_INVALID_PARAMETER ResetFunction is NULL. + @retval EFI_OUT_OF_RESOURCES There are not enough resources available t= o register the reset notification function. + @retval EFI_ALREADY_STARTED The reset notification function specified = by ResetFunction has already been registered. + +**/ +EFI_STATUS +EFIAPI +RegisterResetNotify ( + IN EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI *This, + IN EFI_RESET_SYSTEM ResetFunction + ); + +/** + Unregister a notification function. + + The UnregisterResetNotify() function removes the previously registered + notification using RegisterResetNotify(). + + @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PR= OTOCOL instance. + @param[in] ResetFunction The pointer to the ResetFunction being unr= egistered. + + @retval EFI_SUCCESS The reset notification function was unregi= stered. + @retval EFI_INVALID_PARAMETER ResetFunction is NULL. + @retval EFI_INVALID_PARAMETER The reset notification function specified = by ResetFunction was not previously + registered using RegisterResetNotify(). + +**/ +EFI_STATUS +EFIAPI +UnregisterResetNotify ( + IN EFI_RESET_NOTIFICATION_PROTOCOL *This, + IN EFI_RESET_SYSTEM ResetFunction + ); +#endif diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf b/Mde= ModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf new file mode 100644 index 0000000000..38fdd16ceb --- /dev/null +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf @@ -0,0 +1,62 @@ +## @file +# This driver implements Reset2, ResetFilter and ResetHandler PPIs. +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials are +# licensed and made available under the terms and conditions of the BSD Li= cense +# which accompanies this distribution. The full text of the license may b= e found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D ResetSystemPei + MODULE_UNI_FILE =3D ResetSystemPei.uni + FILE_GUID =3D 6141E486-7543-4F1A-A579-FF532ED78E75 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + + ENTRY_POINT =3D InitializeResetSystem + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + ResetSystem.h + ResetSystem.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PeiServicesLib + HobLib + PeimEntryPoint + ResetSystemLib + ReportStatusCodeLib + +[Ppis] + gEfiPeiReset2PpiGuid ## PRODUCES + gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES + gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + ResetSystemPeiExtra.uni diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni b/Mde= ModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni new file mode 100644 index 0000000000..6d2d650c37 --- /dev/null +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni @@ -0,0 +1,20 @@ +// /** @file +// This driver implements Reset2, ResetFilter and ResetHandler PPIs. +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials are +// licensed and made available under the terms and conditions of the BSD L= icense +// which accompanies this distribution. The full text of the license may = be found at +// http://opensource.org/licenses/bsd-license.php +//=20 +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Implements Reset2= , ResetFilter and ResetHandler PPIs" + +#string STR_MODULE_DESCRIPTION #language en-US "This driver imple= ments Reset2, ResetFilter and ResetHandler PPIs." + diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni = b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni new file mode 100644 index 0000000000..2681afc707 --- /dev/null +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// ResetSystemPei Localized Strings and Content +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials are +// licensed and made available under the terms and conditions of the BSD L= icense +// which accompanies this distribution. The full text of the license may = be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME=20 +#language en-US=20 +"Reset System PEIM" + + --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 09:14:36 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 1517553993943498.858541036896; Thu, 1 Feb 2018 22:46:33 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 19CAC223AF823; Thu, 1 Feb 2018 22:40:08 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 62280223AF81C for ; Thu, 1 Feb 2018 22:40:06 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 22:45:44 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 01 Feb 2018 22:45:43 -0800 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.120; helo=mga04.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,447,1511856000"; d="scan'208";a="14900538" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Feb 2018 14:45:30 +0800 Message-Id: <20180202064530.407028-11-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180202064530.407028-1-ruiyu.ni@intel.com> References: <20180202064530.407028-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 10/10] MdeModulePkg/ResetSystemPei: Add reset notifications in PEI X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng , Liming Gao 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" From: Bret Barkelew The Reset Notification protocol is added in UEFI spec to support reset notification mechanism in the DXE phase. This patch adds similar EDKII specific Reset Notification PPI to PEI phase to provide the same support. Cc: Liming Gao Cc: Michael D Kinney Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bret Barkelew Signed-off-by: Ruiyu Ni --- .../Ppi/PlatformSpecificResetNotification.h | 31 ++++++++++++++++++= ++++ MdeModulePkg/MdeModulePkg.dec | 3 +++ .../Universal/ResetSystemPei/ResetSystem.c | 16 +++++++++++ .../Universal/ResetSystemPei/ResetSystem.h | 1 + .../Universal/ResetSystemPei/ResetSystemPei.inf | 7 ++--- 5 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 MdeModulePkg/Include/Ppi/PlatformSpecificResetNotificat= ion.h diff --git a/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h b= /MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h new file mode 100644 index 0000000000..ea53e24133 --- /dev/null +++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h @@ -0,0 +1,31 @@ +/** @file + This PPI provides services to register a platform specific notification = callback for + ResetSystem(). The registered handlers are processed after + EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI notifications. + + Copyright (c) 2017 Intel Corporation. All rights reserved.
+ Copyright (c) 2017 Microsoft Corporation. All rights reserved.
+ + This program and the accompanying materials are licensed and made availa= ble under + the terms and conditions of the BSD License that accompanies this distri= bution. + The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#ifndef _PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_H_ +#define _PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_H_ + +#include + +#define EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_GUID \ + { 0xe09f355d, 0xdae8, 0x4910, { 0xb1, 0x4a, 0x92, 0x78, 0x0f, 0xdc, 0xf7= , 0xcb } } + +typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_NOT= IFICATION_PPI; + +extern EFI_GUID gEdkiiPlatformSpecificResetNotificationPpiGuid; + +#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 1b971d599f..297b02ffa9 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -444,6 +444,9 @@ [Ppis] ## Include/Ppi/PlatformSpecificResetFilter.h gEdkiiPlatformSpecificResetFilterPpiGuid =3D { 0x8c9f4de3, 0x7b90, 0x47e= f, { 0x93, 0x8, 0x28, 0x7c, 0xec, 0xd6, 0x6d, 0xe8 } } =20 + ## Include/Ppi/PlatformSpecificResetNotification.h + gEdkiiPlatformSpecificResetNotificationPpiGuid =3D { 0xe09f355d, 0xdae8,= 0x4910, { 0xb1, 0x4a, 0x92, 0x78, 0xf, 0xdc, 0xf7, 0xcb } } + ## Include/Ppi/PlatformSpecificResetHandler.h gEdkiiPlatformSpecificResetHandlerPpiGuid =3D { 0x75cf14ae, 0x3441, 0x49= dc, { 0xaa, 0x10, 0xbb, 0x35, 0xa7, 0xba, 0x8b, 0xab } } =20 diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c b/MdeModul= ePkg/Universal/ResetSystemPei/ResetSystem.c index 720593de6a..4dfe303f77 100644 --- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c @@ -25,6 +25,7 @@ EFI_PEI_RESET2_PPI mPpiReset2 =3D { =20 EFI_GUID *mProcessingOrder[] =3D { &gEdkiiPlatformSpecificResetFilterPpiGuid, + &gEdkiiPlatformSpecificResetNotificationPpiGuid, &gEdkiiPlatformSpecificResetHandlerPpiGuid }; =20 @@ -36,6 +37,14 @@ RESET_FILTER_INSTANCE mResetFilter =3D { &gEdkiiPlatformSpecificResetFilterPpiGuid }; =20 +RESET_FILTER_INSTANCE mResetNotification =3D { + { + RegisterResetNotify, + UnregisterResetNotify + }, + &gEdkiiPlatformSpecificResetNotificationPpiGuid +}; + RESET_FILTER_INSTANCE mResetHandler =3D { { RegisterResetNotify, @@ -55,6 +64,11 @@ EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] =3D { &gEdkiiPlatformSpecificResetFilterPpiGuid, &mResetFilter.ResetFilter }, + { + EFI_PEI_PPI_DESCRIPTOR_PPI, + &gEdkiiPlatformSpecificResetNotificationPpiGuid, + &mResetNotification.ResetFilter + }, { EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, &gEdkiiPlatformSpecificResetHandlerPpiGuid, @@ -101,6 +115,7 @@ RegisterResetNotify ( =20 ResetFilter =3D (RESET_FILTER_INSTANCE *) This; ASSERT (CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetFilt= erPpiGuid) || + CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetNoti= ficationPpiGuid) || CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetHand= lerPpiGuid) ); =20 @@ -187,6 +202,7 @@ UnregisterResetNotify ( =20 ResetFilter =3D (RESET_FILTER_INSTANCE *)This; ASSERT (CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetFilt= erPpiGuid) || + CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetNotificati= onPpiGuid) || CompareGuid (ResetFilter->Guid, &gEdkiiPlatformSpecificResetHandlerPpi= Guid) ); =20 diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h b/MdeModul= ePkg/Universal/ResetSystemPei/ResetSystem.h index 2fcc3592b6..b623a4c381 100644 --- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h @@ -21,6 +21,7 @@ =20 #include #include +#include #include =20 #include diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf b/Mde= ModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf index 38fdd16ceb..a88e2018b7 100644 --- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf @@ -48,9 +48,10 @@ [LibraryClasses] ReportStatusCodeLib =20 [Ppis] - gEfiPeiReset2PpiGuid ## PRODUCES - gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES - gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES + gEfiPeiReset2PpiGuid ## PRODUCES + gEdkiiPlatformSpecificResetFilterPpiGuid ## PRODUCES + gEdkiiPlatformSpecificResetHandlerPpiGuid ## PRODUCES + gEdkiiPlatformSpecificResetNotificationPpiGuid ## PRODUCES =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel