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/LocalApic.h>
27 #include <Library/BaseLib.h>
28 #include <Library/BaseMemoryLib.h>
29 #include <Library/DebugLib.h>
30 #include <Library/HobLib.h>
31 #include <Library/LocalApicLib.h>
32 #include <Library/MtrrLib.h>
33 #include <Library/PcdLib.h>
34 #include <Library/PeimEntryPoint.h>
35 #include <Library/PeiServicesLib.h>
36 #include <Library/ReportStatusCodeLib.h>
37 #include <Library/SynchronizationLib.h>
38 #include <Library/TimerLib.h>
39 #include <Library/UefiCpuLib.h>
41 #include "Microcode.h"
53 // AP reset code information
56 UINT8
*RendezvousFunnelAddress
;
57 UINTN PModeEntryOffset
;
58 UINTN LModeEntryOffset
;
59 UINTN RendezvousFunnelSize
;
60 } MP_ASSEMBLY_ADDRESS_MAP
;
63 // CPU exchange information for switch BSP
66 UINT8 State
; // offset 0
67 UINTN StackPointer
; // offset 4 / 8
68 IA32_DESCRIPTOR Gdtr
; // offset 8 / 16
69 IA32_DESCRIPTOR Idtr
; // offset 14 / 26
70 } CPU_EXCHANGE_ROLE_INFO
;
72 typedef struct _PEI_CPU_MP_DATA PEI_CPU_MP_DATA
;
88 UINT32 DefaultSize
: 1;
89 UINT32 Granularity
: 1;
96 // MP CPU exchange information for AP reset code
103 IA32_DESCRIPTOR GdtrProfile
;
104 IA32_DESCRIPTOR IdtrProfile
;
107 UINTN NumApsExecuting
;
110 PEI_CPU_MP_DATA
*PeiCpuMpData
;
111 } MP_CPU_EXCHANGE_INFO
;
117 EFI_HEALTH_FLAGS Health
;
123 // PEI CPU MP Data save in memory
125 struct _PEI_CPU_MP_DATA
{
129 UINTN CpuApStackSize
;
130 MP_ASSEMBLY_ADDRESS_MAP AddressMap
;
133 UINTN BackupBufferSize
;
135 UINTN ApFunctionArgument
;
136 volatile UINT32 FinishedCount
;
137 BOOLEAN EndOfPeiFlag
;
139 CPU_EXCHANGE_ROLE_INFO BSPInfo
;
140 CPU_EXCHANGE_ROLE_INFO APInfo
;
141 MTRR_SETTINGS MtrrTable
;
142 PEI_CPU_DATA
*CpuData
;
143 volatile MP_CPU_EXCHANGE_INFO
*MpCpuExchangeInfo
;
145 extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc
;
149 Assembly code to get starting address and size of the rendezvous entry for APs.
150 Information for fixing a jump instruction in the code is also returned.
152 @param AddressMap Output buffer for address map information.
157 OUT MP_ASSEMBLY_ADDRESS_MAP
*AddressMap
161 Assembly code to load GDT table and update segment accordingly.
163 @param Gdtr Pointer to GDT descriptor
168 IN IA32_DESCRIPTOR
*Gdtr
172 Assembly code to do CLI-HALT loop.
182 Get available system memory below 1MB by specified size.
184 @param PeiCpuMpData Pointer to PEI CPU MP Data
187 BackupAndPrepareWakeupBuffer(
188 IN PEI_CPU_MP_DATA
*PeiCpuMpData
192 Restore wakeup buffer data.
194 @param PeiCpuMpData Pointer to PEI CPU MP Data
198 IN PEI_CPU_MP_DATA
*PeiCpuMpData
202 Notify function on End Of Pei PPI.
204 On S3 boot, this function will restore wakeup buffer data.
205 On normal boot, this function will flag wakeup buffer to be un-used type.
207 @param PeiServices The pointer to the PEI Services Table.
208 @param NotifyDescriptor Address of the notification descriptor data structure.
209 @param Ppi Address of the PPI that was installed.
211 @retval EFI_SUCCESS When everything is OK.
216 CpuMpEndOfPeiCallback (
217 IN EFI_PEI_SERVICES
**PeiServices
,
218 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
223 This function will be called by BSP to wakeup AP.
225 @param PeiCpuMpData Pointer to PEI CPU MP Data
226 @param Broadcast TRUE: Send broadcast IPI to all APs
227 FALSE: Send IPI to AP by ApicId
228 @param ApicId Apic ID for the processor to be waked
229 @param Procedure The function to be invoked by AP
230 @param ProcedureArgument The argument to be passed into AP function
234 IN PEI_CPU_MP_DATA
*PeiCpuMpData
,
235 IN BOOLEAN Broadcast
,
237 IN EFI_AP_PROCEDURE Procedure
, OPTIONAL
238 IN VOID
*ProcedureArgument OPTIONAL
242 Get CPU MP Data pointer from the Guided HOB.
244 @return Pointer to Pointer to PEI CPU MP Data
252 Find the current Processor number by APIC ID.
254 @param PeiCpuMpData Pointer to PEI CPU MP Data
255 @param ProcessorNumber Return the pocessor number found
257 @retval EFI_SUCCESS ProcessorNumber is found and returned.
258 @retval EFI_NOT_FOUND ProcessorNumber is not found.
262 IN PEI_CPU_MP_DATA
*PeiCpuMpData
,
263 OUT UINTN
*ProcessorNumber
267 Collects BIST data from PPI.
269 This function collects BIST data from Sec Platform Information2 PPI
270 or SEC Platform Information PPI.
272 @param PeiServices Pointer to PEI Services Table
273 @param PeiCpuMpData Pointer to PEI CPU MP Data
277 CollectBistDataFromPpi (
278 IN CONST EFI_PEI_SERVICES
**PeiServices
,
279 IN PEI_CPU_MP_DATA
*PeiCpuMpData
283 Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.
285 @param PeiServices The pointer to the PEI Services Table.
286 @param StructureSize The pointer to the variable describing size of the input buffer.
287 @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.
289 @retval EFI_SUCCESS The data was successfully returned.
290 @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to
291 hold the record is returned in StructureSize.
296 SecPlatformInformation2 (
297 IN CONST EFI_PEI_SERVICES
**PeiServices
,
298 IN OUT UINT64
*StructureSize
,
299 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2
*PlatformInformationRecord2