2 Definitions to install Multiple Processor PPI.
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _CPU_MP_PEI_H_
16 #define _CPU_MP_PEI_H_
20 #include <Ppi/MpServices.h>
21 #include <Ppi/SecPlatformInformation.h>
22 #include <Ppi/SecPlatformInformation2.h>
23 #include <Ppi/EndOfPeiPhase.h>
25 #include <Register/Cpuid.h>
26 #include <Register/LocalApic.h>
28 #include <Library/BaseLib.h>
29 #include <Library/BaseMemoryLib.h>
30 #include <Library/DebugLib.h>
31 #include <Library/HobLib.h>
32 #include <Library/LocalApicLib.h>
33 #include <Library/MtrrLib.h>
34 #include <Library/PcdLib.h>
35 #include <Library/PeimEntryPoint.h>
36 #include <Library/PeiServicesLib.h>
37 #include <Library/ReportStatusCodeLib.h>
38 #include <Library/SynchronizationLib.h>
39 #include <Library/TimerLib.h>
40 #include <Library/UefiCpuLib.h>
41 #include <Library/CpuLib.h>
43 #include "Microcode.h"
54 #define WAKEUP_AP_SIGNAL SIGNATURE_32 ('S', 'T', 'A', 'P')
63 // AP reset code information
66 UINT8
*RendezvousFunnelAddress
;
67 UINTN PModeEntryOffset
;
68 UINTN LModeEntryOffset
;
69 UINTN RendezvousFunnelSize
;
70 } MP_ASSEMBLY_ADDRESS_MAP
;
73 // CPU exchange information for switch BSP
76 UINT8 State
; // offset 0
77 UINTN StackPointer
; // offset 4 / 8
78 IA32_DESCRIPTOR Gdtr
; // offset 8 / 16
79 IA32_DESCRIPTOR Idtr
; // offset 14 / 26
80 } CPU_EXCHANGE_ROLE_INFO
;
82 typedef struct _PEI_CPU_MP_DATA PEI_CPU_MP_DATA
;
98 UINT32 DefaultSize
: 1;
99 UINT32 Granularity
: 1;
106 // MP CPU exchange information for AP reset code
107 // This structure is required to be packed because fixed field offsets
108 // into this structure are used in assembly code in this module
115 IA32_DESCRIPTOR GdtrProfile
;
116 IA32_DESCRIPTOR IdtrProfile
;
119 UINTN NumApsExecuting
;
122 PEI_CPU_MP_DATA
*PeiCpuMpData
;
123 } MP_CPU_EXCHANGE_INFO
;
137 } CPU_VOLATILE_REGISTERS
;
140 volatile UINT32
*StartupApSignal
;
142 EFI_HEALTH_FLAGS Health
;
145 CPU_VOLATILE_REGISTERS VolatileRegisters
;
149 // PEI CPU MP Data save in memory
151 struct _PEI_CPU_MP_DATA
{
156 UINTN CpuApStackSize
;
157 MP_ASSEMBLY_ADDRESS_MAP AddressMap
;
160 UINTN BackupBufferSize
;
162 UINTN ApFunctionArgument
;
163 volatile UINT32 FinishedCount
;
164 BOOLEAN EndOfPeiFlag
;
166 BOOLEAN X2ApicEnable
;
167 CPU_EXCHANGE_ROLE_INFO BSPInfo
;
168 CPU_EXCHANGE_ROLE_INFO APInfo
;
169 MTRR_SETTINGS MtrrTable
;
171 UINT8 ApTargetCState
;
172 PEI_CPU_DATA
*CpuData
;
173 volatile MP_CPU_EXCHANGE_INFO
*MpCpuExchangeInfo
;
175 extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc
;
179 Assembly code to get starting address and size of the rendezvous entry for APs.
180 Information for fixing a jump instruction in the code is also returned.
182 @param AddressMap Output buffer for address map information.
187 OUT MP_ASSEMBLY_ADDRESS_MAP
*AddressMap
191 Assembly code to load GDT table and update segment accordingly.
193 @param Gdtr Pointer to GDT descriptor
198 IN IA32_DESCRIPTOR
*Gdtr
202 Assembly code to do CLI-HALT loop.
212 Get available system memory below 1MB by specified size.
214 @param PeiCpuMpData Pointer to PEI CPU MP Data
217 BackupAndPrepareWakeupBuffer(
218 IN PEI_CPU_MP_DATA
*PeiCpuMpData
222 Restore wakeup buffer data.
224 @param PeiCpuMpData Pointer to PEI CPU MP Data
228 IN PEI_CPU_MP_DATA
*PeiCpuMpData
232 Notify function on End Of Pei PPI.
234 On S3 boot, this function will restore wakeup buffer data.
235 On normal boot, this function will flag wakeup buffer to be un-used type.
237 @param PeiServices The pointer to the PEI Services Table.
238 @param NotifyDescriptor Address of the notification descriptor data structure.
239 @param Ppi Address of the PPI that was installed.
241 @retval EFI_SUCCESS When everything is OK.
246 CpuMpEndOfPeiCallback (
247 IN EFI_PEI_SERVICES
**PeiServices
,
248 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
253 This function will be called by BSP to wakeup AP.
255 @param PeiCpuMpData Pointer to PEI CPU MP Data
256 @param Broadcast TRUE: Send broadcast IPI to all APs
257 FALSE: Send IPI to AP by ApicId
258 @param ProcessorNumber The handle number of specified processor
259 @param Procedure The function to be invoked by AP
260 @param ProcedureArgument The argument to be passed into AP function
264 IN PEI_CPU_MP_DATA
*PeiCpuMpData
,
265 IN BOOLEAN Broadcast
,
266 IN UINTN ProcessorNumber
,
267 IN EFI_AP_PROCEDURE Procedure
, OPTIONAL
268 IN VOID
*ProcedureArgument OPTIONAL
272 Get CPU MP Data pointer from the Guided HOB.
274 @return Pointer to Pointer to PEI CPU MP Data
282 Find the current Processor number by APIC ID.
284 @param PeiCpuMpData Pointer to PEI CPU MP Data
285 @param ProcessorNumber Return the pocessor number found
287 @retval EFI_SUCCESS ProcessorNumber is found and returned.
288 @retval EFI_NOT_FOUND ProcessorNumber is not found.
292 IN PEI_CPU_MP_DATA
*PeiCpuMpData
,
293 OUT UINTN
*ProcessorNumber
297 Collects BIST data from PPI.
299 This function collects BIST data from Sec Platform Information2 PPI
300 or SEC Platform Information PPI.
302 @param PeiServices Pointer to PEI Services Table
303 @param PeiCpuMpData Pointer to PEI CPU MP Data
307 CollectBistDataFromPpi (
308 IN CONST EFI_PEI_SERVICES
**PeiServices
,
309 IN PEI_CPU_MP_DATA
*PeiCpuMpData
313 Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.
315 @param PeiServices The pointer to the PEI Services Table.
316 @param StructureSize The pointer to the variable describing size of the input buffer.
317 @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.
319 @retval EFI_SUCCESS The data was successfully returned.
320 @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to
321 hold the record is returned in StructureSize.
326 SecPlatformInformation2 (
327 IN CONST EFI_PEI_SERVICES
**PeiServices
,
328 IN OUT UINT64
*StructureSize
,
329 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2
*PlatformInformationRecord2