5 * Construct a northbridge interface for a Node.
7 * Handle build options and run-time detection.
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: HyperTransport
12 * @e \$Revision: 56279 $ @e \$Date: 2011-07-11 13:11:28 -0600 (Mon, 11 Jul 2011) $
16 *****************************************************************************
18 * Copyright (C) 2012 Advanced Micro Devices, Inc.
19 * All rights reserved.
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.
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.
43 * ***************************************************************************
48 *----------------------------------------------------------------------------
51 *----------------------------------------------------------------------------
56 #include "OptionsHt.h"
61 #include "htNbCommonHardware.h"
62 #include "CommonReturns.h"
63 #include "cpuRegisters.h"
64 #include "cpuFamilyTranslation.h"
65 #include "cpuFamRegisters.h"
71 #define FILECODE PROC_HT_HTNB_FILECODE
73 extern OPTION_HT_CONFIGURATION OptionHtConfiguration;
75 /*----------------------------------------------------------------------------
76 * DEFINITIONS AND MACROS
78 *----------------------------------------------------------------------------
81 /*----------------------------------------------------------------------------
82 * TYPEDEFS AND STRUCTURES
84 *----------------------------------------------------------------------------
86 /*----------------------------------------------------------------------------
87 * PROTOTYPES OF LOCAL FUNCTIONS
89 *----------------------------------------------------------------------------
92 /***************************************************************************
93 *** FAMILY/NORTHBRIDGE SPECIFIC FUNCTIONS ***
94 ***************************************************************************/
98 * Initial construction data for no HT Northbridge.
100 CONST NORTHBRIDGE ROMDATA HtFam10NbNone =
103 (PF_WRITE_ROUTING_TABLE)CommonVoid,
104 (PF_WRITE_NODEID)CommonVoid,
105 (PF_READ_DEFAULT_LINK)CommonReturnZero8,
106 (PF_ENABLE_ROUTING_TABLES)CommonVoid,
107 (PF_DISABLE_ROUTING_TABLES)CommonVoid,
108 (PF_VERIFY_LINK_IS_COHERENT)CommonReturnFalse,
109 (PF_READ_TOKEN)CommonReturnZero8,
110 (PF_WRITE_TOKEN)CommonVoid,
111 (PF_WRITE_FULL_ROUTING_TABLE)CommonVoid,
112 (PF_IS_ILLEGAL_TYPE_MIX)CommonReturnFalse,
113 (PF_IS_EXCEEDED_CAPABLE)CommonReturnFalse,
114 (PF_STOP_LINK)CommonVoid,
115 (PF_HANDLE_SPECIAL_LINK_CASE)CommonReturnFalse,
116 (PF_HANDLE_SPECIAL_NODE_CASE)CommonReturnFalse,
117 (PF_READ_SB_LINK)CommonReturnZero8,
118 (PF_VERIFY_LINK_IS_NON_COHERENT)CommonReturnFalse,
119 (PF_SET_CONFIG_ADDR_MAP)CommonVoid,
120 (PF_NORTH_BRIDGE_FREQ_MASK)CommonReturnZero32,
121 (PF_GATHER_LINK_FEATURES)CommonVoid,
122 (PF_SET_LINK_REGANG)CommonVoid,
123 (PF_SET_LINK_FREQUENCY)CommonVoid,
124 (PF_SET_LINK_UNITID_CLUMPING)CommonVoid,
125 (PF_WRITE_TRAFFIC_DISTRIBUTION)CommonVoid,
126 (PF_WRITE_LINK_PAIR_DISTRIBUTION)CommonVoid,
127 (PF_WRITE_VICTIM_DISTRIBUTION)CommonVoid,
128 (PF_BUFFER_OPTIMIZATIONS)CommonVoid,
129 (PF_GET_NUM_CORES_ON_NODE)CommonReturnZero8,
130 (PF_SET_TOTAL_NODES_AND_CORES)CommonVoid,
131 (PF_GET_NODE_COUNT)CommonReturnZero8,
132 (PF_LIMIT_NODES)CommonVoid,
133 (PF_READ_TRUE_LINK_FAIL_STATUS)CommonReturnFalse,
134 (PF_GET_NEXT_LINK)CommonReturnZero32,
135 (PF_GET_PACKAGE_LINK)CommonReturnZero8,
136 (PF_MAKE_LINK_BASE)CommonReturnZero32,
137 (PF_GET_MODULE_INFO)CommonVoid,
138 (PF_POST_MAILBOX)CommonVoid,
139 (PF_RETRIEVE_MAILBOX)CommonReturnZero32,
140 (PF_GET_SOCKET)CommonReturnZero8,
141 (PF_GET_ENABLED_COMPUTE_UNITS)CommonReturnZero8,
142 (PF_GET_DUALCORE_COMPUTE_UNITS)CommonReturnZero8,
152 (PF_MAKE_KEY)CommonReturnZero64,
156 /*----------------------------------------------------------------------------------------*/
158 * Make a compatibility key.
160 * @HtNbMethod{::F_MAKE_KEY}
162 * Private routine to northbridge code.
163 * Create a key which can be used to determine whether a Node is compatible with
164 * the discovered configuration so far. Currently, that means the family,
165 * extended family of the new Node are the same as the BSP's. Family specific
166 * implementations can add whatever else is necessary.
168 * @param[in] Node the Node
169 * @param[in] Nb this northbridge
179 CPU_LOGICAL_ID LogicalId;
183 Reg.AddressValue = MAKE_SBDFO (MakePciSegmentFromNode (Node),
184 MakePciBusFromNode (Node),
185 MakePciDeviceFromNode (Node),
189 LibAmdPciReadBits (Reg, 31, 0, &RawCpuId, Nb->ConfigHandle);
190 GetLogicalIdFromCpuid (RawCpuId, &LogicalId, Nb->ConfigHandle);
191 return LogicalId.Family;
194 /*----------------------------------------------------------------------------------------*/
196 * Construct a new northbridge.
198 * This routine encapsulates knowledge of how to tell significant differences between
199 * families of supported northbridges and what routines can be used in common and
200 * which are unique. A fully populated northbridge interface is provided by Nb.
202 * @param[in] Node create a northbridge interface for this Node.
203 * @param[in] State global state
204 * @param[out] Nb the caller's northbridge structure to initialize.
209 IN STATE_DATA *State,
213 CPU_LOGICAL_ID LogicalId;
217 NORTHBRIDGE **InitializerInstance;
219 // Start with enough of the key to identify the northbridge interface
220 Reg.AddressValue = MAKE_SBDFO (MakePciSegmentFromNode (Node),
221 MakePciBusFromNode (Node),
222 MakePciDeviceFromNode (Node),
225 LibAmdPciReadBits (Reg, 31, 0, &RawCpuId, State->ConfigHandle);
226 IDS_HDT_CONSOLE (HT_TRACE, "AMD Processor at Node %d has raw CPUID=%x.\n", Node, RawCpuId);
227 GetLogicalIdFromCpuid (RawCpuId, &LogicalId, State->ConfigHandle);
228 Match = LogicalId.Family;
230 // Test each Northbridge interface in turn looking for a match.
231 // Use it to Init the Nb struct if a match is found.
233 ASSERT (OptionHtConfiguration.HtOptionFamilyNorthbridgeList != NULL);
234 InitializerInstance = (NORTHBRIDGE **) (OptionHtConfiguration.HtOptionFamilyNorthbridgeList);
235 while (*InitializerInstance != NULL) {
236 if ((Match & (*InitializerInstance)->CompatibleKey) != 0) {
237 LibAmdMemCopy ((VOID *)Nb, (VOID *)*InitializerInstance, (UINT32) sizeof (NORTHBRIDGE), State->ConfigHandle);
240 InitializerInstance++;
242 // There must be an available northbridge implementation.
243 ASSERT (*InitializerInstance != NULL);
245 // Set the config handle for passing to the library.
246 Nb->ConfigHandle = State->ConfigHandle;