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>
28 #include <Register/Msr.h>
30 #include <Library/BaseLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/DebugLib.h>
33 #include <Library/HobLib.h>
34 #include <Library/LocalApicLib.h>
35 #include <Library/MtrrLib.h>
36 #include <Library/PcdLib.h>
37 #include <Library/PeimEntryPoint.h>
38 #include <Library/PeiServicesLib.h>
39 #include <Library/ReportStatusCodeLib.h>
40 #include <Library/SynchronizationLib.h>
41 #include <Library/TimerLib.h>
42 #include <Library/UefiCpuLib.h>
43 #include <Library/CpuLib.h>
44 #include <Library/CpuExceptionHandlerLib.h>
45 #include <Library/MpInitLib.h>
47 #include "Microcode.h"
58 #define WAKEUP_AP_SIGNAL SIGNATURE_32 ('S', 'T', 'A', 'P')
67 // AP reset code information
70 UINT8
*RendezvousFunnelAddress
;
71 UINTN ModeEntryOffset
;
72 UINTN RendezvousFunnelSize
;
73 } MP_ASSEMBLY_ADDRESS_MAP
;
76 // CPU exchange information for switch BSP
79 UINT8 State
; // offset 0
80 UINTN StackPointer
; // offset 4 / 8
81 IA32_DESCRIPTOR Gdtr
; // offset 8 / 16
82 IA32_DESCRIPTOR Idtr
; // offset 14 / 26
83 } CPU_EXCHANGE_ROLE_INFO
;
85 typedef struct _PEI_CPU_MP_DATA PEI_CPU_MP_DATA
;
90 // MP CPU exchange information for AP reset code
91 // This structure is required to be packed because fixed field offsets
92 // into this structure are used in assembly code in this module
99 IA32_DESCRIPTOR GdtrProfile
;
100 IA32_DESCRIPTOR IdtrProfile
;
103 UINTN NumApsExecuting
;
107 PEI_CPU_MP_DATA
*PeiCpuMpData
;
108 } MP_CPU_EXCHANGE_INFO
;
122 } CPU_VOLATILE_REGISTERS
;
125 volatile UINT32
*StartupApSignal
;
127 EFI_HEALTH_FLAGS Health
;
130 CPU_VOLATILE_REGISTERS VolatileRegisters
;
134 // PEI CPU MP Data save in memory
136 struct _PEI_CPU_MP_DATA
{
141 UINTN CpuApStackSize
;
142 MP_ASSEMBLY_ADDRESS_MAP AddressMap
;
145 UINTN BackupBufferSize
;
147 UINTN ApFunctionArgument
;
148 volatile UINT32 FinishedCount
;
149 BOOLEAN EndOfPeiFlag
;
151 BOOLEAN X2ApicEnable
;
152 CPU_EXCHANGE_ROLE_INFO BSPInfo
;
153 CPU_EXCHANGE_ROLE_INFO APInfo
;
154 MTRR_SETTINGS MtrrTable
;
156 UINT8 ApTargetCState
;
157 PEI_CPU_DATA
*CpuData
;
158 volatile MP_CPU_EXCHANGE_INFO
*MpCpuExchangeInfo
;
160 extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc
;
164 Assembly code to get starting address and size of the rendezvous entry for APs.
165 Information for fixing a jump instruction in the code is also returned.
167 @param AddressMap Output buffer for address map information.
172 OUT MP_ASSEMBLY_ADDRESS_MAP
*AddressMap
176 Assembly code to load GDT table and update segment accordingly.
178 @param Gdtr Pointer to GDT descriptor
183 IN IA32_DESCRIPTOR
*Gdtr
187 Get available system memory below 1MB by specified size.
189 @param PeiCpuMpData Pointer to PEI CPU MP Data
193 BackupAndPrepareWakeupBuffer(
194 IN PEI_CPU_MP_DATA
*PeiCpuMpData
198 Restore wakeup buffer data.
200 @param PeiCpuMpData Pointer to PEI CPU MP Data
205 IN PEI_CPU_MP_DATA
*PeiCpuMpData
209 Notify function on End Of Pei PPI.
211 On S3 boot, this function will restore wakeup buffer data.
212 On normal boot, this function will flag wakeup buffer to be un-used type.
214 @param PeiServices The pointer to the PEI Services Table.
215 @param NotifyDescriptor Address of the notification descriptor data structure.
216 @param Ppi Address of the PPI that was installed.
218 @retval EFI_SUCCESS When everything is OK.
224 CpuMpEndOfPeiCallback (
225 IN EFI_PEI_SERVICES
**PeiServices
,
226 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
231 This function will be called by BSP to wakeup AP.
233 @param PeiCpuMpData Pointer to PEI CPU MP Data
234 @param Broadcast TRUE: Send broadcast IPI to all APs
235 FALSE: Send IPI to AP by ApicId
236 @param ProcessorNumber The handle number of specified processor
237 @param Procedure The function to be invoked by AP
238 @param ProcedureArgument The argument to be passed into AP function
243 IN PEI_CPU_MP_DATA
*PeiCpuMpData
,
244 IN BOOLEAN Broadcast
,
245 IN UINTN ProcessorNumber
,
246 IN EFI_AP_PROCEDURE Procedure
, OPTIONAL
247 IN VOID
*ProcedureArgument OPTIONAL
251 Get CPU MP Data pointer from the Guided HOB.
253 @return Pointer to Pointer to PEI CPU MP Data
261 Find the current Processor number by APIC ID.
263 @param PeiCpuMpData Pointer to PEI CPU MP Data
264 @param ProcessorNumber Return the pocessor number found
266 @retval EFI_SUCCESS ProcessorNumber is found and returned.
267 @retval EFI_NOT_FOUND ProcessorNumber is not found.
272 IN PEI_CPU_MP_DATA
*PeiCpuMpData
,
273 OUT UINTN
*ProcessorNumber
277 Collects BIST data from PPI.
279 This function collects BIST data from Sec Platform Information2 PPI
280 or SEC Platform Information PPI.
282 @param PeiServices Pointer to PEI Services Table
286 CollectBistDataFromPpi (
287 IN CONST EFI_PEI_SERVICES
**PeiServices
291 Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.
293 @param PeiServices The pointer to the PEI Services Table.
294 @param StructureSize The pointer to the variable describing size of the input buffer.
295 @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.
297 @retval EFI_SUCCESS The data was successfully returned.
298 @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to
299 hold the record is returned in StructureSize.
304 SecPlatformInformation2 (
305 IN CONST EFI_PEI_SERVICES
**PeiServices
,
306 IN OUT UINT64
*StructureSize
,
307 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2
*PlatformInformationRecord2
311 Detect whether specified processor can find matching microcode patch and load it.
313 @param PeiCpuMpData Pointer to PEI CPU MP Data
317 IN PEI_CPU_MP_DATA
*PeiCpuMpData