2 FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
\r
4 This file is part of the FreeRTOS.org distribution.
\r
6 FreeRTOS.org is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 FreeRTOS.org is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with FreeRTOS.org; if not, write to the Free Software
\r
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
20 A special exception to the GPL can be applied should you wish to distribute
\r
21 a combined work that includes FreeRTOS.org, without being obliged to provide
\r
22 the source code for any proprietary components. See the licensing section
\r
23 of http://www.FreeRTOS.org for full details of how and when the exception
\r
26 ***************************************************************************
\r
28 Please ensure to read the configuration and relevant port sections of the
\r
29 online documentation.
\r
31 +++ http://www.FreeRTOS.org +++
\r
32 Documentation, latest information, license and contact details.
\r
34 +++ http://www.SafeRTOS.com +++
\r
35 A version that is certified for use in safety critical systems.
\r
37 +++ http://www.OpenRTOS.com +++
\r
38 Commercial support, development, porting, licensing and training services.
\r
40 ***************************************************************************
\r
44 * Creates all the demo application tasks, then starts the scheduler. The WEB
\r
45 * documentation provides more details of the demo application tasks.
\r
47 * In addition to the standard demo tasks, the follow demo specific tasks are
\r
50 * The "Check" task. This only executes every three seconds but has the highest
\r
51 * priority so is guaranteed to get processor time. Its main function is to
\r
52 * check that all the other tasks are still operational. Most tasks maintain
\r
53 * a unique count that is incremented each time the task successfully completes
\r
54 * its function. Should any error occur within such a task the count is
\r
55 * permanently halted. The check task inspects the count of each task to ensure
\r
56 * it has changed since the last time the check task executed. If all the count
\r
57 * variables have changed all the tasks are still executing error free, and the
\r
58 * check task toggles the onboard LED. Should any task contain an error at any time
\r
59 * the LED toggle rate will change from 3 seconds to 500ms.
\r
64 /* Scheduler includes. */
\r
65 #include "FreeRTOS.h"
\r
68 #include "integer.h"
\r
69 #include "comtest2.h"
\r
70 #include "semtest.h"
\r
72 #include "dynamic.h"
\r
74 #include "GenQTest.h"
\r
76 #include "blocktim.h"
\r
78 #include "partest.h"
\r
79 #include "xcache_l.h"
\r
81 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
82 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
83 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
84 #define mainQUEUE_BLOCK_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
85 #define mainDEATH_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
86 #define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
87 #define mainGENERIC_QUEUE_PRIORITY ( tskIDLE_PRIORITY )
\r
89 #define mainCOM_TEST_BAUD_RATE ( 115200UL )
\r
90 #define mainCOM_TEST_LED ( 4 )
\r
92 #define mainNO_ERROR_CHECK_DELAY ( ( portTickType ) 3000 / portTICK_RATE_MS )
\r
93 #define mainERROR_CHECK_DELAY ( ( portTickType ) 500 / portTICK_RATE_MS )
\r
95 #define mainCHECK_TEST_LED ( 3 )
\r
97 static void prvRegTestTask1( void *pvParameters );
\r
98 static void prvRegTestTask2( void *pvParameters );
\r
99 static void prvFlashTask( void *pvParameters );
\r
100 static void prvErrorChecks( void *pvParameters );
\r
102 static unsigned portBASE_TYPE xRegTestStatus = pdPASS;
\r
103 static portSHORT prvCheckOtherTasksAreStillRunning( void );
\r
107 XCache_EnableICache( 0x80000000 );
\r
108 XCache_EnableDCache( 0x80000000 );
\r
109 vParTestInitialise();
\r
111 /* Start the standard demo application tasks. */
\r
112 vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
\r
113 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
114 vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED - 1 );
\r
115 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
116 vStartBlockingQueueTasks ( mainQUEUE_BLOCK_PRIORITY );
\r
117 vStartDynamicPriorityTasks();
\r
118 vStartMathTasks( tskIDLE_PRIORITY );
\r
119 vStartGenericQueueTasks( mainGENERIC_QUEUE_PRIORITY );
\r
120 vStartQueuePeekTasks();
\r
121 vCreateBlockTimeTasks();
\r
123 xTaskCreate( prvRegTestTask1, "Regtest1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
\r
124 xTaskCreate( prvRegTestTask2, "Regtest2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
\r
125 xTaskCreate( prvErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
127 /* The suicide tasks must be started last as they record the number of other
\r
128 tasks that exist within the system. The value is then used to ensure at run
\r
129 time the number of tasks that exists is within expected bounds. */
\r
130 vCreateSuicidalTasks( mainDEATH_PRIORITY );
\r
132 /* Now start the scheduler. Following this call the created tasks should
\r
134 vTaskStartScheduler( );
\r
136 /* vTaskStartScheduler() will only return if an error occurs while the
\r
137 idle task is being created. */
\r
143 static portSHORT prvCheckOtherTasksAreStillRunning( void )
\r
145 portBASE_TYPE lReturn = pdPASS;
\r
147 /* The demo tasks maintain a count that increments every cycle of the task
\r
148 provided that the task has never encountered an error. This function
\r
149 checks the counts maintained by the tasks to ensure they are still being
\r
150 incremented. A count remaining at the same value between calls therefore
\r
151 indicates that an error has been detected. */
\r
153 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
158 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
163 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
168 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
173 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
178 if( xAreMathsTaskStillRunning() != pdTRUE )
\r
183 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
188 if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
193 if ( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
198 if ( xAreQueuePeekTasksStillRunning() != pdTRUE )
\r
203 /* Have the register test tasks found any errors? */
\r
204 if( xRegTestStatus != pdPASS )
\r
211 /*-----------------------------------------------------------*/
\r
213 static void prvErrorChecks( void *pvParameters )
\r
215 portTickType xDelayPeriod = mainNO_ERROR_CHECK_DELAY, xLastExecutionTime;
\r
216 volatile unsigned portBASE_TYPE uxFreeStack;
\r
218 uxFreeStack = uxTaskGetStackHighWaterMark();
\r
220 /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
\r
221 works correctly. */
\r
222 xLastExecutionTime = xTaskGetTickCount();
\r
224 /* Cycle for ever, delaying then checking all the other tasks are still
\r
225 operating without error. */
\r
228 uxFreeStack = uxTaskGetStackHighWaterMark();
\r
230 /* Wait until it is time to check again. The time we wait here depends
\r
231 on whether an error has been detected or not. When an error is
\r
232 detected the time is shortened resulting in a faster LED flash rate. */
\r
233 /* Perform this check every mainCHECK_DELAY milliseconds. */
\r
234 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );
\r
236 /* See if the other tasks are all ok. */
\r
237 if( prvCheckOtherTasksAreStillRunning() != pdPASS )
\r
239 /* An error occurred in one of the tasks so shorten the delay
\r
240 period - which has the effect of increasing the frequency of the
\r
242 xDelayPeriod = mainERROR_CHECK_DELAY;
\r
246 vParTestToggleLED( mainCHECK_TEST_LED );
\r
249 /*-----------------------------------------------------------*/
\r
252 static void prvRegTestTask1( void *pvParameters )
\r
256 "RegTest1Start: \n\t" \
\r
267 " li 10, 10 \n\t" \
\r
268 " li 11, 11 \n\t" \
\r
269 " li 12, 12 \n\t" \
\r
270 " li 13, 13 \n\t" \
\r
271 " li 14, 14 \n\t" \
\r
272 " li 15, 15 \n\t" \
\r
273 " li 16, 16 \n\t" \
\r
274 " li 17, 17 \n\t" \
\r
275 " li 18, 18 \n\t" \
\r
276 " li 19, 19 \n\t" \
\r
277 " li 20, 20 \n\t" \
\r
278 " li 21, 21 \n\t" \
\r
279 " li 22, 22 \n\t" \
\r
280 " li 23, 23 \n\t" \
\r
281 " li 24, 24 \n\t" \
\r
282 " li 25, 25 \n\t" \
\r
283 " li 26, 26 \n\t" \
\r
284 " li 27, 27 \n\t" \
\r
285 " li 28, 28 \n\t" \
\r
286 " li 29, 29 \n\t" \
\r
287 " li 30, 30 \n\t" \
\r
288 " li 31, 31 \n\t" \
\r
293 " cmpwi 0, 1 \n\t" \
\r
294 " bne RegTest1Fail \n\t" \
\r
295 " cmpwi 2, 2 \n\t" \
\r
296 " bne RegTest1Fail \n\t" \
\r
297 " cmpwi 3, 3 \n\t" \
\r
298 " bne RegTest1Fail \n\t" \
\r
299 " cmpwi 4, 4 \n\t" \
\r
300 " bne RegTest1Fail \n\t" \
\r
301 " cmpwi 5, 5 \n\t" \
\r
302 " bne RegTest1Fail \n\t" \
\r
303 " cmpwi 6, 6 \n\t" \
\r
304 " bne RegTest1Fail \n\t" \
\r
305 " cmpwi 7, 7 \n\t" \
\r
306 " bne RegTest1Fail \n\t" \
\r
307 " cmpwi 8, 8 \n\t" \
\r
308 " bne RegTest1Fail \n\t" \
\r
309 " cmpwi 9, 9 \n\t" \
\r
310 " bne RegTest1Fail \n\t" \
\r
311 " cmpwi 10, 10 \n\t" \
\r
312 " bne RegTest1Fail \n\t" \
\r
313 " cmpwi 11, 11 \n\t" \
\r
314 " bne RegTest1Fail \n\t" \
\r
315 " cmpwi 12, 12 \n\t" \
\r
316 " bne RegTest1Fail \n\t" \
\r
317 " cmpwi 13, 13 \n\t" \
\r
318 " bne RegTest1Fail \n\t" \
\r
319 " cmpwi 14, 14 \n\t" \
\r
320 " bne RegTest1Fail \n\t" \
\r
321 " cmpwi 15, 15 \n\t" \
\r
322 " bne RegTest1Fail \n\t" \
\r
323 " cmpwi 16, 16 \n\t" \
\r
324 " bne RegTest1Fail \n\t" \
\r
325 " cmpwi 17, 17 \n\t" \
\r
326 " bne RegTest1Fail \n\t" \
\r
327 " cmpwi 18, 18 \n\t" \
\r
328 " bne RegTest1Fail \n\t" \
\r
329 " cmpwi 19, 19 \n\t" \
\r
330 " bne RegTest1Fail \n\t" \
\r
331 " cmpwi 20, 20 \n\t" \
\r
332 " bne RegTest1Fail \n\t" \
\r
333 " cmpwi 21, 21 \n\t" \
\r
334 " bne RegTest1Fail \n\t" \
\r
335 " cmpwi 22, 22 \n\t" \
\r
336 " bne RegTest1Fail \n\t" \
\r
337 " cmpwi 23, 23 \n\t" \
\r
338 " bne RegTest1Fail \n\t" \
\r
339 " cmpwi 24, 24 \n\t" \
\r
340 " bne RegTest1Fail \n\t" \
\r
341 " cmpwi 25, 25 \n\t" \
\r
342 " bne RegTest1Fail \n\t" \
\r
343 " cmpwi 26, 26 \n\t" \
\r
344 " bne RegTest1Fail \n\t" \
\r
345 " cmpwi 27, 27 \n\t" \
\r
346 " bne RegTest1Fail \n\t" \
\r
347 " cmpwi 28, 28 \n\t" \
\r
348 " bne RegTest1Fail \n\t" \
\r
349 " cmpwi 29, 29 \n\t" \
\r
350 " bne RegTest1Fail \n\t" \
\r
351 " cmpwi 30, 30 \n\t" \
\r
352 " bne RegTest1Fail \n\t" \
\r
353 " cmpwi 31, 31 \n\t" \
\r
354 " bne RegTest1Fail \n\t" \
\r
356 " b RegTest1Start \n\t" \
\r
358 "RegTest1Fail: \n\t" \
\r
360 " xor 0, 0, 0 \n\t" \
\r
361 " stw 0, xRegTestStatus( 0 ) \n\t" \
\r
363 " b RegTest1Start \n\t" \
\r
367 static void prvRegTestTask2( void *pvParameters )
\r
371 "RegTest2Start: \n\t" \
\r
382 " li 10, 110 \n\t" \
\r
383 " li 11, 111 \n\t" \
\r
384 " li 12, 112 \n\t" \
\r
385 " li 13, 113 \n\t" \
\r
386 " li 14, 114 \n\t" \
\r
387 " li 15, 115 \n\t" \
\r
388 " li 16, 116 \n\t" \
\r
389 " li 17, 117 \n\t" \
\r
390 " li 18, 118 \n\t" \
\r
391 " li 19, 119 \n\t" \
\r
392 " li 20, 120 \n\t" \
\r
393 " li 21, 121 \n\t" \
\r
394 " li 22, 122 \n\t" \
\r
395 " li 23, 123 \n\t" \
\r
396 " li 24, 124 \n\t" \
\r
397 " li 25, 125 \n\t" \
\r
398 " li 26, 126 \n\t" \
\r
399 " li 27, 127 \n\t" \
\r
400 " li 28, 128 \n\t" \
\r
401 " li 29, 129 \n\t" \
\r
402 " li 30, 130 \n\t" \
\r
403 " li 31, 131 \n\t" \
\r
408 " cmpwi 0, 11 \n\t" \
\r
409 " bne RegTest2Fail \n\t" \
\r
410 " cmpwi 2, 12 \n\t" \
\r
411 " bne RegTest2Fail \n\t" \
\r
412 " cmpwi 3, 13 \n\t" \
\r
413 " bne RegTest2Fail \n\t" \
\r
414 " cmpwi 4, 14 \n\t" \
\r
415 " bne RegTest2Fail \n\t" \
\r
416 " cmpwi 5, 15 \n\t" \
\r
417 " bne RegTest2Fail \n\t" \
\r
418 " cmpwi 6, 16 \n\t" \
\r
419 " bne RegTest2Fail \n\t" \
\r
420 " cmpwi 7, 17 \n\t" \
\r
421 " bne RegTest2Fail \n\t" \
\r
422 " cmpwi 8, 18 \n\t" \
\r
423 " bne RegTest2Fail \n\t" \
\r
424 " cmpwi 9, 19 \n\t" \
\r
425 " bne RegTest2Fail \n\t" \
\r
426 " cmpwi 10, 110 \n\t" \
\r
427 " bne RegTest2Fail \n\t" \
\r
428 " cmpwi 11, 111 \n\t" \
\r
429 " bne RegTest2Fail \n\t" \
\r
430 " cmpwi 12, 112 \n\t" \
\r
431 " bne RegTest2Fail \n\t" \
\r
432 " cmpwi 13, 113 \n\t" \
\r
433 " bne RegTest2Fail \n\t" \
\r
434 " cmpwi 14, 114 \n\t" \
\r
435 " bne RegTest2Fail \n\t" \
\r
436 " cmpwi 15, 115 \n\t" \
\r
437 " bne RegTest2Fail \n\t" \
\r
438 " cmpwi 16, 116 \n\t" \
\r
439 " bne RegTest2Fail \n\t" \
\r
440 " cmpwi 17, 117 \n\t" \
\r
441 " bne RegTest2Fail \n\t" \
\r
442 " cmpwi 18, 118 \n\t" \
\r
443 " bne RegTest2Fail \n\t" \
\r
444 " cmpwi 19, 119 \n\t" \
\r
445 " bne RegTest2Fail \n\t" \
\r
446 " cmpwi 20, 120 \n\t" \
\r
447 " bne RegTest2Fail \n\t" \
\r
448 " cmpwi 21, 121 \n\t" \
\r
449 " bne RegTest2Fail \n\t" \
\r
450 " cmpwi 22, 122 \n\t" \
\r
451 " bne RegTest2Fail \n\t" \
\r
452 " cmpwi 23, 123 \n\t" \
\r
453 " bne RegTest2Fail \n\t" \
\r
454 " cmpwi 24, 124 \n\t" \
\r
455 " bne RegTest2Fail \n\t" \
\r
456 " cmpwi 25, 125 \n\t" \
\r
457 " bne RegTest2Fail \n\t" \
\r
458 " cmpwi 26, 126 \n\t" \
\r
459 " bne RegTest2Fail \n\t" \
\r
460 " cmpwi 27, 127 \n\t" \
\r
461 " bne RegTest2Fail \n\t" \
\r
462 " cmpwi 28, 128 \n\t" \
\r
463 " bne RegTest2Fail \n\t" \
\r
464 " cmpwi 29, 129 \n\t" \
\r
465 " bne RegTest2Fail \n\t" \
\r
466 " cmpwi 30, 130 \n\t" \
\r
467 " bne RegTest2Fail \n\t" \
\r
468 " cmpwi 31, 131 \n\t" \
\r
469 " bne RegTest2Fail \n\t" \
\r
471 " b RegTest2Start \n\t" \
\r
473 "RegTest2Fail: \n\t" \
\r
475 " xor 0, 0, 0 \n\t" \
\r
476 " stw 0, xRegTestStatus( 0 ) \n\t" \
\r
478 " b RegTest2Start \n\t" \
\r
485 static void prvRegTestTask2( void *pvParameters )
\r
487 volatile unsigned int i= 0;
\r
496 static void prvRegTestTask1( void *pvParameters )
\r
498 volatile unsigned int i= 0;
\r
509 void vApplicationStackOverflowHook( xTaskHandle xTask, signed portCHAR *pcTaskName );
\r
510 void vApplicationStackOverflowHook( xTaskHandle xTask, signed portCHAR *pcTaskName )
\r