diff options
Diffstat (limited to 'firmware/thread.c')
-rw-r--r-- | firmware/thread.c | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/firmware/thread.c b/firmware/thread.c index 1875650050..bb3c321ddf 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 && !defined (BOOTLOADER) | 84 | #if NUM_CORES > 1 |
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,23 +132,11 @@ extern int cpu_idlestackbegin[]; | |||
132 | extern int cpu_idlestackend[]; | 132 | extern int cpu_idlestackend[]; |
133 | extern int cop_idlestackbegin[]; | 133 | extern int cop_idlestackbegin[]; |
134 | extern int cop_idlestackend[]; | 134 | extern int cop_idlestackend[]; |
135 | #ifndef BOOTLOADER | ||
136 | static int * const idle_stacks[NUM_CORES] NOCACHEDATA_ATTR = | 135 | static int * const idle_stacks[NUM_CORES] NOCACHEDATA_ATTR = |
137 | { | 136 | { |
138 | [CPU] = cpu_idlestackbegin, | 137 | [CPU] = cpu_idlestackbegin, |
139 | [COP] = cop_idlestackbegin | 138 | [COP] = cop_idlestackbegin |
140 | }; | 139 | }; |
141 | #endif /* BOOTLOADER */ | ||
142 | #else /* NUM_CORES == 1 */ | ||
143 | #ifndef BOOTLOADER | ||
144 | extern int cop_stackbegin[]; | ||
145 | extern int cop_stackend[]; | ||
146 | #else | ||
147 | /* The coprocessor stack is not set up in the bootloader code, but the threading | ||
148 | * is. No threads are run on the coprocessor, so set up some dummy stack */ | ||
149 | int *cop_stackbegin = stackbegin; | ||
150 | int *cop_stackend = stackend; | ||
151 | #endif /* BOOTLOADER */ | ||
152 | #endif /* NUM_CORES */ | 140 | #endif /* NUM_CORES */ |
153 | 141 | ||
154 | static inline void core_sleep(void) | 142 | static inline void core_sleep(void) |
@@ -173,12 +161,10 @@ static inline void core_sleep(void) | |||
173 | */ | 161 | */ |
174 | static inline void switch_to_idle_stack(const unsigned int core) | 162 | static inline void switch_to_idle_stack(const unsigned int core) |
175 | { | 163 | { |
176 | #ifndef BOOTLOADER | ||
177 | asm volatile ( | 164 | asm volatile ( |
178 | "str sp, [%0] \n" /* save original stack pointer on idle stack */ | 165 | "str sp, [%0] \n" /* save original stack pointer on idle stack */ |
179 | "mov sp, %0 \n" /* switch stacks */ | 166 | "mov sp, %0 \n" /* switch stacks */ |
180 | : : "r"(&idle_stacks[core][IDLE_STACK_WORDS-1])); | 167 | : : "r"(&idle_stacks[core][IDLE_STACK_WORDS-1])); |
181 | #endif | ||
182 | (void)core; | 168 | (void)core; |
183 | } | 169 | } |
184 | #endif /* NUM_CORES */ | 170 | #endif /* NUM_CORES */ |
@@ -1086,17 +1072,14 @@ void init_threads(void) | |||
1086 | /* Mark CPU initialized */ | 1072 | /* Mark CPU initialized */ |
1087 | cores[CPU].kernel_running = true; | 1073 | cores[CPU].kernel_running = true; |
1088 | /* Do _not_ wait for the COP to init in the bootloader because it doesn't */ | 1074 | /* Do _not_ wait for the COP to init in the bootloader because it doesn't */ |
1089 | #ifndef BOOTLOADER | ||
1090 | /* TODO: HAL interface for this */ | 1075 | /* TODO: HAL interface for this */ |
1091 | /* Wake up coprocessor and let it initialize kernel and threads */ | 1076 | /* Wake up coprocessor and let it initialize kernel and threads */ |
1092 | COP_CTL = PROC_WAKE; | 1077 | COP_CTL = PROC_WAKE; |
1093 | /* Sleep until finished */ | 1078 | /* Sleep until finished */ |
1094 | CPU_CTL = PROC_SLEEP; | 1079 | CPU_CTL = PROC_SLEEP; |
1095 | #endif | ||
1096 | } | 1080 | } |
1097 | else | 1081 | else |
1098 | { | 1082 | { |
1099 | #ifndef BOOTLOADER | ||
1100 | /* Initial stack is the COP idle stack */ | 1083 | /* Initial stack is the COP idle stack */ |
1101 | threads[slot].stack = cop_idlestackbegin; | 1084 | threads[slot].stack = cop_idlestackbegin; |
1102 | threads[slot].stack_size = IDLE_STACK_SIZE; | 1085 | threads[slot].stack_size = IDLE_STACK_SIZE; |
@@ -1107,7 +1090,6 @@ void init_threads(void) | |||
1107 | CPU_CTL = PROC_WAKE; | 1090 | CPU_CTL = PROC_WAKE; |
1108 | set_irq_level(0); | 1091 | set_irq_level(0); |
1109 | remove_thread(NULL); | 1092 | remove_thread(NULL); |
1110 | #endif /* BOOTLOADER */ | ||
1111 | #endif /* NUM_CORES */ | 1093 | #endif /* NUM_CORES */ |
1112 | } | 1094 | } |
1113 | } | 1095 | } |
@@ -1127,7 +1109,7 @@ int thread_stack_usage(const struct thread_entry *thread) | |||
1127 | thread->stack_size; | 1109 | thread->stack_size; |
1128 | } | 1110 | } |
1129 | 1111 | ||
1130 | #if NUM_CORES > 1 && !defined (BOOTLOADER) | 1112 | #if NUM_CORES > 1 |
1131 | /*--------------------------------------------------------------------------- | 1113 | /*--------------------------------------------------------------------------- |
1132 | * Returns the maximum percentage of the core's idle stack ever used during | 1114 | * Returns the maximum percentage of the core's idle stack ever used during |
1133 | * runtime. | 1115 | * runtime. |