Skip to content

Commit 553caa1

Browse files
authored
Update the memory alignment within the Cortex-A9 port asm code (#426)
Update alignment in ARM_CA9 port.
1 parent a79752a commit 553caa1

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

portable/GCC/ARM_CA9/portASM.S

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@
7575

7676
/* Save the floating point context, if any. */
7777
FMRXNE R1, FPSCR
78+
PUSHNE {R1}
7879
VPUSHNE {D0-D15}
7980
VPUSHNE {D16-D31}
80-
PUSHNE {R1}
8181

8282
/* Save ulPortTaskHasFPUContext itself. */
8383
PUSH {R3}
@@ -106,9 +106,9 @@
106106
CMP R1, #0
107107

108108
/* Restore the floating point context, if any. */
109-
POPNE {R0}
110109
VPOPNE {D16-D31}
111110
VPOPNE {D0-D15}
111+
POPNE {R0}
112112
VMSRNE FPSCR, R0
113113

114114
/* Restore the critical section nesting depth. */
@@ -145,8 +145,15 @@
145145
FreeRTOS_SWI_Handler:
146146
/* Save the context of the current task and select a new task to run. */
147147
portSAVE_CONTEXT
148+
149+
/* Ensure bit 2 of the stack pointer is clear. */
150+
MOV r2, sp
151+
AND r2, r2, #4
152+
SUB sp, sp, r2
153+
148154
LDR R0, vTaskSwitchContextConst
149155
BLX R0
156+
150157
portRESTORE_CONTEXT
151158

152159

@@ -256,7 +263,13 @@ switch_before_exit:
256263
/* Call the function that selects the new task to execute.
257264
vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD
258265
instructions, or 8 byte aligned stack allocated data. LR does not need
259-
saving as a new LR will be loaded by portRESTORE_CONTEXT anyway. */
266+
saving as a new LR will be loaded by portRESTORE_CONTEXT anyway.
267+
Ensure bit 2 of the stack pointer is clear. r2 holds the bit 2 value for
268+
future use. */
269+
MOV r2, sp
270+
AND r2, r2, #4
271+
SUB sp, sp, r2
272+
260273
LDR R0, vTaskSwitchContextConst
261274
BLX R0
262275

0 commit comments

Comments
 (0)