TianoCore EDK2 master
Loading...
Searching...
No Matches
MpLib.h
Go to the documentation of this file.
1
10#ifndef MP_LIB_H_
11#define MP_LIB_H_
12
13#include <PiPei.h>
16
17#include <Library/MpInitLib.h>
18#include <Library/BaseLib.h>
21#include <Library/DebugLib.h>
22#include <Library/CpuLib.h>
24#include <Library/TimerLib.h>
25#include <Library/HobLib.h>
26
27#define WAKEUP_AP_SIGNAL SIGNATURE_32 ('S', 'T', 'A', 'P')
28
29#define CPU_INIT_MP_LIB_HOB_GUID \
30 { \
31 0x58eb6a19, 0x3699, 0x4c68, { 0xa8, 0x36, 0xda, 0xcd, 0x8e, 0xdc, 0xad, 0x4a } \
32 }
33
34//
35// AP loop state when APs are in idle state
36// It's value is the same with PcdCpuApLoopMode
37//
38typedef enum {
39 ApInHltLoop = 1,
40 ApInRunLoop = 2
41} AP_LOOP_MODE;
42
43//
44// AP initialization state during APs wakeup
45//
46typedef enum {
47 ApInitConfig = 1,
48 ApInitReconfig = 2,
49 ApInitDone = 3
50} AP_INIT_STATE;
51
52//
53// AP state
54//
55typedef enum {
56 CpuStateIdle,
57 CpuStateReady,
58 CpuStateBusy,
59 CpuStateFinished,
60 CpuStateDisabled
61} CPU_STATE;
62
63//
64// AP related data
65//
66typedef struct {
67 SPIN_LOCK ApLock;
68 volatile UINT32 *StartupApSignal;
69 volatile UINTN ApFunction;
70 volatile UINTN ApFunctionArgument;
71 BOOLEAN CpuHealthy;
72 volatile CPU_STATE State;
73 BOOLEAN Waiting;
74 BOOLEAN *Finished;
75 UINT64 ExpectedTime;
76 UINT64 CurrentTime;
77 UINT64 TotalTime;
78 EFI_EVENT WaitEvent;
80
81//
82// Basic CPU information saved in Guided HOB.
83// Because the contents will be shard between PEI and DXE,
84// we need to make sure the each fields offset same in different
85// architecture.
86//
87#pragma pack (1)
88typedef struct {
89 UINT32 ApicId;
90 UINT32 Health;
92#pragma pack ()
93
94typedef struct MP_CPU_DATA CPU_MP_DATA;
95
96#pragma pack(1)
97
98//
99// MP CPU exchange information for AP reset code
100// This structure is required to be packed because fixed field offsets
101// into this structure are used in assembly code in this module
102//
103typedef struct {
104 CPU_MP_DATA *CpuMpData;
106
107#pragma pack()
108
109//
110// CPU MP Data save in memory
111//
113 UINT64 CpuInfoInHob;
114 UINT32 CpuCount;
115 UINT32 BspNumber;
116 //
117 // The above fields data will be passed from PEI to DXE
118 // Please make sure the fields offset same in the different
119 // architecture.
120 //
121 SPIN_LOCK MpLock;
122
123 volatile UINT32 FinishedCount;
124 UINT32 RunningCount;
125 BOOLEAN SingleThread;
126 EFI_AP_PROCEDURE Procedure;
127 VOID *ProcArguments;
128 BOOLEAN *Finished;
129 UINT64 ExpectedTime;
130 UINT64 CurrentTime;
131 UINT64 TotalTime;
132 EFI_EVENT WaitEvent;
133
134 AP_INIT_STATE InitFlag;
135 UINT8 ApLoopMode;
136 CPU_AP_DATA *CpuData;
137 volatile MP_CPU_EXCHANGE_INFO *MpCpuExchangeInfo;
138};
139
140extern EFI_GUID mCpuInitMpLibHobGuid;
141
149 VOID
150 );
151
157VOID
159 IN CPU_MP_DATA *CpuMpData
160 );
161
173VOID
174WakeUpAP (
175 IN CPU_MP_DATA *CpuMpData,
176 IN BOOLEAN Broadcast,
177 IN UINTN ProcessorNumber,
178 IN EFI_AP_PROCEDURE Procedure OPTIONAL,
179 IN VOID *ProcedureArgument OPTIONAL,
180 IN BOOLEAN WakeUpDisabledAps
181 );
182
188VOID
190 IN CPU_MP_DATA *CpuMpData
191 );
192
226 IN EFI_AP_PROCEDURE Procedure,
227 IN BOOLEAN SingleThread,
228 IN BOOLEAN ExcludeBsp,
229 IN EFI_EVENT WaitEvent OPTIONAL,
230 IN UINTN TimeoutInMicroseconds,
231 IN VOID *ProcedureArgument OPTIONAL,
232 OUT UINTN **FailedCpuList OPTIONAL
233 );
234
260 IN EFI_AP_PROCEDURE Procedure,
261 IN UINTN ProcessorNumber,
262 IN EFI_EVENT WaitEvent OPTIONAL,
263 IN UINTN TimeoutInMicroseconds,
264 IN VOID *ProcedureArgument OPTIONAL,
265 OUT BOOLEAN *Finished OPTIONAL
266 );
267
285 IN UINTN ProcessorNumber,
286 IN BOOLEAN EnableAP,
287 IN UINT32 *HealthFlag OPTIONAL
288 );
289
297 VOID
298 );
299
313 IN UINTN ProcessorNumber
314 );
315
328 VOID
329 );
330
335VOID
337 VOID
338 );
339
345VOID
347 VOID
348 );
349
350#endif
UINT64 UINTN
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
CPU_MP_DATA * GetCpuMpDataFromGuidedHob(VOID)
Definition: MpLib.c:1609
EFI_STATUS EnableDisableApWorker(IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
Definition: MpLib.c:2745
VOID CheckAndUpdateApsStatus(VOID)
Definition: DxeMpLib.c:235
VOID WakeUpAP(IN CPU_MP_DATA *CpuMpData, IN BOOLEAN Broadcast, IN UINTN ProcessorNumber, IN EFI_AP_PROCEDURE Procedure OPTIONAL, IN VOID *ProcedureArgument OPTIONAL, IN BOOLEAN WakeUpDisabledAps)
Definition: MpLib.c:672
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
CPU_MP_DATA * GetCpuMpData(VOID)
Definition: DxeMpLib.c:56
EFI_STATUS CheckAllAPs(VOID)
Definition: MpLib.c:910
VOID InitMpGlobalData(IN CPU_MP_DATA *CpuMpData)
Definition: DxeMpLib.c:499
VOID EnableDebugAgent(VOID)
Definition: DxeMpLib.c:40
VOID SaveCpuMpData(IN CPU_MP_DATA *CpuMpData)
Definition: DxeMpLib.c:70
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
VOID(EFIAPI * EFI_AP_PROCEDURE)(IN OUT VOID *Buffer)
Definition: PiMultiPhase.h:198
volatile UINTN SPIN_LOCK
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
Definition: Base.h:213