]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/CpuMpPei/PeiMpServices.h
6264abd7c6501eae6174d17fc0880362127ce7d6
[mirror_edk2.git] / UefiCpuPkg / CpuMpPei / PeiMpServices.h
1 /** @file
2 Functions prototype of Multiple Processor PPI services.
3
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _PEI_MP_SERVICES_H_
16 #define _PEI_MP_SERVICES_H_
17
18 #include "CpuMpPei.h"
19
20
21 #define CPU_CHECK_AP_INTERVAL 0x100 // 100 microseconds
22
23 /**
24 This service retrieves the number of logical processor in the platform
25 and the number of those logical processors that are enabled on this boot.
26 This service may only be called from the BSP.
27
28 This function is used to retrieve the following information:
29 - The number of logical processors that are present in the system.
30 - The number of enabled logical processors in the system at the instant
31 this call is made.
32
33 Because MP Service Ppi provides services to enable and disable processors
34 dynamically, the number of enabled logical processors may vary during the
35 course of a boot session.
36
37 If this service is called from an AP, then EFI_DEVICE_ERROR is returned.
38 If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then
39 EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors
40 is returned in NumberOfProcessors, the number of currently enabled processor
41 is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.
42
43 @param[in] PeiServices An indirect pointer to the PEI Services Table
44 published by the PEI Foundation.
45 @param[in] This Pointer to this instance of the PPI.
46 @param[out] NumberOfProcessors Pointer to the total number of logical processors in
47 the system, including the BSP and disabled APs.
48 @param[out] NumberOfEnabledProcessors
49 Number of processors in the system that are enabled.
50
51 @retval EFI_SUCCESS The number of logical processors and enabled
52 logical processors was retrieved.
53 @retval EFI_DEVICE_ERROR The calling processor is an AP.
54 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.
55 NumberOfEnabledProcessors is NULL.
56 **/
57 EFI_STATUS
58 EFIAPI
59 PeiGetNumberOfProcessors (
60 IN CONST EFI_PEI_SERVICES **PeiServices,
61 IN EFI_PEI_MP_SERVICES_PPI *This,
62 OUT UINTN *NumberOfProcessors,
63 OUT UINTN *NumberOfEnabledProcessors
64 );
65
66 /**
67 Gets detailed MP-related information on the requested processor at the
68 instant this call is made. This service may only be called from the BSP.
69
70 This service retrieves detailed MP-related information about any processor
71 on the platform. Note the following:
72 - The processor information may change during the course of a boot session.
73 - The information presented here is entirely MP related.
74
75 Information regarding the number of caches and their sizes, frequency of operation,
76 slot numbers is all considered platform-related information and is not provided
77 by this service.
78
79 @param[in] PeiServices An indirect pointer to the PEI Services Table
80 published by the PEI Foundation.
81 @param[in] This Pointer to this instance of the PPI.
82 @param[in] ProcessorNumber Pointer to the total number of logical processors in
83 the system, including the BSP and disabled APs.
84 @param[out] ProcessorInfoBuffer Number of processors in the system that are enabled.
85
86 @retval EFI_SUCCESS Processor information was returned.
87 @retval EFI_DEVICE_ERROR The calling processor is an AP.
88 @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
89 @retval EFI_NOT_FOUND The processor with the handle specified by
90 ProcessorNumber does not exist in the platform.
91 **/
92 EFI_STATUS
93 EFIAPI
94 PeiGetProcessorInfo (
95 IN CONST EFI_PEI_SERVICES **PeiServices,
96 IN EFI_PEI_MP_SERVICES_PPI *This,
97 IN UINTN ProcessorNumber,
98 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
99 );
100
101 /**
102 This service executes a caller provided function on all enabled APs. APs can
103 run either simultaneously or one at a time in sequence. This service supports
104 both blocking requests only. This service may only
105 be called from the BSP.
106
107 This function is used to dispatch all the enabled APs to the function specified
108 by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned
109 immediately and Procedure is not started on any AP.
110
111 If SingleThread is TRUE, all the enabled APs execute the function specified by
112 Procedure one by one, in ascending order of processor handle number. Otherwise,
113 all the enabled APs execute the function specified by Procedure simultaneously.
114
115 If the timeout specified by TimeoutInMicroSeconds expires before all APs return
116 from Procedure, then Procedure on the failed APs is terminated. All enabled APs
117 are always available for further calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
118 and EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If FailedCpuList is not NULL, its
119 content points to the list of processor handle numbers in which Procedure was
120 terminated.
121
122 Note: It is the responsibility of the consumer of the EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
123 to make sure that the nature of the code that is executed on the BSP and the
124 dispatched APs is well controlled. The MP Services Ppi does not guarantee
125 that the Procedure function is MP-safe. Hence, the tasks that can be run in
126 parallel are limited to certain independent tasks and well-controlled exclusive
127 code. PEI services and Ppis may not be called by APs unless otherwise
128 specified.
129
130 In blocking execution mode, BSP waits until all APs finish or
131 TimeoutInMicroSeconds expires.
132
133 @param[in] PeiServices An indirect pointer to the PEI Services Table
134 published by the PEI Foundation.
135 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
136 @param[in] Procedure A pointer to the function to be run on enabled APs of
137 the system.
138 @param[in] SingleThread If TRUE, then all the enabled APs execute the function
139 specified by Procedure one by one, in ascending order
140 of processor handle number. If FALSE, then all the
141 enabled APs execute the function specified by Procedure
142 simultaneously.
143 @param[in] TimeoutInMicroSeconds
144 Indicates the time limit in microseconds for APs to
145 return from Procedure, for blocking mode only. Zero
146 means infinity. If the timeout expires before all APs
147 return from Procedure, then Procedure on the failed APs
148 is terminated. All enabled APs are available for next
149 function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
150 or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the
151 timeout expires in blocking mode, BSP returns
152 EFI_TIMEOUT.
153 @param[in] ProcedureArgument The parameter passed into Procedure for all APs.
154
155 @retval EFI_SUCCESS In blocking mode, all APs have finished before the
156 timeout expired.
157 @retval EFI_DEVICE_ERROR Caller processor is AP.
158 @retval EFI_NOT_STARTED No enabled APs exist in the system.
159 @retval EFI_NOT_READY Any enabled APs are busy.
160 @retval EFI_TIMEOUT In blocking mode, the timeout expired before all
161 enabled APs have finished.
162 @retval EFI_INVALID_PARAMETER Procedure is NULL.
163 **/
164 EFI_STATUS
165 EFIAPI
166 PeiStartupAllAPs (
167 IN CONST EFI_PEI_SERVICES **PeiServices,
168 IN EFI_PEI_MP_SERVICES_PPI *This,
169 IN EFI_AP_PROCEDURE Procedure,
170 IN BOOLEAN SingleThread,
171 IN UINTN TimeoutInMicroSeconds,
172 IN VOID *ProcedureArgument OPTIONAL
173 );
174
175 /**
176 This service lets the caller get one enabled AP to execute a caller-provided
177 function. The caller can request the BSP to wait for the completion
178 of the AP. This service may only be called from the BSP.
179
180 This function is used to dispatch one enabled AP to the function specified by
181 Procedure passing in the argument specified by ProcedureArgument.
182 The execution is in blocking mode. The BSP waits until the AP finishes or
183 TimeoutInMicroSecondss expires.
184
185 If the timeout specified by TimeoutInMicroseconds expires before the AP returns
186 from Procedure, then execution of Procedure by the AP is terminated. The AP is
187 available for subsequent calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() and
188 EFI_PEI_MP_SERVICES_PPI.StartupThisAP().
189
190 @param[in] PeiServices An indirect pointer to the PEI Services Table
191 published by the PEI Foundation.
192 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
193 @param[in] Procedure A pointer to the function to be run on enabled APs of
194 the system.
195 @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
196 total number of logical processors minus 1. The total
197 number of logical processors can be retrieved by
198 EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
199 @param[in] TimeoutInMicroseconds
200 Indicates the time limit in microseconds for APs to
201 return from Procedure, for blocking mode only. Zero
202 means infinity. If the timeout expires before all APs
203 return from Procedure, then Procedure on the failed APs
204 is terminated. All enabled APs are available for next
205 function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
206 or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the
207 timeout expires in blocking mode, BSP returns
208 EFI_TIMEOUT.
209 @param[in] ProcedureArgument The parameter passed into Procedure for all APs.
210
211 @retval EFI_SUCCESS In blocking mode, specified AP finished before the
212 timeout expires.
213 @retval EFI_DEVICE_ERROR The calling processor is an AP.
214 @retval EFI_TIMEOUT In blocking mode, the timeout expired before the
215 specified AP has finished.
216 @retval EFI_NOT_FOUND The processor with the handle specified by
217 ProcessorNumber does not exist.
218 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
219 @retval EFI_INVALID_PARAMETER Procedure is NULL.
220 **/
221 EFI_STATUS
222 EFIAPI
223 PeiStartupThisAP (
224 IN CONST EFI_PEI_SERVICES **PeiServices,
225 IN EFI_PEI_MP_SERVICES_PPI *This,
226 IN EFI_AP_PROCEDURE Procedure,
227 IN UINTN ProcessorNumber,
228 IN UINTN TimeoutInMicroseconds,
229 IN VOID *ProcedureArgument OPTIONAL
230 );
231
232
233 /**
234 This return the handle number for the calling processor. This service may be
235 called from the BSP and APs.
236
237 This service returns the processor handle number for the calling processor.
238 The returned value is in the range from 0 to the total number of logical
239 processors minus 1. The total number of logical processors can be retrieved
240 with EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). This service may be
241 called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER
242 is returned. Otherwise, the current processors handle number is returned in
243 ProcessorNumber, and EFI_SUCCESS is returned.
244
245 @param[in] PeiServices An indirect pointer to the PEI Services Table
246 published by the PEI Foundation.
247 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
248 @param[out] ProcessorNumber The handle number of the AP. The range is from 0 to the
249 total number of logical processors minus 1. The total
250 number of logical processors can be retrieved by
251 EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
252
253 @retval EFI_SUCCESS The current processor handle number was returned in
254 ProcessorNumber.
255 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
256 **/
257 EFI_STATUS
258 EFIAPI
259 PeiWhoAmI (
260 IN CONST EFI_PEI_SERVICES **PeiServices,
261 IN EFI_PEI_MP_SERVICES_PPI *This,
262 OUT UINTN *ProcessorNumber
263 );
264
265 #endif