@@ -93,22 +93,36 @@ TaskType WaitingTask = INVALID_TASK;
93
93
94
94
void ReturnHook_Arch (void )
95
95
{
96
- /* Tasks shouldn't return here... */
97
- while (1 ) osekpause ();
96
+ /*
97
+ * Tasks shouldn't return here...
98
+ *
99
+ * This is a security net for runaway tasks that reach the end of
100
+ * their main body code without terminating their execution
101
+ * properly using TerminateTask or something of the kind.
102
+ *
103
+ * */
98
104
105
+ while (1 )
106
+ {
107
+ osekpause ();
108
+ }
99
109
}
100
110
101
111
102
112
103
113
void CheckTerminatingTask_Arch (void )
104
114
{
115
+ /*
116
+ * If there is task being terminated, destroy its context information and
117
+ * reset its state so that the next time that the task is activated it
118
+ * starts its execution on the first instruction of the task body.
119
+ * */
120
+
105
121
if (TerminatingTask != INVALID_TASK )
106
122
{
107
- // int i;
108
- // for(i=0; i<TasksConst[TerminatingTask].StackSize/4; i++)
109
- // ((uint32 *)TasksConst[TerminatingTask].StackPtr)[i] = 0;
110
123
InitStack_Arch (TerminatingTask );
111
124
}
125
+
112
126
TerminatingTask = INVALID_TASK ;
113
127
}
114
128
@@ -117,7 +131,6 @@ void CheckTerminatingTask_Arch(void)
117
131
/* Task Stack Initialization */
118
132
void InitStack_Arch (uint8 TaskID )
119
133
{
120
-
121
134
uint32_t * taskStackRegionPtr ;
122
135
int32_t taskStackSizeWords ;
123
136
@@ -243,23 +256,32 @@ void InitStack_Arch(uint8 TaskID)
243
256
/* Periodic Interrupt Timer, included in all Cortex-M4 processors */
244
257
void SysTick_Handler (void )
245
258
{
246
- /* store the calling context in a variable */
259
+ /* Store the calling context in a variable. */
247
260
ContextType actualContext = GetCallingContext ();
248
- /* set isr 2 context */
261
+
262
+ /* Set ISR2 context. */
249
263
SetActualContext (CONTEXT_ISR2 );
250
264
251
265
#if (ALARMS_COUNT != 0 )
252
- /* counter increment */
253
- static CounterIncrementType CounterIncrement = 1 ;
254
- (void )CounterIncrement ; /* TODO remove me */
255
266
256
- /* increment the disable interrupt conter to avoid enable the interrupts */
267
+ /* Counter increment. */
268
+ static CounterIncrementType CounterIncrement = 1 ; /* TODO remove me. */
269
+
270
+ (void )CounterIncrement ; /* This avoids a compiler warning because the variable is not being used. */
271
+
272
+ /*
273
+ * Enter critical section.
274
+ * */
257
275
IntSecure_Start ();
258
276
259
- /* call counter interrupt handler */
277
+ /*
278
+ * The the RTOS counter increment handler.
279
+ * */
260
280
CounterIncrement = IncrementCounter (0 , 1 /* CounterIncrement */ ); /* TODO FIXME */
261
281
262
- /* set the disable interrupt counter back */
282
+ /*
283
+ * Exit the critical section.
284
+ * */
263
285
IntSecure_End ();
264
286
265
287
#endif /* #if (ALARMS_COUNT != 0) */
@@ -268,13 +290,19 @@ void SysTick_Handler(void)
268
290
SetActualContext (actualContext );
269
291
270
292
#if (NON_PREEMPTIVE == OSEK_DISABLE )
271
- /* check if the actual task is preemptive */
293
+
294
+ /*
295
+ * Check if the currently active task is preemptive;
296
+ * if it is, call schedule().
297
+ * */
298
+
272
299
if ( ( CONTEXT_TASK == actualContext ) &&
273
- ( TasksConst [GetRunningTask ()].ConstFlags .Preemtive ) )
300
+ ( TasksConst [GetRunningTask ()].ConstFlags .Preemtive ) )
274
301
{
275
- /* this shall force a call to the scheduler */
302
+ /* This shall force a call to the scheduler. */
276
303
PostIsr2_Arch (isr );
277
304
}
305
+
278
306
#endif /* #if (NON_PREEMPTIVE == OSEK_DISABLE) */
279
307
}
280
308
0 commit comments