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