diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/crt0.S | 5 | ||||
-rw-r--r-- | firmware/export/kernel.h | 5 | ||||
-rw-r--r-- | firmware/kernel.c | 35 | ||||
-rw-r--r-- | firmware/system.c | 22 | ||||
-rw-r--r-- | 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: | |||
275 | .word fiq_handler | 275 | .word fiq_handler |
276 | ecodeend: | 276 | ecodeend: |
277 | 277 | ||
278 | .global irq | ||
279 | |||
278 | undef_instr_handler: | 280 | undef_instr_handler: |
279 | software_int_handler: | 281 | software_int_handler: |
280 | reserved_handler: | 282 | reserved_handler: |
@@ -288,6 +290,9 @@ data_abort_handler: | |||
288 | subs pc, lr, #8 | 290 | subs pc, lr, #8 |
289 | 291 | ||
290 | irq_handler: | 292 | irq_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 | ||
73 | extern long current_tick; | 69 | extern 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) | ||
29 | long current_tick = 0; | 28 | long current_tick = 0; |
30 | #endif | ||
31 | 29 | ||
32 | static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); | 30 | static 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 | ||
322 | void tick_start(unsigned int interval_in_ms) { | 320 | #define USECS_PER_INT 0x2710 |
323 | /* TODO: Implement tick_start */ | 321 | |
324 | (void)interval_in_ms; | 322 | void 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 | |||
340 | void 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 */ | 1109 | extern void TIMER1(void); |
1110 | |||
1111 | void system_init(void) { | ||
1112 | 1110 | ||
1111 | void irq(void) | ||
1112 | { | ||
1113 | if (PP5020_CPU_INT_STAT & PP5020_TIMER1_MASK) | ||
1114 | TIMER1(); | ||
1113 | } | 1115 | } |
1114 | 1116 | ||
1115 | void system_reboot(void) { | 1117 | void 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 | ||
1129 | void system_reboot(void) | ||
1130 | { | ||
1117 | } | 1131 | } |
1118 | 1132 | ||
1119 | int system_memory_guard(int newmode) | 1133 | 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) | |||
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 | ||