diff options
author | Michael D Kinney <michael.d.kinney@intel.com> | 2017-09-01 00:51:08 -0700 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2018-02-09 15:29:56 +0800 |
commit | 99a6529e1ed38606bb5330895cba64cc98aa3e26 (patch) | |
tree | 0f8be6a10006a706d1afba987538737099c34aad /MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c | |
parent | 8f86d67d464da4d3bf3437575bfd2409da4c800e (diff) | |
download | edk2-99a6529e1ed38606bb5330895cba64cc98aa3e26.zip edk2-99a6529e1ed38606bb5330895cba64cc98aa3e26.tar.gz edk2-99a6529e1ed38606bb5330895cba64cc98aa3e26.tar.bz2 |
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/ResetSystem.c')
-rw-r--r-- | MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c | 75 |
1 files changed, 71 insertions, 4 deletions
diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c index 75cff37..fed527f 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) {
|