/** @file\r
Implementation of SMM CPU Services Protocol.\r
\r
-Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2022, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
SmmRegisterExceptionHandler\r
};\r
\r
+//\r
+// EDKII SMM CPU Rendezvous Service Protocol instance\r
+//\r
+EDKII_SMM_CPU_RENDEZVOUS_PROTOCOL mSmmCpuRendezvousService = {\r
+ SmmCpuRendezvous\r
+};\r
+\r
/**\r
Gets processor information on the requested processor at the instant this call is made.\r
\r
@param ImageHandle The firmware allocated handle for the EFI image.\r
\r
@retval EFI_SUCCESS EFI SMM CPU Services Protocol was installed successfully.\r
+ @retval OTHER Fail to install Protocol.\r
**/\r
EFI_STATUS\r
InitializeSmmCpuServices (\r
&mSmmCpuService\r
);\r
ASSERT_EFI_ERROR (Status);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ Status = gSmst->SmmInstallProtocolInterface (\r
+ &Handle,\r
+ &gEdkiiSmmCpuRendezvousProtocolGuid,\r
+ EFI_NATIVE_INTERFACE,\r
+ &mSmmCpuRendezvousService\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Wait for all processors enterring SMM until all CPUs are already synchronized or not.\r
+\r
+ If BlockingMode is False, timeout value is zero.\r
+\r
+ @param This A pointer to the EDKII_SMM_CPU_RENDEZVOUS_PROTOCOL instance.\r
+ @param BlockingMode Blocking mode or non-blocking mode.\r
+\r
+ @retval EFI_SUCCESS All avaiable APs arrived.\r
+ @retval EFI_TIMEOUT Wait for all APs until timeout.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmCpuRendezvous (\r
+ IN EDKII_SMM_CPU_RENDEZVOUS_PROTOCOL *This,\r
+ IN BOOLEAN BlockingMode\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Return success immediately if all CPUs are already synchronized.\r
+ //\r
+ if (mSmmMpSyncData->AllApArrivedWithException) {\r
+ Status = EFI_SUCCESS;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ if (!BlockingMode) {\r
+ Status = EFI_TIMEOUT;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ //\r
+ // There are some APs outside SMM, Wait for all avaiable APs to arrive.\r
+ //\r
+ SmmWaitForApArrival ();\r
+ Status = mSmmMpSyncData->AllApArrivedWithException ? EFI_SUCCESS : EFI_TIMEOUT;\r
+\r
+ON_EXIT:\r
+ if (!mSmmMpSyncData->AllApArrivedWithException) {\r
+ DEBUG ((DEBUG_INFO, "EdkiiSmmWaitForAllApArrival: Timeout to wait all APs arrival\n"));\r
+ }\r
+\r
return Status;\r
}\r