2 SMM CPU Rendezvous sevice implement.
4 Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/BaseLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/MmServicesTableLib.h>
14 #include <Protocol/SmmCpuService.h>
15 #include <Library/SmmCpuRendezvousLib.h>
17 STATIC EDKII_SMM_CPU_RENDEZVOUS_PROTOCOL
*mSmmCpuRendezvous
= NULL
;
18 STATIC VOID
*mRegistration
= NULL
;
21 Callback function to wait Smm cpu rendezvous service located.
23 SmmCpuRendezvousLib need to support MM_STANDALONE and DXE_SMM_DRIVER driver.
24 So do not use library constructor to locate the protocol.
26 @param[in] Protocol Points to the protocol's unique identifier.
27 @param[in] Interface Points to the interface instance.
28 @param[in] Handle The handle on which the interface was installed.
30 @retval EFI_SUCCESS Notification runs successfully.
35 SmmCpuRendezvousProtocolNotify (
36 IN CONST EFI_GUID
*Protocol
,
43 Status
= gMmst
->MmLocateProtocol (
44 &gEdkiiSmmCpuRendezvousProtocolGuid
,
46 (VOID
**)&mSmmCpuRendezvous
48 ASSERT_EFI_ERROR (Status
);
54 This routine wait for all AP processors to arrive in SMM.
56 @param[in] BlockingMode Blocking mode or non-blocking mode.
58 @retval EFI_SUCCESS All avaiable APs arrived.
59 @retval EFI_TIMEOUT Wait for all APs until timeout.
60 @retval OTHER Fail to register SMM CPU Rendezvous service Protocol.
64 SmmWaitForAllProcessor (
65 IN BOOLEAN BlockingMode
70 if ((mRegistration
== NULL
) && (mSmmCpuRendezvous
== NULL
)) {
72 // Locate SMM cpu rendezvous protocol for the first time execute the function.
74 Status
= gMmst
->MmLocateProtocol (
75 &gEdkiiSmmCpuRendezvousProtocolGuid
,
77 (VOID
**)&mSmmCpuRendezvous
79 if (EFI_ERROR (Status
)) {
80 Status
= gMmst
->MmRegisterProtocolNotify (
81 &gEdkiiSmmCpuRendezvousProtocolGuid
,
82 SmmCpuRendezvousProtocolNotify
,
85 if (EFI_ERROR (Status
)) {
92 // The platform have not set up. It doesn't need smm cpu rendezvous.
94 if (mSmmCpuRendezvous
== NULL
) {
98 Status
= mSmmCpuRendezvous
->WaitForAllProcessor (