@@ -12,6 +12,15 @@ static hwtimer_t xKernelTimer;
12
12
13
13
uint32_t ulPortYieldRequired [ portMAX_CORE_COUNT ] = { pdFALSE };
14
14
15
+ /* When this port was designed, it was assumed that pxCurrentTCBs would always
16
+ exist and that it would always be an array containing pointers to the current
17
+ TCBs for each core. In v11, this is not the case; if we are only running one
18
+ core, the symbol is pxCurrentTCB instead. Therefore, this port adds a layer
19
+ of indirection - we populate this pointer-to-pointer in the RTOS kernel entry
20
+ function below. This makes this port agnostic to whether it is running on SMP
21
+ or singlecore RTOS. */
22
+ void * * xcorePvtTCBContainer ;
23
+
15
24
/*-----------------------------------------------------------*/
16
25
17
26
void vIntercoreInterruptISR ( void )
@@ -140,15 +149,37 @@ DEFINE_RTOS_KERNEL_ENTRY( void, vPortStartSchedulerOnCore, void )
140
149
}
141
150
#endif
142
151
152
+ /* Populate the TCBContainer depending on whether we're singlecore or SMP */
153
+ #if ( configNUMBER_OF_CORES == 1 )
154
+ {
155
+ asm volatile (
156
+ "ldaw %0, dp[pxCurrentTCB]\n\t"
157
+ : "=r" (xcorePvtTCBContainer )
158
+ : /* no inputs */
159
+ : /* no clobbers */
160
+ );
161
+ }
162
+ #else
163
+ {
164
+ asm volatile (
165
+ "ldaw %0, dp[pxCurrentTCBs]\n\t"
166
+ : "=r" (xcorePvtTCBContainer )
167
+ : /* no inputs */
168
+ : /* no clobbers */
169
+ );
170
+ }
171
+
172
+ #endif
173
+
143
174
debug_printf ( "FreeRTOS Core %d initialized\n" , xCoreID );
144
175
145
176
/*
146
177
* Restore the context of the first thread
147
178
* to run and jump into it.
148
179
*/
149
180
asm volatile (
150
- "mov r6, %0\n\t" /* R6 must be the FreeRTOS core ID*/
151
- "ldaw r5, dp[pxCurrentTCBs ]\n\t" /* R5 must be the TCB list which is indexed by R6 */
181
+ "mov r6, %0\n\t" /* R6 must be the FreeRTOS core ID. In singlecore this is always 0. */
182
+ "ldw r5, dp[xcorePvtTCBContainer ]\n\t" /* R5 must be the TCB list which is indexed by R6 */
152
183
"bu _freertos_restore_ctx\n\t"
153
184
: /* no outputs */
154
185
: "r" ( xCoreID )
0 commit comments