rendered paste bodyIndex: apps/main.c
===================================================================
RCS file: /cvsroot/rockbox/apps/main.c,v
retrieving revision 1.178
diff -u -b -r1.178 main.c
--- apps/main.c 21 Jul 2006 08:42:27 -0000 1.178
+++ apps/main.c 3 Aug 2006 12:45:17 -0000
@@ -99,6 +99,7 @@
/*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */
const char appsversion[]=APPSVERSION;
+bool cop_is_available IDATA_ATTR = false;
void init(void);
@@ -451,6 +452,20 @@
#endif
}
+void cop_main(void)
+{
+/* This is the entry point for the coprocessor
+ Anyone not running an upgraded bootloader will never reach this point,
+ so it should not be assumed that the coprocessor be usable even on
+ platforms which support it.
+
+ At present all we do is send the COP to sleep if anything wakes it. */
+ while(1) {
+ cop_is_available = true;
+ sleep(1);
+ }
+}
+
int main(void)
{
app_main();
Index: firmware/thread.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/thread.c,v
retrieving revision 1.59
diff -u -b -r1.59 thread.c
--- firmware/thread.c 8 Feb 2006 21:30:35 -0000 1.59
+++ firmware/thread.c 3 Aug 2006 12:45:23 -0000
@@ -23,6 +23,7 @@
#include "system.h"
#include "kernel.h"
#include "cpu.h"
+#include "string.h"
#ifdef CPU_COLDFIRE
struct regs
@@ -48,6 +49,9 @@
void *sp; /* Stack pointer (r13) */
unsigned int lr; /* r14 (lr) */
void *start; /* Thread start address, or NULL when started */
+#ifdef CPU_PP
+ bool run_on_cop; /* Thread should be run on the coprocessor */
+#endif
};
#elif CONFIG_CPU == TCC730
struct regs
@@ -74,6 +78,16 @@
extern int stackbegin[];
extern int stackend[];
+#ifdef CPU_PP
+static const char cop_main_thread_name[] = "main_coprocessor";
+
+extern int cop_stackbegin[];
+extern int cop_stackend[];
+
+extern void cop_main(void);
+extern bool cop_is_available;
+#endif
+
void switch_thread(void) ICODE_ATTR;
static inline void store_context(void* addr) __attribute__ ((always_inline));
static inline void load_context(const void* addr) __attribute__ ((always_inline));
@@ -292,8 +306,17 @@
panicf("Stkov %s", thread_name[current]);
#endif
+#ifdef CPU_PP
+ /* Find the next thread on this processor */
+ while(thread_contexts[++current].run_on_cop !=
+ thread_contexts[current_thread].run_on_cop){
+ if (current >= num_threads)
+ current = -1;
+ }
+#else
if (++current >= num_threads)
current = 0;
+#endif
current_thread = current;
load_context(&thread_contexts[current]);
@@ -351,6 +374,13 @@
regs->started = 0;
#endif
regs->start = (void*)function;
+#ifdef CPU_PP
+ if((cop_is_available) && strncmp(thread_name[num_threads], "codec_thread", 14)){
+ regs->run_on_cop = true;
+ } else {
+ regs->run_on_cop = false;
+ }
+#endif
wake_up_thread();
return num_threads++; /* return the current ID, e.g for remove_thread() */
@@ -396,6 +426,17 @@
thread_contexts[0].start = 0; /* thread 0 already running */
#endif
num_sleepers = 0;
+#ifdef CPU_PP
+ thread_contexts[0].run_on_cop = false;
+ /* If the COP has not been set up, then the next thread will never be
+ run. */
+ num_threads++;
+ thread_name[1] = cop_main_thread_name;
+ thread_stack[1] = cop_stackbegin;
+ thread_stack_size[1] = (int)cop_stackend - (int)cop_stackbegin;
+ thread_contexts[1].start = &cop_main;
+ thread_contexts[1].run_on_cop = true;
+#endif
}
int thread_stack_usage(int threadnum)