Dual core support for PP502x players (iPod G4 and later, iriver h10, Sansa - iPod G3 will be coming soon.) This allows threads to be run on either core provided that all communications between the cores is done using uncached memory. There should be no significant change in battery life from doing this. Documentation (on the RockboxKernel wiki page) will follow shortly.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12601 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Ankers 2007-03-04 20:06:41 +00:00
parent 74e572c9d6
commit 82f9056988
38 changed files with 379 additions and 211 deletions

View file

@ -123,7 +123,7 @@ struct codec_api ci = {
&current_tick,
default_event_handler,
default_event_handler_ex,
create_thread_on_core,
create_thread,
remove_thread,
reset_poweroff_timer,
#ifndef SIMULATOR

View file

@ -199,9 +199,10 @@ struct codec_api {
long* current_tick;
long (*default_event_handler)(long event);
long (*default_event_handler_ex)(long event, void (*callback)(void *), void *parameter);
struct thread_entry* (*create_thread)(unsigned int core, void (*function)(void),
struct thread_entry* (*create_thread)(void (*function)(void),
void* stack, int stack_size, const char *name
IF_PRIO(, int priority));
IF_PRIO(, int priority)
IF_COP(, unsigned int core, bool fallback));
void (*remove_thread)(struct thread_entry *thread);
void (*reset_poweroff_timer)(void);
#ifndef SIMULATOR

View file

@ -296,6 +296,9 @@ static void init(void)
#if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
/* if nobody initialized ATA before, I consider this a cold start */
bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */
#endif
#ifdef CPU_PP
COP_CTL = PROC_WAKE;
#endif
system_init();
kernel_init();
@ -549,19 +552,22 @@ void cop_main(void)
so it should not be assumed that the coprocessor be usable even on
platforms which support it.
At present the COP sleeps unless it receives a message from the CPU telling
it that we are loading a new kernel, so must reboot */
A kernel thread runs on the coprocessor which waits for other threads to be
added, and gracefully handles RoLo */
#if CONFIG_CPU == PP5002
/* 3G doesn't have Rolo support yet */
/* 3G doesn't have Rolo or dual core support yet */
while(1) {
COP_CTL = PROC_SLEEP;
}
#else
extern volatile unsigned char cpu_message;
system_init();
kernel_init();
while(cpu_message != COP_REBOOT) {
COP_CTL = PROC_SLEEP;
sleep(HZ);
}
rolo_restart_cop();
#endif /* PP5002 */

View file

@ -194,9 +194,9 @@ static bool audio_is_initialized = false;
/* TBD: Split out "audio" and "playback" (ie. calling) threads */
/* Main state control */
static volatile bool audio_codec_loaded; /* Is codec loaded? (C/A-) */
static volatile bool playing; /* Is audio playing? (A) */
static volatile bool paused; /* Is audio paused? (A/C-) */
static volatile bool audio_codec_loaded NOCACHEBSS_ATTR;/* Codec loaded? (C/A-) */
static volatile bool playing NOCACHEBSS_ATTR; /* Is audio playing? (A) */
static volatile bool paused NOCACHEBSS_ATTR; /* Is audio paused? (A/C-) */
static volatile bool filling IDATA_ATTR; /* Is file buffer refilling? (A/C-) */
/* Ring buffer where compressed audio and codecs are loaded */
@ -290,7 +290,7 @@ static void audio_reset_buffer(size_t pcmbufsize);
/* Codec thread */
extern struct codec_api ci;
static struct event_queue codec_queue;
static struct event_queue codec_queue NOCACHEBSS_ATTR;
static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)]
IBSS_ATTR;
static const char codec_thread_name[] = "codec";
@ -304,7 +304,7 @@ static volatile int current_codec IDATA_ATTR; /* Current codec (normal/voice) */
extern struct codec_api ci_voice;
static struct thread_entry *voice_thread_p = NULL;
static struct event_queue voice_queue;
static struct event_queue voice_queue NOCACHEBSS_ATTR;
static long voice_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)]
IBSS_ATTR_VOICE_STACK;
static const char voice_thread_name[] = "voice codec";
@ -324,12 +324,12 @@ static unsigned char *iram_buf[2] = { NULL, NULL };
/* Pointer to DRAM buffers for normal/voice codecs */
static unsigned char *dram_buf[2] = { NULL, NULL };
/* Mutex to control which codec (normal/voice) is running */
static struct mutex mutex_codecthread;
static struct mutex mutex_codecthread NOCACHEBSS_ATTR;
/* Voice state */
static volatile bool voice_thread_start; /* Triggers voice playback (A/V) */
static volatile bool voice_is_playing; /* Is voice currently playing? (V) */
static volatile bool voice_codec_loaded; /* Is voice codec loaded (V/A-) */
static volatile bool voice_is_playing NOCACHEBSS_ATTR; /* Is voice currently playing? (V) */
static volatile bool voice_codec_loaded NOCACHEBSS_ATTR; /* Is voice codec loaded (V/A-) */
static char *voicebuf;
static size_t voice_remaining;
@ -863,7 +863,8 @@ void audio_preinit(void)
queue_init(&codec_queue, true);
create_thread(audio_thread, audio_stack, sizeof(audio_stack),
audio_thread_name IF_PRIO(, PRIORITY_BUFFERING));
audio_thread_name IF_PRIO(, PRIORITY_BUFFERING)
IF_COP(, CPU, false));
}
void audio_init(void)
@ -888,7 +889,7 @@ void voice_init(void)
queue_init(&voice_queue, true);
voice_thread_p = create_thread(voice_thread, voice_stack,
sizeof(voice_stack), voice_thread_name
IF_PRIO(, PRIORITY_PLAYBACK));
IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, CPU, false));
while (!voice_codec_loaded)
yield();
@ -3533,7 +3534,8 @@ static void audio_playback_init(void)
codec_thread_p = create_thread(
codec_thread, codec_stack, sizeof(codec_stack),
codec_thread_name IF_PRIO(, PRIORITY_PLAYBACK));
codec_thread_name IF_PRIO(, PRIORITY_PLAYBACK)
IF_COP(, COP, true));
while (1)
{

View file

@ -1873,7 +1873,8 @@ void playlist_init(void)
memset(playlist->filenames, 0,
playlist->max_playlist_size * sizeof(int));
create_thread(playlist_thread, playlist_stack, sizeof(playlist_stack),
playlist_thread_name IF_PRIO(, PRIORITY_BACKGROUND));
playlist_thread_name IF_PRIO(, PRIORITY_BACKGROUND)
IF_COP(, CPU, false));
queue_init(&playlist_queue, true);
#endif
}

