From 544b03cf9abafc080e10a91f65046eda540ff5ae Mon Sep 17 00:00:00 2001 From: Thom Johansen Date: Mon, 12 Dec 2005 13:53:22 +0000 Subject: 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 --- firmware/crt0.S | 5 +++++ firmware/export/kernel.h | 5 ----- firmware/kernel.c | 35 ++++++++++++++++++++++++++++++----- firmware/system.c | 22 ++++++++++++++++++---- firmware/thread.c | 3 --- 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: .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 67dadbcda5..23c7bc7cb1 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 b9aee94221..6166437282 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 5e8a7cd4d7..6ef35e8505 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 7ed8dbde37..13577e8efb 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 */ @@ -270,7 +268,6 @@ void switch_thread(void) */ #endif } -#endif #endif current = current_thread; store_context(&thread_contexts[current]); -- cgit v1.2.3