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:
parent
7914e90738
commit
a13a1d5492
2 changed files with 14 additions and 3 deletions
|
@ -71,6 +71,7 @@ static inline unsigned int current_core(void)
|
||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef BOOTLOADER
|
||||||
#define CACHE_FUNCTIONS_AS_CALL
|
#define CACHE_FUNCTIONS_AS_CALL
|
||||||
|
|
||||||
#define HAVE_INVALIDATE_ICACHE
|
#define HAVE_INVALIDATE_ICACHE
|
||||||
|
@ -78,6 +79,7 @@ void invalidate_icache(void);
|
||||||
|
|
||||||
#define HAVE_FLUSH_ICACHE
|
#define HAVE_FLUSH_ICACHE
|
||||||
void flush_icache(void);
|
void flush_icache(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
unsigned int current_core(void);
|
unsigned int current_core(void);
|
||||||
|
|
|
@ -81,7 +81,7 @@ static void start_thread(void)
|
||||||
"ldr r4, [r0, #40] \n" /* start in r4 since it's non-volatile */
|
"ldr r4, [r0, #40] \n" /* start in r4 since it's non-volatile */
|
||||||
"mov r1, #0 \n" /* Mark thread as running */
|
"mov r1, #0 \n" /* Mark thread as running */
|
||||||
"str r1, [r0, #40] \n"
|
"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. */
|
"ldr r0, =invalidate_icache \n" /* Invalidate this core's cache. */
|
||||||
"mov lr, pc \n" /* This could be the first entry into */
|
"mov lr, pc \n" /* This could be the first entry into */
|
||||||
"bx r0 \n" /* plugin or codec code for this core. */
|
"bx r0 \n" /* plugin or codec code for this core. */
|
||||||
|
@ -132,11 +132,13 @@ extern int cpu_idlestackbegin[];
|
||||||
extern int cpu_idlestackend[];
|
extern int cpu_idlestackend[];
|
||||||
extern int cop_idlestackbegin[];
|
extern int cop_idlestackbegin[];
|
||||||
extern int cop_idlestackend[];
|
extern int cop_idlestackend[];
|
||||||
|
#ifndef BOOTLOADER
|
||||||
static int * const idle_stacks[NUM_CORES] NOCACHEDATA_ATTR =
|
static int * const idle_stacks[NUM_CORES] NOCACHEDATA_ATTR =
|
||||||
{
|
{
|
||||||
[CPU] = cpu_idlestackbegin,
|
[CPU] = cpu_idlestackbegin,
|
||||||
[COP] = cop_idlestackbegin
|
[COP] = cop_idlestackbegin
|
||||||
};
|
};
|
||||||
|
#endif /* BOOTLOADER */
|
||||||
#else /* NUM_CORES == 1 */
|
#else /* NUM_CORES == 1 */
|
||||||
#ifndef BOOTLOADER
|
#ifndef BOOTLOADER
|
||||||
extern int cop_stackbegin[];
|
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)
|
static inline void switch_to_idle_stack(const unsigned int core)
|
||||||
{
|
{
|
||||||
|
#ifndef BOOTLOADER
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"str sp, [%0] \n" /* save original stack pointer on idle stack */
|
"str sp, [%0] \n" /* save original stack pointer on idle stack */
|
||||||
"mov sp, %0 \n" /* switch stacks */
|
"mov sp, %0 \n" /* switch stacks */
|
||||||
: : "r"(&idle_stacks[core][IDLE_STACK_WORDS-1]));
|
: : "r"(&idle_stacks[core][IDLE_STACK_WORDS-1]));
|
||||||
|
#endif
|
||||||
|
(void)core;
|
||||||
}
|
}
|
||||||
#endif /* NUM_CORES */
|
#endif /* NUM_CORES */
|
||||||
|
|
||||||
|
@ -926,7 +931,9 @@ struct thread_entry*
|
||||||
|
|
||||||
/* Writeback stack munging or anything else before starting */
|
/* Writeback stack munging or anything else before starting */
|
||||||
if (core != CURRENT_CORE)
|
if (core != CURRENT_CORE)
|
||||||
|
{
|
||||||
flush_icache();
|
flush_icache();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Align stack to an even 32 bit boundary */
|
/* Align stack to an even 32 bit boundary */
|
||||||
|
@ -1086,6 +1093,7 @@ void init_threads(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifndef BOOTLOADER
|
||||||
/* Initial stack is the COP idle stack */
|
/* Initial stack is the COP idle stack */
|
||||||
threads[slot].stack = cop_idlestackbegin;
|
threads[slot].stack = cop_idlestackbegin;
|
||||||
threads[slot].stack_size = IDLE_STACK_SIZE;
|
threads[slot].stack_size = IDLE_STACK_SIZE;
|
||||||
|
@ -1096,7 +1104,8 @@ void init_threads(void)
|
||||||
CPU_CTL = PROC_WAKE;
|
CPU_CTL = PROC_WAKE;
|
||||||
set_irq_level(0);
|
set_irq_level(0);
|
||||||
remove_thread(NULL);
|
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;
|
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
|
* Returns the maximum percentage of the core's idle stack ever used during
|
||||||
* runtime.
|
* runtime.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue