]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/CpuMpPei/CpuMpPei.h
UefiCpuPkg/CpuMpPei: Remove un-used variables and functions
[mirror_edk2.git] / UefiCpuPkg / CpuMpPei / CpuMpPei.h
CommitLineData
ea0f431c
JF
1/** @file\r
2 Definitions to install Multiple Processor PPI.\r
3\r
9bedfb2f 4 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
ea0f431c
JF
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _CPU_MP_PEI_H_\r
16#define _CPU_MP_PEI_H_\r
17\r
18#include <PiPei.h>\r
19\r
20#include <Ppi/MpServices.h>\r
21#include <Ppi/SecPlatformInformation.h>\r
22#include <Ppi/SecPlatformInformation2.h>\r
23#include <Ppi/EndOfPeiPhase.h>\r
9bedfb2f 24#include <Ppi/VectorHandoffInfo.h>\r
ea0f431c 25\r
28a7ddf0 26#include <Register/Cpuid.h>\r
ea0f431c
JF
27#include <Register/LocalApic.h>\r
28\r
29#include <Library/BaseLib.h>\r
30#include <Library/BaseMemoryLib.h>\r
31#include <Library/DebugLib.h>\r
32#include <Library/HobLib.h>\r
33#include <Library/LocalApicLib.h>\r
34#include <Library/MtrrLib.h>\r
35#include <Library/PcdLib.h>\r
36#include <Library/PeimEntryPoint.h>\r
37#include <Library/PeiServicesLib.h>\r
38#include <Library/ReportStatusCodeLib.h>\r
39#include <Library/SynchronizationLib.h>\r
40#include <Library/TimerLib.h>\r
41#include <Library/UefiCpuLib.h>\r
c87e41b4 42#include <Library/CpuLib.h>\r
9bedfb2f 43#include <Library/CpuExceptionHandlerLib.h>\r
ea0f431c
JF
44\r
45#include "Microcode.h"\r
46\r
47//\r
48// AP state\r
49//\r
50typedef enum {\r
51 CpuStateIdle,\r
52 CpuStateBusy,\r
53 CpuStateDisabled\r
54} CPU_STATE;\r
55\r
c87e41b4
JF
56#define WAKEUP_AP_SIGNAL SIGNATURE_32 ('S', 'T', 'A', 'P')\r
57\r
4de216c0
JF
58typedef enum {\r
59 ApInHltLoop = 1,\r
60 ApInMwaitLoop = 2,\r
61 ApInRunLoop = 3\r
62} AP_LOOP_MODE;\r
63\r
ea0f431c
JF
64//\r
65// AP reset code information\r
66//\r
67typedef struct {\r
68 UINT8 *RendezvousFunnelAddress;\r
69 UINTN PModeEntryOffset;\r
70 UINTN LModeEntryOffset;\r
71 UINTN RendezvousFunnelSize;\r
72} MP_ASSEMBLY_ADDRESS_MAP;\r
73\r
74//\r
75// CPU exchange information for switch BSP\r
76//\r
77typedef struct {\r
78 UINT8 State; // offset 0\r
79 UINTN StackPointer; // offset 4 / 8\r
80 IA32_DESCRIPTOR Gdtr; // offset 8 / 16\r
81 IA32_DESCRIPTOR Idtr; // offset 14 / 26\r
82} CPU_EXCHANGE_ROLE_INFO;\r
83\r
84typedef struct _PEI_CPU_MP_DATA PEI_CPU_MP_DATA;\r
85\r
d603b115 86#pragma pack(1)\r
ea0f431c 87\r
ea0f431c
JF
88//\r
89// MP CPU exchange information for AP reset code\r
d603b115
JF
90// This structure is required to be packed because fixed field offsets\r
91// into this structure are used in assembly code in this module\r
ea0f431c
JF
92//\r
93typedef struct {\r
94 UINTN Lock;\r
95 UINTN StackStart;\r
96 UINTN StackSize;\r
97 UINTN CFunction;\r
98 IA32_DESCRIPTOR GdtrProfile;\r
99 IA32_DESCRIPTOR IdtrProfile;\r
100 UINTN BufferStart;\r
101 UINTN PmodeOffset;\r
102 UINTN NumApsExecuting;\r
ed04bffe
JF
103 UINTN CodeSegment;\r
104 UINTN DataSegment;\r
ea0f431c
JF
105 UINTN LmodeOffset;\r
106 UINTN Cr3;\r
107 PEI_CPU_MP_DATA *PeiCpuMpData;\r
108} MP_CPU_EXCHANGE_INFO;\r
109\r
110#pragma pack()\r
111\r
ef1fdb80
JF
112typedef struct {\r
113 UINTN Cr0;\r
114 UINTN Cr3;\r
115 UINTN Cr4;\r
116 UINTN Dr0;\r
117 UINTN Dr1;\r
118 UINTN Dr2;\r
119 UINTN Dr3;\r
120 UINTN Dr6;\r
121 UINTN Dr7;\r
122} CPU_VOLATILE_REGISTERS;\r
123\r
ea0f431c 124typedef struct {\r
e001e11f 125 volatile UINT32 *StartupApSignal;\r
ea0f431c
JF
126 UINT32 ApicId;\r
127 EFI_HEALTH_FLAGS Health;\r
128 CPU_STATE State;\r
129 BOOLEAN CpuHealthy;\r
ef1fdb80 130 CPU_VOLATILE_REGISTERS VolatileRegisters;\r
ea0f431c
JF
131} PEI_CPU_DATA;\r
132\r
133//\r
134// PEI CPU MP Data save in memory\r
135//\r
136struct _PEI_CPU_MP_DATA {\r
2f0261b7 137 SPIN_LOCK MpLock;\r
ea0f431c
JF
138 UINT32 CpuCount;\r
139 UINT32 BspNumber;\r
140 UINTN Buffer;\r
141 UINTN CpuApStackSize;\r
142 MP_ASSEMBLY_ADDRESS_MAP AddressMap;\r
143 UINTN WakeupBuffer;\r
144 UINTN BackupBuffer;\r
145 UINTN BackupBufferSize;\r
146 UINTN ApFunction;\r
147 UINTN ApFunctionArgument;\r
148 volatile UINT32 FinishedCount;\r
149 BOOLEAN EndOfPeiFlag;\r
150 BOOLEAN InitFlag;\r
2f0261b7 151 BOOLEAN X2ApicEnable;\r
ea0f431c
JF
152 CPU_EXCHANGE_ROLE_INFO BSPInfo;\r
153 CPU_EXCHANGE_ROLE_INFO APInfo;\r
154 MTRR_SETTINGS MtrrTable;\r
e001e11f
JF
155 UINT8 ApLoopMode;\r
156 UINT8 ApTargetCState;\r
ea0f431c
JF
157 PEI_CPU_DATA *CpuData;\r
158 volatile MP_CPU_EXCHANGE_INFO *MpCpuExchangeInfo;\r
159};\r
160extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc;\r
161\r
162\r
163/**\r
164 Assembly code to get starting address and size of the rendezvous entry for APs.\r
165 Information for fixing a jump instruction in the code is also returned.\r
166\r
167 @param AddressMap Output buffer for address map information.\r
168**/\r
169VOID\r
170EFIAPI\r
171AsmGetAddressMap (\r
172 OUT MP_ASSEMBLY_ADDRESS_MAP *AddressMap\r
173 );\r
174\r
175/**\r
176 Assembly code to load GDT table and update segment accordingly.\r
177\r
178 @param Gdtr Pointer to GDT descriptor\r
179**/\r
180VOID\r
181EFIAPI\r
182AsmInitializeGdt (\r
183 IN IA32_DESCRIPTOR *Gdtr\r
184 );\r
185\r
ea0f431c
JF
186/**\r
187 Get available system memory below 1MB by specified size.\r
188\r
189 @param PeiCpuMpData Pointer to PEI CPU MP Data\r
190**/\r
191VOID\r
192BackupAndPrepareWakeupBuffer(\r
193 IN PEI_CPU_MP_DATA *PeiCpuMpData\r
194 );\r
195\r
196/**\r
197 Restore wakeup buffer data.\r
198\r
199 @param PeiCpuMpData Pointer to PEI CPU MP Data\r
200**/\r
201VOID\r
202RestoreWakeupBuffer(\r
203 IN PEI_CPU_MP_DATA *PeiCpuMpData\r
204 );\r
205\r
206/**\r
207 Notify function on End Of Pei PPI.\r
208\r
209 On S3 boot, this function will restore wakeup buffer data.\r
210 On normal boot, this function will flag wakeup buffer to be un-used type.\r
211\r
212 @param PeiServices The pointer to the PEI Services Table.\r
213 @param NotifyDescriptor Address of the notification descriptor data structure.\r
214 @param Ppi Address of the PPI that was installed.\r
215\r
216 @retval EFI_SUCCESS When everything is OK.\r
217\r
218**/\r
219EFI_STATUS\r
220EFIAPI\r
221CpuMpEndOfPeiCallback (\r
222 IN EFI_PEI_SERVICES **PeiServices,\r
223 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
224 IN VOID *Ppi\r
225 );\r
226\r
227/**\r
228 This function will be called by BSP to wakeup AP.\r
229\r
230 @param PeiCpuMpData Pointer to PEI CPU MP Data\r
231 @param Broadcast TRUE: Send broadcast IPI to all APs\r
232 FALSE: Send IPI to AP by ApicId\r
a09647f3 233 @param ProcessorNumber The handle number of specified processor\r
ea0f431c
JF
234 @param Procedure The function to be invoked by AP\r
235 @param ProcedureArgument The argument to be passed into AP function\r
236**/\r
237VOID\r
238WakeUpAP (\r
239 IN PEI_CPU_MP_DATA *PeiCpuMpData,\r
240 IN BOOLEAN Broadcast,\r
a09647f3 241 IN UINTN ProcessorNumber,\r
ea0f431c
JF
242 IN EFI_AP_PROCEDURE Procedure, OPTIONAL\r
243 IN VOID *ProcedureArgument OPTIONAL\r
244 );\r
245\r
246/**\r
247 Get CPU MP Data pointer from the Guided HOB.\r
248\r
249 @return Pointer to Pointer to PEI CPU MP Data\r
250**/\r
251PEI_CPU_MP_DATA *\r
252GetMpHobData (\r
253 VOID\r
254 );\r
255\r
256/**\r
257 Find the current Processor number by APIC ID.\r
258\r
259 @param PeiCpuMpData Pointer to PEI CPU MP Data\r
260 @param ProcessorNumber Return the pocessor number found\r
261\r
262 @retval EFI_SUCCESS ProcessorNumber is found and returned.\r
263 @retval EFI_NOT_FOUND ProcessorNumber is not found.\r
264**/\r
265EFI_STATUS\r
266GetProcessorNumber (\r
267 IN PEI_CPU_MP_DATA *PeiCpuMpData,\r
268 OUT UINTN *ProcessorNumber\r
269 );\r
270\r
271/**\r
272 Collects BIST data from PPI.\r
273\r
274 This function collects BIST data from Sec Platform Information2 PPI\r
275 or SEC Platform Information PPI.\r
276\r
277 @param PeiServices Pointer to PEI Services Table\r
278 @param PeiCpuMpData Pointer to PEI CPU MP Data\r
279\r
280**/\r
281VOID\r
282CollectBistDataFromPpi (\r
283 IN CONST EFI_PEI_SERVICES **PeiServices,\r
284 IN PEI_CPU_MP_DATA *PeiCpuMpData\r
285 );\r
286\r
287/**\r
288 Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.\r
289\r
290 @param PeiServices The pointer to the PEI Services Table.\r
291 @param StructureSize The pointer to the variable describing size of the input buffer.\r
292 @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.\r
293\r
294 @retval EFI_SUCCESS The data was successfully returned.\r
295 @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to\r
296 hold the record is returned in StructureSize.\r
297\r
298**/\r
299EFI_STATUS\r
300EFIAPI\r
301SecPlatformInformation2 (\r
302 IN CONST EFI_PEI_SERVICES **PeiServices,\r
303 IN OUT UINT64 *StructureSize,\r
304 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2\r
305 );\r
306\r
719ff8cf
JF
307/**\r
308 Detect whether specified processor can find matching microcode patch and load it.\r
309\r
310 @param PeiCpuMpData Pointer to PEI CPU MP Data\r
311**/\r
312VOID\r
313MicrocodeDetect (\r
314 IN PEI_CPU_MP_DATA *PeiCpuMpData\r
315 );\r
316\r
ea0f431c 317#endif\r