Skip to content

Commit 9788e7e

Browse files
authored
modernize ARM assembler syntax (FreeRTOS#1148)
modernize ARM assembler syntax Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
1 parent 61440fc commit 9788e7e

File tree

5 files changed

+25
-43
lines changed

5 files changed

+25
-43
lines changed

portable/GCC/ARM_CM3/port.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ static void prvTaskExitError( void )
228228
void vPortSVCHandler( void )
229229
{
230230
__asm volatile (
231-
" ldr r3, pxCurrentTCBConst2 \n" /* Restore the context. */
232-
" ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */
231+
" ldr r3, =pxCurrentTCB \n" /* Restore the context. */
232+
" ldr r1, [r3] \n" /* Get the pxCurrentTCB address. */
233233
" ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */
234234
" ldmia r0!, {r4-r11} \n" /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */
235235
" msr psp, r0 \n" /* Restore the task stack pointer. */
@@ -239,8 +239,7 @@ void vPortSVCHandler( void )
239239
" orr r14, #0xd \n"
240240
" bx r14 \n"
241241
" \n"
242-
" .align 4 \n"
243-
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
242+
" .ltorg \n"
244243
);
245244
}
246245
/*-----------------------------------------------------------*/
@@ -462,7 +461,7 @@ void xPortPendSVHandler( void )
462461
" mrs r0, psp \n"
463462
" isb \n"
464463
" \n"
465-
" ldr r3, pxCurrentTCBConst \n" /* Get the location of the current TCB. */
464+
" ldr r3, =pxCurrentTCB \n" /* Get the location of the current TCB. */
466465
" ldr r2, [r3] \n"
467466
" \n"
468467
" stmdb r0!, {r4-r11} \n" /* Save the remaining registers. */
@@ -483,8 +482,7 @@ void xPortPendSVHandler( void )
483482
" isb \n"
484483
" bx r14 \n"
485484
" \n"
486-
" .align 4 \n"
487-
"pxCurrentTCBConst: .word pxCurrentTCB \n"
485+
" .ltorg \n"
488486
::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
489487
);
490488
}

portable/GCC/ARM_CM3_MPU/port.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ static void prvRestoreContextOfFirstTask( void )
695695
" msr msp, r0 \n" /* Set the msp back to the start of the stack. */
696696
" \n"
697697
/*------------ Program MPU. ------------ */
698-
" ldr r3, pxCurrentTCBConst2 \n" /* r3 = pxCurrentTCBConst2. */
698+
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
699699
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
700700
" add r2, r2, #4 \n" /* r2 = Second item in the TCB which is xMPUSettings. */
701701
" \n"
@@ -716,7 +716,7 @@ static void prvRestoreContextOfFirstTask( void )
716716
" dsb \n" /* Force memory writes before continuing. */
717717
" \n"
718718
/*---------- Restore Context. ---------- */
719-
" ldr r3, pxCurrentTCBConst2 \n" /* r3 = pxCurrentTCBConst2. */
719+
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
720720
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
721721
" ldr r1, [r2] \n" /* r1 = Location of saved context in TCB. */
722722
" \n"
@@ -732,8 +732,6 @@ static void prvRestoreContextOfFirstTask( void )
732732
" bx lr \n"
733733
" \n"
734734
" .ltorg \n" /* Assemble current literal pool to avoid offset-out-of-bound errors with lto. */
735-
" .align 4 \n"
736-
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
737735
);
738736
}
739737
/*-----------------------------------------------------------*/
@@ -988,7 +986,7 @@ void xPortPendSVHandler( void )
988986

