AGESA F15: AMD family15 AGESA code
[coreboot.git] / src / vendorcode / amd / agesa / f15 / Proc / CPU / Feature / cpuL3Features.h
1 /* $NoKeywords:$ */
2 /**
3  * @file
4  *
5  * AMD CPU L3 Features Initialization functions.
6  *
7  * Contains code that declares the AGESA CPU L3 dependent feature related APIs
8  *
9  * @xrefitem bom "File Content Label" "Release Content"
10  * @e project:      AGESA
11  * @e sub-project:  CPU/Feature
12  * @e \$Revision: 60552 $   @e \$Date: 2011-10-17 18:50:55 -0600 (Mon, 17 Oct 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 #ifndef _CPU_L3_FEATURES_H_
47 #define _CPU_L3_FEATIRES_H_
48
49 #include "Filecode.h"
50 /*----------------------------------------------------------------------------------------
51  *          M I X E D   (Definitions And Macros / Typedefs, Structures, Enums)
52  *----------------------------------------------------------------------------------------
53  */
54 //  Forward declaration needed for multi-structure mutual references
55 AGESA_FORWARD_DECLARATION (L3_FEATURE_FAMILY_SERVICES);
56
57 /*----------------------------------------------------------------------------------------
58  *                 D E F I N I T I O N S     A N D     M A C R O S
59  *----------------------------------------------------------------------------------------
60  */
61 #define AP_LATE_TASK_DISABLE_CACHE (0x00000000 | PROC_CPU_FEATURE_CPUL3FEATURES_FILECODE)
62 #define AP_LATE_TASK_ENABLE_CACHE  (0x00010000 | PROC_CPU_FEATURE_CPUL3FEATURES_FILECODE)
63
64 /*----------------------------------------------------------------------------------------
65  *                    T Y P E D E F S     A N D     S T R U C T U R E S
66  *----------------------------------------------------------------------------------------
67  */
68 #define L3_SCRUBBER_CONTEXT_ARRAY_SIZE 4
69
70 /*---------------------------------------------------------------------------------------*/
71 /**
72  *  Family specific call to check if L3 Features are supported.
73  *
74  * @param[in]    L3FeatureServices   L3 Feature family services.
75  * @param[in]    Socket              Processor socket to check.
76  * @param[in]    StdHeader           Config Handle for library, services.
77  * @param[in]    PlatformConfig      Contains the runtime modifiable feature input data.
78  *
79  * @retval       TRUE               L3 dependent features are supported
80  * @retval       FALSE              L3 dependent features are not supported
81  *
82  */
83 typedef BOOLEAN F_L3_FEATURE_IS_SUPPORTED (
84   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
85   IN       UINT32 Socket,
86   IN       AMD_CONFIG_PARAMS *StdHeader,
87   IN       PLATFORM_CONFIGURATION *PlatformConfig
88   );
89
90 /// Reference to a Method.
91 typedef F_L3_FEATURE_IS_SUPPORTED *PF_L3_FEATURE_IS_SUPPORTED;
92
93 /*---------------------------------------------------------------------------------------*/
94 /**
95  *  Family specific hook before L3 features are initialized.
96  *
97  * @param[in]    L3FeatureServices   L3 Feature family services.
98  * @param[in]    Socket              Processor socket to check.
99  * @param[in]    StdHeader           Config Handle for library, services.
100  *
101  */
102 typedef VOID F_L3_FEATURE_BEFORE_INIT (
103   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
104   IN       UINT32 Socket,
105   IN       AMD_CONFIG_PARAMS *StdHeader
106   );
107
108 /// Reference to a Method.
109 typedef F_L3_FEATURE_BEFORE_INIT *PF_L3_FEATURE_BEFORE_INIT;
110
111 /*---------------------------------------------------------------------------------------*/
112 /**
113  *  Family specific call to disable cache.
114  *
115  * @param[in]    L3FeatureServices   L3 Feature family services.
116  * @param[in]    HtAssistEnabled     Indicates whether Ht Assist is enabled.
117  * @param[in]    StdHeader           Config Handle for library, services.
118  *
119  */
120 typedef VOID F_L3_FEATURE_DISABLE_CACHE (
121   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
122   IN       BOOLEAN HtAssistEnabled,
123   IN       AMD_CONFIG_PARAMS *StdHeader
124   );
125
126 /// Reference to a Method.
127 typedef F_L3_FEATURE_DISABLE_CACHE *PF_L3_FEATURE_DISABLE_CACHE;
128
129 /*---------------------------------------------------------------------------------------*/
130 /**
131  *  Family specific call to disable cache.
132  *
133  * @param[in]    L3FeatureServices   L3 Feature family services.
134  * @param[in]    StdHeader           Config Handle for library, services.
135  *
136  * @return       Family specific error value.
137  *
138  */
139 typedef VOID F_L3_FEATURE_ENABLE_CACHE (
140   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
141   IN       AMD_CONFIG_PARAMS *StdHeader
142   );
143
144 /// Reference to a Method.
145 typedef F_L3_FEATURE_ENABLE_CACHE *PF_L3_FEATURE_ENABLE_CACHE;
146
147 /*---------------------------------------------------------------------------------------*/
148 /**
149  *  Family specific call to Initialize L3 Features
150  *
151  * @param[in]    L3FeatureServices   L3 Feature family services.
152  * @param[in]    Socket              Processor socket to enable.
153  * @param[in]    StdHeader           Config Handle for library, services.
154  *
155  */
156 typedef VOID F_L3_FEATURE_INIT (
157   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
158   IN       UINT32 Socket,
159   IN       AMD_CONFIG_PARAMS *StdHeader
160   );
161
162 /// Reference to a Method.
163 typedef F_L3_FEATURE_INIT *PF_L3_FEATURE_INIT;
164
165 /*---------------------------------------------------------------------------------------*/
166 /**
167  *  Family specific hook after L3 Features are initialized.
168  *
169  * @param[in]    L3FeatureServices   L3 Features family services.
170  * @param[in]    Socket              Processor socket to check.
171  * @param[in]    StdHeader           Config Handle for library, services.
172  *
173  */
174 typedef VOID F_L3_FEATURE_AFTER_INIT (
175   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
176   IN       UINT32 Socket,
177   IN       AMD_CONFIG_PARAMS *StdHeader
178   );
179
180 /// Reference to a Method.
181 typedef F_L3_FEATURE_AFTER_INIT *PF_L3_FEATURE_AFTER_INIT;
182
183 /*---------------------------------------------------------------------------------------*/
184 /**
185  *  Family specific call to save the L3 scrubber.
186  *
187  * @param[in]    L3FeatureServices   L3 Feature family services.
188  * @param[in]    Socket              Processor socket to check.
189  * @param[in]    ScrubSettings       Location to store current L3 scrubber settings.
190  * @param[in]    StdHeader           Config Handle for library, services.
191  *
192  */
193 typedef VOID F_L3_FEATURE_GET_L3_SCRUB_CTRL (
194   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
195   IN       UINT32 Socket,
196   IN       UINT32 ScrubSettings[L3_SCRUBBER_CONTEXT_ARRAY_SIZE],
197   IN       AMD_CONFIG_PARAMS *StdHeader
198   );
199
200 /// Reference to a Method.
201 typedef F_L3_FEATURE_GET_L3_SCRUB_CTRL *PF_L3_FEATURE_GET_L3_SCRUB_CTRL;
202
203 /*---------------------------------------------------------------------------------------*/
204 /**
205  *  Family specific call to restore the L3 scrubber.
206  *
207  * @param[in]    L3FeatureServices   L3 Feature family services.
208  * @param[in]    Socket              Processor socket to check.
209  * @param[in]    ScrubSettings       Contains L3 scrubber settings to restore.
210  * @param[in]    StdHeader           Config Handle for library, services.
211  *
212  */
213 typedef VOID F_L3_FEATURE_SET_L3_SCRUB_CTRL (
214   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
215   IN       UINT32 Socket,
216   IN       UINT32 ScrubSettings[L3_SCRUBBER_CONTEXT_ARRAY_SIZE],
217   IN       AMD_CONFIG_PARAMS *StdHeader
218   );
219
220 /// Reference to a Method.
221 typedef F_L3_FEATURE_SET_L3_SCRUB_CTRL *PF_L3_FEATURE_SET_L3_SCRUB_CTRL;
222
223 /*---------------------------------------------------------------------------------------*/
224 /**
225  *  Family specific call to check if HT Assist is supported.
226  *
227  * @param[in]    L3FeatureServices   L3 Feature family services.
228  * @param[in]    PlatformConfig      Contains the runtime modifiable feature input data
229  * @param[in]    StdHeader           Config Handle for library, services.
230  *
231  * @retval       TRUE               HT Assist is supported.
232  * @retval       FALSE              HT Assist is not supported.
233  *
234  */
235 typedef BOOLEAN F_HT_ASSIST_IS_SUPPORTED (
236   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
237   IN       PLATFORM_CONFIGURATION *PlatformConfig,
238   IN       AMD_CONFIG_PARAMS *StdHeader
239   );
240
241 /// Reference to a Method.
242 typedef F_HT_ASSIST_IS_SUPPORTED *PF_HT_ASSIST_IS_SUPPORTED;
243
244 /*---------------------------------------------------------------------------------------*/
245 /**
246  *  Family specific call to Initialize HT Assist
247  *
248  * @param[in]    L3FeatureServices   L3 Features family services.
249  * @param[in]    Socket              Processor socket to enable.
250  * @param[in]    StdHeader           Config Handle for library, services.
251  *
252  */
253 typedef VOID F_HT_ASSIST_INIT (
254   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
255   IN       UINT32 Socket,
256   IN       AMD_CONFIG_PARAMS *StdHeader
257   );
258
259 /// Reference to a Method.
260 typedef F_HT_ASSIST_INIT *PF_HT_ASSIST_INIT;
261
262 /*---------------------------------------------------------------------------------------*/
263 /**
264  *  Family specific call to provide non_optimal HT Assist support
265  *
266  * @param[in]    L3FeatureServices   L3 Feature family services.
267  * @param[in]    Socket              Processor socket to check.
268  * @param[in]    StdHeader           Config Handle for library, services.
269  *
270  * @return       TRUE                The system may be running with non-optimal settings.
271  * @return       FALSE               The system may is running optimally.
272  *
273  */
274 typedef BOOLEAN F_HT_ASSIST_IS_NONOPTIMAL (
275   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
276   IN       UINT32 Socket,
277   IN       AMD_CONFIG_PARAMS *StdHeader
278   );
279
280 /// Reference to a Method.
281 typedef F_HT_ASSIST_IS_NONOPTIMAL *PF_HT_ASSIST_IS_NONOPTIMAL;
282
283 /*---------------------------------------------------------------------------------------*/
284 /**
285  *  Family specific call to check if ATM Mode is supported.
286  *
287  * @param[in]    L3FeatureServices   L3 Features family services.
288  * @param[in]    PlatformConfig      Contains the runtime modifiable feature input data.
289  * @param[in]    StdHeader           Config Handle for library, services.
290  *
291  * @retval       TRUE               ATM Mode is supported.
292  * @retval       FALSE              ATM Mode is not supported.
293  *
294  */
295 typedef BOOLEAN F_ATM_MODE_IS_SUPPORTED (
296   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
297   IN       PLATFORM_CONFIGURATION *PlatformConfig,
298   IN       AMD_CONFIG_PARAMS *StdHeader
299   );
300
301 /// Reference to a Method.
302 typedef F_ATM_MODE_IS_SUPPORTED *PF_ATM_MODE_IS_SUPPORTED;
303
304 /*---------------------------------------------------------------------------------------*/
305 /**
306  *  Family specific call to Initialize ATM mode
307  *
308  * @param[in]    L3FeatureServices   L3 Features family services.
309  * @param[in]    Socket              Processor socket to enable.
310  * @param[in]    StdHeader           Config Handle for library, services.
311  *
312  */
313 typedef VOID F_ATM_MODE_INIT (
314   IN       L3_FEATURE_FAMILY_SERVICES *L3FeatureServices,
315   IN       UINT32 Socket,
316   IN       AMD_CONFIG_PARAMS *StdHeader
317   );
318
319 /// Reference to a Method.
320 typedef F_ATM_MODE_INIT *PF_ATM_MODE_INIT;
321
322 /**
323  * Provide the interface to the L3 dependent features Family Specific Services.
324  *
325  * Use the methods or data in this struct to adapt the feature code to a specific cpu family or model (or stepping!).
326  * Each supported Family must provide an implementation for all methods in this interface, even if the
327  * implementation is a CommonReturn().
328  */
329 struct _L3_FEATURE_FAMILY_SERVICES {
330   UINT16          Revision;                             ///< Interface version
331   // Public Methods.
332   PF_L3_FEATURE_IS_SUPPORTED IsL3FeatureSupported;      ///< Method: Check if L3 dependent features are supported.
333   PF_L3_FEATURE_GET_L3_SCRUB_CTRL GetL3ScrubCtrl;       ///< Method: Save/disable the L3 scrubber.
334   PF_L3_FEATURE_SET_L3_SCRUB_CTRL SetL3ScrubCtrl;       ///< Method: Restore the L3 scrubber.
335   PF_L3_FEATURE_BEFORE_INIT HookBeforeInit;             ///< Method: Hook before enabling L3 dependent features.
336   PF_L3_FEATURE_AFTER_INIT HookAfterInit;               ///< Method: Hook after enabling L3 dependent features.
337   PF_L3_FEATURE_DISABLE_CACHE HookDisableCache;         ///< Method: Core hook just before disabling cache.
338   PF_L3_FEATURE_ENABLE_CACHE HookEnableCache;           ///< Method: Core hook just after enabling cache.
339   PF_HT_ASSIST_IS_SUPPORTED IsHtAssistSupported;        ///< Method: Check if HT Assist is supported.
340   PF_HT_ASSIST_INIT HtAssistInit;                       ///< Method: Enable HT Assist.
341   PF_HT_ASSIST_IS_NONOPTIMAL IsNonOptimalConfig;        ///< Method: Check if HT Assist is running optimally.
342   PF_ATM_MODE_IS_SUPPORTED IsAtmModeSupported;          ///< Method: Check if ATM Mode is supported.
343   PF_ATM_MODE_INIT AtmModeInit;                         ///< Method: Enable ATM Mode.
344 };
345
346
347 /*----------------------------------------------------------------------------------------
348  *                          F U N C T I O N S     P R O T O T Y P E
349  *----------------------------------------------------------------------------------------
350  */
351 AGESA_STATUS
352 DisableAllCaches (
353   IN       AP_EXE_PARAMS *ApExeParams
354   );
355
356 AGESA_STATUS
357 EnableAllCaches (
358   IN       AP_EXE_PARAMS *ApExeParams
359   );
360
361 #endif  // _CPU_L3_FEATURES_H_