- Linus: more PageDirty / swapcache handling
[davej-history.git] / arch / mips64 / sgi-ip27 / ip27-berr.c
blobfade5a7af5bddde380f3b23c81880d423a09afb0
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
6 * Copyright (C) 1994, 1995, 1996, 1999, 2000 by Ralf Baechle
7 * Copyright (C) 1999, 2000 by Silicon Graphics
8 */
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <asm/sn/addrs.h>
12 #include <asm/sn/arch.h>
13 #include <asm/sn/sn0/hub.h>
14 #include <asm/uaccess.h>
16 extern void dump_tlb_addr(unsigned long addr);
17 extern void dump_tlb_all(void);
19 extern asmlinkage void handle_ibe(void);
20 extern asmlinkage void handle_dbe(void);
22 extern const struct exception_table_entry __start___dbe_table[];
23 extern const struct exception_table_entry __stop___dbe_table[];
25 static inline unsigned long
26 search_one_table(const struct exception_table_entry *first,
27 const struct exception_table_entry *last,
28 unsigned long value)
30 while (first <= last) {
31 const struct exception_table_entry *mid;
32 long diff;
34 mid = (last - first) / 2 + first;
35 diff = mid->insn - value;
36 if (diff == 0)
37 return mid->nextinsn;
38 else if (diff < 0)
39 first = mid+1;
40 else
41 last = mid-1;
43 return 0;
46 static inline unsigned long
47 search_dbe_table(unsigned long addr)
49 unsigned long ret;
51 /* There is only the kernel to search. */
52 ret = search_one_table(__start___dbe_table, __stop___dbe_table-1, addr);
53 if (ret) return ret;
55 return 0;
58 void do_ibe(struct pt_regs *regs)
60 printk("Got ibe at 0x%lx\n", regs->cp0_epc);
61 show_regs(regs);
62 dump_tlb_addr(regs->cp0_epc);
63 force_sig(SIGBUS, current);
64 while(1);
67 void do_dbe(struct pt_regs *regs)
69 unsigned long fixup;
71 fixup = search_dbe_table(regs->cp0_epc);
72 if (fixup) {
73 long new_epc;
75 new_epc = fixup_exception(dpf_reg, fixup, regs->cp0_epc);
76 regs->cp0_epc = new_epc;
77 return;
80 printk("Got dbe at 0x%lx\n", regs->cp0_epc);
81 show_regs(regs);
82 dump_tlb_all();
83 while(1);
84 force_sig(SIGBUS, current);
87 void __init
88 bus_error_init(void)
90 /* XXX Initialize all the Hub & Bridge error handling here. */
91 int cpu = LOCAL_HUB_L(PI_CPU_NUM);
92 int cpuoff = cpu << 8;
94 set_except_vector(6, handle_ibe);
95 set_except_vector(7, handle_dbe);
97 LOCAL_HUB_S(PI_ERR_INT_PEND,
98 cpu ? PI_ERR_CLEAR_ALL_A : PI_ERR_CLEAR_ALL_B);
99 LOCAL_HUB_S(PI_ERR_INT_MASK_A + cpuoff, 0);
100 LOCAL_HUB_S(PI_ERR_STACK_ADDR_A + cpuoff, 0);
101 LOCAL_HUB_S(PI_ERR_STACK_SIZE, 0); /* Disable error stack */
102 LOCAL_HUB_S(PI_SYSAD_ERRCHK_EN, PI_SYSAD_CHECK_ALL);