Adapt audio interrupts for Coldfire SDL-1.2
authorPatrice Mandin
Sat, 07 Nov 2009 20:45:45 +0000
branchSDL-1.2
changeset 438066aea42c3541
parent 4379 2da8b4494ceb
child 4381 5425a6fbacf8
Adapt audio interrupts for Coldfire
src/audio/mint/SDL_mintaudio_it.S
     1.1 --- a/src/audio/mint/SDL_mintaudio_it.S	Sat Nov 07 12:20:01 2009 +0000
     1.2 +++ b/src/audio/mint/SDL_mintaudio_it.S	Sat Nov 07 20:45:45 2009 +0000
     1.3 @@ -55,45 +55,110 @@
     1.4  #define	savptr	0x4a2
     1.5  #define	savamt	0x46
     1.6  
     1.7 +/*--- Save/restore FPU context ---*/
     1.8 +
     1.9 +#if defined(__mcoldfire__)
    1.10 +
    1.11 +#define SAVE_FPU_CONTEXT \
    1.12 +	lea		sp@(-216),sp;	\
    1.13 +	fsave		sp@;	\
    1.14 +	fmovel		fpiar,sp@-;	\
    1.15 +	lea		sp@(-64),sp;	\
    1.16 +	fmovemd	fp0-fp7,sp@
    1.17 +
    1.18 +#define RESTORE_FPU_CONTEXT	\
    1.19 +	fmovemd		sp@,fp0-fp7;	\
    1.20 +	lea		sp@(64),sp;	\
    1.21 +	fmovel		sp@+,fpiar;	\
    1.22 +	frestore	sp@;	\
    1.23 +	lea		sp@(216),sp
    1.24 +
    1.25 +#else
    1.26 +
    1.27 +#define SAVE_FPU_CONTEXT	\
    1.28 +	.chip	68k/68881;	\
    1.29 +	fsave	sp@-;	\
    1.30 +	fmoveml fpcr/fpsr/fpiar,sp@-;	\
    1.31 +	fmovemx	fp0-fp7,sp@-;	\
    1.32 +	.chip	68k
    1.33 +
    1.34 +#define RESTORE_FPU_CONTEXT	\
    1.35 +	.chip	68k/68881;	\
    1.36 +	fmovemx	sp@+,fp0-fp7;	\
    1.37 +	fmoveml	sp@+,fpcr/fpsr/fpiar;	\
    1.38 +	frestore	sp@+;	\
    1.39 +	.chip	68k
    1.40 +
    1.41 +#endif
    1.42 +
    1.43  /*--- Xbios interrupt vector to measure Falcon external clock ---*/
    1.44  
    1.45  _SDL_MintAudio_XbiosInterruptMeasureClock:          /* 1 mS */
    1.46 -
    1.47 +#if defined(__mcoldfire__)
    1.48 +	movel	d0,sp@-
    1.49 +	
    1.50 +	moveql	#0,d0
    1.51 +	btst	d0,0xFFFF8901:w	/* state DMA sound */
    1.52 +#else
    1.53  	btst	#0,0xFFFF8901:w	/* state DMA sound */
    1.54 +#endif
    1.55  	beqs	SDL_MintAudio_EndIntMeasure
    1.56  	addql	#1,_SDL_MintAudio_clocktics
    1.57  SDL_MintAudio_EndIntMeasure:
    1.58 +#if defined(__mcoldfire__)
    1.59 +	moveql	#5,d0
    1.60 +	bclr	d0,0xFFFFFA0F:w	/* Clear service bit */
    1.61 +
    1.62 +	movel	sp@+,d0
    1.63 +#else
    1.64  	bclr	#5,0xFFFFFA0F:w	/* Clear service bit */
    1.65 +#endif
    1.66  	rte
    1.67  
    1.68  /*--- Xbios interrupt vector ---*/
    1.69  
    1.70  _SDL_MintAudio_XbiosInterrupt:
    1.71 +#if defined(__mcoldfire__)
    1.72 +	lea	sp@(-60),sp
    1.73 +	moveml	d0-d7/a0-a6,sp@
    1.74 +#else
    1.75 +	moveml	d0-d7/a0-a6,sp@-
    1.76 +#endif
    1.77  
    1.78  	/* Reenable interrupts, so other interrupts can work */
    1.79  	movew	#0x2300,sr
    1.80  
    1.81  	/* Clear service bit, so other MFP interrupts can work */
    1.82 +#if defined(__mcoldfire__)
    1.83 +	moveql	#5,d0
    1.84 +	bclr	d0,0xfffffa0f:w
    1.85 +#else
    1.86  	bclr	#5,0xfffffa0f:w
    1.87 +#endif
    1.88  
    1.89  	/* Check if we are not already running */
    1.90  	tstw	_SDL_MintAudio_mutex
    1.91  	bne	SDL_MintAudio_XbiosEnd
    1.92 +
    1.93 +#if defined(__mcoldfire__)
    1.94 +	movew	_SDL_MintAudio_mutex,d0
    1.95 +	notl	d0
    1.96 +	movew	d0,_SDL_MintAudio_mutex
    1.97 +
    1.98 +	movew	_SDL_MintAudio_numbuf,d1
    1.99 +	eorl	#1,d1
   1.100 +	movew	d1,_SDL_MintAudio_numbuf
   1.101 +#else
   1.102  	notw	_SDL_MintAudio_mutex
   1.103 -	
   1.104 +
   1.105  	/* Swap buffers */
   1.106  	eorw	#1,_SDL_MintAudio_numbuf
   1.107 -
   1.108 -	moveml	d0-d7/a0-a6,sp@-
   1.109 -
   1.110 +#endif
   1.111 +	
   1.112  	/* Save FPU if needed */
   1.113  	tstw	_SDL_MintAudio_hasfpu
   1.114  	beqs	SDL_MintAudio_Xbios_nofpu1
   1.115 -	.chip	68060
   1.116 -	fsave	sp@-
   1.117 -	fmoveml fpcr/fpsr/fpiar,sp@-
   1.118 -	fmovemx	fp0-fp7,sp@-
   1.119 -	.chip	68000
   1.120 +	SAVE_FPU_CONTEXT
   1.121  SDL_MintAudio_Xbios_nofpu1:
   1.122  
   1.123  	/* Callback */
   1.124 @@ -102,15 +167,16 @@
   1.125  	/* Restore FPU if needed */
   1.126  	tstw	_SDL_MintAudio_hasfpu
   1.127  	beqs	SDL_MintAudio_Xbios_nofpu2
   1.128 -	.chip	68060
   1.129 -	fmovemx	sp@+,fp0-fp7
   1.130 -	fmoveml	sp@+,fpcr/fpsr/fpiar
   1.131 -	frestore	sp@+
   1.132 -	.chip	68000
   1.133 +	RESTORE_FPU_CONTEXT
   1.134  SDL_MintAudio_Xbios_nofpu2:
   1.135  
   1.136  	/* Reserve space for registers */
   1.137 +#if defined(__mcoldfire__)
   1.138 +	movel	#savamt,d0
   1.139 +	subl	d0,savptr
   1.140 +#else
   1.141  	subl	#savamt,savptr
   1.142 +#endif
   1.143  
   1.144  	/* Set new buffer */
   1.145  
   1.146 @@ -132,42 +198,66 @@
   1.147  	lea	sp@(12),sp
   1.148  
   1.149  	/* Restore registers space */
   1.150 +#if defined(__mcoldfire__)
   1.151 +	movel	#savamt,d0
   1.152 +	addl	d0,savptr
   1.153 +#else
   1.154  	addl	#savamt,savptr
   1.155 -
   1.156 -	moveml	sp@+,d0-d7/a0-a6
   1.157 +#endif
   1.158  
   1.159  	clrw	_SDL_MintAudio_mutex
   1.160  SDL_MintAudio_XbiosEnd:
   1.161 +#if defined(__mcoldfire__)
   1.162 +	moveml	sp@,d0-d7/a0-a6
   1.163 +	lea	sp@(60),sp
   1.164 +#else
   1.165 +	moveml	sp@+,d0-d7/a0-a6
   1.166 +#endif
   1.167  	rte
   1.168  
   1.169  /*--- DMA 8 bits interrupt vector ---*/
   1.170  
   1.171  _SDL_MintAudio_Dma8Interrupt:
   1.172 +#if defined(__mcoldfire__)
   1.173 +	lea	sp@(-16),sp
   1.174 +	moveml	d0-d1/a0-a1,sp@
   1.175 +#else
   1.176 +	moveml	d0-d1/a0-a1,sp@-
   1.177 +#endif
   1.178  
   1.179  	/* Reenable interrupts, so other interrupts can work */
   1.180  	movew	#0x2300,sr
   1.181  
   1.182  	/* Clear service bit, so other MFP interrupts can work */
   1.183 +#if defined(__mcoldfire__)
   1.184 +	moveql	#5,d0
   1.185 +	bclr	d0,0xfffffa0f:w
   1.186 +#else
   1.187  	bclr	#5,0xfffffa0f:w
   1.188 -
   1.189 +#endif
   1.190  	/* Check if we are not already running */
   1.191  	tstw	_SDL_MintAudio_mutex
   1.192  	bne	SDL_MintAudio_Dma8End
   1.193 +
   1.194 +#if defined(__mcoldfire__)
   1.195 +	movew	_SDL_MintAudio_mutex,d0
   1.196 +	notl	d0
   1.197 +	movew	d0,_SDL_MintAudio_mutex
   1.198 +
   1.199 +	movew	_SDL_MintAudio_numbuf,d1
   1.200 +	eorl	#1,d1
   1.201 +	movew	d1,_SDL_MintAudio_numbuf
   1.202 +#else
   1.203  	notw	_SDL_MintAudio_mutex
   1.204 -	
   1.205 +
   1.206  	/* Swap buffers */
   1.207  	eorw	#1,_SDL_MintAudio_numbuf
   1.208 -
   1.209 -	moveml	d0-d1/a0-a1,sp@-
   1.210 +#endif
   1.211  
   1.212  	/* Save FPU if needed */
   1.213  	tstw	_SDL_MintAudio_hasfpu
   1.214  	beqs	SDL_MintAudio_Dma8_nofpu1
   1.215 -	.chip	68060
   1.216 -	fsave	sp@-
   1.217 -	fmoveml fpcr/fpsr/fpiar,sp@-
   1.218 -	fmovemx	fp0-fp7,sp@-
   1.219 -	.chip	68000
   1.220 +	SAVE_FPU_CONTEXT
   1.221  SDL_MintAudio_Dma8_nofpu1:
   1.222  
   1.223  	/* Callback */
   1.224 @@ -176,11 +266,7 @@
   1.225  	/* Restore FPU if needed */
   1.226  	tstw	_SDL_MintAudio_hasfpu
   1.227  	beqs	SDL_MintAudio_Dma8_nofpu2
   1.228 -	.chip	68060
   1.229 -	fmovemx	sp@+,fp0-fp7
   1.230 -	fmoveml	sp@+,fpcr/fpsr/fpiar
   1.231 -	frestore	sp@+
   1.232 -	.chip	68000
   1.233 +	RESTORE_FPU_CONTEXT
   1.234  SDL_MintAudio_Dma8_nofpu2:
   1.235  
   1.236  	/* Set new buffer */
   1.237 @@ -188,32 +274,39 @@
   1.238  	moveq	#0,d0
   1.239  
   1.240  	movew	_SDL_MintAudio_numbuf,d0
   1.241 -	lslw	#2,d0
   1.242 +	lsll	#2,d0
   1.243  	lea	_SDL_MintAudio_audiobuf,a0
   1.244 -	movel	a0@(d0:w),d1
   1.245 +	movel	a0@(d0:l),d1
   1.246  
   1.247  	/* Modify DMA addresses */
   1.248  	lea	0xffff8900:w,a0
   1.249  
   1.250 -	moveb	d1,a0@(0x07)	/* Start address */
   1.251 -	rorl	#8,d1
   1.252 -	moveb	d1,a0@(0x05)
   1.253 -	rorl	#8,d1
   1.254 -	moveb	d1,a0@(0x03)
   1.255 -	swap	d1
   1.256 +	movel	d1,d0
   1.257 +
   1.258 +	moveb	d0,a0@(0x07)	/* Start address */
   1.259 +	lsrl	#8,d0
   1.260 +	moveb	d0,a0@(0x05)
   1.261 +	lsrl	#8,d0
   1.262 +	moveb	d0,a0@(0x03)
   1.263  
   1.264  	addl	_SDL_MintAudio_audiosize,d1
   1.265  
   1.266 -	moveb	d1,a0@(0x13)	/* End address */
   1.267 -	rorl	#8,d1
   1.268 -	moveb	d1,a0@(0x11)
   1.269 -	rorl	#8,d1
   1.270 -	moveb	d1,a0@(0x0f)
   1.271 +	movel	d1,d0
   1.272  
   1.273 -	moveml	sp@+,d0-d1/a0-a1
   1.274 +	moveb	d0,a0@(0x13)	/* End address */
   1.275 +	lsrl	#8,d0
   1.276 +	moveb	d0,a0@(0x11)
   1.277 +	lsrl	#8,d0
   1.278 +	moveb	d0,a0@(0x0f)
   1.279  
   1.280  	clrw	_SDL_MintAudio_mutex
   1.281  SDL_MintAudio_Dma8End:
   1.282 +#if defined(__mcoldfire__)
   1.283 +	moveml	sp@,d0-d1/a0-a1
   1.284 +	lea	sp@(16),sp
   1.285 +#else
   1.286 +	moveml	sp@+,d0-d1/a0-a1
   1.287 +#endif
   1.288  	rte
   1.289  
   1.290  /*--- STFA interrupt vector ---*/
   1.291 @@ -222,28 +315,40 @@
   1.292  STFA_SOUND_END		=	STFA_SOUND_START+8
   1.293  
   1.294  _SDL_MintAudio_StfaInterrupt:
   1.295 -
   1.296  	/* Reenable interrupts, so other interrupts can work */
   1.297  	movew	#0x2300,sr
   1.298  
   1.299  	/* Check if we are not already running */
   1.300  	tstw	_SDL_MintAudio_mutex
   1.301 +
   1.302 +#if defined(__mcoldfire__)
   1.303 +	bne	SDL_MintAudio_StfaEnd
   1.304 +
   1.305 +	lea	sp@(-60),sp
   1.306 +	moveml	d0-d7/a0-a6,sp@
   1.307 +
   1.308 +	movew	_SDL_MintAudio_mutex,d0
   1.309 +	notl	d0
   1.310 +	movew	d0,_SDL_MintAudio_mutex
   1.311 +
   1.312 +	movew	_SDL_MintAudio_numbuf,d1
   1.313 +	eorl	#1,d1
   1.314 +	movew	d1,_SDL_MintAudio_numbuf
   1.315 +#else
   1.316  	bnes	SDL_MintAudio_StfaEnd
   1.317 -	notw	_SDL_MintAudio_mutex
   1.318 -	
   1.319 -	/* Swap buffers */
   1.320 -	eorw	#1,_SDL_MintAudio_numbuf
   1.321  
   1.322  	moveml	d0-d7/a0-a6,sp@-
   1.323  
   1.324 +	notw	_SDL_MintAudio_mutex
   1.325 +
   1.326 +	/* Swap buffers */
   1.327 +	eorw	#1,_SDL_MintAudio_numbuf
   1.328 +#endif
   1.329 +	
   1.330  	/* Save FPU if needed */
   1.331  	tstw	_SDL_MintAudio_hasfpu
   1.332  	beqs	SDL_MintAudio_Stfa_nofpu1
   1.333 -	.chip	68060
   1.334 -	fsave	sp@-
   1.335 -	fmoveml fpcr/fpsr/fpiar,sp@-
   1.336 -	fmovemx	fp0-fp7,sp@-
   1.337 -	.chip	68000
   1.338 +	SAVE_FPU_CONTEXT
   1.339  SDL_MintAudio_Stfa_nofpu1:
   1.340  
   1.341  	/* Callback */
   1.342 @@ -252,11 +357,7 @@
   1.343  	/* Restore FPU if needed */
   1.344  	tstw	_SDL_MintAudio_hasfpu
   1.345  	beqs	SDL_MintAudio_Stfa_nofpu2
   1.346 -	.chip	68060
   1.347 -	fmovemx	sp@+,fp0-fp7
   1.348 -	fmoveml	sp@+,fpcr/fpsr/fpiar
   1.349 -	frestore	sp@+
   1.350 -	.chip	68000
   1.351 +	RESTORE_FPU_CONTEXT
   1.352  SDL_MintAudio_Stfa_nofpu2:
   1.353  
   1.354  	/* Set new buffer */
   1.355 @@ -265,17 +366,21 @@
   1.356  	movel	_SDL_MintAudio_stfa,a1
   1.357  
   1.358  	movew	_SDL_MintAudio_numbuf,d0
   1.359 -	lslw	#2,d0
   1.360 +	lsll	#2,d0
   1.361  	lea	_SDL_MintAudio_audiobuf,a0
   1.362 -	movel	a0@(d0:w),d1
   1.363 +	movel	a0@(d0:l),d1
   1.364  
   1.365  	/* Modify STFA replay buffers */
   1.366  	movel	d1,a1@(STFA_SOUND_START)
   1.367  	addl	_SDL_MintAudio_audiosize,d1
   1.368  	movel	d1,a1@(STFA_SOUND_END)
   1.369  
   1.370 +#if defined(__mcoldfire__)
   1.371 +	moveml	sp@,d0-d7/a0-a6
   1.372 +	lea	sp@(60),sp
   1.373 +#else
   1.374  	moveml	sp@+,d0-d7/a0-a6
   1.375 -
   1.376 +#endif
   1.377  	clrw	_SDL_MintAudio_mutex
   1.378  SDL_MintAudio_StfaEnd:
   1.379  	rte