/** @file\r
Reset Architectural and Reset Notification protocols implementation.\r
\r
- Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
\r
#include "ResetSystem.h"\r
\r
+GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = {\r
+ L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific"\r
+};\r
+\r
+//\r
+// The current ResetSystem() notification recursion depth\r
+//\r
+UINTN mResetNotifyDepth = 0;\r
+\r
/**\r
Register a notification function to be called when ResetSystem() is called.\r
\r
INITIALIZE_LIST_HEAD_VARIABLE (mResetNotification.ResetNotifies)\r
};\r
\r
+RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetFilter = {\r
+ RESET_NOTIFICATION_INSTANCE_SIGNATURE,\r
+ {\r
+ RegisterResetNotify,\r
+ UnregisterResetNotify\r
+ },\r
+ INITIALIZE_LIST_HEAD_VARIABLE (mPlatformSpecificResetFilter.ResetNotifies)\r
+};\r
+\r
+RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetHandler = {\r
+ RESET_NOTIFICATION_INSTANCE_SIGNATURE,\r
+ {\r
+ RegisterResetNotify,\r
+ UnregisterResetNotify\r
+ },\r
+ INITIALIZE_LIST_HEAD_VARIABLE (mPlatformSpecificResetHandler.ResetNotifies)\r
+};\r
+\r
/**\r
The driver's entry point.\r
\r
It initializes the Reset Architectural Protocol.\r
\r
- @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
@param[in] SystemTable A pointer to the EFI System Table.\r
- \r
+\r
@retval EFI_SUCCESS The entry point is executed successfully.\r
@retval other Cannot install ResetArch protocol.\r
\r
&Handle,\r
&gEfiResetArchProtocolGuid, NULL,\r
&gEfiResetNotificationProtocolGuid, &mResetNotification.ResetNotification,\r
+ &gEdkiiPlatformSpecificResetFilterProtocolGuid, &mPlatformSpecificResetFilter.ResetNotification,\r
+ &gEdkiiPlatformSpecificResetHandlerProtocolGuid, &mPlatformSpecificResetHandler.ResetNotification,\r
NULL\r
);\r
ASSERT_EFI_ERROR (Status);\r
}\r
\r
/**\r
- Put the system into S3 power state. \r
+ Put the system into S3 power state.\r
**/\r
VOID\r
DoS3 (\r
valid if ResetStatus is something other than EFI_SUCCESS\r
unless the ResetType is EfiResetPlatformSpecific\r
where a minimum amount of ResetData is always required.\r
+ For a ResetType of EfiResetPlatformSpecific the data buffer\r
+ also starts with a Null-terminated string that is followed\r
+ by an EFI_GUID that describes the specific type of reset to perform.\r
**/\r
VOID\r
EFIAPI\r
UINTN CapsuleDataPtr;\r
LIST_ENTRY *Link;\r
RESET_NOTIFY_ENTRY *Entry;\r
- \r
+\r
//\r
- // Indicate reset system runtime service is called.\r
+ // Only do REPORT_STATUS_CODE() on first call to ResetSystem()\r
//\r
- REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));\r
-\r
- if (!EfiAtRuntime ()) {\r
- for ( Link = GetFirstNode (&mResetNotification.ResetNotifies)\r
- ; !IsNull (&mResetNotification.ResetNotifies, Link)\r
- ; Link = GetNextNode (&mResetNotification.ResetNotifies, Link)\r
- ) {\r
- Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);\r
- Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);\r
+ if (mResetNotifyDepth == 0) {\r
+ //\r
+ // Indicate reset system runtime service is called.\r
+ //\r
+ REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));\r
+ }\r
+\r
+ mResetNotifyDepth++;\r
+ DEBUG ((\r
+ DEBUG_INFO, "DXE ResetSystem2: ResetType %s, Call Depth = %d.\n",\r
+ mResetTypeStr[ResetType], mResetNotifyDepth\r
+ ));\r
+\r
+ if (mResetNotifyDepth <= MAX_RESET_NOTIFY_DEPTH) {\r
+ if (!EfiAtRuntime ()) {\r
+ //\r
+ // Call reset notification functions registered through the\r
+ // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL.\r
+ //\r
+ for ( Link = GetFirstNode (&mPlatformSpecificResetFilter.ResetNotifies)\r
+ ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link)\r
+ ; Link = GetNextNode (&mPlatformSpecificResetFilter.ResetNotifies, Link)\r
+ ) {\r
+ Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);\r
+ Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);\r
+ }\r
+ //\r
+ // Call reset notification functions registered through the\r
+ // EFI_RESET_NOTIFICATION_PROTOCOL.\r
+ //\r
+ for ( Link = GetFirstNode (&mResetNotification.ResetNotifies)\r
+ ; !IsNull (&mResetNotification.ResetNotifies, Link)\r
+ ; Link = GetNextNode (&mResetNotification.ResetNotifies, Link)\r
+ ) {\r
+ Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);\r
+ Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);\r
+ }\r
+ //\r
+ // call reset notification functions registered through the\r
+ // EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL.\r
+ //\r
+ for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies)\r
+ ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)\r
+ ; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, Link)\r
+ ) {\r
+ Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);\r
+ Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);\r
+ }\r
}\r
+ } else {\r
+ ASSERT (ResetType < ARRAY_SIZE (mResetTypeStr));\r
+ DEBUG ((DEBUG_ERROR, "DXE ResetSystem2: Maximum reset call depth is met. Use the current reset type: %s!\n", mResetTypeStr[ResetType]));\r
}\r
\r
switch (ResetType) {\r
}\r
\r
ResetWarm ();\r
-\r
break;\r
\r
case EfiResetCold:\r