Skip to content

Commit 859dbaf

Browse files
authored
RP2040: Use indirect reference for pxCurrentTCB (#525)
1 parent 2dfdfc4 commit 859dbaf

File tree

1 file changed

+6
-2
lines changed
  • portable/ThirdParty/GCC/RP2040

1 file changed

+6
-2
lines changed

portable/ThirdParty/GCC/RP2040/port.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void vPortStartFirstTask( void )
206206
{
207207
__asm volatile (
208208
" .syntax unified \n"
209-
" ldr r2, =pxCurrentTCB \n"/* Obtain location of pxCurrentTCB. */
209+
" ldr r2, pxCurrentTCBConst1 \n"/* Obtain location of pxCurrentTCB. */
210210
" ldr r3, [r2] \n"
211211
" ldr r0, [r3] \n"/* The first item in pxCurrentTCB is the task top of stack. */
212212
" adds r0, #32 \n"/* Discard everything up to r0. */
@@ -220,6 +220,8 @@ void vPortStartFirstTask( void )
220220
" pop {r2} \n"/* Pop and discard XPSR. */
221221
" cpsie i \n"/* The first task has its context and interrupts can be enabled. */
222222
" bx r3 \n"/* Finally, jump to the user defined task code. */
223+
" .align 4 \n"
224+
"pxCurrentTCBConst1: .word pxCurrentTCB\n"
223225
);
224226
}
225227
/*-----------------------------------------------------------*/
@@ -380,7 +382,7 @@ void xPortPendSVHandler( void )
380382
" .syntax unified \n"
381383
" mrs r0, psp \n"
382384
" \n"
383-
" ldr r3, =pxCurrentTCB \n"/* Get the location of the current TCB. */
385+
" ldr r3, pxCurrentTCBConst2 \n"/* Get the location of the current TCB. */
384386
" ldr r2, [r3] \n"
385387
" \n"
386388
" subs r0, r0, #32 \n"/* Make space for the remaining low registers. */
@@ -450,6 +452,8 @@ void xPortPendSVHandler( void )
450452
" ldmia r0!, {r4-r7} \n"/* Pop low registers. */
451453
" \n"
452454
" bx r3 \n"
455+
" .align 4 \n"
456+
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
453457
);
454458
}
455459
/*-----------------------------------------------------------*/

0 commit comments

Comments
 (0)