/
MpManagementInternal.h
224 lines (179 loc) · 6.01 KB
/
MpManagementInternal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/** @file
Internal metadata, enum and function definitions for MP management
protocol driver.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef MP_MANAGEMENT_INTERNAL_H_
#define MP_MANAGEMENT_INTERNAL_H_
typedef enum {
AP_TASK_IDLE,
AP_TASK_BUSY,
AP_TASK_ACTIVE,
AP_TASK_NUM
} AP_TASK;
typedef enum {
AP_STATE_ON,
AP_STATE_OFF,
AP_STATE_SUSPEND_HALT,
AP_STATE_SUSPEND_CLOCK_GATE,
AP_STATE_SUSPEND_SLEEP,
AP_STATE_RESUME,
AP_STATE_NUM
} AP_STATE;
#pragma pack (push, 1)
///
/// Structure that describes information about a logical CPU.
///
typedef struct {
UINTN ApStatus; // AP_STATE
UINTN TargetStatus; // AP_STATE
UINTN ApTask; // AP_TASK
UINTN TargetPowerState;
BASE_LIBRARY_JUMP_BUFFER JumpBuffer;
UINTN ApBufferSize;
VOID *ApBuffer;
VOID *CpuArchBuffer;
} MP_MANAGEMENT_METADATA;
#pragma pack (pop)
extern UINTN mNumCpus;
extern UINTN mBspIndex;
extern volatile MP_MANAGEMENT_METADATA *mCommonBuffer;
extern EFI_MP_SERVICES_PROTOCOL *mMpServices;
/** The procedure to run with the MP Services interface.
@param Arg The procedure argument.
**/
VOID
EFIAPI
ApFunction (
IN OUT VOID *Arg
);
/**
Architectural initialization routine, allowing different CPU architectures
to prepare their own register data buffer, data cache, etc.
@param NumOfCpus The number of CPUs supported on this platform.
@return EFI_SUCCESS The routine completed successfully.
@return Others The routine failed during operation.
**/
EFI_STATUS
CpuMpArchInit (
IN UINTN NumOfCpus
);
/**
This routine will setup/recover the AP specific interrupt states.
The main goal is to enable the AP to accept software generated
interrupts sent from BSP.
@param CpuIndex The number of intended CPU to be setup.
@return EFI_SUCCESS The routine completed successfully.
@return Others The routine failed during operation.
**/
EFI_STATUS
SetupInterruptStatus (
IN UINTN CpuIndex
);
/**
This routine will restore the AP specific interrupt states after
the entire AP routine is about to be completed.
@param CpuIndex The number of intended CPU to be setup.
@return EFI_SUCCESS The routine completed successfully.
@return Others The routine failed during operation.
**/
EFI_STATUS
RestoreInterruptStatus (
IN UINTN CpuIndex
);
/**
This routine will perform common architectural restores after all
types of suspend resumption.
@param CpuIndex The number of intended CPU to be setup.
@return EFI_SUCCESS The routine completed successfully.
@return Others The routine failed during operation.
**/
EFI_STATUS
CpuArchResumeCommon (
IN UINTN CpuIndex
);
/**
This routine will be used for suspending the currently running
processor to halt state. It could be run by both BSP and APs.
Given the state definition, this function will halt execution
until woken up.
@return EFI_SUCCESS The routine wake up successfully.
@return Others The routine failed during operation.
**/
EFI_STATUS
EFIAPI
CpuArchHalt (
VOID
);
/**
This routine will be used for suspending the currently running
processor to clock gate state. It could be run by both BSP and APs.
This architectural specific routine should validate whether the
power state is supported for clock gate suspension.
Given the state definition, this function will halt execution
until woken up.
@param PowerState The intended power state.
@return EFI_SUCCESS The routine wake up successfully.
@return Others The routine failed during operation.
**/
EFI_STATUS
EFIAPI
CpuArchClockGate (
IN UINTN PowerState OPTIONAL
);
/**
This routine will be used for suspending the currently running
processor to sleep state. It could be run by both BSP and APs.
This architectural specific routine should validate whether the
power state is supported for clock gate suspension.
Given the state definition, this function will make the CPU to
resume without any context. The caller should handle the data
saving and restoration accordingly.
@param PowerState The intended power state.
@return EFI_SUCCESS The routine wake up successfully.
@return Others The routine failed during operation.
**/
EFI_STATUS
EFIAPI
CpuArchSleep (
IN UINTN PowerState OPTIONAL
);
/**
This routine is invoked by BSP to wake up suspended APs.
@param CpuIndex The number of intended CPU to be setup.
@return None.
**/
VOID
EFIAPI
CpuArchWakeFromSleep (
UINTN CpuIndex
);
/**
This routine will be used for disabling all the current interrupts,
but set up timer interrupt to prepare for BSP suspension. It is only
run by BSP.
@param Handle An EFI_HANDLE that is used for the BSP to
manage and cache current interrupts' status.
@return EFI_SUCCESS The routine wake up successfully.
@return Others The routine failed during operation.
**/
EFI_STATUS
CpuArchDisableAllInterruptsButSetupTimer (
IN EFI_HANDLE *Handle,
IN UINTN TimeoutInMicroseconds
);
/**
This routine will be used for restoring all the interrupts, from
previously prepared EFI_HANDLE before BSP finishes timed suspension
routine. It is only run by BSP.
@param Handle An EFI_HANDLE that is used for the BSP to
manage and cache current interrupts' status.
@return EFI_SUCCESS The routine wake up successfully.
@return Others The routine failed during operation.
**/
EFI_STATUS
CpuArchRestoreAllInterrupts (
IN EFI_HANDLE Handle
);
#endif // MP_MANAGEMENT_INTERNAL_H_