summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-09-28 10:20:02 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-09-28 10:20:02 +0000
commit7914e90738ff37e6378b37632eb1f05bab7354d5 (patch)
tree6b3d6a6bac4c7a3f82fa212d5f3ed324d81dc8bb /apps
parentedbf5d81f5a635a0db68039554b086f942b3e005 (diff)
downloadrockbox-7914e90738ff37e6378b37632eb1f05bab7354d5.tar.gz
rockbox-7914e90738ff37e6378b37632eb1f05bab7354d5.zip
Commit a subset of the dual core changes that have to do with cache handling, stacks, firmware startup and thread startup. Tested on e200, H10-20GB, iPod Color and 5.5G. Thread function return implemented for all targets. Some changes to plugins to follow shortly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14879 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs.c4
-rw-r--r--apps/codecs.h24
-rw-r--r--apps/codecs/codec_crt0.c2
-rw-r--r--apps/debug_menu.c66
-rw-r--r--apps/main.c26
-rw-r--r--apps/plugin.c5
-rw-r--r--apps/plugin.h25
7 files changed, 107 insertions, 45 deletions
diff --git a/apps/codecs.c b/apps/codecs.c
index ba9d7392b1..35cce6a861 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -157,6 +157,10 @@ struct codec_api ci = {
157 /* new stuff at the end, sort into place next time 157 /* new stuff at the end, sort into place next time
158 the API gets incompatible */ 158 the API gets incompatible */
159 159
160#ifdef CACHE_FUNCTIONS_AS_CALL
161 flush_icache,
162 invalidate_icache,
163#endif
160}; 164};
161 165
162void codec_get_full_path(char *path, const char *codec_root_fn) 166void codec_get_full_path(char *path, const char *codec_root_fn)
diff --git a/apps/codecs.h b/apps/codecs.h
index 652ae7451a..50bc36baa2 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -80,7 +80,7 @@
80#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ 80#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */
81 81
82/* increase this every time the api struct changes */ 82/* increase this every time the api struct changes */
83#define CODEC_API_VERSION 18 83#define CODEC_API_VERSION 19
84 84
85/* update this to latest version if a change to the api struct breaks 85/* update this to latest version if a change to the api struct breaks
86 backwards compatibility (and please take the opportunity to sort in any 86 backwards compatibility (and please take the opportunity to sort in any
@@ -230,6 +230,10 @@ struct codec_api {
230 /* new stuff at the end, sort into place next time 230 /* new stuff at the end, sort into place next time
231 the API gets incompatible */ 231 the API gets incompatible */
232 232
233#ifdef CACHE_FUNCTIONS_AS_CALL
234 void (*flush_icache)(void);
235 void (*invalidate_icache)(void);
236#endif
233}; 237};
234 238
235/* codec header */ 239/* codec header */
@@ -286,4 +290,22 @@ int codec_load_file(const char* codec, struct codec_api *api);
286/* defined by the codec */ 290/* defined by the codec */
287enum codec_status codec_start(struct codec_api* rockbox); 291enum codec_status codec_start(struct codec_api* rockbox);
288 292
293#ifndef CACHE_FUNCTION_WRAPPERS
294
295#ifdef CACHE_FUNCTIONS_AS_CALL
296#define CACHE_FUNCTION_WRAPPERS(api) \
297 void flush_icache(void) \
298 { \
299 (api)->flush_icache(); \
300 } \
301 void invalidate_icache(void) \
302 { \
303 (api)->invalidate_icache(); \
304 }
305#else
306#define CACHE_FUNCTION_WRAPPERS(api)
307#endif /* CACHE_FUNCTIONS_AS_CALL */
308
309#endif /* CACHE_FUNCTION_WRAPPERS */
310
289#endif 311#endif
diff --git a/apps/codecs/codec_crt0.c b/apps/codecs/codec_crt0.c
index c9c2cba370..1c61d84b47 100644
--- a/apps/codecs/codec_crt0.c
+++ b/apps/codecs/codec_crt0.c
@@ -32,6 +32,8 @@ extern unsigned char plugin_end_addr[];
32 32
33extern enum codec_status codec_main(void); 33extern enum codec_status codec_main(void);
34 34
35CACHE_FUNCTION_WRAPPERS(ci);
36
35enum codec_status codec_start(struct codec_api *api) 37enum codec_status codec_start(struct codec_api *api)
36{ 38{
37#ifndef SIMULATOR 39#ifndef SIMULATOR
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 40c0fcc9b0..15c2c93d62 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -180,7 +180,6 @@ static bool dbg_list(struct action_callback_info *info)
180/*---------------------------------------------------*/ 180/*---------------------------------------------------*/
181extern struct thread_entry threads[MAXTHREADS]; 181extern struct thread_entry threads[MAXTHREADS];
182 182
183
184static char thread_status_char(int status) 183static char thread_status_char(int status)
185{ 184{
186 switch (status) 185 switch (status)
@@ -193,42 +192,48 @@ static char thread_status_char(int status)
193 192
194 return '?'; 193 return '?';
195} 194}
196#if NUM_CORES > 1 195
197#define IF_COP2(...) __VA_ARGS__
198#else
199#define IF_COP2(...)
200#endif
201static char* threads_getname(int selected_item, void * data, char *buffer) 196static char* threads_getname(int selected_item, void * data, char *buffer)
202{ 197{
203 (void)data; 198 (void)data;
199 char name[32];
204 struct thread_entry *thread = NULL; 200 struct thread_entry *thread = NULL;
205 int status, usage; 201 unsigned status;
202 int usage;
203
204#if NUM_CORES > 1
205 if (selected_item < (int)NUM_CORES)
206 {
207 usage = idle_stack_usage(selected_item);
208 snprintf(buffer, MAX_PATH, "Idle (%d): %2d%%", selected_item, usage);
209 return buffer;
210 }
211
212 selected_item -= NUM_CORES;
213#endif
214
206 thread = &threads[selected_item]; 215 thread = &threads[selected_item];
216 status = thread_get_status(thread);
207 217
208 if (thread->name == NULL) 218 if (thread->name == NULL)
209 { 219 {
210 snprintf(buffer, MAX_PATH, "%2d: ---", selected_item); 220 snprintf(buffer, MAX_PATH, "%2d: ---", selected_item);
211 return buffer; 221 return buffer;
212 } 222 }
213 223
224 thread_get_name(name, 32, thread);
214 usage = thread_stack_usage(thread); 225 usage = thread_stack_usage(thread);
215 status = thread_get_status(thread); 226 status = thread_get_status(thread);
216#ifdef HAVE_PRIORITY_SCHEDULING 227
217 snprintf(buffer, MAX_PATH, "%2d: " IF_COP2("(%d) ") "%c%c %d %2d%% %s", 228 snprintf(buffer, MAX_PATH,
218 selected_item, 229 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d ") "%2d%% %s",
219 IF_COP2(thread->core,)
220 (status == STATE_RUNNING) ? '*' : ' ',
221 thread_status_char(status),
222 thread->priority,
223 usage, thread->name);
224#else
225 snprintf(buffer, MAX_PATH, "%2d: " IF_COP2("(%d) ") "%c%c %2d%% %s",
226 selected_item, 230 selected_item,
227 IF_COP2(thread->core,) 231 IF_COP(thread->core,)
228 (status == STATE_RUNNING) ? '*' : ' ', 232 (status == STATE_RUNNING) ? '*' : ' ',
229 thread_status_char(status), 233 thread_status_char(status),
230 usage, thread->name); 234 IF_PRIO(thread->priority,)
231#endif 235 usage, name);
236
232 return buffer; 237 return buffer;
233} 238}
234static int dbg_threads_action_callback(int action, struct action_callback_info *info) 239static int dbg_threads_action_callback(int action, struct action_callback_info *info)
@@ -236,11 +241,16 @@ static int dbg_threads_action_callback(int action, struct action_callback_info *
236#ifdef ROCKBOX_HAS_LOGF 241#ifdef ROCKBOX_HAS_LOGF
237 if (action == ACTION_STD_OK) 242 if (action == ACTION_STD_OK)
238 { 243 {
239 struct thread_entry *thread = &threads[gui_synclist_get_sel_pos(info->lists)]; 244 int selpos = gui_synclist_get_sel_pos(info->lists);
240 if (thread->name != NULL) 245#if NUM_CORES > 1
241 remove_thread(thread); 246 if (selpos >= NUM_CORES)
242 } 247 remove_thread(&threads[selpos - NUM_CORES]);
248#else
249 remove_thread(&threads[selpos]);
243#endif 250#endif
251 }
252 gui_synclist_hide_selection_marker(info->lists, false);
253#endif /* ROCKBOX_HAS_LOGF */
244 gui_synclist_draw(info->lists); 254 gui_synclist_draw(info->lists);
245 return action; 255 return action;
246} 256}
@@ -248,8 +258,12 @@ static int dbg_threads_action_callback(int action, struct action_callback_info *
248static bool dbg_os(void) 258static bool dbg_os(void)
249{ 259{
250 struct action_callback_info info; 260 struct action_callback_info info;
251 info.title = IF_COP2("Core and ") "Stack usage:"; 261 info.title = IF_COP("Core and ") "Stack usage:";
262#if NUM_CORES == 1
252 info.count = MAXTHREADS; 263 info.count = MAXTHREADS;
264#else
265 info.count = MAXTHREADS+NUM_CORES;
266#endif
253 info.selection_size = 1; 267 info.selection_size = 1;
254 info.action_callback = dbg_threads_action_callback; 268 info.action_callback = dbg_threads_action_callback;
255 info.dbg_getname = threads_getname; 269 info.dbg_getname = threads_getname;
diff --git a/apps/main.c b/apps/main.c
index a27998168c..bc8a12dd4e 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -334,9 +334,7 @@ static void init(void)
334 /* if nobody initialized ATA before, I consider this a cold start */ 334 /* if nobody initialized ATA before, I consider this a cold start */
335 bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */ 335 bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */
336#endif 336#endif
337#ifdef CPU_PP 337
338 COP_CTL = PROC_WAKE;
339#endif
340 system_init(); 338 system_init();
341 kernel_init(); 339 kernel_init();
342 340
@@ -591,25 +589,19 @@ void cop_main(void)
591 so it should not be assumed that the coprocessor be usable even on 589 so it should not be assumed that the coprocessor be usable even on
592 platforms which support it. 590 platforms which support it.
593 591
594 A kernel thread runs on the coprocessor which waits for other threads to be 592 A kernel thread is initially setup on the coprocessor and immediately
595 added, and gracefully handles RoLo */ 593 destroyed for purposes of continuity. The cop sits idle until at least
594 one thread exists on it. */
596 595
597#if CONFIG_CPU == PP5002
598/* 3G doesn't have Rolo or dual core support yet */ 596/* 3G doesn't have Rolo or dual core support yet */
599 while(1) { 597#if NUM_CORES > 1
600 COP_CTL = PROC_SLEEP;
601 }
602#else
603 extern volatile unsigned char cpu_message;
604
605 system_init(); 598 system_init();
606 kernel_init(); 599 kernel_init();
607 600 /* This should never be reached */
608 while(cpu_message != COP_REBOOT) { 601#endif
609 sleep(HZ); 602 while(1) {
603 COP_CTL = PROC_SLEEP;
610 } 604 }
611 rolo_restart_cop();
612#endif /* PP5002 */
613} 605}
614#endif /* CPU_PP */ 606#endif /* CPU_PP */
615 607
diff --git a/apps/plugin.c b/apps/plugin.c
index f56d532537..f0b86c08cb 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -509,6 +509,11 @@ static const struct plugin_api rockbox_api = {
509#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) 509#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
510 lcd_yuv_set_options, 510 lcd_yuv_set_options,
511#endif 511#endif
512
513#ifdef CACHE_FUNCTIONS_AS_CALL
514 flush_icache,
515 invalidate_icache,
516#endif
512}; 517};
513 518
514int plugin_load(const char* plugin, void* parameter) 519int plugin_load(const char* plugin, void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index a2e24f88d9..5f868e5654 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -112,7 +112,7 @@
112#define PLUGIN_MAGIC 0x526F634B /* RocK */ 112#define PLUGIN_MAGIC 0x526F634B /* RocK */
113 113
114/* increase this every time the api struct changes */ 114/* increase this every time the api struct changes */
115#define PLUGIN_API_VERSION 77 115#define PLUGIN_API_VERSION 78
116 116
117/* update this to latest version if a change to the api struct breaks 117/* update this to latest version if a change to the api struct breaks
118 backwards compatibility (and please take the opportunity to sort in any 118 backwards compatibility (and please take the opportunity to sort in any
@@ -627,6 +627,11 @@ struct plugin_api {
627#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) 627#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200)
628 void (*lcd_yuv_set_options)(unsigned options); 628 void (*lcd_yuv_set_options)(unsigned options);
629#endif 629#endif
630
631#ifdef CACHE_FUNCTIONS_AS_CALL
632 void (*flush_icache)(void);
633 void (*invalidate_icache)(void);
634#endif
630}; 635};
631 636
632/* plugin header */ 637/* plugin header */
@@ -710,4 +715,22 @@ enum plugin_status plugin_start(struct plugin_api* rockbox, void* parameter)
710 return (api)->memcmp(s1, s2, n); \ 715 return (api)->memcmp(s1, s2, n); \
711 } 716 }
712 717
718#ifndef CACHE_FUNCTION_WRAPPERS
719
720#ifdef CACHE_FUNCTIONS_AS_CALL
721#define CACHE_FUNCTION_WRAPPERS(api) \
722 void flush_icache(void) \
723 { \
724 (api)->flush_icache(); \
725 } \
726 void invalidate_icache(void) \
727 { \
728 (api)->invalidate_icache(); \
729 }
730#else
731#define CACHE_FUNCTION_WRAPPERS(api)
732#endif /* CACHE_FUNCTIONS_AS_CALL */
733
734#endif /* CACHE_FUNCTION_WRAPPERS */
735
713#endif 736#endif