summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2005-12-12 13:53:22 +0000
committerThom Johansen <thomj@rockbox.org>2005-12-12 13:53:22 +0000
commit544b03cf9abafc080e10a91f65046eda540ff5ae (patch)
tree1fabed08230448393c5cab1f20f1a845f3ab883d
parent07a2ad2a2246c649ec86c2adb077ec9ed3cfef11 (diff)
downloadrockbox-544b03cf9abafc080e10a91f65046eda540ff5ae.tar.gz
rockbox-544b03cf9abafc080e10a91f65046eda540ff5ae.zip
Add interrupt handler for iPod. Add timer tick support. Remove temporary thread sleep solution. Remove temporary iPod current_tick solution.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8224 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/crt0.S5
-rw-r--r--firmware/export/kernel.h5
-rw-r--r--firmware/kernel.c35
-rw-r--r--firmware/system.c22
-rw-r--r--firmware/thread.c3
5 files changed, 53 insertions, 17 deletions
diff --git a/firmware/crt0.S b/firmware/crt0.S
index bb772e2c5d..7ab7e2cbd8 100644
--- a/firmware/crt0.S
+++ b/firmware/crt0.S
@@ -275,6 +275,8 @@ ecode:
275 .word fiq_handler 275 .word fiq_handler
276ecodeend: 276ecodeend:
277 277
278 .global irq
279
278undef_instr_handler: 280undef_instr_handler:
279software_int_handler: 281software_int_handler:
280reserved_handler: 282reserved_handler:
@@ -288,6 +290,9 @@ data_abort_handler:
288 subs pc, lr, #8 290 subs pc, lr, #8
289 291
290irq_handler: 292irq_handler:
293 stmfd sp!, {r0-r3, r12, lr}
294 bl irq
295 ldmfd sp!, {r0-r3, r12, lr}
291 subs pc, lr, #4 296 subs pc, lr, #4
292 297
293/* 256 words of IRQ stack */ 298/* 256 words of IRQ stack */
diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h
index 67dadbcda5..23c7bc7cb1 100644
--- a/firmware/export/kernel.h
+++ b/firmware/export/kernel.h
@@ -66,12 +66,7 @@ struct mutex
66}; 66};
67 67
68/* global tick variable */ 68/* global tick variable */
69#if (CONFIG_CPU==PP5020)
70/* A temporary hack until timer interrupt is enabled - use the RTC */
71#define current_tick ((*((volatile long*)0x60005010))/10000)
72#else
73extern long current_tick; 69extern long current_tick;
74#endif
75 70
76#ifdef SIMULATOR 71#ifdef SIMULATOR
77#define sleep(x) sim_sleep(x) 72#define sleep(x) sim_sleep(x)
diff --git a/firmware/kernel.c b/firmware/kernel.c
index b9aee94221..6166437282 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -25,9 +25,7 @@
25#include "system.h" 25#include "system.h"
26#include "panic.h" 26#include "panic.h"
27 27
28#if (CONFIG_CPU != PP5020)
29long current_tick = 0; 28long current_tick = 0;
30#endif
31 29
32static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); 30static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
33 31
@@ -319,9 +317,36 @@ void tick_start(unsigned int interval_in_ms)
319 317
320#elif CONFIG_CPU == PP5020 318#elif CONFIG_CPU == PP5020
321 319
322void tick_start(unsigned int interval_in_ms) { 320#define USECS_PER_INT 0x2710
323 /* TODO: Implement tick_start */ 321
324 (void)interval_in_ms; 322void TIMER1(void)
323{
324 int i;
325
326 PP5020_TIMER1_ACK;
327 /* Run through the list of tick tasks */
328 for (i = 0;i < MAX_NUM_TICK_TASKS;i++)
329 {
330 if (tick_funcs[i])
331 {
332 tick_funcs[i]();
333 }
334 }
335
336 current_tick++;
337 wake_up_thread();
338}
339
340void tick_start(unsigned int interval_in_ms)
341{
342 /* TODO: use interval_in_ms to set timer periode */
343 (void)interval_in_ms;
344 PP5020_TIMER1 = 0x0;
345 PP5020_TIMER1_ACK;
346 /* enable timer, period, trigger value 0x2710 -> 100Hz */
347 PP5020_TIMER1 = 0xc0000000 | USECS_PER_INT;
348 /* unmask interrupt source */
349 PP5020_CPU_INT_EN = PP5020_TIMER1_MASK;
325} 350}
326 351
327#endif 352#endif
diff --git a/firmware/system.c b/firmware/system.c
index 5e8a7cd4d7..6ef35e8505 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -1106,14 +1106,28 @@ int system_memory_guard(int newmode)
1106} 1106}
1107#elif CONFIG_CPU==PP5020 1107#elif CONFIG_CPU==PP5020
1108 1108
1109/* TODO: Implement system.c */ 1109extern void TIMER1(void);
1110
1111void system_init(void) {
1112 1110
1111void irq(void)
1112{
1113 if (PP5020_CPU_INT_STAT & PP5020_TIMER1_MASK)
1114 TIMER1();
1113} 1115}
1114 1116
1115void system_reboot(void) { 1117void system_init(void)
1118{
1119 /* disable all irqs */
1120 outl(-1, 0x60001138);
1121 outl(-1, 0x60001128);
1122 outl(-1, 0x6000111c);
1123
1124 outl(-1, 0x60001038);
1125 outl(-1, 0x60001028);
1126 outl(-1, 0x6000101c);
1127}
1116 1128
1129void system_reboot(void)
1130{
1117} 1131}
1118 1132
1119int system_memory_guard(int newmode) 1133int system_memory_guard(int newmode)
diff --git a/firmware/thread.c b/firmware/thread.c
index 7ed8dbde37..13577e8efb 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -251,8 +251,6 @@ void switch_thread(void)
251#ifdef SIMULATOR 251#ifdef SIMULATOR
252 /* Do nothing */ 252 /* Do nothing */
253#else 253#else
254/* We currently have no interrupts on iPod targets, so remove this temp. */
255#if CONFIG_CPU != PP5020
256 while (num_sleepers == num_threads) 254 while (num_sleepers == num_threads)
257 { 255 {
258 /* Enter sleep mode, woken up on interrupt */ 256 /* Enter sleep mode, woken up on interrupt */
@@ -271,7 +269,6 @@ void switch_thread(void)
271#endif 269#endif
272 } 270 }
273#endif 271#endif
274#endif
275 current = current_thread; 272 current = current_thread;
276 store_context(&thread_contexts[current]); 273 store_context(&thread_contexts[current]);
277 274