summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/src/timer/mint
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2018-02-07 20:04:46 -0500
committerFranklin Wei <git@fwei.tk>2018-03-12 20:52:01 -0400
commit6039eb05ba6d82ef56f2868c96654c552d117bf9 (patch)
tree9db7016bcbf66cfdf7b9bc998d84c6eaff9c8378 /apps/plugins/sdl/src/timer/mint
parentef373c03b96b0be08babca581d9f10bccfd4931f (diff)
downloadrockbox-6039eb05ba6d82ef56f2868c96654c552d117bf9.tar.gz
rockbox-6039eb05ba6d82ef56f2868c96654c552d117bf9.zip
sdl: remove non-rockbox drivers
We never use any of these other drivers, so having them around just takes up space. Change-Id: Iced812162df1fef3fd55522b7e700acb6c3bcd41
Diffstat (limited to 'apps/plugins/sdl/src/timer/mint')
-rw-r--r--apps/plugins/sdl/src/timer/mint/SDL_systimer.c149
-rw-r--r--apps/plugins/sdl/src/timer/mint/SDL_vbltimer.S228
-rw-r--r--apps/plugins/sdl/src/timer/mint/SDL_vbltimer_s.h35
3 files changed, 0 insertions, 412 deletions
diff --git a/apps/plugins/sdl/src/timer/mint/SDL_systimer.c b/apps/plugins/sdl/src/timer/mint/SDL_systimer.c
deleted file mode 100644
index 01e7a410c1..0000000000
--- a/apps/plugins/sdl/src/timer/mint/SDL_systimer.c
+++ /dev/null
@@ -1,149 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21*/
22#include "SDL_config.h"
23
24#ifdef SDL_TIMER_MINT
25
26/*
27 * TOS/MiNT timer driver
28 * based on vbl vector
29 *
30 * Patrice Mandin
31 */
32
33#include <stdio.h>
34#include <sys/time.h>
35#include <signal.h>
36#include <unistd.h>
37#include <string.h>
38#include <errno.h>
39
40#include <mint/cookie.h>
41#include <mint/sysvars.h>
42#include <mint/osbind.h>
43#include <mint/mintbind.h>
44
45#include "SDL_timer.h"
46#include "../SDL_timer_c.h"
47#include "SDL_thread.h"
48
49#include "../../video/ataricommon/SDL_atarisuper.h"
50
51#include "SDL_vbltimer_s.h"
52
53/* from audio/mint */
54void SDL_MintAudio_CheckFpu(void);
55
56/* The first ticks value of the application */
57static Uint32 start;
58static SDL_bool read_hz200_from_vbl = SDL_FALSE;
59static int mint_present; /* can we use Syield() ? */
60
61void SDL_StartTicks(void)
62{
63 void *old_stack;
64 long dummy;
65
66 /* Set first ticks value */
67 old_stack = (void *)Super(0);
68 start = *((volatile long *)_hz_200);
69 SuperToUser(old_stack);
70
71 start *= 5; /* One _hz_200 tic is 5ms */
72
73 mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
74}
75
76Uint32 SDL_GetTicks (void)
77{
78 Uint32 now = start;
79
80 if (read_hz200_from_vbl) {
81 now = SDL_Atari_hz200;
82 } else {
83 void *old_stack = (void *)Super(0);
84 now = *((volatile long *)_hz_200);
85 SuperToUser(old_stack);
86 }
87
88 return((now*5)-start);
89}
90
91void SDL_Delay (Uint32 ms)
92{
93 Uint32 now;
94
95 now = SDL_GetTicks();
96 while ((SDL_GetTicks()-now)<ms){
97 if (mint_present) {
98 Syield();
99 }
100 }
101}
102
103/* Data to handle a single periodic alarm */
104static SDL_bool timer_installed=SDL_FALSE;
105
106/* This is only called if the event thread is not running */
107int SDL_SYS_TimerInit(void)
108{
109 void *old_stack;
110
111 SDL_MintAudio_CheckFpu();
112
113 /* Install RunTimer in vbl vector */
114 old_stack = (void *)Super(0);
115 timer_installed = !SDL_AtariVblInstall(SDL_ThreadedTimerCheck);
116 SuperToUser(old_stack);
117
118 if (!timer_installed) {
119 return(-1);
120 }
121
122 read_hz200_from_vbl = SDL_TRUE;
123 return(SDL_SetTimerThreaded(0));
124}
125
126void SDL_SYS_TimerQuit(void)
127{
128 /* Uninstall RunTimer vbl vector */
129 if (timer_installed) {
130 void *old_stack = (void *)Super(0);
131 SDL_AtariVblUninstall(SDL_ThreadedTimerCheck);
132 SuperToUser(old_stack);
133 timer_installed = SDL_FALSE;
134 }
135 read_hz200_from_vbl = SDL_FALSE;
136}
137
138int SDL_SYS_StartTimer(void)
139{
140 SDL_SetError("Internal logic error: MiNT uses vbl timer");
141 return(-1);
142}
143
144void SDL_SYS_StopTimer(void)
145{
146 return;
147}
148
149#endif /* SDL_TIMER_MINT */
diff --git a/apps/plugins/sdl/src/timer/mint/SDL_vbltimer.S b/apps/plugins/sdl/src/timer/mint/SDL_vbltimer.S
deleted file mode 100644
index 7837afce08..0000000000
--- a/apps/plugins/sdl/src/timer/mint/SDL_vbltimer.S
+++ /dev/null
@@ -1,228 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21*/
22
23/*
24 * VBL queue routine
25 *
26 * Patrice Mandin
27 */
28
29#define _vbl_queue 0x456
30#define _hz_200 0x4ba
31
32 .text
33
34 .globl _SDL_AtariVblInstall
35 .globl _SDL_AtariVblUninstall
36
37 .globl _SDL_MintAudio_hasfpu
38
39/*--- Save/restore FPU context ---*/
40
41#if defined(__mcoldfire__)
42
43#define SAVE_FPU_CONTEXT \
44 lea sp@(-216),sp; \
45 fsave sp@; \
46 fmovel fpiar,sp@-; \
47 lea sp@(-64),sp; \
48 fmovemd fp0-fp7,sp@
49
50#define RESTORE_FPU_CONTEXT \
51 fmovemd sp@,fp0-fp7; \
52 lea sp@(64),sp; \
53 fmovel sp@+,fpiar; \
54 frestore sp@; \
55 lea sp@(216),sp
56
57#else
58
59#define SAVE_FPU_CONTEXT \
60 .chip 68k/68881; \
61 fsave sp@-; \
62 fmoveml fpcr/fpsr/fpiar,sp@-; \
63 fmovemx fp0-fp7,sp@-; \
64 .chip 68k
65
66#define RESTORE_FPU_CONTEXT \
67 .chip 68k/68881; \
68 fmovemx sp@+,fp0-fp7; \
69 fmoveml sp@+,fpcr/fpsr/fpiar; \
70 frestore sp@+; \
71 .chip 68k
72
73#endif
74
75/*--- Vector installer ---*/
76
77_SDL_AtariVblInstall:
78#if defined(__mcoldfire__)
79 movel sp@(4),d0
80 movel d0,my_vector
81#else
82 movel sp@(4),my_vector
83#endif
84
85 lea _my_vbl,a0
86
87 clrw vbl_mutex
88#if defined(__mcoldfire__)
89 movel _hz_200.w,d0
90 movel d0, _SDL_Atari_hz200
91#else
92 movel _hz_200.w, _SDL_Atari_hz200
93#endif
94
95 /* Stop interrupts */
96
97 movew #0x2700,sr
98
99 /* Read vbl_queue pointer */
100 movel _vbl_queue.w,a1
101
102 /* Search a free place */
103 moveq #7,d0
104bcl_search_place:
105 movel (a1),d1
106 beqs place_found
107 addql #4,a1
108#if defined(__mcoldfire__)
109 subql #1,d0
110 bpls bcl_search_place
111#else
112 dbra d0,bcl_search_place
113#endif
114
115 /* Not found */
116 moveq #1,d0
117 bras exit_vbl_queue
118
119 /* Then install ourselves */
120place_found:
121 movel a0,(a1)
122 moveq #0,d0
123
124exit_vbl_queue:
125 /* Restart interrupts */
126 movew #0x2300,sr
127
128 rts
129
130/*--- Vector uninstaller ---*/
131
132_SDL_AtariVblUninstall:
133 movel sp@(4),d0
134 cmpl my_vector,d0
135 bnes badvector
136
137 movel #_my_vbl,d0
138
139 /* Stop interrupts */
140
141 movew #0x2700,sr
142
143 /* Read vbl_queue pointer */
144 movel _vbl_queue.w,a1
145
146 /* Search where we are */
147 moveq #7,d1
148bcl2_search_place:
149 cmpl (a1),d0
150 bnes next_place
151 clrl (a1)
152 moveq #0,d1
153next_place:
154 addql #4,a1
155#if defined(__mcoldfire__)
156 subql #1,d1
157 bpls bcl_search_place
158#else
159 dbra d1,bcl2_search_place
160#endif
161
162 /* Restart interrupts */
163 movew #0x2300,sr
164badvector:
165 rts
166
167/*--- Our vbl ---*/
168
169_my_vbl:
170#if defined(__mcoldfire__)
171 lea sp@(-60),sp
172 moveml d0-d7/a0-a6,sp@
173#else
174 moveml d0-d7/a0-a6,sp@-
175#endif
176
177 /* Update _hz_200 */
178#if defined(__mcoldfire__)
179 movel _hz_200.w,d0
180 movel d0, _SDL_Atari_hz200
181#else
182 movel _hz_200.w, _SDL_Atari_hz200
183#endif
184
185 /* Verify if this is not already running */
186
187 tstw vbl_mutex
188 bnes vbl_end
189#if defined(__mcoldfire__)
190 movew vbl_mutex,d0
191 notl d0
192 movew d0,vbl_mutex
193#else
194 notw vbl_mutex
195#endif
196
197 /* Save FPU if needed */
198 tstw _SDL_MintAudio_hasfpu
199 beqs SDL_AtariVbl_nofpu1
200 SAVE_FPU_CONTEXT
201SDL_AtariVbl_nofpu1:
202
203 movel my_vector,a0
204 jsr a0@
205
206 /* Restore FPU if needed */
207 tstw _SDL_MintAudio_hasfpu
208 beqs SDL_AtariVbl_Xbios_nofpu2
209 RESTORE_FPU_CONTEXT
210SDL_AtariVbl_Xbios_nofpu2:
211
212 clrw vbl_mutex
213vbl_end:
214#if defined(__mcoldfire__)
215 moveml sp@,d0-d7/a0-a6
216 lea sp@(60),sp
217#else
218 moveml sp@+,d0-d7/a0-a6
219#endif
220 rts
221
222 .data
223 .even
224 .comm _SDL_Atari_hz200,4*1
225 .even
226 .comm vbl_mutex,2*1
227 .even
228 .comm my_vector,4*1
diff --git a/apps/plugins/sdl/src/timer/mint/SDL_vbltimer_s.h b/apps/plugins/sdl/src/timer/mint/SDL_vbltimer_s.h
deleted file mode 100644
index 011c138ddb..0000000000
--- a/apps/plugins/sdl/src/timer/mint/SDL_vbltimer_s.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21*/
22#include "SDL_config.h"
23
24/*
25 * TOS/MiNT timer driver
26 * based on vbl vector
27 *
28 * Patrice Mandin
29 */
30
31extern volatile long SDL_Atari_hz200;
32
33/* Functions prototypes */
34extern int SDL_AtariVblInstall(void *newvector);
35extern void SDL_AtariVblUninstall(void *newvector);