blob: 9d663e81525a948ed28ca1d0012e88099607c332 [file] [log] [blame]
Frank Vibrans2b4c8312011-02-14 18:30:54 +00001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * HT NorthBridge header
6 *
7 * Defines the interface to the HT NorthBridge module for use by other internal
8 * HT modules. This is not a wrapper or external interface, "public" in the
9 * comments below is used in the class definition style and refers to HT client
10 * modules only ("private" being for use only by the HT NB module itself).
11 *
12 * It is expected that there will be multiple northbridge implementation files all
13 * conforming to this common interface.
14 *
15 * @xrefitem bom "File Content Label" "Release Content"
16 * @e project: AGESA
17 * @e sub-project: HyperTransport
18 * @e \$Revision: 39162 $ @e \$Date: 2010-10-07 22:41:37 +0800 (Thu, 07 Oct 2010) $
19 *
20 */
21/*
22 *****************************************************************************
23 *
24 * Copyright (c) 2011, Advanced Micro Devices, Inc.
25 * All rights reserved.
Edward O'Callaghane963b382014-07-06 19:27:14 +100026 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000027 * 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.
Edward O'Callaghane963b382014-07-06 19:27:14 +100034 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
35 * its contributors may be used to endorse or promote products derived
Frank Vibrans2b4c8312011-02-14 18:30:54 +000036 * from this software without specific prior written permission.
Edward O'Callaghane963b382014-07-06 19:27:14 +100037 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000038 * 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.
Edward O'Callaghane963b382014-07-06 19:27:14 +100048 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000049 * ***************************************************************************
50 *
51 */
52
53#ifndef _HT_NB_H_
54#define _HT_NB_H_
55
56/**
57 * @page htimplnb HT Northbridge Implementation Guide
58 *
59 * The HT Northbridge provides access to the Northbridge hardware, in a manner that
60 * isolates calling code from knowledge about the hardware implementation or which
61 * features are supported in the current build. This is the mechanism in the HT code for
62 * supporting new Family or Model northbridges, as well as the means for supporting
63 * multiple northbridges in a single build or mixed revision northbridge sets.
64 *
65 * @par Adding a Method to the Northbridge
66 *
67 * To add a new method to the Northbridge, follow these steps.
68 * <ul>
69 * <li> Create a typedef for the Method with the correct parameters and return type.
70 *
71 * <ul>
72 * <li> Name the method typedef (F_METHOD_NAME)(), where METHOD_NAME is the same
73 * name as the method table item, but with "_"'s and UPPERCASE, rather than mixed case.
74 * @n <tt> typedef VOID (F_METHOD_NAME)(); </tt> @n
75 *
76 * <li> Make a reference type for references to a method implementation:
77 * @n <tt> /// Reference to a Method </tt>
78 * @n <tt> typedef F_METHOD_NAME *PF_METHOD_NAME </tt> @n
79 * </ul>
80 *
81 * <li> One of the parameters to @b all northbridge Methods is @b required to be a
82 * reference to its current northbridge object. By convention, this is the
83 * last parameter.
84 *
85 * <li> Provide a standard doxygen function preamble for the Method typedef. Begin the
86 * detailed description by providing a reference to the method instances page by including
87 * the lines below:
88 * @code
89 * *
90 * * @HtNbInstances
91 * *
92 * @endcode
93 * @note It is important to provide documentation for the method type, because the method may not
94 * have an implementation in any families supported by the current package. @n
95 *
96 * <li> Add to the NORTHBRIDGE struct an item for the Method:
97 * @n <tt> PF_METHOD_NAME MethodName; ///< Method: description. </tt> @n
98 * </ul>
99 *
100 * @par Implementing an Instance of a Northbridge method.
101 *
102 * To implement an instance of a method for a specific feature follow these steps.
103 *
104 * - In appropriate files, implement the method with the return type and parameters
105 * matching the Method typedef.
106 * - If the Method implementation is common to all families, use the northbridge file
107 * for the function area, for example, add a new coherent initialization support method to the
108 * coherent northbridge file.
109 * - If the Method implementation is unique to each supported northbridge, use the
110 * family specific file for that function area (create it, if it doesn't already exist).
111 * The family specific files have the same name as the common one suffixed with "FamNN",
112 * or "FamNNRevX" if for a model or revision.
113 *
114 * - Name the function MethodName(). If Family specific, FamNNMethodName().
115 *
116 * - Create a doxygen function preamble for the method instance. Begin the detailed description with
117 * an Implements command to reference the method type and add this instance to the Method Instances page.
118 * @code
119 * *
120 * * @HtNbMethod{::F_METHOD_NAME}.
121 * *
122 * @endcode
123 *
124 * - To access other northbridge routines or data as part of the method implementation,
125 * the function must use Nb->OtherMethod(). Do not directly access other northbridge
126 * routines, because in the table there may be overrides or this routine may be shared by
127 * multiple configurations.
128 *
129 * - Add the instance, or the correct family specific instance, to the NORTHBRIDGE instances
130 * used by the northbridge constructor.
131 *
132 * - If a northbridge does not need an instance of the method use one of the CommonReturns from
133 * CommonReturns.h with the same return type.
134 *
135 * @par Making common Northbridge Methods.
136 *
137 * In some cases, Northbridge methods can easily have a common implementation because the hardware
138 * is very compatible or is even standard. In other cases, where processor family northbridges
139 * differ in their implementation, it may be possible to provide a single, common method
140 * implementation. This can be accomplished by adding Northbridge data members.
141 *
142 * For example, a bit position or bit field mask can be used to accommodate different bit placement or size.
143 * Another example, a small table can be used to translate index values from a common set
144 * to specific sets.
145 *
146 * The Northbridge Method Instance must use its NORTHBRIDGE reference parameter to access
147 * private data members.
148 *
149 * @par Invoking HT Northbridge Methods.
150 *
151 * Each unique northbridge is constructed based on matching the current northbridge.
152 * @n @code
153 * NORTHBRIDGE Nb;
154 * // Create the BSP's northbridge.
155 * NewNorthBridge (0, State, &Nb);
156 * State->Nb = &Nb;
157 * @endcode
158 *
159 * The following example shows how to invoke a Northbridge method.
160 * @n @code
161 * State->Nb->MethodName (State->Nb);
162 * @endcode
163 *
164 */
165
166/*----------------------------------------------------------------------------
167 * Mixed (DEFINITIONS AND MACROS / TYPEDEFS, STRUCTURES, ENUMS)
168 *
169 *----------------------------------------------------------------------------
170 */
171
172/*-----------------------------------------------------------------------------
173 * DEFINITIONS AND MACROS
174 *
175 *-----------------------------------------------------------------------------
176 */
177
178/** Use a macro to convert a Node number to a PCI device. If some future port of
179 * this code needs to, this can easily be replaced by the function declaration:
180 * UINT8 makePCIDeviceFromNode(UINT8 Node);
181 */
182#define MakePciDeviceFromNode(Node) \
183 ((UINT8) (24 + (Node)))
184
185/** Use a macro to convert a Node number to a PCI bus. If some future port of
186 * this code needs to, this can easily be replaced by the function declaration:
187 * UINT8 MakePciBusFromNode(UINT8 Node);
188 */
189#define MakePciBusFromNode(Node) \
190 ((UINT8) (0))
191
192/** Use a macro to convert a Node number to a PCI Segment. If some future port of
193 * this code needs to, this can easily be replaced by the function declaration:
194 * UINT8 MakePciSegmentFromNode(UINT8 Node);
195 */
196#define MakePciSegmentFromNode(Node) \
197 ((UINT8) (0))
198
199/*----------------------------------------------------------------------------
200 * TYPEDEFS, STRUCTURES, ENUMS
201 *
202 *----------------------------------------------------------------------------
203 */
204/**
205 * Status for iterating through internal (if supported) and external links.
206 */
207typedef enum {
208 LinkIteratorEnd, ///< This is the end of all links, no valid link.
209 LinkIteratorExternal, ///< The next link (the one we got on this call) is an external link.
210 LinkIteratorInternal, ///< The next link (the one we got on this call) is an internal link.
211 LinkIteratorMax ///< For bounds checking and limit only.
212} LINK_ITERATOR_STATUS;
213
214#define LINK_ITERATOR_BEGIN 0xFF
215
216/**
217 * Write a temporary Route.
218 *
219 * @HtNbInstances
220 *
221 * @param[in] Node The node on which to set a temporary route
222 * @param[in] Target A route to this node, which route table entry is to be set
223 * @param[in] Link The link which routes to the target node
224 * @param[in] Nb This northbridge
225 */
226typedef VOID F_WRITE_ROUTING_TABLE (
227 IN UINT8 Node,
228 IN UINT8 Target,
229 IN UINT8 Link,
230 IN NORTHBRIDGE *Nb
231 );
232/// Reference to a method.
233typedef F_WRITE_ROUTING_TABLE *PF_WRITE_ROUTING_TABLE;
234
235/**
236 * Modifies the NodeID register on the target Node
237 *
238 * @HtNbInstances
239 *
240 * @param[in] Node the Node that will have its NodeID altered.
241 * @param[in] NodeID the new value for NodeID
242 * @param[in] Nb this northbridge
243 */
244typedef VOID F_WRITE_NODEID (
245 IN UINT8 Node,
246 IN UINT8 NodeID,
247 IN NORTHBRIDGE *Nb
248 );
249/// Reference to a method.
250typedef F_WRITE_NODEID *PF_WRITE_NODEID;
251
252/**
253 * Read the Default Link
254 *
255 * @HtNbInstances
256 *
257 * @param[in] Node the Node that will have its NodeID altered.
258 * @param[in] Nb this northbridge
259 *
260 * @return The HyperTransport Link where the request to
261 * read the default Link came from. Since this code is running on the BSP,
262 * this should be the Link pointing back towards the BSP.
263 */
264typedef UINT8 F_READ_DEFAULT_LINK (
265 IN UINT8 Node,
266 IN NORTHBRIDGE *Nb
267 );
268/// Reference to a method.
269typedef F_READ_DEFAULT_LINK *PF_READ_DEFAULT_LINK;
270
271/**
272 * Turns routing tables on for a given Node
273 *
274 * @HtNbInstances
275 *
276 * @param[in] Node the Node that will have it's routing tables enabled
277 * @param[in] Nb this northbridge
278 */
279typedef VOID F_ENABLE_ROUTING_TABLES (
280 IN UINT8 Node,
281 IN NORTHBRIDGE *Nb
282 );
283/// Reference to a method.
284typedef F_ENABLE_ROUTING_TABLES *PF_ENABLE_ROUTING_TABLES;
285
286/**
287 * Turns routing tables off for a given Node
288 *
289 * @HtNbInstances
290 *
291 * @param[in] Node the Node that will have it's routing tables disabled
292 * @param[in] Nb this northbridge
293 */
294typedef VOID F_DISABLE_ROUTING_TABLES (
295 IN UINT8 Node,
296 IN NORTHBRIDGE *Nb
297 );
298/// Reference to a method.
299typedef F_DISABLE_ROUTING_TABLES *PF_DISABLE_ROUTING_TABLES;
300
301/**
302 * Verify that the Link is coherent, connected, and ready
303 *
304 * @HtNbInstances
305 *
306 * @param[in] Node the Node that will be examined
307 * @param[in] Link the Link on that Node to examine
308 * @param[in] Nb this northbridge
309 *
310 * @retval TRUE The Link is coherent
311 * @retval FALSE The Link has some other status
312*/
313typedef BOOLEAN F_VERIFY_LINK_IS_COHERENT (
314 IN UINT8 Node,
315 IN UINT8 Link,
316 IN NORTHBRIDGE *Nb
317 );
318/// Reference to a method.
319typedef F_VERIFY_LINK_IS_COHERENT *PF_VERIFY_LINK_IS_COHERENT;
320
321/**
322 * Read the token stored in the scratchpad register field.
323 *
324 * @HtNbInstances
325 *
326 * @param[in] Node the Node that will be examined
327 * @param[in] Nb this northbridge
328 *
329 * @return the Token read from the Node
330 */
331typedef UINT8 F_READ_TOKEN (
332 IN UINT8 Node,
333 IN NORTHBRIDGE *Nb
334 );
335/// Reference to a method.
336typedef F_READ_TOKEN *PF_READ_TOKEN;
337
338/**
339 * Write the token stored in the scratchpad register
340 *
341 * @HtNbInstances
342 *
343 * @param[in] Node the Node that marked with token
344 * @param[in] Value the token Value
345 * @param[in] Nb this northbridge
346 */
347typedef VOID F_WRITE_TOKEN (
348 IN UINT8 Node,
349 IN UINT8 Value,
350 IN NORTHBRIDGE *Nb
351 );
352/// Reference to a method.
353typedef F_WRITE_TOKEN *PF_WRITE_TOKEN;
354
355/**
356 * Full Routing Table Register initialization
357 *
358 * @HtNbInstances
359 *
360 * @param[in] Node the Node that will be examined
361 * @param[in] Target the Target Node for these routes
362 * @param[in] ReqLink the Link for requests to Target
363 * @param[in] RspLink the Link for responses to Target
364 * @param[in] BroadcastLinks the broadcast Links
365 * @param[in] Nb this northbridge
366 */
367typedef VOID F_WRITE_FULL_ROUTING_TABLE (
368 IN UINT8 Node,
369 IN UINT8 Target,
370 IN UINT8 ReqLink,
371 IN UINT8 RspLink,
372 IN UINT32 BroadcastLinks,
373 IN NORTHBRIDGE *Nb
374 );
375/// Reference to a method.
376typedef F_WRITE_FULL_ROUTING_TABLE *PF_WRITE_FULL_ROUTING_TABLE;
377
378/**
379 * Determine whether a Node is compatible with the discovered configuration so far.
380 *
381 * @HtNbInstances
382 *
383 * @param[in] Node the Node
384 * @param[in] Nb this northbridge
385 *
386 * @retval TRUE the node is not compatible
387 * @retval FALSE the node is compatible
388 */
389typedef BOOLEAN F_IS_ILLEGAL_TYPE_MIX (
390 IN UINT8 Node,
391 IN NORTHBRIDGE *Nb
392 );
393/// Reference to a method.
394typedef F_IS_ILLEGAL_TYPE_MIX *PF_IS_ILLEGAL_TYPE_MIX;
395
396/**
397 * Return whether the current configuration exceeds the capability
398 * of the nodes detected.
399 *
400 * @HtNbInstances
401 *
402 * @param[in] Node the Node
403 * @param[in] State sysMpCap (updated) and NodesDiscovered
404 * @param[in] Nb this northbridge
405 *
406 * @retval TRUE system is not capable of current config.
407 * @retval FALSE system is capable of current config.
408 */
409typedef BOOLEAN F_IS_EXCEEDED_CAPABLE (
410 IN UINT8 Node,
411 IN STATE_DATA *State,
412 IN NORTHBRIDGE *Nb
413 );
414/// Reference to a method.
415typedef F_IS_EXCEEDED_CAPABLE *PF_IS_EXCEEDED_CAPABLE;
416
417/**
418 * Stop a link, so that it is isolated from a connected device.
419 *
420 * @HtNbInstances
421 *
422 * Use is for fatal incompatible configurations.
423 * While XMIT and RCV off are HT standard, the use of these bits
424 * is generally family specific.
425 *
426 * @param[in] Node the node to stop a link on.
427 * @param[in] Link the link to stop.
428 * @param[in] State access to special routine for writing link control register
429 * @param[in] Nb this northbridge.
430 */
431typedef VOID F_STOP_LINK (
432 IN UINT8 Node,
433 IN UINT8 Link,
434 IN STATE_DATA *State,
435 IN NORTHBRIDGE *Nb
436 );
437/// Reference to a method.
438typedef F_STOP_LINK *PF_STOP_LINK;
439
440/**
441 * Fix (hopefully) exceptional conditions.
442 *
443 * @HtNbInstances
444 *
445 * This routine is expected to be unimplemented for most families.
446 * Some configurations may require that links be processed specially to prevent
447 * serious problems, like hangs. Check for that condition in this routine,
448 * handle the link both for hardware and for adding to port list, if appropriate.
449 * If this routine adds the link to port list or the link should not be added, return TRUE.
450 *
451 * @param[in] Node The Node which has this link
452 * @param[in] Link The link to check for special conditions.
453 * @param[in] State our global state.
454 * @param[in] Nb this northbridge.
455 *
456 * @retval TRUE This link received special handling.
457 * @retval FALSE This link was not handled specially, handle it normally.
458 *
459 */
460typedef BOOLEAN F_HANDLE_SPECIAL_LINK_CASE (
461 IN UINT8 Node,
462 IN UINT8 Link,
463 IN STATE_DATA *State,
464 IN NORTHBRIDGE *Nb
465 );
466/// Reference to a method.
467typedef F_HANDLE_SPECIAL_LINK_CASE *PF_HANDLE_SPECIAL_LINK_CASE;
468
469/**
470 * Fix (hopefully) exceptional conditions.
471 *
472 * @HtNbInstances
473 *
474 * This routine is expected to be unimplemented for most families.
475 * Some configurations may require that nodes be processed specially to prevent
476 * serious problems, like hangs. Check for that condition in this routine,
477 * handle the node both for hardware and for adding to port list, if appropriate.
478 * If this routine adds the node to port list or the node should not be added, return TRUE.
479 *
480 * @param[in] Node The Node which need to be checked.
481 * @param[in] Link The link to check for special conditions.
482 * @param[in] State our global state.
483 * @param[in] Nb this northbridge.
484 *
485 * @retval TRUE This node received special handling.
486 * @retval FALSE This node was not handled specially, handle it normally.
487 *
488 */
489typedef BOOLEAN F_HANDLE_SPECIAL_NODE_CASE (
490 IN UINT8 Node,
491 IN UINT8 Link,
492 IN STATE_DATA *State,
493 IN NORTHBRIDGE *Nb
494 );
495/// Reference to a method.
496typedef F_HANDLE_SPECIAL_NODE_CASE *PF_HANDLE_SPECIAL_NODE_CASE;
497
498/**
499 * Get Info about Module Type of this northbridge
500 *
501 * @HtNbInstances
502 *
503 * @param[in] Node the Node
504 * @param[out] ModuleType 0 for Single, 1 for Multi
505 * @param[out] Module The module number of this node (0 if Single)
506 * @param[in] Nb this northbridge
507 *
508 */
509typedef VOID F_GET_MODULE_INFO (
510 IN UINT8 Node,
511 OUT UINT8 *ModuleType,
512 OUT UINT8 *Module,
513 IN NORTHBRIDGE *Nb
514 );
515/// Reference to a method.
516typedef F_GET_MODULE_INFO *PF_GET_MODULE_INFO;
517
518/**
519 * Post info to AP cores via a mailbox.
520 *
521 * @HtNbInstances
522 *
523 * @param[in] Node the Node
524 * @param[in] ApMailInfo The info to post
525 * @param[in] Nb this northbridge
526 *
527 */
528typedef VOID F_POST_MAILBOX (
529 IN UINT8 Node,
530 IN AP_MAILBOXES ApMailInfo,
531 IN NORTHBRIDGE *Nb
532 );
533/// Reference to a method.
534typedef F_POST_MAILBOX *PF_POST_MAILBOX;
535
536/**
537 * Retrieve info from a node's AP mailbox.
538 *
539 * @HtNbInstances
540 *
541 * @param[in] Node the Node
542 * @param[in] ApMailInfo The info to post
543 * @param[in] Nb this northbridge
544 *
545 */
546typedef AP_MAIL_INFO F_RETRIEVE_MAILBOX (
547 IN UINT8 Node,
548 IN NORTHBRIDGE *Nb
549 );
550/// Reference to a method.
551typedef F_RETRIEVE_MAILBOX *PF_RETRIEVE_MAILBOX;
552
553/**
554 * Implement the hardware method of doing Socket Naming, by accessing this northbridge's Socket Id register.
555 *
556 * @HtNbInstances
557 *
558 * @param[in] Node The node for which we want the socket id.
559 * @param[in] TempNode The temporary node id route where the node can be accessed.
560 * @param[in] Nb Our Northbridge.
561 *
562 * @return The Socket Id
563 */
564typedef UINT8 F_GET_SOCKET (
565 IN UINT8 Node,
566 IN UINT8 TempNode,
567 IN NORTHBRIDGE *Nb
568 );
569
570/// Reference to a method.
571typedef F_GET_SOCKET *PF_GET_SOCKET;
572
573/**
574 * Get the enabled Compute Units.
575 *
576 * Processors which don't support compute units return zero.
577 *
578 * @HtNbInstances
579 *
580 * @param[in] Node The node for which we want the socket id.
581 * @param[in] Nb Our Northbridge.
582 *
583 * @return The Socket Id
584 */
585typedef UINT8 F_GET_ENABLED_COMPUTE_UNITS (
586 IN UINT8 Node,
587 IN NORTHBRIDGE *Nb
588 );
589
590/// Reference to a method.
591typedef F_GET_ENABLED_COMPUTE_UNITS *PF_GET_ENABLED_COMPUTE_UNITS;
592
593/**
594 * Get the dual core Compute Units.
595 *
596 * Processors which don't support compute units return zero.
597 *
598 * @HtNbInstances
599 *
600 * @param[in] Node The node for which we want the socket id.
601 * @param[in] Nb Our Northbridge.
602 *
603 * @return The Socket Id
604 */
605typedef UINT8 F_GET_DUALCORE_COMPUTE_UNITS (
606 IN UINT8 Node,
607 IN NORTHBRIDGE *Nb
608 );
609
610/// Reference to a method.
611typedef F_GET_DUALCORE_COMPUTE_UNITS *PF_GET_DUALCORE_COMPUTE_UNITS;
612
613/**
614 * Return the Link to the Southbridge
615 *
616 * @HtNbInstances
617 *
618 * @param[in] Nb this northbridge
619 *
620 * @return the Link to the southbridge
621 */
622typedef UINT8 F_READ_SB_LINK (
623 IN NORTHBRIDGE *Nb
624 );
625/// Reference to a method.
626typedef F_READ_SB_LINK *PF_READ_SB_LINK;
627
628/**
629 * Verify that the Link is non-coherent, connected, and ready
630 *
631 * @HtNbInstances
632 *
633 * @param[in] Node the Node that will be examined
634 * @param[in] Link the Link on that Node to examine
635 * @param[in] Nb this northbridge
636 *
637 * @retval TRUE The Link is non-coherent.
638 * @retval FALSE The Link has some other status
639 */
640typedef BOOLEAN F_VERIFY_LINK_IS_NON_COHERENT (
641 IN UINT8 Node,
642 IN UINT8 Link,
643 IN NORTHBRIDGE *Nb
644 );
645/// Reference to a method.
646typedef F_VERIFY_LINK_IS_NON_COHERENT *PF_VERIFY_LINK_IS_NON_COHERENT;
647
648/**
649 * Enable config access to a non-coherent chain for the given bus range.
650 *
651 * @HtNbInstances
652 *
653 * @param[in] ConfigMapIndex the map entry to set
654 * @param[in] SecBus The secondary bus number to use
655 * @param[in] SubBus The subordinate bus number to use
656 * @param[in] TargetNode The Node that shall be the recipient of the traffic
657 * @param[in] TargetLink The Link that shall be the recipient of the traffic
658 * @param[in] State our global state
659 * @param[in] Nb this northbridge
660 */
661typedef VOID F_SET_CONFIG_ADDR_MAP (
662 IN UINT8 ConfigMapIndex,
663 IN UINT8 SecBus,
664 IN UINT8 SubBus,
665 IN UINT8 TargetNode,
666 IN UINT8 TargetLink,
667 IN STATE_DATA *State,
668 IN NORTHBRIDGE *Nb
669 );
670/// Reference to a method.
671typedef F_SET_CONFIG_ADDR_MAP *PF_SET_CONFIG_ADDR_MAP;
672
673/**
674 * Northbridge specific Frequency limit.
675 *
676 * @HtNbInstances
677 *
678 * Return a mask that eliminates HT frequencies that cannot be used due to a slow
679 * northbridge frequency.
680 *
681 * @param[in] Node Result could (later) be for a specific Node
682 * @param[in] Interface Access to non-HT support functions.
683 * @param[in] PlatformConfig Platform profile/build option config structure.
684 * @param[in] Nb this northbridge
685 *
686 * @return Frequency mask
687 */
688typedef UINT32 F_NORTH_BRIDGE_FREQ_MASK (
689 IN UINT8 Node,
690 IN HT_INTERFACE *Interface,
691 IN PLATFORM_CONFIGURATION *PlatformConfig,
692 IN NORTHBRIDGE *Nb
693 );
694/// Reference to a method.
695typedef F_NORTH_BRIDGE_FREQ_MASK *PF_NORTH_BRIDGE_FREQ_MASK;
696
697/**
698 * Get Link features into system data structure.
699 *
700 * @HtNbInstances
701 *
702 * @param[in,out] ThisPort The PortList structure entry for this link's port
703 * @param[in] Interface Access to non-HT support functions.
704 * @param[in] PlatformConfig Platform profile/build option config structure.
705 * @param[in] Nb this northbridge
706 */
707typedef VOID F_GATHER_LINK_FEATURES (
708 IN OUT PORT_DESCRIPTOR *ThisPort,
709 IN HT_INTERFACE *Interface,
710 IN PLATFORM_CONFIGURATION *PlatformConfig,
711 IN NORTHBRIDGE *Nb
712 );
713/// Reference to a method.
714typedef F_GATHER_LINK_FEATURES *PF_GATHER_LINK_FEATURES;
715
716/**
717 * Change the hardware state for all Links according to the now optimized data in the
718 * port list data structure.
719 *
720 * @HtNbInstances
721 *
722 * @param[in] Node the node on which to regang a link
723 * @param[in] Link the sublink 0 of the sublink pair to regang
724 * @param[in] Nb this northbridge
725 */
726typedef VOID F_SET_LINK_REGANG (
727 IN UINT8 Node,
728 IN UINT8 Link,
729 IN NORTHBRIDGE *Nb
730 );
731/// Reference to a method.
732typedef F_SET_LINK_REGANG *PF_SET_LINK_REGANG;
733
734/**
735 * Change the hardware state for all Links according to the now optimized data in the
736 * port list data structure.
737 *
738 * @HtNbInstances
739 *
740 * @param[in] Node the node on which to set frequency for a link
741 * @param[in] Link the link to set frequency
742 * @param[in] Frequency the frequency to set
743 * @param[in] Nb this northbridge
744 */
745typedef VOID F_SET_LINK_FREQUENCY (
746 IN UINT8 Node,
747 IN UINT8 Link,
748 IN UINT8 Frequency,
749 IN NORTHBRIDGE *Nb
750 );
751/// Reference to a method.
752typedef F_SET_LINK_FREQUENCY *PF_SET_LINK_FREQUENCY;
753
754/**
755 * Set the link's Unit Id Clumping enable.
756 *
757 * @HtNbInstances
758 *
759 * This applies to the host root of a non-coherent chain.
760 *
761 * @param[in] Node the node on which to set frequency for a link
762 * @param[in] Link the link to set frequency
763 * @param[in] ClumpingEnables the unit id clumping enables to set
764 * @param[in] Nb this northbridge
765 */
766typedef VOID F_SET_LINK_UNITID_CLUMPING (
767 IN UINT8 Node,
768 IN UINT8 Link,
769 IN UINT32 ClumpingEnables,
770 IN NORTHBRIDGE *Nb
771 );
772/// Reference to a method.
773typedef F_SET_LINK_UNITID_CLUMPING *PF_SET_LINK_UNITID_CLUMPING;
774
775/**
776 * Set the traffic distribution register for the Links provided.
777 *
778 * @HtNbInstances
779 *
780 * @param[in] Links01 coherent Links from Node 0 to 1
781 * @param[in] Links10 coherent Links from Node 1 to 0
782 * @param[in] Nb this northbridge
783 */
784typedef VOID F_WRITE_TRAFFIC_DISTRIBUTION (
785 IN UINT32 Links01,
786 IN UINT32 Links10,
787 IN NORTHBRIDGE *Nb
788 );
789/// Reference to a method.
790typedef F_WRITE_TRAFFIC_DISTRIBUTION *PF_WRITE_TRAFFIC_DISTRIBUTION;
791
792/**
793 * Write a link pair to the link pair distribution and fixups.
794 *
795 * @HtNbInstances
796 *
797 * @param[in] Node Set the pair on this node
798 * @param[in] ConnectedNode The Node to which this link pair directly connects.
799 * @param[in] Pair Using this pair set in the register
800 * @param[in] Asymmetric True if different widths
801 * @param[in] MasterLink Set this as the master link and in the route
802 * @param[in] AlternateLink Set this as the alternate link
803 * @param[in] Nb this northbridge
804 *
805 */
806typedef VOID F_WRITE_LINK_PAIR_DISTRIBUTION (
807 IN UINT8 Node,
808 IN UINT8 ConnectedNode,
809 IN UINT8 Pair,
810 IN BOOLEAN Asymmetric,
811 IN UINT8 MasterLink,
812 IN UINT8 AlternateLink,
813 IN NORTHBRIDGE *Nb
814 );
815/// Pointer to method WriteLinkPairDistribution
816typedef F_WRITE_LINK_PAIR_DISTRIBUTION *PF_WRITE_LINK_PAIR_DISTRIBUTION;
817
818/**
819 * Family specific tunings.
820 *
821 * @HtNbInstances
822 *
823 * Buffer tunings are inherently northbridge specific. Check for specific configs
824 * which require adjustments and apply any standard workarounds to this Node.
825 *
826 * @param[in] Node the Node to tune
827 * @param[in] State global state
828 * @param[in] Nb this northbridge
829 */
830typedef VOID F_BUFFER_OPTIMIZATIONS (
831 IN UINT8 Node,
832 IN STATE_DATA *State,
833 IN NORTHBRIDGE *Nb
834 );
835/// Reference to a method.
836typedef F_BUFFER_OPTIMIZATIONS *PF_BUFFER_OPTIMIZATIONS;
837
838/**
839 * Return the number of cores (1 based count) on Node.
840 *
841 * @HtNbInstances
842 *
843 * @param[in] Node the Node that will be examined
844 * @param[in] Nb this northbridge
845 *
846 * @return the number of cores
847 */
848typedef UINT8 F_GET_NUM_CORES_ON_NODE (
849 IN UINT8 Node,
850 IN NORTHBRIDGE *Nb
851 );
852/// Reference to a method.
853typedef F_GET_NUM_CORES_ON_NODE *PF_GET_NUM_CORES_ON_NODE;
854
855/**
856 * Write the total number of cores and Nodes to the Node
857 *
858 * @HtNbInstances
859 *
860 * @param[in] Node the Node that will be examined
861 * @param[in] TotalNodes the total number of Nodes
862 * @param[in] TotalCores the total number of cores
863 * @param[in] Nb this northbridge
864 */
865typedef VOID F_SET_TOTAL_NODES_AND_CORES (
866 IN UINT8 Node,
867 IN UINT8 TotalNodes,
868 IN UINT8 TotalCores,
869 IN NORTHBRIDGE *Nb
870 );
871/// Reference to a method.
872typedef F_SET_TOTAL_NODES_AND_CORES *PF_SET_TOTAL_NODES_AND_CORES;
873
874/**
875 * Get the Count of Nodes in the system.
876 *
877 * @HtNbInstances
878 *
879 * @param[in] Nb This Northbridge.
880 *
881 * @return The Count (1 based) of Nodes in the system.
882 */
883typedef UINT8 F_GET_NODE_COUNT (
884 IN NORTHBRIDGE *Nb
885 );
886
887/// Reference to a method.
888typedef F_GET_NODE_COUNT *PF_GET_NODE_COUNT;
889
890/**
891 * Limit coherent config accesses to cpus as indicated by Nodecnt.
892 *
893 * @HtNbInstances
894 *
895 * @param[in] Node the Node that will be examined
896 * @param[in] Nb this northbridge
897 */
898typedef VOID F_LIMIT_NODES (
899 IN UINT8 Node,
900 IN NORTHBRIDGE *Nb
901 );
902/// Reference to a method.
903typedef F_LIMIT_NODES *PF_LIMIT_NODES;
904
905/**
906 * Return the LinkFailed status AFTER an attempt is made to clear the bit.
907 *
908 * @HtNbInstances
909 *
910 * @param[in] Node the Node that will be examined
911 * @param[in] Link the Link on that Node to examine
912 * @param[in] State access to call back routine
913 * @param[in] Nb this northbridge
914 *
915 * @retval TRUE the Link is not connected or has hard error
916 * @retval FALSE the Link is connected
917 */
918typedef BOOLEAN F_READ_TRUE_LINK_FAIL_STATUS (
919 IN UINT8 Node,
920 IN UINT8 Link,
921 IN STATE_DATA *State,
922 IN NORTHBRIDGE *Nb
923 );
924/// Reference to a method.
925typedef F_READ_TRUE_LINK_FAIL_STATUS *PF_READ_TRUE_LINK_FAIL_STATUS;
926
927/**
928 * Get the next link for iterating over the links on a node in the correct order.
929 *
930 * @HtNbInstances
931 *
932 * @param[in] Node The node on which to iterate links.
933 * @param[in,out] Link IN: the current iteration context, OUT: the next link.
934 * @param[in] Nb This Northbridge, access to config pointer.
935 *
936 * @retval LinkIteratorEnd There is no next link (Link is back to BEGIN).
937 * @retval LinkIteratorExternal The next Link is an external link.
938 * @retval LinkIteratorInternal The next Link is an internal link.
939 */
940typedef LINK_ITERATOR_STATUS F_GET_NEXT_LINK (
941 IN UINT8 Node,
942 IN OUT UINT8 *Link,
943 IN NORTHBRIDGE *Nb
944 );
945/// Pointer to method GetNextLink
946typedef F_GET_NEXT_LINK *PF_GET_NEXT_LINK;
947
948/**
949 * Get the Package Link number, given the node and real link number.
950 *
951 * @HtNbInstances
952 *
953 * @param[in] Node the node which has this link
954 * @param[in] Link the link on that node
955 * @param[in] Nb this northbridge
956 *
957 * @return the Package Link
958 *
959 */
960typedef UINT8 F_GET_PACKAGE_LINK (
961 IN UINT8 Node,
962 IN UINT8 Link,
963 IN NORTHBRIDGE *Nb
964 );
965/// Reference to a method
966typedef F_GET_PACKAGE_LINK *PF_GET_PACKAGE_LINK;
967
968/**
969 * Return the HT Host capability base PCI config address for a Link.
970 *
971 * @HtNbInstances
972 *
973 * @param[in] Node the Node this Link is on
974 * @param[in] Link the Link
975 * @param[in] Nb this northbridge
976 *
977 * @return the pci config address
978 */
979typedef PCI_ADDR F_MAKE_LINK_BASE (
980 IN UINT8 Node,
981 IN UINT8 Link,
982 IN NORTHBRIDGE *Nb
983 );
984/// Reference to a method.
985typedef F_MAKE_LINK_BASE *PF_MAKE_LINK_BASE;
986
987/**
988 * Make a compatibility key.
989 *
990 * @HtNbInstances
991 *
992 * @param[in] Node the Node
993 * @param[in] Nb this northbridge
994 *
995 * @return the key
996 */
997typedef UINT64 F_MAKE_KEY (
998 IN UINT8 Node,
999 IN NORTHBRIDGE *Nb
1000 );
1001/// Reference to a method.
1002typedef F_MAKE_KEY *PF_MAKE_KEY;
1003
1004/**
1005 * The northbridge interface.
1006 *
1007 * Abstract the hardware implementation of the processor northbridge. Feature code does
1008 * not need to be tailored to specific families. Also, more than a single family (or
1009 * model in some cases) can be supported at once. Multiple family support can be for
1010 * mixed revisions or for incompatible revisions where only one is used at a time.
1011 *
1012 * The northbridge object contains both HT component public and northbridge private
1013 * members. These sets are grouped together. Within each group, members are grouped
1014 * according to the function area they support.
1015 *
1016 */
1017struct _NORTHBRIDGE { // See forward declaration in HtFeats.h
1018 /* Public data, clients of northbridge can access */
1019 UINT8 MaxLinks; /**< The maximum number of Links implemented by the northbridge */
1020
1021 /* Public Interfaces for northbridge clients, coherent init*/
1022 PF_WRITE_ROUTING_TABLE WriteRoutingTable; /**< Method: Write a Temporary route for discovery */
1023 PF_WRITE_NODEID WriteNodeID; /**< Method: Assign a Node ID*/
1024 PF_READ_DEFAULT_LINK ReadDefaultLink; /**< Method: Which link are we connected to on a remote node? */
1025 PF_ENABLE_ROUTING_TABLES EnableRoutingTables; /**< Method: Make the routing table active */
1026 PF_DISABLE_ROUTING_TABLES DisableRoutingTables; /**< Method: Put a node back in discoverable state (deflnk) */
1027 PF_VERIFY_LINK_IS_COHERENT VerifyLinkIsCoherent; /**< Method: is a link connected and coherent? */
1028 PF_READ_TOKEN ReadToken; /**< Method: Read the enumeration token from a node */
1029 PF_WRITE_TOKEN WriteToken; /**< Method: Assign an enumeration token to a node */
1030 PF_WRITE_FULL_ROUTING_TABLE WriteFullRoutingTable; /**< Method: Set a complete routing table entry on a node */
1031 PF_IS_ILLEGAL_TYPE_MIX IsIllegalTypeMix; /**< Method: Is this node compatible with the system */
1032 PF_IS_EXCEEDED_CAPABLE IsExceededCapable; /**< Method: Is this node capable of working in this system */
1033 PF_STOP_LINK StopLink; /**< Method: stop a link which must be unused */
1034 PF_HANDLE_SPECIAL_LINK_CASE HandleSpecialLinkCase; /**< Method: Fix broken configuration designs */
1035 PF_HANDLE_SPECIAL_NODE_CASE HandleSpecialNodeCase; /**< Method: Fix broken configuration designs */
1036
1037 /* Public Interfaces for northbridge clients, noncoherent init */
1038 PF_READ_SB_LINK ReadSouthbridgeLink; /**< Method: Which link goes to the southbridge? */
1039 PF_VERIFY_LINK_IS_NON_COHERENT VerifyLinkIsNonCoherent; /**< Method: is a link connected and non-coherent? */
1040 PF_SET_CONFIG_ADDR_MAP SetConfigAddrMap; /**< Method: Add a non-coherent chain to the PCI Config Bus Address Map */
1041
1042 /* Public Interfaces for northbridge clients, Optimization */
1043 PF_NORTH_BRIDGE_FREQ_MASK NorthBridgeFreqMask; /**< Method: Check for frequency limits other than HT */
1044 PF_GATHER_LINK_FEATURES GatherLinkFeatures; /**< Method: Get frequency and link features */
1045 PF_SET_LINK_REGANG SetLinkRegang; /**< Method: Set a Link to regang */
1046 PF_SET_LINK_FREQUENCY SetLinkFrequency; /**< Method: Set the link Frequency */
1047 PF_SET_LINK_UNITID_CLUMPING SetLinkUnitIdClumping; /**< Method: Set the link's Unit Id Clumping register */
1048
1049 /* Public Interfaces for northbridge clients, System and performance Tuning. */
1050 PF_WRITE_TRAFFIC_DISTRIBUTION WriteTrafficDistribution; /**< Method: traffic distribution setting */
1051 PF_WRITE_LINK_PAIR_DISTRIBUTION WriteLinkPairDistribution; /**< Method: Link Pair setting and fix up */
1052 PF_BUFFER_OPTIMIZATIONS BufferOptimizations; /**< Method: system tunings which can not be
1053 * done using register table */
1054
1055 /* Public Interfaces for northbridge clients, utility routines */
1056 PF_GET_NUM_CORES_ON_NODE GetNumCoresOnNode; /**< Method: Count cores */
1057 PF_SET_TOTAL_NODES_AND_CORES SetTotalNodesAndCores; /**< Method: Set Node and Core counts */
1058 PF_GET_NODE_COUNT GetNodeCount; /**< Method: Get the Count (1 based) of Nodes in the system. */
1059 PF_LIMIT_NODES LimitNodes; /**< Method: Set the Limit Config Space feature */
1060 PF_READ_TRUE_LINK_FAIL_STATUS ReadTrueLinkFailStatus; /**< Method: Get Fault status and connectivity of a link */
1061 PF_GET_NEXT_LINK GetNextLink; /**< Method: Iterate over a node's Internal, then External links. */
1062 PF_GET_PACKAGE_LINK GetPackageLink; /**< Method: the package link corresponding to a node's link */
1063 PF_MAKE_LINK_BASE MakeLinkBase; /**< Method: Provide the PCI Config Base register offset of a CPU link */
1064 PF_GET_MODULE_INFO GetModuleInfo; /**< Method: Get Module Type and internal Module number */
1065 PF_POST_MAILBOX PostMailbox; /**< Method: Post info to the mailbox register */
1066 PF_RETRIEVE_MAILBOX RetrieveMailbox; /**< Method: Retrieve info from the mailbox register */
1067 PF_GET_SOCKET GetSocket; /**< Method: Get a node's Socket, using the hardware naming method. */
1068 PF_GET_ENABLED_COMPUTE_UNITS GetEnabledComputeUnits; /**< Method: Get the Enabled Compute Units */
1069 PF_GET_DUALCORE_COMPUTE_UNITS GetDualCoreComputeUnits; /**< Method: Get which Compute Units have two cores. */
1070
1071 /* Private Data for northbridge implementation use only */
1072 UINT32 SelfRouteRequestMask; /**< Bit pattern for route request to self in routing table register */
1073 UINT32 SelfRouteResponseMask; /**< Bit pattern for route response to self in routing table register */
1074 UINT8 BroadcastSelfBit; /**< Bit offset of broadcast self bit in routing table register */
1075 BOOLEAN IsOrderBSPCoresByNode; /**< This processor orders Cores by Node id on the BSP, if TRUE. */
1076 BOOLEAN IsOrderCoresByModule; /**< Processors other than the BSP order Cores by Module, if TRUE. */
1077 UINT64 CompatibleKey; /**< Used for checking compatibility of northbridges in the system */
1078 PACKAGE_HTLINK_MAP PackageLinkMap; /**< Tell GetPackageLink() how to assign link names */
1079 UINT32 CoreFrequency; /**< Cache the northbridge core frequency, so repeated interface calls are avoided.
1080 * A value of zero, means no value yet. */
1081 IGNORE_LINK *DefaultIgnoreLinkList; /**< After processing the user interface ignore link, process this list. */
1082
1083 /* Private Interfaces for northbridge implementation. */
1084 PF_MAKE_KEY MakeKey; /**< Method: make the compatibility key for this node */
1085
1086 /** Config Pointer, opaque handle for passing to lib */
1087 VOID *ConfigHandle;
1088};
1089
1090/*----------------------------------------------------------------------------
1091 * FUNCTIONS PROTOTYPE
1092 *
1093 *----------------------------------------------------------------------------
1094 */
1095/**
1096 * Make a compatibility key.
1097 *
1098 */
1099UINT64
1100MakeKey (
1101 IN UINT8 Node,
1102 IN NORTHBRIDGE *Nb
1103 );
1104
1105VOID
1106NewNorthBridge (
1107 IN UINT8 Node,
1108 IN STATE_DATA *State,
1109 OUT NORTHBRIDGE *Nb
1110 );
1111
1112#endif /* _HT_NB_H_ */