1
0
Fork 0
forked from len0rd/rockbox

Anti-red: No need for COP initialization in the bootloaders nor idle stacks.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14880 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2007-09-28 10:54:27 +00:00
parent 7914e90738
commit a13a1d5492
2 changed files with 14 additions and 3 deletions

View file

@ -71,6 +71,7 @@ static inline unsigned int current_core(void)
return core;
}
#ifndef BOOTLOADER
#define CACHE_FUNCTIONS_AS_CALL
#define HAVE_INVALIDATE_ICACHE
@ -78,6 +79,7 @@ void invalidate_icache(void);
#define HAVE_FLUSH_ICACHE
void flush_icache(void);
#endif
#else
unsigned int current_core(void);

View file

@ -81,7 +81,7 @@ static void start_thread(void)
"ldr r4, [r0, #40] \n" /* start in r4 since it's non-volatile */
"mov r1, #0 \n" /* Mark thread as running */
"str r1, [r0, #40] \n"
#if NUM_CORES > 1
#if NUM_CORES > 1 && !defined (BOOTLOADER)
"ldr r0, =invalidate_icache \n" /* Invalidate this core's cache. */
"mov lr, pc \n" /* This could be the first entry into */
"bx r0 \n" /* plugin or codec code for this core. */
@ -132,11 +132,13 @@ extern int cpu_idlestackbegin[];
extern int cpu_idlestackend[];
extern int cop_idlestackbegin[];
extern int cop_idlestackend[];
#ifndef BOOTLOADER
static int * const idle_stacks[NUM_CORES] NOCACHEDATA_ATTR =
{
[CPU] = cpu_idlestackbegin,
[COP] = cop_idlestackbegin
};
#endif /* BOOTLOADER */
#else /* NUM_CORES == 1 */
#ifndef BOOTLOADER
extern int cop_stackbegin[];
@ -171,10 +173,13 @@ static inline void core_sleep(void)
*/
static inline void switch_to_idle_stack(const unsigned int core)
{
#ifndef BOOTLOADER
asm volatile (
"str sp, [%0] \n" /* save original stack pointer on idle stack */
"mov sp, %0 \n" /* switch stacks */
: : "r"(&idle_stacks[core][IDLE_STACK_WORDS-1]));
#endif
(void)core;
}
#endif /* NUM_CORES */
@ -926,7 +931,9 @@ struct thread_entry*
/* Writeback stack munging or anything else before starting */
if (core != CURRENT_CORE)
{
flush_icache();
}
#endif
/* Align stack to an even 32 bit boundary */
@ -1086,6 +1093,7 @@ void init_threads(void)
}
else
{
#ifndef BOOTLOADER
/* Initial stack is the COP idle stack */
threads[slot].stack = cop_idlestackbegin;
threads[slot].stack_size = IDLE_STACK_SIZE;
@ -1096,7 +1104,8 @@ void init_threads(void)
CPU_CTL = PROC_WAKE;
set_irq_level(0);
remove_thread(NULL);
#endif
#endif /* BOOTLOADER */
#endif /* NUM_CORES */
}
}
@ -1115,7 +1124,7 @@ int thread_stack_usage(const struct thread_entry *thread)
thread->stack_size;
}
#if NUM_CORES > 1
#if NUM_CORES > 1 && !defined (BOOTLOADER)
/*---------------------------------------------------------------------------
* Returns the maximum percentage of the core's idle stack ever used during
* runtime.