Update ia64 patch to 2.5.72-030619
[linux-flexiantxendom0-3.2.10.git] / arch / ia64 / sn / kernel / mca.c
1 /*
2  * File:        mca.c
3  * Purpose:     SN specific MCA code.
4  *
5  * Copyright (C) 2001-2003 Silicon Graphics, Inc.  All Rights Reserved.
6  * 
7  * This program is free software; you can redistribute it and/or modify it 
8  * under the terms of version 2 of the GNU General Public License 
9  * as published by the Free Software Foundation.
10  * 
11  * This program is distributed in the hope that it would be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty of 
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
14  * 
15  * Further, this software is distributed without any warranty that it is 
16  * free of the rightful claim of any third person regarding infringement 
17  * or the like.  Any license provided herein, whether implied or 
18  * otherwise, applies only to this software file.  Patent licenses, if 
19  * any, provided herein do not apply to combinations of this program with 
20  * other software, or any other product whatsoever.
21  * 
22  * You should have received a copy of the GNU General Public 
23  * License along with this program; if not, write the Free Software 
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
25  * 
26  * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
27  * Mountain View, CA  94043, or:
28  * 
29  * http://www.sgi.com 
30  * 
31  * For further information regarding this notice, see: 
32  * 
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan
34  */
35
36 #include <linux/types.h>
37 #include <linux/kernel.h>
38 #include <linux/timer.h>
39 #include <asm/mca.h>
40 #include <asm/sal.h>
41 #include <asm/sn/sn_sal.h>
42
43
44
45 /*
46  * Interval for calling SAL to poll for errors that do NOT cause error
47  * interrupts. SAL will raise a CPEI if any errors are present that
48  * need to be logged.
49  */
50 #define CPEI_INTERVAL   (5*HZ)
51
52
53 struct timer_list sn_cpei_timer;
54 void sn_init_cpei_timer(void);
55
56
57 /*
58  * print_hook
59  *
60  * This function is the callback routine that SAL calls to log error
61  * info for platform errors. 
62  */
63 static int
64 print_hook(const char *fmt, ...)
65 {
66         static int      newline=1;
67         char            buf[400], *p;
68         va_list         args;
69         int             len=0;
70
71
72         va_start(args, fmt);
73         if (newline) {
74                 strcpy(buf, "+ ");
75                 len += 2;
76         }
77         len += vsnprintf(buf+len, sizeof(buf)-len, fmt, args);
78
79         /* Prefix each line with "+ " to be consistent with mca.c. */
80         p = buf;
81         while ((p=strchr(p, '\n')) && *++p != '\0') {
82                 memmove(p+2, p, 1+strlen(p));
83                 strncpy(p, "+ ", 2);
84                 len += 2;
85         }
86         newline = (p != 0);
87
88         va_end(args);
89         printk("%s", buf);
90         return len;
91 }
92
93
94
95 /*
96  * ia64_sn2_platform_plat_specific_err_print
97  *
98  * Called by the MCA handler to log platform-specific errors.
99  */
100 void
101 ia64_sn2_platform_plat_specific_err_print(int header_len, int sect_len, u8 *p_data, prfunc_t prfunc)
102 {
103         ia64_sn_plat_specific_err_print(print_hook, p_data - sect_len);
104 }
105
106
107
108 static void
109 sn_cpei_handler(int irq, void *devid, struct pt_regs *regs)
110 {
111         /*
112          * this function's sole purpose is to call SAL when we receive
113          * a CE interrupt from SHUB or when the timer routine decides
114          * we need to call SAL to check for CEs.
115          */
116
117         /* CALL SAL_LOG_CE */
118
119         ia64_sn_plat_cpei_handler();
120 }
121
122
123 static void
124 sn_cpei_timer_handler(unsigned long dummy) {
125         sn_cpei_handler(-1, NULL, NULL);
126         mod_timer(&sn_cpei_timer, jiffies + CPEI_INTERVAL);
127 }
128
129 void
130 sn_init_cpei_timer() {
131         sn_cpei_timer.expires = jiffies + CPEI_INTERVAL;
132         sn_cpei_timer.function = sn_cpei_timer_handler;
133         add_timer(&sn_cpei_timer);
134 }