Ok. I didn't make 2.4.0 in 2000. Tough. I tried, but we had some
[davej-history.git] / arch / mips / kernel / entry.S
blobbc56db51bc0771219c7543ec2100a970b5fcc001
1 /* $Id: entry.S,v 1.19 1999/12/08 22:05:10 harald Exp $
2  *
3  * Low level exception handling
4  *
5  * This file is subject to the terms and conditions of the GNU General Public
6  * License.  See the file "COPYING" in the main directory of this archive
7  * for more details.
8  *
9  * Copyright (C) 1994 - 2000 by Ralf Baechle
10  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
11  */
12 #include <linux/config.h>
13 #include <linux/sys.h>
15 #include <asm/asm.h>
16 #include <asm/current.h>
17 #include <asm/errno.h>
18 #include <asm/mipsregs.h>
19 #include <asm/page.h>
20 #include <asm/pgtable.h>
21 #include <asm/stackframe.h>
22 #include <asm/processor.h>
23 #include <asm/regdef.h>
24 #include <asm/fpregdef.h>
25 #include <asm/unistd.h>
26 #include <asm/isadep.h>
28                 .text
29                 .align 4
30                 .set    push
31                 .set    reorder
32 EXPORT(ret_from_fork)
33                  move   a0, v0                  # prev
34                 jal     schedule_tail
35                 j       ret_from_sys_call
37 EXPORT(handle_softirq)
38                 jal     do_softirq
39                 b       9f
41 reschedule:     jal     schedule 
43 EXPORT(ret_from_sys_call)
44 EXPORT(ret_from_irq)
45                 .type   ret_from_irq,@function
46                 lw      t0, irq_stat            # softirq_active
47                 lw      t1, irq_stat+4          # softirq_mask.  unused delay slot
48                 and     t0, t1
49                 bnez    t0, handle_softirq
52 9:              lw      t0,PT_STATUS(sp)        # returning to kernel mode?
53                 lw      t2, TASK_NEED_RESCHED($28)
54                 andi    t1, t0, KU_USER
55                 beqz    t1, return              # -> yes
56                 bnez    t2, reschedule
57                 lw      v0, TASK_SIGPENDING($28)
58                  move   a0, zero
59                 beqz    v0, return
60                  move   a1, sp
61                 jal     do_signal
63 EXPORT(return)  .set    noat
64                 RESTORE_ALL_AND_RET
65                 .set    at
68  * Common spurious interrupt handler.
69  */
70                 .text
71                 .align  5
72 LEAF(spurious_interrupt)
73                 /*
74                  * Someone tried to fool us by sending an interrupt but we
75                  * couldn't find a cause for it.
76                  */
77                 lui     t1,%hi(spurious_count)
78                 .set    reorder
79                 lw      t0,%lo(spurious_count)(t1)
80                 .set    noreorder
81                 addiu   t0,1
82                 j       ret_from_irq
83                  sw      t0,%lo(spurious_count)(t1)
84                 END(spurious_interrupt)
87  * Build a default exception handler for the exceptions that don't need
88  * special handlers.  If you didn't know yet - I *like* playing games with
89  * the C preprocessor ...
90  */
91 #define __BUILD_clear_none(exception)
92 #define __BUILD_clear_sti(exception)                                    \
93                 STI
94 #define __BUILD_clear_cli(exception)                                    \
95                 CLI
96 #define __BUILD_clear_fpe(exception)                                    \
97                 cfc1    a1,fcr31;                                       \
98                 li      a2,~(0x3f<<12);                                 \
99                 and     a2,a1;                                          \
100                 ctc1    a2,fcr31;                                       \
101                 STI
102 #define __BUILD_clear_ade(exception)                                    \
103                 .set    reorder;                                                \
104                 MFC0    t0,CP0_BADVADDR;                                \
105                 .set    noreorder;                                      \
106                 REG_S   t0,PT_BVADDR(sp);                               \
107                 KMODE
108 #define __BUILD_silent(exception)
110 #define fmt "Got %s at %08lx.\n"
112 #define __BUILD_verbose(exception)                                      \
113                 la      a1,8f;                                          \
114                 TEXT    (#exception);                                   \
115                 REG_L   a2,PT_EPC(sp);                                  \
116                 PRINT(fmt)
117 #define __BUILD_count(exception)                                        \
118                 .set    reorder;                                        \
119                 lw      t0,exception_count_##exception;                 \
120                 .set    noreorder;                                      \
121                 addiu   t0, 1;                                          \
122                 sw      t0,exception_count_##exception;                 \
123                 .data;                                                  \
124 EXPORT(exception_count_##exception);                                    \
125                 .word   0;                                              \
126                 .previous;
127 #define BUILD_HANDLER(exception,handler,clear,verbose)                  \
128                 .align  5;                                              \
129                 NESTED(handle_##exception, PT_SIZE, sp);                \
130                 .set    noat;                                           \
131                 SAVE_ALL;                                               \
132                 __BUILD_clear_##clear(exception);                       \
133                 .set    at;                                             \
134                 __BUILD_##verbose(exception);                           \
135                 jal     do_##handler;                                   \
136                  move   a0,sp;                                          \
137                 j       ret_from_sys_call;                              \
138                  nop;                                                   \
139                 END(handle_##exception)
141                 BUILD_HANDLER(adel,ade,ade,silent)              /* #4  */
142                 BUILD_HANDLER(ades,ade,ade,silent)              /* #5  */
143                 BUILD_HANDLER(ibe,ibe,cli,verbose)              /* #6  */
144                 BUILD_HANDLER(dbe,dbe,cli,silent)               /* #7  */
145                 BUILD_HANDLER(bp,bp,sti,silent)                 /* #9  */
146                 BUILD_HANDLER(ri,ri,sti,silent)                 /* #10 */
147                 BUILD_HANDLER(cpu,cpu,sti,silent)               /* #11 */
148                 BUILD_HANDLER(ov,ov,sti,silent)                 /* #12 */
149                 BUILD_HANDLER(tr,tr,sti,silent)                 /* #13 */
150                 BUILD_HANDLER(fpe,fpe,fpe,silent)               /* #15 */
151                 BUILD_HANDLER(watch,watch,sti,verbose)          /* #23 */
152                 BUILD_HANDLER(reserved,reserved,sti,verbose)    /* others */
154                 .set    pop
157  * Table of syscalls
158  */
159                 .data
160                 .align  PTRLOG
161 EXPORT(sys_call_table)
162 #define SYS(call, narg) PTR call
164                 /* Reserved space for all SVR4 syscalls. */
165                 .space  (1000)*PTRSIZE
167 #ifdef CONFIG_BINFMT_IRIX
168                 /* 32bit IRIX5 system calls. */
169 #include "irix5sys.h"
170 #else
171                 .space  (1000)*PTRSIZE          /* No IRIX syscalls */
172 #endif
174                 /* Reserved space for all the BSD43 and POSIX syscalls. */
175                 .space  (2000)*PTRSIZE
177                 /* Linux flavoured syscalls. */
178 #include "syscalls.h"
181  * Number of arguments of each syscall
182  */
183 EXPORT(sys_narg_table)
184 #undef SYS
185 #define SYS(call, narg) .byte narg
187                 /* Reserved space for all SVR4 flavoured syscalls. */
188                 .space  (1000)
190 #ifdef CONFIG_BINFMT_IRIX
191                 /* 32bit IRIX5 system calls. */
192 #include "irix5sys.h"
193 #else
194                 .space  (1000)                  /* No IRIX syscalls */
195 #endif
197                 /* Reserved space for all the BSD43 and POSIX syscalls. */
198                 .space  (2000)
200                 /* Linux flavoured syscalls. */
201 #include "syscalls.h"