revert between 56095 -> 55830 in arch
[AROS.git] / arch / .unmaintained / m68k-linux / exec / sighandler.s
blob2f045bf5aef5752155a81d36147eed481e3ce21c
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Signal handler for Linux/m68k
6 Lang: english
7 */
9 #include "machine.i"
11 #ifdef TEST
12 # undef Dispatch
13 #endif
15 #define FirstArg 4+(2*4)
16 #define signum FirstArg+0
17 #define code FirstArg+4
18 #define sc FirstArg+8
20 .text
21 .align 2
22 .globl AROS_CDEFNAME(linux_sighandler)
23 .type AROS_CDEFNAME(linux_sighandler),@function
24 AROS_CDEFNAME(linux_sighandler):
25 /* save regs */
26 movem.l %a5-%a6,-(%sp)
27 #ifdef __PIC__
28 lea (%pc,_GLOBAL_OFFSET_TABLE_@GOTPC),%a5
29 movea.l supervisor@GOT(%a5),%a0
30 #else
31 lea supervisor,%a0
32 #endif
33 #ifndef TEST
34 /* Already in signal handler... Not good */
35 tst.l (%a0)
36 jbne .exit
37 #endif
38 /* Increase supervisor count */
39 addq.l #1,(%a0)
40 /* Call the Amiga interrupt server for this signal */
41 move.l signum(%sp),-(%sp)
42 #ifdef __PIC__
43 bsr.l AROS_CSYMNAME(call_inthandlers)@PLTPC
44 #else
45 jbsr AROS_CSYMNAME(call_inthandlers)
46 #endif
47 addq.w #4,%sp
48 #ifdef __PIC__
49 movea.l SysBase@GOT(%a5),%a1
50 movea.l (%a1),%a6
51 #else
52 movea.l SysBase,%a6
53 #endif
54 #ifdef TEST
55 tst.l TDNestCnt(%a6)
56 jbge .exitsup
57 #else
58 /* Dispatch pending? */
59 btst #7,AttnResched(%a6)
60 jbeq .exitsup
61 /* Clear flag */
62 bclr #7,AttnResched(%a6)
63 #endif
64 /* If there's no current task, we don't need to save
65 the registers */
66 movea.l ThisTask(%a6),%a1
67 jbeq .nosave
68 /* Don's save the registers if the task was removed,
69 it will never get to run again. */
70 cmp.b #TS_REMOVED,tc_State(%a1)
71 jbeq .nosave
72 movea.l sc(%sp),%a0
73 move.l sc_usp(%a0),tc_SPReg(%a1)
74 movea.l tc_UnionETask(%a1),%a1
75 movea.l iet_Context(%a1),%a1
76 /* Save all registers in
77 SysBase->ThisTask->tc_UnionETask->iet_Context */
78 #if !UseRegisterArgs
79 pea sc_size.w
80 #else
81 move.l #sc_size,%d0
82 #endif
83 move.l %a1,-(%sp)
84 move.l %a0,-(%sp)
85 jsr CopyMem(%a6)
86 movea.l (%sp)+,%a0
87 movea.l (%sp)+,%a1
88 #if !UseRegisterArgs
89 addq.w #4,%sp
90 #endif
91 movem.l (%sp)+,%a5-%a6
92 movem.l %d2-%d7/%a2-%a6,regs(%a1)
93 movem.l %a5-%a6,-(%sp)
94 fmovem.x %fp2-%fp7,fpregs(%a1)
95 #ifdef __PIC__
96 lea (%pc,_GLOBAL_OFFSET_TABLE_@GOTPC),%a5
97 movea.l SysBase@GOT(%a5),%a6
98 movea.l (%a6),%a6
99 #else
100 movea.l SysBase,%a6
101 #endif
102 .nosave:
103 /* Call Dispatch() to do its work */
104 #ifdef TEST
105 # ifdef __PIC__
106 bsr.l AROS_CSYMNAME(Dispatch)@PLTPC
107 # else
108 jbsr AROS_CSYMNAME(Dispatch)
109 # endif
110 #else
111 # if !UseRegisterArgs
112 move.l %a6,-(%sp)
113 # endif
114 jsr Dispatch(%a6)
115 # if !UseRegisterArgs
116 move.l (%sp)+,%a6
117 # endif
118 #endif
119 /* We have switched tasks, restore the registers */
120 movea.l ThisTask(%a6),%a1
121 movea.l tc_UnionETask(%a1),%a1
122 movea.l iet_Context(%a1),%a0
123 movea.l sc(%sp),%a1
124 /* Is this the first time? */
125 tst.l sc_usp(%a0)
126 jbeq .nocopy
127 #if !UseRegisterArgs
128 pea sc_size.w
129 #else
130 move.l #sc_size,%d0
131 #endif
132 move.l %a1,-(%sp)
133 move.l %a0,-(%sp)
134 jsr CopyMem(%a6)
135 move.l (%sp)+,%a0
136 move.l (%sp)+,%a1
137 #if !UseRegisterArgs
138 addq.w #4,%sp
139 #endif
140 fmovem.x fpregs(%a0),%fp2-%fp7
141 jbra .cont
142 .nocopy:
143 move.l sc_d0(%a0),sc_d0(%a1)
144 move.l sc_d1(%a0),sc_d1(%a1)
145 move.l sc_a0(%a0),sc_a0(%a1)
146 move.l sc_a1(%a0),sc_a1(%a1)
147 move.l sc_pc(%a0),sc_pc(%a1)
148 .cont:
149 movem.l regs(%a0),%d2-%d7/%a2-%a6
150 addq.w #8,%sp
151 movem.l %a5-%a6,-(%sp)
152 #ifdef __PIC__
153 lea (%pc,_GLOBAL_OFFSET_TABLE_@GOTPC),%a5
154 movea.l SysBase@GOT(%a5),%a0
155 movea.l (%a0),%a6
156 #else
157 movea.l SysBase,%a6
158 #endif
159 move.l ThisTask(%a6),%a0
160 move.l tc_SPReg(%a0),sc_usp(%a1)
161 /* Are interrupts enabled or disable for this task? */
162 tst.b IDNestCnt(%a6)
163 jblt .unmask
164 moveq.l #-1,%d0
165 move.l %d0,sc_mask(%a1)
166 jbra .except
167 .unmask:
168 clr.l sc_mask(%a1)
169 .except:
170 /* Is there an exception to be processed? */
171 #ifndef TEST
172 btst #TB_EXCEPT,tc_Flags(%a0)
173 jbeq .exitsup
174 # if !UseRegisterArgs
175 move.l %a6,-(%sp)
176 # endif
177 jsr Disable(%a6)
178 jsr Exception(%a6)
179 jsr Enable(%a6)
180 # if !UseRegisterArgs
181 move.l (%sp)+,%a6
182 # endif
183 #endif
184 .exitsup:
185 #ifndef TEST
186 # ifdef __PIC__
187 movea.l supervisor@GOT(%a5),%a0
188 # else
189 lea supervisor,%a0
190 # endif
191 /* Decrease supervisor nest count */
192 subq.l #1,(%a0)
193 #else
194 bset #15,SysFlags(%a6)
195 #endif
196 .exit:
197 movem.l (%sp)+,%a5-%a6