From nobody Mon Dec 23 13:55:09 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