ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / sh / mm / fault-nommu.c
1 /* 
2  * arch/sh/mm/fault-nommu.c
3  *
4  * Copyright (C) 2002 Paul Mundt
5  *
6  * Based on linux/arch/sh/mm/fault.c:
7  *  Copyright (C) 1999  Niibe Yutaka
8  *
9  * Released under the terms of the GNU GPL v2.0.
10  */
11
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
25 #include <asm/system.h>
26 #include <asm/io.h>
27 #include <asm/uaccess.h>
28 #include <asm/pgalloc.h>
29 #include <asm/hardirq.h>
30 #include <asm/mmu_context.h>
31 #include <asm/cacheflush.h>
32
33 #if defined(CONFIG_SH_KGDB)
34 #include <asm/kgdb.h>
35 #endif
36
37 extern void die(const char *,struct pt_regs *,long);
38
39 /*
40  * This routine handles page faults.  It determines the address,
41  * and the problem, and then passes it off to one of the appropriate
42  * routines.
43  */
44 asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
45                               unsigned long address)
46 {
47 #if defined(CONFIG_SH_KGDB)
48         if (kgdb_nofault && kgdb_bus_err_hook)
49                 kgdb_bus_err_hook();
50 #endif
51
52         /*
53          * Oops. The kernel tried to access some bad page. We'll have to
54          * terminate things with extreme prejudice.
55          *
56          */
57         if (address < PAGE_SIZE) {
58                 printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
59         } else {
60                 printk(KERN_ALERT "Unable to handle kernel paging request");
61         }
62
63         printk(" at virtual address %08lx\n", address);
64         printk(KERN_ALERT "pc = %08lx\n", regs->pc);
65
66         die("Oops", regs, writeaccess);
67         do_exit(SIGKILL);
68 }
69
70 asmlinkage int __do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
71                                unsigned long address)
72 {
73 #if defined(CONFIG_SH_KGDB)
74         if (kgdb_nofault && kgdb_bus_err_hook)
75                 kgdb_bus_err_hook();
76 #endif
77
78         if (address >= TASK_SIZE)
79                 return 1;
80
81         return 0;
82 }
83