diff options
Diffstat (limited to 'firmware/kernel.c')
-rw-r--r-- | firmware/kernel.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c index a9c7711003..221f8a3b38 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <string.h> | 20 | #include <string.h> |
21 | #include "kernel.h" | 21 | #include "kernel.h" |
22 | #include "thread.h" | 22 | #include "thread.h" |
23 | #include "sh7034.h" | 23 | #include "cpu.h" |
24 | #include "system.h" | 24 | #include "system.h" |
25 | #include "panic.h" | 25 | #include "panic.h" |
26 | 26 | ||
@@ -154,6 +154,7 @@ int queue_broadcast(int id, void *data) | |||
154 | /**************************************************************************** | 154 | /**************************************************************************** |
155 | * Timer tick | 155 | * Timer tick |
156 | ****************************************************************************/ | 156 | ****************************************************************************/ |
157 | #if CONFIG_CPU == SH7034 | ||
157 | static void tick_start(unsigned int interval_in_ms) | 158 | static void tick_start(unsigned int interval_in_ms) |
158 | { | 159 | { |
159 | unsigned int count; | 160 | unsigned int count; |
@@ -205,6 +206,52 @@ void IMIA0(void) | |||
205 | 206 | ||
206 | TSR0 &= ~0x01; | 207 | TSR0 &= ~0x01; |
207 | } | 208 | } |
209 | #elif CONFIG_CPU == MCF5249 | ||
210 | static void tick_start(unsigned int interval_in_ms) | ||
211 | { | ||
212 | unsigned int count; | ||
213 | |||
214 | count = FREQ/2 * interval_in_ms / 1000 / 16; | ||
215 | |||
216 | if(count > 0xffff) | ||
217 | { | ||
218 | panicf("Error! The tick interval is too long (%d ms)\n", | ||
219 | interval_in_ms); | ||
220 | return; | ||
221 | } | ||
222 | |||
223 | /* We are using timer 0 */ | ||
224 | |||
225 | TRR0 = count; /* The reference count */ | ||
226 | TCN0 = 0; /* reset the timer */ | ||
227 | TMR0 = 0x001d; /* no prescaler, restart, CLK/16, enabled */ | ||
228 | |||
229 | TER0 = 0xff; /* Clear all events */ | ||
230 | |||
231 | ICR0 = (ICR0 & 0xff00ffff) | 0x008c0000; /* Interrupt on level 3.0 */ | ||
232 | IMR &= ~0x200; | ||
233 | } | ||
234 | |||
235 | void TIMER0(void) __attribute__ ((interrupt_handler)); | ||
236 | void TIMER0(void) | ||
237 | { | ||
238 | int i; | ||
239 | |||
240 | /* Run through the list of tick tasks */ | ||
241 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
242 | { | ||
243 | if(tick_funcs[i]) | ||
244 | { | ||
245 | tick_funcs[i](); | ||
246 | } | ||
247 | } | ||
248 | |||
249 | current_tick++; | ||
250 | wake_up_thread(); | ||
251 | |||
252 | TER0 = 0xff; /* Clear all events */ | ||
253 | } | ||
254 | #endif | ||
208 | 255 | ||
209 | int tick_add_task(void (*f)(void)) | 256 | int tick_add_task(void (*f)(void)) |
210 | { | 257 | { |