AGESA F15: AMD family15 AGESA code
[coreboot.git] / src / vendorcode / amd / agesa / f15 / Proc / HT / htInterface.c
1 /* $NoKeywords:$ */
2 /**
3  * @file
4  *
5  * External Interface implementation.
6  *
7  * Contains routines for implementing the interface to the client BIOS.
8  * This file includes the interface access constructor.
9  * This file implements build options using conditional compilation.
10  *
11  * @xrefitem bom "File Content Label" "Release Content"
12  * @e project:      AGESA
13  * @e sub-project:  HyperTransport
14  * @e \$Revision: 56279 $   @e \$Date: 2011-07-11 13:11:28 -0600 (Mon, 11 Jul 2011) $
15  *
16  */
17 /*
18  *****************************************************************************
19  *
20  * Copyright (C) 2012 Advanced Micro Devices, Inc.
21  * All rights reserved.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions are met:
25  *     * Redistributions of source code must retain the above copyright
26  *       notice, this list of conditions and the following disclaimer.
27  *     * Redistributions in binary form must reproduce the above copyright
28  *       notice, this list of conditions and the following disclaimer in the
29  *       documentation and/or other materials provided with the distribution.
30  *     * Neither the name of Advanced Micro Devices, Inc. nor the names of
31  *       its contributors may be used to endorse or promote products derived
32  *       from this software without specific prior written permission.
33  *
34  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
35  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37  * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
38  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
41  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
43  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44  *
45  * ***************************************************************************
46  *
47  */
48
49 /*
50  *----------------------------------------------------------------------------
51  *                                MODULES USED
52  *
53  *----------------------------------------------------------------------------
54  */
55
56
57
58 #include "AGESA.h"
59 #include "AdvancedApi.h"
60 #include "amdlib.h"
61 #include "OptionsHt.h"
62 #include "Ids.h"
63 #include "Topology.h"
64 #include "htFeat.h"
65 #include "htInterface.h"
66 #include "CommonReturns.h"
67 #include "htInterfaceGeneral.h"
68 #include "htInterfaceCoherent.h"
69 #include "htInterfaceNonCoherent.h"
70 #include "Filecode.h"
71 CODE_GROUP (G1_PEICC)
72 RDATA_GROUP (G2_PEI)
73
74 #define FILECODE PROC_HT_HTINTERFACE_FILECODE
75 /*----------------------------------------------------------------------------
76  *                          DEFINITIONS AND MACROS
77  *
78  *----------------------------------------------------------------------------
79  */
80
81 extern CONST OPTION_HT_CONFIGURATION OptionHtConfiguration;
82
83 /*----------------------------------------------------------------------------
84  *                           TYPEDEFS AND STRUCTURES
85  *
86  *----------------------------------------------------------------------------
87  */
88
89 /**
90  * The default initializer for the HT internal interface, full features.
91  */
92 CONST HT_INTERFACE ROMDATA HtInterfaceDefault =
93 {
94   GetCpu2CpuPcbLimits,
95   GetSkipRegang,
96   NewHopCountTable,
97   GetOverrideBusNumbers,
98   GetManualBuidSwapList,
99   GetDeviceCapOverride,
100   GetIoPcbLimits,
101   GetSocketFromMap,
102   GetIgnoreLink,
103   PostMapToAp,
104   NewNodeAndSocketTables,
105   CleanMapsAfterError,
106   SetNodeToSocketMap,
107   GetMinNbCoreFreq
108 };
109
110 /**
111  * The initializer for the HT internal interface, coherent only features.
112  */
113 CONST HT_INTERFACE ROMDATA HtInterfaceCoherentOnly =
114 {
115   GetCpu2CpuPcbLimits,
116   GetSkipRegang,
117   NewHopCountTable,
118   GetOverrideBusNumbers,
119   (PF_GET_MANUAL_BUID_SWAP_LIST)CommonReturnFalse,
120   (PF_GET_DEVICE_CAP_OVERRIDE)CommonVoid,
121   (PF_GET_IO_PCB_LIMITS)CommonVoid,
122   GetSocketFromMap,
123   GetIgnoreLink,
124   PostMapToAp,
125   NewNodeAndSocketTables,
126   CleanMapsAfterError,
127   SetNodeToSocketMap,
128   GetMinNbCoreFreq
129 };
130
131 /**
132  * The non-coherent only build option initializer for the HT internal interface.
133  */
134 CONST HT_INTERFACE ROMDATA HtInterfaceNonCoherentOnly =
135 {
136   (PF_GET_CPU_2_CPU_PCB_LIMITS)CommonVoid,
137   (PF_GET_SKIP_REGANG)CommonReturnFalse,
138   (PF_NEW_HOP_COUNT_TABLE)CommonVoid,
139   GetOverrideBusNumbers,
140   GetManualBuidSwapList,
141   GetDeviceCapOverride,
142   GetIoPcbLimits,
143   GetSocketFromMap,
144   GetIgnoreLink,
145   PostMapToAp,
146   NewNodeAndSocketTables,
147   (PF_CLEAN_MAPS_AFTER_ERROR)CommonVoid,
148   SetNodeToSocketMap,
149   GetMinNbCoreFreq
150 };
151
152 /**
153  * Topology Maps only feature build option initializer for the HT internal interface.
154  */
155 CONST HT_INTERFACE ROMDATA HtInterfaceMapsOnly =
156 {
157   (PF_GET_CPU_2_CPU_PCB_LIMITS)CommonVoid,
158   (PF_GET_SKIP_REGANG)CommonReturnFalse,
159   (PF_NEW_HOP_COUNT_TABLE)CommonVoid,
160   (PF_GET_OVERRIDE_BUS_NUMBERS)CommonReturnFalse,
161   (PF_GET_MANUAL_BUID_SWAP_LIST)CommonReturnFalse,
162   (PF_GET_DEVICE_CAP_OVERRIDE)CommonVoid,
163   (PF_GET_IO_PCB_LIMITS)CommonVoid,
164   (PF_GET_SOCKET_FROM_MAP)CommonReturnZero8,
165   (PF_GET_IGNORE_LINK)CommonReturnFalse,
166   PostMapToAp,
167   NewNodeAndSocketTables,
168   (PF_CLEAN_MAPS_AFTER_ERROR)CommonVoid,
169   SetNodeToSocketMap,
170   (PF_GET_MIN_NB_CORE_FREQ)CommonReturnZero8
171 };
172
173 /**
174  * No features build option initializer for the HT internal interface.
175  */
176 CONST HT_INTERFACE ROMDATA HtInterfaceNone =
177 {
178   (PF_GET_CPU_2_CPU_PCB_LIMITS)CommonVoid,
179   (PF_GET_SKIP_REGANG)CommonReturnFalse,
180   (PF_NEW_HOP_COUNT_TABLE)CommonVoid,
181   (PF_GET_OVERRIDE_BUS_NUMBERS)CommonReturnFalse,
182   (PF_GET_MANUAL_BUID_SWAP_LIST)CommonReturnFalse,
183   (PF_GET_DEVICE_CAP_OVERRIDE)CommonVoid,
184   (PF_GET_IO_PCB_LIMITS)CommonVoid,
185   (PF_GET_SOCKET_FROM_MAP)CommonReturnZero8,
186   (PF_GET_IGNORE_LINK)CommonReturnFalse,
187   (PF_POST_MAP_TO_AP)CommonVoid,
188   (PF_NEW_NODE_AND_SOCKET_TABLES)CommonVoid,
189   (PF_CLEAN_MAPS_AFTER_ERROR)CommonVoid,
190   (PF_SET_NODE_TO_SOCKET_MAP)CommonVoid,
191   (PF_GET_MIN_NB_CORE_FREQ)CommonReturnZero8
192 };
193
194 /*----------------------------------------------------------------------------
195  *                        PROTOTYPES OF LOCAL FUNCTIONS
196  *
197  *----------------------------------------------------------------------------
198  */
199
200 /*----------------------------------------------------------------------------
201  *                            EXPORTED FUNCTIONS
202  *
203  *----------------------------------------------------------------------------
204  */
205
206 /*----------------------------------------------------------------------------
207  *                              LOCAL FUNCTIONS
208  *
209  *----------------------------------------------------------------------------
210  */
211
212 /*----------------------------------------------------------------------------------------*/
213 /**
214  * A constructor for the internal Ht Interface.
215  *
216  * The install has a reference to the initializer appropriate to the user selected build
217  * options.  Use the selected initializer to construct the internal interface.
218  *
219  * @param[in,out]   HtInterface    Contains pointer to HT Interface structure to initialize.
220  * @param[in]       StdHeader         Opaque handle to standard config header
221  *
222 */
223 VOID
224 NewHtInterface (
225      OUT   HT_INTERFACE         *HtInterface,
226   IN       AMD_CONFIG_PARAMS    *StdHeader
227   )
228 {
229   LibAmdMemCopy (
230     (VOID *) HtInterface,
231     (VOID *) OptionHtConfiguration.HtOptionInternalInterface,
232     (sizeof (HT_INTERFACE)),
233     StdHeader
234     );
235 }
236
237 /*----------------------------------------------------------------------------------------*/
238 /**
239  * A "constructor" for the HyperTransport external interface.
240  *
241  * Sets inputs to valid, basic level, defaults.
242  *
243  * Copy the initial default values from the build options tables to the interface struct.
244  *
245  * @param[in]   StdHeader       Opaque handle to standard config header
246  * @param[in]   AmdHtInterface  HT Interface structure to initialize.
247  *
248  * @retval AGESA_SUCCESS      Constructors are not allowed to fail
249 */
250 AGESA_STATUS
251 AmdHtInterfaceConstructor (
252   IN       AMD_CONFIG_PARAMS    *StdHeader,
253   IN       AMD_HT_INTERFACE     *AmdHtInterface
254   )
255 {
256   LibAmdMemCopy (
257     (VOID *) AmdHtInterface,
258     (VOID *) OptionHtConfiguration.HtOptionPlatformDefaults,
259     (UINT32) (sizeof (AMD_HT_INTERFACE)),
260     StdHeader
261     );
262   return AGESA_SUCCESS;
263 }