989987
__asm volatile
990988
(
991-
" ldr r3, pxCurrentTCBConst \n" /* r3 = pxCurrentTCBConst. */
989+
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
992990
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
993991
" ldr r1, [r2] \n" /* r1 = Location where the context should be saved. */
994992
" \n"
@@ -1012,7 +1010,7 @@ void xPortPendSVHandler( void )
10121010
" msr basepri, r0 \n"
10131011
" \n"
10141012
/*------------ Program MPU. ------------ */
1015-
" ldr r3, pxCurrentTCBConst \n" /* r3 = pxCurrentTCBConst. */
1013+
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
10161014
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
10171015
" add r2, r2, #4 \n" /* r2 = Second item in the TCB which is xMPUSettings. */
10181016
" \n"
@@ -1033,7 +1031,7 @@ void xPortPendSVHandler( void )
10331031
" dsb \n" /* Force memory writes before continuing. */
10341032
" \n"
10351033
/*---------- Restore Context. ---------- */
1036-
" ldr r3, pxCurrentTCBConst \n" /* r3 = pxCurrentTCBConst. */
1034+
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
10371035
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
10381036
" ldr r1, [r2] \n" /* r1 = Location of saved context in TCB. */
10391037
" \n"
@@ -1047,8 +1045,6 @@ void xPortPendSVHandler( void )
10471045
" bx lr \n"
10481046
" \n"
10491047
" .ltorg \n" /* Assemble current literal pool to avoid offset-out-of-bound errors with lto. */
1050-
" .align 4 \n"
1051-
"pxCurrentTCBConst: .word pxCurrentTCB \n"
10521048
::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
10531049
);
10541050
}
@@ -1207,8 +1203,6 @@ BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */
12071203
" movne r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */
12081204
" moveq r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */
12091205
" bx lr \n" /* Return. */
1210-
" \n"
1211-
" .align 4 \n"
12121206
::: "r0", "memory"
12131207
);
12141208
}

portable/GCC/ARM_CM4F/port.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ static void prvTaskExitError( void )
260260
void vPortSVCHandler( void )
261261
{
262262
__asm volatile (
263-
" ldr r3, pxCurrentTCBConst2 \n" /* Restore the context. */
264-
" ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */
263+
" ldr r3, =pxCurrentTCB \n" /* Restore the context. */
264+
" ldr r1, [r3] \n" /* Get the pxCurrentTCB address. */
265265
" ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */
266266
" ldmia r0!, {r4-r11, r14} \n" /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */
267267
" msr psp, r0 \n" /* Restore the task stack pointer. */
@@ -270,8 +270,7 @@ void vPortSVCHandler( void )
270270
" msr basepri, r0 \n"
271271
" bx r14 \n"
272272
" \n"
273-
" .align 4 \n"
274-
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
273+
" .ltorg \n"
275274
);
276275
}
277276
/*-----------------------------------------------------------*/
@@ -511,7 +510,7 @@ void xPortPendSVHandler( void )
511510
" mrs r0, psp \n"
512511
" isb \n"
513512
" \n"
514-
" ldr r3, pxCurrentTCBConst \n" /* Get the location of the current TCB. */
513+
" ldr r3, =pxCurrentTCB \n" /* Get the location of the current TCB. */
515514
" ldr r2, [r3] \n"
516515
" \n"
517516
" tst r14, #0x10 \n" /* Is the task using the FPU context? If so, push high vfp registers. */
@@ -552,8 +551,7 @@ void xPortPendSVHandler( void )
552551
" \n"
553552
" bx r14 \n"
554553
" \n"
555-
" .align 4 \n"
556-
"pxCurrentTCBConst: .word pxCurrentTCB \n"
554+
" .ltorg \n"
557555
::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
558556
);
559557
}

portable/GCC/ARM_CM4_MPU/port.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ static void prvRestoreContextOfFirstTask( void )
761761
" msr msp, r0 \n" /* Set the msp back to the start of the stack. */
762762
" \n"
763763
/*------------ Program MPU. ------------ */
764-
" ldr r3, pxCurrentTCBConst2 \n" /* r3 = pxCurrentTCBConst2. */
764+
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
765765
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
766766
" add r2, r2, #4 \n" /* r2 = Second item in the TCB which is xMPUSettings. */
767767
" \n"
@@ -789,7 +789,7 @@ static void prvRestoreContextOfFirstTask( void )
789789
" dsb \n" /* Force memory writes before continuing. */
790790
" \n"
791791
/*---------- Restore Context. ---------- */
792-
" ldr r3, pxCurrentTCBConst2 \n" /* r3 = pxCurrentTCBConst2. */
792+
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
793793
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
794794
" ldr r1, [r2] \n" /* r1 = Location of saved context in TCB. */
795795
" \n"
@@ -805,8 +805,6 @@ static void prvRestoreContextOfFirstTask( void )
805805
" bx lr \n"
806806
" \n"
807807
" .ltorg \n" /* Assemble current literal pool to avoid offset-out-of-bound errors with lto. */
808-
" .align 4 \n"
809-
" pxCurrentTCBConst2: .word pxCurrentTCB\n"
810808
);
811809
}
812810
/*-----------------------------------------------------------*/
@@ -1084,7 +1082,7 @@ void xPortPendSVHandler( void )
10841082

