3 * Purpose: SN specific MCA code.
5 * Copyright (C) 2001-2003 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
31 * For further information regarding this notice, see:
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan
36 #include <linux/types.h>
37 #include <linux/kernel.h>
38 #include <linux/timer.h>
39 #include <linux/vmalloc.h>
40 #include <asm/machvec.h>
43 #include <asm/sn/sn_sal.h>
48 * Interval for calling SAL to poll for errors that do NOT cause error
49 * interrupts. SAL will raise a CPEI if any errors are present that
52 #define CPEI_INTERVAL (5*HZ)
55 struct timer_list sn_cpei_timer;
56 void sn_init_cpei_timer(void);
58 /* Printing oemdata from mca uses data that is not passed through SAL, it is
59 * global. Only one user at a time.
61 static DECLARE_MUTEX(sn_oemdata_mutex);
62 static u8 **sn_oemdata;
63 static u64 *sn_oemdata_size, sn_oemdata_bufsize;
65 /* Called as the "printk" routine via sn_platform_plat_specific_err_print,
66 * ia64_sn_plat_specific_err_print through SAL to print_hook. It only handles
67 * a print of '"%s", buf'. buf is appended to sn_oemdata, resizing as required.
70 sn_oemdata_print(const char *fmt, ...)
76 buf = va_arg(args, char *);
79 while (*sn_oemdata_size + len + 1 > sn_oemdata_bufsize) {
80 u8 *newbuf = vmalloc(sn_oemdata_bufsize += 1000);
82 printk(KERN_ERR "%s: unable to extend sn_oemdata\n", __FUNCTION__);
85 memcpy(newbuf, *sn_oemdata, *sn_oemdata_size);
89 memcpy(*sn_oemdata + *sn_oemdata_size, buf, len + 1);
90 *sn_oemdata_size += len;
97 * This function is the callback routine that SAL calls to log error
98 * info for platform errors.
101 print_hook(const char *fmt, ...)
103 static int newline=1;
114 len += vsnprintf(buf+len, sizeof(buf)-len, fmt, args);
116 /* Prefix each line with "+ " to be consistent with mca.c. */
118 while ((p=strchr(p, '\n')) && *++p != '\0') {
119 memmove(p+2, p, 1+strlen(p));
126 sn_oemdata_print("%s", buf); /* args must be '"%s", buf' */
132 sn_cpei_handler(int irq, void *devid, struct pt_regs *regs)
135 * this function's sole purpose is to call SAL when we receive
136 * a CE interrupt from SHUB or when the timer routine decides
137 * we need to call SAL to check for CEs.
140 /* CALL SAL_LOG_CE */
142 ia64_sn_plat_cpei_handler();
147 sn_cpei_timer_handler(unsigned long dummy) {
148 sn_cpei_handler(-1, NULL, NULL);
149 mod_timer(&sn_cpei_timer, jiffies + CPEI_INTERVAL);
153 sn_init_cpei_timer() {
154 sn_cpei_timer.expires = jiffies + CPEI_INTERVAL;
155 sn_cpei_timer.function = sn_cpei_timer_handler;
156 add_timer(&sn_cpei_timer);
160 sn_platform_plat_specific_err_print(const u8 *sect_header, u8 **oemdata, u64 *oemdata_size)
162 sal_log_plat_specific_err_info_t *psei = (sal_log_plat_specific_err_info_t *)sect_header;
163 if (!psei->valid.oem_data)
165 down(&sn_oemdata_mutex);
166 sn_oemdata = oemdata;
167 sn_oemdata_size = oemdata_size;
168 ia64_sn_plat_specific_err_print(print_hook, (char *)psei);
169 up(&sn_oemdata_mutex);
173 /* Callback when userspace salinfo wants to decode oem data via the platform
174 * kernel and/or prom.
176 int sn_salinfo_platform_oemdata(const u8 *sect_header, u8 **oemdata, u64 *oemdata_size)
178 efi_guid_t guid = *(efi_guid_t *)sect_header;
180 sn_oemdata_bufsize = 0;
183 if (efi_guidcmp(guid, SAL_PLAT_SPECIFIC_ERR_SECT_GUID) == 0)
184 return sn_platform_plat_specific_err_print(sect_header, oemdata, oemdata_size);
188 static int __init sn_salinfo_init(void)
190 salinfo_platform_oemdata = &sn_salinfo_platform_oemdata;
194 module_init(sn_salinfo_init)