@@ -125,131 +125,130 @@ extern volatile tskTCB * volatile pxCurrentTCB;
125
125
* The interrupts will have been disabled during the call to portSAVE_CONTEXT()
126
126
* so we need not worry about reading/writing to the stack pointer.
127
127
*/
128
- #define portSAVE_CONTEXT () \
129
- asm volatile ( "push r0 \n\t" \
130
- "in r0, __SREG__ \n\t" \
131
- "cli \n\t" \
132
- "push r0 \n\t" \
128
+ inline void portSAVE_CONTEXT () __attribute__((__always_inline__ ,__noreturn__ ));
129
+ inline void portSAVE_CONTEXT (){
130
+ asm volatile ( "push r0 \n\t"
131
+ "in r0, __SREG__ \n\t"
132
+ "cli \n\t"
133
+ "push r0 \n\t"
133
134
);
134
- /* CDCP - begin*/
135
135
#if defined(__AVR_HAVE_RAMPZ__ )
136
136
/*
137
137
* have RAMPZ Extended Z-pointer Register for ELPM/SPM
138
138
* the uC have extend program memory
139
139
* 0x3b --> RAMPZ
140
140
* 0x3c --> EIND
141
141
*/
142
- asm volatile ( "in r0, 0x3b \n\t" \
143
- "push r0 \n\t" \
144
- "in r0, 0x3c \n\t" \
145
- "push r0 \n\t" \
142
+ asm volatile ( "in r0, 0x3b \n\t"
143
+ "push r0 \n\t"
144
+ "in r0, 0x3c \n\t"
145
+ "push r0 \n\t"
146
146
);
147
147
#endif
148
- asm volatile ( "push r1 \n\t" \
149
- "clr r1 \n\t" \
150
- "push r2 \n\t" \
151
- "push r3 \n\t" \
152
- "push r4 \n\t" \
153
- "push r5 \n\t" \
154
- "push r6 \n\t" \
155
- "push r7 \n\t" \
156
- "push r8 \n\t" \
157
- "push r9 \n\t" \
158
- "push r10 \n\t" \
159
- "push r11 \n\t" \
160
- "push r12 \n\t" \
161
- "push r13 \n\t" \
162
- "push r14 \n\t" \
163
- "push r15 \n\t" \
164
- "push r16 \n\t" \
165
- "push r17 \n\t" \
166
- "push r18 \n\t" \
167
- "push r19 \n\t" \
168
- "push r20 \n\t" \
169
- "push r21 \n\t" \
170
- "push r22 \n\t" \
171
- "push r23 \n\t" \
172
- "push r24 \n\t" \
173
- "push r25 \n\t" \
174
- "push r26 \n\t" \
175
- "push r27 \n\t" \
176
- "push r28 \n\t" \
177
- "push r29 \n\t" \
178
- "push r30 \n\t" \
179
- "push r31 \n\t" \
180
- "lds r26, pxCurrentTCB \n\t" \
181
- "lds r27, pxCurrentTCB + 1 \n\t" \
182
- "in r0, 0x3d \n\t" \
183
- "st x+, r0 \n\t" \
184
- "in r0, 0x3e \n\t" \
185
- "st x+, r0 \n\t" \
148
+ asm volatile ( "push r1 \n\t"
149
+ "clr r1 \n\t"
150
+ "push r2 \n\t"
151
+ "push r3 \n\t"
152
+ "push r4 \n\t"
153
+ "push r5 \n\t"
154
+ "push r6 \n\t"
155
+ "push r7 \n\t"
156
+ "push r8 \n\t"
157
+ "push r9 \n\t"
158
+ "push r10 \n\t"
159
+ "push r11 \n\t"
160
+ "push r12 \n\t"
161
+ "push r13 \n\t"
162
+ "push r14 \n\t"
163
+ "push r15 \n\t"
164
+ "push r16 \n\t"
165
+ "push r17 \n\t"
166
+ "push r18 \n\t"
167
+ "push r19 \n\t"
168
+ "push r20 \n\t"
169
+ "push r21 \n\t"
170
+ "push r22 \n\t"
171
+ "push r23 \n\t"
172
+ "push r24 \n\t"
173
+ "push r25 \n\t"
174
+ "push r26 \n\t"
175
+ "push r27 \n\t"
176
+ "push r28 \n\t"
177
+ "push r29 \n\t"
178
+ "push r30 \n\t"
179
+ "push r31 \n\t"
180
+ "lds r26, pxCurrentTCB \n\t"
181
+ "lds r27, pxCurrentTCB + 1 \n\t"
182
+ "in r0, 0x3d \n\t"
183
+ "st x+, r0 \n\t"
184
+ "in r0, 0x3e \n\t"
185
+ "st x+, r0 \n\t"
186
186
);
187
-
187
+ }
188
188
189
189
/*
190
190
* Opposite to portSAVE_CONTEXT(). Interrupts will have been disabled during
191
191
* the context save so we can write to the stack pointer.
192
192
*/
193
-
194
- #define portRESTORE_CONTEXT () \
195
- asm volatile ( "lds r26, pxCurrentTCB \n\t" \
196
- "lds r27, pxCurrentTCB + 1 \n\t" \
197
- "ld r28, x+ \n\t" \
198
- "out __SP_L__, r28 \n\t" \
199
- "ld r29, x+ \n\t" \
200
- "out __SP_H__, r29 \n\t" \
201
- "pop r31 \n\t" \
202
- "pop r30 \n\t" \
203
- "pop r29 \n\t" \
204
- "pop r28 \n\t" \
205
- "pop r27 \n\t" \
206
- "pop r26 \n\t" \
207
- "pop r25 \n\t" \
208
- "pop r24 \n\t" \
209
- "pop r23 \n\t" \
210
- "pop r22 \n\t" \
211
- "pop r21 \n\t" \
212
- "pop r20 \n\t" \
213
- "pop r19 \n\t" \
214
- "pop r18 \n\t" \
215
- "pop r17 \n\t" \
216
- "pop r16 \n\t" \
217
- "pop r15 \n\t" \
218
- "pop r14 \n\t" \
219
- "pop r13 \n\t" \
220
- "pop r12 \n\t" \
221
- "pop r11 \n\t" \
222
- "pop r10 \n\t" \
223
- "pop r9 \n\t" \
224
- "pop r8 \n\t" \
225
- "pop r7 \n\t" \
226
- "pop r6 \n\t" \
227
- "pop r5 \n\t" \
228
- "pop r4 \n\t" \
229
- "pop r3 \n\t" \
230
- "pop r2 \n\t" \
231
- "pop r1 \n\t" \
232
- "pop r0 \n\t" \
193
+ inline void portRESTORE_CONTEXT () __attribute__(( __always_inline__ , __noreturn__ ));
194
+ inline void portRESTORE_CONTEXT (){
195
+ asm volatile ( "lds r26, pxCurrentTCB \n\t"
196
+ "lds r27, pxCurrentTCB + 1 \n\t"
197
+ "ld r28, x+ \n\t"
198
+ "out __SP_L__, r28 \n\t"
199
+ "ld r29, x+ \n\t"
200
+ "out __SP_H__, r29 \n\t"
201
+ "pop r31 \n\t"
202
+ "pop r30 \n\t"
203
+ "pop r29 \n\t"
204
+ "pop r28 \n\t"
205
+ "pop r27 \n\t"
206
+ "pop r26 \n\t"
207
+ "pop r25 \n\t"
208
+ "pop r24 \n\t"
209
+ "pop r23 \n\t"
210
+ "pop r22 \n\t"
211
+ "pop r21 \n\t"
212
+ "pop r20 \n\t"
213
+ "pop r19 \n\t"
214
+ "pop r18 \n\t"
215
+ "pop r17 \n\t"
216
+ "pop r16 \n\t"
217
+ "pop r15 \n\t"
218
+ "pop r14 \n\t"
219
+ "pop r13 \n\t"
220
+ "pop r12 \n\t"
221
+ "pop r11 \n\t"
222
+ "pop r10 \n\t"
223
+ "pop r9 \n\t"
224
+ "pop r8 \n\t"
225
+ "pop r7 \n\t"
226
+ "pop r6 \n\t"
227
+ "pop r5 \n\t"
228
+ "pop r4 \n\t"
229
+ "pop r3 \n\t"
230
+ "pop r2 \n\t"
231
+ "pop r1 \n\t"
232
+ "pop r0 \n\t"
233
233
);
234
-
235
234
#if defined(__AVR_HAVE_RAMPZ__ )
236
235
/*
237
236
* have RAMPZ Extended Z-pointer Register for ELPM/SPM
238
237
* the uC have extend program memory
239
238
* 0x3b --> RAMPZ
240
239
* 0x3c --> EIND
241
240
*/
242
- asm volatile ( "out 0x3c, r0 \n\t" \
243
- "pop r0 \n\t" \
244
- "out 0x3b, r0 \n\t" \
245
- "pop r0 \n\t" \
241
+ asm volatile ( "out 0x3c, r0 \n\t"
242
+ "pop r0 \n\t"
243
+ "out 0x3b, r0 \n\t"
244
+ "pop r0 \n\t"
246
245
);
247
246
#endif
248
247
249
- asm volatile ( "out __SREG__, r0 \n\t" \
250
- "pop r0 \n\t" \
248
+ asm volatile ( "out __SREG__, r0 \n\t"
249
+ "pop r0 \n\t"
251
250
);
252
-
251
+ }
253
252
/*-----------------------------------------------------------*/
254
253
255
254
/*
0 commit comments