]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | CPU DXE MP support\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef _CPU_MP_H_\r | |
16 | #define _CPU_MP_H_\r | |
17 | \r | |
18 | #include <Protocol/MpService.h>\r | |
19 | #include <Library/SynchronizationLib.h>\r | |
20 | \r | |
21 | /**\r | |
22 | Initialize Multi-processor support.\r | |
23 | \r | |
24 | **/\r | |
25 | VOID\r | |
26 | InitializeMpSupport (\r | |
27 | VOID\r | |
28 | );\r | |
29 | \r | |
30 | typedef\r | |
31 | VOID\r | |
32 | (EFIAPI *STACKLESS_AP_ENTRY_POINT)(\r | |
33 | VOID\r | |
34 | );\r | |
35 | \r | |
36 | /**\r | |
37 | Starts the Application Processors and directs them to jump to the\r | |
38 | specified routine.\r | |
39 | \r | |
40 | The processor jumps to this code in flat mode, but the processor's\r | |
41 | stack is not initialized.\r | |
42 | \r | |
43 | @param ApEntryPoint Pointer to the Entry Point routine\r | |
44 | \r | |
45 | @retval EFI_SUCCESS The APs were started\r | |
46 | @retval EFI_OUT_OF_RESOURCES Cannot allocate memory to start APs\r | |
47 | \r | |
48 | **/\r | |
49 | EFI_STATUS\r | |
50 | StartApsStackless (\r | |
51 | IN STACKLESS_AP_ENTRY_POINT ApEntryPoint\r | |
52 | );\r | |
53 | \r | |
54 | /**\r | |
55 | The AP entry point that the Startup-IPI target code will jump to.\r | |
56 | \r | |
57 | The processor jumps to this code in flat mode, but the processor's\r | |
58 | stack is not initialized.\r | |
59 | \r | |
60 | **/\r | |
61 | VOID\r | |
62 | EFIAPI\r | |
63 | AsmApEntryPoint (\r | |
64 | VOID\r | |
65 | );\r | |
66 | \r | |
67 | /**\r | |
68 | Releases the lock preventing other APs from using the shared AP\r | |
69 | stack.\r | |
70 | \r | |
71 | Once the AP has transitioned to using a new stack, it can call this\r | |
72 | function to allow another AP to proceed with using the shared stack.\r | |
73 | \r | |
74 | **/\r | |
75 | VOID\r | |
76 | EFIAPI\r | |
77 | AsmApDoneWithCommonStack (\r | |
78 | VOID\r | |
79 | );\r | |
80 | \r | |
81 | typedef enum {\r | |
82 | CpuStateIdle,\r | |
83 | CpuStateBlocked,\r | |
84 | CpuStateReady,\r | |
85 | CpuStateBuzy,\r | |
86 | CpuStateFinished\r | |
87 | } CPU_STATE;\r | |
88 | \r | |
89 | /**\r | |
90 | Define Individual Processor Data block.\r | |
91 | \r | |
92 | **/\r | |
93 | typedef struct {\r | |
94 | EFI_PROCESSOR_INFORMATION Info;\r | |
95 | SPIN_LOCK CpuDataLock;\r | |
96 | volatile CPU_STATE State;\r | |
97 | \r | |
98 | EFI_AP_PROCEDURE Procedure;\r | |
99 | VOID *Parameter;\r | |
100 | BOOLEAN *Finished;\r | |
101 | INTN Timeout;\r | |
102 | EFI_EVENT WaitEvent;\r | |
103 | BOOLEAN TimeoutActive;\r | |
104 | EFI_EVENT CheckThisAPEvent;\r | |
105 | } CPU_DATA_BLOCK;\r | |
106 | \r | |
107 | /**\r | |
108 | Define MP data block which consumes individual processor block.\r | |
109 | \r | |
110 | **/\r | |
111 | typedef struct {\r | |
112 | CPU_DATA_BLOCK *CpuDatas;\r | |
113 | UINTN NumberOfProcessors;\r | |
114 | UINTN NumberOfEnabledProcessors;\r | |
115 | } MP_SYSTEM_DATA;\r | |
116 | \r | |
117 | /**\r | |
118 | This function is called by all processors (both BSP and AP) once and collects MP related data.\r | |
119 | \r | |
120 | @param Bsp TRUE if the CPU is BSP\r | |
121 | @param ProcessorNumber The specific processor number\r | |
122 | \r | |
123 | @retval EFI_SUCCESS Data for the processor collected and filled in\r | |
124 | \r | |
125 | **/\r | |
126 | EFI_STATUS\r | |
127 | FillInProcessorInformation (\r | |
128 | IN BOOLEAN Bsp,\r | |
129 | IN UINTN ProcessorNumber\r | |
130 | );\r | |
131 | \r | |
132 | /**\r | |
133 | This service retrieves the number of logical processor in the platform\r | |
134 | and the number of those logical processors that are enabled on this boot.\r | |
135 | This service may only be called from the BSP.\r | |
136 | \r | |
137 | This function is used to retrieve the following information:\r | |
138 | - The number of logical processors that are present in the system.\r | |
139 | - The number of enabled logical processors in the system at the instant\r | |
140 | this call is made.\r | |
141 | \r | |
142 | Because MP Service Protocol provides services to enable and disable processors\r | |
143 | dynamically, the number of enabled logical processors may vary during the\r | |
144 | course of a boot session.\r | |
145 | \r | |
146 | If this service is called from an AP, then EFI_DEVICE_ERROR is returned.\r | |
147 | If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then\r | |
148 | EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors\r | |
149 | is returned in NumberOfProcessors, the number of currently enabled processor\r | |
150 | is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.\r | |
151 | \r | |
152 | @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r | |
153 | instance.\r | |
154 | @param[out] NumberOfProcessors Pointer to the total number of logical\r | |
155 | processors in the system, including the BSP\r | |
156 | and disabled APs.\r | |
157 | @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical\r | |
158 | processors that exist in system, including\r | |
159 | the BSP.\r | |
160 | \r | |
161 | @retval EFI_SUCCESS The number of logical processors and enabled\r | |
162 | logical processors was retrieved.\r | |
163 | @retval EFI_DEVICE_ERROR The calling processor is an AP.\r | |
164 | @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.\r | |
165 | @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL.\r | |
166 | \r | |
167 | **/\r | |
168 | EFI_STATUS\r | |
169 | EFIAPI\r | |
170 | GetNumberOfProcessors (\r | |
171 | IN EFI_MP_SERVICES_PROTOCOL *This,\r | |
172 | OUT UINTN *NumberOfProcessors,\r | |
173 | OUT UINTN *NumberOfEnabledProcessors\r | |
174 | );\r | |
175 | \r | |
176 | /**\r | |
177 | Gets detailed MP-related information on the requested processor at the\r | |
178 | instant this call is made. This service may only be called from the BSP.\r | |
179 | \r | |
180 | This service retrieves detailed MP-related information about any processor\r | |
181 | on the platform. Note the following:\r | |
182 | - The processor information may change during the course of a boot session.\r | |
183 | - The information presented here is entirely MP related.\r | |
184 | \r | |
185 | Information regarding the number of caches and their sizes, frequency of operation,\r | |
186 | slot numbers is all considered platform-related information and is not provided\r | |
187 | by this service.\r | |
188 | \r | |
189 | @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r | |
190 | instance.\r | |
191 | @param[in] ProcessorNumber The handle number of processor.\r | |
192 | @param[out] ProcessorInfoBuffer A pointer to the buffer where information for\r | |
193 | the requested processor is deposited.\r | |
194 | \r | |
195 | @retval EFI_SUCCESS Processor information was returned.\r | |
196 | @retval EFI_DEVICE_ERROR The calling processor is an AP.\r | |
197 | @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.\r | |
198 | @retval EFI_NOT_FOUND The processor with the handle specified by\r | |
199 | ProcessorNumber does not exist in the platform.\r | |
200 | \r | |
201 | **/\r | |
202 | EFI_STATUS\r | |
203 | EFIAPI\r | |
204 | GetProcessorInfo (\r | |
205 | IN EFI_MP_SERVICES_PROTOCOL *This,\r | |
206 | IN UINTN ProcessorNumber,\r | |
207 | OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer\r | |
208 | );\r | |
209 | \r | |
210 | /**\r | |
211 | This service lets the caller get one enabled AP to execute a caller-provided\r | |
212 | function. The caller can request the BSP to either wait for the completion\r | |
213 | of the AP or just proceed with the next task by using the EFI event mechanism.\r | |
214 | See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking\r | |
215 | execution support. This service may only be called from the BSP.\r | |
216 | \r | |
217 | This function is used to dispatch one enabled AP to the function specified by\r | |
218 | Procedure passing in the argument specified by ProcedureArgument. If WaitEvent\r | |
219 | is NULL, execution is in blocking mode. The BSP waits until the AP finishes or\r | |
220 | TimeoutInMicroSecondss expires. Otherwise, execution is in non-blocking mode.\r | |
221 | BSP proceeds to the next task without waiting for the AP. If a non-blocking mode\r | |
222 | is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled,\r | |
223 | then EFI_UNSUPPORTED must be returned.\r | |
224 | \r | |
225 | If the timeout specified by TimeoutInMicroseconds expires before the AP returns\r | |
226 | from Procedure, then execution of Procedure by the AP is terminated. The AP is\r | |
227 | available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and\r | |
228 | EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r | |
229 | \r | |
230 | @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r | |
231 | instance.\r | |
232 | @param[in] Procedure A pointer to the function to be run on\r | |
233 | enabled APs of the system. See type\r | |
234 | EFI_AP_PROCEDURE.\r | |
235 | @param[in] ProcessorNumber The handle number of the AP. The range is\r | |
236 | from 0 to the total number of logical\r | |
237 | processors minus 1. The total number of\r | |
238 | logical processors can be retrieved by\r | |
239 | EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r | |
240 | @param[in] WaitEvent The event created by the caller with CreateEvent()\r | |
241 | service. If it is NULL, then execute in\r | |
242 | blocking mode. BSP waits until all APs finish\r | |
243 | or TimeoutInMicroseconds expires. If it's\r | |
244 | not NULL, then execute in non-blocking mode.\r | |
245 | BSP requests the function specified by\r | |
246 | Procedure to be started on all the enabled\r | |
247 | APs, and go on executing immediately. If\r | |
248 | all return from Procedure or TimeoutInMicroseconds\r | |
249 | expires, this event is signaled. The BSP\r | |
250 | can use the CheckEvent() or WaitForEvent()\r | |
251 | services to check the state of event. Type\r | |
252 | EFI_EVENT is defined in CreateEvent() in\r | |
253 | the Unified Extensible Firmware Interface\r | |
254 | Specification.\r | |
255 | @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for\r | |
256 | APs to return from Procedure, either for\r | |
257 | blocking or non-blocking mode. Zero means\r | |
258 | infinity. If the timeout expires before\r | |
259 | all APs return from Procedure, then Procedure\r | |
260 | on the failed APs is terminated. All enabled\r | |
261 | APs are available for next function assigned\r | |
262 | by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r | |
263 | or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r | |
264 | If the timeout expires in blocking mode,\r | |
265 | BSP returns EFI_TIMEOUT. If the timeout\r | |
266 | expires in non-blocking mode, WaitEvent\r | |
267 | is signaled with SignalEvent().\r | |
268 | @param[in] ProcedureArgument The parameter passed into Procedure for\r | |
269 | all APs.\r | |
270 | @param[out] Finished If NULL, this parameter is ignored. In\r | |
271 | blocking mode, this parameter is ignored.\r | |
272 | In non-blocking mode, if AP returns from\r | |
273 | Procedure before the timeout expires, its\r | |
274 | content is set to TRUE. Otherwise, the\r | |
275 | value is set to FALSE. The caller can\r | |
276 | determine if the AP returned from Procedure\r | |
277 | by evaluating this value.\r | |
278 | \r | |
279 | @retval EFI_SUCCESS In blocking mode, specified AP finished before\r | |
280 | the timeout expires.\r | |
281 | @retval EFI_SUCCESS In non-blocking mode, the function has been\r | |
282 | dispatched to specified AP.\r | |
283 | @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r | |
284 | UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r | |
285 | signaled.\r | |
286 | @retval EFI_DEVICE_ERROR The calling processor is an AP.\r | |
287 | @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r | |
288 | the specified AP has finished.\r | |
289 | @retval EFI_NOT_READY The specified AP is busy.\r | |
290 | @retval EFI_NOT_FOUND The processor with the handle specified by\r | |
291 | ProcessorNumber does not exist.\r | |
292 | @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.\r | |
293 | @retval EFI_INVALID_PARAMETER Procedure is NULL.\r | |
294 | \r | |
295 | **/\r | |
296 | EFI_STATUS\r | |
297 | EFIAPI\r | |
298 | StartupThisAP (\r | |
299 | IN EFI_MP_SERVICES_PROTOCOL *This,\r | |
300 | IN EFI_AP_PROCEDURE Procedure,\r | |
301 | IN UINTN ProcessorNumber,\r | |
302 | IN EFI_EVENT WaitEvent OPTIONAL,\r | |
303 | IN UINTN TimeoutInMicroseconds,\r | |
304 | IN VOID *ProcedureArgument OPTIONAL,\r | |
305 | OUT BOOLEAN *Finished OPTIONAL\r | |
306 | );\r | |
307 | \r | |
308 | /**\r | |
309 | This service lets the caller enable or disable an AP from this point onward.\r | |
310 | This service may only be called from the BSP.\r | |
311 | \r | |
312 | This service allows the caller enable or disable an AP from this point onward.\r | |
313 | The caller can optionally specify the health status of the AP by Health. If\r | |
314 | an AP is being disabled, then the state of the disabled AP is implementation\r | |
315 | dependent. If an AP is enabled, then the implementation must guarantee that a\r | |
316 | complete initialization sequence is performed on the AP, so the AP is in a state\r | |
317 | that is compatible with an MP operating system. This service may not be supported\r | |
318 | after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled.\r | |
319 | \r | |
320 | If the enable or disable AP operation cannot be completed prior to the return\r | |
321 | from this service, then EFI_UNSUPPORTED must be returned.\r | |
322 | \r | |
323 | @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r | |
324 | @param[in] ProcessorNumber The handle number of AP that is to become the new\r | |
325 | BSP. The range is from 0 to the total number of\r | |
326 | logical processors minus 1. The total number of\r | |
327 | logical processors can be retrieved by\r | |
328 | EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r | |
329 | @param[in] EnableAP Specifies the new state for the processor for\r | |
330 | enabled, FALSE for disabled.\r | |
331 | @param[in] HealthFlag If not NULL, a pointer to a value that specifies\r | |
332 | the new health status of the AP. This flag\r | |
333 | corresponds to StatusFlag defined in\r | |
334 | EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only\r | |
335 | the PROCESSOR_HEALTH_STATUS_BIT is used. All other\r | |
336 | bits are ignored. If it is NULL, this parameter\r | |
337 | is ignored.\r | |
338 | \r | |
339 | @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.\r | |
340 | @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed\r | |
341 | prior to this service returning.\r | |
342 | @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.\r | |
343 | @retval EFI_DEVICE_ERROR The calling processor is an AP.\r | |
344 | @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber\r | |
345 | does not exist.\r | |
346 | @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.\r | |
347 | \r | |
348 | **/\r | |
349 | EFI_STATUS\r | |
350 | EFIAPI\r | |
351 | EnableDisableAP (\r | |
352 | IN EFI_MP_SERVICES_PROTOCOL *This,\r | |
353 | IN UINTN ProcessorNumber,\r | |
354 | IN BOOLEAN EnableAP,\r | |
355 | IN UINT32 *HealthFlag OPTIONAL\r | |
356 | );\r | |
357 | \r | |
358 | /**\r | |
359 | This return the handle number for the calling processor. This service may be\r | |
360 | called from the BSP and APs.\r | |
361 | \r | |
362 | This service returns the processor handle number for the calling processor.\r | |
363 | The returned value is in the range from 0 to the total number of logical\r | |
364 | processors minus 1. The total number of logical processors can be retrieved\r | |
365 | with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be\r | |
366 | called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER\r | |
367 | is returned. Otherwise, the current processors handle number is returned in\r | |
368 | ProcessorNumber, and EFI_SUCCESS is returned.\r | |
369 | \r | |
370 | @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r | |
371 | @param[out] ProcessorNumber The handle number of AP that is to become the new\r | |
372 | BSP. The range is from 0 to the total number of\r | |
373 | logical processors minus 1. The total number of\r | |
374 | logical processors can be retrieved by\r | |
375 | EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r | |
376 | \r | |
377 | @retval EFI_SUCCESS The current processor handle number was returned\r | |
378 | in ProcessorNumber.\r | |
379 | @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.\r | |
380 | \r | |
381 | **/\r | |
382 | EFI_STATUS\r | |
383 | EFIAPI\r | |
384 | WhoAmI (\r | |
385 | IN EFI_MP_SERVICES_PROTOCOL *This,\r | |
386 | OUT UINTN *ProcessorNumber\r | |
387 | );\r | |
388 | \r | |
389 | /**\r | |
390 | Terminate AP's task and set it to idle state.\r | |
391 | \r | |
392 | This function terminates AP's task due to timeout by sending INIT-SIPI,\r | |
393 | and sends it to idle state.\r | |
394 | \r | |
395 | @param CpuData the pointer to CPU_DATA_BLOCK of specified AP\r | |
396 | \r | |
397 | **/\r | |
398 | VOID\r | |
399 | ResetProcessorToIdleState (\r | |
400 | IN CPU_DATA_BLOCK *CpuData\r | |
401 | );\r | |
402 | \r | |
403 | #endif // _CPU_MP_H_\r | |
404 | \r |