summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/system-target.h2
-rw-r--r--firmware/thread.c15
2 files changed, 14 insertions, 3 deletions
diff --git a/firmware/target/arm/system-target.h b/firmware/target/arm/system-target.h
index 4811f7e2d6..6dc317e427 100644
--- a/firmware/target/arm/system-target.h
+++ b/firmware/target/arm/system-target.h
@@ -71,6 +71,7 @@ static inline unsigned int current_core(void)
71 return core; 71 return core;
72} 72}
73 73
74#ifndef BOOTLOADER
74#define CACHE_FUNCTIONS_AS_CALL 75#define CACHE_FUNCTIONS_AS_CALL
75 76
76#define HAVE_INVALIDATE_ICACHE 77#define HAVE_INVALIDATE_ICACHE
@@ -78,6 +79,7 @@ void invalidate_icache(void);
78 79
79#define HAVE_FLUSH_ICACHE 80#define HAVE_FLUSH_ICACHE
80void flush_icache(void); 81void flush_icache(void);
82#endif
81 83
82#else 84#else
83unsigned int current_core(void); 85unsigned int current_core(void);
diff --git a/firmware/thread.c b/firmware/thread.c
index d0a0229430..b37a99237d 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -81,7 +81,7 @@ static void start_thread(void)
81 "ldr r4, [r0, #40] \n" /* start in r4 since it's non-volatile */ 81 "ldr r4, [r0, #40] \n" /* start in r4 since it's non-volatile */
82 "mov r1, #0 \n" /* Mark thread as running */ 82 "mov r1, #0 \n" /* Mark thread as running */
83 "str r1, [r0, #40] \n" 83 "str r1, [r0, #40] \n"
84#if NUM_CORES > 1 84#if NUM_CORES > 1 && !defined (BOOTLOADER)
85 "ldr r0, =invalidate_icache \n" /* Invalidate this core's cache. */ 85 "ldr r0, =invalidate_icache \n" /* Invalidate this core's cache. */
86 "mov lr, pc \n" /* This could be the first entry into */ 86 "mov lr, pc \n" /* This could be the first entry into */
87 "bx r0 \n" /* plugin or codec code for this core. */ 87 "bx r0 \n" /* plugin or codec code for this core. */
@@ -132,11 +132,13 @@ extern int cpu_idlestackbegin[];
132extern int cpu_idlestackend[]; 132extern int cpu_idlestackend[];
133extern int cop_idlestackbegin[]; 133extern int cop_idlestackbegin[];
134extern int cop_idlestackend[]; 134extern int cop_idlestackend[];
135#ifndef BOOTLOADER
135static int * const idle_stacks[NUM_CORES] NOCACHEDATA_ATTR = 136static int * const idle_stacks[NUM_CORES] NOCACHEDATA_ATTR =
136{ 137{
137 [CPU] = cpu_idlestackbegin, 138 [CPU] = cpu_idlestackbegin,
138 [COP] = cop_idlestackbegin 139 [COP] = cop_idlestackbegin
139}; 140};
141#endif /* BOOTLOADER */
140#else /* NUM_CORES == 1 */ 142#else /* NUM_CORES == 1 */
141#ifndef BOOTLOADER 143#ifndef BOOTLOADER
142extern int cop_stackbegin[]; 144extern int cop_stackbegin[];
@@ -171,10 +173,13 @@ static inline void core_sleep(void)
171 */ 173 */
172static inline void switch_to_idle_stack(const unsigned int core) 174static inline void switch_to_idle_stack(const unsigned int core)
173{ 175{
176#ifndef BOOTLOADER
174 asm volatile ( 177 asm volatile (
175 "str sp, [%0] \n" /* save original stack pointer on idle stack */ 178 "str sp, [%0] \n" /* save original stack pointer on idle stack */
176 "mov sp, %0 \n" /* switch stacks */ 179 "mov sp, %0 \n" /* switch stacks */
177 : : "r"(&idle_stacks[core][IDLE_STACK_WORDS-1])); 180 : : "r"(&idle_stacks[core][IDLE_STACK_WORDS-1]));
181#endif
182 (void)core;
178} 183}
179#endif /* NUM_CORES */ 184#endif /* NUM_CORES */
180 185
@@ -926,7 +931,9 @@ struct thread_entry*
926 931
927 /* Writeback stack munging or anything else before starting */ 932 /* Writeback stack munging or anything else before starting */
928 if (core != CURRENT_CORE) 933 if (core != CURRENT_CORE)
934 {
929 flush_icache(); 935 flush_icache();
936 }
930#endif 937#endif
931 938
932 /* Align stack to an even 32 bit boundary */ 939 /* Align stack to an even 32 bit boundary */
@@ -1086,6 +1093,7 @@ void init_threads(void)
1086 } 1093 }
1087 else 1094 else
1088 { 1095 {
1096#ifndef BOOTLOADER
1089 /* Initial stack is the COP idle stack */ 1097 /* Initial stack is the COP idle stack */
1090 threads[slot].stack = cop_idlestackbegin; 1098 threads[slot].stack = cop_idlestackbegin;
1091 threads[slot].stack_size = IDLE_STACK_SIZE; 1099 threads[slot].stack_size = IDLE_STACK_SIZE;
@@ -1096,7 +1104,8 @@ void init_threads(void)
1096 CPU_CTL = PROC_WAKE; 1104 CPU_CTL = PROC_WAKE;
1097 set_irq_level(0); 1105 set_irq_level(0);
1098 remove_thread(NULL); 1106 remove_thread(NULL);
1099#endif 1107#endif /* BOOTLOADER */
1108#endif /* NUM_CORES */
1100 } 1109 }
1101} 1110}
1102 1111
@@ -1115,7 +1124,7 @@ int thread_stack_usage(const struct thread_entry *thread)
1115 thread->stack_size; 1124 thread->stack_size;
1116} 1125}
1117 1126
1118#if NUM_CORES > 1 1127#if NUM_CORES > 1 && !defined (BOOTLOADER)
1119/*--------------------------------------------------------------------------- 1128/*---------------------------------------------------------------------------
1120 * Returns the maximum percentage of the core's idle stack ever used during 1129 * Returns the maximum percentage of the core's idle stack ever used during
1121 * runtime. 1130 * runtime.