AGESA F15: AMD family15 AGESA code
[coreboot.git] / src / vendorcode / amd / agesa / f15 / Proc / HT / htNotify.c
1 /* $NoKeywords:$ */
2 /**
3  * @file
4  *
5  * Code for detailed notification of events and status.
6  *
7  * Routines for logging and reporting details and summary status.
8  *
9  * @xrefitem bom "File Content Label" "Release Content"
10  * @e project:      AGESA
11  * @e sub-project:  HyperTransport
12  * @e \$Revision: 56279 $   @e \$Date: 2011-07-11 13:11:28 -0600 (Mon, 11 Jul 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
47 /*
48  *----------------------------------------------------------------------------
49  *                                MODULES USED
50  *
51  *----------------------------------------------------------------------------
52  */
53
54
55
56 #include "AGESA.h"
57 #include "amdlib.h"
58 #include "Ids.h"
59 #include "Topology.h"
60 #include "htFeat.h"
61 #include "htNotify.h"
62 #include "GeneralServices.h"
63 #include "Filecode.h"
64 CODE_GROUP (G1_PEICC)
65 RDATA_GROUP (G2_PEI)
66
67 #define FILECODE PROC_HT_HTNOTIFY_FILECODE
68 /*----------------------------------------------------------------------------
69  *                          DEFINITIONS AND MACROS
70  *
71  *----------------------------------------------------------------------------
72  */
73
74 /*----------------------------------------------------------------------------
75  *                            EXPORTED FUNCTIONS
76  *
77  *----------------------------------------------------------------------------
78  */
79
80 /*----------------------------------------------------------------------------------------*/
81 /**
82  * Log an event.
83  *
84  * Errors, events, faults, warnings, and useful information are provided by
85  * calling this routine as often as necessary, once for each notification.
86  * @sa AGESA.h for class, and event definitions.
87  * @sa htNotify.h for event data definitions.
88  *
89  * @param[in]     EvtClass      What level event is this
90  * @param[in]     Event         A unique ID of this event
91  * @param[in]     EventData     useful data associated with the event.
92  * @param[in]     State         the log area and remaining free space
93  */
94 VOID
95 STATIC
96 setEventNotify (
97   IN       AGESA_STATUS  EvtClass,
98   IN       UINT32        Event,
99   IN       CONST UINT8  *EventData,
100   IN       STATE_DATA   *State
101   )
102 {
103   UINT32 DataParam[NUMBER_OF_EVENT_DATA_PARAMS];
104
105   // Remember the highest event class notified, that becomes our return code.
106   if (State->MaxEventClass < EvtClass) {
107     State->MaxEventClass = EvtClass;
108   }
109
110   // Copy the event data to the log data
111   LibAmdMemCopy (
112     DataParam,
113     (VOID *)EventData,
114     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
115     State->ConfigHandle
116     );
117
118   // Log the event
119   PutEventLog (
120     EvtClass,
121     Event,
122     DataParam[0],
123     DataParam[1],
124     DataParam[2],
125     DataParam[3],
126     State->ConfigHandle
127     );
128 }
129
130 /*----------------------------------------------------------------------------------------*/
131 /**
132  * For event HT_EVENT_HW_SYNCFLOOD
133  *
134  * @param[in] Node      The node on which the fault is reported
135  * @param[in] Link      The link from that node
136  * @param[in] State     our State
137  *
138  */
139 VOID
140 NotifyAlertHwSyncFlood (
141   IN       UINT8        Node,
142   IN       UINT8        Link,
143   IN       STATE_DATA   *State
144   )
145 {
146   HT_EVENT_DATA_HW_SYNCFLOOD Evt;
147   // Zero out the event data
148   LibAmdMemFill (
149     &Evt,
150     0,
151     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
152     State->ConfigHandle
153     );
154
155   IDS_HDT_CONSOLE (HT_TRACE, "Sync Flood on Node %d Link %d.\n", Node, Link);
156   Evt.Node = Node;
157   Evt.Link = Link;
158   setEventNotify (AGESA_ALERT,
159                  HT_EVENT_HW_SYNCFLOOD,
160                  (UINT8 *)&Evt, State);
161 }
162
163 /*----------------------------------------------------------------------------------------*/
164 /**
165  * For event HT_EVENT_HW_HTCRC
166  *
167  * @param[in] Node      The node on which the error is reported
168  * @param[in] Link      The link from that node
169  * @param[in] LaneMask  The lanes which had CRC
170  * @param[in] State     our State
171  *
172  */
173 VOID
174 NotifyAlertHwHtCrc (
175   IN       UINT8      Node,
176   IN       UINT8      Link,
177   IN       UINT8      LaneMask,
178   IN       STATE_DATA *State
179   )
180 {
181   HT_EVENT_DATA_HW_HT_CRC Evt;
182   // Zero out the event data
183   LibAmdMemFill (
184     &Evt,
185     0,
186     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
187     State->ConfigHandle
188     );
189
190   IDS_HDT_CONSOLE (HT_TRACE, "CRC Error on Node %d Link %d lanes %x.\n", Node, Link, LaneMask);
191   Evt.Node = Node;
192   Evt.Link = Link;
193   Evt.LaneMask = LaneMask;
194   setEventNotify (AGESA_ALERT,
195                  HT_EVENT_HW_HTCRC,
196                  (UINT8 *)&Evt, State);
197 }
198
199 /*----------------------------------------------------------------------------------------*/
200 /**
201  * For event HT_EVENT_NCOH_BUS_MAX_EXCEED
202  *
203  * @param[in] Node      The node on which the chain is located
204  * @param[in] Link      The link from that node
205  * @param[in] Bus       The bus number to assign
206  * @param[in] State     our State
207  *
208  */
209 VOID
210 NotifyErrorNcohBusMaxExceed (
211   IN       UINT8      Node,
212   IN       UINT8      Link,
213   IN       UINT8      Bus,
214   IN       STATE_DATA *State
215   )
216 {
217   HT_EVENT_DATA_NCOH_BUS_MAX_EXCEED Evt;
218   // Zero out the event data
219   LibAmdMemFill (
220     &Evt,
221     0,
222     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
223     State->ConfigHandle
224     );
225
226   Evt.Node = Node;
227   Evt.Link = Link;
228   Evt.Bus = Bus;
229   setEventNotify (AGESA_ERROR,
230                  HT_EVENT_NCOH_BUS_MAX_EXCEED,
231                  (UINT8 *)&Evt, State);
232 }
233
234 /*----------------------------------------------------------------------------------------*/
235 /**
236  * For event HT_EVENT_NCOH_CFG_MAP_EXCEED
237  *
238  * @param[in] Node      The node on which the chain is located
239  * @param[in] Link      The link from that node
240  * @param[in] State     our State
241  *
242  */
243 VOID
244 NotifyErrorNcohCfgMapExceed (
245   IN       UINT8      Node,
246   IN       UINT8      Link,
247   IN       STATE_DATA *State
248   )
249 {
250   HT_EVENT_DATA_NCOH_CFG_MAP_EXCEED Evt;
251   // Zero out the event data
252   LibAmdMemFill (
253     &Evt,
254     0,
255     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
256     State->ConfigHandle
257     );
258
259   Evt.Node = Node;
260   Evt.Link = Link;
261   setEventNotify (AGESA_ERROR,
262                  HT_EVENT_NCOH_CFG_MAP_EXCEED,
263                  (UINT8 *)&Evt, State);
264 }
265
266 /*----------------------------------------------------------------------------------------*/
267 /**
268  * For event HT_EVENT_NCOH_BUID_EXCEED
269  *
270  * @param[in] Node      The node on which the chain is located
271  * @param[in] Link      The link from that node
272  * @param[in] Depth     Position on chain
273  * @param[in] Id        The Id which was attempted to assigned
274  * @param[in] Units     The number of units in this device
275  * @param[in] State     our State
276  *
277  */
278 VOID
279 NotifyErrorNcohBuidExceed (
280   IN       UINT8      Node,
281   IN       UINT8      Link,
282   IN       UINT8      Depth,
283   IN       UINT8      Id,
284   IN       UINT8      Units,
285   IN       STATE_DATA *State
286   )
287 {
288   HT_EVENT_DATA_NCOH_BUID_EXCEED Evt;
289   // Zero out the event data
290   LibAmdMemFill (
291     &Evt,
292     0,
293     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
294     State->ConfigHandle
295     );
296
297   Evt.Node = Node;
298   Evt.Link = Link;
299   Evt.Depth = Depth;
300   Evt.CurrentBuid = Id;
301   Evt.UnitCount = Units;
302   setEventNotify (AGESA_ERROR,
303                  HT_EVENT_NCOH_BUID_EXCEED,
304                  (UINT8 *)&Evt, State);
305 }
306
307 /*----------------------------------------------------------------------------------------*/
308 /**
309  * For event HT_EVENT_NCOH_DEVICE_FAILED
310  *
311  * @param[in] Node      The node on which the chain is located
312  * @param[in] Link      The link from that node
313  * @param[in] Depth     Position on chain
314  * @param[in] Id        The Id which was attempted to assigned
315  * @param[in] State     our State
316  *
317  */
318 VOID
319 NotifyErrorNcohDeviceFailed (
320   IN       UINT8      Node,
321   IN       UINT8      Link,
322   IN       UINT8      Depth,
323   IN       UINT8      Id,
324   IN       STATE_DATA *State
325   )
326 {
327   HT_EVENT_DATA_NCOH_DEVICE_FAILED Evt;
328   // Zero out the event data
329   LibAmdMemFill (
330     &Evt,
331     0,
332     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
333     State->ConfigHandle
334     );
335
336   Evt.Node = Node;
337   Evt.Link = Link;
338   Evt.Depth = Depth;
339   Evt.AttemptedBuid = Id;
340   setEventNotify (AGESA_ERROR,
341                  HT_EVENT_NCOH_DEVICE_FAILED,
342                  (UINT8 *)&Evt, State);
343 }
344
345 /*----------------------------------------------------------------------------------------*/
346 /**
347  * For event HT_EVENT_NCOH_AUTO_DEPTH
348  *
349  * @param[in] Node      The node on which the chain is located
350  * @param[in] Link      The link from that node
351  * @param[in] Depth     Position on chain
352  * @param[in] State     our State
353  *
354  */
355 VOID
356 NotifyInfoNcohAutoDepth (
357   IN       UINT8      Node,
358   IN       UINT8      Link,
359   IN       UINT8      Depth,
360   IN       STATE_DATA *State
361   )
362 {
363   HT_EVENT_DATA_NCOH_AUTO_DEPTH Evt;
364   // Zero out the event data
365   LibAmdMemFill (
366     &Evt,
367     0,
368     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
369     State->ConfigHandle
370     );
371
372   Evt.Node = Node;
373   Evt.Link = Link;
374   Evt.Depth = Depth;
375   setEventNotify (AGESA_SUCCESS,
376                  HT_EVENT_NCOH_AUTO_DEPTH,
377                  (UINT8 *)&Evt, State);
378 }
379
380 /*----------------------------------------------------------------------------------------*/
381 /**
382  * For event HT_EVENT_OPT_REQUIRED_CAP_RETRY
383  *
384  * @param[in] Node      The node on which the chain is located
385  * @param[in] Link      The link from that node
386  * @param[in] Depth     Position on chain
387  * @param[in] State     our State
388  *
389  */
390 VOID
391 NotifyWarningOptRequiredCapRetry (
392   IN       UINT8 Node,
393   IN       UINT8 Link,
394   IN       UINT8 Depth,
395   IN       STATE_DATA *State
396   )
397 {
398   HT_EVENT_DATA_OPT_REQUIRED_CAP Evt;
399   // Zero out the event data
400   LibAmdMemFill (
401     &Evt,
402     0,
403     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
404     State->ConfigHandle
405     );
406
407   Evt.Node = Node;
408   Evt.Link = Link;
409   Evt.Depth = Depth;
410   setEventNotify (AGESA_WARNING,
411                  HT_EVENT_OPT_REQUIRED_CAP_RETRY,
412                  (UINT8 *)&Evt, State);
413 }
414
415 /*----------------------------------------------------------------------------------------*/
416 /**
417  * For event HT_EVENT_OPT_REQUIRED_CAP_GEN3
418  *
419  * @param[in] Node      The node on which the chain is located
420  * @param[in] Link      The link from that node
421  * @param[in] Depth     Position on chain
422  * @param[in] State     our State
423  *
424  */
425 VOID
426 NotifyWarningOptRequiredCapGen3 (
427   IN       UINT8 Node,
428   IN       UINT8 Link,
429   IN       UINT8 Depth,
430   IN       STATE_DATA *State
431   )
432 {
433   HT_EVENT_DATA_OPT_REQUIRED_CAP Evt;
434   // Zero out the event data
435   LibAmdMemFill (
436     &Evt,
437     0,
438     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
439     State->ConfigHandle
440     );
441
442   Evt.Node = Node;
443   Evt.Link = Link;
444   Evt.Depth = Depth;
445   setEventNotify (AGESA_WARNING,
446                  HT_EVENT_OPT_REQUIRED_CAP_GEN3,
447                  (UINT8 *)&Evt, State);
448 }
449
450 /*----------------------------------------------------------------------------------------*/
451 /**
452  * For event HT_EVENT_OPT_UNUSED_LINKS
453  *
454  * @param[in]  NodeA    One of the nodes connected
455  * @param[in]  NodeB    The other connected node
456  * @param[in]  LinkA    its unusable link
457  * @param[in]  LinkB    its unusable link
458  * @param[in]  State    our State
459  *
460  */
461 VOID
462 NotifyWarningOptUnusedLinks (
463   IN       UINT32    NodeA,
464   IN       UINT32    LinkA,
465   IN       UINT32    NodeB,
466   IN       UINT32    LinkB,
467   IN       STATE_DATA *State
468   )
469 {
470   HT_EVENT_DATA_OPT_UNUSED_LINKS Evt;
471   // Zero out the event data
472   LibAmdMemFill (
473     &Evt,
474     0,
475     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
476     State->ConfigHandle
477     );
478
479   Evt.NodeA = NodeA;
480   Evt.LinkA = LinkA;
481   Evt.NodeB = NodeB;
482   Evt.LinkB = LinkB;
483   setEventNotify (AGESA_WARNING,
484                  HT_EVENT_OPT_UNUSED_LINKS,
485                  (UINT8 *)&Evt, State);
486 }
487
488
489 /*----------------------------------------------------------------------------------------*/
490 /**
491  * For event HT_EVENT_OPT_LINK_PAIR_EXCEED
492  *
493  * @param[in]  NodeA      One of the nodes connected
494  * @param[in]  NodeB      The other connected node
495  * @param[in]  MasterLink its unusable Masterlink
496  * @param[in]  AltLink    its unusable Alternate link
497  * @param[in]  State      our State
498  *
499  */
500 VOID
501 NotifyWarningOptLinkPairExceed (
502   IN       UINT32    NodeA,
503   IN       UINT32    NodeB,
504   IN       UINT32    MasterLink,
505   IN       UINT32    AltLink,
506   IN       STATE_DATA *State
507   )
508 {
509   HT_EVENT_DATA_OPT_LINK_PAIR_EXCEED Evt;
510   // Zero out the event data
511   LibAmdMemFill (
512     &Evt,
513     0,
514     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
515     State->ConfigHandle
516     );
517
518   Evt.NodeA = NodeA;
519   Evt.MasterLink = MasterLink;
520   Evt.NodeB = NodeB;
521   Evt.AltLink = AltLink;
522   setEventNotify (AGESA_WARNING,
523                  HT_EVENT_OPT_LINK_PAIR_EXCEED,
524                  (UINT8 *)&Evt, State);
525 }
526
527
528 /*----------------------------------------------------------------------------------------*/
529 /**
530  * For event HT_EVENT_COH_NO_TOPOLOGY
531  *
532  * @param[in] Nodes     The total number of nodes found so far
533  * @param[in] State     our State
534  *
535  */
536 VOID
537 NotifyErrorCohNoTopology (
538   IN       UINT8 Nodes,
539   IN       STATE_DATA *State
540   )
541 {
542   HT_EVENT_DATA_COH_NO_TOPOLOGY Evt;
543   // Zero out the event data
544   LibAmdMemFill (
545     &Evt,
546     0,
547     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
548     State->ConfigHandle
549     );
550
551   IDS_HDT_CONSOLE (HT_TRACE, "No Topology Matched system with %d nodes found.\n", Nodes);
552   Evt.TotalNodes = Nodes;
553   setEventNotify (AGESA_ERROR,
554                  HT_EVENT_COH_NO_TOPOLOGY,
555                  (UINT8 *)&Evt, State);
556 }
557
558 /*----------------------------------------------------------------------------------------*/
559 /**
560  * For event HT_EVENT_COH_PROCESSOR_TYPE_MIX
561  *
562  * @param[in] Node      The node from which a new node was discovered
563  * @param[in] Link      The link from that node
564  * @param[in] Nodes     The total number of nodes found so far
565  * @param[in] State     our State
566  *
567  */
568 VOID
569 NotifyFatalCohProcessorTypeMix (
570   IN       UINT8 Node,
571   IN       UINT8 Link,
572   IN       UINT8 Nodes,
573   IN       STATE_DATA *State
574   )
575 {
576   HT_EVENT_DATA_COH_PROCESSOR_TYPE_MIX Evt;
577   // Zero out the event data
578   LibAmdMemFill (
579     &Evt,
580     0,
581     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
582     State->ConfigHandle
583     );
584
585   IDS_HDT_CONSOLE (HT_TRACE, "Illegal Processor Type Mix.\n");
586   Evt.Node = Node;
587   Evt.Link = Link;
588   Evt.TotalNodes = Nodes;
589   setEventNotify (AGESA_CRITICAL,
590                  HT_EVENT_COH_PROCESSOR_TYPE_MIX,
591                  (UINT8 *)&Evt, State);
592 }
593
594 /*----------------------------------------------------------------------------------------*/
595 /**
596  * For event HT_EVENT_COH_NODE_DISCOVERED
597  *
598  * @param[in] Node       Node from which a new node was discovered
599  * @param[in] Link       The link to that new node
600  * @param[in] NewNode    The new node's id
601  * @param[in] TempRoute  Temporarily, during discovery, the new node is accessed at this id.
602  * @param[in] State      our State
603  *
604  */
605 VOID
606 NotifyInfoCohNodeDiscovered (
607   IN       UINT8 Node,
608   IN       UINT8 Link,
609   IN       UINT8 NewNode,
610   IN       UINT8 TempRoute,
611   IN       STATE_DATA *State
612   )
613 {
614   HT_EVENT_DATA_COH_NODE_DISCOVERED Evt;
615   // Zero out the event data
616   LibAmdMemFill (
617     &Evt,
618     0,
619     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
620     State->ConfigHandle
621     );
622
623   IDS_HDT_CONSOLE (HT_TRACE, "Adding Node %d.\n", NewNode);
624   Evt.Node = Node;
625   Evt.Link = Link;
626   Evt.NewNode = NewNode;
627   Evt.TempRoute = TempRoute;
628   setEventNotify (AGESA_SUCCESS,
629                  HT_EVENT_COH_NODE_DISCOVERED,
630                  (UINT8 *)&Evt, State);
631 }
632
633 /*----------------------------------------------------------------------------------------*/
634 /**
635  * For event HT_EVENT_COH_MPCAP_MISMATCH
636  *
637  * @param[in] Node      The node from which a new node was discovered
638  * @param[in] Link      The link from that node
639  * @param[in] Cap       The aggregate system MP Capability
640  * @param[in] Nodes     The total number of nodes found so far
641  * @param[in] State     our State
642  *
643  */
644 VOID
645 NotifyFatalCohMpCapMismatch (
646   IN       UINT8      Node,
647   IN       UINT8      Link,
648   IN       UINT8      Cap,
649   IN       UINT8      Nodes,
650   IN       STATE_DATA *State
651   )
652 {
653   HT_EVENT_DATA_COH_MP_CAP_MISMATCH Evt;
654   // Zero out the event data
655   LibAmdMemFill (
656     &Evt,
657     0,
658     (sizeof(UINT32) * NUMBER_OF_EVENT_DATA_PARAMS),
659     State->ConfigHandle
660     );
661
662   IDS_HDT_CONSOLE (HT_TRACE, "Mp Capability Mismatch.\n");
663   Evt.Node = Node;
664   Evt.Link = Link;
665   Evt.SysMpCap = Cap;
666   Evt.TotalNodes = Nodes;
667   setEventNotify (AGESA_CRITICAL,
668                  HT_EVENT_COH_MPCAP_MISMATCH,
669                  (UINT8 *)&Evt, State);
670 }