5 * Internal access to HT Interface.
7 * This file provides definitions used by HT internal modules. The
8 * external HT interface (in agesa.h) is accessed using these methods.
9 * This keeps the HT Feature implementations abstracted from the HT
12 * This file includes the interface access constructor and interface
13 * support which is not removed with various build options.
15 * @xrefitem bom "File Content Label" "Release Content"
17 * @e sub-project: HyperTransport
18 * @e \$Revision: 44324 $ @e \$Date: 2010-12-22 02:16:51 -0700 (Wed, 22 Dec 2010) $
22 *****************************************************************************
24 * Copyright (C) 2012 Advanced Micro Devices, Inc.
25 * All rights reserved.
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions are met:
29 * * Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * * Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in the
33 * documentation and/or other materials provided with the distribution.
34 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
35 * its contributors may be used to endorse or promote products derived
36 * from this software without specific prior written permission.
38 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
39 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
40 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
42 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
43 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
47 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 * ***************************************************************************
53 #ifndef _HT_INTERFACE_H_
54 #define _HT_INTERFACE_H_
57 * @page htimplintf HT Internal Interface Implementation Guide
59 * HT Internal Interface provides access to the HT Component external interface (see AGESA.h),
60 * in a manner that isolates calling code from knowledge about the external interface or which
61 * interfaces are supported in the current build.
63 * @par Adding a Method to HT Internal Interface
65 * To add a new method to the HT Internal Interface, follow these steps.
67 * <li> Create a typedef for the Method with the correct parameters and return type.
70 * <li> Name the method typedef (F_METHOD_NAME)(), where METHOD_NAME is the same name as the method table item,
71 * but with "_"'s and UPPERCASE, rather than mixed case.
72 * @n <tt> typedef VOID (F_METHOD_NAME)(); </tt> @n
74 * <li> Make a reference type for references to a method implementation:
75 * @n <tt> /// Reference to a Method </tt>
76 * @n <tt> typedef F_METHOD_NAME *PF_METHOD_NAME </tt> @n
79 * <li> Provide a standard doxygen function preamble for the Method typedef. Begin the
80 * detailed description by providing a reference to the method instances page by including
84 * * @HtInterfaceInstances
87 * @note It is important to provide documentation for the method type, because the method may not
88 * have an implementation in any families supported by the current package. @n
90 * <li> Add to the HT_INTERFACE struct an item for the Method:
91 * @n <tt> PF_METHOD_NAME MethodName; ///< Method: description. </tt> @n
94 * @par Implementing an HT Internal Interface Instance of the method.
96 * To implement an instance of a method for a specific interface follow these steps.
98 * - In appropriate files, implement the method with the return type and parameters
99 * matching the method typedef.
101 * - Name the function MethodName().
103 * - Create a doxygen function preamble for the method instance. Begin the detailed description with
104 * an Implements command to reference the method type and add this instance to the Method Instances page.
107 * * @HtInterfaceMethod{::F_METHOD_NAME}.
111 * - To access other Ht internal interface routines or data as part of the method implementation, the function
112 * must use HtInterface->OtherMethod(). Do not directly access other HT internal interface
113 * routines, because in the table there may be overrides or this routine may be shared by multiple families.
115 * - Add the instance to the HT_INTERFACE instances.
117 * - If a configuration does not need an instance of the method use one of the CommonReturns from
118 * CommonReturns.h with the same return type.
120 * @par Invoking HT Internal Interface Methods.
122 * The first step is carried out only once by the top level HT entry point.
124 * HT_INTERFACE HtInterface;
125 * // Get the current HT internal interface (to HtBlock data)
126 * NewHtInterface (&HtInterface);
127 * State->HtInterface = &HtInterface;
130 * The following example shows how to invoke a HT Internal Interface method.
132 * State->HtInterface->MethodName ();
137 /*----------------------------------------------------------------------------
138 * Mixed (DEFINITIONS AND MACROS / TYPEDEFS, STRUCTURES, ENUMS)
140 *----------------------------------------------------------------------------
143 /*-----------------------------------------------------------------------------
144 * DEFINITIONS AND MACROS
146 *-----------------------------------------------------------------------------
149 /*----------------------------------------------------------------------------
150 * TYPEDEFS, STRUCTURES, ENUMS
152 *----------------------------------------------------------------------------
156 * Get limits for CPU to CPU Links.
158 * @HtInterfaceInstances.
160 * @param[in] NodeA One Node on which this Link is located
161 * @param[in] LinkA The Link on this Node
162 * @param[in] NodeB The other Node on which this Link is located
163 * @param[in] LinkB The Link on that Node
164 * @param[in,out] ABLinkWidthLimit modify to change the Link Width In
165 * @param[in,out] BALinkWidthLimit modify to change the Link Width Out
166 * @param[in,out] PcbFreqCap modify to change the Link's frequency capability
167 * @param[in] State the input data
170 typedef VOID F_GET_CPU_2_CPU_PCB_LIMITS (
175 IN OUT UINT8 *ABLinkWidthLimit,
176 IN OUT UINT8 *BALinkWidthLimit,
177 IN OUT UINT32 *PcbFreqCap,
180 /// Reference to a method.
181 typedef F_GET_CPU_2_CPU_PCB_LIMITS *PF_GET_CPU_2_CPU_PCB_LIMITS;
184 * Skip reganging of subLinks.
186 * @HtInterfaceInstances.
188 * @param[in] NodeA One Node on which this Link is located
189 * @param[in] LinkA The Link on this Node
190 * @param[in] NodeB The other Node on which this Link is located
191 * @param[in] LinkB The Link on that Node
192 * @param[in] State the input data
194 * @retval MATCHED leave Link unganged
195 * @retval POWERED_OFF leave link unganged and power off the paired sublink
196 * @retval UNMATCHED regang Link automatically
198 typedef FINAL_LINK_STATE F_GET_SKIP_REGANG (
205 /// Reference to a method.
206 typedef F_GET_SKIP_REGANG *PF_GET_SKIP_REGANG;
209 * Manually control bus number assignment.
211 * @HtInterfaceInstances.
213 * @param[in] Node The Node on which this chain is located
214 * @param[in] Link The Link on the host for this chain
215 * @param[out] SecBus Secondary Bus number for this non-coherent chain
216 * @param[out] SubBus Subordinate Bus number
217 * @param[in] State the input data
219 * @retval TRUE this routine is supplying the bus numbers
220 * @retval FALSE use auto Bus numbering
222 typedef BOOLEAN F_GET_OVERRIDE_BUS_NUMBERS (
229 /// Reference to a method.
230 typedef F_GET_OVERRIDE_BUS_NUMBERS *PF_GET_OVERRIDE_BUS_NUMBERS;
233 * Get Manual BUID assignment list.
235 * @HtInterfaceInstances.
237 * @param[in] Node The Node on which this chain is located
238 * @param[in] Link The Link on the host for this chain
239 * @param[out] List a pointer to a list, if returns TRUE
240 * @param[in] State the input data
242 * @retval TRUE use manual List
243 * @retval FALSE initialize the Link automatically. List not valid.
245 typedef BOOLEAN F_GET_MANUAL_BUID_SWAP_LIST (
248 OUT BUID_SWAP_LIST **List,
251 /// Reference to a method.
252 typedef F_GET_MANUAL_BUID_SWAP_LIST *PF_GET_MANUAL_BUID_SWAP_LIST;
255 * Override capabilities of a device.
257 * @HtInterfaceInstances.
259 * @param[in] HostNode The Node on which this chain is located
260 * @param[in] HostLink The Link on the host for this chain
261 * @param[in] Depth The Depth in the I/O chain from the Host
262 * @param[in] PciAddress The Device's PCI config address (for callout)
263 * @param[in] DevVenId The Device's PCI Vendor + Device ID (offset 0x00)
264 * @param[in] Revision The Device's PCI Revision
265 * @param[in] Link The Device's Link number (0 or 1)
266 * @param[in,out] LinkWidthIn modify to change the Link Width In
267 * @param[in,out] LinkWidthOut modify to change the Link Width Out
268 * @param[in,out] FreqCap modify to change the Link's frequency capability
269 * @param[in,out] Clumping modify to change unit id clumping capability
270 * @param[in] State the input data
273 typedef VOID F_GET_DEVICE_CAP_OVERRIDE (
277 IN PCI_ADDR PciAddress,
281 IN OUT UINT8 *LinkWidthIn,
282 IN OUT UINT8 *LinkWidthOut,
283 IN OUT UINT32 *FreqCap,
284 IN OUT UINT32 *Clumping,
287 /// Reference to a method.
288 typedef F_GET_DEVICE_CAP_OVERRIDE *PF_GET_DEVICE_CAP_OVERRIDE;
291 * Get limits for non-coherent Links.
293 * @HtInterfaceInstances.
295 * @param[in] HostNode The Node on which this Link is located
296 * @param[in] HostLink The Link about to be initialized
297 * @param[in] Depth The Depth in the I/O chain from the Host
298 * @param[in,out] DownstreamLinkWidthLimit modify to change the Link Width In
299 * @param[in,out] UpstreamLinkWidthLimit modify to change the Link Width Out
300 * @param[in,out] PcbFreqCap modify to change the Link's frequency capability
301 * @param[in] State the input data
303 typedef VOID F_GET_IO_PCB_LIMITS (
307 IN OUT UINT8 *DownstreamLinkWidthLimit,
308 IN OUT UINT8 *UpstreamLinkWidthLimit,
309 IN OUT UINT32 *PcbFreqCap,
312 /// Reference to a method.
313 typedef F_GET_IO_PCB_LIMITS *PF_GET_IO_PCB_LIMITS;
316 * Get the Socket number for a given Node number.
318 * @HtInterfaceInstances.
320 * @param[in] Node Node discovered event data.
321 * @param[in] State reference to Node to socket map
323 * @return the socket id
326 typedef UINT8 F_GET_SOCKET_FROM_MAP (
330 /// Reference to a method.
331 typedef F_GET_SOCKET_FROM_MAP *PF_GET_SOCKET_FROM_MAP;
336 * @HtInterfaceInstances.
338 * @param[in] Node The Node on which this Link is located
339 * @param[in] Link The Link about to be initialized
340 * @param[in] NbList The northbridge default ignore link list
341 * @param[in] State the input data
343 * @retval MATCHED ignore this Link and skip it
344 * @retval POWERED_OFF ignore this link and power it off.
345 * @retval UNMATCHED initialize the Link normally
347 typedef FINAL_LINK_STATE F_GET_IGNORE_LINK (
350 IN IGNORE_LINK *NbIgnoreLinkList,
353 /// Reference to a method.
354 typedef F_GET_IGNORE_LINK *PF_GET_IGNORE_LINK;
357 * Post Node id and other context info to AP cores via mailbox.
359 * @HtInterfaceInstances.
361 * @param[in] State Our state
363 typedef VOID F_POST_MAP_TO_AP (
366 /// Reference to a method.
367 typedef F_POST_MAP_TO_AP *PF_POST_MAP_TO_AP;
370 * Clean up the map structures after severe event has caused a fall back to 1 node.
372 * @HtInterfaceInstances.
374 * @param[in] State Our state
376 typedef VOID F_CLEAN_MAPS_AFTER_ERROR (
379 /// Reference to a method.
380 typedef F_CLEAN_MAPS_AFTER_ERROR *PF_CLEAN_MAPS_AFTER_ERROR;
383 * Get a new Socket Die to Node Map.
385 * @HtInterfaceInstances.
387 * @param[in,out] State global state
389 typedef VOID F_NEW_NODE_AND_SOCKET_TABLES (
390 IN OUT STATE_DATA *State
392 /// Reference to a method.
393 typedef F_NEW_NODE_AND_SOCKET_TABLES *PF_NEW_NODE_AND_SOCKET_TABLES;
396 * Fill in the socket's Node id when a processor is discovered in that socket.
398 * @HtInterfaceInstances.
400 * @param[in] Node Node from which a new node was discovered
401 * @param[in] CurrentNodeModule The current node's module id in it's processor.
402 * @param[in] PackageLink The package level link from Node to NewNode.
403 * @param[in] NewNode The new node's id
404 * @param[in] HardwareSocket If we use the hardware method (preferred), this is the socket of new node.
405 * @param[in] Module The new node's module id in it's processor.
406 * @param[in] State our State
408 typedef VOID F_SET_NODE_TO_SOCKET_MAP (
410 IN UINT8 CurrentNodeModule,
411 IN UINT8 PackageLink,
413 IN UINT8 HardwareSocket,
417 /// Reference to a method.
418 typedef F_SET_NODE_TO_SOCKET_MAP *PF_SET_NODE_TO_SOCKET_MAP;
421 * Get a new, empty Hop Count Table, to make one for the installed topology.
423 * @HtInterfaceInstances.
425 * @param[in,out] State Keep our buffer handle.
428 typedef VOID F_NEW_HOP_COUNT_TABLE (
429 IN OUT STATE_DATA *State
431 /// Reference to a method.
432 typedef F_NEW_HOP_COUNT_TABLE *PF_NEW_HOP_COUNT_TABLE;
435 * Get the minimum Northbridge frequency for the system.
437 * @HtInterfaceInstances.
439 * Invoke the CPU component power mgt interface.
441 * @param[in] PlatformConfig Platform profile/build option config structure.
442 * @param[in] StdHeader Config for library and services.
444 * @return Frequency in MHz.
447 typedef UINT32 F_GET_MIN_NB_CORE_FREQ (
448 IN PLATFORM_CONFIGURATION *PlatformConfig,
449 IN AMD_CONFIG_PARAMS *StdHeader
451 /// Reference to a Method.
452 typedef F_GET_MIN_NB_CORE_FREQ *PF_GET_MIN_NB_CORE_FREQ;
455 * The HT Interface, feature code uses these methods to get interface parameters.
457 struct _HT_INTERFACE { // See Forward Declaration in HtFeates.h
458 PF_GET_CPU_2_CPU_PCB_LIMITS GetCpu2CpuPcbLimits; /**< Method: Get link limits for coherent links. */
459 PF_GET_SKIP_REGANG GetSkipRegang; /**< Method: Skip reganging for coherent links. */
460 PF_NEW_HOP_COUNT_TABLE NewHopCountTable; /**< Method: Get a new hop count table. */
461 PF_GET_OVERRIDE_BUS_NUMBERS GetOverrideBusNumbers; /**< Method: Control Bus number assignment. */
462 PF_GET_MANUAL_BUID_SWAP_LIST GetManualBuidSwapList; /**< Method: Assign device IDs. */
463 PF_GET_DEVICE_CAP_OVERRIDE GetDeviceCapOverride; /**< Method: Override Device capabilities. */
464 PF_GET_IO_PCB_LIMITS GetIoPcbLimits; /**< Method: Get link limits for noncoherent links. */
465 PF_GET_SOCKET_FROM_MAP GetSocketFromMap; /**< Method: Get the Socket for a node id. */
466 PF_GET_IGNORE_LINK GetIgnoreLink; /**< Method: Ignore a link. */
467 PF_POST_MAP_TO_AP PostMapToAp; /**< Method: Post Socket and other info to AP cores. */
468 PF_NEW_NODE_AND_SOCKET_TABLES NewNodeAndSocketTables; /**< Method: Get new socket and node maps. */
469 PF_CLEAN_MAPS_AFTER_ERROR CleanMapsAfterError; /**< Method: Clean up maps for forced 1P on error fall back. */
470 PF_SET_NODE_TO_SOCKET_MAP SetNodeToSocketMap; /**< Method: Associate a node id with a socket. */
471 PF_GET_MIN_NB_CORE_FREQ GetMinNbCoreFreq; /**< Method: Get the minimum northbridge frequency */
474 /*----------------------------------------------------------------------------
475 * Prototypes to Interface from Feature Code
477 *----------------------------------------------------------------------------
481 * A constructor for the internal Ht Interface.
486 OUT HT_INTERFACE *HtInterface,
487 IN AMD_CONFIG_PARAMS *StdHeader
490 #endif /* _HT_INTERFACE_H_ */