]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
UefiCpuPkg/MpInitLib: Add MicrocodeDetect() and load microcode on BSP
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / DxeMpLib.c
CommitLineData
3e8ad6bd
JF
1/** @file\r
2 MP initialize support functions for DXE phase.\r
3\r
4 Copyright (c) 2016, 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#include "MpLib.h"\r
16\r
17/**\r
18 This service executes a caller provided function on all enabled APs.\r
19\r
20 @param[in] Procedure A pointer to the function to be run on\r
21 enabled APs of the system. See type\r
22 EFI_AP_PROCEDURE.\r
23 @param[in] SingleThread If TRUE, then all the enabled APs execute\r
24 the function specified by Procedure one by\r
25 one, in ascending order of processor handle\r
26 number. If FALSE, then all the enabled APs\r
27 execute the function specified by Procedure\r
28 simultaneously.\r
29 @param[in] WaitEvent The event created by the caller with CreateEvent()\r
30 service. If it is NULL, then execute in\r
31 blocking mode. BSP waits until all APs finish\r
32 or TimeoutInMicroSeconds expires. If it's\r
33 not NULL, then execute in non-blocking mode.\r
34 BSP requests the function specified by\r
35 Procedure to be started on all the enabled\r
36 APs, and go on executing immediately. If\r
37 all return from Procedure, or TimeoutInMicroSeconds\r
38 expires, this event is signaled. The BSP\r
39 can use the CheckEvent() or WaitForEvent()\r
40 services to check the state of event. Type\r
41 EFI_EVENT is defined in CreateEvent() in\r
42 the Unified Extensible Firmware Interface\r
43 Specification.\r
44 @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for\r
45 APs to return from Procedure, either for\r
46 blocking or non-blocking mode. Zero means\r
47 infinity. If the timeout expires before\r
48 all APs return from Procedure, then Procedure\r
49 on the failed APs is terminated. All enabled\r
50 APs are available for next function assigned\r
51 by MpInitLibStartupAllAPs() or\r
52 MPInitLibStartupThisAP().\r
53 If the timeout expires in blocking mode,\r
54 BSP returns EFI_TIMEOUT. If the timeout\r
55 expires in non-blocking mode, WaitEvent\r
56 is signaled with SignalEvent().\r
57 @param[in] ProcedureArgument The parameter passed into Procedure for\r
58 all APs.\r
59 @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise,\r
60 if all APs finish successfully, then its\r
61 content is set to NULL. If not all APs\r
62 finish before timeout expires, then its\r
63 content is set to address of the buffer\r
64 holding handle numbers of the failed APs.\r
65 The buffer is allocated by MP Initialization\r
66 library, and it's the caller's responsibility to\r
67 free the buffer with FreePool() service.\r
68 In blocking mode, it is ready for consumption\r
69 when the call returns. In non-blocking mode,\r
70 it is ready when WaitEvent is signaled. The\r
71 list of failed CPU is terminated by\r
72 END_OF_CPU_LIST.\r
73\r
74 @retval EFI_SUCCESS In blocking mode, all APs have finished before\r
75 the timeout expired.\r
76 @retval EFI_SUCCESS In non-blocking mode, function has been dispatched\r
77 to all enabled APs.\r
78 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r
79 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r
80 signaled.\r
81 @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not\r
82 supported.\r
83 @retval EFI_DEVICE_ERROR Caller processor is AP.\r
84 @retval EFI_NOT_STARTED No enabled APs exist in the system.\r
85 @retval EFI_NOT_READY Any enabled APs are busy.\r
86 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
87 @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r
88 all enabled APs have finished.\r
89 @retval EFI_INVALID_PARAMETER Procedure is NULL.\r
90\r
91**/\r
92EFI_STATUS\r
93EFIAPI\r
94MpInitLibStartupAllAPs (\r
95 IN EFI_AP_PROCEDURE Procedure,\r
96 IN BOOLEAN SingleThread,\r
97 IN EFI_EVENT WaitEvent OPTIONAL,\r
98 IN UINTN TimeoutInMicroseconds,\r
99 IN VOID *ProcedureArgument OPTIONAL,\r
100 OUT UINTN **FailedCpuList OPTIONAL\r
101 )\r
102{\r
103 return EFI_UNSUPPORTED;\r
104}\r
105\r
106/**\r
107 This service lets the caller get one enabled AP to execute a caller-provided\r
108 function.\r
109\r
110 @param[in] Procedure A pointer to the function to be run on the\r
111 designated AP of the system. See type\r
112 EFI_AP_PROCEDURE.\r
113 @param[in] ProcessorNumber The handle number of the AP. The range is\r
114 from 0 to the total number of logical\r
115 processors minus 1. The total number of\r
116 logical processors can be retrieved by\r
117 MpInitLibGetNumberOfProcessors().\r
118 @param[in] WaitEvent The event created by the caller with CreateEvent()\r
119 service. If it is NULL, then execute in\r
120 blocking mode. BSP waits until this AP finish\r
121 or TimeoutInMicroSeconds expires. If it's\r
122 not NULL, then execute in non-blocking mode.\r
123 BSP requests the function specified by\r
124 Procedure to be started on this AP,\r
125 and go on executing immediately. If this AP\r
126 return from Procedure or TimeoutInMicroSeconds\r
127 expires, this event is signaled. The BSP\r
128 can use the CheckEvent() or WaitForEvent()\r
129 services to check the state of event. Type\r
130 EFI_EVENT is defined in CreateEvent() in\r
131 the Unified Extensible Firmware Interface\r
132 Specification.\r
133 @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for\r
134 this AP to finish this Procedure, either for\r
135 blocking or non-blocking mode. Zero means\r
136 infinity. If the timeout expires before\r
137 this AP returns from Procedure, then Procedure\r
138 on the AP is terminated. The\r
139 AP is available for next function assigned\r
140 by MpInitLibStartupAllAPs() or\r
141 MpInitLibStartupThisAP().\r
142 If the timeout expires in blocking mode,\r
143 BSP returns EFI_TIMEOUT. If the timeout\r
144 expires in non-blocking mode, WaitEvent\r
145 is signaled with SignalEvent().\r
146 @param[in] ProcedureArgument The parameter passed into Procedure on the\r
147 specified AP.\r
148 @param[out] Finished If NULL, this parameter is ignored. In\r
149 blocking mode, this parameter is ignored.\r
150 In non-blocking mode, if AP returns from\r
151 Procedure before the timeout expires, its\r
152 content is set to TRUE. Otherwise, the\r
153 value is set to FALSE. The caller can\r
154 determine if the AP returned from Procedure\r
155 by evaluating this value.\r
156\r
157 @retval EFI_SUCCESS In blocking mode, specified AP finished before\r
158 the timeout expires.\r
159 @retval EFI_SUCCESS In non-blocking mode, the function has been\r
160 dispatched to specified AP.\r
161 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r
162 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r
163 signaled.\r
164 @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not\r
165 supported.\r
166 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
167 @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r
168 the specified AP has finished.\r
169 @retval EFI_NOT_READY The specified AP is busy.\r
170 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
171 @retval EFI_NOT_FOUND The processor with the handle specified by\r
172 ProcessorNumber does not exist.\r
173 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.\r
174 @retval EFI_INVALID_PARAMETER Procedure is NULL.\r
175\r
176**/\r
177EFI_STATUS\r
178EFIAPI\r
179MpInitLibStartupThisAP (\r
180 IN EFI_AP_PROCEDURE Procedure,\r
181 IN UINTN ProcessorNumber,\r
182 IN EFI_EVENT WaitEvent OPTIONAL,\r
183 IN UINTN TimeoutInMicroseconds,\r
184 IN VOID *ProcedureArgument OPTIONAL,\r
185 OUT BOOLEAN *Finished OPTIONAL\r
186 )\r
187{\r
188 return EFI_UNSUPPORTED;\r
189}\r
190\r
191/**\r
192 This service switches the requested AP to be the BSP from that point onward.\r
193 This service changes the BSP for all purposes. This call can only be performed\r
194 by the current BSP.\r
195\r
196 @param[in] ProcessorNumber The handle number of AP that is to become the new\r
197 BSP. The range is from 0 to the total number of\r
198 logical processors minus 1. The total number of\r
199 logical processors can be retrieved by\r
200 MpInitLibGetNumberOfProcessors().\r
201 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an\r
202 enabled AP. Otherwise, it will be disabled.\r
203\r
204 @retval EFI_SUCCESS BSP successfully switched.\r
205 @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to\r
206 this service returning.\r
207 @retval EFI_UNSUPPORTED Switching the BSP is not supported.\r
208 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
209 @retval EFI_NOT_FOUND The processor with the handle specified by\r
210 ProcessorNumber does not exist.\r
211 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or\r
212 a disabled AP.\r
213 @retval EFI_NOT_READY The specified AP is busy.\r
214 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
215\r
216**/\r
217EFI_STATUS\r
218EFIAPI\r
219MpInitLibSwitchBSP (\r
220 IN UINTN ProcessorNumber,\r
221 IN BOOLEAN EnableOldBSP\r
222 )\r
223{\r
224 return EFI_UNSUPPORTED;\r
225}\r
226\r
227/**\r
228 This service lets the caller enable or disable an AP from this point onward.\r
229 This service may only be called from the BSP.\r
230\r
231 @param[in] ProcessorNumber The handle number of AP.\r
232 The range is from 0 to the total number of\r
233 logical processors minus 1. The total number of\r
234 logical processors can be retrieved by\r
235 MpInitLibGetNumberOfProcessors().\r
236 @param[in] EnableAP Specifies the new state for the processor for\r
237 enabled, FALSE for disabled.\r
238 @param[in] HealthFlag If not NULL, a pointer to a value that specifies\r
239 the new health status of the AP. This flag\r
240 corresponds to StatusFlag defined in\r
241 EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only\r
242 the PROCESSOR_HEALTH_STATUS_BIT is used. All other\r
243 bits are ignored. If it is NULL, this parameter\r
244 is ignored.\r
245\r
246 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.\r
247 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed\r
248 prior to this service returning.\r
249 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.\r
250 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
251 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber\r
252 does not exist.\r
253 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.\r
254 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
255\r
256**/\r
257EFI_STATUS\r
258EFIAPI\r
259MpInitLibEnableDisableAP (\r
260 IN UINTN ProcessorNumber,\r
261 IN BOOLEAN EnableAP,\r
262 IN UINT32 *HealthFlag OPTIONAL\r
263 )\r
264{\r
265 return EFI_UNSUPPORTED;\r
266}\r