10851083
__asm volatile
10861084
(
1087-
" ldr r3, pxCurrentTCBConst \n" /* r3 = pxCurrentTCBConst. */
1085+
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
10881086
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
10891087
" ldr r1, [r2] \n" /* r1 = Location where the context should be saved. */
10901088
" \n"
@@ -1122,7 +1120,7 @@ void xPortPendSVHandler( void )
11221120
" msr basepri, r0 \n"
11231121
" \n"
11241122
/*------------ Program MPU. ------------ */
1125-
" ldr r3, pxCurrentTCBConst \n" /* r3 = pxCurrentTCBConst. */
1123+
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
11261124
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
11271125
" add r2, r2, #4 \n" /* r2 = Second item in the TCB which is xMPUSettings. */
11281126
" \n"
@@ -1150,7 +1148,7 @@ void xPortPendSVHandler( void )
11501148
" dsb \n" /* Force memory writes before continuing. */
11511149
" \n"
11521150
/*---------- Restore Context. ---------- */
1153-
" ldr r3, pxCurrentTCBConst \n" /* r3 = pxCurrentTCBConst. */
1151+
" ldr r3, =pxCurrentTCB \n" /* r3 = =pxCurrentTCB. */
11541152
" ldr r2, [r3] \n" /* r2 = pxCurrentTCB. */
11551153
" ldr r1, [r2] \n" /* r1 = Location of saved context in TCB. */
11561154
" \n"
@@ -1170,8 +1168,6 @@ void xPortPendSVHandler( void )
11701168
" bx lr \n"
11711169
" \n"
11721170
" .ltorg \n" /* Assemble the current literal pool to avoid offset-out-of-bound errors with lto. */
1173-
" .align 4 \n"
1174-
" pxCurrentTCBConst: .word pxCurrentTCB \n"
11751171
::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
11761172
);
11771173
}
@@ -1349,8 +1345,6 @@ BaseType_t xIsPrivileged( void ) /* __attribute__ (( naked )) */
13491345
" movne r0, #0 \n" /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */
13501346
" moveq r0, #1 \n" /* CONTROL[0]==0. Return true to indicate that the processor is privileged. */
13511347
" bx lr \n" /* Return. */
1352-
" \n"
1353-
" .align 4 \n"
13541348
::: "r0", "memory"
13551349
);
13561350
}

portable/GCC/ARM_CM7/r0p1/port.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ static void prvTaskExitError( void )
254254
void vPortSVCHandler( void )
255255
{
256256
__asm volatile (
257-
" ldr r3, pxCurrentTCBConst2 \n" /* Restore the context. */
258-
" ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */
257+
" ldr r3, =pxCurrentTCB \n" /* Restore the context. */
258+
" ldr r1, [r3] \n" /* Get the pxCurrentTCB address. */
259259
" ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */
260260
" ldmia r0!, {r4-r11, r14} \n" /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */
261261
" msr psp, r0 \n" /* Restore the task stack pointer. */
@@ -264,8 +264,7 @@ void vPortSVCHandler( void )
264264
" msr basepri, r0 \n"
265265
" bx r14 \n"
266266
" \n"
267-
" .align 4 \n"
268-
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
267+
" .ltorg \n"
269268
);
270269
}
271270
/*-----------------------------------------------------------*/
@@ -499,7 +498,7 @@ void xPortPendSVHandler( void )
499498
" mrs r0, psp \n"
500499
" isb \n"
501500
" \n"
502-
" ldr r3, pxCurrentTCBConst \n" /* Get the location of the current TCB. */
501+
" ldr r3, =pxCurrentTCB \n" /* Get the location of the current TCB. */
503502
" ldr r2, [r3] \n"
504503
" \n"
505504
" tst r14, #0x10 \n" /* Is the task using the FPU context? If so, push high vfp registers. */
@@ -542,8 +541,7 @@ void xPortPendSVHandler( void )
542541
" \n"
543542
" bx r14 \n"
544543
" \n"
545-
" .align 4 \n"
546-
"pxCurrentTCBConst: .word pxCurrentTCB \n"
544+
" .ltorg \n"
547545
::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
548546
);
549547
}

0 commit comments

Comments
 (0)