summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/ResetSystemRuntimeDxe
diff options
context:
space:
mode:
authorMichael D Kinney <michael.d.kinney@intel.com>2017-09-01 00:51:08 -0700
committerRuiyu Ni <ruiyu.ni@intel.com>2018-02-09 15:29:56 +0800
commit99a6529e1ed38606bb5330895cba64cc98aa3e26 (patch)
tree0f8be6a10006a706d1afba987538737099c34aad /MdeModulePkg/Universal/ResetSystemRuntimeDxe
parent8f86d67d464da4d3bf3437575bfd2409da4c800e (diff)
downloadedk2-99a6529e1ed38606bb5330895cba64cc98aa3e26.tar.gz
edk2-99a6529e1ed38606bb5330895cba64cc98aa3e26.tar.bz2
edk2-99a6529e1ed38606bb5330895cba64cc98aa3e26.zip
MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler
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 and handlers are registered through the following 2 PPIs that are based on EFI_RESET_NOTIFICATION_PROTOCOL. * gEdkiiPlatformSpecificResetFilterPpiGuid * gEdkiiPlatformSpecificResetHandlerPpiGuid In the DXE Phase, filters and handlers are registered through the following 2 Protocols that are based on EFI_RESET_NOTIFICATION_PROTOCOL. * gEdkiiPlatformSpecificResetFilterProtocolGuid * gEdkiiPlatformSpecificResetHandlerProtocolGuid Cc: Liming Gao <liming.gao@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Diffstat (limited to 'MdeModulePkg/Universal/ResetSystemRuntimeDxe')
-rw-r--r--MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c75
-rw-r--r--MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h7
-rw-r--r--MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf7
3 files changed, 82 insertions, 7 deletions
diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
index 75cff37773..fed527fac2 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
@@ -15,6 +15,11 @@
#include "ResetSystem.h"
+//
+// The current ResetSystem() notification recursion depth
+//
+UINTN mResetNotifyDepth = 0;
+
/**
Register a notification function to be called when ResetSystem() is called.
@@ -130,6 +135,24 @@ RESET_NOTIFICATION_INSTANCE mResetNotification = {
INITIALIZE_LIST_HEAD_VARIABLE (mResetNotification.ResetNotifies)
};
+RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetFilter = {
+ RESET_NOTIFICATION_INSTANCE_SIGNATURE,
+ {
+ RegisterResetNotify,
+ UnregisterResetNotify
+ },
+ INITIALIZE_LIST_HEAD_VARIABLE (mPlatformSpecificResetFilter.ResetNotifies)
+};
+
+RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetHandler = {
+ RESET_NOTIFICATION_INSTANCE_SIGNATURE,
+ {
+ RegisterResetNotify,
+ UnregisterResetNotify
+ },
+ INITIALIZE_LIST_HEAD_VARIABLE (mPlatformSpecificResetHandler.ResetNotifies)
+};
+
/**
The driver's entry point.
@@ -170,6 +193,8 @@ InitializeResetSystem (
&Handle,
&gEfiResetArchProtocolGuid, NULL,
&gEfiResetNotificationProtocolGuid, &mResetNotification.ResetNotification,
+ &gEdkiiPlatformSpecificResetFilterProtocolGuid, &mPlatformSpecificResetFilter.ResetNotification,
+ &gEdkiiPlatformSpecificResetHandlerProtocolGuid, &mPlatformSpecificResetHandler.ResetNotification,
NULL
);
ASSERT_EFI_ERROR (Status);
@@ -225,13 +250,44 @@ ResetSystem (
UINTN CapsuleDataPtr;
LIST_ENTRY *Link;
RESET_NOTIFY_ENTRY *Entry;
-
+
+ //
+ // Above the maximum recursion depth, so do the smallest amount of
+ // work to perform a cold reset.
+ //
+ if (mResetNotifyDepth >= 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 == 0) {
+ //
+ // Indicate reset system runtime service is called.
+ //
+ REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));
+ }
- 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 = GetFirstNode (&mPlatformSpecificResetFilter.ResetNotifies)
+ ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link)
+ ; Link = GetNextNode (&mPlatformSpecificResetFilter.ResetNotifies, Link)
+ ) {
+ Entry = 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 = GetFirstNode (&mResetNotification.ResetNotifies)
; !IsNull (&mResetNotification.ResetNotifies, Link)
; Link = GetNextNode (&mResetNotification.ResetNotifies, Link)
@@ -239,6 +295,17 @@ ResetSystem (
Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
}
+ //
+ // call reset notification functions registered through the
+ // EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL.
+ //
+ for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies)
+ ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)
+ ; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, Link)
+ ) {
+ Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
+ Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
+ }
}
switch (ResetType) {
diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
index 75cdd88896..ea5660274b 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
@@ -20,6 +20,8 @@
#include <Protocol/Reset.h>
#include <Protocol/ResetNotification.h>
+#include <Protocol/PlatformSpecificResetFilter.h>
+#include <Protocol/PlatformSpecificResetHandler.h>
#include <Guid/CapsuleVendor.h>
#include <Library/BaseLib.h>
@@ -34,6 +36,11 @@
#include <Library/ReportStatusCodeLib.h>
#include <Library/MemoryAllocationLib.h>
+//
+// The maximum recurstion depth to ResetSystem() by reset notification handlers
+//
+#define MAX_RESET_NOTIFY_DEPTH 10
+
typedef struct {
UINT32 Signature;
LIST_ENTRY Link;
diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
index 11233757c2..da9e8e118b 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
@@ -55,9 +55,10 @@
[Protocols]
- gEfiResetArchProtocolGuid ## PRODUCES
- gEfiResetNotificationProtocolGuid ## PRODUCES
-
+ gEfiResetArchProtocolGuid ## PRODUCES
+ gEfiResetNotificationProtocolGuid ## PRODUCES
+ gEdkiiPlatformSpecificResetFilterProtocolGuid ## PRODUCES
+ gEdkiiPlatformSpecificResetHandlerProtocolGuid ## PRODUCES
[Depex]
TRUE