View file

@ -481,7 +481,6 @@ static const struct plugin_api rockbox_api = {
sound_default,
pcm_record_more,
#endif
create_thread_on_core,
#ifdef IRIVER_H100_SERIES
/* Routines for the iriver_flash -plugin. */

View file

@ -327,7 +327,8 @@ struct plugin_api {
long (*default_event_handler_ex)(long event, void (*callback)(void *), void *parameter);
struct thread_entry* (*create_thread)(void (*function)(void), void* stack,
int stack_size, const char *name
IF_PRIO(, int priority));
IF_PRIO(, int priority)
IF_COP(, unsigned int core, bool fallback));
void (*remove_thread)(struct thread_entry *thread);
void (*reset_poweroff_timer)(void);
#ifndef SIMULATOR
@ -595,11 +596,6 @@ struct plugin_api {
void (*pcm_record_more)(void *start, size_t size);
#endif
struct thread_entry*(*create_thread_on_core)(
unsigned int core, void (*function)(void),
void* stack, int stack_size,
const char *name IF_PRIO(, int priority));
#ifdef IRIVER_H100_SERIES
/* Routines for the iriver_flash -plugin. */
bool (*detect_original_firmware)(void);

View file

@ -1171,7 +1171,8 @@ int main(void* parameter)
rb->memset(&gTread, 0, sizeof(gTread));
gTread.foreground = true;
rb->create_thread(thread, stack, stacksize, "CDC"
IF_PRIO(, PRIORITY_BACKGROUND));
IF_PRIO(, PRIORITY_BACKGROUND)
IF_COP(, CPU, false));
#ifdef DEBUG
do

View file

@ -479,7 +479,8 @@ int main(void)
rb->queue_init(&thread_q, true); /* put the thread's queue in the bcast list */
if(rb->create_thread(thread, thread_stack,
sizeof(thread_stack), "Battery Benchmark"
IF_PRIO(, PRIORITY_BACKGROUND)) == NULL)
IF_PRIO(, PRIORITY_BACKGROUND)
IF_COP(, CPU, false)) == NULL)
{
rb->splash(HZ,true,"Cannot create thread!");
return PLUGIN_ERROR;

View file

@ -909,19 +909,17 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
videostatus = STREAM_PLAYING;
/* We put the video thread on the second processor for multi-core targets. */
#if NUM_CORES > 1
if ((videothread_id = rb->create_thread_on_core(COP,decode_mpeg2,
#else
if ((videothread_id = rb->create_thread(decode_mpeg2,
#endif
(uint8_t*)video_stack,VIDEO_STACKSIZE,"mpgvideo" IF_PRIO(,PRIORITY_PLAYBACK))) == NULL)
(uint8_t*)video_stack,VIDEO_STACKSIZE,"mpgvideo" IF_PRIO(,PRIORITY_PLAYBACK)
IF_COP(, COP, true))) == NULL)
{
rb->splash(HZ,true,"Cannot create video thread!");
return PLUGIN_ERROR;
}
if ((audiothread_id = rb->create_thread(mad_decode,
(uint8_t*)audio_stack,AUDIO_STACKSIZE,"mpgaudio" IF_PRIO(,PRIORITY_PLAYBACK))) == NULL)
(uint8_t*)audio_stack,AUDIO_STACKSIZE,"mpgaudio" IF_PRIO(,PRIORITY_PLAYBACK)
IF_COP(, CPU, false))) == NULL)
{
rb->splash(HZ,true,"Cannot create audio thread!");
rb->remove_thread(videothread_id);

View file

@ -3941,7 +3941,8 @@ void tagcache_init(void)
queue_init(&tagcache_queue, true);
create_thread(tagcache_thread, tagcache_stack,
sizeof(tagcache_stack), tagcache_thread_name
IF_PRIO(, PRIORITY_BACKGROUND));
IF_PRIO(, PRIORITY_BACKGROUND)
IF_COP(, CPU, false));
#else
tc_stat.initialized = true;
allocate_tempbuf();