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.zip
rockbox-544b03cf9abafc080e10a91f65046eda540ff5ae.tar.gz
rockbox-544b03cf9abafc080e10a91f65046eda540ff5ae.tar.bz2
rockbox-544b03cf9abafc080e10a91f65046eda540ff5ae.tar.xz
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 bb772e2..7ab7e2c 100644
--- a/firmware/crt0.S
+++ b/firmware/crt0.S
@@ -275,6 +275,8 @@ ecode:
.word fiq_handler
ecodeend:
+ .global irq
+
undef_instr_handler:
software_int_handler:
reserved_handler:
@@ -288,6 +290,9 @@ data_abort_handler:
subs pc, lr, #8
irq_handler:
+ stmfd sp!, {r0-r3, r12, lr}
+ bl irq
+ ldmfd sp!, {r0-r3, r12, lr}
subs pc, lr, #4
/* 256 words of IRQ stack */
diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h
index 67dadbc..23c7bc7 100644
--- a/firmware/export/kernel.h
+++ b/firmware/export/kernel.h
@@ -66,12 +66,7 @@ struct mutex
};
/* global tick variable */
-#if (CONFIG_CPU==PP5020)
-/* A temporary hack until timer interrupt is enabled - use the RTC */
-#define current_tick ((*((volatile long*)0x60005010))/10000)
-#else
extern long current_tick;
-#endif
#ifdef SIMULATOR
#define sleep(x) sim_sleep(x)
diff --git a/firmware/kernel.c b/firmware/kernel.c
index b9aee94..6166437 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -25,9 +25,7 @@
#include "system.h"
#include "panic.h"
-#if (CONFIG_CPU != PP5020)
long current_tick = 0;
-#endif
static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
@@ -319,9 +317,36 @@ void tick_start(unsigned int interval_in_ms)
#elif CONFIG_CPU == PP5020
-void tick_start(unsigned int interval_in_ms) {
- /* TODO: Implement tick_start */
- (void)interval_in_ms;
+#define USECS_PER_INT 0x2710
+
+void TIMER1(void)
+{
+ int i;
+
+ PP5020_TIMER1_ACK;
+ /* Run through the list of tick tasks */
+ for (i = 0;i < MAX_NUM_TICK_TASKS;i++)
+ {
+ if (tick_funcs[i])
+ {
+ tick_funcs[i]();
+ }
+ }
+
+ current_tick++;
+ wake_up_thread();
+}
+
+void tick_start(unsigned int interval_in_ms)
+{
+ /* TODO: use interval_in_ms to set timer periode */
+ (void)interval_in_ms;
+ PP5020_TIMER1 = 0x0;
+ PP5020_TIMER1_ACK;
+ /* enable timer, period, trigger value 0x2710 -> 100Hz */
+ PP5020_TIMER1 = 0xc0000000 | USECS_PER_INT;
+ /* unmask interrupt source */
+ PP5020_CPU_INT_EN = PP5020_TIMER1_MASK;
}
#endif
diff --git a/firmware/system.c b/firmware/system.c
index 5e8a7cd..6ef35e8 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -1106,14 +1106,28 @@ int system_memory_guard(int newmode)
}
#elif CONFIG_CPU==PP5020
-/* TODO: Implement system.c */
-
-void system_init(void) {
+extern void TIMER1(void);
+void irq(void)
+{
+ if (PP5020_CPU_INT_STAT & PP5020_TIMER1_MASK)
+ TIMER1();
}
-void system_reboot(void) {
+void system_init(void)
+{
+ /* disable all irqs */
+ outl(-1, 0x60001138);
+ outl(-1, 0x60001128);
+ outl(-1, 0x6000111c);
+
+ outl(-1, 0x60001038);
+ outl(-1, 0x60001028);
+ outl(-1, 0x6000101c);
+}
+void system_reboot(void)
+{
}
int system_memory_guard(int newmode)
diff --git a/firmware/thread.c b/firmware/thread.c
index 7ed8dbd..13577e8 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -251,8 +251,6 @@ void switch_thread(void)
#ifdef SIMULATOR
/* Do nothing */
#else
-/* We currently have no interrupts on iPod targets, so remove this temp. */
-#if CONFIG_CPU != PP5020
while (num_sleepers == num_threads)
{
/* Enter sleep mode, woken up on interrupt */
@@ -271,7 +269,6 @@ void switch_thread(void)
#endif
}
#endif
-#endif
current = current_thread;
store_context(&thread_contexts[current]);