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
6 * Copyright (C) 1994 - 1999, 2000, 01 Ralf Baechle
7 * Copyright (C) 1995, 1996 Paul M. Antoine
8 * Copyright (C) 1998 Ulf Carlsson
9 * Copyright (C) 1999 Silicon Graphics, Inc.
10 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
11 * Copyright (C) 2000, 01 MIPS Technologies, Inc.
12 * Copyright (C) 2002, 2003, 2004 Maciej W. Rozycki
14 #include <linux/config.h>
15 #include <linux/init.h>
17 #include <linux/module.h>
18 #include <linux/sched.h>
19 #include <linux/smp.h>
20 #include <linux/smp_lock.h>
21 #include <linux/spinlock.h>
23 #include <asm/bootinfo.h>
24 #include <asm/branch.h>
25 #include <asm/break.h>
28 #include <asm/cachectl.h>
31 #include <asm/module.h>
32 #include <asm/pgtable.h>
34 #include <asm/siginfo.h>
35 #include <asm/watch.h>
36 #include <asm/tlbdebug.h>
37 #include <asm/types.h>
38 #include <asm/system.h>
39 #include <asm/traps.h>
40 #include <asm/uaccess.h>
41 #include <asm/mmu_context.h>
43 extern asmlinkage void handle_mod(void);
44 extern asmlinkage void handle_tlbl(void);
45 extern asmlinkage void handle_tlbs(void);
46 extern asmlinkage void handle_adel(void);
47 extern asmlinkage void handle_ades(void);
48 extern asmlinkage void handle_ibe(void);
49 extern asmlinkage void handle_dbe(void);
50 extern asmlinkage void handle_sys(void);
51 extern asmlinkage void handle_bp(void);
52 extern asmlinkage void handle_ri(void);
53 extern asmlinkage void handle_cpu(void);
54 extern asmlinkage void handle_ov(void);
55 extern asmlinkage void handle_tr(void);
56 extern asmlinkage void handle_fpe(void);
57 extern asmlinkage void handle_mdmx(void);
58 extern asmlinkage void handle_watch(void);
59 extern asmlinkage void handle_mcheck(void);
60 extern asmlinkage void handle_reserved(void);
62 extern int fpu_emulator_cop1Handler(int xcptno, struct pt_regs *xcp,
63 struct mips_fpu_soft_struct *ctx);
65 void (*board_be_init)(void);
66 int (*board_be_handler)(struct pt_regs *regs, int is_fixup);
67 void (*board_nmi_handler_setup)(void);
69 int kstack_depth_to_print = 24;
72 * These constant is for searching for possible module text segments.
73 * MODULE_RANGE is a guess of how much space is likely to be vmalloced.
75 #define MODULE_RANGE (8*1024*1024)
78 * If the address is either in the .text section of the
79 * kernel, or in the vmalloc'ed module regions, it *may*
80 * be the address of a calling routine
85 extern struct module *module_list;
86 extern struct module kernel_module;
88 static inline int kernel_text_address(long addr)
90 extern char _stext, _etext;
94 if (addr >= (long) &_stext && addr <= (long) &_etext)
97 for (mod = module_list; mod != &kernel_module; mod = mod->next) {
98 /* mod_bound tests for addr being inside the vmalloc'ed
99 * module area. Of course it'd be better to test only
100 * for the .text subset... */
101 if (mod_bound(addr, 0, mod)) {
112 static inline int kernel_text_address(long addr)
114 extern char _stext, _etext;
116 return (addr >= (long) &_stext && addr <= (long) &_etext);
122 * This routine abuses get_user()/put_user() to reference pointers
123 * with at least a bit of error checking ...
125 void show_stack(long *sp)
130 sp = sp ? sp : (long *)&sp;
134 while ((long) sp & (PAGE_SIZE - 1)) {
135 if (i && ((i % 8) == 0))
142 if (__get_user(stackdata, sp++)) {
143 printk(" (Bad stack address)");
147 printk(" %08lx", stackdata);
153 void show_trace(long *sp)
158 sp = sp ? sp : (long *) &sp;
160 printk("Call Trace: ");
162 while ((long) sp & (PAGE_SIZE - 1)) {
164 if (__get_user(addr, sp++)) {
165 if (i && ((i % 6) == 0))
167 printk(" (Bad stack address)\n");
172 * If the address is either in the text segment of the
173 * kernel, or in the region which contains vmalloc'ed
174 * memory, it *may* be the address of a calling
175 * routine; if so, print it so that someone tracing
176 * down the cause of the crash will be able to figure
177 * out the call path that was taken.
180 if (kernel_text_address(addr)) {
181 if (i && ((i % 6) == 0))
188 printk(" [<%08lx>]", addr);
195 void show_trace_task(struct task_struct *tsk)
197 show_trace((long *)tsk->thread.reg29);
200 void show_code(unsigned int *pc)
206 for(i = -3 ; i < 6 ; i++) {
208 if (__get_user(insn, pc + i)) {
209 printk(" (Bad address in epc)\n");
212 printk("%c%08lx%c",(i?' ':'<'),insn,(i?' ':'>'));
216 void show_regs(struct pt_regs *regs)
219 * Saved main processor registers
221 printk("$0 : %08x %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
222 0, regs->regs[1], regs->regs[2], regs->regs[3],
223 regs->regs[4], regs->regs[5], regs->regs[6], regs->regs[7]);
224 printk("$8 : %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
225 regs->regs[8], regs->regs[9], regs->regs[10], regs->regs[11],
226 regs->regs[12], regs->regs[13], regs->regs[14], regs->regs[15]);
227 printk("$16: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
228 regs->regs[16], regs->regs[17], regs->regs[18], regs->regs[19],
229 regs->regs[20], regs->regs[21], regs->regs[22], regs->regs[23]);
230 printk("$24: %08lx %08lx %08lx %08lx %08lx %08lx\n",
231 regs->regs[24], regs->regs[25],
232 regs->regs[28], regs->regs[29], regs->regs[30], regs->regs[31]);
233 printk("Hi : %08lx\n", regs->hi);
234 printk("Lo : %08lx\n", regs->lo);
237 * Saved cp0 registers
239 printk("epc : %08lx %s\n", regs->cp0_epc, print_tainted());
240 printk("Status: %08lx\n", regs->cp0_status);
241 printk("Cause : %08lx\n", regs->cp0_cause);
242 printk("PrId : %08x\n", read_c0_prid());
245 void show_registers(struct pt_regs *regs)
248 printk("Process %s (pid: %d, stackpage=%08lx)\n",
249 current->comm, current->pid, (unsigned long) current);
250 show_stack((long *) regs->regs[29]);
251 show_trace((long *) regs->regs[29]);
252 show_code((unsigned int *) regs->cp0_epc);
256 static spinlock_t die_lock = SPIN_LOCK_UNLOCKED;
258 void __die(const char * str, struct pt_regs * regs, const char * file,
259 const char * func, unsigned long line)
262 spin_lock_irq(&die_lock);
265 printk(" in %s:%s, line %ld", file, func, line);
267 show_registers(regs);
268 spin_unlock_irq(&die_lock);
272 void __die_if_kernel(const char * str, struct pt_regs * regs,
273 const char * file, const char * func, unsigned long line)
275 if (!user_mode(regs))
276 __die(str, regs, file, func, line);
279 extern const struct exception_table_entry __start___dbe_table[];
280 extern const struct exception_table_entry __stop___dbe_table[];
282 void __declare_dbe_table(void)
284 __asm__ __volatile__(
285 ".section\t__dbe_table,\"a\"\n\t"
290 static inline unsigned long
291 search_one_table(const struct exception_table_entry *first,
292 const struct exception_table_entry *last,
295 const struct exception_table_entry *mid;
298 while (first < last) {
299 mid = (last - first) / 2 + first;
300 diff = mid->insn - value;
306 return (first == last && first->insn == value) ? first->nextinsn : 0;
309 extern spinlock_t modlist_lock;
311 static inline unsigned long
312 search_dbe_table(unsigned long addr)
314 unsigned long ret = 0;
316 #ifndef CONFIG_MODULES
317 /* There is only the kernel to search. */
318 ret = search_one_table(__start___dbe_table, __stop___dbe_table-1, addr);
323 /* The kernel is the last "module" -- no need to treat it special. */
327 spin_lock_irqsave(&modlist_lock, flags);
328 for (mp = module_list; mp != NULL; mp = mp->next) {
329 if (!mod_member_present(mp, archdata_end) ||
330 !mod_archdata_member_present(mp, struct archdata,
333 ap = (struct archdata *)(mp->archdata_start);
335 if (ap->dbe_table_start == NULL ||
336 !(mp->flags & (MOD_RUNNING | MOD_INITIALIZING)))
338 ret = search_one_table(ap->dbe_table_start,
339 ap->dbe_table_end - 1, addr);
343 spin_unlock_irqrestore(&modlist_lock, flags);
348 asmlinkage void do_be(struct pt_regs *regs)
350 unsigned long new_epc;
351 unsigned long fixup = 0;
352 int data = regs->cp0_cause & 4;
353 int action = MIPS_BE_FATAL;
355 if (data && !user_mode(regs))
356 fixup = search_dbe_table(exception_epc(regs));
359 action = MIPS_BE_FIXUP;
361 if (board_be_handler)
362 action = board_be_handler(regs, fixup != 0);
365 case MIPS_BE_DISCARD:
369 new_epc = fixup_exception(dpf_reg, fixup,
371 regs->cp0_epc = new_epc;
380 * Assume it would be too dangerous to continue ...
382 printk(KERN_ALERT "%s bus error, epc == %08lx, ra == %08lx\n",
383 data ? "Data" : "Instruction",
384 regs->cp0_epc, regs->regs[31]);
385 die_if_kernel("Oops", regs);
386 force_sig(SIGBUS, current);
389 static inline int get_insn_opcode(struct pt_regs *regs, unsigned int *opcode)
393 epc = (unsigned int *) regs->cp0_epc +
394 ((regs->cp0_cause & CAUSEF_BD) != 0);
395 if (!get_user(*opcode, epc))
398 force_sig(SIGSEGV, current);
406 #define OPCODE 0xfc000000
407 #define BASE 0x03e00000
408 #define RT 0x001f0000
409 #define OFFSET 0x0000ffff
410 #define LL 0xc0000000
411 #define SC 0xe0000000
414 * The ll_bit is cleared by r*_switch.S
417 unsigned long ll_bit;
419 static struct task_struct *ll_task = NULL;
421 static inline void simulate_ll(struct pt_regs *regs, unsigned int opcode)
423 unsigned long value, *vaddr;
428 * analyse the ll instruction that just caused a ri exception
429 * and put the referenced address to addr.
432 /* sign extend offset */
433 offset = opcode & OFFSET;
437 vaddr = (unsigned long *)((long)(regs->regs[(opcode & BASE) >> 21]) + offset);
439 if ((unsigned long)vaddr & 3) {
443 if (get_user(value, vaddr)) {
448 if (ll_task == NULL || ll_task == current) {
455 regs->regs[(opcode & RT) >> 16] = value;
457 compute_return_epc(regs);
461 force_sig(signal, current);
464 static inline void simulate_sc(struct pt_regs *regs, unsigned int opcode)
466 unsigned long *vaddr, reg;
471 * analyse the sc instruction that just caused a ri exception
472 * and put the referenced address to addr.
475 /* sign extend offset */
476 offset = opcode & OFFSET;
480 vaddr = (unsigned long *)((long)(regs->regs[(opcode & BASE) >> 21]) + offset);
481 reg = (opcode & RT) >> 16;
483 if ((unsigned long)vaddr & 3) {
487 if (ll_bit == 0 || ll_task != current) {
489 compute_return_epc(regs);
493 if (put_user(regs->regs[reg], vaddr)) {
500 compute_return_epc(regs);
504 force_sig(signal, current);
508 * ll uses the opcode of lwc0 and sc uses the opcode of swc0. That is both
509 * opcodes are supposed to result in coprocessor unusable exceptions if
510 * executed on ll/sc-less processors. That's the theory. In practice a
511 * few processors such as NEC's VR4100 throw reserved instruction exceptions
512 * instead, so we're doing the emulation thing in both exception handlers.
514 static inline int simulate_llsc(struct pt_regs *regs)
518 if (unlikely(get_insn_opcode(regs, &opcode)))
521 if ((opcode & OPCODE) == LL) {
522 simulate_ll(regs, opcode);
525 if ((opcode & OPCODE) == SC) {
526 simulate_sc(regs, opcode);
530 return -EFAULT; /* Strange things going on ... */
533 asmlinkage void do_ov(struct pt_regs *regs)
537 info.si_code = FPE_INTOVF;
538 info.si_signo = SIGFPE;
540 info.si_addr = (void *)regs->cp0_epc;
541 force_sig_info(SIGFPE, &info, current);
545 * XXX Delayed fp exceptions when doing a lazy ctx switch XXX
547 asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)
549 if (fcr31 & FPU_CSR_UNI_X) {
553 * Unimplemented operation exception. If we've got the full
554 * software emulator on-board, let's use it...
556 * Force FPU to dump state into task/thread context. We're
557 * moving a lot of data here for what is probably a single
558 * instruction, but the alternative is to pre-decode the FP
559 * register operands before invoking the emulator, which seems
560 * a bit extreme for what should be an infrequent event.
564 /* Run the emulator */
565 sig = fpu_emulator_cop1Handler (0, regs,
566 ¤t->thread.fpu.soft);
569 * We can't allow the emulated instruction to leave any of
570 * the cause bit set in $fcr31.
572 current->thread.fpu.soft.sr &= ~FPU_CSR_ALL_X;
574 /* Restore the hardware register state */
577 /* If something went wrong, signal */
579 force_sig(sig, current);
584 force_sig(SIGFPE, current);
587 asmlinkage void do_bp(struct pt_regs *regs)
589 unsigned int opcode, bcode;
592 die_if_kernel("Break instruction in kernel code", regs);
594 if (get_insn_opcode(regs, &opcode))
598 * There is the ancient bug in the MIPS assemblers that the break
599 * code starts left to bit 16 instead to bit 6 in the opcode.
600 * Gas is bug-compatible, but not always, grrr...
601 * We handle both cases with a simple heuristics. --macro
603 bcode = ((opcode >> 6) & ((1 << 20) - 1));
604 if (bcode < (1 << 10))
608 * (A short test says that IRIX 5.3 sends SIGTRAP for all break
609 * insns, even for break codes that indicate arithmetic failures.
611 * But should we continue the brokenness??? --macro
614 case BRK_OVERFLOW << 10:
615 case BRK_DIVZERO << 10:
616 if (bcode == (BRK_DIVZERO << 10))
617 info.si_code = FPE_INTDIV;
619 info.si_code = FPE_INTOVF;
620 info.si_signo = SIGFPE;
622 info.si_addr = (void *)regs->cp0_epc;
623 force_sig_info(SIGFPE, &info, current);
626 force_sig(SIGTRAP, current);
630 asmlinkage void do_tr(struct pt_regs *regs)
632 unsigned int opcode, tcode = 0;
635 if (get_insn_opcode(regs, &opcode))
638 /* Immediate versions don't provide a code. */
639 if (!(opcode & OPCODE))
640 tcode = ((opcode >> 6) & ((1 << 10) - 1));
643 * (A short test says that IRIX 5.3 sends SIGTRAP for all trap
644 * insns, even for trap codes that indicate arithmetic failures.
646 * But should we continue the brokenness??? --macro
651 if (tcode == BRK_DIVZERO)
652 info.si_code = FPE_INTDIV;
654 info.si_code = FPE_INTOVF;
655 info.si_signo = SIGFPE;
657 info.si_addr = (void *)regs->cp0_epc;
658 force_sig_info(SIGFPE, &info, current);
661 force_sig(SIGTRAP, current);
665 asmlinkage void do_ri(struct pt_regs *regs)
667 die_if_kernel("Reserved instruction in kernel code", regs);
670 if (!simulate_llsc(regs))
673 force_sig(SIGILL, current);
676 asmlinkage void do_cpu(struct pt_regs *regs)
680 die_if_kernel("do_cpu invoked from kernel context!", regs);
682 cpid = (regs->cp0_cause >> CAUSEB_CE) & 3;
689 if (!simulate_llsc(regs))
695 if (current->used_math) { /* Using the FPU again. */
697 } else { /* First time FPU user. */
699 current->used_math = 1;
703 int sig = fpu_emulator_cop1Handler(0, regs,
704 ¤t->thread.fpu.soft);
706 force_sig(sig, current);
716 force_sig(SIGILL, current);
719 asmlinkage void do_mdmx(struct pt_regs *regs)
721 force_sig(SIGILL, current);
724 asmlinkage void do_watch(struct pt_regs *regs)
727 * We use the watch exception where available to detect stack
732 panic("Caught WATCH exception - probably caused by stack overflow.");
735 asmlinkage void do_mcheck(struct pt_regs *regs)
740 * Some chips may have other causes of machine check (e.g. SB1
743 panic("Caught Machine Check exception - %scaused by multiple "
744 "matching entries in the TLB.",
745 (regs->cp0_status & ST0_TS) ? "" : "not ");
748 asmlinkage void do_reserved(struct pt_regs *regs)
751 * Game over - no way to handle this if it ever occurs. Most probably
752 * caused by a new unknown cpu type or after another deadly
753 * hard/software error.
756 panic("Caught reserved exception %ld - should not happen.",
757 (regs->cp0_cause & 0x7f) >> 2);
761 * Some MIPS CPUs can enable/disable for cache parity detection, but do
764 static inline void parity_protection_init(void)
766 switch (current_cpu_data.cputype) {
768 /* Set the PE bit (bit 31) in the c0_ecc register. */
769 printk(KERN_INFO "Enable the cache parity protection for "
771 write_c0_ecc(read_c0_ecc() | 0x80000000);
778 asmlinkage void cache_parity_error(void)
780 unsigned int reg_val;
782 /* For the moment, report the problem and hang. */
783 printk("Cache error exception:\n");
784 printk("cp0_errorepc == %08lx\n", read_c0_errorepc());
785 reg_val = read_c0_cacheerr();
786 printk("c0_cacheerr == %08x\n", reg_val);
788 printk("Decoded c0_cacheerr: %s cache fault in %s reference.\n",
789 reg_val & (1<<30) ? "secondary" : "primary",
790 reg_val & (1<<31) ? "data" : "insn");
791 printk("Error bits: %s%s%s%s%s%s%s\n",
792 reg_val & (1<<29) ? "ED " : "",
793 reg_val & (1<<28) ? "ET " : "",
794 reg_val & (1<<26) ? "EE " : "",
795 reg_val & (1<<25) ? "EB " : "",
796 reg_val & (1<<24) ? "EI " : "",
797 reg_val & (1<<23) ? "E1 " : "",
798 reg_val & (1<<22) ? "E0 " : "");
799 printk("IDX: 0x%08x\n", reg_val & ((1<<22)-1));
801 #if defined(CONFIG_CPU_MIPS32) || defined (CONFIG_CPU_MIPS64)
802 if (reg_val & (1<<22))
803 printk("DErrAddr0: 0x%08lx\n", read_c0_derraddr0());
805 if (reg_val & (1<<23))
806 printk("DErrAddr1: 0x%08lx\n", read_c0_derraddr1());
809 panic("Can't handle the cache error!");
813 * SDBBP EJTAG debug exception handler.
814 * We skip the instruction and return to the next instruction.
816 void ejtag_exception_handler(struct pt_regs *regs)
818 unsigned long depc, old_epc;
821 printk("SDBBP EJTAG debug exception - not handled yet, just ignored!\n");
822 depc = read_c0_depc();
823 debug = read_c0_debug();
824 printk("c0_depc = %08lx, DEBUG = %08x\n", depc, debug);
825 if (debug & 0x80000000) {
827 * In branch delay slot.
828 * We cheat a little bit here and use EPC to calculate the
829 * debug return address (DEPC). EPC is restored after the
832 old_epc = regs->cp0_epc;
833 regs->cp0_epc = depc;
834 __compute_return_epc(regs);
835 depc = regs->cp0_epc;
836 regs->cp0_epc = old_epc;
842 printk("\n\n----- Enable EJTAG single stepping ----\n\n");
843 write_c0_debug(debug | 0x100);
848 * NMI exception handler.
850 void nmi_exception_handler(struct pt_regs *regs)
852 printk("NMI taken!!!!\n");
857 unsigned long exception_handlers[32];
860 * As a side effect of the way this is implemented we're limited
861 * to interrupt handlers in the address range from
862 * KSEG0 <= x < KSEG0 + 256mb on the Nevada. Oh well ...
864 void *set_except_vector(int n, void *addr)
866 unsigned long handler = (unsigned long) addr;
867 unsigned long old_handler = exception_handlers[n];
869 exception_handlers[n] = handler;
870 if (n == 0 && cpu_has_divec) {
871 *(volatile u32 *)(KSEG0+0x200) = 0x08000000 |
872 (0x03ffffff & (handler >> 2));
873 flush_icache_range(KSEG0+0x200, KSEG0 + 0x204);
875 return (void *)old_handler;
878 asmlinkage int (*save_fp_context)(struct sigcontext *sc);
879 asmlinkage int (*restore_fp_context)(struct sigcontext *sc);
881 extern asmlinkage int _save_fp_context(struct sigcontext *sc);
882 extern asmlinkage int _restore_fp_context(struct sigcontext *sc);
884 extern asmlinkage int fpu_emulator_save_context(struct sigcontext *sc);
885 extern asmlinkage int fpu_emulator_restore_context(struct sigcontext *sc);
887 void __init per_cpu_trap_init(void)
889 unsigned int cpu = smp_processor_id();
891 /* Some firmware leaves the BEV flag set, clear it. */
892 clear_c0_status(ST0_CU3|ST0_CU2|ST0_CU1|ST0_BEV|ST0_KX|ST0_SX|ST0_UX);
894 if (current_cpu_data.isa_level == MIPS_CPU_ISA_IV)
895 set_c0_status(ST0_XX);
898 * Some MIPS CPUs have a dedicated interrupt vector which reduces the
899 * interrupt processing overhead. Use it where available.
902 set_c0_cause(CAUSEF_IV);
904 cpu_data[cpu].asid_cache = ASID_FIRST_VERSION;
905 write_c0_context(cpu << 23);
907 atomic_inc(&init_mm.mm_count);
908 current->active_mm = &init_mm;
910 enter_lazy_tlb(&init_mm, current, cpu);
913 void __init trap_init(void)
915 extern char except_vec1_generic;
916 extern char except_vec3_generic, except_vec3_r4000;
917 extern char except_vec_ejtag_debug;
918 extern char except_vec4;
923 /* Copy the generic exception handler code to it's final destination. */
924 memcpy((void *)(KSEG0 + 0x80), &except_vec1_generic, 0x80);
927 * Setup default vectors
929 for (i = 0; i <= 31; i++)
930 set_except_vector(i, handle_reserved);
933 * Copy the EJTAG debug exception vector handler code to it's final
937 memcpy((void *)(KSEG0 + 0x300), &except_vec_ejtag_debug, 0x80);
940 * Only some CPUs have the watch exceptions.
943 set_except_vector(23, handle_watch);
946 * Some MIPS CPUs have a dedicated interrupt vector which reduces the
947 * interrupt processing overhead. Use it where available.
950 memcpy((void *)(KSEG0 + 0x200), &except_vec4, 8);
953 * Some CPUs can enable/disable for cache parity detection, but does
956 parity_protection_init();
959 * The Data Bus Errors / Instruction Bus Errors are signaled
960 * by external hardware. Therefore these two exceptions
961 * may have board specific handlers.
966 set_except_vector(1, handle_mod);
967 set_except_vector(2, handle_tlbl);
968 set_except_vector(3, handle_tlbs);
969 set_except_vector(4, handle_adel);
970 set_except_vector(5, handle_ades);
972 set_except_vector(6, handle_ibe);
973 set_except_vector(7, handle_dbe);
975 set_except_vector(8, handle_sys);
976 set_except_vector(9, handle_bp);
977 set_except_vector(10, handle_ri);
978 set_except_vector(11, handle_cpu);
979 set_except_vector(12, handle_ov);
980 set_except_vector(13, handle_tr);
981 set_except_vector(22, handle_mdmx);
983 if (cpu_has_fpu && !cpu_has_nofpuex)
984 set_except_vector(15, handle_fpe);
987 set_except_vector(24, handle_mcheck);
990 memcpy((void *)(KSEG0 + 0x180), &except_vec3_r4000, 0x80);
991 else if (cpu_has_4kex)
992 memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, 0x80);
994 memcpy((void *)(KSEG0 + 0x080), &except_vec3_generic, 0x80);
996 if (current_cpu_data.cputype == CPU_R6000 ||
997 current_cpu_data.cputype == CPU_R6000A) {
999 * The R6000 is the only R-series CPU that features a machine
1000 * check exception (similar to the R4000 cache error) and
1001 * unaligned ldc1/sdc1 exception. The handlers have not been
1002 * written yet. Well, anyway there is no R6000 machine on the
1003 * current list of targets for Linux/MIPS.
1004 * (Duh, crap, there is someone with a tripple R6k machine)
1006 //set_except_vector(14, handle_mc);
1007 //set_except_vector(15, handle_ndc);
1011 save_fp_context = _save_fp_context;
1012 restore_fp_context = _restore_fp_context;
1014 save_fp_context = fpu_emulator_save_context;
1015 restore_fp_context = fpu_emulator_restore_context;
1018 if (board_nmi_handler_setup)
1019 board_nmi_handler_setup();
1021 flush_icache_range(KSEG0, KSEG0 + 0x400);
1023 atomic_inc(&init_mm.mm_count); /* XXX UP? */
1024 current->active_mm = &init_mm;
1026 /* XXX Must be done for all CPUs */
1027 current_cpu_data.asid_cache = ASID_FIRST_VERSION;
1028 TLBMISS_HANDLER_SETUP();