From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 DBC5E22361E48 for ; Thu, 8 Feb 2018 20:10:54 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Feb 2018 20:16:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,481,1511856000"; d="scan'208";a="199842746" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.37]) by orsmga005.jf.intel.com with ESMTP; 08 Feb 2018 20:16:39 -0800 From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 9 Feb 2018 12:16:25 +0800 Message-Id: <20180209041635.320856-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [PATCH v2 00/10] Formalize the reset system core design 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: , X-List-Received-Date: Fri, 09 Feb 2018 04:10:55 -0000 The patches add/update two core modules that perform the reset action ResetSystemPei and ResetSystemRuntimeDxe With the two core modules, every time a reset action is performed in either PEI phase or DXE phase, the accordingly registerred reset filter/notification/handler will be triggered. Reset filters are processed first so the final reset type and reset data can be determined. Reset Notifications are processed second so all components that have registered for a Reset Notification can perform any required clean up actions. Reset handlers are processed third. If there are no registered reset handlers or none of them resets the platform, then the default reset action based on the ResetSystemLib is performed. The v2 changes against v2 are attached in the end of this mail. Bret Barkelew (1): MdeModulePkg/ResetSystemPei: Add reset notifications in PEI Michael D Kinney (6): MdePkg/PeiServicesLib: Add PeiServicesResetSystem2() MdeModulePkg/PeiMain: Always attempt to use Reset2 PPI first MdeModulePkg/PeiMain: Cleanup whitespace in Reset.c MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler MdeModulePkg: Add ResetSystemLib instances that call core services MdeModulePkg: Add ResetUtility librray class and BASE instance Ruiyu Ni (3): MdeModulePkg/ResetSystemRuntimeDxe: Add more debug message MdePkg/UefiRuntimeLib: Support more module types. MdeModulePkg: Add ResetSystemPei PEIM MdeModulePkg/Core/Pei/Reset/Reset.c | 67 ++-- MdeModulePkg/Include/Library/ResetUtilityLib.h | 111 ++++++ .../Include/Ppi/PlatformSpecificResetFilter.h | 31 ++ .../Include/Ppi/PlatformSpecificResetHandler.h | 29 ++ .../Ppi/PlatformSpecificResetNotification.h | 32 ++ .../Include/Protocol/PlatformSpecificResetFilter.h | 31 ++ .../Protocol/PlatformSpecificResetHandler.h | 29 ++ .../Library/DxeResetSystemLib/DxeResetSystemLib.c | 98 ++++++ .../DxeResetSystemLib/DxeResetSystemLib.inf | 39 +++ .../DxeResetSystemLib/DxeResetSystemLib.uni | 21 ++ .../Library/PeiResetSystemLib/PeiResetSystemLib.c | 98 ++++++ .../PeiResetSystemLib/PeiResetSystemLib.inf | 39 +++ .../PeiResetSystemLib/PeiResetSystemLib.uni | 21 ++ .../Library/ResetUtilityLib/ResetUtility.c | 220 ++++++++++++ .../Library/ResetUtilityLib/ResetUtilityLib.inf | 40 +++ MdeModulePkg/MdeModulePkg.dec | 20 ++ MdeModulePkg/MdeModulePkg.dsc | 7 + MdeModulePkg/MdeModulePkg.uni | 7 +- .../Universal/ResetSystemPei/ResetSystem.c | 371 +++++++++++++++++++++ .../Universal/ResetSystemPei/ResetSystem.h | 130 ++++++++ .../ResetSystemPei.inf} | 45 ++- .../Universal/ResetSystemPei/ResetSystemPei.uni | 20 ++ .../ResetSystemPei/ResetSystemPeiExtra.uni | 20 ++ .../Universal/ResetSystemRuntimeDxe/ResetSystem.c | 91 ++++- .../Universal/ResetSystemRuntimeDxe/ResetSystem.h | 7 + .../ResetSystemRuntimeDxe.inf | 7 +- MdePkg/Include/Library/PeiServicesLib.h | 24 ++ MdePkg/Library/PeiServicesLib/PeiServicesLib.c | 26 ++ MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf | 4 +- 29 files changed, 1615 insertions(+), 70 deletions(-) create mode 100644 MdeModulePkg/Include/Library/ResetUtilityLib.h create mode 100644 MdeModulePkg/Include/Ppi/PlatformSpecificResetFilter.h create mode 100644 MdeModulePkg/Include/Ppi/PlatformSpecificResetHandler.h create mode 100644 MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h create mode 100644 MdeModulePkg/Include/Protocol/PlatformSpecificResetFilter.h create mode 100644 MdeModulePkg/Include/Protocol/PlatformSpecificResetHandler.h create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h copy MdeModulePkg/Universal/{ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf => ResetSystemPei/ResetSystemPei.inf} (50%) create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni diff --git a/MdeModulePkg/Include/Ppi/PlatformSpecificResetFilter.h b/MdeModulePkg/Include/Ppi/PlatformSpecificResetFilter.h index 0f1432f5f8..1f728387b7 100644 --- a/MdeModulePkg/Include/Ppi/PlatformSpecificResetFilter.h +++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetFilter.h @@ -3,9 +3,9 @@ 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. + EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI handlers. - Copyright (c) 2017 Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2018 Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at diff --git a/MdeModulePkg/Include/Ppi/PlatformSpecificResetHandler.h b/MdeModulePkg/Include/Ppi/PlatformSpecificResetHandler.h index d5f1350c69..8d938abb02 100644 --- a/MdeModulePkg/Include/Ppi/PlatformSpecificResetHandler.h +++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetHandler.h @@ -1,9 +1,9 @@ /** @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. + EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI notifications. - Copyright (c) 2017 Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2018 Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at diff --git a/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h index ea53e24133..cf6d1f18a6 100644 --- a/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h +++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h @@ -1,9 +1,10 @@ /** @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. + EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI notifications and before + EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI notifications. - Copyright (c) 2017 Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2018 Intel Corporation. All rights reserved.
Copyright (c) 2017 Microsoft Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c index 70ee1175d5..ea452e3231 100644 --- a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c @@ -1,7 +1,7 @@ /** @file DXE Reset System Library instance that calls gRT->ResetSystem(). - Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
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 @@ -13,9 +13,7 @@ **/ #include - #include -#include #include /** diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf index f2e04cfd00..6eb2766b93 100644 --- a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf @@ -1,7 +1,7 @@ ## @file # DXE Reset System Library instance that calls gRT->ResetSystem(). # -# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -35,6 +35,5 @@ [Packages] MdeModulePkg/MdeModulePkg.dec [LibraryClasses] - DebugLib UefiRuntimeLib diff --git a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c index b7e10110b0..30225d73a5 100644 --- a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c +++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c @@ -1,7 +1,7 @@ /** @file PEI Reset System Library instance that calls the ResetSystem2() PEI Service. - Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
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 @@ -13,9 +13,7 @@ **/ #include - #include -#include #include /** diff --git a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf index e82ec6b2b6..b1b9388c63 100644 --- a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf +++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf @@ -1,7 +1,7 @@ ## @file # PEI Reset System Library instance that calls the ResetSystem2() PEI Service. # -# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -35,6 +35,5 @@ [Packages] MdeModulePkg/MdeModulePkg.dec [LibraryClasses] - DebugLib PeiServicesLib diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c index 5bbe002be0..90de94ca9b 100644 --- a/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c +++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c @@ -37,7 +37,6 @@ typedef struct { 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. **/ @@ -90,7 +89,7 @@ GetResetPlatformSpecificGuid ( } // - // Determine the number of bytes in in the Null-terminated Unicode string + // Determine the number of bytes in the Null-terminated Unicode string // at the beginning of ResetData including the Null terminator. // ResetDataStringSize = StrnSizeS (ResetData, (DataSize / sizeof (CHAR16))); diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf b/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf index 7a403749c5..2a4e53a8a6 100644 --- a/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf +++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf @@ -1,10 +1,7 @@ ## @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. -# -# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2018, 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 BSD License diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 297b02ffa9..0695ce607e 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -54,6 +54,9 @@ [LibraryClasses] ## @libraryclass Defines a set of methods to reset whole system. ResetSystemLib|Include/Library/ResetSystemLib.h + ## @libraryclass Defines a set of helper functions for resetting the system. + ResetUtilityLib|Include/Library/ResetUtilityLib.h + ## @libraryclass Defines a set of methods related do S3 mode. # This library class is no longer used and modules using this library should # directly locate EFI_PEI_S3_RESUME_PPI defined in PI 1.2 specification. @@ -1422,8 +1425,8 @@ [PcdsFixedAtBuild, PcdsPatchableInModule] # @Prompt CapsuleMax value in capsule report variable. gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax|0xFFFF|UINT16|0x00000107 - ## Indicates the allowable maximum number of Reset Filters or Reset Handlers in PEI phase. - # @Prompt Maximum Number of PEI Reset Filters or Reset Handlers. + ## Indicates the allowable maximum number of Reset Filters, Reset Notifications or Reset Handlers in PEI phase. + # @Prompt Maximum Number of PEI Reset Filters, Reset Notifications or Reset Handlers. gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies|0x10|UINT32|0x00000109 [PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni index 0e068422e4..d8cc7416c5 100644 --- a/MdeModulePkg/MdeModulePkg.uni +++ b/MdeModulePkg/MdeModulePkg.uni @@ -4,7 +4,7 @@ // It also provides the definitions(including PPIs/PROTOCOLs/GUIDs and library classes) // and libraries instances, which are used for those modules. // -// Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
// // This program and the accompanying materials are licensed and made available under // the terms and conditions of the BSD License that accompanies this distribution. @@ -1059,6 +1059,11 @@ #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdCapsuleMax_HELP #language en-US "CapsuleMax value in capsule report variable." +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMaximumPeiResetNotifies_PROMPT #language en-US "Maximum Number of PEI Reset Filters, Reset Notifications or Reset Handlers." + +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMaximumPeiResetNotifies_HELP #language en-US "Indicates the allowable maximum number of Reset Filters,
\n" + "Reset Notifications or Reset Handlers in PEI phase." + #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdRecoveryFileName_PROMPT #language en-US "Recover file name in PEI phase" #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdRecoveryFileName_HELP #language en-US "This is recover file name in PEI phase.\n" diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c index 4dfe303f77..c2ee592d56 100644 --- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c @@ -80,13 +80,13 @@ EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] = { Register a notification function to be called when ResetSystem() is called. The RegisterResetNotify() function registers a notification function that is called when - ResetSystem()is called and prior to completing the reset of the platform. + ResetSystem() is called and prior to completing the reset of the platform. The registered functions must not perform a platform reset themselves. These 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 ResetSystem()is called before ExitBootServices(). The list of registered reset notification functions is ignored if - ResetSystem()is called after ExitBootServices(). + ResetSystem() is called after ExitBootServices(). @param[in] This A pointer to the EFI_RESET_NOTIFICATION_PROTOCOL instance. @param[in] ResetFunction Points to the function to be called when a ResetSystem() is executed. @@ -312,7 +312,7 @@ ResetSystem2 ( // // Indicate reset system runtime service is called. // - REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM)); + REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_PEI_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM)); } // diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h index b623a4c381..8e9f872056 100644 --- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h +++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -34,7 +34,7 @@ // -// The maximum recurstion depth to ResetSystem() by reset notification handlers +// The maximum recursion depth to ResetSystem() by reset notification handlers // #define MAX_RESET_NOTIFY_DEPTH 10 diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c index 4b5af76999..2c795426f5 100644 --- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c +++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c @@ -294,7 +294,7 @@ ResetSystem ( } // // call reset notification functions registered through the - // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL. + // EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL. // for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies) ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link) -- 2.16.1.windows.1