Skip to content

Commit 6270e2a

Browse files
authored
Update the memory alignment within the Cortex-R5 port asm code (#1023)
Update alignment in ARM_CR5 port. This is the same patch as 553caa1 provided by Richard Barry for issue #426 (ARM_CA9). Signed-off-by: Florian La Roche <[email protected]>
1 parent 5da55ba commit 6270e2a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

portable/GCC/ARM_CR5/portASM.S

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676

7777
/* Save the floating point context, if any. */
7878
FMRXNE R1, FPSCR
79-
VPUSHNE {D0-D15}
8079
PUSHNE {R1}
80+
VPUSHNE {D0-D15}
8181

8282
/* Save ulPortTaskHasFPUContext itself. */
8383
PUSH {R3}
@@ -110,8 +110,8 @@
110110
CMP R1, #0
111111

112112
/* Restore the floating point context, if any. */
113-
POPNE {R0}
114113
VPOPNE {D0-D15}
114+
POPNE {R0}
115115
VMSRNE FPSCR, R0
116116
#endif /* __ARM_FP */
117117

@@ -147,8 +147,15 @@
147147
FreeRTOS_SWI_Handler:
148148
/* Save the context of the current task and select a new task to run. */
149149
portSAVE_CONTEXT
150+
151+
/* Ensure bit 2 of the stack pointer is clear. */
152+
MOV r2, sp
153+
AND r2, r2, #4
154+
SUB sp, sp, r2
155+
150156
LDR R0, vTaskSwitchContextConst
151157
BLX R0
158+
152159
portRESTORE_CONTEXT
153160

154161

@@ -256,6 +263,11 @@ switch_before_exit:
256263
POP {LR}
257264
portSAVE_CONTEXT
258265

266+
/* Ensure bit 2 of the stack pointer is clear. */
267+
MOV r2, sp
268+
AND r2, r2, #4
269+
SUB sp, sp, r2
270+
259271
/* Call the function that selects the new task to execute.
260272
vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD
261273
instructions, or 8 byte aligned stack allocated data. LR does not need

0 commit comments

Comments
 (0)