summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-02-25 21:43:10 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-02-25 21:43:10 +0000
commit2c9cbc12e137b1c756721a8fc4df6003032b0b53 (patch)
treea9ac372f2cf28287deaa17a786e4bba9be339263
parentf5184f34bfd794884d18057a594e7acb9aeb00e4 (diff)
downloadrockbox-2c9cbc12e137b1c756721a8fc4df6003032b0b53.tar.gz
rockbox-2c9cbc12e137b1c756721a8fc4df6003032b0b53.zip
Add CPU-model-specific init to newborn threads. Add default %macsr for each thread created on coldfire (EMAC_FRACTIONAL | EMAC_SATURATE).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12483 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/coldfire/system-coldfire.c7
-rw-r--r--firmware/thread.c18
2 files changed, 20 insertions, 5 deletions
diff --git a/firmware/target/coldfire/system-coldfire.c b/firmware/target/coldfire/system-coldfire.c
index 9e5db41daa..4094f3875f 100644
--- a/firmware/target/coldfire/system-coldfire.c
+++ b/firmware/target/coldfire/system-coldfire.c
@@ -234,16 +234,13 @@ void (* const vbr[]) (void) __attribute__ ((section (".vectors"))) =
234void system_init(void) 234void system_init(void)
235{ 235{
236 /* Clear the accumulators. From here on it's the responsibility of 236 /* Clear the accumulators. From here on it's the responsibility of
237 whoever uses them to clear them after use (use movclr instruction). */ 237 whoever uses them to clear them after use and before giving control
238 to "foreign" code (use movclr instruction). */
238 asm volatile ("movclr.l %%acc0, %%d0\n\t" 239 asm volatile ("movclr.l %%acc0, %%d0\n\t"
239 "movclr.l %%acc1, %%d0\n\t" 240 "movclr.l %%acc1, %%d0\n\t"
240 "movclr.l %%acc2, %%d0\n\t" 241 "movclr.l %%acc2, %%d0\n\t"
241 "movclr.l %%acc3, %%d0\n\t" 242 "movclr.l %%acc3, %%d0\n\t"
242 : : : "d0"); 243 : : : "d0");
243 /* Set EMAC unit to fractional mode with saturation, since that's
244 what'll be the most useful for most things which the main thread
245 will do. */
246 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
247 244
248 /* Set INTBASE and SPURVEC */ 245 /* Set INTBASE and SPURVEC */
249 INTBASE = 64; 246 INTBASE = 64;
diff --git a/firmware/thread.c b/firmware/thread.c
index 6a583a470a..05325bb341 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -141,6 +141,13 @@ static inline void load_context(const void* addr)
141 ); 141 );
142} 142}
143 143
144/* Set EMAC unit to fractional mode with saturation for each new thread,
145 since that's what'll be the most useful for most things which the dsp
146 will do. Codecs should still initialize their preferred modes
147 explicitly. */
148#define THREAD_CPU_INIT(core, thread) \
149 ({ (thread)->context.macsr = EMAC_FRACTIONAL | EMAC_SATURATE; })
150
144#elif CONFIG_CPU == SH7034 151#elif CONFIG_CPU == SH7034
145/*--------------------------------------------------------------------------- 152/*---------------------------------------------------------------------------
146 * Store non-volatile context. 153 * Store non-volatile context.
@@ -193,6 +200,11 @@ static inline void load_context(const void* addr)
193 200
194#endif 201#endif
195 202
203#ifndef THREAD_CPU_INIT
204/* No cpu specific init - make empty */
205#define THREAD_CPU_INIT(core, thread)
206#endif
207
196static void add_to_list(struct thread_entry **list, struct thread_entry *thread) 208static void add_to_list(struct thread_entry **list, struct thread_entry *thread)
197{ 209{
198 if (*list == NULL) 210 if (*list == NULL)
@@ -660,6 +672,10 @@ struct thread_entry*
660 regs->sp = (void*)(((unsigned int)stack + stack_size) & ~3); 672 regs->sp = (void*)(((unsigned int)stack + stack_size) & ~3);
661 regs->start = (void*)function; 673 regs->start = (void*)function;
662 674
675 /* Do any CPU specific inits after initializing common items
676 to have access to valid data */
677 THREAD_CPU_INIT(core, thread);
678
663 return thread; 679 return thread;
664} 680}
665 681
@@ -753,10 +769,12 @@ void init_threads(void)
753 * probably a much better way to do this. */ 769 * probably a much better way to do this. */
754 if (core == CPU) 770 if (core == CPU)
755 { 771 {
772 THREAD_CPU_INIT(core, &cores[CPU].threads[0]);
756 cores[CPU].threads[0].stack = stackbegin; 773 cores[CPU].threads[0].stack = stackbegin;
757 cores[CPU].threads[0].stack_size = (int)stackend - (int)stackbegin; 774 cores[CPU].threads[0].stack_size = (int)stackend - (int)stackbegin;
758 } else { 775 } else {
759#if NUM_CORES > 1 /* This code path will not be run on single core targets */ 776#if NUM_CORES > 1 /* This code path will not be run on single core targets */
777 THREAD_CPU_INIT(core, &cores[COP].threads[0]);
760 cores[COP].threads[0].stack = cop_stackbegin; 778 cores[COP].threads[0].stack = cop_stackbegin;
761 cores[COP].threads[0].stack_size = 779 cores[COP].threads[0].stack_size =
762 (int)cop_stackend - (int)cop_stackbegin; 780 (int)cop_stackend - (int)cop_stackbegin;