VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/CpuMpPei/CpuMpPei.h@ 105670

Last change on this file since 105670 was 105670, checked in by vboxsync, 4 months ago

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

  • Property svn:eol-style set to native
File size: 20.9 KB
Line 
1/** @file
2 Definitions to install Multiple Processor PPI.
3
4 Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#ifndef _CPU_MP_PEI_H_
10#define _CPU_MP_PEI_H_
11
12#include <PiPei.h>
13
14#include <Ppi/MpServices.h>
15#include <Ppi/SecPlatformInformation.h>
16#include <Ppi/SecPlatformInformation2.h>
17#include <Ppi/EndOfPeiPhase.h>
18#include <Ppi/MpServices2.h>
19
20#include <Library/BaseLib.h>
21#include <Library/DebugLib.h>
22#include <Library/HobLib.h>
23#include <Library/LocalApicLib.h>
24#include <Library/PeimEntryPoint.h>
25#include <Library/PeiServicesLib.h>
26#include <Library/ReportStatusCodeLib.h>
27#include <Library/CpuExceptionHandlerLib.h>
28#include <Library/MpInitLib.h>
29#include <Library/BaseMemoryLib.h>
30#include <Library/MemoryAllocationLib.h>
31#include <Library/CpuPageTableLib.h>
32
33#include <Guid/MpInformation2.h>
34
35#include <Register/Cpuid.h>
36
37extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc;
38
39/**
40 This service retrieves the number of logical processor in the platform
41 and the number of those logical processors that are enabled on this boot.
42 This service may only be called from the BSP.
43
44 This function is used to retrieve the following information:
45 - The number of logical processors that are present in the system.
46 - The number of enabled logical processors in the system at the instant
47 this call is made.
48
49 Because MP Service Ppi provides services to enable and disable processors
50 dynamically, the number of enabled logical processors may vary during the
51 course of a boot session.
52
53 If this service is called from an AP, then EFI_DEVICE_ERROR is returned.
54 If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then
55 EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors
56 is returned in NumberOfProcessors, the number of currently enabled processor
57 is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.
58
59 @param[in] PeiServices An indirect pointer to the PEI Services Table
60 published by the PEI Foundation.
61 @param[in] This Pointer to this instance of the PPI.
62 @param[out] NumberOfProcessors Pointer to the total number of logical processors in
63 the system, including the BSP and disabled APs.
64 @param[out] NumberOfEnabledProcessors
65 Number of processors in the system that are enabled.
66
67 @retval EFI_SUCCESS The number of logical processors and enabled
68 logical processors was retrieved.
69 @retval EFI_DEVICE_ERROR The calling processor is an AP.
70 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.
71 NumberOfEnabledProcessors is NULL.
72**/
73EFI_STATUS
74EFIAPI
75PeiGetNumberOfProcessors (
76 IN CONST EFI_PEI_SERVICES **PeiServices,
77 IN EFI_PEI_MP_SERVICES_PPI *This,
78 OUT UINTN *NumberOfProcessors,
79 OUT UINTN *NumberOfEnabledProcessors
80 );
81
82/**
83 Gets detailed MP-related information on the requested processor at the
84 instant this call is made. This service may only be called from the BSP.
85
86 This service retrieves detailed MP-related information about any processor
87 on the platform. Note the following:
88 - The processor information may change during the course of a boot session.
89 - The information presented here is entirely MP related.
90
91 Information regarding the number of caches and their sizes, frequency of operation,
92 slot numbers is all considered platform-related information and is not provided
93 by this service.
94
95 @param[in] PeiServices An indirect pointer to the PEI Services Table
96 published by the PEI Foundation.
97 @param[in] This Pointer to this instance of the PPI.
98 @param[in] ProcessorNumber Pointer to the total number of logical processors in
99 the system, including the BSP and disabled APs.
100 @param[out] ProcessorInfoBuffer Number of processors in the system that are enabled.
101
102 @retval EFI_SUCCESS Processor information was returned.
103 @retval EFI_DEVICE_ERROR The calling processor is an AP.
104 @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
105 @retval EFI_NOT_FOUND The processor with the handle specified by
106 ProcessorNumber does not exist in the platform.
107**/
108EFI_STATUS
109EFIAPI
110PeiGetProcessorInfo (
111 IN CONST EFI_PEI_SERVICES **PeiServices,
112 IN EFI_PEI_MP_SERVICES_PPI *This,
113 IN UINTN ProcessorNumber,
114 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
115 );
116
117/**
118 This service executes a caller provided function on all enabled APs. APs can
119 run either simultaneously or one at a time in sequence. This service supports
120 both blocking requests only. This service may only
121 be called from the BSP.
122
123 This function is used to dispatch all the enabled APs to the function specified
124 by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned
125 immediately and Procedure is not started on any AP.
126
127 If SingleThread is TRUE, all the enabled APs execute the function specified by
128 Procedure one by one, in ascending order of processor handle number. Otherwise,
129 all the enabled APs execute the function specified by Procedure simultaneously.
130
131 If the timeout specified by TimeoutInMicroSeconds expires before all APs return
132 from Procedure, then Procedure on the failed APs is terminated. All enabled APs
133 are always available for further calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
134 and EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If FailedCpuList is not NULL, its
135 content points to the list of processor handle numbers in which Procedure was
136 terminated.
137
138 Note: It is the responsibility of the consumer of the EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
139 to make sure that the nature of the code that is executed on the BSP and the
140 dispatched APs is well controlled. The MP Services Ppi does not guarantee
141 that the Procedure function is MP-safe. Hence, the tasks that can be run in
142 parallel are limited to certain independent tasks and well-controlled exclusive
143 code. PEI services and Ppis may not be called by APs unless otherwise
144 specified.
145
146 In blocking execution mode, BSP waits until all APs finish or
147 TimeoutInMicroSeconds expires.
148
149 @param[in] PeiServices An indirect pointer to the PEI Services Table
150 published by the PEI Foundation.
151 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
152 @param[in] Procedure A pointer to the function to be run on enabled APs of
153 the system.
154 @param[in] SingleThread If TRUE, then all the enabled APs execute the function
155 specified by Procedure one by one, in ascending order
156 of processor handle number. If FALSE, then all the
157 enabled APs execute the function specified by Procedure
158 simultaneously.
159 @param[in] TimeoutInMicroSeconds
160 Indicates the time limit in microseconds for APs to
161 return from Procedure, for blocking mode only. Zero
162 means infinity. If the timeout expires before all APs
163 return from Procedure, then Procedure on the failed APs
164 is terminated. All enabled APs are available for next
165 function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
166 or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the
167 timeout expires in blocking mode, BSP returns
168 EFI_TIMEOUT.
169 @param[in] ProcedureArgument The parameter passed into Procedure for all APs.
170
171 @retval EFI_SUCCESS In blocking mode, all APs have finished before the
172 timeout expired.
173 @retval EFI_DEVICE_ERROR Caller processor is AP.
174 @retval EFI_NOT_STARTED No enabled APs exist in the system.
175 @retval EFI_NOT_READY Any enabled APs are busy.
176 @retval EFI_TIMEOUT In blocking mode, the timeout expired before all
177 enabled APs have finished.
178 @retval EFI_INVALID_PARAMETER Procedure is NULL.
179**/
180EFI_STATUS
181EFIAPI
182PeiStartupAllAPs (
183 IN CONST EFI_PEI_SERVICES **PeiServices,
184 IN EFI_PEI_MP_SERVICES_PPI *This,
185 IN EFI_AP_PROCEDURE Procedure,
186 IN BOOLEAN SingleThread,
187 IN UINTN TimeoutInMicroSeconds,
188 IN VOID *ProcedureArgument OPTIONAL
189 );
190
191/**
192 This service lets the caller get one enabled AP to execute a caller-provided
193 function. The caller can request the BSP to wait for the completion
194 of the AP. This service may only be called from the BSP.
195
196 This function is used to dispatch one enabled AP to the function specified by
197 Procedure passing in the argument specified by ProcedureArgument.
198 The execution is in blocking mode. The BSP waits until the AP finishes or
199 TimeoutInMicroSecondss expires.
200
201 If the timeout specified by TimeoutInMicroseconds expires before the AP returns
202 from Procedure, then execution of Procedure by the AP is terminated. The AP is
203 available for subsequent calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() and
204 EFI_PEI_MP_SERVICES_PPI.StartupThisAP().
205
206 @param[in] PeiServices An indirect pointer to the PEI Services Table
207 published by the PEI Foundation.
208 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
209 @param[in] Procedure A pointer to the function to be run on enabled APs of
210 the system.
211 @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
212 total number of logical processors minus 1. The total
213 number of logical processors can be retrieved by
214 EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
215 @param[in] TimeoutInMicroseconds
216 Indicates the time limit in microseconds for APs to
217 return from Procedure, for blocking mode only. Zero
218 means infinity. If the timeout expires before all APs
219 return from Procedure, then Procedure on the failed APs
220 is terminated. All enabled APs are available for next
221 function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
222 or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the
223 timeout expires in blocking mode, BSP returns
224 EFI_TIMEOUT.
225 @param[in] ProcedureArgument The parameter passed into Procedure for all APs.
226
227 @retval EFI_SUCCESS In blocking mode, specified AP finished before the
228 timeout expires.
229 @retval EFI_DEVICE_ERROR The calling processor is an AP.
230 @retval EFI_TIMEOUT In blocking mode, the timeout expired before the
231 specified AP has finished.
232 @retval EFI_NOT_FOUND The processor with the handle specified by
233 ProcessorNumber does not exist.
234 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
235 @retval EFI_INVALID_PARAMETER Procedure is NULL.
236**/
237EFI_STATUS
238EFIAPI
239PeiStartupThisAP (
240 IN CONST EFI_PEI_SERVICES **PeiServices,
241 IN EFI_PEI_MP_SERVICES_PPI *This,
242 IN EFI_AP_PROCEDURE Procedure,
243 IN UINTN ProcessorNumber,
244 IN UINTN TimeoutInMicroseconds,
245 IN VOID *ProcedureArgument OPTIONAL
246 );
247
248/**
249 This service switches the requested AP to be the BSP from that point onward.
250 This service changes the BSP for all purposes. This call can only be performed
251 by the current BSP.
252
253 This service switches the requested AP to be the BSP from that point onward.
254 This service changes the BSP for all purposes. The new BSP can take over the
255 execution of the old BSP and continue seamlessly from where the old one left
256 off.
257
258 If the BSP cannot be switched prior to the return from this service, then
259 EFI_UNSUPPORTED must be returned.
260
261 @param[in] PeiServices An indirect pointer to the PEI Services Table
262 published by the PEI Foundation.
263 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
264 @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
265 total number of logical processors minus 1. The total
266 number of logical processors can be retrieved by
267 EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
268 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an enabled
269 AP. Otherwise, it will be disabled.
270
271 @retval EFI_SUCCESS BSP successfully switched.
272 @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to this
273 service returning.
274 @retval EFI_UNSUPPORTED Switching the BSP is not supported.
275 @retval EFI_DEVICE_ERROR The calling processor is an AP.
276 @retval EFI_NOT_FOUND The processor with the handle specified by
277 ProcessorNumber does not exist.
278 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or a disabled
279 AP.
280 @retval EFI_NOT_READY The specified AP is busy.
281**/
282EFI_STATUS
283EFIAPI
284PeiSwitchBSP (
285 IN CONST EFI_PEI_SERVICES **PeiServices,
286 IN EFI_PEI_MP_SERVICES_PPI *This,
287 IN UINTN ProcessorNumber,
288 IN BOOLEAN EnableOldBSP
289 );
290
291/**
292 This service lets the caller enable or disable an AP from this point onward.
293 This service may only be called from the BSP.
294
295 This service allows the caller enable or disable an AP from this point onward.
296 The caller can optionally specify the health status of the AP by Health. If
297 an AP is being disabled, then the state of the disabled AP is implementation
298 dependent. If an AP is enabled, then the implementation must guarantee that a
299 complete initialization sequence is performed on the AP, so the AP is in a state
300 that is compatible with an MP operating system.
301
302 If the enable or disable AP operation cannot be completed prior to the return
303 from this service, then EFI_UNSUPPORTED must be returned.
304
305 @param[in] PeiServices An indirect pointer to the PEI Services Table
306 published by the PEI Foundation.
307 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
308 @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
309 total number of logical processors minus 1. The total
310 number of logical processors can be retrieved by
311 EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
312 @param[in] EnableAP Specifies the new state for the processor for enabled,
313 FALSE for disabled.
314 @param[in] HealthFlag If not NULL, a pointer to a value that specifies the
315 new health status of the AP. This flag corresponds to
316 StatusFlag defined in EFI_PEI_MP_SERVICES_PPI.GetProcessorInfo().
317 Only the PROCESSOR_HEALTH_STATUS_BIT is used. All other
318 bits are ignored. If it is NULL, this parameter is
319 ignored.
320
321 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
322 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed prior
323 to this service returning.
324 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.
325 @retval EFI_DEVICE_ERROR The calling processor is an AP.
326 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber
327 does not exist.
328 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
329**/
330EFI_STATUS
331EFIAPI
332PeiEnableDisableAP (
333 IN CONST EFI_PEI_SERVICES **PeiServices,
334 IN EFI_PEI_MP_SERVICES_PPI *This,
335 IN UINTN ProcessorNumber,
336 IN BOOLEAN EnableAP,
337 IN UINT32 *HealthFlag OPTIONAL
338 );
339
340/**
341 This return the handle number for the calling processor. This service may be
342 called from the BSP and APs.
343
344 This service returns the processor handle number for the calling processor.
345 The returned value is in the range from 0 to the total number of logical
346 processors minus 1. The total number of logical processors can be retrieved
347 with EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). This service may be
348 called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER
349 is returned. Otherwise, the current processors handle number is returned in
350 ProcessorNumber, and EFI_SUCCESS is returned.
351
352 @param[in] PeiServices An indirect pointer to the PEI Services Table
353 published by the PEI Foundation.
354 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
355 @param[out] ProcessorNumber The handle number of the AP. The range is from 0 to the
356 total number of logical processors minus 1. The total
357 number of logical processors can be retrieved by
358 EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
359
360 @retval EFI_SUCCESS The current processor handle number was returned in
361 ProcessorNumber.
362 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
363**/
364EFI_STATUS
365EFIAPI
366PeiWhoAmI (
367 IN CONST EFI_PEI_SERVICES **PeiServices,
368 IN EFI_PEI_MP_SERVICES_PPI *This,
369 OUT UINTN *ProcessorNumber
370 );
371
372/**
373 Collects BIST data from PPI.
374
375 This function collects BIST data from Sec Platform Information2 PPI
376 or SEC Platform Information PPI.
377
378 @param PeiServices Pointer to PEI Services Table
379
380**/
381VOID
382CollectBistDataFromPpi (
383 IN CONST EFI_PEI_SERVICES **PeiServices
384 );
385
386/**
387 Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.
388
389 @param PeiServices The pointer to the PEI Services Table.
390 @param StructureSize The pointer to the variable describing size of the input buffer.
391 @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.
392
393 @retval EFI_SUCCESS The data was successfully returned.
394 @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to
395 hold the record is returned in StructureSize.
396
397**/
398EFI_STATUS
399EFIAPI
400SecPlatformInformation2 (
401 IN CONST EFI_PEI_SERVICES **PeiServices,
402 IN OUT UINT64 *StructureSize,
403 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2
404 );
405
406/**
407 Migrates the Global Descriptor Table (GDT) to permanent memory.
408
409 @retval EFI_SUCCESS The GDT was migrated successfully.
410 @retval EFI_OUT_OF_RESOURCES The GDT could not be migrated due to lack of available memory.
411
412**/
413EFI_STATUS
414MigrateGdt (
415 VOID
416 );
417
418/**
419 Initializes MP and exceptions handlers.
420
421 @param PeiServices The pointer to the PEI Services Table.
422
423 @retval EFI_SUCCESS MP was successfully initialized.
424 @retval others Error occurred in MP initialization.
425
426**/
427EFI_STATUS
428InitializeCpuMpWorker (
429 IN CONST EFI_PEI_SERVICES **PeiServices
430 );
431
432/**
433 Enable/setup stack guard for each processor if PcdCpuStackGuard is set to TRUE.
434
435 Doing this in the memory-discovered callback is to make sure the Stack Guard
436 feature to cover as most PEI code as possible.
437
438 @param[in] PeiServices General purpose services available to every PEIM.
439 @param[in] NotifyDescriptor The notification structure this PEIM registered on install.
440 @param[in] Ppi The memory discovered PPI. Not used.
441
442 @retval EFI_SUCCESS The function completed successfully.
443 @retval others There's error in MP initialization.
444**/
445EFI_STATUS
446EFIAPI
447MemoryDiscoveredPpiNotifyCallback (
448 IN EFI_PEI_SERVICES **PeiServices,
449 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
450 IN VOID *Ppi
451 );
452
453extern EFI_PEI_NOTIFY_DESCRIPTOR mPostMemNotifyList[];
454
455#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette