VirtualBox

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

最後變更 在這個檔案從105668是 101291,由 vboxsync 提交於 17 月 前

EFI/FirmwareNew: Make edk2-stable202308 build on all supported platforms (using gcc at least, msvc not tested yet), bugref:4643

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

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