]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/MpService.h
Add MP Services Protocol from the UEFI Platform Initialization 1.2 Specification
[mirror_edk2.git] / MdePkg / Include / Protocol / MpService.h
CommitLineData
82336c28 1/** @file\r
2 When installed, the MP Services Protocol produces a collection of services \r
3 that are needed for MP management.\r
4\r
5 The MP Services Protocol provides a generalized way of performing following tasks:\r
6 - Retrieving information of multi-processor environment and MP-related status of\r
7 specific processors.\r
8 - Dispatching user-provided function to APs.\r
9 - Maintain MP-related processor status.\r
10\r
11 The MP Services Protocol must be produced on any system with more than one logical\r
12 processor.\r
13\r
14 The Protocol is available only during boot time.\r
15\r
16 MP Services Protocol is hardware-independent. Most of the logic of this protocol\r
17 is architecturally neutral. It abstracts the multi-processor environment and \r
18 status of processors, and provides interfaces to retrieve information, maintain, \r
19 and dispatch.\r
20\r
21 MP Services Protocol may be consumed by ACPI module. The ACPI module may use this \r
22 protocol to retrieve data that are needed for an MP platform and report them to OS.\r
23 MP Services Protocol may also be used to program and configure processors, such \r
24 as MTRR synchronization for memory space attributes setting in DXE Services.\r
25 MP Services Protocol may be used by non-CPU DXE drivers to speed up platform boot \r
26 by taking advantage of the processing capabilities of the APs, for example, using \r
27 APs to help test system memory in parallel with other device initialization.\r
28 Diagnostics applications may also use this protocol for multi-processor.\r
29\r
30 Copyright (c) 2006 - 2009, Intel Corporation.<BR>\r
31 All rights reserved. This program and the accompanying materials\r
32 are licensed and made available under the terms and conditions of the BSD License\r
33 which accompanies this distribution. The full text of the license may be found at<BR>\r
34 http://opensource.org/licenses/bsd-license.php\r
35\r
36 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
37 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
38\r
39 @par Revision Reference:\r
40 This Protocol is defined in the UEFI Platform Initialization Specification 1.2, \r
41 Volume 2:Driver Execution Environment Core Interface.\r
42 \r
43**/\r
44\r
45#ifndef _MP_SERVICE_PROTOCOL_H_\r
46#define _MP_SERVICE_PROTOCOL_H_\r
47\r
48///\r
49/// Global ID for the EFI_MP_SERVICES_PROTOCOL\r
50///\r
51#define EFI_MP_SERVICES_PROTOCOL_GUID \\r
52 { \\r
53 0x3fdda605, 0xa76e, 0x4f46, {0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08} \\r
54 }\r
55\r
56///\r
57/// Forward declaration for the EFI_MP_SERVICES_PROTOCOL\r
58///\r
59typedef struct _EFI_MP_SERVICES_PROTOCOL EFI_MP_SERVICES_PROTOCOL;\r
60\r
61///\r
62/// Terminator for a list of failed CPUs returned by StartAllAPs().\r
63///\r
64#define END_OF_CPU_LIST 0xffffffff\r
65\r
66///\r
67/// This bit is used in the StatusFlag field of EFI_PROCESSOR_INFORMATION and \r
68/// indicates whether the processor is playing the role of BSP. If the bit is 1,\r
69/// then the processor is BSP. Otherwise, it is AP.\r
70///\r
71#define PROCESSOR_AS_BSP_BIT 0x00000001\r
72\r
73///\r
74/// This bit is used in the StatusFlag field of EFI_PROCESSOR_INFORMATION and \r
75/// indicates whether the processor is enabled. If the bit is 1, then the \r
76/// processor is enabled. Otherwise, it is disabled.\r
77///\r
78#define PROCESSOR_ENABLED_BIT 0x00000002\r
79\r
80///\r
81/// This bit is used in the StatusFlag field of EFI_PROCESSOR_INFORMATION and \r
82/// indicates whether the processor is healthy. If the bit is 1, then the \r
83/// processor is healthy. Otherwise, some fault has been detected for the processor.\r
84///\r
85#define PROCESSOR_HEALTH_STATUS_BIT 0x00000004\r
86\r
87///\r
88/// Structure that describes the pyhiscal location of a logical CPU.\r
89///\r
90typedef struct {\r
91 ///\r
92 /// Zero-based physical package number that identifies the cartridge of the processor.\r
93 ///\r
94 UINT32 Package;\r
95 ///\r
96 /// Zero-based physical core number within package of the processor.\r
97 ///\r
98 UINT32 Core;\r
99 ///\r
100 /// Zero-based logical thread number within core of the processor.\r
101 ///\r
102 UINT32 Thread;\r
103} EFI_CPU_PHYSICAL_LOCATION;\r
104\r
105///\r
106/// Structure that describes information about a logical CPU.\r
107///\r
108typedef struct {\r
109 ///\r
110 /// The unique processor ID determined by system hardware. For IA32 and X64, \r
111 /// the processor ID is the same as the Local APIC ID. Only the lower 8 bits \r
112 /// are used, and higher bits are reserved. For IPF, the lower 16 bits contains\r
113 /// id/eid, and higher bits are reserved.\r
114 ///\r
115 UINT64 ProcessorId; \r
116 ///\r
117 /// Flags indicating if the processor is BSP or AP, if the processor is enabled \r
118 /// or disabled, and if the processor is healthy. Bits 3..31 are reserved and \r
119 /// must be 0. \r
120 /// \r
121 /// <pre>\r
122 /// BSP ENABLED HEALTH Description\r
123 /// === ======= ====== ===================================================\r
124 /// 0 0 0 Unhealthy Disabled AP.\r
125 /// 0 0 1 Healthy Disabled AP.\r
126 /// 0 1 0 Unhealthy Enabled AP.\r
127 /// 0 1 1 Healthy Enabled AP.\r
128 /// 1 0 0 Invalid. The BSP can never be in the disabled state.\r
129 /// 1 0 1 Invalid. The BSP can never be in the disabled state.\r
130 /// 1 1 0 Unhealthy Enabled BSP.\r
131 /// 1 1 1 Healthy Enabled BSP\r
132 /// </pre>\r
133 ///\r
134 UINT32 StatusFlag;\r
135 ///\r
136 /// The physical location of the processor, including the physical package number\r
137 /// that identifies the cartridge, the physical core number within package, and \r
138 /// logical threadnumber within core.\r
139 ///\r
140 EFI_CPU_PHYSICAL_LOCATION Location;\r
141} EFI_PROCESSOR_INFORMATION;\r
142\r
143/**\r
144 Functions of this type are passed into StartUpAllAPs() and StartThisAP() to\r
145 execute a procedure on enabled APs. The context the AP should use durng \r
146 execution is specified by ProcedureArgument.\r
147 \r
148 @param[in] ProcedureArgument Pointer to the procedure's argument.\r
149\r
150**/\r
151typedef\r
152VOID\r
153(EFIAPI *EFI_AP_PROCEDURE)(\r
154 IN VOID *ProcedureArgument\r
155 );\r
156\r
157/**\r
158 This service retrieves the number of logical processor in the platform\r
159 and the number of those logical processors that are enabled on this boot.\r
160 This service may only be called from the BSP.\r
161\r
162 This function is used to retrieve the following information:\r
163 - The number of logical processors that are present in the system\r
164 - The number of enabled logical processors in the system at the instant \r
165 this call is made.\r
166\r
167 Since MP Service Protocol provides services to enable and disable processors \r
168 dynamically, the number of enabled logical processors may vary during the \r
169 course of a boot session.\r
170 \r
171 If this service is called from an AP, then EFI_DEVICE_ERROR is returned. \r
172 If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then \r
173 EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors \r
174 is returned in NumberOfProcessors, the number of currently enabled processor \r
175 is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.\r
176\r
177 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r
178 instance.\r
179 @param[out] NumberOfProcessors Pointer to the total number of logical\r
180 processors in the system, including the BSP\r
181 and disabled APs.\r
182 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical\r
183 processors that exist in system, including\r
184 the BSP.\r
185\r
186 @retval EFI_SUCCESS The number of logical processors and enabled \r
187 logical processors was retrieved.\r
188 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
189 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL\r
190 @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL\r
191\r
192**/\r
193typedef\r
194EFI_STATUS\r
195(EFIAPI *EFI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS)(\r
196 IN EFI_MP_SERVICES_PROTOCOL *This,\r
197 OUT UINTN *NumberOfProcessors,\r
198 OUT UINTN *NumberOfEnabledProcessors\r
199 );\r
200\r
201/**\r
202 Gets detailed MP-related information on the requested processor at the\r
203 instant this call is made. This service may only be called from the BSP.\r
204\r
205 This service retrieves detailed MP-related information about any processor \r
206 on the platform. Note the following:\r
207 - The processor information may change during the course of a boot session.\r
208 - The information presented here is entirely MP related.\r
209 \r
210 Information regarding the number of caches and their sizes, frequency of operation,\r
211 slot numbers is all considered platform-related information and is not provided \r
212 by this service.\r
213\r
214 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r
215 instance.\r
216 @param[in] ProcessorNumber The handle number of processor.\r
217 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for\r
218 the requested processor is deposited.\r
219\r
220 @retval EFI_SUCCESS Processor information was returned.\r
221 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
222 @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.\r
223 @retval EFI_NOT_FOUND The processor with the handle specified by\r
224 ProcessorNumber does not exist in the platform.\r
225\r
226**/\r
227typedef\r
228EFI_STATUS\r
229(EFIAPI *EFI_MP_SERVICES_GET_PROCESSOR_INFO)(\r
230 IN EFI_MP_SERVICES_PROTOCOL *This,\r
231 IN UINTN ProcessorNumber,\r
232 OUT EFI_PROCESSOR_INFORMATION *ProcessorContextBuffer\r
233 );\r
234\r
235/**\r
236 This service executes a caller provided function on all enabled APs. APs can \r
237 run either simultaneously or one at a time in sequence. This service supports \r
238 both blocking and non-blocking requests. The non-blocking requests use EFI \r
239 events so the BSP can detect when the APs have finished. This service may only \r
240 be called from the BSP.\r
241\r
242 This function is used to dispatch all the enabled APs to the function specified \r
243 by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned \r
244 immediately and Procedure is not started on any AP.\r
245\r
246 If SingleThread is TRUE, all the enabled APs execute the function specified by \r
247 Procedure one by one, in ascending order of processor handle number. Otherwise, \r
248 all the enabled APs execute the function specified by Procedure simultaneously.\r
249\r
250 If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all \r
251 APs finish or TimeoutInMicroSecs expires. Otherwise, execution is in non-blocking \r
252 mode, and the BSP returns from this service without waiting for APs. If a \r
253 non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT \r
254 is signaled, then EFI_UNSUPPORTED must be returned.\r
255\r
256 If the timeout specified by TimeoutInMicroseconds expires before all APs return \r
257 from Procedure, then Procedure on the failed APs is terminated. All enabled APs \r
258 are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
259 and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its \r
260 content points to the list of processor handle numbers in which Procedure was \r
261 terminated.\r
262\r
263 Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() \r
264 to make sure that the nature of the code that is executed on the BSP and the \r
265 dispatched APs is well controlled. The MP Services Protocol does not guarantee \r
266 that the Procedure function is MP-safe. Hence, the tasks that can be run in \r
267 parallel are limited to certain independent tasks and well-controlled exclusive \r
268 code. EFI services and protocols may not be called by APs unless otherwise \r
269 specified.\r
270\r
271 In blocking execution mode, BSP waits until all APs finish or \r
272 TimeoutInMicroSeconds expires.\r
273\r
274 In non-blocking execution mode, BSP is freed to return to the caller and then \r
275 proceed to the next task without having to wait for APs. The following \r
276 sequence needs to occur in a non-blocking execution mode:\r
277\r
278 -# The caller that intends to use this MP Services Protocol in non-blocking \r
279 mode creates WaitEvent by calling the EFI CreateEvent() service. The caller \r
280 invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent \r
281 is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests \r
282 the function specified by Procedure to be started on all the enabled APs, \r
283 and releases the BSP to continue with other tasks.\r
284 -# The caller can use the CheckEvent() and WaitForEvent() services to check \r
285 the state of the WaitEvent created in step 1.\r
286 -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP \r
287 Service signals WaitEvent by calling the EFI SignalEvent() function. If \r
288 FailedCpuList is not NULL, its content is available when WaitEvent is \r
289 signaled. If all APs returned from Procedure prior to the timeout, then \r
290 FailedCpuList is set to NULL. If not all APs return from Procedure before \r
291 the timeout, then FailedCpuList is filled in with the list of the failed \r
292 APs. The buffer is allocated by MP Service Protocol using AllocatePool(). \r
293