comparison src/audio/mint/SDL_mintaudio_it.S @ 4380:66aea42c3541 SDL-1.2

Adapt audio interrupts for Coldfire
author Patrice Mandin <patmandin@gmail.com>
date Sat, 07 Nov 2009 20:45:45 +0000
parents a1b03ba2fcd0
children
comparison
equal deleted inserted replaced
4379:2da8b4494ceb 4380:66aea42c3541
53 */ 53 */
54 54
55 #define savptr 0x4a2 55 #define savptr 0x4a2
56 #define savamt 0x46 56 #define savamt 0x46
57 57
58 /*--- Save/restore FPU context ---*/
59
60 #if defined(__mcoldfire__)
61
62 #define SAVE_FPU_CONTEXT \
63 lea sp@(-216),sp; \
64 fsave sp@; \
65 fmovel fpiar,sp@-; \
66 lea sp@(-64),sp; \
67 fmovemd fp0-fp7,sp@
68
69 #define RESTORE_FPU_CONTEXT \
70 fmovemd sp@,fp0-fp7; \
71 lea sp@(64),sp; \
72 fmovel sp@+,fpiar; \
73 frestore sp@; \
74 lea sp@(216),sp
75
76 #else
77
78 #define SAVE_FPU_CONTEXT \
79 .chip 68k/68881; \
80 fsave sp@-; \
81 fmoveml fpcr/fpsr/fpiar,sp@-; \
82 fmovemx fp0-fp7,sp@-; \
83 .chip 68k
84
85 #define RESTORE_FPU_CONTEXT \
86 .chip 68k/68881; \
87 fmovemx sp@+,fp0-fp7; \
88 fmoveml sp@+,fpcr/fpsr/fpiar; \
89 frestore sp@+; \
90 .chip 68k
91
92 #endif
93
58 /*--- Xbios interrupt vector to measure Falcon external clock ---*/ 94 /*--- Xbios interrupt vector to measure Falcon external clock ---*/
59 95
60 _SDL_MintAudio_XbiosInterruptMeasureClock: /* 1 mS */ 96 _SDL_MintAudio_XbiosInterruptMeasureClock: /* 1 mS */
61 97 #if defined(__mcoldfire__)
98 movel d0,sp@-
99
100 moveql #0,d0
101 btst d0,0xFFFF8901:w /* state DMA sound */
102 #else
62 btst #0,0xFFFF8901:w /* state DMA sound */ 103 btst #0,0xFFFF8901:w /* state DMA sound */
104 #endif
63 beqs SDL_MintAudio_EndIntMeasure 105 beqs SDL_MintAudio_EndIntMeasure
64 addql #1,_SDL_MintAudio_clocktics 106 addql #1,_SDL_MintAudio_clocktics
65 SDL_MintAudio_EndIntMeasure: 107 SDL_MintAudio_EndIntMeasure:
108 #if defined(__mcoldfire__)
109 moveql #5,d0
110 bclr d0,0xFFFFFA0F:w /* Clear service bit */
111
112 movel sp@+,d0
113 #else
66 bclr #5,0xFFFFFA0F:w /* Clear service bit */ 114 bclr #5,0xFFFFFA0F:w /* Clear service bit */
115 #endif
67 rte 116 rte
68 117
69 /*--- Xbios interrupt vector ---*/ 118 /*--- Xbios interrupt vector ---*/
70 119
71 _SDL_MintAudio_XbiosInterrupt: 120 _SDL_MintAudio_XbiosInterrupt:
121 #if defined(__mcoldfire__)
122 lea sp@(-60),sp
123 moveml d0-d7/a0-a6,sp@
124 #else
125 moveml d0-d7/a0-a6,sp@-
126 #endif
72 127
73 /* Reenable interrupts, so other interrupts can work */ 128 /* Reenable interrupts, so other interrupts can work */
74 movew #0x2300,sr 129 movew #0x2300,sr
75 130
76 /* Clear service bit, so other MFP interrupts can work */ 131 /* Clear service bit, so other MFP interrupts can work */
132 #if defined(__mcoldfire__)
133 moveql #5,d0
134 bclr d0,0xfffffa0f:w
135 #else
77 bclr #5,0xfffffa0f:w 136 bclr #5,0xfffffa0f:w
137 #endif
78 138
79 /* Check if we are not already running */ 139 /* Check if we are not already running */
80 tstw _SDL_MintAudio_mutex 140 tstw _SDL_MintAudio_mutex
81 bne SDL_MintAudio_XbiosEnd 141 bne SDL_MintAudio_XbiosEnd
142
143 #if defined(__mcoldfire__)
144 movew _SDL_MintAudio_mutex,d0
145 notl d0
146 movew d0,_SDL_MintAudio_mutex
147
148 movew _SDL_MintAudio_numbuf,d1
149 eorl #1,d1
150 movew d1,_SDL_MintAudio_numbuf
151 #else
82 notw _SDL_MintAudio_mutex 152 notw _SDL_MintAudio_mutex
83 153
84 /* Swap buffers */ 154 /* Swap buffers */
85 eorw #1,_SDL_MintAudio_numbuf 155 eorw #1,_SDL_MintAudio_numbuf
86 156 #endif
87 moveml d0-d7/a0-a6,sp@- 157
88
89 /* Save FPU if needed */ 158 /* Save FPU if needed */
90 tstw _SDL_MintAudio_hasfpu 159 tstw _SDL_MintAudio_hasfpu
91 beqs SDL_MintAudio_Xbios_nofpu1 160 beqs SDL_MintAudio_Xbios_nofpu1
92 .chip 68060 161 SAVE_FPU_CONTEXT
93 fsave sp@-
94 fmoveml fpcr/fpsr/fpiar,sp@-
95 fmovemx fp0-fp7,sp@-
96 .chip 68000
97 SDL_MintAudio_Xbios_nofpu1: 162 SDL_MintAudio_Xbios_nofpu1:
98 163
99 /* Callback */ 164 /* Callback */
100 jsr _SDL_MintAudio_Callback 165 jsr _SDL_MintAudio_Callback
101 166
102 /* Restore FPU if needed */ 167 /* Restore FPU if needed */
103 tstw _SDL_MintAudio_hasfpu 168 tstw _SDL_MintAudio_hasfpu
104 beqs SDL_MintAudio_Xbios_nofpu2 169 beqs SDL_MintAudio_Xbios_nofpu2
105 .chip 68060 170 RESTORE_FPU_CONTEXT
106 fmovemx sp@+,fp0-fp7
107 fmoveml sp@+,fpcr/fpsr/fpiar
108 frestore sp@+
109 .chip 68000
110 SDL_MintAudio_Xbios_nofpu2: 171 SDL_MintAudio_Xbios_nofpu2:
111 172
112 /* Reserve space for registers */ 173 /* Reserve space for registers */
174 #if defined(__mcoldfire__)
175 movel #savamt,d0
176 subl d0,savptr
177 #else
113 subl #savamt,savptr 178 subl #savamt,savptr
179 #endif
114 180
115 /* Set new buffer */ 181 /* Set new buffer */
116 182
117 moveq #0,d0 183 moveq #0,d0
118 movel _SDL_MintAudio_audiosize,d1 184 movel _SDL_MintAudio_audiosize,d1
130 movew #131,sp@- 196 movew #131,sp@-
131 trap #14 197 trap #14
132 lea sp@(12),sp 198 lea sp@(12),sp
133 199
134 /* Restore registers space */ 200 /* Restore registers space */
201 #if defined(__mcoldfire__)
202 movel #savamt,d0
203 addl d0,savptr
204 #else
135 addl #savamt,savptr 205 addl #savamt,savptr
136 206 #endif
137 moveml sp@+,d0-d7/a0-a6
138 207
139 clrw _SDL_MintAudio_mutex 208 clrw _SDL_MintAudio_mutex
140 SDL_MintAudio_XbiosEnd: 209 SDL_MintAudio_XbiosEnd:
210 #if defined(__mcoldfire__)
211 moveml sp@,d0-d7/a0-a6
212 lea sp@(60),sp
213 #else
214 moveml sp@+,d0-d7/a0-a6
215 #endif
141 rte 216 rte
142 217
143 /*--- DMA 8 bits interrupt vector ---*/ 218 /*--- DMA 8 bits interrupt vector ---*/
144 219
145 _SDL_MintAudio_Dma8Interrupt: 220 _SDL_MintAudio_Dma8Interrupt:
221 #if defined(__mcoldfire__)
222 lea sp@(-16),sp
223 moveml d0-d1/a0-a1,sp@
224 #else
225 moveml d0-d1/a0-a1,sp@-
226 #endif
146 227
147 /* Reenable interrupts, so other interrupts can work */ 228 /* Reenable interrupts, so other interrupts can work */
148 movew #0x2300,sr 229 movew #0x2300,sr
149 230
150 /* Clear service bit, so other MFP interrupts can work */ 231 /* Clear service bit, so other MFP interrupts can work */
232 #if defined(__mcoldfire__)
233 moveql #5,d0
234 bclr d0,0xfffffa0f:w
235 #else
151 bclr #5,0xfffffa0f:w 236 bclr #5,0xfffffa0f:w
152 237 #endif
153 /* Check if we are not already running */ 238 /* Check if we are not already running */
154 tstw _SDL_MintAudio_mutex 239 tstw _SDL_MintAudio_mutex
155 bne SDL_MintAudio_Dma8End 240 bne SDL_MintAudio_Dma8End
241
242 #if defined(__mcoldfire__)
243 movew _SDL_MintAudio_mutex,d0
244 notl d0
245 movew d0,_SDL_MintAudio_mutex
246
247 movew _SDL_MintAudio_numbuf,d1
248 eorl #1,d1
249 movew d1,_SDL_MintAudio_numbuf
250 #else
156 notw _SDL_MintAudio_mutex 251 notw _SDL_MintAudio_mutex
157 252
158 /* Swap buffers */ 253 /* Swap buffers */
159 eorw #1,_SDL_MintAudio_numbuf 254 eorw #1,_SDL_MintAudio_numbuf
160 255 #endif
161 moveml d0-d1/a0-a1,sp@-
162 256
163 /* Save FPU if needed */ 257 /* Save FPU if needed */
164 tstw _SDL_MintAudio_hasfpu 258 tstw _SDL_MintAudio_hasfpu
165 beqs SDL_MintAudio_Dma8_nofpu1 259 beqs SDL_MintAudio_Dma8_nofpu1
166 .chip 68060 260 SAVE_FPU_CONTEXT
167 fsave sp@-
168 fmoveml fpcr/fpsr/fpiar,sp@-
169 fmovemx fp0-fp7,sp@-
170 .chip 68000
171 SDL_MintAudio_Dma8_nofpu1: 261 SDL_MintAudio_Dma8_nofpu1:
172 262
173 /* Callback */ 263 /* Callback */
174 jsr _SDL_MintAudio_Callback 264 jsr _SDL_MintAudio_Callback
175 265
176 /* Restore FPU if needed */ 266 /* Restore FPU if needed */
177 tstw _SDL_MintAudio_hasfpu 267 tstw _SDL_MintAudio_hasfpu
178 beqs SDL_MintAudio_Dma8_nofpu2 268 beqs SDL_MintAudio_Dma8_nofpu2
179 .chip 68060 269 RESTORE_FPU_CONTEXT
180 fmovemx sp@+,fp0-fp7
181 fmoveml sp@+,fpcr/fpsr/fpiar
182 frestore sp@+
183 .chip 68000
184 SDL_MintAudio_Dma8_nofpu2: 270 SDL_MintAudio_Dma8_nofpu2:
185 271
186 /* Set new buffer */ 272 /* Set new buffer */
187 273
188 moveq #0,d0 274 moveq #0,d0
189 275
190 movew _SDL_MintAudio_numbuf,d0 276 movew _SDL_MintAudio_numbuf,d0
191 lslw #2,d0 277 lsll #2,d0
192 lea _SDL_MintAudio_audiobuf,a0 278 lea _SDL_MintAudio_audiobuf,a0
193 movel a0@(d0:w),d1 279 movel a0@(d0:l),d1
194 280
195 /* Modify DMA addresses */ 281 /* Modify DMA addresses */
196 lea 0xffff8900:w,a0 282 lea 0xffff8900:w,a0
197 283
198 moveb d1,a0@(0x07) /* Start address */ 284 movel d1,d0
199 rorl #8,d1 285
200 moveb d1,a0@(0x05) 286 moveb d0,a0@(0x07) /* Start address */
201 rorl #8,d1 287 lsrl #8,d0
202 moveb d1,a0@(0x03) 288 moveb d0,a0@(0x05)
203 swap d1 289 lsrl #8,d0
290 moveb d0,a0@(0x03)
204 291
205 addl _SDL_MintAudio_audiosize,d1 292 addl _SDL_MintAudio_audiosize,d1
206 293
207 moveb d1,a0@(0x13) /* End address */ 294 movel d1,d0
208 rorl #8,d1 295
209 moveb d1,a0@(0x11) 296 moveb d0,a0@(0x13) /* End address */
210 rorl #8,d1 297 lsrl #8,d0
211 moveb d1,a0@(0x0f) 298 moveb d0,a0@(0x11)
212 299 lsrl #8,d0
213 moveml sp@+,d0-d1/a0-a1 300 moveb d0,a0@(0x0f)
214 301
215 clrw _SDL_MintAudio_mutex 302 clrw _SDL_MintAudio_mutex
216 SDL_MintAudio_Dma8End: 303 SDL_MintAudio_Dma8End:
304 #if defined(__mcoldfire__)
305 moveml sp@,d0-d1/a0-a1
306 lea sp@(16),sp
307 #else
308 moveml sp@+,d0-d1/a0-a1
309 #endif
217 rte 310 rte
218 311
219 /*--- STFA interrupt vector ---*/ 312 /*--- STFA interrupt vector ---*/
220 313
221 STFA_SOUND_START = 6 314 STFA_SOUND_START = 6
222 STFA_SOUND_END = STFA_SOUND_START+8 315 STFA_SOUND_END = STFA_SOUND_START+8
223 316
224 _SDL_MintAudio_StfaInterrupt: 317 _SDL_MintAudio_StfaInterrupt:
225
226 /* Reenable interrupts, so other interrupts can work */ 318 /* Reenable interrupts, so other interrupts can work */
227 movew #0x2300,sr 319 movew #0x2300,sr
228 320
229 /* Check if we are not already running */ 321 /* Check if we are not already running */
230 tstw _SDL_MintAudio_mutex 322 tstw _SDL_MintAudio_mutex
323
324 #if defined(__mcoldfire__)
325 bne SDL_MintAudio_StfaEnd
326
327 lea sp@(-60),sp
328 moveml d0-d7/a0-a6,sp@
329
330 movew _SDL_MintAudio_mutex,d0
331 notl d0
332 movew d0,_SDL_MintAudio_mutex
333
334 movew _SDL_MintAudio_numbuf,d1
335 eorl #1,d1
336 movew d1,_SDL_MintAudio_numbuf
337 #else
231 bnes SDL_MintAudio_StfaEnd 338 bnes SDL_MintAudio_StfaEnd
339
340 moveml d0-d7/a0-a6,sp@-
341
232 notw _SDL_MintAudio_mutex 342 notw _SDL_MintAudio_mutex
233 343
234 /* Swap buffers */ 344 /* Swap buffers */
235 eorw #1,_SDL_MintAudio_numbuf 345 eorw #1,_SDL_MintAudio_numbuf
236 346 #endif
237 moveml d0-d7/a0-a6,sp@- 347
238
239 /* Save FPU if needed */ 348 /* Save FPU if needed */
240 tstw _SDL_MintAudio_hasfpu 349 tstw _SDL_MintAudio_hasfpu
241 beqs SDL_MintAudio_Stfa_nofpu1 350 beqs SDL_MintAudio_Stfa_nofpu1
242 .chip 68060 351 SAVE_FPU_CONTEXT
243 fsave sp@-
244 fmoveml fpcr/fpsr/fpiar,sp@-
245 fmovemx fp0-fp7,sp@-
246 .chip 68000
247 SDL_MintAudio_Stfa_nofpu1: 352 SDL_MintAudio_Stfa_nofpu1:
248 353
249 /* Callback */ 354 /* Callback */
250 jsr _SDL_MintAudio_Callback 355 jsr _SDL_MintAudio_Callback
251 356
252 /* Restore FPU if needed */ 357 /* Restore FPU if needed */
253 tstw _SDL_MintAudio_hasfpu 358 tstw _SDL_MintAudio_hasfpu
254 beqs SDL_MintAudio_Stfa_nofpu2 359 beqs SDL_MintAudio_Stfa_nofpu2
255 .chip 68060 360 RESTORE_FPU_CONTEXT
256 fmovemx sp@+,fp0-fp7
257 fmoveml sp@+,fpcr/fpsr/fpiar
258 frestore sp@+
259 .chip 68000
260 SDL_MintAudio_Stfa_nofpu2: 361 SDL_MintAudio_Stfa_nofpu2:
261 362
262 /* Set new buffer */ 363 /* Set new buffer */
263 364
264 moveq #0,d0 365 moveq #0,d0
265 movel _SDL_MintAudio_stfa,a1 366 movel _SDL_MintAudio_stfa,a1
266 367
267 movew _SDL_MintAudio_numbuf,d0 368 movew _SDL_MintAudio_numbuf,d0
268 lslw #2,d0 369 lsll #2,d0
269 lea _SDL_MintAudio_audiobuf,a0 370 lea _SDL_MintAudio_audiobuf,a0
270 movel a0@(d0:w),d1 371 movel a0@(d0:l),d1
271 372
272 /* Modify STFA replay buffers */ 373 /* Modify STFA replay buffers */
273 movel d1,a1@(STFA_SOUND_START) 374 movel d1,a1@(STFA_SOUND_START)
274 addl _SDL_MintAudio_audiosize,d1 375 addl _SDL_MintAudio_audiosize,d1
275 movel d1,a1@(STFA_SOUND_END) 376 movel d1,a1@(STFA_SOUND_END)
276 377
378 #if defined(__mcoldfire__)
379 moveml sp@,d0-d7/a0-a6
380 lea sp@(60),sp
381 #else
277 moveml sp@+,d0-d7/a0-a6 382 moveml sp@+,d0-d7/a0-a6
278 383 #endif
279 clrw _SDL_MintAudio_mutex 384 clrw _SDL_MintAudio_mutex
280 SDL_MintAudio_StfaEnd: 385 SDL_MintAudio_StfaEnd:
281 rte 386 rte