Import 2.3.9pre5
[davej-history.git] / arch / mips / kernel / entry.S
bloba92443692eb8575c187d1c0053919198db41e512
1 /*
2  * Low level exception handling
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License.  See the file "COPYING" in the main directory of this archive
6  * for more details.
7  *
8  * Copyright (C) 1994, 1995 by Ralf Baechle
9  *
10  * $Id: entry.S,v 1.14 1999/04/12 19:13:21 harald Exp $
11  */
14  * entry.S contains the system-call and fault low-level handling routines.
15  * This also contains the timer-interrupt handler, as well as all interrupts
16  * and faults that can result in a task-switch. The ISA dependent TLB
17  * code is in arch/mips/<ISA-level>/<cputype>.S
18  */
19 #include <linux/config.h>
20 #include <linux/sys.h>
22 #include <asm/asm.h>
23 #include <asm/current.h>
24 #include <asm/errno.h>
25 #include <asm/mipsregs.h>
26 #include <asm/mipsconfig.h>
27 #include <asm/page.h>
28 #include <asm/pgtable.h>
29 #include <asm/stackframe.h>
30 #include <asm/processor.h>
31 #include <asm/regdef.h>
32 #include <asm/fpregdef.h>
33 #include <asm/unistd.h>
36  * Heia ...  The %lo, %hi and %HI stuff is too strong for the ELF assembler
37  * and the ABI to cope with ...
38  */
39                 .text
40                 .set    noreorder
41                 .set    mips3
42                 .align 4
43 EXPORT(handle_bottom_half)
44                 jal     do_bottom_half
45                  nop
46                 b       9f
47                  nop
49 reschedule:     jal     schedule 
50                  nop
52 EXPORT(ret_from_sys_call)
53 EXPORT(ret_from_irq)
54                 lw      t0,bh_mask
55                 lw      t1,bh_active            # unused delay slot
56                 and     t0,t1
57                 bnez    t0,handle_bottom_half
58 9:               lw     t0,PT_STATUS(sp)        # returning to kernel mode?
60                 andi    t1, t0, 0x10
61                 beqz    t1, return              # -> yes
62                  lw     t1, TASK_NEED_RESCHED($28)
63                 bnez    t1, reschedule
64                 lw      v0, TASK_SIGPENDING($28)
65                  move   a0, zero
66                 beqz    v0, return
67                  nop
68                 jal     do_signal
69                  move   a1, sp
71 EXPORT(return)  .set    noat
72                 RESTORE_ALL
73                 eret
74                 .set    at
77  * Common spurious interrupt handler.
78  */
79                 .text
80                 .align  5
81 LEAF(spurious_interrupt)
82                 /*
83                  * Someone tried to fool us by sending an interrupt but we
84                  * couldn't find a cause for it.
85                  */
86                 lui     t1,%hi(spurious_count)
87                 lw      t0,%lo(spurious_count)(t1)
88                 addiu   t0,1
89                 j       ret_from_irq
90                  sw      t0,%lo(spurious_count)(t1)
91                 END(spurious_interrupt)
94  * Build a default exception handler for the exceptions that don't need
95  * special handlers.  If you didn't know yet - I *like* playing games with
96  * the C preprocessor ...
97  */
98 #define __BUILD_clear_none(exception)
99 #define __BUILD_clear_sti(exception)                                    \
100                 STI
101 #define __BUILD_clear_cli(exception)                                    \
102                 CLI
103 #define __BUILD_clear_fpe(exception)                                    \
104                 cfc1    a1,fcr31;                                       \
105                 li      a2,~(0x3f<<12);                                 \
106                 and     a2,a1;                                          \
107                 ctc1    a2,fcr31;                                       \
108                 STI
109 #define __BUILD_clear_ade(exception)                                    \
110                 MFC0    t0,CP0_BADVADDR;                                \
111                 REG_S   t0,PT_BVADDR(sp);                               \
112                 KMODE
113 #define __BUILD_silent(exception)
115 #define fmt "Got %s at %08lx.\n"
117 #define __BUILD_verbose(exception)                                      \
118                 la      a1,8f;                                          \
119                 TEXT    (#exception);                                   \
120                 REG_L   a2,PT_EPC(sp);                                  \
121                 PRINT(fmt)
122 #define __BUILD_count(exception)                                        \
123                 .set    reorder;                                        \
124                 lw      t0,exception_count_##exception;                 \
125                 addiu   t0, 1;                                          \
126                 sw      t0,exception_count_##exception;                 \
127                 .set    noreorder;                                      \
128                 .data;                                                  \
129 EXPORT(exception_count_##exception);                                    \
130                 .word   0;                                              \
131                 .previous;
132 #define BUILD_HANDLER(exception,handler,clear,verbose)                  \
133                 .align  5;                                              \
134                 NESTED(handle_##exception, PT_SIZE, sp);                \
135                 .set    noat;                                           \
136                 SAVE_ALL;                                               \
137                 __BUILD_clear_##clear(exception);                       \
138                 .set    at;                                             \
139                 __BUILD_##verbose(exception);                           \
140                 jal     do_##handler;                                   \
141                  move   a0,sp;                                          \
142                 j       ret_from_sys_call;                              \
143                  nop;                                                   \
144                 END(handle_##exception)
146                 BUILD_HANDLER(adel,ade,ade,silent)              /* #4  */
147                 BUILD_HANDLER(ades,ade,ade,silent)              /* #5  */
148                 BUILD_HANDLER(ibe,ibe,cli,verbose)              /* #6  */
149                 BUILD_HANDLER(dbe,dbe,cli,silent)               /* #7  */
150                 BUILD_HANDLER(bp,bp,sti,silent)                 /* #9  */
151                 BUILD_HANDLER(ri,ri,sti,silent)                 /* #10 */
152                 BUILD_HANDLER(cpu,cpu,sti,silent)               /* #11 */
153                 BUILD_HANDLER(ov,ov,sti,silent)                 /* #12 */
154                 BUILD_HANDLER(tr,tr,sti,silent)                 /* #13 */
155                 BUILD_HANDLER(fpe,fpe,fpe,silent)               /* #15 */
156                 BUILD_HANDLER(watch,watch,sti,verbose)          /* #23 */
157                 BUILD_HANDLER(reserved,reserved,sti,verbose)    /* others */
160  * Table of syscalls
161  */
162                 .data
163                 .align  PTRLOG
164 EXPORT(sys_call_table)
165 #define SYS(call, narg) PTR call
167                 /* Reserved space for all SVR4 syscalls. */
168                 .space  (1000)*PTRSIZE
170 #ifdef CONFIG_BINFMT_IRIX
171                 /* 32bit IRIX5 system calls. */
172 #include "irix5sys.h"
173 #else
174                 .space  (1000)*PTRSIZE          /* No IRIX syscalls */
175 #endif
177                 /* Reserved space for all the BSD43 and POSIX syscalls. */
178                 .space  (2000)*PTRSIZE
180                 /* Linux flavoured syscalls. */
181 #include "syscalls.h"
184  * Number of arguments of each syscall
185  */
186 EXPORT(sys_narg_table)
187 #undef SYS
188 #define SYS(call, narg) .byte narg
190                 /* Reserved space for all SVR4 flavoured syscalls. */
191                 .space  (1000)
193 #ifdef CONFIG_BINFMT_IRIX
194                 /* 32bit IRIX5 system calls. */
195 #include "irix5sys.h"
196 #else
197                 .space  (1000)                  /* No IRIX syscalls */
198 #endif
200                 /* Reserved space for all the BSD43 and POSIX syscalls. */
201                 .space  (2000)
203                 /* Linux flavoured syscalls. */
204 #include "syscalls.h"