]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/CpuDxe/CpuMp.h
UefiCpuPkg/CpuDxe: implement Mp Protocol:EnableDisableAP()
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuMp.h
CommitLineData
6022e28c
JJ
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
003973d9 18#include <Protocol/MpService.h>\r
03673ae1 19#include <Library/SynchronizationLib.h>\r
003973d9 20\r
6022e28c
JJ
21/**\r
22 Initialize Multi-processor support.\r
23\r
24**/\r
25VOID\r
26InitializeMpSupport (\r
27 VOID\r
28 );\r
29\r
533263ee
JJ
30typedef\r
31VOID\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
49EFI_STATUS\r
50StartApsStackless (\r
51 IN STACKLESS_AP_ENTRY_POINT ApEntryPoint\r
52 );\r
53\r
fab82c18
JJ
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
61VOID\r
62EFIAPI\r
63AsmApEntryPoint (\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
75VOID\r
76EFIAPI\r
77AsmApDoneWithCommonStack (\r
78 VOID\r
79 );\r
80\r
03673ae1
CF
81typedef 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
93typedef 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} CPU_DATA_BLOCK;\r
101\r
102/**\r
103 Define MP data block which consumes individual processor block.\r
104\r
105**/\r
106typedef struct {\r
107 CPU_DATA_BLOCK *CpuDatas;\r
108 UINTN NumberOfProcessors;\r
109 UINTN NumberOfEnabledProcessors;\r
110} MP_SYSTEM_DATA;\r
111\r
112/**\r
113 This function is called by all processors (both BSP and AP) once and collects MP related data.\r
114\r
115 @param Bsp TRUE if the CPU is BSP\r
116 @param ProcessorNumber The specific processor number\r
117\r
118 @retval EFI_SUCCESS Data for the processor collected and filled in\r
119\r
120**/\r
121EFI_STATUS\r
122FillInProcessorInformation (\r
123 IN BOOLEAN Bsp,\r
124 IN UINTN ProcessorNumber\r
125 );\r
126\r
d894d8b7
CF
127/**\r
128 This service retrieves the number of logical processor in the platform\r
129 and the number of those logical processors that are enabled on this boot.\r
130 This service may only be called from the BSP.\r
131\r
132 This function is used to retrieve the following information:\r
133 - The number of logical processors that are present in the system.\r
134 - The number of enabled logical processors in the system at the instant\r
135 this call is made.\r
136\r
137 Because MP Service Protocol provides services to enable and disable processors\r
138 dynamically, the number of enabled logical processors may vary during the\r
139 course of a boot session.\r
140\r
141 If this service is called from an AP, then EFI_DEVICE_ERROR is returned.\r
142 If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then\r
143 EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors\r
144 is returned in NumberOfProcessors, the number of currently enabled processor\r
145 is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.\r
146\r
147 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r
148 instance.\r
149 @param[out] NumberOfProcessors Pointer to the total number of logical\r
150 processors in the system, including the BSP\r
151 and disabled APs.\r
152 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical\r
153 processors that exist in system, including\r
154 the BSP.\r
155\r
156 @retval EFI_SUCCESS The number of logical processors and enabled\r
157 logical processors was retrieved.\r
158 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
159 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.\r
160 @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL.\r
161\r
162**/\r
163EFI_STATUS\r
164EFIAPI\r
165GetNumberOfProcessors (\r
166 IN EFI_MP_SERVICES_PROTOCOL *This,\r
167 OUT UINTN *NumberOfProcessors,\r
168 OUT UINTN *NumberOfEnabledProcessors\r
169 );\r
170\r
e7938b5a
CF
171/**\r
172 Gets detailed MP-related information on the requested processor at the\r
173 instant this call is made. This service may only be called from the BSP.\r
174\r
175 This service retrieves detailed MP-related information about any processor\r
176 on the platform. Note the following:\r
177 - The processor information may change during the course of a boot session.\r
178 - The information presented here is entirely MP related.\r
179\r
180 Information regarding the number of caches and their sizes, frequency of operation,\r
181 slot numbers is all considered platform-related information and is not provided\r
182 by this service.\r
183\r
184 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r
185 instance.\r
186 @param[in] ProcessorNumber The handle number of processor.\r
187 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for\r
188 the requested processor is deposited.\r
189\r
190 @retval EFI_SUCCESS Processor information was returned.\r
191 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
192 @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.\r
193 @retval EFI_NOT_FOUND The processor with the handle specified by\r
194 ProcessorNumber does not exist in the platform.\r
195\r
196**/\r
197EFI_STATUS\r
198EFIAPI\r
199GetProcessorInfo (\r
200 IN EFI_MP_SERVICES_PROTOCOL *This,\r
201 IN UINTN ProcessorNumber,\r
202 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer\r
203 );\r
204\r
fa7ce675
CF
205/**\r
206 This service lets the caller enable or disable an AP from this point onward.\r
207 This service may only be called from the BSP.\r
208\r
209 This service allows the caller enable or disable an AP from this point onward.\r
210 The caller can optionally specify the health status of the AP by Health. If\r
211 an AP is being disabled, then the state of the disabled AP is implementation\r
212 dependent. If an AP is enabled, then the implementation must guarantee that a\r
213 complete initialization sequence is performed on the AP, so the AP is in a state\r
214 that is compatible with an MP operating system. This service may not be supported\r
215 after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled.\r
216\r
217 If the enable or disable AP operation cannot be completed prior to the return\r
218 from this service, then EFI_UNSUPPORTED must be returned.\r
219\r
220 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
221 @param[in] ProcessorNumber The handle number of AP that is to become the new\r
222 BSP. The range is from 0 to the total number of\r
223 logical processors minus 1. The total number of\r
224 logical processors can be retrieved by\r
225 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
226 @param[in] EnableAP Specifies the new state for the processor for\r
227 enabled, FALSE for disabled.\r
228 @param[in] HealthFlag If not NULL, a pointer to a value that specifies\r
229 the new health status of the AP. This flag\r
230 corresponds to StatusFlag defined in\r
231 EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only\r
232 the PROCESSOR_HEALTH_STATUS_BIT is used. All other\r
233 bits are ignored. If it is NULL, this parameter\r
234 is ignored.\r
235\r
236 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.\r
237 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed\r
238 prior to this service returning.\r
239 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.\r
240 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
241 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber\r
242 does not exist.\r
243 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.\r
244\r
245**/\r
246EFI_STATUS\r
247EFIAPI\r
248EnableDisableAP (\r
249 IN EFI_MP_SERVICES_PROTOCOL *This,\r
250 IN UINTN ProcessorNumber,\r
251 IN BOOLEAN EnableAP,\r
252 IN UINT32 *HealthFlag OPTIONAL\r
253 );\r
254\r
cfa2fac1
CF
255/**\r
256 This return the handle number for the calling processor. This service may be\r
257 called from the BSP and APs.\r
258\r
259 This service returns the processor handle number for the calling processor.\r
260 The returned value is in the range from 0 to the total number of logical\r
261 processors minus 1. The total number of logical processors can be retrieved\r
262 with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be\r
263 called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER\r
264 is returned. Otherwise, the current processors handle number is returned in\r
265 ProcessorNumber, and EFI_SUCCESS is returned.\r
266\r
267 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
268 @param[out] ProcessorNumber The handle number of AP that is to become the new\r
269 BSP. The range is from 0 to the total number of\r
270 logical processors minus 1. The total number of\r
271 logical processors can be retrieved by\r
272 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
273\r
274 @retval EFI_SUCCESS The current processor handle number was returned\r
275 in ProcessorNumber.\r
276 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.\r
277\r
278**/\r
279EFI_STATUS\r
280EFIAPI\r
281WhoAmI (\r
282 IN EFI_MP_SERVICES_PROTOCOL *This,\r
283 OUT UINTN *ProcessorNumber\r
284 );\r
285\r
6022e28c
JJ
286#endif // _CPU_MP_H_\r
287\r