]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/MmMp.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Include / Protocol / MmMp.h
CommitLineData
18f169a9
ED
1/** @file\r
2 EFI MM MP Protocol is defined in the PI 1.5 specification.\r
3\r
4 The MM MP protocol provides a set of functions to allow execution of procedures on processors that\r
5 have entered MM. This protocol has the following properties:\r
6 1. The caller can only invoke execution of a procedure on a processor, other than the caller, that\r
7 has also entered MM.\r
8 2. It is possible to invoke a procedure on multiple processors. Supports blocking and non-blocking\r
9 modes of operation.\r
10\r
11 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
12 SPDX-License-Identifier: BSD-2-Clause-Patent\r
13\r
14**/\r
15\r
16#ifndef _MM_MP_H_\r
17#define _MM_MP_H_\r
18\r
19#include <Pi/PiMmCis.h>\r
20\r
21#define EFI_MM_MP_PROTOCOL_GUID \\r
22 { \\r
23 0x5d5450d7, 0x990c, 0x4180, {0xa8, 0x3, 0x8e, 0x63, 0xf0, 0x60, 0x83, 0x7 } \\r
24 }\r
25\r
26//\r
27// Revision definition.\r
28//\r
2f88bd3a 29#define EFI_MM_MP_PROTOCOL_REVISION 0x00\r
18f169a9
ED
30\r
31//\r
32// Attribute flags\r
33//\r
2f88bd3a 34#define EFI_MM_MP_TIMEOUT_SUPPORTED 0x01\r
18f169a9
ED
35\r
36//\r
37// Completion token\r
38//\r
2f88bd3a 39typedef VOID *MM_COMPLETION;\r
18f169a9
ED
40\r
41typedef struct {\r
2f88bd3a
MK
42 MM_COMPLETION Completion;\r
43 EFI_STATUS Status;\r
18f169a9
ED
44} MM_DISPATCH_COMPLETION_TOKEN;\r
45\r
2f88bd3a 46typedef struct _EFI_MM_MP_PROTOCOL EFI_MM_MP_PROTOCOL;\r
18f169a9
ED
47\r
48/**\r
49 Service to retrieves the number of logical processor in the platform.\r
50\r
51 @param[in] This The EFI_MM_MP_PROTOCOL instance.\r
52 @param[out] NumberOfProcessors Pointer to the total number of logical processors in the system,\r
53 including the BSP and all APs.\r
54\r
55 @retval EFI_SUCCESS The number of processors was retrieved successfully\r
56 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL\r
57**/\r
58typedef\r
59EFI_STATUS\r
2f88bd3a 60(EFIAPI *EFI_MM_GET_NUMBER_OF_PROCESSORS)(\r
18f169a9
ED
61 IN CONST EFI_MM_MP_PROTOCOL *This,\r
62 OUT UINTN *NumberOfProcessors\r
2f88bd3a 63 );\r
18f169a9
ED
64\r
65/**\r
66 This service allows the caller to invoke a procedure one of the application processors (AP). This\r
67 function uses an optional token parameter to support blocking and non-blocking modes. If the token\r
68 is passed into the call, the function will operate in a non-blocking fashion and the caller can\r
69 check for completion with CheckOnProcedure or WaitForProcedure.\r
70\r
71 @param[in] This The EFI_MM_MP_PROTOCOL instance.\r
72 @param[in] Procedure A pointer to the procedure to be run on the designated target\r
73 AP of the system. Type EFI_AP_PROCEDURE2 is defined below in\r
74 related definitions.\r
75 @param[in] CpuNumber The zero-based index of the processor number of the target\r
76 AP, on which the code stream is supposed to run. If the number\r
77 points to the calling processor then it will not run the\r
78 supplied code.\r
79 @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for this AP to\r
80 finish execution of Procedure, either for blocking or\r
81 non-blocking mode. Zero means infinity. If the timeout\r
82 expires before this AP returns from Procedure, then Procedure\r
83 on the AP is terminated. If the timeout expires in blocking\r
84 mode, the call returns EFI_TIMEOUT. If the timeout expires\r
85 in non-blocking mode, the timeout determined can be through\r
86 CheckOnProcedure or WaitForProcedure.\r
87 Note that timeout support is optional. Whether an\r
88 implementation supports this feature, can be determined via\r
89 the Attributes data member.\r
90 @param[in,out] ProcedureArguments Allows the caller to pass a list of parameters to the code\r
91 that is run by the AP. It is an optional common mailbox\r
92 between APs and the caller to share information.\r
93 @param[in,out] Token This is parameter is broken into two components:\r
94 1.Token->Completion is an optional parameter that allows the\r
95 caller to execute the procedure in a blocking or non-blocking\r
96 fashion. If it is NULL the call is blocking, and the call will\r
97 not return until the AP has completed the procedure. If the\r
98 token is not NULL, the call will return immediately. The caller\r
99 can check whether the procedure has completed with\r
100 CheckOnProcedure or WaitForProcedure.\r
101 2.Token->Status The implementation updates the address pointed\r
102 at by this variable with the status code returned by Procedure\r
103 when it completes execution on the target AP, or with EFI_TIMEOUT\r
104 if the Procedure fails to complete within the optional timeout.\r
105 The implementation will update this variable with EFI_NOT_READY\r
106 prior to starting Procedure on the target AP.\r
107 @param[in,out] CPUStatus This optional pointer may be used to get the status code returned\r
108 by Procedure when it completes execution on the target AP, or with\r
109 EFI_TIMEOUT if the Procedure fails to complete within the optional\r
110 timeout. The implementation will update this variable with\r
111 EFI_NOT_READY prior to starting Procedure on the target AP.\r
112\r
113 @retval EFI_SUCCESS In the blocking case, this indicates that Procedure has completed\r
114 execution on the target AP.\r
115 In the non-blocking case this indicates that the procedure has\r
116 been successfully scheduled for execution on the target AP.\r
117 @retval EFI_INVALID_PARAMETER The input arguments are out of range. Either the target AP is the\r
118 caller of the function, or the Procedure or Token is NULL\r
119 @retval EFI_NOT_READY If the target AP is busy executing another procedure\r
120 @retval EFI_ALREADY_STARTED Token is already in use for another procedure\r
121 @retval EFI_TIMEOUT In blocking mode, the timeout expired before the specified AP\r
122 has finished\r
123**/\r
124typedef\r
125EFI_STATUS\r
2f88bd3a 126(EFIAPI *EFI_MM_DISPATCH_PROCEDURE)(\r
18f169a9
ED
127 IN CONST EFI_MM_MP_PROTOCOL *This,\r
128 IN EFI_AP_PROCEDURE2 Procedure,\r
129 IN UINTN CpuNumber,\r
130 IN UINTN TimeoutInMicroseconds,\r
131 IN OUT VOID *ProcedureArguments OPTIONAL,\r
132 IN OUT MM_COMPLETION *Token,\r
133 IN OUT EFI_STATUS *CPUStatus\r
2f88bd3a 134 );\r
18f169a9
ED
135\r
136/**\r
137 This service allows the caller to invoke a procedure on all running application processors (AP)\r
138 except the caller. This function uses an optional token parameter to support blocking and\r
139 nonblocking modes. If the token is passed into the call, the function will operate in a non-blocking\r
140 fashion and the caller can check for completion with CheckOnProcedure or WaitForProcedure.\r
141\r
142 It is not necessary for the implementation to run the procedure on every processor on the platform.\r
143 Processors that are powered down in such a way that they cannot respond to interrupts, may be\r
144 excluded from the broadcast.\r
145\r
146\r
147 @param[in] This The EFI_MM_MP_PROTOCOL instance.\r
148 @param[in] Procedure A pointer to the code stream to be run on the APs that have\r
149 entered MM. Type EFI_AP_PROCEDURE is defined below in related\r
150 definitions.\r
151 @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for the APs to finish\r
152 execution of Procedure, either for blocking or non-blocking mode.\r
153 Zero means infinity. If the timeout expires before all APs return\r
154 from Procedure, then Procedure on the failed APs is terminated. If\r
155 the timeout expires in blocking mode, the call returns EFI_TIMEOUT.\r
156 If the timeout expires in non-blocking mode, the timeout determined\r
157 can be through CheckOnProcedure or WaitForProcedure.\r
158 Note that timeout support is optional. Whether an implementation\r
159 supports this feature can be determined via the Attributes data\r
160 member.\r
161 @param[in,out] ProcedureArguments Allows the caller to pass a list of parameters to the code\r
162 that is run by the AP. It is an optional common mailbox\r
163 between APs and the caller to share information.\r
164 @param[in,out] Token This is parameter is broken into two components:\r
165 1.Token->Completion is an optional parameter that allows the\r
166 caller to execute the procedure in a blocking or non-blocking\r
167 fashion. If it is NULL the call is blocking, and the call will\r
168 not return until the AP has completed the procedure. If the\r
169 token is not NULL, the call will return immediately. The caller\r
170 can check whether the procedure has completed with\r
171 CheckOnProcedure or WaitForProcedure.\r
172 2.Token->Status The implementation updates the address pointed\r
173 at by this variable with the status code returned by Procedure\r
174 when it completes execution on the target AP, or with EFI_TIMEOUT\r
175 if the Procedure fails to complete within the optional timeout.\r
176 The implementation will update this variable with EFI_NOT_READY\r
177 prior to starting Procedure on the target AP\r
178 @param[in,out] CPUStatus This optional pointer may be used to get the individual status\r
179 returned by every AP that participated in the broadcast. This\r
180 parameter if used provides the base address of an array to hold\r
181 the EFI_STATUS value of each AP in the system. The size of the\r
182 array can be ascertained by the GetNumberOfProcessors function.\r
183 As mentioned above, the broadcast may not include every processor\r
184 in the system. Some implementations may exclude processors that\r
185 have been powered down in such a way that they are not responsive\r
186 to interrupts. Additionally the broadcast excludes the processor\r
187 which is making the BroadcastProcedure call. For every excluded\r
188 processor, the array entry must contain a value of EFI_NOT_STARTED\r
189\r
190 @retval EFI_SUCCESS In the blocking case, this indicates that Procedure has completed\r
191 execution on the APs. In the non-blocking case this indicates that\r
192 the procedure has been successfully scheduled for execution on the\r
193 APs.\r
194 @retval EFI_INVALID_PARAMETER Procedure or Token is NULL.\r
195 @retval EFI_NOT_READY If a target AP is busy executing another procedure.\r
196 @retval EFI_TIMEOUT In blocking mode, the timeout expired before all enabled APs have\r
197 finished.\r
198 @retval EFI_ALREADY_STARTED Before the AP procedure associated with the Token is finished, the\r
199 same Token cannot be used to dispatch or broadcast another procedure.\r
200\r
201**/\r
202typedef\r
203EFI_STATUS\r
2f88bd3a 204(EFIAPI *EFI_MM_BROADCAST_PROCEDURE)(\r
18f169a9
ED
205 IN CONST EFI_MM_MP_PROTOCOL *This,\r
206 IN EFI_AP_PROCEDURE2 Procedure,\r
207 IN UINTN TimeoutInMicroseconds,\r
208 IN OUT VOID *ProcedureArguments OPTIONAL,\r
209 IN OUT MM_COMPLETION *Token,\r
210 IN OUT EFI_STATUS *CPUStatus\r
2f88bd3a 211 );\r
18f169a9
ED
212\r
213/**\r
214 This service allows the caller to set a startup procedure that will be executed when an AP powers\r
215 up from a state where core configuration and context is lost. The procedure is execution has the\r
216 following properties:\r
217 1. The procedure executes before the processor is handed over to the operating system.\r
218 2. All processors execute the same startup procedure.\r
219 3. The procedure may run in parallel with other procedures invoked through the functions in this\r
220 protocol, or with processors that are executing an MM handler or running in the operating system.\r
221\r
222\r
223 @param[in] This The EFI_MM_MP_PROTOCOL instance.\r
224 @param[in] Procedure A pointer to the code stream to be run on the designated target AP\r
225 of the system. Type EFI_AP_PROCEDURE is defined below in Volume 2\r
226 with the related definitions of\r
227 EFI_MP_SERVICES_PROTOCOL.StartupAllAPs.\r
228 If caller may pass a value of NULL to deregister any existing\r
229 startup procedure.\r
230 @param[in,out] ProcedureArguments Allows the caller to pass a list of parameters to the code that is\r
231 run by the AP. It is an optional common mailbox between APs and\r
232 the caller to share information\r
233\r
234 @retval EFI_SUCCESS The Procedure has been set successfully.\r
235 @retval EFI_INVALID_PARAMETER The Procedure is NULL.\r
236**/\r
237typedef\r
238EFI_STATUS\r
2f88bd3a 239(EFIAPI *EFI_MM_SET_STARTUP_PROCEDURE)(\r
18f169a9
ED
240 IN CONST EFI_MM_MP_PROTOCOL *This,\r
241 IN EFI_AP_PROCEDURE Procedure,\r
242 IN OUT VOID *ProcedureArguments OPTIONAL\r
2f88bd3a 243 );\r
18f169a9
ED
244\r
245/**\r
246 When non-blocking execution of a procedure on an AP is invoked with DispatchProcedure,\r
247 via the use of a token, this function can be used to check for completion of the procedure on the AP.\r
248 The function takes the token that was passed into the DispatchProcedure call. If the procedure\r
249 is complete, and therefore it is now possible to run another procedure on the same AP, this function\r
250 returns EFI_SUCESS. In this case the status returned by the procedure that executed on the AP is\r
251 returned in the token's Status field. If the procedure has not yet completed, then this function\r
252 returns EFI_NOT_READY.\r
253\r
254 When a non-blocking execution of a procedure is invoked with BroadcastProcedure, via the\r
255 use of a token, this function can be used to check for completion of the procedure on all the\r
256 broadcast APs. The function takes the token that was passed into the BroadcastProcedure\r
257 call. If the procedure is complete on all broadcast APs this function returns EFI_SUCESS. In this\r
258 case the Status field in the token passed into the function reflects the overall result of the\r
259 invocation, which may be EFI_SUCCESS, if all executions succeeded, or the first observed failure.\r
260 If the procedure has not yet completed on the broadcast APs, the function returns\r
261 EFI_NOT_READY.\r
262\r
263 @param[in] This The EFI_MM_MP_PROTOCOL instance.\r
264 @param[in] Token This parameter describes the token that was passed into\r
265 DispatchProcedure or BroadcastProcedure.\r
266\r
267 @retval EFI_SUCCESS Procedure has completed.\r
268 @retval EFI_NOT_READY The Procedure has not completed.\r
269 @retval EFI_INVALID_PARAMETER Token or Token->Completion is NULL\r
270 @retval EFI_NOT_FOUND Token is not currently in use for a non-blocking call\r
271\r
272**/\r
273typedef\r
274EFI_STATUS\r
2f88bd3a 275(EFIAPI *EFI_CHECK_FOR_PROCEDURE)(\r
18f169a9
ED
276 IN CONST EFI_MM_MP_PROTOCOL *This,\r
277 IN MM_COMPLETION Token\r
2f88bd3a 278 );\r
18f169a9
ED
279\r
280/**\r
281 When a non-blocking execution of a procedure on an AP is invoked via DispatchProcedure,\r
282 this function will block the caller until the remote procedure has completed on the designated AP.\r
283 The non-blocking procedure invocation is identified by the Token parameter, which must match the\r
284 token that used when DispatchProcedure was called. Upon completion the status returned by\r
285 the procedure that executed on the AP is used to update the token's Status field.\r
286\r
287 When a non-blocking execution of a procedure on an AP is invoked via BroadcastProcedure\r
288 this function will block the caller until the remote procedure has completed on all of the APs that\r
289 entered MM. The non-blocking procedure invocation is identified by the Token parameter, which\r
290 must match the token that used when BroadcastProcedure was called. Upon completion the\r
291 overall status returned by the procedures that executed on the broadcast AP is used to update the\r
292 token's Status field. The overall status may be EFI_SUCCESS, if all executions succeeded, or the\r
293 first observed failure.\r
294\r
295\r
296 @param[in] This The EFI_MM_MP_PROTOCOL instance.\r
297 @param[in] Token This parameter describes the token that was passed into\r
298 DispatchProcedure or BroadcastProcedure.\r
299\r
300 @retval EFI_SUCCESS Procedure has completed.\r
301 @retval EFI_INVALID_PARAMETER Token or Token->Completion is NULL\r
302 @retval EFI_NOT_FOUND Token is not currently in use for a non-blocking call\r
303\r
304**/\r
305typedef\r
306EFI_STATUS\r
2f88bd3a 307(EFIAPI *EFI_WAIT_FOR_PROCEDURE)(\r
18f169a9
ED
308 IN CONST EFI_MM_MP_PROTOCOL *This,\r
309 IN MM_COMPLETION Token\r
2f88bd3a 310 );\r
18f169a9
ED
311\r
312///\r
313/// The MM MP protocol provides a set of functions to allow execution of procedures on processors that\r
314/// have entered MM.\r
315///\r
316struct _EFI_MM_MP_PROTOCOL {\r
2f88bd3a
MK
317 UINT32 Revision;\r
318 UINT32 Attributes;\r
319 EFI_MM_GET_NUMBER_OF_PROCESSORS GetNumberOfProcessors;\r
320 EFI_MM_DISPATCH_PROCEDURE DispatchProcedure;\r
321 EFI_MM_BROADCAST_PROCEDURE BroadcastProcedure;\r
322 EFI_MM_SET_STARTUP_PROCEDURE SetStartupProcedure;\r
323 EFI_CHECK_FOR_PROCEDURE CheckForProcedure;\r
324 EFI_WAIT_FOR_PROCEDURE WaitForProcedure;\r
18f169a9
ED
325};\r
326\r
2f88bd3a 327extern EFI_GUID gEfiMmMpProtocolGuid;\r
18f169a9
ED
328\r
329#endif\r