]>
Commit | Line | Data |
---|---|---|
4a68176c LZ |
1 | /** @file\r |
2 | SMM CPU Rendezvous sevice implement.\r | |
3 | \r | |
4 | Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | \r | |
9 | #include <Base.h>\r | |
10 | #include <Uefi.h>\r | |
11 | #include <Library/BaseLib.h>\r | |
12 | #include <Library/DebugLib.h>\r | |
13 | #include <Library/MmServicesTableLib.h>\r | |
14 | #include <Protocol/SmmCpuService.h>\r | |
15 | #include <Library/SmmCpuRendezvousLib.h>\r | |
16 | \r | |
17 | STATIC EDKII_SMM_CPU_RENDEZVOUS_PROTOCOL *mSmmCpuRendezvous = NULL;\r | |
18 | STATIC VOID *mRegistration = NULL;\r | |
19 | \r | |
20 | /**\r | |
21 | Callback function to wait Smm cpu rendezvous service located.\r | |
22 | \r | |
23 | SmmCpuRendezvousLib need to support MM_STANDALONE and DXE_SMM_DRIVER driver.\r | |
24 | So do not use library constructor to locate the protocol.\r | |
25 | \r | |
26 | @param[in] Protocol Points to the protocol's unique identifier.\r | |
27 | @param[in] Interface Points to the interface instance.\r | |
28 | @param[in] Handle The handle on which the interface was installed.\r | |
29 | \r | |
30 | @retval EFI_SUCCESS Notification runs successfully.\r | |
31 | \r | |
32 | **/\r | |
33 | EFI_STATUS\r | |
34 | EFIAPI\r | |
35 | SmmCpuRendezvousProtocolNotify (\r | |
36 | IN CONST EFI_GUID *Protocol,\r | |
37 | IN VOID *Interface,\r | |
38 | IN EFI_HANDLE Handle\r | |
39 | )\r | |
40 | {\r | |
41 | EFI_STATUS Status;\r | |
42 | \r | |
43 | Status = gMmst->MmLocateProtocol (\r | |
44 | &gEdkiiSmmCpuRendezvousProtocolGuid,\r | |
45 | NULL,\r | |
46 | (VOID **)&mSmmCpuRendezvous\r | |
47 | );\r | |
48 | ASSERT_EFI_ERROR (Status);\r | |
49 | \r | |
50 | return EFI_SUCCESS;\r | |
51 | }\r | |
52 | \r | |
53 | /**\r | |
54 | This routine wait for all AP processors to arrive in SMM.\r | |
55 | \r | |
56 | @param[in] BlockingMode Blocking mode or non-blocking mode.\r | |
57 | \r | |
58 | @retval EFI_SUCCESS All avaiable APs arrived.\r | |
59 | @retval EFI_TIMEOUT Wait for all APs until timeout.\r | |
60 | @retval OTHER Fail to register SMM CPU Rendezvous service Protocol.\r | |
61 | **/\r | |
62 | EFI_STATUS\r | |
63 | EFIAPI\r | |
64 | SmmWaitForAllProcessor (\r | |
65 | IN BOOLEAN BlockingMode\r | |
66 | )\r | |
67 | {\r | |
68 | EFI_STATUS Status;\r | |
69 | \r | |
70 | if ((mRegistration == NULL) && (mSmmCpuRendezvous == NULL)) {\r | |
71 | //\r | |
72 | // Locate SMM cpu rendezvous protocol for the first time execute the function.\r | |
73 | //\r | |
74 | Status = gMmst->MmLocateProtocol (\r | |
75 | &gEdkiiSmmCpuRendezvousProtocolGuid,\r | |
76 | NULL,\r | |
77 | (VOID **)&mSmmCpuRendezvous\r | |
78 | );\r | |
79 | if (EFI_ERROR (Status)) {\r | |
80 | Status = gMmst->MmRegisterProtocolNotify (\r | |
81 | &gEdkiiSmmCpuRendezvousProtocolGuid,\r | |
82 | SmmCpuRendezvousProtocolNotify,\r | |
83 | &mRegistration\r | |
84 | );\r | |
85 | if (EFI_ERROR (Status)) {\r | |
86 | return Status;\r | |
87 | }\r | |
88 | }\r | |
89 | }\r | |
90 | \r | |
91 | //\r | |
92 | // The platform have not set up. It doesn't need smm cpu rendezvous.\r | |
93 | //\r | |
94 | if (mSmmCpuRendezvous == NULL) {\r | |
95 | return EFI_SUCCESS;\r | |
96 | }\r | |
97 | \r | |
98 | Status = mSmmCpuRendezvous->WaitForAllProcessor (\r | |
99 | mSmmCpuRendezvous,\r | |
100 | BlockingMode\r | |
101 | );\r | |
102 | return Status;\r | |
103 | }\r |