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