branch Attitude Adjustment
[12.09/openwrt.git] / target / linux / ubicom32 / files / arch / ubicom32 / mm / fault.c
1 /*
2  * arch/ubicom32/mm/fault.c
3  *   Ubicom32 architecture page fault implementation.
4  *
5  * (C) Copyright 2009, Ubicom, Inc.
6  *  Copyright (C) 1998  D. Jeff Dionne <jeff@lineo.ca>,
7  *  Copyright (C) 2000  Lineo, Inc.  (www.lineo.com)
8  *
9  *  Based on:
10  *
11  *  linux/arch/m68k/mm/fault.c
12  *
13  *  Copyright (C) 1995  Hamish Macdonald
14  *
15  * This file is part of the Ubicom32 Linux Kernel Port.
16  *
17  * The Ubicom32 Linux Kernel Port is free software: you can redistribute
18  * it and/or modify it under the terms of the GNU General Public License
19  * as published by the Free Software Foundation, either version 2 of the
20  * License, or (at your option) any later version.
21  *
22  * The Ubicom32 Linux Kernel Port is distributed in the hope that it
23  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
24  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
25  * the GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with the Ubicom32 Linux Kernel Port.  If not,
29  * see <http://www.gnu.org/licenses/>.
30  *
31  * Ubicom32 implementation derived from (with many thanks):
32  *   arch/m68knommu
33  *   arch/blackfin
34  *   arch/parisc
35  */
36
37 #include <linux/module.h>
38 #include <linux/mman.h>
39 #include <linux/mm.h>
40 #include <linux/kernel.h>
41 #include <linux/ptrace.h>
42
43 #include <asm/system.h>
44 #include <asm/pgtable.h>
45
46 extern void die_if_kernel(char *, struct pt_regs *, long);
47
48 /*
49  * This routine handles page faults.  It determines the problem, and
50  * then passes it off to one of the appropriate routines.
51  *
52  * error_code:
53  *      bit 0 == 0 means no page found, 1 means protection fault
54  *      bit 1 == 0 means read, 1 means write
55  *
56  * If this routine detects a bad access, it returns 1, otherwise it
57  * returns 0.
58  */
59 asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address,
60                               unsigned long error_code)
61 {
62 #ifdef DEBUG
63         printk (KERN_DEBUG "regs->sr=%#x, regs->pc=%#lx, address=%#lx, %ld\n",
64                 regs->sr, regs->pc, address, error_code);
65 #endif
66
67         /*
68          * Oops. The kernel tried to access some bad page. We'll have to
69          * terminate things with extreme prejudice.
70          */
71         if ((unsigned long) address < PAGE_SIZE) {
72                 printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
73         } else
74                 printk(KERN_ALERT "Unable to handle kernel access");
75         printk(KERN_ALERT " at virtual address %08lx\n",address);
76         die_if_kernel("Oops", regs, error_code);
77         do_exit(SIGKILL);
78
79         return 1;
80 }