Save/restore FPU registers in interrupt
authorPatrice Mandin <patmandin@gmail.com>
Sat, 16 Sep 2006 16:59:46 +0000
changeset 2027d48ead2d2ba5
parent 2026 a5d0758f88d8
child 2028 6dbe2a67b23b
Save/restore FPU registers in interrupt
src/audio/mint/SDL_mintaudio.c
src/audio/mint/SDL_mintaudio.h
src/audio/mint/SDL_mintaudio_dma8.c
src/audio/mint/SDL_mintaudio_gsxb.c
src/audio/mint/SDL_mintaudio_it.S
src/audio/mint/SDL_mintaudio_mcsn.c
src/audio/mint/SDL_mintaudio_stfa.c
src/audio/mint/SDL_mintaudio_xbios.c
     1.1 --- a/src/audio/mint/SDL_mintaudio.c	Wed Sep 13 04:47:46 2006 +0000
     1.2 +++ b/src/audio/mint/SDL_mintaudio.c	Sat Sep 16 16:59:46 2006 +0000
     1.3 @@ -145,6 +145,26 @@
     1.4      return MINTAUDIO_freqcount - 1;
     1.5  }
     1.6  
     1.7 +/* Check if FPU is present */
     1.8 +void SDL_MintAudio_CheckFpu(void)
     1.9 +{
    1.10 +	unsigned long cookie_fpu;
    1.11 +
    1.12 +	SDL_MintAudio_hasfpu = 0;
    1.13 +	if (Getcookie(C__FPU, &cookie_fpu) != C_FOUND) {
    1.14 +		return;
    1.15 +	}
    1.16 +	switch ((cookie_fpu>>16)&0xfffe) {
    1.17 +		case 2:
    1.18 +		case 4:
    1.19 +		case 6:
    1.20 +		case 8:
    1.21 +		case 16:
    1.22 +			SDL_MintAudio_hasfpu = 1;
    1.23 +			break;
    1.24 +	}
    1.25 +}
    1.26 +
    1.27  /* The thread function, used under MiNT with xbios */
    1.28  int
    1.29  SDL_MintAudio_Thread(long param)
     2.1 --- a/src/audio/mint/SDL_mintaudio.h	Wed Sep 13 04:47:46 2006 +0000
     2.2 +++ b/src/audio/mint/SDL_mintaudio.h	Sat Sep 16 16:59:46 2006 +0000
     2.3 @@ -128,6 +128,7 @@
     2.4  extern volatile unsigned short SDL_MintAudio_mutex;
     2.5  extern cookie_stfa_t *SDL_MintAudio_stfa;
     2.6  extern volatile unsigned long SDL_MintAudio_clocktics;
     2.7 +extern unsigned short SDL_MintAudio_hasfpu;	/* To preserve fpu registers if needed */
     2.8  
     2.9  /* MiNT thread variables */
    2.10  extern SDL_bool SDL_MintAudio_mint_present;
    2.11 @@ -140,6 +141,7 @@
    2.12  void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock,
    2.13                                  Uint32 prediv, int gpio_bits);
    2.14  int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq);
    2.15 +void SDL_MintAudio_CheckFpu(void);
    2.16  
    2.17  /* MiNT thread functions */
    2.18  int SDL_MintAudio_Thread(long param);
     3.1 --- a/src/audio/mint/SDL_mintaudio_dma8.c	Wed Sep 13 04:47:46 2006 +0000
     3.2 +++ b/src/audio/mint/SDL_mintaudio_dma8.c	Sat Sep 16 16:59:46 2006 +0000
     3.3 @@ -367,6 +367,8 @@
     3.4      DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n",
     3.5                   SDL_MintAudio_audiobuf[1]));
     3.6  
     3.7 +    SDL_MintAudio_CheckFpu();
     3.8 +
     3.9      /* Setup audio hardware */
    3.10      Mint_InitAudio(this, spec);
    3.11  
     4.1 --- a/src/audio/mint/SDL_mintaudio_gsxb.c	Wed Sep 13 04:47:46 2006 +0000
     4.2 +++ b/src/audio/mint/SDL_mintaudio_gsxb.c	Sat Sep 16 16:59:46 2006 +0000
     4.3 @@ -438,6 +438,8 @@
     4.4      DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n",
     4.5                   SDL_MintAudio_audiobuf[1]));
     4.6  
     4.7 +    SDL_MintAudio_CheckFpu();
     4.8 +
     4.9      /* Setup audio hardware */
    4.10      Mint_InitAudio(this, spec);
    4.11  
     5.1 --- a/src/audio/mint/SDL_mintaudio_it.S	Wed Sep 13 04:47:46 2006 +0000
     5.2 +++ b/src/audio/mint/SDL_mintaudio_it.S	Sat Sep 16 16:59:46 2006 +0000
     5.3 @@ -40,6 +40,7 @@
     5.4  	.globl	_SDL_MintAudio_numbuf
     5.5  	.globl	_SDL_MintAudio_audiosize
     5.6  	.globl	_SDL_MintAudio_clocktics
     5.7 +	.globl	_SDL_MintAudio_hasfpu
     5.8  
     5.9  	.globl	_SDL_MintAudio_stfa
    5.10  
    5.11 @@ -85,9 +86,29 @@
    5.12  
    5.13  	moveml	d0-d7/a0-a6,sp@-
    5.14  
    5.15 +	/* Save FPU if needed */
    5.16 +	tstw	_SDL_MintAudio_hasfpu
    5.17 +	beqs	SDL_MintAudio_Xbios_nofpu1
    5.18 +	.chip	68060
    5.19 +	fsave	sp@-
    5.20 +	fmoveml fpcr/fpsr/fpiar,sp@-
    5.21 +	fmovemx	fp0-fp7,sp@-
    5.22 +	.chip	68000
    5.23 +SDL_MintAudio_Xbios_nofpu1:
    5.24 +
    5.25  	/* Callback */
    5.26  	jsr	_SDL_MintAudio_Callback
    5.27  
    5.28 +	/* Restore FPU if needed */
    5.29 +	tstw	_SDL_MintAudio_hasfpu
    5.30 +	beqs	SDL_MintAudio_Xbios_nofpu2
    5.31 +	.chip	68060
    5.32 +	fmovemx	sp@+,fp0-fp7
    5.33 +	fmoveml	sp@+,fpcr/fpsr/fpiar
    5.34 +	frestore	sp@+
    5.35 +	.chip	68000
    5.36 +SDL_MintAudio_Xbios_nofpu2:
    5.37 +
    5.38  	/* Reserve space for registers */
    5.39  	subl	#savamt,savptr
    5.40  
    5.41 @@ -137,11 +158,31 @@
    5.42  	/* Swap buffers */
    5.43  	eorw	#1,_SDL_MintAudio_numbuf
    5.44  
    5.45 -	moveml	d0-d7/a0-a6,sp@-
    5.46 +	moveml	d0-d1/a0-a1,sp@-
    5.47 +
    5.48 +	/* Save FPU if needed */
    5.49 +	tstw	_SDL_MintAudio_hasfpu
    5.50 +	beqs	SDL_MintAudio_Dma8_nofpu1
    5.51 +	.chip	68060
    5.52 +	fsave	sp@-
    5.53 +	fmoveml fpcr/fpsr/fpiar,sp@-
    5.54 +	fmovemx	fp0-fp7,sp@-
    5.55 +	.chip	68000
    5.56 +SDL_MintAudio_Dma8_nofpu1:
    5.57  
    5.58  	/* Callback */
    5.59  	jsr	_SDL_MintAudio_Callback
    5.60  
    5.61 +	/* Restore FPU if needed */
    5.62 +	tstw	_SDL_MintAudio_hasfpu
    5.63 +	beqs	SDL_MintAudio_Dma8_nofpu2
    5.64 +	.chip	68060
    5.65 +	fmovemx	sp@+,fp0-fp7
    5.66 +	fmoveml	sp@+,fpcr/fpsr/fpiar
    5.67 +	frestore	sp@+
    5.68 +	.chip	68000
    5.69 +SDL_MintAudio_Dma8_nofpu2:
    5.70 +
    5.71  	/* Set new buffer */
    5.72  
    5.73  	moveq	#0,d0
    5.74 @@ -169,7 +210,7 @@
    5.75  	rorl	#8,d1
    5.76  	moveb	d1,a0@(0x0f)
    5.77  
    5.78 -	moveml	sp@+,d0-d7/a0-a6
    5.79 +	moveml	sp@+,d0-d1/a0-a1
    5.80  
    5.81  	clrw	_SDL_MintAudio_mutex
    5.82  SDL_MintAudio_Dma8End:
    5.83 @@ -195,9 +236,29 @@
    5.84  
    5.85  	moveml	d0-d7/a0-a6,sp@-
    5.86  
    5.87 +	/* Save FPU if needed */
    5.88 +	tstw	_SDL_MintAudio_hasfpu
    5.89 +	beqs	SDL_MintAudio_Stfa_nofpu1
    5.90 +	.chip	68060
    5.91 +	fsave	sp@-
    5.92 +	fmoveml fpcr/fpsr/fpiar,sp@-
    5.93 +	fmovemx	fp0-fp7,sp@-
    5.94 +	.chip	68000
    5.95 +SDL_MintAudio_Stfa_nofpu1:
    5.96 +
    5.97  	/* Callback */
    5.98  	jsr	_SDL_MintAudio_Callback
    5.99  
   5.100 +	/* Restore FPU if needed */
   5.101 +	tstw	_SDL_MintAudio_hasfpu
   5.102 +	beqs	SDL_MintAudio_Stfa_nofpu2
   5.103 +	.chip	68060
   5.104 +	fmovemx	sp@+,fp0-fp7
   5.105 +	fmoveml	sp@+,fpcr/fpsr/fpiar
   5.106 +	frestore	sp@+
   5.107 +	.chip	68000
   5.108 +SDL_MintAudio_Stfa_nofpu2:
   5.109 +
   5.110  	/* Set new buffer */
   5.111  
   5.112  	moveq	#0,d0
     6.1 --- a/src/audio/mint/SDL_mintaudio_mcsn.c	Wed Sep 13 04:47:46 2006 +0000
     6.2 +++ b/src/audio/mint/SDL_mintaudio_mcsn.c	Sat Sep 16 16:59:46 2006 +0000
     6.3 @@ -415,6 +415,8 @@
     6.4      DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n",
     6.5                   SDL_MintAudio_audiobuf[1]));
     6.6  
     6.7 +    SDL_MintAudio_CheckFpu();
     6.8 +
     6.9      /* Setup audio hardware */
    6.10      Mint_InitAudio(this, spec);
    6.11  
     7.1 --- a/src/audio/mint/SDL_mintaudio_stfa.c	Wed Sep 13 04:47:46 2006 +0000
     7.2 +++ b/src/audio/mint/SDL_mintaudio_stfa.c	Sat Sep 16 16:59:46 2006 +0000
     7.3 @@ -332,6 +332,8 @@
     7.4      DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n",
     7.5                   SDL_MintAudio_audiobuf[1]));
     7.6  
     7.7 +    SDL_MintAudio_CheckFpu();
     7.8 +
     7.9      /* Setup audio hardware */
    7.10      Mint_InitAudio(this, spec);
    7.11  
     8.1 --- a/src/audio/mint/SDL_mintaudio_xbios.c	Wed Sep 13 04:47:46 2006 +0000
     8.2 +++ b/src/audio/mint/SDL_mintaudio_xbios.c	Sat Sep 16 16:59:46 2006 +0000
     8.3 @@ -519,6 +519,8 @@
     8.4      DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n",
     8.5                   SDL_MintAudio_audiobuf[1]));
     8.6  
     8.7 +    SDL_MintAudio_CheckFpu();
     8.8 +
     8.9      /* Setup audio hardware */
    8.10      Mint_InitAudio(this, spec);
    8.11