TianoCore EDK2 master
Loading...
Searching...
No Matches
DxeMpLib.c
Go to the documentation of this file.
1
9#include "MpLib.h"
10
13#include <Library/UefiLib.h>
14
15#include <Protocol/Timer.h>
16
17CPU_MP_DATA *mCpuMpData = NULL;
18EFI_EVENT mCheckAllApsEvent = NULL;
19volatile BOOLEAN mStopCheckAllApsStatus = TRUE;
20
25VOID
27 VOID
28 )
29{
30 //
31 // Initialize Debug Agent to support source level debug in DXE phase
32 //
33 InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_AP, NULL, NULL);
34}
35
43 VOID
44 )
45{
46 ASSERT (mCpuMpData != NULL);
47 return mCpuMpData;
48}
49
55VOID
57 IN CPU_MP_DATA *CpuMpData
58 )
59{
60 mCpuMpData = CpuMpData;
61}
62
77 IN UINTN BufferSize
78 )
79{
80 return 0;
81}
82
87VOID
89 VOID
90 )
91{
92 UINTN ProcessorNumber;
93 EFI_STATUS Status;
94 CPU_MP_DATA *CpuMpData;
95
96 CpuMpData = GetCpuMpData ();
97
98 //
99 // First, check whether pending StartupAllAPs() exists.
100 //
101 if (CpuMpData->WaitEvent != NULL) {
102 Status = CheckAllAPs ();
103 //
104 // If all APs finish for StartupAllAPs(), signal the WaitEvent for it.
105 //
106 if (Status != EFI_NOT_READY) {
107 Status = gBS->SignalEvent (CpuMpData->WaitEvent);
108 CpuMpData->WaitEvent = NULL;
109 }
110 }
111
112 //
113 // Second, check whether pending StartupThisAPs() callings exist.
114 //
115 for (ProcessorNumber = 0; ProcessorNumber < CpuMpData->CpuCount; ProcessorNumber++) {
116 if (CpuMpData->CpuData[ProcessorNumber].WaitEvent == NULL) {
117 continue;
118 }
119
120 Status = CheckThisAP (ProcessorNumber);
121
122 if (Status != EFI_NOT_READY) {
123 gBS->SignalEvent (CpuMpData->CpuData[ProcessorNumber].WaitEvent);
124 CpuMpData->CpuData[ProcessorNumber].WaitEvent = NULL;
125 }
126 }
127}
128
140VOID
141EFIAPI
143 IN EFI_EVENT Event,
144 IN VOID *Context
145 )
146{
147 //
148 // If CheckApsStatus() is not stopped, otherwise return immediately.
149 //
150 if (!mStopCheckAllApsStatus) {
152 }
153}
154
160VOID
162 IN CPU_MP_DATA *CpuMpData
163 )
164{
165 EFI_STATUS Status;
166
167 SaveCpuMpData (CpuMpData);
168
169 Status = gBS->CreateEvent (
170 EVT_TIMER | EVT_NOTIFY_SIGNAL,
171 TPL_NOTIFY,
173 NULL,
174 &mCheckAllApsEvent
175 );
176 ASSERT_EFI_ERROR (Status);
177
178 //
179 // Set timer to check all APs status.
180 //
181 Status = gBS->SetTimer (
182 mCheckAllApsEvent,
185 PcdGet32 (PcdCpuApStatusCheckIntervalInMicroSeconds)
186 )
187 );
188 ASSERT_EFI_ERROR (Status);
189}
190
267EFIAPI
269 IN EFI_AP_PROCEDURE Procedure,
270 IN BOOLEAN SingleThread,
271 IN EFI_EVENT WaitEvent OPTIONAL,
272 IN UINTN TimeoutInMicroseconds,
273 IN VOID *ProcedureArgument OPTIONAL,
274 OUT UINTN **FailedCpuList OPTIONAL
275 )
276{
277 EFI_STATUS Status;
278
279 //
280 // Temporarily stop checkAllApsStatus for avoid resource dead-lock.
281 //
282 mStopCheckAllApsStatus = TRUE;
283
284 Status = StartupAllCPUsWorker (
285 Procedure,
286 SingleThread,
287 TRUE,
288 WaitEvent,
289 TimeoutInMicroseconds,
290 ProcedureArgument,
291 FailedCpuList
292 );
293
294 //
295 // Start checkAllApsStatus
296 //
297 mStopCheckAllApsStatus = FALSE;
298
299 return Status;
300}
301
374EFIAPI
376 IN EFI_AP_PROCEDURE Procedure,
377 IN UINTN ProcessorNumber,
378 IN EFI_EVENT WaitEvent OPTIONAL,
379 IN UINTN TimeoutInMicroseconds,
380 IN VOID *ProcedureArgument OPTIONAL,
381 OUT BOOLEAN *Finished OPTIONAL
382 )
383{
384 EFI_STATUS Status;
385
386 //
387 // temporarily stop checkAllApsStatus for avoid resource dead-lock.
388 //
389 mStopCheckAllApsStatus = TRUE;
390
391 Status = StartupThisAPWorker (
392 Procedure,
393 ProcessorNumber,
394 WaitEvent,
395 TimeoutInMicroseconds,
396 ProcedureArgument,
397 Finished
398 );
399
400 mStopCheckAllApsStatus = FALSE;
401
402 return Status;
403}
404
432EFIAPI
434 IN UINTN ProcessorNumber,
435 IN BOOLEAN EnableOldBSP
436 )
437{
438 return EFI_UNSUPPORTED;
439}
440
472EFIAPI
474 IN UINTN ProcessorNumber,
475 IN BOOLEAN EnableAP,
476 IN UINT32 *HealthFlag OPTIONAL
477 )
478{
479 return EFI_UNSUPPORTED;
480}
UINT64 UINTN
VOID EFIAPI InitializeDebugAgent(IN UINT32 InitFlag, IN VOID *Context OPTIONAL, IN DEBUG_AGENT_CONTINUE Function OPTIONAL)
EFI_STATUS EFIAPI MpInitLibEnableDisableAP(IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
Definition: DxeMpLib.c:920
EFI_STATUS EFIAPI MpInitLibStartupAllAPs(IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT UINTN **FailedCpuList OPTIONAL)
Definition: DxeMpLib.c:682
VOID CheckAndUpdateApsStatus(VOID)
Definition: DxeMpLib.c:235
EFI_STATUS EFIAPI MpInitLibSwitchBSP(IN UINTN ProcessorNumber, IN BOOLEAN EnableOldBSP)
Definition: DxeMpLib.c:847
VOID EFIAPI CheckApsStatus(IN EFI_EVENT Event, IN VOID *Context)
Definition: DxeMpLib.c:289
CPU_MP_DATA * GetCpuMpData(VOID)
Definition: DxeMpLib.c:56
VOID InitMpGlobalData(IN CPU_MP_DATA *CpuMpData)
Definition: DxeMpLib.c:499
VOID EnableDebugAgent(VOID)
Definition: DxeMpLib.c:40
EFI_STATUS EFIAPI MpInitLibStartupThisAP(IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT BOOLEAN *Finished OPTIONAL)
Definition: DxeMpLib.c:789
VOID SaveCpuMpData(IN CPU_MP_DATA *CpuMpData)
Definition: DxeMpLib.c:70
UINTN GetModeTransitionBuffer(IN UINTN BufferSize)
Definition: DxeMpLib.c:76
EFI_STATUS StartupThisAPWorker(IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT BOOLEAN *Finished OPTIONAL)
Definition: MpLib.c:1176
EFI_STATUS StartupAllCPUsWorker(IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, IN BOOLEAN ExcludeBsp, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT UINTN **FailedCpuList OPTIONAL)
Definition: MpLib.c:1019
EFI_STATUS CheckThisAP(IN UINTN ProcessorNumber)
Definition: MpLib.c:863
EFI_STATUS CheckAllAPs(VOID)
Definition: MpLib.c:910
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
VOID(EFIAPI * EFI_AP_PROCEDURE)(IN OUT VOID *Buffer)
Definition: PiMultiPhase.h:198
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
EFI_BOOT_SERVICES * gBS
#define EFI_TIMER_PERIOD_MICROSECONDS(Microseconds)
Definition: UefiLib.h:74
@ TimerPeriodic
Definition: UefiSpec.h:535