]>
Commit | Line | Data |
---|---|---|
3e8ad6bd JF |
1 | /** @file\r |
2 | Common header file for MP Initialize Library.\r | |
3 | \r | |
ee0c39fa | 4 | Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>\r |
0acd8697 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
3e8ad6bd JF |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #ifndef _MP_LIB_H_\r | |
10 | #define _MP_LIB_H_\r | |
11 | \r | |
12 | #include <PiPei.h>\r | |
13 | \r | |
01acb06c RN |
14 | #include <Register/Intel/Cpuid.h>\r |
15 | #include <Register/Intel/Msr.h>\r | |
16 | #include <Register/Intel/LocalApic.h>\r | |
17 | #include <Register/Intel/Microcode.h>\r | |
3e8ad6bd JF |
18 | \r |
19 | #include <Library/MpInitLib.h>\r | |
20 | #include <Library/BaseLib.h>\r | |
21 | #include <Library/BaseMemoryLib.h>\r | |
22 | #include <Library/MemoryAllocationLib.h>\r | |
23 | #include <Library/DebugLib.h>\r | |
24 | #include <Library/LocalApicLib.h>\r | |
25 | #include <Library/CpuLib.h>\r | |
26 | #include <Library/UefiCpuLib.h>\r | |
27 | #include <Library/TimerLib.h>\r | |
28 | #include <Library/SynchronizationLib.h>\r | |
29 | #include <Library/MtrrLib.h>\r | |
30 | #include <Library/HobLib.h>\r | |
31 | \r | |
b8b04307 JF |
32 | #define WAKEUP_AP_SIGNAL SIGNATURE_32 ('S', 'T', 'A', 'P')\r |
33 | \r | |
93ca4c0f JF |
34 | #define CPU_INIT_MP_LIB_HOB_GUID \\r |
35 | { \\r | |
36 | 0x58eb6a19, 0x3699, 0x4c68, { 0xa8, 0x36, 0xda, 0xcd, 0x8e, 0xdc, 0xad, 0x4a } \\r | |
37 | }\r | |
38 | \r | |
41be0da5 JF |
39 | //\r |
40 | // The MP data for switch BSP\r | |
41 | //\r | |
42 | #define CPU_SWITCH_STATE_IDLE 0\r | |
43 | #define CPU_SWITCH_STATE_STORED 1\r | |
44 | #define CPU_SWITCH_STATE_LOADED 2\r | |
45 | \r | |
d786a172 HW |
46 | //\r |
47 | // Default maximum number of entries to store the microcode patches information\r | |
48 | //\r | |
49 | #define DEFAULT_MAX_MICROCODE_PATCH_NUM 8\r | |
50 | \r | |
51 | //\r | |
52 | // Data structure for microcode patch information\r | |
53 | //\r | |
54 | typedef struct {\r | |
55 | UINTN Address;\r | |
56 | UINTN Size;\r | |
57 | UINTN AlignedSize;\r | |
58 | } MICROCODE_PATCH_INFO;\r | |
59 | \r | |
41be0da5 JF |
60 | //\r |
61 | // CPU exchange information for switch BSP\r | |
62 | //\r | |
63 | typedef struct {\r | |
64 | UINT8 State; // offset 0\r | |
65 | UINTN StackPointer; // offset 4 / 8\r | |
66 | IA32_DESCRIPTOR Gdtr; // offset 8 / 16\r | |
67 | IA32_DESCRIPTOR Idtr; // offset 14 / 26\r | |
68 | } CPU_EXCHANGE_ROLE_INFO;\r | |
69 | \r | |
9ebcf0f4 JF |
70 | //\r |
71 | // AP loop state when APs are in idle state\r | |
72 | // It's value is the same with PcdCpuApLoopMode\r | |
73 | //\r | |
74 | typedef enum {\r | |
75 | ApInHltLoop = 1,\r | |
76 | ApInMwaitLoop = 2,\r | |
77 | ApInRunLoop = 3\r | |
78 | } AP_LOOP_MODE;\r | |
79 | \r | |
e59f8f6b JF |
80 | //\r |
81 | // AP initialization state during APs wakeup\r | |
82 | //\r | |
83 | typedef enum {\r | |
84 | ApInitConfig = 1,\r | |
85 | ApInitReconfig = 2,\r | |
86 | ApInitDone = 3\r | |
87 | } AP_INIT_STATE;\r | |
88 | \r | |
03a1a925 JF |
89 | //\r |
90 | // AP state\r | |
91 | //\r | |
2a5997f8 ED |
92 | // The state transitions for an AP when it process a procedure are:\r |
93 | // Idle ----> Ready ----> Busy ----> Idle\r | |
94 | // [BSP] [AP] [AP]\r | |
95 | //\r | |
03a1a925 JF |
96 | typedef enum {\r |
97 | CpuStateIdle,\r | |
98 | CpuStateReady,\r | |
99 | CpuStateBusy,\r | |
e048ce88 | 100 | CpuStateFinished,\r |
03a1a925 JF |
101 | CpuStateDisabled\r |
102 | } CPU_STATE;\r | |
103 | \r | |
68cb9330 JF |
104 | //\r |
105 | // CPU volatile registers around INIT-SIPI-SIPI\r | |
106 | //\r | |
107 | typedef struct {\r | |
108 | UINTN Cr0;\r | |
109 | UINTN Cr3;\r | |
110 | UINTN Cr4;\r | |
111 | UINTN Dr0;\r | |
112 | UINTN Dr1;\r | |
113 | UINTN Dr2;\r | |
114 | UINTN Dr3;\r | |
115 | UINTN Dr6;\r | |
116 | UINTN Dr7;\r | |
e9415e48 JW |
117 | IA32_DESCRIPTOR Gdtr;\r |
118 | IA32_DESCRIPTOR Idtr;\r | |
119 | UINT16 Tr;\r | |
68cb9330 JF |
120 | } CPU_VOLATILE_REGISTERS;\r |
121 | \r | |
e59f8f6b JF |
122 | //\r |
123 | // AP related data\r | |
124 | //\r | |
125 | typedef struct {\r | |
126 | SPIN_LOCK ApLock;\r | |
127 | volatile UINT32 *StartupApSignal;\r | |
128 | volatile UINTN ApFunction;\r | |
129 | volatile UINTN ApFunctionArgument;\r | |
e59f8f6b | 130 | BOOLEAN CpuHealthy;\r |
03a1a925 | 131 | volatile CPU_STATE State;\r |
68cb9330 | 132 | CPU_VOLATILE_REGISTERS VolatileRegisters;\r |
e59f8f6b JF |
133 | BOOLEAN Waiting;\r |
134 | BOOLEAN *Finished;\r | |
135 | UINT64 ExpectedTime;\r | |
136 | UINT64 CurrentTime;\r | |
137 | UINT64 TotalTime;\r | |
138 | EFI_EVENT WaitEvent;\r | |
999463c8 HW |
139 | UINT32 ProcessorSignature;\r |
140 | UINT8 PlatformId;\r | |
e1ed5573 | 141 | UINT64 MicrocodeEntryAddr;\r |
e59f8f6b JF |
142 | } CPU_AP_DATA;\r |
143 | \r | |
144 | //\r | |
145 | // Basic CPU information saved in Guided HOB.\r | |
146 | // Because the contents will be shard between PEI and DXE,\r | |
147 | // we need to make sure the each fields offset same in different\r | |
148 | // architecture.\r | |
149 | //\r | |
dd3fa0cd | 150 | #pragma pack (1)\r |
e59f8f6b JF |
151 | typedef struct {\r |
152 | UINT32 InitialApicId;\r | |
153 | UINT32 ApicId;\r | |
154 | UINT32 Health;\r | |
dd3fa0cd | 155 | UINT64 ApTopOfStack;\r |
e59f8f6b | 156 | } CPU_INFO_IN_HOB;\r |
dd3fa0cd | 157 | #pragma pack ()\r |
e59f8f6b | 158 | \r |
f7f85d83 JF |
159 | //\r |
160 | // AP reset code information including code address and size,\r | |
161 | // this structure will be shared be C code and assembly code.\r | |
162 | // It is natural aligned by design.\r | |
163 | //\r | |
164 | typedef struct {\r | |
165 | UINT8 *RendezvousFunnelAddress;\r | |
166 | UINTN ModeEntryOffset;\r | |
167 | UINTN RendezvousFunnelSize;\r | |
168 | UINT8 *RelocateApLoopFuncAddress;\r | |
169 | UINTN RelocateApLoopFuncSize;\r | |
f32bfe6d | 170 | UINTN ModeTransitionOffset;\r |
f7f85d83 | 171 | } MP_ASSEMBLY_ADDRESS_MAP;\r |
3e8ad6bd | 172 | \r |
e59f8f6b JF |
173 | typedef struct _CPU_MP_DATA CPU_MP_DATA;\r |
174 | \r | |
d94e5f67 JF |
175 | #pragma pack(1)\r |
176 | \r | |
177 | //\r | |
178 | // MP CPU exchange information for AP reset code\r | |
179 | // This structure is required to be packed because fixed field offsets\r | |
180 | // into this structure are used in assembly code in this module\r | |
181 | //\r | |
182 | typedef struct {\r | |
183 | UINTN Lock;\r | |
184 | UINTN StackStart;\r | |
185 | UINTN StackSize;\r | |
186 | UINTN CFunction;\r | |
187 | IA32_DESCRIPTOR GdtrProfile;\r | |
188 | IA32_DESCRIPTOR IdtrProfile;\r | |
189 | UINTN BufferStart;\r | |
190 | UINTN ModeOffset;\r | |
37676b9f | 191 | UINTN ApIndex;\r |
d94e5f67 JF |
192 | UINTN CodeSegment;\r |
193 | UINTN DataSegment;\r | |
5c66d125 | 194 | UINTN EnableExecuteDisable;\r |
d94e5f67 | 195 | UINTN Cr3;\r |
46d4b885 JF |
196 | UINTN InitFlag;\r |
197 | CPU_INFO_IN_HOB *CpuInfo;\r | |
0594ec41 | 198 | UINTN NumApsExecuting;\r |
e59f8f6b | 199 | CPU_MP_DATA *CpuMpData;\r |
3b2928b4 | 200 | UINTN InitializeFloatingPointUnitsAddress;\r |
f32bfe6d JW |
201 | UINT32 ModeTransitionMemory;\r |
202 | UINT16 ModeTransitionSegment;\r | |
203 | UINT32 ModeHighMemory;\r | |
204 | UINT16 ModeHighSegment;\r | |
09f69a87 RN |
205 | //\r |
206 | // Enable5LevelPaging indicates whether 5-level paging is enabled in long mode.\r | |
207 | //\r | |
208 | BOOLEAN Enable5LevelPaging;\r | |
d94e5f67 JF |
209 | } MP_CPU_EXCHANGE_INFO;\r |
210 | \r | |
211 | #pragma pack()\r | |
e59f8f6b JF |
212 | \r |
213 | //\r | |
214 | // CPU MP Data save in memory\r | |
215 | //\r | |
216 | struct _CPU_MP_DATA {\r | |
217 | UINT64 CpuInfoInHob;\r | |
218 | UINT32 CpuCount;\r | |
219 | UINT32 BspNumber;\r | |
88bd0661 HW |
220 | UINT64 MicrocodePatchAddress;\r |
221 | UINT64 MicrocodePatchRegionSize;\r | |
e59f8f6b JF |
222 | //\r |
223 | // The above fields data will be passed from PEI to DXE\r | |
224 | // Please make sure the fields offset same in the different\r | |
225 | // architecture.\r | |
226 | //\r | |
227 | SPIN_LOCK MpLock;\r | |
228 | UINTN Buffer;\r | |
229 | UINTN CpuApStackSize;\r | |
230 | MP_ASSEMBLY_ADDRESS_MAP AddressMap;\r | |
231 | UINTN WakeupBuffer;\r | |
66833b2a | 232 | UINTN WakeupBufferHigh;\r |
e59f8f6b JF |
233 | UINTN BackupBuffer;\r |
234 | UINTN BackupBufferSize;\r | |
e59f8f6b | 235 | \r |
e59f8f6b | 236 | volatile UINT32 FinishedCount;\r |
2da3e96c | 237 | UINT32 RunningCount;\r |
e59f8f6b JF |
238 | BOOLEAN SingleThread;\r |
239 | EFI_AP_PROCEDURE Procedure;\r | |
240 | VOID *ProcArguments;\r | |
241 | BOOLEAN *Finished;\r | |
242 | UINT64 ExpectedTime;\r | |
243 | UINT64 CurrentTime;\r | |
244 | UINT64 TotalTime;\r | |
245 | EFI_EVENT WaitEvent;\r | |
246 | UINTN **FailedCpuList;\r | |
247 | \r | |
248 | AP_INIT_STATE InitFlag;\r | |
41be0da5 | 249 | BOOLEAN SwitchBspFlag;\r |
b3775af2 | 250 | UINTN NewBspNumber;\r |
41be0da5 JF |
251 | CPU_EXCHANGE_ROLE_INFO BSPInfo;\r |
252 | CPU_EXCHANGE_ROLE_INFO APInfo;\r | |
e59f8f6b JF |
253 | MTRR_SETTINGS MtrrTable;\r |
254 | UINT8 ApLoopMode;\r | |
255 | UINT8 ApTargetCState;\r | |
256 | UINT16 PmCodeSegment;\r | |
257 | CPU_AP_DATA *CpuData;\r | |
258 | volatile MP_CPU_EXCHANGE_INFO *MpCpuExchangeInfo;\r | |
ffab2442 JF |
259 | \r |
260 | UINT32 CurrentTimerCount;\r | |
261 | UINTN DivideValue;\r | |
262 | UINT8 Vector;\r | |
263 | BOOLEAN PeriodicMode;\r | |
264 | BOOLEAN TimerInterruptState;\r | |
2a089134 ED |
265 | \r |
266 | UINT32 ProcessorSignature;\r | |
267 | UINT32 ProcessorFlags;\r | |
268 | UINT64 MicrocodeDataAddress;\r | |
269 | UINT32 MicrocodeRevision;\r | |
58942277 ED |
270 | \r |
271 | //\r | |
272 | // Whether need to use Init-Sipi-Sipi to wake up the APs.\r | |
273 | // Two cases need to set this value to TRUE. One is in HLT\r | |
274 | // loop mode, the other is resume from S3 which loop mode\r | |
e23d9c3e | 275 | // will be hardcode change to HLT mode by PiSmmCpuDxeSmm\r |
58942277 ED |
276 | // driver.\r |
277 | //\r | |
278 | BOOLEAN WakeUpByInitSipiSipi;\r | |
e59f8f6b | 279 | };\r |
93ca4c0f JF |
280 | \r |
281 | extern EFI_GUID mCpuInitMpLibHobGuid;\r | |
282 | \r | |
76157021 JF |
283 | /**\r |
284 | Assembly code to place AP into safe loop mode.\r | |
285 | \r | |
286 | Place AP into targeted C-State if MONITOR is supported, otherwise\r | |
287 | place AP into hlt state.\r | |
288 | Place AP in protected mode if the current is long mode. Due to AP maybe\r | |
289 | wakeup by some hardware event. It could avoid accessing page table that\r | |
290 | may not available during booting to OS.\r | |
291 | \r | |
292 | @param[in] MwaitSupport TRUE indicates MONITOR is supported.\r | |
293 | FALSE indicates MONITOR is not supported.\r | |
294 | @param[in] ApTargetCState Target C-State value.\r | |
295 | @param[in] PmCodeSegment Protected mode code segment value.\r | |
296 | **/\r | |
297 | typedef\r | |
298 | VOID\r | |
299 | (EFIAPI * ASM_RELOCATE_AP_LOOP) (\r | |
300 | IN BOOLEAN MwaitSupport,\r | |
301 | IN UINTN ApTargetCState,\r | |
bf2786dc | 302 | IN UINTN PmCodeSegment,\r |
9f91cb01 JF |
303 | IN UINTN TopOfApStack,\r |
304 | IN UINTN NumberToFinish\r | |
76157021 | 305 | );\r |
f7f85d83 JF |
306 | \r |
307 | /**\r | |
308 | Assembly code to get starting address and size of the rendezvous entry for APs.\r | |
309 | Information for fixing a jump instruction in the code is also returned.\r | |
310 | \r | |
311 | @param[out] AddressMap Output buffer for address map information.\r | |
312 | **/\r | |
313 | VOID\r | |
314 | EFIAPI\r | |
315 | AsmGetAddressMap (\r | |
316 | OUT MP_ASSEMBLY_ADDRESS_MAP *AddressMap\r | |
317 | );\r | |
318 | \r | |
41be0da5 JF |
319 | /**\r |
320 | This function is called by both the BSP and the AP which is to become the BSP to\r | |
321 | Exchange execution context including stack between them. After return from this\r | |
322 | function, the BSP becomes AP and the AP becomes the BSP.\r | |
323 | \r | |
324 | @param[in] MyInfo Pointer to buffer holding the exchanging information for the executing processor.\r | |
325 | @param[in] OthersInfo Pointer to buffer holding the exchanging information for the peer.\r | |
326 | \r | |
327 | **/\r | |
328 | VOID\r | |
329 | EFIAPI\r | |
330 | AsmExchangeRole (\r | |
331 | IN CPU_EXCHANGE_ROLE_INFO *MyInfo,\r | |
332 | IN CPU_EXCHANGE_ROLE_INFO *OthersInfo\r | |
333 | );\r | |
334 | \r | |
93ca4c0f JF |
335 | /**\r |
336 | Get the pointer to CPU MP Data structure.\r | |
337 | \r | |
338 | @return The pointer to CPU MP Data structure.\r | |
339 | **/\r | |
340 | CPU_MP_DATA *\r | |
341 | GetCpuMpData (\r | |
342 | VOID\r | |
343 | );\r | |
344 | \r | |
345 | /**\r | |
346 | Save the pointer to CPU MP Data structure.\r | |
347 | \r | |
348 | @param[in] CpuMpData The pointer to CPU MP Data structure will be saved.\r | |
349 | **/\r | |
350 | VOID\r | |
351 | SaveCpuMpData (\r | |
352 | IN CPU_MP_DATA *CpuMpData\r | |
353 | );\r | |
354 | \r | |
ed66e0e3 JF |
355 | \r |
356 | /**\r | |
a6b3d753 | 357 | Get available system memory below 1MB by specified size.\r |
ed66e0e3 | 358 | \r |
a6b3d753 SZ |
359 | @param[in] WakeupBufferSize Wakeup buffer size required\r |
360 | \r | |
361 | @retval other Return wakeup buffer address below 1MB.\r | |
362 | @retval -1 Cannot find free memory below 1MB.\r | |
ed66e0e3 | 363 | **/\r |
a6b3d753 SZ |
364 | UINTN\r |
365 | GetWakeupBuffer (\r | |
366 | IN UINTN WakeupBufferSize\r | |
ed66e0e3 JF |
367 | );\r |
368 | \r | |
f32bfe6d JW |
369 | /**\r |
370 | Get available EfiBootServicesCode memory below 4GB by specified size.\r | |
371 | \r | |
372 | This buffer is required to safely transfer AP from real address mode to\r | |
373 | protected mode or long mode, due to the fact that the buffer returned by\r | |
374 | GetWakeupBuffer() may be marked as non-executable.\r | |
375 | \r | |
376 | @param[in] BufferSize Wakeup transition buffer size.\r | |
377 | \r | |
378 | @retval other Return wakeup transition buffer address below 4GB.\r | |
379 | @retval 0 Cannot find free memory below 4GB.\r | |
380 | **/\r | |
381 | UINTN\r | |
382 | GetModeTransitionBuffer (\r | |
383 | IN UINTN BufferSize\r | |
384 | );\r | |
385 | \r | |
96f5920d JF |
386 | /**\r |
387 | This function will be called by BSP to wakeup AP.\r | |
388 | \r | |
389 | @param[in] CpuMpData Pointer to CPU MP Data\r | |
390 | @param[in] Broadcast TRUE: Send broadcast IPI to all APs\r | |
391 | FALSE: Send IPI to AP by ApicId\r | |
392 | @param[in] ProcessorNumber The handle number of specified processor\r | |
393 | @param[in] Procedure The function to be invoked by AP\r | |
394 | @param[in] ProcedureArgument The argument to be passed into AP function\r | |
cf4e79e4 | 395 | @param[in] WakeUpDisabledAps Whether need to wake up disabled APs in broadcast mode.\r |
96f5920d JF |
396 | **/\r |
397 | VOID\r | |
398 | WakeUpAP (\r | |
399 | IN CPU_MP_DATA *CpuMpData,\r | |
400 | IN BOOLEAN Broadcast,\r | |
401 | IN UINTN ProcessorNumber,\r | |
402 | IN EFI_AP_PROCEDURE Procedure, OPTIONAL\r | |
cf4e79e4 ED |
403 | IN VOID *ProcedureArgument, OPTIONAL\r |
404 | IN BOOLEAN WakeUpDisabledAps OPTIONAL\r | |
96f5920d JF |
405 | );\r |
406 | \r | |
93ca4c0f JF |
407 | /**\r |
408 | Initialize global data for MP support.\r | |
409 | \r | |
410 | @param[in] CpuMpData The pointer to CPU MP Data structure.\r | |
411 | **/\r | |
412 | VOID\r | |
413 | InitMpGlobalData (\r | |
414 | IN CPU_MP_DATA *CpuMpData\r | |
415 | );\r | |
416 | \r | |
86efe976 JF |
417 | /**\r |
418 | Worker function to execute a caller provided function on all enabled APs.\r | |
419 | \r | |
420 | @param[in] Procedure A pointer to the function to be run on\r | |
421 | enabled APs of the system.\r | |
422 | @param[in] SingleThread If TRUE, then all the enabled APs execute\r | |
423 | the function specified by Procedure one by\r | |
424 | one, in ascending order of processor handle\r | |
425 | number. If FALSE, then all the enabled APs\r | |
426 | execute the function specified by Procedure\r | |
427 | simultaneously.\r | |
ee0c39fa | 428 | @param[in] ExcludeBsp Whether let BSP also trig this task.\r |
86efe976 JF |
429 | @param[in] WaitEvent The event created by the caller with CreateEvent()\r |
430 | service.\r | |
367284e7 | 431 | @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for\r |
86efe976 JF |
432 | APs to return from Procedure, either for\r |
433 | blocking or non-blocking mode.\r | |
434 | @param[in] ProcedureArgument The parameter passed into Procedure for\r | |
435 | all APs.\r | |
436 | @param[out] FailedCpuList If all APs finish successfully, then its\r | |
437 | content is set to NULL. If not all APs\r | |
438 | finish before timeout expires, then its\r | |
439 | content is set to address of the buffer\r | |
440 | holding handle numbers of the failed APs.\r | |
441 | \r | |
442 | @retval EFI_SUCCESS In blocking mode, all APs have finished before\r | |
443 | the timeout expired.\r | |
444 | @retval EFI_SUCCESS In non-blocking mode, function has been dispatched\r | |
445 | to all enabled APs.\r | |
446 | @retval others Failed to Startup all APs.\r | |
447 | \r | |
448 | **/\r | |
449 | EFI_STATUS\r | |
ee0c39fa | 450 | StartupAllCPUsWorker (\r |
86efe976 JF |
451 | IN EFI_AP_PROCEDURE Procedure,\r |
452 | IN BOOLEAN SingleThread,\r | |
ee0c39fa | 453 | IN BOOLEAN ExcludeBsp,\r |
86efe976 JF |
454 | IN EFI_EVENT WaitEvent OPTIONAL,\r |
455 | IN UINTN TimeoutInMicroseconds,\r | |
456 | IN VOID *ProcedureArgument OPTIONAL,\r | |
457 | OUT UINTN **FailedCpuList OPTIONAL\r | |
458 | );\r | |
459 | \r | |
20ae5774 JF |
460 | /**\r |
461 | Worker function to let the caller get one enabled AP to execute a caller-provided\r | |
462 | function.\r | |
463 | \r | |
464 | @param[in] Procedure A pointer to the function to be run on\r | |
465 | enabled APs of the system.\r | |
466 | @param[in] ProcessorNumber The handle number of the AP.\r | |
467 | @param[in] WaitEvent The event created by the caller with CreateEvent()\r | |
468 | service.\r | |
367284e7 | 469 | @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for\r |
20ae5774 JF |
470 | APs to return from Procedure, either for\r |
471 | blocking or non-blocking mode.\r | |
472 | @param[in] ProcedureArgument The parameter passed into Procedure for\r | |
473 | all APs.\r | |
474 | @param[out] Finished If AP returns from Procedure before the\r | |
475 | timeout expires, its content is set to TRUE.\r | |
476 | Otherwise, the value is set to FALSE.\r | |
477 | \r | |
478 | @retval EFI_SUCCESS In blocking mode, specified AP finished before\r | |
479 | the timeout expires.\r | |
480 | @retval others Failed to Startup AP.\r | |
481 | \r | |
482 | **/\r | |
483 | EFI_STATUS\r | |
484 | StartupThisAPWorker (\r | |
485 | IN EFI_AP_PROCEDURE Procedure,\r | |
486 | IN UINTN ProcessorNumber,\r | |
487 | IN EFI_EVENT WaitEvent OPTIONAL,\r | |
488 | IN UINTN TimeoutInMicroseconds,\r | |
489 | IN VOID *ProcedureArgument OPTIONAL,\r | |
490 | OUT BOOLEAN *Finished OPTIONAL\r | |
491 | );\r | |
492 | \r | |
41be0da5 JF |
493 | /**\r |
494 | Worker function to switch the requested AP to be the BSP from that point onward.\r | |
495 | \r | |
496 | @param[in] ProcessorNumber The handle number of AP that is to become the new BSP.\r | |
497 | @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an\r | |
498 | enabled AP. Otherwise, it will be disabled.\r | |
499 | \r | |
500 | @retval EFI_SUCCESS BSP successfully switched.\r | |
7367cc6c | 501 | @retval others Failed to switch BSP.\r |
41be0da5 JF |
502 | \r |
503 | **/\r | |
504 | EFI_STATUS\r | |
505 | SwitchBSPWorker (\r | |
506 | IN UINTN ProcessorNumber,\r | |
507 | IN BOOLEAN EnableOldBSP\r | |
508 | );\r | |
509 | \r | |
e37109bc JF |
510 | /**\r |
511 | Worker function to let the caller enable or disable an AP from this point onward.\r | |
512 | This service may only be called from the BSP.\r | |
513 | \r | |
514 | @param[in] ProcessorNumber The handle number of AP.\r | |
515 | @param[in] EnableAP Specifies the new state for the processor for\r | |
516 | enabled, FALSE for disabled.\r | |
517 | @param[in] HealthFlag If not NULL, a pointer to a value that specifies\r | |
518 | the new health status of the AP.\r | |
519 | \r | |
520 | @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.\r | |
521 | @retval others Failed to Enable/Disable AP.\r | |
522 | \r | |
523 | **/\r | |
524 | EFI_STATUS\r | |
525 | EnableDisableApWorker (\r | |
526 | IN UINTN ProcessorNumber,\r | |
527 | IN BOOLEAN EnableAP,\r | |
528 | IN UINT32 *HealthFlag OPTIONAL\r | |
529 | );\r | |
530 | \r | |
93ca4c0f JF |
531 | /**\r |
532 | Get pointer to CPU MP Data structure from GUIDed HOB.\r | |
533 | \r | |
534 | @return The pointer to CPU MP Data structure.\r | |
535 | **/\r | |
536 | CPU_MP_DATA *\r | |
537 | GetCpuMpDataFromGuidedHob (\r | |
538 | VOID\r | |
539 | );\r | |
08085f08 JF |
540 | \r |
541 | /** Checks status of specified AP.\r | |
542 | \r | |
543 | This function checks whether the specified AP has finished the task assigned\r | |
544 | by StartupThisAP(), and whether timeout expires.\r | |
545 | \r | |
546 | @param[in] ProcessorNumber The handle number of processor.\r | |
547 | \r | |
548 | @retval EFI_SUCCESS Specified AP has finished task assigned by StartupThisAPs().\r | |
549 | @retval EFI_TIMEOUT The timeout expires.\r | |
550 | @retval EFI_NOT_READY Specified AP has not finished task and timeout has not expired.\r | |
551 | **/\r | |
552 | EFI_STATUS\r | |
553 | CheckThisAP (\r | |
554 | IN UINTN ProcessorNumber\r | |
555 | );\r | |
556 | \r | |
557 | /**\r | |
558 | Checks status of all APs.\r | |
559 | \r | |
560 | This function checks whether all APs have finished task assigned by StartupAllAPs(),\r | |
561 | and whether timeout expires.\r | |
562 | \r | |
563 | @retval EFI_SUCCESS All APs have finished task assigned by StartupAllAPs().\r | |
564 | @retval EFI_TIMEOUT The timeout expires.\r | |
565 | @retval EFI_NOT_READY APs have not finished task and timeout has not expired.\r | |
566 | **/\r | |
567 | EFI_STATUS\r | |
568 | CheckAllAPs (\r | |
569 | VOID\r | |
570 | );\r | |
571 | \r | |
572 | /**\r | |
573 | Checks APs status and updates APs status if needed.\r | |
574 | \r | |
575 | **/\r | |
576 | VOID\r | |
577 | CheckAndUpdateApsStatus (\r | |
578 | VOID\r | |
579 | );\r | |
580 | \r | |
94f63c76 JF |
581 | /**\r |
582 | Detect whether specified processor can find matching microcode patch and load it.\r | |
583 | \r | |
e1ed5573 HW |
584 | @param[in] CpuMpData The pointer to CPU MP Data structure.\r |
585 | @param[in] ProcessorNumber The handle number of the processor. The range is\r | |
586 | from 0 to the total number of logical processors\r | |
587 | minus 1.\r | |
94f63c76 JF |
588 | **/\r |
589 | VOID\r | |
590 | MicrocodeDetect (\r | |
2a089134 | 591 | IN CPU_MP_DATA *CpuMpData,\r |
e1ed5573 | 592 | IN UINTN ProcessorNumber\r |
94f63c76 JF |
593 | );\r |
594 | \r | |
d786a172 HW |
595 | /**\r |
596 | Load the required microcode patches data into memory.\r | |
597 | \r | |
598 | @param[in, out] CpuMpData The pointer to CPU MP Data structure.\r | |
599 | **/\r | |
600 | VOID\r | |
601 | LoadMicrocodePatch (\r | |
602 | IN OUT CPU_MP_DATA *CpuMpData\r | |
603 | );\r | |
604 | \r | |
4d3314f6 JF |
605 | /**\r |
606 | Detect whether Mwait-monitor feature is supported.\r | |
607 | \r | |
608 | @retval TRUE Mwait-monitor feature is supported.\r | |
609 | @retval FALSE Mwait-monitor feature is not supported.\r | |
610 | **/\r | |
611 | BOOLEAN\r | |
612 | IsMwaitSupport (\r | |
613 | VOID\r | |
614 | );\r | |
615 | \r | |
43c9fdcc JF |
616 | /**\r |
617 | Enable Debug Agent to support source debugging on AP function.\r | |
618 | \r | |
619 | **/\r | |
620 | VOID\r | |
621 | EnableDebugAgent (\r | |
622 | VOID\r | |
623 | );\r | |
624 | \r | |
e1ed5573 HW |
625 | /**\r |
626 | Find the current Processor number by APIC ID.\r | |
627 | \r | |
628 | @param[in] CpuMpData Pointer to PEI CPU MP Data\r | |
629 | @param[out] ProcessorNumber Return the pocessor number found\r | |
630 | \r | |
631 | @retval EFI_SUCCESS ProcessorNumber is found and returned.\r | |
632 | @retval EFI_NOT_FOUND ProcessorNumber is not found.\r | |
633 | **/\r | |
634 | EFI_STATUS\r | |
635 | GetProcessorNumber (\r | |
636 | IN CPU_MP_DATA *CpuMpData,\r | |
637 | OUT UINTN *ProcessorNumber\r | |
638 | );\r | |
639 | \r | |
3e8ad6bd JF |
640 | #endif\r |
641 | \r |