AGESA F15: AMD family15 AGESA code
[coreboot.git] / src / vendorcode / amd / agesa / f15 / Proc / CPU / Family / 0x10 / cpuF10FeatureLeveling.c
1 /* $NoKeywords:$ */
2 /**
3  * @file
4  *
5  * AMD Family_10 specific feature leveling functions.
6  *
7  * Provides feature leveling functions specific to family 10h.
8  *
9  * @xrefitem bom "File Content Label" "Release Content"
10  * @e project:      AGESA
11  * @e sub-project:  CPU/Family/0x10
12  * @e \$Revision: 56279 $   @e \$Date: 2011-07-11 13:11:28 -0600 (Mon, 11 Jul 2011) $
13  *
14  */
15 /*
16  ******************************************************************************
17  *
18  * Copyright (C) 2012 Advanced Micro Devices, Inc.
19  * All rights reserved.
20  *
21  * Redistribution and use in source and binary forms, with or without
22  * modification, are permitted provided that the following conditions are met:
23  *     * Redistributions of source code must retain the above copyright
24  *       notice, this list of conditions and the following disclaimer.
25  *     * Redistributions in binary form must reproduce the above copyright
26  *       notice, this list of conditions and the following disclaimer in the
27  *       documentation and/or other materials provided with the distribution.
28  *     * Neither the name of Advanced Micro Devices, Inc. nor the names of
29  *       its contributors may be used to endorse or promote products derived
30  *       from this software without specific prior written permission.
31  *
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35  * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
36  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42  *
43  ******************************************************************************
44  */
45
46 /*----------------------------------------------------------------------------------------
47  *                             M O D U L E S    U S E D
48  *----------------------------------------------------------------------------------------
49  */
50 #include "AGESA.h"
51 #include "amdlib.h"
52 #include "cpuRegisters.h"
53 #include "cpuPostInit.h"
54 #include "cpuF10FeatureLeveling.h"
55 #include "cpuFamilyTranslation.h"
56 #include "Filecode.h"
57 CODE_GROUP (G1_PEICC)
58 RDATA_GROUP (G2_PEI)
59
60 #define FILECODE PROC_CPU_FAMILY_0X10_CPUF10FEATURELEVELING_FILECODE
61
62 /*----------------------------------------------------------------------------------------
63  *                   D E F I N I T I O N S    A N D    M A C R O S
64  *----------------------------------------------------------------------------------------
65  */
66
67 /*----------------------------------------------------------------------------------------
68  *                  T Y P E D E F S     A N D     S T R U C T U R E S
69  *----------------------------------------------------------------------------------------
70  */
71
72 /*----------------------------------------------------------------------------------------
73  *           P R O T O T Y P E S     O F     L O C A L     F U N C T I O N S
74  *----------------------------------------------------------------------------------------
75  */
76 BOOLEAN
77 STATIC
78 cpuFeatureListNeedUpdate (
79   IN       CPU_FEATURES_LIST *globalCpuFeatureList,
80   IN       CPU_FEATURES_LIST *thisCoreCpuFeatureList
81   );
82
83 VOID
84 STATIC
85 updateCpuFeatureList (
86   IN       CPU_FEATURES_LIST *globalCpuFeatureList,
87   IN       CPU_FEATURES_LIST *thisCoreCpuFeatureList
88   );
89
90 /*----------------------------------------------------------------------------------------
91  *                          E X P O R T E D    F U N C T I O N S
92  *----------------------------------------------------------------------------------------
93  */
94
95 /* -----------------------------------------------------------------------------*/
96 /**
97  *
98  *  This function get features which CPU supports.
99  *
100  *  @CpuServiceMethod{::F_CPU_SAVE_FEATURES}.
101  *
102  *  Read features from MSR_C0011004 and MSR_C0011005.
103  *
104  *    @param[in]      FamilySpecificServices   - Pointer to CPU_SPECIFIC_SERVICES struct.
105  *    @param[in,out]  cpuFeatureList           - Pointer to CPU_FEATURES_LIST struct.
106  *    @param[in]      StdHeader                - Pointer to AMD_CONFIG_PARAMS struct.
107  *
108  */
109 VOID
110 F10SaveFeatures (
111   IN       CPU_SPECIFIC_SERVICES *FamilySpecificServices,
112   IN OUT   CPU_FEATURES_LIST *cpuFeatureList,
113   IN       AMD_CONFIG_PARAMS *StdHeader
114   )
115 {
116   UINT64 CpuMsrData;
117   BOOLEAN *FirstTime;
118   BOOLEAN *NeedLeveling;
119   CPU_F10_FEATURES *CpuF10Features;
120   CPU_F10_EXT_FEATURES *CpuF10ExtFeatures;
121   CPU_FEATURES_LIST thisCoreCpuFeatureList;
122
123   FirstTime = (BOOLEAN *) ((UINT8 *) cpuFeatureList + sizeof (CPU_FEATURES_LIST));
124   NeedLeveling = (BOOLEAN *) ((UINT8 *) cpuFeatureList + sizeof (CPU_FEATURES_LIST) + sizeof (BOOLEAN));
125
126   LibAmdMemFill (&thisCoreCpuFeatureList, 0x0, sizeof (CPU_FEATURES_LIST), StdHeader);
127   LibAmdMsrRead (MSR_CPUID_FEATS, &CpuMsrData, StdHeader);
128   CpuF10Features = (CPU_F10_FEATURES *) &CpuMsrData;
129
130   thisCoreCpuFeatureList.APIC = (UINT8) CpuF10Features->CpuF10FeaturesLo.APIC;
131   thisCoreCpuFeatureList.CLFSH = (UINT8) CpuF10Features->CpuF10FeaturesLo.CLFSH;
132   thisCoreCpuFeatureList.CMOV = (UINT8) CpuF10Features->CpuF10FeaturesLo.CMOV;
133   thisCoreCpuFeatureList.CMPXCHG8B = (UINT8) CpuF10Features->CpuF10FeaturesLo.CMPXCHG8B;
134   thisCoreCpuFeatureList.DE = (UINT8) CpuF10Features->CpuF10FeaturesLo.DE;
135   thisCoreCpuFeatureList.FPU = (UINT8) CpuF10Features->CpuF10FeaturesLo.FPU;
136   thisCoreCpuFeatureList.FXSR = (UINT8) CpuF10Features->CpuF10FeaturesLo.FXSR;
137   thisCoreCpuFeatureList.HTT = (UINT8) CpuF10Features->CpuF10FeaturesLo.HTT;
138   thisCoreCpuFeatureList.MCA = (UINT8) CpuF10Features->CpuF10FeaturesLo.MCA;
139   thisCoreCpuFeatureList.MCE = (UINT8) CpuF10Features->CpuF10FeaturesLo.MCE;
140   thisCoreCpuFeatureList.MMX = (UINT8) CpuF10Features->CpuF10FeaturesLo.MMX;
141   thisCoreCpuFeatureList.MSR = (UINT8) CpuF10Features->CpuF10FeaturesLo.MSR;
142   thisCoreCpuFeatureList.MTRR = (UINT8) CpuF10Features->CpuF10FeaturesLo.MTRR;
143   thisCoreCpuFeatureList.PAE = (UINT8) CpuF10Features->CpuF10FeaturesLo.PAE;
144   thisCoreCpuFeatureList.PAT = (UINT8) CpuF10Features->CpuF10FeaturesLo.PAT;
145   thisCoreCpuFeatureList.PGE = (UINT8) CpuF10Features->CpuF10FeaturesLo.PGE;
146   thisCoreCpuFeatureList.PSE = (UINT8) CpuF10Features->CpuF10FeaturesLo.PSE;
147   thisCoreCpuFeatureList.PSE36 = (UINT8) CpuF10Features->CpuF10FeaturesLo.PSE36;
148   thisCoreCpuFeatureList.SSE = (UINT8) CpuF10Features->CpuF10FeaturesLo.SSE;
149   thisCoreCpuFeatureList.SSE2 = (UINT8) CpuF10Features->CpuF10FeaturesLo.SSE2;
150   thisCoreCpuFeatureList.SysEnterSysExit = (UINT8) CpuF10Features->CpuF10FeaturesLo.SysEnterSysExit;
151   thisCoreCpuFeatureList.TimeStampCounter = (UINT8) CpuF10Features->CpuF10FeaturesLo.TimeStampCounter;
152   thisCoreCpuFeatureList.VME = (UINT8) CpuF10Features->CpuF10FeaturesLo.VME;
153
154   thisCoreCpuFeatureList.CMPXCHG16B = (UINT8) CpuF10Features->CpuF10FeaturesHi.CMPXCHG16B;
155   thisCoreCpuFeatureList.Monitor = (UINT8) CpuF10Features->CpuF10FeaturesHi.Monitor;
156   thisCoreCpuFeatureList.POPCNT = (UINT8) CpuF10Features->CpuF10FeaturesHi.POPCNT;
157   thisCoreCpuFeatureList.SSE3 = (UINT8) CpuF10Features->CpuF10FeaturesHi.SSE3;
158
159   LibAmdMsrRead (MSR_CPUID_EXT_FEATS, &CpuMsrData, StdHeader);
160   CpuF10ExtFeatures = (CPU_F10_EXT_FEATURES *) &CpuMsrData;
161
162   thisCoreCpuFeatureList.ThreeDNow = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.ThreeDNow;
163   thisCoreCpuFeatureList.ThreeDNowExt = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.ThreeDNowExt;
164   thisCoreCpuFeatureList.APIC = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.APIC;
165   thisCoreCpuFeatureList.CMOV = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.CMOV;
166   thisCoreCpuFeatureList.CMPXCHG8B = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.CMPXCHG8B;
167   thisCoreCpuFeatureList.DE = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.DE;
168   thisCoreCpuFeatureList.FFXSR = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.FFXSR;
169   thisCoreCpuFeatureList.FPU = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.FPU;
170   thisCoreCpuFeatureList.FXSR = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.FXSR;
171   thisCoreCpuFeatureList.LM = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.LM;
172   thisCoreCpuFeatureList.MCA = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.MCA;
173   thisCoreCpuFeatureList.MCE = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.MCE;
174   thisCoreCpuFeatureList.MMX = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.MMX;
175   thisCoreCpuFeatureList.MmxExt = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.MmxExt;
176   thisCoreCpuFeatureList.MSR = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.MSR;
177   thisCoreCpuFeatureList.MTRR = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.MTRR;
178   thisCoreCpuFeatureList.NX = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.NX;
179   thisCoreCpuFeatureList.PAE = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.PAE;
180   thisCoreCpuFeatureList.Page1GB = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.Page1GB;
181   thisCoreCpuFeatureList.PAT = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.PAT;
182   thisCoreCpuFeatureList.PGE = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.PGE;
183   thisCoreCpuFeatureList.PSE = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.PSE;
184   thisCoreCpuFeatureList.PSE36 = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.PSE36;
185   thisCoreCpuFeatureList.RDTSCP = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.RDTSCP;
186   thisCoreCpuFeatureList.SysCallSysRet = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.SysCallSysRet;
187   thisCoreCpuFeatureList.TimeStampCounter = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.TimeStampCounter;
188   thisCoreCpuFeatureList.VME = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesLo.VME;
189
190   thisCoreCpuFeatureList.ThreeDNowPrefetch = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.ThreeDNowPrefetch;
191   thisCoreCpuFeatureList.ABM = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.ABM;
192   thisCoreCpuFeatureList.AltMovCr8 = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.AltMovCr8;
193   thisCoreCpuFeatureList.CmpLegacy = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.CmpLegacy;
194   thisCoreCpuFeatureList.ExtApicSpace = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.ExtApicSpace;
195   thisCoreCpuFeatureList.IBS = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.IBS;
196   thisCoreCpuFeatureList.LahfSahf = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.LahfSahf;
197   thisCoreCpuFeatureList.MisAlignSse = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.MisAlignSse;
198   thisCoreCpuFeatureList.OSVW = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.OSVM;
199   thisCoreCpuFeatureList.SKINIT = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.SKINIT;
200   thisCoreCpuFeatureList.SSE4A = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.SSE4A;
201   thisCoreCpuFeatureList.SVM = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.SVM;
202   thisCoreCpuFeatureList.WDT = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.WDT;
203   thisCoreCpuFeatureList.NodeId = (UINT8) CpuF10ExtFeatures->CpuF10ExtFeaturesHi.NodeId;
204
205   if (*FirstTime) {
206     updateCpuFeatureList (cpuFeatureList, &thisCoreCpuFeatureList);
207     *FirstTime = FALSE;
208   } else if (cpuFeatureListNeedUpdate (cpuFeatureList, &thisCoreCpuFeatureList)) {
209     updateCpuFeatureList (cpuFeatureList, &thisCoreCpuFeatureList);
210     *NeedLeveling = TRUE;
211   }
212 }
213
214 /* -----------------------------------------------------------------------------*/
215 /**
216  *
217  *  This function set features which All CPUs support.
218  *
219  *  @CpuServiceMethod{::F_CPU_WRITE_FEATURES}.
220  *
221  *  Write least common features to MSR_C0011004 and MSR_C0011005.
222  *
223  *    @param[in]      FamilySpecificServices   - Pointer to CPU_SPECIFIC_SERVICES struct.
224  *    @param[in,out]  cpuFeatureList           - Pointer to CPU_FEATURES_LIST struct.
225  *    @param[in]      StdHeader                - Pointer to AMD_CONFIG_PARAMS struct.
226  *
227  */
228 VOID
229 F10WriteFeatures (
230   IN       CPU_SPECIFIC_SERVICES *FamilySpecificServices,
231   IN OUT   CPU_FEATURES_LIST *cpuFeatureList,
232   IN       AMD_CONFIG_PARAMS *StdHeader
233   )
234 {
235   UINT64 CpuMsrData;
236   CPU_F10_FEATURES *CpuF10Features;
237   CPU_F10_EXT_FEATURES *CpuF10ExtFeatures;
238
239   CpuMsrData = 0;
240   CpuF10Features = (CPU_F10_FEATURES *) &CpuMsrData;
241
242   CpuF10Features->CpuF10FeaturesLo.APIC = cpuFeatureList->APIC;
243   CpuF10Features->CpuF10FeaturesLo.CLFSH = cpuFeatureList->CLFSH;
244   CpuF10Features->CpuF10FeaturesLo.CMOV = cpuFeatureList->CMOV;
245   CpuF10Features->CpuF10FeaturesLo.CMPXCHG8B = cpuFeatureList->CMPXCHG8B;
246   CpuF10Features->CpuF10FeaturesLo.DE = cpuFeatureList->DE;
247   CpuF10Features->CpuF10FeaturesLo.FPU = cpuFeatureList->FPU;
248   CpuF10Features->CpuF10FeaturesLo.FXSR = cpuFeatureList->FXSR;
249   CpuF10Features->CpuF10FeaturesLo.HTT = cpuFeatureList->HTT;
250   CpuF10Features->CpuF10FeaturesLo.MCA = cpuFeatureList->MCA;
251   CpuF10Features->CpuF10FeaturesLo.MCE = cpuFeatureList->MCE;
252   CpuF10Features->CpuF10FeaturesLo.MMX = cpuFeatureList->MMX;
253   CpuF10Features->CpuF10FeaturesLo.MSR = cpuFeatureList->MSR;
254   CpuF10Features->CpuF10FeaturesLo.MTRR = cpuFeatureList->MTRR;
255   CpuF10Features->CpuF10FeaturesLo.PAE = cpuFeatureList->PAE;
256   CpuF10Features->CpuF10FeaturesLo.PAT = cpuFeatureList->PAT;
257   CpuF10Features->CpuF10FeaturesLo.PGE = cpuFeatureList->PGE;
258   CpuF10Features->CpuF10FeaturesLo.PSE = cpuFeatureList->PSE;
259   CpuF10Features->CpuF10FeaturesLo.PSE36 = cpuFeatureList->PSE36;
260   CpuF10Features->CpuF10FeaturesLo.SSE = cpuFeatureList->SSE;
261   CpuF10Features->CpuF10FeaturesLo.SSE2 = cpuFeatureList->SSE2;
262   CpuF10Features->CpuF10FeaturesLo.SysEnterSysExit = cpuFeatureList->SysEnterSysExit;
263   CpuF10Features->CpuF10FeaturesLo.TimeStampCounter = cpuFeatureList->TimeStampCounter;
264   CpuF10Features->CpuF10FeaturesLo.VME = cpuFeatureList->VME;
265
266   CpuF10Features->CpuF10FeaturesHi.CMPXCHG16B = cpuFeatureList->CMPXCHG16B;
267   CpuF10Features->CpuF10FeaturesHi.Monitor = cpuFeatureList->Monitor;
268   CpuF10Features->CpuF10FeaturesHi.POPCNT = cpuFeatureList->POPCNT;
269   CpuF10Features->CpuF10FeaturesHi.SSE3 = cpuFeatureList->SSE3;
270
271   LibAmdMsrWrite (MSR_CPUID_FEATS, &CpuMsrData, StdHeader);
272
273   CpuMsrData = 0;
274   CpuF10ExtFeatures = (CPU_F10_EXT_FEATURES *) &CpuMsrData;
275
276   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.ThreeDNow = cpuFeatureList->ThreeDNow;
277   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.ThreeDNowExt = cpuFeatureList->ThreeDNowExt;
278   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.APIC = cpuFeatureList->APIC;
279   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.CMOV = cpuFeatureList->CMOV;
280   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.CMPXCHG8B = cpuFeatureList->CMPXCHG8B;
281   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.DE = cpuFeatureList->DE;
282   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.FFXSR = cpuFeatureList->FFXSR;
283   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.FPU = cpuFeatureList->FPU;
284   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.FXSR = cpuFeatureList->FXSR;
285   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.LM = cpuFeatureList->LM;
286   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.MCA = cpuFeatureList->MCA;
287   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.MCE = cpuFeatureList->MCE;
288   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.MMX = cpuFeatureList->MMX;
289   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.MmxExt = cpuFeatureList->MmxExt;
290   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.MSR = cpuFeatureList->MSR;
291   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.MTRR = cpuFeatureList->MTRR;
292   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.NX = cpuFeatureList->NX;
293   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.PAE = cpuFeatureList->PAE;
294   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.Page1GB = cpuFeatureList->Page1GB;
295   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.PAT = cpuFeatureList->PAT;
296   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.PGE = cpuFeatureList->PGE;
297   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.PSE = cpuFeatureList->PSE;
298   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.PSE36 = cpuFeatureList->PSE36;
299   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.RDTSCP = cpuFeatureList->RDTSCP;
300   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.SysCallSysRet = cpuFeatureList->SysCallSysRet;
301   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.TimeStampCounter = cpuFeatureList->TimeStampCounter;
302   CpuF10ExtFeatures->CpuF10ExtFeaturesLo.VME = cpuFeatureList->VME;
303
304   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.ThreeDNowPrefetch = cpuFeatureList->ThreeDNowPrefetch;
305   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.ABM = cpuFeatureList->ABM;
306   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.AltMovCr8 = cpuFeatureList->AltMovCr8;
307   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.CmpLegacy = cpuFeatureList->CmpLegacy;
308   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.ExtApicSpace = cpuFeatureList->ExtApicSpace;
309   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.IBS = cpuFeatureList->IBS;
310   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.LahfSahf = cpuFeatureList->LahfSahf;
311   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.MisAlignSse = cpuFeatureList->MisAlignSse;
312   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.OSVM = cpuFeatureList->OSVW;
313   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.SKINIT = cpuFeatureList->SKINIT;
314   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.SSE4A = cpuFeatureList->SSE4A;
315   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.SVM = cpuFeatureList->SVM;
316   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.WDT = cpuFeatureList->WDT;
317   CpuF10ExtFeatures->CpuF10ExtFeaturesHi.NodeId = cpuFeatureList->NodeId;
318   LibAmdMsrWrite (MSR_CPUID_EXT_FEATS, &CpuMsrData, StdHeader);
319 }
320
321 /* -----------------------------------------------------------------------------*/
322 /**
323  *
324  *  cpuFeatureListNeedUpdate
325  *
326  *    Compare global CPU feature list with this core feature list to see if global CPU feature list
327  *    needs updated.
328  *
329  *    @param[in]  globalCpuFeatureList  - Pointer to global CPU Feature List.
330  *    @param[in]  thisCoreCpuFeatureList  - Pointer to this core CPU Feature List.
331  *
332  *    @retval FALSE  globalCpuFeatureList is equal to thisCoreCpuFeatureList
333  *    @retval True  globalCpuFeatureList is NOT equal to thisCoreCpuFeatureList
334  */
335 BOOLEAN
336 STATIC
337 cpuFeatureListNeedUpdate (
338   IN       CPU_FEATURES_LIST *globalCpuFeatureList,
339   IN       CPU_FEATURES_LIST *thisCoreCpuFeatureList
340   )
341 {
342   BOOLEAN flag;
343   UINT8 *global;
344   UINT8 *thisCore;
345   UINT8 i;
346
347   flag = FALSE;
348   global = (UINT8 *) globalCpuFeatureList;
349   thisCore = (UINT8 *) thisCoreCpuFeatureList;
350
351   for (i = 0; i < sizeof (CPU_FEATURES_LIST); i++) {
352     if ((*global) != (*thisCore)) {
353       flag = TRUE;
354       break;
355     }
356     global++;
357     thisCore++;
358   }
359   return flag;
360 }
361
362 /* -----------------------------------------------------------------------------*/
363 /**
364  *
365  *  updateCpuFeatureList
366  *
367  *    Update global CPU feature list
368  *
369  *    @param[in]  globalCpuFeatureList  - Pointer to global CPU Feature List.
370  *    @param[in]  thisCoreCpuFeatureList  - Pointer to this core CPU Feature List.
371  *
372  */
373 VOID
374 STATIC
375 updateCpuFeatureList (
376   IN       CPU_FEATURES_LIST *globalCpuFeatureList,
377   IN       CPU_FEATURES_LIST *thisCoreCpuFeatureList
378   )
379 {
380   UINT8 *globalFeatureList;
381   UINT8 *thisCoreFeatureList;
382   UINT32 sizeInByte;
383
384   globalFeatureList = (UINT8 *) globalCpuFeatureList;
385   thisCoreFeatureList = (UINT8 *) thisCoreCpuFeatureList;
386
387   for (sizeInByte = 0; sizeInByte < sizeof (CPU_FEATURES_LIST); sizeInByte++) {
388     *globalFeatureList &= *thisCoreFeatureList;
389     globalFeatureList++;
390     thisCoreFeatureList++;
391   }
392 }
393