TianoCore EDK2 master
Loading...
Searching...
No Matches
MachineCheck.c
Go to the documentation of this file.
1
9#include "CpuCommonFeatures.h"
10
27BOOLEAN
28EFIAPI
30 IN UINTN ProcessorNumber,
32 IN VOID *ConfigData OPTIONAL
33 )
34{
35 return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCE == 1);
36}
37
55RETURN_STATUS
56EFIAPI
58 IN UINTN ProcessorNumber,
60 IN VOID *ConfigData OPTIONAL,
61 IN BOOLEAN State
62 )
63{
64 //
65 // Set MCE bit in CR4
66 //
68 ProcessorNumber,
69 ControlRegister,
70 4,
71 IA32_CR4,
72 Bits.MCE,
73 (State) ? 1 : 0
74 );
75 return RETURN_SUCCESS;
76}
77
94BOOLEAN
95EFIAPI
97 IN UINTN ProcessorNumber,
99 IN VOID *ConfigData OPTIONAL
100 )
101{
102 if (!MceSupport (ProcessorNumber, CpuInfo, ConfigData)) {
103 return FALSE;
104 }
105
106 return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCA == 1);
107}
108
126RETURN_STATUS
127EFIAPI
129 IN UINTN ProcessorNumber,
131 IN VOID *ConfigData OPTIONAL,
132 IN BOOLEAN State
133 )
134{
136 UINT32 BankIndex;
137
138 //
139 // The scope of MSR_IA32_MC*_CTL/MSR_IA32_MC*_STATUS is core for below processor type, only program
140 // MSR_IA32_MC*_CTL/MSR_IA32_MC*_STATUS for thread 0 in each core.
141 //
142 if (IS_ATOM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
143 IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
144 IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
145 IS_SKYLAKE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
146 IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
147 IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
148 IS_CORE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel))
149 {
150 if (CpuInfo->ProcessorInfo.Location.Thread != 0) {
151 return RETURN_SUCCESS;
152 }
153 }
154
155 //
156 // The scope of MSR_IA32_MC*_CTL/MSR_IA32_MC*_STATUS is package for below processor type, only program
157 // MSR_IA32_MC*_CTL/MSR_IA32_MC*_STATUS once for each package.
158 //
159 if (IS_NEHALEM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {
160 if ((CpuInfo->First.Thread == 0) || (CpuInfo->First.Core == 0)) {
161 return RETURN_SUCCESS;
162 }
163 }
164
165 if (State) {
167 for (BankIndex = 0; BankIndex < (UINT32)McgCap.Bits.Count; BankIndex++) {
169 ProcessorNumber,
170 Msr,
171 MSR_IA32_MC0_CTL + BankIndex * 4,
172 MAX_UINT64
173 );
174 }
175
176 if (PcdGetBool (PcdIsPowerOnReset)) {
177 for (BankIndex = 0; BankIndex < (UINT32)McgCap.Bits.Count; BankIndex++) {
179 ProcessorNumber,
180 Msr,
181 MSR_IA32_MC0_STATUS + BankIndex * 4,
182 0
183 );
184 }
185 }
186 }
187
188 return RETURN_SUCCESS;
189}
190
207BOOLEAN
208EFIAPI
210 IN UINTN ProcessorNumber,
212 IN VOID *ConfigData OPTIONAL
213 )
214{
216
217 if (!McaSupport (ProcessorNumber, CpuInfo, ConfigData)) {
218 return FALSE;
219 }
220
222 return (McgCap.Bits.MCG_CTL_P == 1);
223}
224
242RETURN_STATUS
243EFIAPI
245 IN UINTN ProcessorNumber,
247 IN VOID *ConfigData OPTIONAL,
248 IN BOOLEAN State
249 )
250{
252 ProcessorNumber,
253 Msr,
255 (State) ? MAX_UINT64 : 0
256 );
257 return RETURN_SUCCESS;
258}
259
277BOOLEAN
278EFIAPI
280 IN UINTN ProcessorNumber,
282 IN VOID *ConfigData OPTIONAL
283 )
284{
286
287 if (!McaSupport (ProcessorNumber, CpuInfo, ConfigData)) {
288 return FALSE;
289 }
290
292
293 return (BOOLEAN)(McgCap.Bits.MCG_LMCE_P != 0);
294}
295
314RETURN_STATUS
315EFIAPI
317 IN UINTN ProcessorNumber,
319 IN VOID *ConfigData OPTIONAL,
320 IN BOOLEAN State
321 )
322{
323 //
324 // The scope of LcmeOn bit in the MSR_IA32_MISC_ENABLE is core for below processor type, only program
325 // MSR_IA32_MISC_ENABLE for thread 0 in each core.
326 //
327 if (IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
328 IS_GOLDMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
329 IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel))
330 {
331 if (CpuInfo->ProcessorInfo.Location.Thread != 0) {
332 return RETURN_SUCCESS;
333 }
334 }
335
337 ProcessorNumber,
338 Msr,
341 Bits.LmceOn,
342 (State) ? 1 : 0
343 );
344
345 return RETURN_SUCCESS;
346}
UINT64 UINTN
#define IS_ATOM_PROCESSOR(DisplayFamily, DisplayModel)
Definition: AtomMsr.h:32
#define IS_CORE_PROCESSOR(DisplayFamily, DisplayModel)
Definition: CoreMsr.h:32
#define IS_GOLDMONT_PROCESSOR(DisplayFamily, DisplayModel)
Definition: GoldmontMsr.h:32
UINT64 EFIAPI AsmReadMsr64(IN UINT32 Index)
Definition: GccInlinePriv.c:60
RETURN_STATUS EFIAPI McaInitialize(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL, IN BOOLEAN State)
Definition: MachineCheck.c:128
BOOLEAN EFIAPI McgCtlSupport(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL)
Definition: MachineCheck.c:209
RETURN_STATUS EFIAPI McgCtlInitialize(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL, IN BOOLEAN State)
Definition: MachineCheck.c:244
RETURN_STATUS EFIAPI MceInitialize(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL, IN BOOLEAN State)
Definition: MachineCheck.c:57
RETURN_STATUS EFIAPI LmceInitialize(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL, IN BOOLEAN State)
Definition: MachineCheck.c:316
BOOLEAN EFIAPI LmceSupport(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL)
Definition: MachineCheck.c:279
BOOLEAN EFIAPI MceSupport(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL)
Definition: MachineCheck.c:29
BOOLEAN EFIAPI McaSupport(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL)
Definition: MachineCheck.c:96
#define RETURN_SUCCESS
Definition: Base.h:1066
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define MSR_IA32_MC0_STATUS
#define MSR_IA32_MCG_CAP
#define MSR_IA32_MC0_CTL
#define MSR_IA32_MCG_CTL
#define MSR_IA32_FEATURE_CONTROL
#define IS_NEHALEM_PROCESSOR(DisplayFamily, DisplayModel)
Definition: NehalemMsr.h:32
#define PcdGetBool(TokenName)
Definition: PcdLib.h:401
#define IS_PENTIUM_4_PROCESSOR(DisplayFamily, DisplayModel)
Definition: Pentium4Msr.h:32
#define CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value)
#define CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value)
#define CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value)
#define IS_SANDY_BRIDGE_PROCESSOR(DisplayFamily, DisplayModel)
#define IS_SILVERMONT_PROCESSOR(DisplayFamily, DisplayModel)
Definition: SilvermontMsr.h:32
#define IS_SKYLAKE_PROCESSOR(DisplayFamily, DisplayModel)
Definition: SkylakeMsr.h:32
#define IS_XEON_PHI_PROCESSOR(DisplayFamily, DisplayModel)
Definition: XeonPhiMsr.h:32
struct MSR_IA32_MCG_CAP_REGISTER::@633 Bits