2 Definitions to install Multiple Processor PPI.
4 Copyright (c) 2015 - 2016, 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>
24 #include <Ppi/VectorHandoffInfo.h>
26 #include <Register/Cpuid.h>
27 #include <Register/LocalApic.h>
29 #include <Library/BaseLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/DebugLib.h>
32 #include <Library/HobLib.h>
33 #include <Library/LocalApicLib.h>
34 #include <Library/MtrrLib.h>
35 #include <Library/PcdLib.h>
36 #include <Library/PeimEntryPoint.h>
37 #include <Library/PeiServicesLib.h>
38 #include <Library/ReportStatusCodeLib.h>
39 #include <Library/SynchronizationLib.h>
40 #include <Library/TimerLib.h>
41 #include <Library/UefiCpuLib.h>
42 #include <Library/CpuLib.h>
43 #include <Library/CpuExceptionHandlerLib.h>
45 #include "Microcode.h"
56 #define WAKEUP_AP_SIGNAL SIGNATURE_32 ('S', 'T', 'A', 'P')
65 // AP reset code information
68 UINT8
*RendezvousFunnelAddress
;
69 UINTN PModeEntryOffset
;
70 UINTN LModeEntryOffset
;
71 UINTN RendezvousFunnelSize
;
72 } MP_ASSEMBLY_ADDRESS_MAP
;
75 // CPU exchange information for switch BSP
78 UINT8 State
; // offset 0
79 UINTN StackPointer
; // offset 4 / 8
80 IA32_DESCRIPTOR Gdtr
; // offset 8 / 16
81 IA32_DESCRIPTOR Idtr
; // offset 14 / 26
82 } CPU_EXCHANGE_ROLE_INFO
;
84 typedef struct _PEI_CPU_MP_DATA PEI_CPU_MP_DATA
;
100 UINT32 DefaultSize
: 1;
101 UINT32 Granularity
: 1;
108 // MP CPU exchange information for AP reset code
109 // This structure is required to be packed because fixed field offsets
110 // into this structure are used in assembly code in this module
117 IA32_DESCRIPTOR GdtrProfile
;
118 IA32_DESCRIPTOR IdtrProfile
;
121 UINTN NumApsExecuting
;
126 PEI_CPU_MP_DATA
*PeiCpuMpData
;
127 } MP_CPU_EXCHANGE_INFO
;
141 } CPU_VOLATILE_REGISTERS
;
144 volatile UINT32
*StartupApSignal
;
146 EFI_HEALTH_FLAGS Health
;
149 CPU_VOLATILE_REGISTERS VolatileRegisters
;
153 // PEI CPU MP Data save in memory
155 struct _PEI_CPU_MP_DATA
{
160 UINTN CpuApStackSize
;
161 MP_ASSEMBLY_ADDRESS_MAP AddressMap
;
164 UINTN BackupBufferSize
;
166 UINTN ApFunctionArgument
;
167 volatile UINT32 FinishedCount
;
168 BOOLEAN EndOfPeiFlag
;
170 BOOLEAN X2ApicEnable
;
171 CPU_EXCHANGE_ROLE_INFO BSPInfo
;
172 CPU_EXCHANGE_ROLE_INFO APInfo
;
173 MTRR_SETTINGS MtrrTable
;
175 UINT8 ApTargetCState
;
176 PEI_CPU_DATA
*CpuData
;
177 volatile MP_CPU_EXCHANGE_INFO
*MpCpuExchangeInfo
;
179 extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc
;
183 Assembly code to get starting address and size of the rendezvous entry for APs.
184 Information for fixing a jump instruction in the code is also returned.
186 @param AddressMap Output buffer for address map information.
191 OUT MP_ASSEMBLY_ADDRESS_MAP
*AddressMap
195 Assembly code to load GDT table and update segment accordingly.
197 @param Gdtr Pointer to GDT descriptor
202 IN IA32_DESCRIPTOR
*Gdtr
206 Get available system memory below 1MB by specified size.
208 @param PeiCpuMpData Pointer to PEI CPU MP Data
211 BackupAndPrepareWakeupBuffer(
212 IN PEI_CPU_MP_DATA
*PeiCpuMpData
216 Restore wakeup buffer data.
218 @param PeiCpuMpData Pointer to PEI CPU MP Data
222 IN PEI_CPU_MP_DATA
*PeiCpuMpData
226 Notify function on End Of Pei PPI.
228 On S3 boot, this function will restore wakeup buffer data.
229 On normal boot, this function will flag wakeup buffer to be un-used type.
231 @param PeiServices The pointer to the PEI Services Table.
232 @param NotifyDescriptor Address of the notification descriptor data structure.
233 @param Ppi Address of the PPI that was installed.
235 @retval EFI_SUCCESS When everything is OK.
240 CpuMpEndOfPeiCallback (
241 IN EFI_PEI_SERVICES
**PeiServices
,
242 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
247 This function will be called by BSP to wakeup AP.
249 @param PeiCpuMpData Pointer to PEI CPU MP Data
250 @param Broadcast TRUE: Send broadcast IPI to all APs
251 FALSE: Send IPI to AP by ApicId
252 @param ProcessorNumber The handle number of specified processor
253 @param Procedure The function to be invoked by AP
254 @param ProcedureArgument The argument to be passed into AP function
258 IN PEI_CPU_MP_DATA
*PeiCpuMpData
,
259 IN BOOLEAN Broadcast
,
260 IN UINTN ProcessorNumber
,
261 IN EFI_AP_PROCEDURE Procedure
, OPTIONAL
262 IN VOID
*ProcedureArgument OPTIONAL
266 Get CPU MP Data pointer from the Guided HOB.
268 @return Pointer to Pointer to PEI CPU MP Data
276 Find the current Processor number by APIC ID.
278 @param PeiCpuMpData Pointer to PEI CPU MP Data
279 @param ProcessorNumber Return the pocessor number found
281 @retval EFI_SUCCESS ProcessorNumber is found and returned.
282 @retval EFI_NOT_FOUND ProcessorNumber is not found.
286 IN PEI_CPU_MP_DATA
*PeiCpuMpData
,
287 OUT UINTN
*ProcessorNumber
291 Collects BIST data from PPI.
293 This function collects BIST data from Sec Platform Information2 PPI
294 or SEC Platform Information PPI.
296 @param PeiServices Pointer to PEI Services Table
297 @param PeiCpuMpData Pointer to PEI CPU MP Data
301 CollectBistDataFromPpi (
302 IN CONST EFI_PEI_SERVICES
**PeiServices
,
303 IN PEI_CPU_MP_DATA
*PeiCpuMpData
307 Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.
309 @param PeiServices The pointer to the PEI Services Table.
310 @param StructureSize The pointer to the variable describing size of the input buffer.
311 @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.
313 @retval EFI_SUCCESS The data was successfully returned.
314 @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to
315 hold the record is returned in StructureSize.
320 SecPlatformInformation2 (
321 IN CONST EFI_PEI_SERVICES
**PeiServices
,
322 IN OUT UINT64
*StructureSize
,
323 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2
*PlatformInformationRecord2
327 Detect whether specified processor can find matching microcode patch and load it.
329 @param PeiCpuMpData Pointer to PEI CPU MP Data
333 IN PEI_CPU_MP_DATA
*PeiCpuMpData