34
34
.set IRQ_MODE , 0x12
35
35
36
36
/ * Variables and functions. * /
37
- . extern ulMaxAPIPriorityMask
38
- . extern _freertos_vector_table
39
37
. extern pxCurrentTCB
40
38
. extern vTaskSwitchContext
41
39
. extern vApplicationIRQHandler
48
46
. global FreeRTOS_SVC_Handler
49
47
. global vPortRestoreTaskContext
50
48
. global vPortInitialiseFPSCR
51
- . global ulReadValueAPSR
49
+ . global ulReadAPSR
52
50
51
+ / *-----------------------------------------------------------* /
53
52
54
53
.macro portSAVE_CONTEXT
55
54
56
55
/ * Save the LR and SPSR onto the system mode stack before switching to
57
- system mode to save the remaining system mode registers. * /
56
+ * system mode to save the remaining system mode registers. * /
58
57
SRSDB sp ! , #SYS_MODE
59
58
CPS #SYS_MODE
60
59
PUSH {R0 - R12 , R14 }
61
60
62
61
/ * Push the critical nesting count. * /
63
- LDR R2 , ulCriticalNestingConst
62
+ LDR R2 , =ulCriticalNesting
64
63
LDR R1 , [ R2 ]
65
64
PUSH {R1}
66
65
67
66
/ * Does the task have a floating point context th at needs saving? If
68
- ulPortTaskHasFPUContext is 0 then no. * /
69
- LDR R2 , ulPortTaskHasFPUContextConst
67
+ * ulPortTaskHasFPUContext is 0 then no. * /
68
+ LDR R2 , =ulPortTaskHasFPUContext
70
69
LDR R3 , [ R2 ]
71
70
CMP R3 , # 0
72
71
73
72
/ * Save the floating point context , if any. * /
74
- FMRXNE R1 , FPSCR
73
+ VMRSNE R1 , FPSCR
75
74
VPUSHNE {D0 - D15}
76
75
#if configFPU_D32 == 1
77
76
VPUSHNE {D16 - D31}
82
81
PUSH {R3}
83
82
84
83
/ * Save the stack pointer in the TCB. * /
85
- LDR R0 , pxCurrentTCBConst
84
+ LDR R0 , =pxCurrentTCB
86
85
LDR R1 , [ R0 ]
87
86
STR SP , [ R1 ]
88
87
89
88
.endm
90
89
91
- ; /********************************************************************* */
90
+ / *----------------------------------------------------------- */
92
91
93
92
.macro portRESTORE_CONTEXT
94
93
95
94
/ * Set the SP to point to the stack of the task being restored. * /
96
- LDR R0 , pxCurrentTCBConst
95
+ LDR R0 , =pxCurrentTCB
97
96
LDR R1 , [ R0 ]
98
97
LDR SP , [ R1 ]
99
98
100
99
/ * Is there a floating point context to restore? If the restored
101
- ulPortTaskHasFPUContext is zero then no. * /
102
- LDR R0 , ulPortTaskHasFPUContextConst
100
+ * ulPortTaskHasFPUContext is zero then no. * /
101
+ LDR R0 , =ulPortTaskHasFPUContext
103
102
POP {R1}
104
103
STR R1 , [ R0 ]
105
104
CMP R1 , # 0
113
112
VMSRNE FPSCR , R0
114
113
115
114
/ * Restore the critical section nesting depth. * /
116
- LDR R0 , ulCriticalNestingConst
115
+ LDR R0 , =ulCriticalNesting
117
116
POP {R1}
118
117
STR R1 , [ R0 ]
119
118
126
125
127
126
.endm
128
127
128
+ / *-----------------------------------------------------------* /
129
129
130
-
131
-
132
- / ******************************************************************************
130
+ / *
133
131
* SVC handler is used to yield.
134
- ***************************************************************************** /
132
+ * /
135
133
. align 4
136
134
.type FreeRTOS_SVC_Handler , %function
137
135
FreeRTOS_SVC_Handler:
138
136
/ * Save the context of the current task and select a new task to run. * /
139
137
portSAVE_CONTEXT
140
- LDR R0 , vTaskSwitchContextConst
141
- BLX R0
138
+ BLX vTaskSwitchContext
142
139
portRESTORE_CONTEXT
143
140
144
141
145
- / ******************************************************************************
142
+ / *-----------------------------------------------------------* /
143
+
144
+ / *
146
145
* vPortRestoreTaskContext is used to start the scheduler.
147
- ***************************************************************************** /
146
+ * /
148
147
. align 4
149
148
.type vPortRestoreTaskContext , %function
150
149
vPortRestoreTaskContext:
151
150
/ * Switch to system mode. * /
152
151
CPS #SYS_MODE
153
152
portRESTORE_CONTEXT
154
153
154
+ / *-----------------------------------------------------------* /
155
155
156
- / ******************************************************************************
157
- * vPortInitialiseFPSCR is used to initialize the FPSCR context .
158
- ***************************************************************************** /
156
+ / *
157
+ * vPortInitialiseFPSCR is used to initialize the FPSCR register .
158
+ * /
159
159
. align 4
160
160
.type vPortInitialiseFPSCR , %function
161
161
vPortInitialiseFPSCR:
162
162
MOV R0 , # 0
163
- FMXR FPSCR , R0
163
+ VMSR FPSCR , R0
164
164
BX LR
165
165
166
- / ******************************************************************************
167
- * ulReadValueAPSR is used to read the value of APSR context.
168
- ***************************************************************************** /
166
+ / *-----------------------------------------------------------* /
167
+
168
+ / *
169
+ * ulReadAPSR is used to read the value of APSR context.
170
+ * /
169
171
. align 4
170
- .type ulReadValueAPSR , %function
171
- ulReadValueAPSR :
172
+ .type ulReadAPSR , %function
173
+ ulReadAPSR :
172
174
MRS R0 , APSR
173
175
BX LR
174
176
177
+ / *-----------------------------------------------------------* /
178
+
175
179
. align 4
176
180
.type FreeRTOS_IRQ_Handler , %function
177
181
FreeRTOS_IRQ_Handler:
@@ -184,29 +188,28 @@ FreeRTOS_IRQ_Handler:
184
188
PUSH {lr}
185
189
186
190
/ * Change to supervisor mode to allow reentry. * /
187
- CPS # 0x13
191
+ CPS #SVC_MODE
188
192
189
193
/ * Push used registers. * /
190
194
PUSH {r0 - r3 , r12 }
191
195
192
196
/ * Increment nesting count. r3 holds the address of ulPortInterruptNesting
193
- for future use. r1 holds the original ulPortInterruptNesting value for
194
- future use. * /
195
- LDR r3 , ulPortInterruptNestingConst
197
+ * for future use. r1 holds the original ulPortInterruptNesting value for
198
+ * future use. * /
199
+ LDR r3 , =ulPortInterruptNesting
196
200
LDR r1 , [ r3 ]
197
201
ADD r0 , r1 , # 1
198
202
STR r0 , [ r3 ]
199
203
200
204
/ * Ensure bit 2 of the stack pointer is clear. r2 holds the bit 2 value for
201
- future use. * /
205
+ * future use. * /
202
206
MOV r0 , sp
203
207
AND r2 , r0 , # 4
204
208
SUB sp , sp , r2
205
209
206
210
/ * Call the interrupt handler. * /
207
211
PUSH {r0 - r3 , lr}
208
- LDR r1 , vApplicationIRQHandlerConst
209
- BLX r1
212
+ BLX vApplicationIRQHandler
210
213
POP {r0 - r3 , lr}
211
214
ADD sp , sp , r2
212
215
@@ -215,7 +218,7 @@ FreeRTOS_IRQ_Handler:
215
218
ISB
216
219
217
220
/ * Write to the EOI register. * /
218
- LDR r0 , ulICCEOIRConst
221
+ LDR r0 , =ulICCEOIR
219
222
LDR r2 , [ r0 ]
220
223
STR r0 , [ r2 ]
221
224
@@ -227,16 +230,16 @@ FreeRTOS_IRQ_Handler:
227
230
BNE exit_without_switch
228
231
229
232
/ * Did the interrupt request a context switch? r1 holds the address of
230
- ulPortYieldRequired and r0 the value of ulPortYieldRequired for future
231
- use. * /
232
- LDR r1 , ulPortYieldRequiredConst
233
+ * ulPortYieldRequired and r0 the value of ulPortYieldRequired for future
234
+ * use. * /
235
+ LDR r1 , =ulPortYieldRequired
233
236
LDR r0 , [ r1 ]
234
237
CMP r0 , # 0
235
238
BNE switch_before_exit
236
239
237
240
exit_without_switch:
238
241
/ * No context switch. Restore used registers , LR_irq and SPSR before
239
- returning. * /
242
+ * returning. * /
240
243
POP {r0 - r3 , r12 }
241
244
CPS #IRQ_MODE
242
245
POP {LR}
@@ -246,12 +249,12 @@ exit_without_switch:
246
249
247
250
switch_before_exit:
248
251
/ * A context switch is to be performed. Clear the context switch pending
249
- flag. * /
252
+ * flag. * /
250
253
MOV r0 , # 0
251
254
STR r0 , [ r1 ]
252
255
253
256
/ * Restore used registers , LR - irq and SPSR before saving the context
254
- to the task stack. * /
257
+ * to the task stack. * /
255
258
POP {r0 - r3 , r12 }
256
259
CPS #IRQ_MODE
257
260
POP {LR}
@@ -260,23 +263,15 @@ switch_before_exit:
260
263
portSAVE_CONTEXT
261
264
262
265
/ * Call the function th at selects the new task to execute.
263
- vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD
264
- instructions , or 8 byte aligned stack allocated data. LR does not need
265
- saving as a new LR will be loaded by portRESTORE_CONTEXT anyway. * /
266
- LDR R0 , vTaskSwitchContextConst
267
- BLX R0
266
+ * vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD
267
+ * instructions , or 8 byte aligned stack allocated data. LR does not need
268
+ * saving as a new LR will be loaded by portRESTORE_CONTEXT anyway. * /
269
+ BLX vTaskSwitchContext
268
270
269
271
/ * Restore the context of , and branch to , the task selected to execute
270
- next. * /
272
+ * next. * /
271
273
portRESTORE_CONTEXT
272
274
273
- ulICCEOIRConst: .word ulICCEOIR
274
- pxCurrentTCBConst: .word pxCurrentTCB
275
- ulCriticalNestingConst: .word ulCriticalNesting
276
- ulPortTaskHasFPUContextConst: .word ulPortTaskHasFPUContext
277
- vTaskSwitchContextConst: .word vTaskSwitchContext
278
- vApplicationIRQHandlerConst: .word vApplicationIRQHandler
279
- ulPortInterruptNestingConst: .word ulPortInterruptNesting
280
- ulPortYieldRequiredConst: .word ulPortYieldRequired
275
+ / *-----------------------------------------------------------* /
281
276
282
277
.end
0 commit comments