]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/CpuDxe/CpuMp.h
UefiCpuPkg/CpuDxe: implement Mp Protocol:EnableDisableAP()
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuMp.h
1 /** @file
2 CPU DXE MP support
3
4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _CPU_MP_H_
16 #define _CPU_MP_H_
17
18 #include <Protocol/MpService.h>
19 #include <Library/SynchronizationLib.h>
20
21 /**
22 Initialize Multi-processor support.
23
24 **/
25 VOID
26 InitializeMpSupport (
27 VOID
28 );
29
30 typedef
31 VOID
32 (EFIAPI *STACKLESS_AP_ENTRY_POINT)(
33 VOID
34 );
35
36 /**
37 Starts the Application Processors and directs them to jump to the
38 specified routine.
39
40 The processor jumps to this code in flat mode, but the processor's
41 stack is not initialized.
42
43 @param ApEntryPoint Pointer to the Entry Point routine
44
45 @retval EFI_SUCCESS The APs were started
46 @retval EFI_OUT_OF_RESOURCES Cannot allocate memory to start APs
47
48 **/
49 EFI_STATUS
50 StartApsStackless (
51 IN STACKLESS_AP_ENTRY_POINT ApEntryPoint
52 );
53
54 /**
55 The AP entry point that the Startup-IPI target code will jump to.
56
57 The processor jumps to this code in flat mode, but the processor's
58 stack is not initialized.
59
60 **/
61 VOID
62 EFIAPI
63 AsmApEntryPoint (
64 VOID
65 );
66
67 /**
68 Releases the lock preventing other APs from using the shared AP
69 stack.
70
71 Once the AP has transitioned to using a new stack, it can call this
72 function to allow another AP to proceed with using the shared stack.
73
74 **/
75 VOID
76 EFIAPI
77 AsmApDoneWithCommonStack (
78 VOID
79 );
80
81 typedef enum {
82 CpuStateIdle,
83 CpuStateBlocked,
84 CpuStateReady,
85 CpuStateBuzy,
86 CpuStateFinished
87 } CPU_STATE;
88
89 /**
90 Define Individual Processor Data block.
91
92 **/
93 typedef struct {
94 EFI_PROCESSOR_INFORMATION Info;
95 SPIN_LOCK CpuDataLock;
96 volatile CPU_STATE State;
97
98 EFI_AP_PROCEDURE Procedure;
99 VOID *Parameter;
100 } CPU_DATA_BLOCK;
101
102 /**
103 Define MP data block which consumes individual processor block.
104
105 **/
106 typedef struct {
107 CPU_DATA_BLOCK *CpuDatas;
108 UINTN NumberOfProcessors;
109 UINTN NumberOfEnabledProcessors;
110 } MP_SYSTEM_DATA;
111
112 /**
113 This function is called by all processors (both BSP and AP) once and collects MP related data.
114
115 @param Bsp TRUE if the CPU is BSP
116 @param ProcessorNumber The specific processor number
117
118 @retval EFI_SUCCESS Data for the processor collected and filled in
119
120 **/
121 EFI_STATUS
122 FillInProcessorInformation (
123 IN BOOLEAN Bsp,
124 IN UINTN ProcessorNumber
125 );
126
127 /**
128 This service retrieves the number of logical processor in the platform
129 and the number of those logical processors that are enabled on this boot.
130 This service may only be called from the BSP.
131
132 This function is used to retrieve the following information:
133 - The number of logical processors that are present in the system.
134 - The number of enabled logical processors in the system at the instant
135 this call is made.
136
137 Because MP Service Protocol provides services to enable and disable processors
138 dynamically, the number of enabled logical processors may vary during the
139 course of a boot session.
140
141 If this service is called from an AP, then EFI_DEVICE_ERROR is returned.
142 If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then
143 EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors
144 is returned in NumberOfProcessors, the number of currently enabled processor
145 is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.
146
147 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
148 instance.
149 @param[out] NumberOfProcessors Pointer to the total number of logical
150 processors in the system, including the BSP
151 and disabled APs.
152 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
153 processors that exist in system, including
154 the BSP.
155
156 @retval EFI_SUCCESS The number of logical processors and enabled
157 logical processors was retrieved.
158 @retval EFI_DEVICE_ERROR The calling processor is an AP.
159 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.
160 @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL.
161
162 **/
163 EFI_STATUS
164 EFIAPI
165 GetNumberOfProcessors (
166 IN EFI_MP_SERVICES_PROTOCOL *This,
167 OUT UINTN *NumberOfProcessors,
168 OUT UINTN *NumberOfEnabledProcessors
169 );
170
171 /**
172 Gets detailed MP-related information on the requested processor at the
173 instant this call is made. This service may only be called from the BSP.
174
175 This service retrieves detailed MP-related information about any processor
176 on the platform. Note the following:
177 - The processor information may change during the course of a boot session.
178 - The information presented here is entirely MP related.
179
180 Information regarding the number of caches and their sizes, frequency of operation,
181 slot numbers is all considered platform-related information and is not provided
182 by this service.
183
184 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
185 instance.
186 @param[in] ProcessorNumber The handle number of processor.
187 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
188 the requested processor is deposited.
189
190 @retval EFI_SUCCESS Processor information was returned.
191 @retval EFI_DEVICE_ERROR The calling processor is an AP.
192 @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
193 @retval EFI_NOT_FOUND The processor with the handle specified by
194 ProcessorNumber does not exist in the platform.
195
196 **/
197 EFI_STATUS
198 EFIAPI
199 GetProcessorInfo (
200 IN EFI_MP_SERVICES_PROTOCOL *This,
201 IN UINTN ProcessorNumber,
202 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
203 );
204
205 /**
206 This service lets the caller enable or disable an AP from this point onward.
207 This service may only be called from the BSP.
208
209 This service allows the caller enable or disable an AP from this point onward.
210 The caller can optionally specify the health status of the AP by Health. If
211 an AP is being disabled, then the state of the disabled AP is implementation
212 dependent. If an AP is enabled, then the implementation must guarantee that a
213 complete initialization sequence is performed on the AP, so the AP is in a state
214 that is compatible with an MP operating system. This service may not be supported
215 after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled.
216
217 If the enable or disable AP operation cannot be completed prior to the return
218 from this service, then EFI_UNSUPPORTED must be returned.
219
220 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
221 @param[in] ProcessorNumber The handle number of AP that is to become the new
222 BSP. The range is from 0 to the total number of
223 logical processors minus 1. The total number of
224 logical processors can be retrieved by
225 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
226 @param[in] EnableAP Specifies the new state for the processor for
227 enabled, FALSE for disabled.
228 @param[in] HealthFlag If not NULL, a pointer to a value that specifies
229 the new health status of the AP. This flag
230 corresponds to StatusFlag defined in
231 EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only
232 the PROCESSOR_HEALTH_STATUS_BIT is used. All other
233 bits are ignored. If it is NULL, this parameter
234 is ignored.
235
236 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
237 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed
238 prior to this service returning.
239 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.
240 @retval EFI_DEVICE_ERROR The calling processor is an AP.
241 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber
242 does not exist.
243 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
244
245 **/
246 EFI_STATUS
247 EFIAPI
248 EnableDisableAP (
249 IN EFI_MP_SERVICES_PROTOCOL *This,
250 IN UINTN ProcessorNumber,
251 IN BOOLEAN EnableAP,
252 IN UINT32 *HealthFlag OPTIONAL
253 );
254
255 /**
256 This return the handle number for the calling processor. This service may be
257 called from the BSP and APs.
258
259 This service returns the processor handle number for the calling processor.
260 The returned value is in the range from 0 to the total number of logical
261 processors minus 1. The total number of logical processors can be retrieved
262 with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be
263 called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER
264 is returned. Otherwise, the current processors handle number is returned in
265 ProcessorNumber, and EFI_SUCCESS is returned.
266
267 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
268 @param[out] ProcessorNumber The handle number of AP that is to become the new
269 BSP. The range is from 0 to the total number of
270 logical processors minus 1. The total number of
271 logical processors can be retrieved by
272 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
273
274 @retval EFI_SUCCESS The current processor handle number was returned
275 in ProcessorNumber.
276 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
277
278 **/
279 EFI_STATUS
280 EFIAPI
281 WhoAmI (
282 IN EFI_MP_SERVICES_PROTOCOL *This,
283 OUT UINTN *ProcessorNumber
284 );
285
286 #endif // _CPU_MP_H_
287