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
61 * The "Register Check" tasks. These tasks fill the CPU registers with known
\r
62 * values, then check that each register still contains the expected value, the
\r
63 * discovery of an unexpected value being indicative of an error in the RTOS
\r
64 * context switch mechanism. The register check tasks operate at low priority
\r
65 * so are switched in and out frequently.
\r
70 /* Scheduler includes. */
\r
71 #include "FreeRTOS.h"
\r
74 /* Xilinx library includes. */
\r
75 #include "xcache_l.h"
\r
78 /* Demo application includes. */
\r
80 #include "integer.h"
\r
81 #include "comtest2.h"
\r
82 #include "semtest.h"
\r
84 #include "dynamic.h"
\r
86 #include "GenQTest.h"
\r
88 #include "blocktim.h"
\r
90 #include "partest.h"
\r
92 /* Priorities assigned to the demo tasks. */
\r
93 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
94 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
95 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
96 #define mainQUEUE_BLOCK_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
97 #define mainDEATH_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
98 #define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
99 #define mainGENERIC_QUEUE_PRIORITY ( tskIDLE_PRIORITY )
\r
101 /* The first LED used by the COM test and check tasks respectively. */
\r
102 #define mainCOM_TEST_LED ( 4 )
\r
103 #define mainCHECK_TEST_LED ( 3 )
\r
105 /* The baud rate used by the comtest tasks is set by the hardware, so the
\r
106 baud rate parameters passed into the comtest initialisation has no effect. */
\r
107 #define mainBAUD_SET_IN_HARDWARE ( 0 )
\r
109 /* Delay periods used by the check task. If no errors have been found then
\r
110 the check LED will toggle every mainNO_ERROR_CHECK_DELAY milliseconds. If an
\r
111 error has been found at any time then the toggle rate will increase to
\r
112 mainERROR_CHECK_DELAY milliseconds. */
\r
113 #define mainNO_ERROR_CHECK_DELAY ( ( portTickType ) 3000 / portTICK_RATE_MS )
\r
114 #define mainERROR_CHECK_DELAY ( ( portTickType ) 500 / portTICK_RATE_MS )
\r
118 * The tasks defined within this file - described within the comments at the
\r
119 * head of this page.
\r
121 static void prvRegTestTask1( void *pvParameters );
\r
122 static void prvRegTestTask2( void *pvParameters );
\r
123 static void prvErrorChecks( void *pvParameters );
\r
126 * Called by the 'check' task to inspect all the standard demo tasks within
\r
127 * the system, as described within the comments at the head of this page.
\r
129 static portSHORT prvCheckOtherTasksAreStillRunning( void );
\r
132 * Perform any hardware initialisation required by the demo application.
\r
134 static void prvSetupHardware( void );
\r
136 /*-----------------------------------------------------------*/
\r
138 /* xRegTestStatus will geet set to pdFAIL by the regtest tasks if they
\r
139 discover an unexpected value. */
\r
140 static unsigned portBASE_TYPE xRegTestStatus = pdPASS;
\r
142 /*-----------------------------------------------------------*/
\r
146 /* Must be called prior to installing any interrupt handlers! */
\r
147 vPortSetupInterruptController();
\r
149 /* In this case prvSetupHardware() just enables the caches and and
\r
150 configures the IO ports for the LED outputs. */
\r
151 prvSetupHardware();
\r
153 /* Start the standard demo application tasks. Note that the baud rate used
\r
154 by the comtest tasks is set by the hardware, so the baud rate paramter
\r
155 passed has no effect. */
\r
156 vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
\r
157 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
158 vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainBAUD_SET_IN_HARDWARE, mainCOM_TEST_LED );
\r
159 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
160 vStartBlockingQueueTasks ( mainQUEUE_BLOCK_PRIORITY );
\r
161 vStartDynamicPriorityTasks();
\r
162 vStartMathTasks( tskIDLE_PRIORITY );
\r
163 vStartGenericQueueTasks( mainGENERIC_QUEUE_PRIORITY );
\r
164 vStartQueuePeekTasks();
\r
165 vCreateBlockTimeTasks();
\r
167 /* Create the tasks defined within this file. */
\r
168 xTaskCreate( prvRegTestTask1, "Regtest1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
\r
169 xTaskCreate( prvRegTestTask2, "Regtest2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
\r
170 xTaskCreate( prvErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
172 /* The suicide tasks must be started last as they record the number of other
\r
173 tasks that exist within the system. The value is then used to ensure at run
\r
174 time the number of tasks that exists is within expected bounds. */
\r
175 vCreateSuicidalTasks( mainDEATH_PRIORITY );
\r
177 /* Now start the scheduler. Following this call the created tasks should
\r
179 vTaskStartScheduler( );
\r
181 /* vTaskStartScheduler() will only return if an error occurs while the
\r
182 idle task is being created. */
\r
187 /*-----------------------------------------------------------*/
\r
189 static portSHORT prvCheckOtherTasksAreStillRunning( void )
\r
191 portBASE_TYPE lReturn = pdPASS;
\r
193 /* The demo tasks maintain a count that increments every cycle of the task
\r
194 provided that the task has never encountered an error. This function
\r
195 checks the counts maintained by the tasks to ensure they are still being
\r
196 incremented. A count remaining at the same value between calls therefore
\r
197 indicates that an error has been detected. */
\r
199 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
204 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
209 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
214 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
219 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
224 if( xAreMathsTaskStillRunning() != pdTRUE )
\r
229 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
234 if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
239 if ( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
244 if ( xAreQueuePeekTasksStillRunning() != pdTRUE )
\r
249 /* Have the register test tasks found any errors? */
\r
250 if( xRegTestStatus != pdPASS )
\r
257 /*-----------------------------------------------------------*/
\r
259 static void prvErrorChecks( void *pvParameters )
\r
261 portTickType xDelayPeriod = mainNO_ERROR_CHECK_DELAY, xLastExecutionTime;
\r
262 volatile unsigned portBASE_TYPE uxFreeStack;
\r
264 uxFreeStack = uxTaskGetStackHighWaterMark( NULL );
\r
266 /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
\r
267 works correctly. */
\r
268 xLastExecutionTime = xTaskGetTickCount();
\r
270 /* Cycle for ever, delaying then checking all the other tasks are still
\r
271 operating without error. */
\r
274 uxFreeStack = uxTaskGetStackHighWaterMark( NULL );
\r
276 /* Wait until it is time to check again. The time we wait here depends
\r
277 on whether an error has been detected or not. When an error is
\r
278 detected the time is shortened resulting in a faster LED flash rate. */
\r
279 /* Perform this check every mainCHECK_DELAY milliseconds. */
\r
280 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );
\r
282 /* See if the other tasks are all ok. */
\r
283 if( prvCheckOtherTasksAreStillRunning() != pdPASS )
\r
285 /* An error occurred in one of the tasks so shorten the delay
\r
286 period - which has the effect of increasing the frequency of the
\r
288 xDelayPeriod = mainERROR_CHECK_DELAY;
\r
292 vParTestToggleLED( mainCHECK_TEST_LED );
\r
295 /*-----------------------------------------------------------*/
\r
297 static void prvSetupHardware( void )
\r
299 XCache_EnableICache( 0x80000000 );
\r
300 XCache_EnableDCache( 0x80000000 );
\r
302 vParTestInitialise();
\r
305 static void prvRegTestTask1( void *pvParameters )
\r
309 "RegTest1Start: \n\t" \
\r
320 " li 10, 10 \n\t" \
\r
321 " li 11, 11 \n\t" \
\r
322 " li 12, 12 \n\t" \
\r
323 " li 13, 13 \n\t" \
\r
324 " li 14, 14 \n\t" \
\r
325 " li 15, 15 \n\t" \
\r
326 " li 16, 16 \n\t" \
\r
327 " li 17, 17 \n\t" \
\r
328 " li 18, 18 \n\t" \
\r
329 " li 19, 19 \n\t" \
\r
330 " li 20, 20 \n\t" \
\r
331 " li 21, 21 \n\t" \
\r
332 " li 22, 22 \n\t" \
\r
333 " li 23, 23 \n\t" \
\r
334 " li 24, 24 \n\t" \
\r
335 " li 25, 25 \n\t" \
\r
336 " li 26, 26 \n\t" \
\r
337 " li 27, 27 \n\t" \
\r
338 " li 28, 28 \n\t" \
\r
339 " li 29, 29 \n\t" \
\r
340 " li 30, 30 \n\t" \
\r
341 " li 31, 31 \n\t" \
\r
346 " cmpwi 0, 1 \n\t" \
\r
347 " bne RegTest1Fail \n\t" \
\r
348 " cmpwi 2, 2 \n\t" \
\r
349 " bne RegTest1Fail \n\t" \
\r
350 " cmpwi 3, 3 \n\t" \
\r
351 " bne RegTest1Fail \n\t" \
\r
352 " cmpwi 4, 4 \n\t" \
\r
353 " bne RegTest1Fail \n\t" \
\r
354 " cmpwi 5, 5 \n\t" \
\r
355 " bne RegTest1Fail \n\t" \
\r
356 " cmpwi 6, 6 \n\t" \
\r
357 " bne RegTest1Fail \n\t" \
\r
358 " cmpwi 7, 7 \n\t" \
\r
359 " bne RegTest1Fail \n\t" \
\r
360 " cmpwi 8, 8 \n\t" \
\r
361 " bne RegTest1Fail \n\t" \
\r
362 " cmpwi 9, 9 \n\t" \
\r
363 " bne RegTest1Fail \n\t" \
\r
364 " cmpwi 10, 10 \n\t" \
\r
365 " bne RegTest1Fail \n\t" \
\r
366 " cmpwi 11, 11 \n\t" \
\r
367 " bne RegTest1Fail \n\t" \
\r
368 " cmpwi 12, 12 \n\t" \
\r
369 " bne RegTest1Fail \n\t" \
\r
370 " cmpwi 13, 13 \n\t" \
\r
371 " bne RegTest1Fail \n\t" \
\r
372 " cmpwi 14, 14 \n\t" \
\r
373 " bne RegTest1Fail \n\t" \
\r
374 " cmpwi 15, 15 \n\t" \
\r
375 " bne RegTest1Fail \n\t" \
\r
376 " cmpwi 16, 16 \n\t" \
\r
377 " bne RegTest1Fail \n\t" \
\r
378 " cmpwi 17, 17 \n\t" \
\r
379 " bne RegTest1Fail \n\t" \
\r
380 " cmpwi 18, 18 \n\t" \
\r
381 " bne RegTest1Fail \n\t" \
\r
382 " cmpwi 19, 19 \n\t" \
\r
383 " bne RegTest1Fail \n\t" \
\r
384 " cmpwi 20, 20 \n\t" \
\r
385 " bne RegTest1Fail \n\t" \
\r
386 " cmpwi 21, 21 \n\t" \
\r
387 " bne RegTest1Fail \n\t" \
\r
388 " cmpwi 22, 22 \n\t" \
\r
389 " bne RegTest1Fail \n\t" \
\r
390 " cmpwi 23, 23 \n\t" \
\r
391 " bne RegTest1Fail \n\t" \
\r
392 " cmpwi 24, 24 \n\t" \
\r
393 " bne RegTest1Fail \n\t" \
\r
394 " cmpwi 25, 25 \n\t" \
\r
395 " bne RegTest1Fail \n\t" \
\r
396 " cmpwi 26, 26 \n\t" \
\r
397 " bne RegTest1Fail \n\t" \
\r
398 " cmpwi 27, 27 \n\t" \
\r
399 " bne RegTest1Fail \n\t" \
\r
400 " cmpwi 28, 28 \n\t" \
\r
401 " bne RegTest1Fail \n\t" \
\r
402 " cmpwi 29, 29 \n\t" \
\r
403 " bne RegTest1Fail \n\t" \
\r
404 " cmpwi 30, 30 \n\t" \
\r
405 " bne RegTest1Fail \n\t" \
\r
406 " cmpwi 31, 31 \n\t" \
\r
407 " bne RegTest1Fail \n\t" \
\r
409 " b RegTest1Start \n\t" \
\r
411 "RegTest1Fail: \n\t" \
\r
413 " xor 0, 0, 0 \n\t" \
\r
414 " stw 0, xRegTestStatus( 0 ) \n\t" \
\r
416 " b RegTest1Start \n\t" \
\r
420 static void prvRegTestTask2( void *pvParameters )
\r
424 "RegTest2Start: \n\t" \
\r
435 " li 10, 110 \n\t" \
\r
436 " li 11, 111 \n\t" \
\r
437 " li 12, 112 \n\t" \
\r
438 " li 13, 113 \n\t" \
\r
439 " li 14, 114 \n\t" \
\r
440 " li 15, 115 \n\t" \
\r
441 " li 16, 116 \n\t" \
\r
442 " li 17, 117 \n\t" \
\r
443 " li 18, 118 \n\t" \
\r
444 " li 19, 119 \n\t" \
\r
445 " li 20, 120 \n\t" \
\r
446 " li 21, 121 \n\t" \
\r
447 " li 22, 122 \n\t" \
\r
448 " li 23, 123 \n\t" \
\r
449 " li 24, 124 \n\t" \
\r
450 " li 25, 125 \n\t" \
\r
451 " li 26, 126 \n\t" \
\r
452 " li 27, 127 \n\t" \
\r
453 " li 28, 128 \n\t" \
\r
454 " li 29, 129 \n\t" \
\r
455 " li 30, 130 \n\t" \
\r
456 " li 31, 131 \n\t" \
\r
461 " cmpwi 0, 11 \n\t" \
\r
462 " bne RegTest2Fail \n\t" \
\r
463 " cmpwi 2, 12 \n\t" \
\r
464 " bne RegTest2Fail \n\t" \
\r
465 " cmpwi 3, 13 \n\t" \
\r
466 " bne RegTest2Fail \n\t" \
\r
467 " cmpwi 4, 14 \n\t" \
\r
468 " bne RegTest2Fail \n\t" \
\r
469 " cmpwi 5, 15 \n\t" \
\r
470 " bne RegTest2Fail \n\t" \
\r
471 " cmpwi 6, 16 \n\t" \
\r
472 " bne RegTest2Fail \n\t" \
\r
473 " cmpwi 7, 17 \n\t" \
\r
474 " bne RegTest2Fail \n\t" \
\r
475 " cmpwi 8, 18 \n\t" \
\r
476 " bne RegTest2Fail \n\t" \
\r
477 " cmpwi 9, 19 \n\t" \
\r
478 " bne RegTest2Fail \n\t" \
\r
479 " cmpwi 10, 110 \n\t" \
\r
480 " bne RegTest2Fail \n\t" \
\r
481 " cmpwi 11, 111 \n\t" \
\r
482 " bne RegTest2Fail \n\t" \
\r
483 " cmpwi 12, 112 \n\t" \
\r
484 " bne RegTest2Fail \n\t" \
\r
485 " cmpwi 13, 113 \n\t" \
\r
486 " bne RegTest2Fail \n\t" \
\r
487 " cmpwi 14, 114 \n\t" \
\r
488 " bne RegTest2Fail \n\t" \
\r
489 " cmpwi 15, 115 \n\t" \
\r
490 " bne RegTest2Fail \n\t" \
\r
491 " cmpwi 16, 116 \n\t" \
\r
492 " bne RegTest2Fail \n\t" \
\r
493 " cmpwi 17, 117 \n\t" \
\r
494 " bne RegTest2Fail \n\t" \
\r
495 " cmpwi 18, 118 \n\t" \
\r
496 " bne RegTest2Fail \n\t" \
\r
497 " cmpwi 19, 119 \n\t" \
\r
498 " bne RegTest2Fail \n\t" \
\r
499 " cmpwi 20, 120 \n\t" \
\r
500 " bne RegTest2Fail \n\t" \
\r
501 " cmpwi 21, 121 \n\t" \
\r
502 " bne RegTest2Fail \n\t" \
\r
503 " cmpwi 22, 122 \n\t" \
\r
504 " bne RegTest2Fail \n\t" \
\r
505 " cmpwi 23, 123 \n\t" \
\r
506 " bne RegTest2Fail \n\t" \
\r
507 " cmpwi 24, 124 \n\t" \
\r
508 " bne RegTest2Fail \n\t" \
\r
509 " cmpwi 25, 125 \n\t" \
\r
510 " bne RegTest2Fail \n\t" \
\r
511 " cmpwi 26, 126 \n\t" \
\r
512 " bne RegTest2Fail \n\t" \
\r
513 " cmpwi 27, 127 \n\t" \
\r
514 " bne RegTest2Fail \n\t" \
\r
515 " cmpwi 28, 128 \n\t" \
\r
516 " bne RegTest2Fail \n\t" \
\r
517 " cmpwi 29, 129 \n\t" \
\r
518 " bne RegTest2Fail \n\t" \
\r
519 " cmpwi 30, 130 \n\t" \
\r
520 " bne RegTest2Fail \n\t" \
\r
521 " cmpwi 31, 131 \n\t" \
\r
522 " bne RegTest2Fail \n\t" \
\r
524 " b RegTest2Start \n\t" \
\r
526 "RegTest2Fail: \n\t" \
\r
528 " xor 0, 0, 0 \n\t" \
\r
529 " stw 0, xRegTestStatus( 0 ) \n\t" \
\r
531 " b RegTest2Start \n\t" \
\r
538 static void prvRegTestTask2( void *pvParameters )
\r
540 volatile unsigned int i= 0;
\r
549 static void prvRegTestTask1( void *pvParameters )
\r
551 volatile unsigned int i= 0;
\r
562 void vApplicationStackOverflowHook( xTaskHandle xTask, signed portCHAR *pcTaskName );
\r
563 void vApplicationStackOverflowHook( xTaskHandle xTask, signed portCHAR *pcTaskName )
\r