]>
Commit | Line | Data |
---|---|---|
65e79f93 JF |
1 | /** @file |
2 | Definitions to install Multiple Processor PPI. | |
3 | ||
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 | |
9 | ||
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. | |
12 | ||
13 | **/ | |
14 | ||
15 | #ifndef _CPU_MP_PEI_H_ | |
16 | #define _CPU_MP_PEI_H_ | |
17 | ||
18 | #include <PiPei.h> | |
19 | ||
887810c8 | 20 | #include <Ppi/MpServices.h> |
e66d675d | 21 | #include <Ppi/SecPlatformInformation.h> |
a21fe428 | 22 | #include <Ppi/SecPlatformInformation2.h> |
65e79f93 | 23 | |
d1cf9333 JF |
24 | #include <Register/LocalApic.h> |
25 | ||
65e79f93 | 26 | #include <Library/BaseLib.h> |
e66d675d JF |
27 | #include <Library/BaseMemoryLib.h> |
28 | #include <Library/DebugLib.h> | |
05e107f8 | 29 | #include <Library/HobLib.h> |
e66d675d | 30 | #include <Library/LocalApicLib.h> |
b4cd9f78 | 31 | #include <Library/MtrrLib.h> |
e66d675d | 32 | #include <Library/PcdLib.h> |
65e79f93 | 33 | #include <Library/PeimEntryPoint.h> |
e66d675d | 34 | #include <Library/PeiServicesLib.h> |
a21fe428 | 35 | #include <Library/ReportStatusCodeLib.h> |
7d51bf5c JF |
36 | #include <Library/SynchronizationLib.h> |
37 | #include <Library/TimerLib.h> | |
46ba0f63 | 38 | #include <Library/UefiCpuLib.h> |
d1cf9333 JF |
39 | |
40 | #include "Microcode.h" | |
41 | ||
e66d675d JF |
42 | // |
43 | // AP state | |
44 | // | |
45 | typedef enum { | |
46 | CpuStateIdle, | |
47 | CpuStateBusy, | |
48 | CpuStateDisabled | |
49 | } CPU_STATE; | |
65e79f93 | 50 | |
8018cb15 JF |
51 | // |
52 | // AP reset code information | |
53 | // | |
54 | typedef struct { | |
55 | UINT8 *RendezvousFunnelAddress; | |
56 | UINTN PModeEntryOffset; | |
57 | UINTN LModeEntryOffset; | |
58 | UINTN RendezvousFunnelSize; | |
59 | } MP_ASSEMBLY_ADDRESS_MAP; | |
60 | ||
e66d675d JF |
61 | typedef struct _PEI_CPU_MP_DATA PEI_CPU_MP_DATA; |
62 | ||
63 | #pragma pack() | |
a56f6f45 | 64 | |
f9d30595 JF |
65 | typedef union { |
66 | struct { | |
67 | UINT32 LimitLow : 16; | |
68 | UINT32 BaseLow : 16; | |
69 | UINT32 BaseMid : 8; | |
70 | UINT32 Type : 4; | |
71 | UINT32 System : 1; | |
72 | UINT32 Dpl : 2; | |
73 | UINT32 Present : 1; | |
74 | UINT32 LimitHigh : 4; | |
75 | UINT32 Software : 1; | |
76 | UINT32 Reserved : 1; | |
77 | UINT32 DefaultSize : 1; | |
78 | UINT32 Granularity : 1; | |
79 | UINT32 BaseHigh : 8; | |
80 | } Bits; | |
81 | UINT64 Uint64; | |
82 | } IA32_GDT; | |
a56f6f45 JF |
83 | |
84 | // | |
85 | // MP CPU exchange information for AP reset code | |
86 | // | |
87 | typedef struct { | |
88 | UINTN Lock; | |
89 | UINTN StackStart; | |
90 | UINTN StackSize; | |
91 | UINTN CFunction; | |
92 | IA32_DESCRIPTOR GdtrProfile; | |
93 | IA32_DESCRIPTOR IdtrProfile; | |
94 | UINTN BufferStart; | |
95 | UINTN PmodeOffset; | |
96 | UINTN NumApsExecuting; | |
97 | UINTN LmodeOffset; | |
98 | UINTN Cr3; | |
7d51bf5c | 99 | PEI_CPU_MP_DATA *PeiCpuMpData; |
a56f6f45 JF |
100 | } MP_CPU_EXCHANGE_INFO; |
101 | ||
f9d30595 | 102 | #pragma pack() |
8018cb15 | 103 | |
e66d675d JF |
104 | typedef struct { |
105 | UINT32 ApicId; | |
106 | EFI_HEALTH_FLAGS Health; | |
107 | CPU_STATE State; | |
108 | BOOLEAN CpuHealthy; | |
109 | } PEI_CPU_DATA; | |
110 | ||
111 | // | |
112 | // PEI CPU MP Data save in memory | |
113 | // | |
114 | struct _PEI_CPU_MP_DATA { | |
115 | UINT32 CpuCount; | |
116 | UINT32 BspNumber; | |
117 | UINTN Buffer; | |
118 | UINTN CpuApStackSize; | |
119 | MP_ASSEMBLY_ADDRESS_MAP AddressMap; | |
120 | UINTN WakeupBuffer; | |
121 | UINTN BackupBuffer; | |
122 | UINTN BackupBufferSize; | |
7d51bf5c JF |
123 | UINTN ApFunction; |
124 | UINTN ApFunctionArgument; | |
125 | volatile UINT32 FinishedCount; | |
126 | BOOLEAN InitFlag; | |
b4cd9f78 | 127 | MTRR_SETTINGS MtrrTable; |
e66d675d JF |
128 | PEI_CPU_DATA *CpuData; |
129 | volatile MP_CPU_EXCHANGE_INFO *MpCpuExchangeInfo; | |
130 | }; | |
131 | ||
8018cb15 JF |
132 | /** |
133 | Assembly code to get starting address and size of the rendezvous entry for APs. | |
134 | Information for fixing a jump instruction in the code is also returned. | |
135 | ||
136 | @param AddressMap Output buffer for address map information. | |
137 | **/ | |
138 | VOID | |
139 | EFIAPI | |
140 | AsmGetAddressMap ( | |
141 | OUT MP_ASSEMBLY_ADDRESS_MAP *AddressMap | |
142 | ); | |
143 | ||
f9d30595 JF |
144 | /** |
145 | Assembly code to load GDT table and update segment accordingly. | |
146 | ||
147 | @param Gdtr Pointer to GDT descriptor | |
148 | **/ | |
149 | VOID | |
150 | EFIAPI | |
151 | AsmInitializeGdt ( | |
152 | IN IA32_DESCRIPTOR *Gdtr | |
153 | ); | |
65e79f93 JF |
154 | |
155 | ||
60ca9e8c JF |
156 | /** |
157 | This function will be called by BSP to wakeup AP. | |
158 | ||
159 | @param PeiCpuMpData Pointer to PEI CPU MP Data | |
160 | @param Broadcast TRUE: Send broadcast IPI to all APs | |
161 | FALSE: Send IPI to AP by ApicId | |
162 | @param ApicId Apic ID for the processor to be waked | |
163 | @param Procedure The function to be invoked by AP | |
164 | @param ProcedureArgument The argument to be passed into AP function | |
165 | **/ | |
166 | VOID | |
167 | WakeUpAP ( | |
168 | IN PEI_CPU_MP_DATA *PeiCpuMpData, | |
169 | IN BOOLEAN Broadcast, | |
170 | IN UINT32 ApicId, | |
171 | IN EFI_AP_PROCEDURE Procedure, OPTIONAL | |
172 | IN VOID *ProcedureArgument OPTIONAL | |
173 | ); | |
174 | ||
a21fe428 JF |
175 | /** |
176 | Get CPU MP Data pointer from the Guided HOB. | |
177 | ||
178 | @return Pointer to Pointer to PEI CPU MP Data | |
179 | **/ | |
180 | PEI_CPU_MP_DATA * | |
181 | GetMpHobData ( | |
182 | VOID | |
183 | ); | |
184 | ||
60ca9e8c JF |
185 | /** |
186 | Find the current Processor number by APIC ID. | |
187 | ||
188 | @param PeiCpuMpData Pointer to PEI CPU MP Data | |
189 | @param ProcessorNumber Return the pocessor number found | |
190 | ||
191 | @retval EFI_SUCCESS ProcessorNumber is found and returned. | |
192 | @retval EFI_NOT_FOUND ProcessorNumber is not found. | |
193 | **/ | |
194 | EFI_STATUS | |
195 | GetProcessorNumber ( | |
196 | IN PEI_CPU_MP_DATA *PeiCpuMpData, | |
197 | OUT UINTN *ProcessorNumber | |
198 | ); | |
199 | ||
a21fe428 JF |
200 | /** |
201 | Collects BIST data from PPI. | |
202 | ||
203 | This function collects BIST data from Sec Platform Information2 PPI | |
204 | or SEC Platform Information PPI. | |
205 | ||
206 | @param PeiServices Pointer to PEI Services Table | |
207 | @param PeiCpuMpData Pointer to PEI CPU MP Data | |
208 | ||
209 | **/ | |
210 | VOID | |
211 | CollectBistDataFromPpi ( | |
212 | IN CONST EFI_PEI_SERVICES **PeiServices, | |
213 | IN PEI_CPU_MP_DATA *PeiCpuMpData | |
214 | ); | |
215 | ||
216 | /** | |
217 | Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI. | |
218 | ||
219 | @param PeiServices The pointer to the PEI Services Table. | |
220 | @param StructureSize The pointer to the variable describing size of the input buffer. | |
221 | @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2. | |
222 | ||
223 | @retval EFI_SUCCESS The data was successfully returned. | |
224 | @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to | |
225 | hold the record is returned in StructureSize. | |
226 | ||
227 | **/ | |
228 | EFI_STATUS | |
229 | EFIAPI | |
230 | SecPlatformInformation2 ( | |
231 | IN CONST EFI_PEI_SERVICES **PeiServices, | |
232 | IN OUT UINT64 *StructureSize, | |
233 | OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2 | |
234 | ); | |
235 | ||
65e79f93 | 236 | #endif |