--- /dev/null
+/** @file\r
+ This PPI provides services to register a platform specific reset filter\r
+ for ResetSystem(). A reset filter evaluates the parameters passed to\r
+ ResetSystem() and converts a ResetType of EfiResetPlatformSpecific to a\r
+ non-platform specific reset type. The registered filters are processed before\r
+ EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI handlers.\r
+\r
+ Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials are licensed and made available under\r
+ the terms and conditions of the BSD License that accompanies this distribution.\r
+ The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _PLATFORM_SPECIFIC_RESET_FILTER_PPI_H_\r
+#define _PLATFORM_SPECIFIC_RESET_FILTER_PPI_H_\r
+\r
+#include <Protocol/ResetNotification.h>\r
+\r
+#define EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI_GUID \\r
+ { 0x8c9f4de3, 0x7b90, 0x47ef, { 0x93, 0x8, 0x28, 0x7c, 0xec, 0xd6, 0x6d, 0xe8 } }\r
+\r
+typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI;\r
+\r
+extern EFI_GUID gEdkiiPlatformSpecificResetFilterPpiGuid;\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ This PPI provides services to register a platform specific handler for\r
+ ResetSystem(). The registered handlers are processed after\r
+ EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI notifications.\r
+\r
+ Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials are licensed and made available under\r
+ the terms and conditions of the BSD License that accompanies this distribution.\r
+ The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _PLATFORM_SPECIFIC_RESET_HANDLER_PPI_H_\r
+#define _PLATFORM_SPECIFIC_RESET_HANDLER_PPI_H_\r
+\r
+#include <Protocol/ResetNotification.h>\r
+\r
+#define EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI_GUID \\r
+ { 0x75cf14ae, 0x3441, 0x49dc, { 0xaa, 0x10, 0xbb, 0x35, 0xa7, 0xba, 0x8b, 0xab } }\r
+\r
+typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI;\r
+\r
+extern EFI_GUID gEdkiiPlatformSpecificResetHandlerPpiGuid;\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ This Protocol provides services to register a platform specific reset filter\r
+ for ResetSystem(). A reset filter evaluates the parameters passed to\r
+ ResetSystem() and converts a ResetType of EfiResetPlatformSpecific to a\r
+ non-platform specific reset type. The registered filters are processed before\r
+ the UEFI 2.7 Reset Notifications.\r
+\r
+ Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials are licensed and made available under\r
+ the terms and conditions of the BSD License that accompanies this distribution.\r
+ The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL_H_\r
+#define _PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL_H_\r
+\r
+#include <Protocol/ResetNotification.h>\r
+\r
+#define EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL_GUID \\r
+ { 0x695d7835, 0x8d47, 0x4c11, { 0xab, 0x22, 0xfa, 0x8a, 0xcc, 0xe7, 0xae, 0x7a } }\r
+\r
+typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL;\r
+\r
+extern EFI_GUID gEdkiiPlatformSpecificResetFilterProtocolGuid;\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ This protocol provides services to register a platform specific handler for\r
+ ResetSystem(). The registered handlers are called after the UEFI 2.7 Reset\r
+ Notifications are processed\r
+\r
+ Copyright (c) 2017 Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials are licensed and made available under\r
+ the terms and conditions of the BSD License that accompanies this distribution.\r
+ The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL_H_\r
+#define _PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL_H_\r
+\r
+#include <Protocol/ResetNotification.h>\r
+\r
+#define EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL_GUID \\r
+ { 0x2df6ba0b, 0x7092, 0x440d, { 0xbd, 0x4, 0xfb, 0x9, 0x1e, 0xc3, 0xf3, 0xc1 } }\r
+\r
+typedef EFI_RESET_NOTIFICATION_PROTOCOL EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL;\r
+\r
+extern EFI_GUID gEdkiiPlatformSpecificResetHandlerProtocolGuid;\r
+\r
+#endif\r
## Include/Ppi/IoMmu.h\r
gEdkiiIoMmuPpiGuid = { 0x70b0af26, 0xf847, 0x4bb6, { 0xaa, 0xb9, 0xcd, 0xe8, 0x4f, 0xc6, 0x14, 0x31 } }\r
\r
+ ## Include/Ppi/PlatformSpecificResetFilter.h\r
+ gEdkiiPlatformSpecificResetFilterPpiGuid = { 0x8c9f4de3, 0x7b90, 0x47ef, { 0x93, 0x8, 0x28, 0x7c, 0xec, 0xd6, 0x6d, 0xe8 } }\r
+\r
+ ## Include/Ppi/PlatformSpecificResetHandler.h\r
+ gEdkiiPlatformSpecificResetHandlerPpiGuid = { 0x75cf14ae, 0x3441, 0x49dc, { 0xaa, 0x10, 0xbb, 0x35, 0xa7, 0xba, 0x8b, 0xab } }\r
+\r
[Protocols]\r
## Load File protocol provides capability to load and unload EFI image into memory and execute it.\r
# Include/Protocol/LoadPe32Image.h\r
## Include/Protocol/SdMmcOverride.h\r
gEdkiiSdMmcOverrideProtocolGuid = { 0xeaf9e3c1, 0xc9cd, 0x46db, { 0xa5, 0xe5, 0x5a, 0x12, 0x4c, 0x83, 0x23, 0x23 } }\r
\r
+ ## Include/Protocol/PlatformSpecificResetFilter.h\r
+ gEdkiiPlatformSpecificResetFilterProtocolGuid = { 0x695d7835, 0x8d47, 0x4c11, { 0xab, 0x22, 0xfa, 0x8a, 0xcc, 0xe7, 0xae, 0x7a } }\r
+ ## Include/Protocol/PlatformSpecificResetHandler.h\r
+ gEdkiiPlatformSpecificResetHandlerProtocolGuid = { 0x2df6ba0b, 0x7092, 0x440d, { 0xbd, 0x4, 0xfb, 0x9, 0x1e, 0xc3, 0xf3, 0xc1 } }\r
#\r
# [Error.gEfiMdeModulePkgTokenSpaceGuid]\r
# 0x80000001 | Invalid value provided.\r
\r
#include "ResetSystem.h"\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
&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
UINTN CapsuleDataPtr;\r
LIST_ENTRY *Link;\r
RESET_NOTIFY_ENTRY *Entry;\r
- \r
+\r
+ //\r
+ // Above the maximum recursion depth, so do the smallest amount of\r
+ // work to perform a cold reset.\r
+ //\r
+ if (mResetNotifyDepth >= MAX_RESET_NOTIFY_DEPTH) {\r
+ ResetCold ();\r
+ ASSERT (FALSE);\r
+ return;\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
+ 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
- if (!EfiAtRuntime ()) {\r
+ mResetNotifyDepth++;\r
+ if (!EfiAtRuntime () && mResetNotifyDepth < MAX_RESET_NOTIFY_DEPTH) {\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
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
\r
switch (ResetType) {\r
\r
#include <Protocol/Reset.h>\r
#include <Protocol/ResetNotification.h>\r
+#include <Protocol/PlatformSpecificResetFilter.h>\r
+#include <Protocol/PlatformSpecificResetHandler.h>\r
#include <Guid/CapsuleVendor.h>\r
\r
#include <Library/BaseLib.h>\r
#include <Library/ReportStatusCodeLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
\r
+//\r
+// The maximum recurstion depth to ResetSystem() by reset notification handlers\r
+//\r
+#define MAX_RESET_NOTIFY_DEPTH 10\r
+\r
typedef struct {\r
UINT32 Signature;\r
LIST_ENTRY Link;\r
\r
\r
[Protocols]\r
- gEfiResetArchProtocolGuid ## PRODUCES\r
- gEfiResetNotificationProtocolGuid ## PRODUCES\r
-\r
+ gEfiResetArchProtocolGuid ## PRODUCES\r
+ gEfiResetNotificationProtocolGuid ## PRODUCES\r
+ gEdkiiPlatformSpecificResetFilterProtocolGuid ## PRODUCES\r
+ gEdkiiPlatformSpecificResetHandlerProtocolGuid ## PRODUCES\r
\r
[Depex]\r
TRUE\r