| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *  linux/arch/m32r/mm/fault.c | 
|  | 3 | * | 
|  | 4 | *  Copyright (c) 2001, 2002  Hitoshi Yamamoto, and H. Kondo | 
|  | 5 | * | 
|  | 6 | *  Some code taken from i386 version. | 
|  | 7 | *    Copyright (C) 1995  Linus Torvalds | 
|  | 8 | */ | 
|  | 9 |  | 
|  | 10 | /* $Id: fault-nommu.c,v 1.1 2004/03/30 06:40:59 sakugawa Exp $ */ | 
|  | 11 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/signal.h> | 
|  | 13 | #include <linux/sched.h> | 
|  | 14 | #include <linux/kernel.h> | 
|  | 15 | #include <linux/errno.h> | 
|  | 16 | #include <linux/string.h> | 
|  | 17 | #include <linux/types.h> | 
|  | 18 | #include <linux/ptrace.h> | 
|  | 19 | #include <linux/mman.h> | 
|  | 20 | #include <linux/mm.h> | 
|  | 21 | #include <linux/smp.h> | 
|  | 22 | #include <linux/smp_lock.h> | 
|  | 23 | #include <linux/interrupt.h> | 
|  | 24 | #include <linux/init.h> | 
|  | 25 | #include <linux/vt_kern.h>              /* For unblank_screen() */ | 
|  | 26 |  | 
|  | 27 | #include <asm/m32r.h> | 
|  | 28 | #include <asm/system.h> | 
|  | 29 | #include <asm/uaccess.h> | 
|  | 30 | #include <asm/pgalloc.h> | 
|  | 31 | #include <asm/pgtable.h> | 
|  | 32 | #include <asm/hardirq.h> | 
|  | 33 | #include <asm/mmu_context.h> | 
|  | 34 |  | 
|  | 35 | extern void die(const char *, struct pt_regs *, long); | 
|  | 36 |  | 
|  | 37 | #ifndef CONFIG_SMP | 
|  | 38 | asmlinkage unsigned int tlb_entry_i_dat; | 
|  | 39 | asmlinkage unsigned int tlb_entry_d_dat; | 
|  | 40 | #define tlb_entry_i tlb_entry_i_dat | 
|  | 41 | #define tlb_entry_d tlb_entry_d_dat | 
|  | 42 | #else | 
|  | 43 | unsigned int tlb_entry_i_dat[NR_CPUS]; | 
|  | 44 | unsigned int tlb_entry_d_dat[NR_CPUS]; | 
|  | 45 | #define tlb_entry_i tlb_entry_i_dat[smp_processor_id()] | 
|  | 46 | #define tlb_entry_d tlb_entry_d_dat[smp_processor_id()] | 
|  | 47 | #endif | 
|  | 48 |  | 
|  | 49 | /* | 
|  | 50 | * Unlock any spinlocks which will prevent us from getting the | 
|  | 51 | * message out | 
|  | 52 | */ | 
|  | 53 | void bust_spinlocks(int yes) | 
|  | 54 | { | 
|  | 55 | int loglevel_save = console_loglevel; | 
|  | 56 |  | 
|  | 57 | if (yes) { | 
|  | 58 | oops_in_progress = 1; | 
|  | 59 | return; | 
|  | 60 | } | 
|  | 61 | #ifdef CONFIG_VT | 
|  | 62 | unblank_screen(); | 
|  | 63 | #endif | 
|  | 64 | oops_in_progress = 0; | 
|  | 65 | /* | 
|  | 66 | * OK, the message is on the console.  Now we call printk() | 
|  | 67 | * without oops_in_progress set so that printk will give klogd | 
|  | 68 | * a poke.  Hold onto your hats... | 
|  | 69 | */ | 
|  | 70 | console_loglevel = 15;		/* NMI oopser may have shut the console up */ | 
|  | 71 | printk(" "); | 
|  | 72 | console_loglevel = loglevel_save; | 
|  | 73 | } | 
|  | 74 |  | 
|  | 75 | void do_BUG(const char *file, int line) | 
|  | 76 | { | 
|  | 77 | bust_spinlocks(1); | 
|  | 78 | printk("kernel BUG at %s:%d!\n", file, line); | 
|  | 79 | } | 
|  | 80 |  | 
|  | 81 | /*======================================================================* | 
|  | 82 | * do_page_fault() | 
|  | 83 | *======================================================================* | 
|  | 84 | * This routine handles page faults.  It determines the address, | 
|  | 85 | * and the problem, and then passes it off to one of the appropriate | 
|  | 86 | * routines. | 
|  | 87 | * | 
|  | 88 | * ARGUMENT: | 
|  | 89 | *  regs       : M32R SP reg. | 
|  | 90 | *  error_code : See below | 
|  | 91 | *  address    : M32R MMU MDEVA reg. (Operand ACE) | 
|  | 92 | *             : M32R BPC reg. (Instruction ACE) | 
|  | 93 | * | 
|  | 94 | * error_code : | 
|  | 95 | *  bit 0 == 0 means no page found, 1 means protection fault | 
|  | 96 | *  bit 1 == 0 means read, 1 means write | 
|  | 97 | *  bit 2 == 0 means kernel, 1 means user-mode | 
|  | 98 | *======================================================================*/ | 
|  | 99 | asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code, | 
|  | 100 | unsigned long address) | 
|  | 101 | { | 
|  | 102 |  | 
|  | 103 | /* | 
|  | 104 | * Oops. The kernel tried to access some bad page. We'll have to | 
|  | 105 | * terminate things with extreme prejudice. | 
|  | 106 | */ | 
|  | 107 |  | 
|  | 108 | bust_spinlocks(1); | 
|  | 109 |  | 
|  | 110 | if (address < PAGE_SIZE) | 
|  | 111 | printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference"); | 
|  | 112 | else | 
|  | 113 | printk(KERN_ALERT "Unable to handle kernel paging request"); | 
|  | 114 | printk(" at virtual address %08lx\n",address); | 
|  | 115 | printk(" printing bpc:\n"); | 
|  | 116 | printk(KERN_ALERT "bpc = %08lx\n", regs->bpc); | 
|  | 117 |  | 
|  | 118 | die("Oops", regs, error_code); | 
|  | 119 | bust_spinlocks(0); | 
|  | 120 | do_exit(SIGKILL); | 
|  | 121 | } | 
|  | 122 |  | 
|  | 123 | /*======================================================================* | 
|  | 124 | * update_mmu_cache() | 
|  | 125 | *======================================================================*/ | 
|  | 126 | void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, | 
|  | 127 | pte_t pte) | 
|  | 128 | { | 
|  | 129 | BUG(); | 
|  | 130 | } | 
|  | 131 |  | 
|  | 132 | /*======================================================================* | 
|  | 133 | * flush_tlb_page() : flushes one page | 
|  | 134 | *======================================================================*/ | 
|  | 135 | void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page) | 
|  | 136 | { | 
|  | 137 | BUG(); | 
|  | 138 | } | 
|  | 139 |  | 
|  | 140 | /*======================================================================* | 
|  | 141 | * flush_tlb_range() : flushes a range of pages | 
|  | 142 | *======================================================================*/ | 
|  | 143 | void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, | 
|  | 144 | unsigned long end) | 
|  | 145 | { | 
|  | 146 | BUG(); | 
|  | 147 | } | 
|  | 148 |  | 
|  | 149 | /*======================================================================* | 
|  | 150 | * flush_tlb_mm() : flushes the specified mm context TLB's | 
|  | 151 | *======================================================================*/ | 
|  | 152 | void local_flush_tlb_mm(struct mm_struct *mm) | 
|  | 153 | { | 
|  | 154 | BUG(); | 
|  | 155 | } | 
|  | 156 |  | 
|  | 157 | /*======================================================================* | 
|  | 158 | * flush_tlb_all() : flushes all processes TLBs | 
|  | 159 | *======================================================================*/ | 
|  | 160 | void local_flush_tlb_all(void) | 
|  | 161 | { | 
|  | 162 | BUG(); | 
|  | 163 | } | 
|  | 164 |  |