summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"))) =
void system_init(void)
{
/* Clear the accumulators. From here on it's the responsibility of
- whoever uses them to clear them after use (use movclr instruction). */
+ whoever uses them to clear them after use and before giving control
+ to "foreign" code (use movclr instruction). */
asm volatile ("movclr.l %%acc0, %%d0\n\t"
"movclr.l %%acc1, %%d0\n\t"
"movclr.l %%acc2, %%d0\n\t"
"movclr.l %%acc3, %%d0\n\t"
: : : "d0");
- /* Set EMAC unit to fractional mode with saturation, since that's
- what'll be the most useful for most things which the main thread
- will do. */
- coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
/* Set INTBASE and SPURVEC */
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)
);
}
+/* Set EMAC unit to fractional mode with saturation for each new thread,
+ since that's what'll be the most useful for most things which the dsp
+ will do. Codecs should still initialize their preferred modes
+ explicitly. */
+#define THREAD_CPU_INIT(core, thread) \
+ ({ (thread)->context.macsr = EMAC_FRACTIONAL | EMAC_SATURATE; })
+
#elif CONFIG_CPU == SH7034
/*---------------------------------------------------------------------------
* Store non-volatile context.
@@ -193,6 +200,11 @@ static inline void load_context(const void* addr)
#endif
+#ifndef THREAD_CPU_INIT
+/* No cpu specific init - make empty */
+#define THREAD_CPU_INIT(core, thread)
+#endif
+
static void add_to_list(struct thread_entry **list, struct thread_entry *thread)
{
if (*list == NULL)
@@ -660,6 +672,10 @@ struct thread_entry*
regs->sp = (void*)(((unsigned int)stack + stack_size) & ~3);
regs->start = (void*)function;
+ /* Do any CPU specific inits after initializing common items
+ to have access to valid data */
+ THREAD_CPU_INIT(core, thread);
+
return thread;
}
@@ -753,10 +769,12 @@ void init_threads(void)
* probably a much better way to do this. */
if (core == CPU)
{
+ THREAD_CPU_INIT(core, &cores[CPU].threads[0]);
cores[CPU].threads[0].stack = stackbegin;
cores[CPU].threads[0].stack_size = (int)stackend - (int)stackbegin;
} else {
#if NUM_CORES > 1 /* This code path will not be run on single core targets */
+ THREAD_CPU_INIT(core, &cores[COP].threads[0]);
cores[COP].threads[0].stack = cop_stackbegin;
cores[COP].threads[0].stack_size =
(int)cop_stackend - (int)cop_stackbegin;