2 FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.
\r
4 FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
\r
5 http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\r
9 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
10 * Complete, revised, and edited pdf reference manuals are also *
\r
13 * Purchasing FreeRTOS documentation will not only help you, by *
\r
14 * ensuring you get running as quickly as possible and with an *
\r
15 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
16 * the FreeRTOS project to continue with its mission of providing *
\r
17 * professional grade, cross platform, de facto standard solutions *
\r
18 * for microcontrollers - completely free of charge! *
\r
20 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
22 * Thank you for using FreeRTOS, and thank you for your support! *
\r
24 ***************************************************************************
\r
27 This file is part of the FreeRTOS distribution.
\r
29 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
30 the terms of the GNU General Public License (version 2) as published by the
\r
31 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
32 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
33 distribute a combined work that includes FreeRTOS without being obliged to
\r
34 provide the source code for proprietary components outside of the FreeRTOS
\r
35 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
36 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
37 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
38 more details. You should have received a copy of the GNU General Public
\r
39 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
40 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
41 by writing to Richard Barry, contact details for whom are available on the
\r
46 ***************************************************************************
\r
48 * Having a problem? Start by reading the FAQ "My application does *
\r
49 * not run, what could be wrong?" *
\r
51 * http://www.FreeRTOS.org/FAQHelp.html *
\r
53 ***************************************************************************
\r
56 http://www.FreeRTOS.org - Documentation, training, latest versions, license
\r
57 and contact details.
\r
59 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
60 including FreeRTOS+Trace - an indispensable productivity tool.
\r
62 Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
\r
63 the code with commercial support, indemnification, and middleware, under
\r
64 the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
\r
65 provide a safety engineered and independently SIL3 certified version under
\r
66 the SafeRTOS brand: http://www.SafeRTOS.com.
\r
69 /******************************************************************************
\r
70 * >>>>>> NOTE: <<<<<<
\r
72 * main() can be configured to create either a very simple LED flasher demo, or
\r
73 * a more comprehensive test/demo application.
\r
75 * To create a very simple LED flasher example, set the
\r
76 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant (defined below) to 1. When
\r
77 * this is done, only the standard demo flash tasks are created. The standard
\r
78 * demo flash example creates three tasks, each toggle an LED at a fixed but
\r
79 * different frequency.
\r
81 * To create a more comprehensive test and demo application, set
\r
82 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0.
\r
84 * Two build configurations are provided, one that executes from RAM and one
\r
85 * that executes from Flash. The RAM build uses size optimisation, the Flash
\r
86 * build has optimisation completely turned off. The documentation page for
\r
87 * this port on the FreeRTOS.org web site provides full information.
\r
88 ******************************************************************************
\r
90 * main() creates all the demo application tasks and timers, then starts the
\r
91 * scheduler. The web documentation provides more details of the standard demo
\r
92 * application tasks, which provide no particular functionality, but do provide
\r
93 * a good example of how to use the FreeRTOS API.
\r
95 * In addition to the standard demo tasks, the following tasks and tests are
\r
96 * defined and/or created within this file:
\r
98 * "Reg test" tasks - These fill the registers with known values, then check
\r
99 * that each register maintains its expected value for the lifetime of the
\r
100 * task. Each task uses a different set of values. The reg test tasks execute
\r
101 * with a very low priority, so get preempted very frequently. A register
\r
102 * containing an unexpected value is indicative of an error in the context
\r
103 * switching mechanism.
\r
105 * "Check" task - The check task period is initially set to five seconds.
\r
106 * Each time it executes, the check task checks that all the standard demo
\r
107 * tasks, and the register check tasks, are not only still executing, but are
\r
108 * executing without reporting any errors. If the check task discovers that a
\r
109 * task has either stalled, or reported an error, then it changes its own
\r
110 * execution period from the initial five seconds, to just 500ms. The check
\r
111 * task also toggles an LED each time it is called. This provides a visual
\r
112 * indication of the system status: If the LED toggles every five seconds,
\r
113 * then no issues have been discovered. If the LED toggles every 500ms, then
\r
114 * an issue has been discovered with at least one task.
\r
116 * ***NOTE*** This demo uses the standard comtest tasks, which has special
\r
117 * hardware requirements as a loopback connector, or UART echo server are
\r
118 * required. See the documentation page for this demo on the FreeRTOS.org web
\r
119 * site for more information. Note that the comtest tasks were tested by
\r
120 * placing the UART into loopback mode directly in the serial initialisation
\r
121 * sequence, and as such, the baud rate used has not been verified as actually
\r
125 /* Standard includes. */
\r
126 #include <stdlib.h>
\r
127 #include <string.h>
\r
129 /* Scheduler includes. */
\r
130 #include "FreeRTOS.h"
\r
132 #include "croutine.h"
\r
134 /* Demo application includes. */
\r
135 #include "partest.h"
\r
137 #include "integer.h"
\r
139 #include "comtest2.h"
\r
140 #include "semtest.h"
\r
141 #include "dynamic.h"
\r
142 #include "BlockQ.h"
\r
143 #include "blocktim.h"
\r
144 #include "countsem.h"
\r
145 #include "GenQTest.h"
\r
146 #include "recmutex.h"
\r
147 #include "serial.h"
\r
149 #include "TimerDemo.h"
\r
150 #include "InterruptNestTest.h"
\r
152 /*-----------------------------------------------------------*/
\r
154 /* Constants for the ComTest tasks. */
\r
155 #define mainCOM_TEST_BAUD_RATE ( ( unsigned long ) 200000 )
\r
157 #define mainCOM_TEST_LED ( 5 )
\r
159 /* Priorities for the demo application tasks. */
\r
160 #define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
161 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
162 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
163 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
164 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
165 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
166 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
168 /* The rate at which the on board LED will toggle when there is/is not an
\r
170 #define mainNO_ERROR_FLASH_PERIOD_MS ( ( portTickType ) 5000 / portTICK_RATE_MS )
\r
171 #define mainERROR_FLASH_PERIOD_MS ( ( portTickType ) 500 / portTICK_RATE_MS )
\r
172 #define mainON_BOARD_LED_BIT ( ( unsigned long ) 7 )
\r
174 /* Constant used by the standard timer test functions. The timers created by
\r
175 the timer test functions will all have a period that is a multiple of this
\r
177 #define mainTIMER_TEST_PERIOD ( 200 )
\r
179 /* Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 1 to create a simple demo.
\r
180 Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0 to create a much more
\r
181 comprehensive test application. See the comments at the top of this file, and
\r
182 the documentation page on the http://www.FreeRTOS.org web site for more
\r
184 #define mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY 0
\r
186 /*-----------------------------------------------------------*/
\r
189 * Checks that all the demo application tasks are still executing without error
\r
190 * - as described at the top of the file.
\r
192 static long prvCheckOtherTasksAreStillRunning( void );
\r
195 * The task that executes at the highest priority and calls
\r
196 * prvCheckOtherTasksAreStillRunning(). See the description at the top
\r
199 static void prvCheckTask( void *pvParameters );
\r
202 * Configure the processor ready to run this demo.
\r
204 static void prvSetupHardware( void );
\r
207 * Writes to and checks the value of each register that is used in the context
\r
208 * of a task. See the comments at the top of this file.
\r
210 static void prvRegisterCheckTask1( void *pvParameters );
\r
211 static void prvRegisterCheckTask2( void *pvParameters );
\r
214 * Specific check to see if the register test functions are still operating
\r
217 static portBASE_TYPE prvAreRegTestTasksStillRunning( void );
\r
220 * This file can be used to create either a simple LED flasher example, or a
\r
221 * comprehensive test/demo application - depending on the setting of the
\r
222 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant defined above. If
\r
223 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 1, then the following
\r
224 * function will create a lot of additional tasks and timers. If
\r
225 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 0, then the following
\r
226 * function will do nothing.
\r
228 static void prvOptionallyCreateComprehensveTestApplication( void );
\r
230 /*-----------------------------------------------------------*/
\r
232 /* Used by the register test tasks to indicated liveness. */
\r
233 static unsigned long ulRegisterTest1Count = 0;
\r
234 static unsigned long ulRegisterTest2Count = 0;
\r
236 /*-----------------------------------------------------------*/
\r
239 * Starts all the tasks, then starts the scheduler.
\r
243 /* Setup the hardware for use with the TriCore evaluation board. */
\r
244 prvSetupHardware();
\r
246 /* Start standard demo/test application flash tasks. See the comments at
\r
247 the top of this file. The LED flash tasks are always created. The other
\r
248 tasks are only created if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to
\r
249 0 (at the top of this file). See the comments at the top of this file for
\r
250 more information. */
\r
251 vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
\r
253 /* The following function will only create more tasks and timers if
\r
254 mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 0 (at the top of this
\r
255 file). See the comments at the top of this file for more information. */
\r
256 prvOptionallyCreateComprehensveTestApplication();
\r
258 /* Now all the tasks have been started - start the scheduler. */
\r
259 vTaskStartScheduler();
\r
261 /* If all is well then the following line will never be reached. If
\r
262 execution does reach here, then it is highly probably that the heap size
\r
263 is too small for the idle and/or timer tasks to be created within
\r
264 vTaskStartScheduler(). */
\r
267 /*-----------------------------------------------------------*/
\r
269 static void prvCheckTask( void *pvParameters )
\r
271 portTickType xDelayPeriod = mainNO_ERROR_FLASH_PERIOD_MS;
\r
272 portTickType xLastExecutionTime;
\r
274 /* Just to stop compiler warnings. */
\r
275 ( void ) pvParameters;
\r
277 /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
\r
278 works correctly. */
\r
279 xLastExecutionTime = xTaskGetTickCount();
\r
281 /* Cycle for ever, delaying then checking all the other tasks are still
\r
282 operating without error. If an error is detected then the delay period
\r
283 is decreased from mainNO_ERROR_FLASH_PERIOD_MS to mainERROR_FLASH_PERIOD_MS so
\r
284 the on board LED flash rate will increase. NOTE: This task could easily
\r
285 be replaced by a software timer callback to remove the overhead of having
\r
290 /* Delay until it is time to execute again. */
\r
291 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );
\r
293 /* Check all the standard demo application tasks are executing without
\r
295 if( prvCheckOtherTasksAreStillRunning() != pdPASS )
\r
297 /* An error has been detected in one of the tasks - flash the LED
\r
298 at a higher frequency to give visible feedback that something has
\r
299 gone wrong (it might just be that the loop back connector required
\r
300 by the comtest tasks has not been fitted). */
\r
301 xDelayPeriod = mainERROR_FLASH_PERIOD_MS;
\r
304 /* The toggle rate of the LED depends on how long this task delays for.
\r
305 An error reduces the delay period and so increases the toggle rate. */
\r
306 vParTestToggleLED( mainON_BOARD_LED_BIT );
\r
309 /*-----------------------------------------------------------*/
\r
311 static long prvCheckOtherTasksAreStillRunning( void )
\r
313 long lReturn = pdPASS;
\r
314 unsigned long ulHighFrequencyTimerTaskIterations, ulExpectedIncFrequency_ms;
\r
316 /* Check all the demo tasks (other than the flash tasks) to ensure
\r
317 that they are all still running, and that none have detected an error. */
\r
319 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
324 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
329 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
334 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
339 if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
344 if ( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
349 if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
354 if( prvAreRegTestTasksStillRunning() != pdTRUE )
\r
359 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
364 if( xAreTimerDemoTasksStillRunning( mainNO_ERROR_FLASH_PERIOD_MS ) != pdTRUE )
\r
369 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
374 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
379 /* Obtain the number of times the task associated with the high frequency
\r
380 (interrupt nesting) timer test has increment since the check task last
\r
381 executed, and the frequency at which it is expected to execute in ms. */
\r
382 ulHighFrequencyTimerTaskIterations = ulInterruptNestingTestGetIterationCount( &ulExpectedIncFrequency_ms );
\r
383 if( ( ulHighFrequencyTimerTaskIterations < ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) - 1 ) )
\r
385 ( ulHighFrequencyTimerTaskIterations > ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) +5 ) )
\r
388 /* Would have expected the high frequency timer task to have
\r
389 incremented its execution count more times that reported. */
\r
395 /*-----------------------------------------------------------*/
\r
397 static void prvSetupHardware( void )
\r
399 extern void set_cpu_frequency(void);
\r
401 /* Set-up the PLL. */
\r
402 set_cpu_frequency();
\r
404 /* Initialise LED outputs. */
\r
405 vParTestInitialise();
\r
407 /*-----------------------------------------------------------*/
\r
409 void vApplicationMallocFailedHook( void )
\r
411 /* vApplicationMallocFailedHook() will only be called if
\r
412 configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
\r
413 function that will get called if a call to pvPortMalloc() fails.
\r
414 pvPortMalloc() is called internally by the kernel whenever a task, queue,
\r
415 timer or semaphore is created. It is also called by various parts of the
\r
416 demo application. If heap_1.c or heap_2.c are used, then the size of the
\r
417 heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
\r
418 FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
\r
419 to query the size of free heap space that remains (although it does not
\r
420 provide information on how the remaining heap might be fragmented). */
\r
421 taskDISABLE_INTERRUPTS();
\r
424 /*-----------------------------------------------------------*/
\r
426 void vApplicationTickHook( void )
\r
428 #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY != 1
\r
430 /* vApplicationTickHook() will only be called if configUSE_TICK_HOOK is set
\r
431 to 1 in FreeRTOSConfig.h. It is a hook function that will get called during
\r
432 each FreeRTOS tick interrupt. Note that vApplicationTickHook() is called
\r
433 from an interrupt context. */
\r
435 /* Call the periodic timer test, which tests the timer API functions that
\r
436 can be called from an ISR. */
\r
437 vTimerPeriodicISRTests();
\r
439 #endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
441 /*-----------------------------------------------------------*/
\r
443 void vApplicationIdleHook( void )
\r
445 /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
\r
446 to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle
\r
447 task. It is essential that code added to this hook function never attempts
\r
448 to block in any way (for example, call xQueueReceive() with a block time
\r
449 specified, or call vTaskDelay()). If the application makes use of the
\r
450 vTaskDelete() API function (as this demo application does) then it is also
\r
451 important that vApplicationIdleHook() is permitted to return to its calling
\r
452 function, because it is the responsibility of the idle task to clean up
\r
453 memory allocated by the kernel to any task that has since been deleted. */
\r
455 /*-----------------------------------------------------------*/
\r
457 static portBASE_TYPE prvAreRegTestTasksStillRunning( void )
\r
459 static unsigned long ulPreviousRegisterTest1Count = 0;
\r
460 static unsigned long ulPreviousRegisterTest2Count = 0;
\r
461 portBASE_TYPE xReturn = pdPASS;
\r
463 /* Check to see if the Counts have changed since the last check. */
\r
464 if( ulRegisterTest1Count == ulPreviousRegisterTest1Count )
\r
469 if( ulRegisterTest2Count == ulPreviousRegisterTest2Count )
\r
474 /* Remember the current count for the next time this function is called. */
\r
475 ulPreviousRegisterTest1Count = ulRegisterTest1Count;
\r
476 ulPreviousRegisterTest2Count = ulRegisterTest2Count;
\r
480 /*-----------------------------------------------------------*/
\r
482 static void prvOptionallyCreateComprehensveTestApplication( void )
\r
484 #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY == 0
\r
486 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
487 vStartDynamicPriorityTasks();
\r
488 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
489 vCreateBlockTimeTasks();
\r
490 vStartCountingSemaphoreTasks();
\r
491 vStartGenericQueueTasks( tskIDLE_PRIORITY );
\r
492 vStartRecursiveMutexTasks();
\r
493 vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
\r
494 vSetupInterruptNestingTest();
\r
495 vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
\r
496 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
497 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
499 /* Create the register test tasks, as described at the top of this file. */
\r
500 xTaskCreate( prvRegisterCheckTask1, ( signed char * ) "Reg 1", configMINIMAL_STACK_SIZE, &ulRegisterTest1Count, tskIDLE_PRIORITY, NULL );
\r
501 xTaskCreate( prvRegisterCheckTask2, ( signed char * ) "Reg 2", configMINIMAL_STACK_SIZE, &ulRegisterTest2Count, tskIDLE_PRIORITY, NULL );
\r
503 /* Start the check task - which is defined in this file. */
\r
504 xTaskCreate( prvCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
506 /* This task has to be created last as it keeps account of the number of tasks
\r
507 it expects to see running. */
\r
508 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
510 #else /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
512 /* Just to prevent compiler warnings when the configuration options are
\r
513 set such that these static functions are not used. */
\r
514 ( void ) prvCheckTask;
\r
515 ( void ) prvRegisterCheckTask1;
\r
516 ( void ) prvRegisterCheckTask2;
\r
518 #endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
520 /*-----------------------------------------------------------*/
\r
522 static void prvRegisterCheckTask1( void *pvParameters )
\r
524 /* Make space on the stack for the parameter and a counter. */
\r
525 __asm volatile( " sub.a %sp, 4 \n"
\r
526 " st.a [%sp], %a4 \n"
\r
528 " st.w [%sp]4, %d15 \n" );
\r
530 /* Change all of the Context sensitive registers (except SP and RA). */
\r
554 " mov.a %a12, 12 \n"
\r
555 " mov.a %a13, 13 \n"
\r
556 " mov.a %a14, 14 \n" );
\r
558 /* Check the values of the registers. */
\r
559 __asm( " _task1_loop: \n" \
\r
560 " eq %d1, %d0, 0 \n" \
\r
561 " jne %d1, 1, _task1_error_loop \n" \
\r
562 " eq %d1, %d1, 1 \n" \
\r
563 " jne %d1, 1, _task1_error_loop \n" \
\r
564 " eq %d1, %d2, 2 \n" \
\r
565 " jne %d1, 1, _task1_error_loop \n" \
\r
566 " eq %d1, %d3, 3 \n" \
\r
567 " jne %d1, 1, _task1_error_loop \n" \
\r
568 " eq %d1, %d4, 4 \n" \
\r
569 " jne %d1, 1, _task1_error_loop \n" \
\r
570 " eq %d1, %d5, 5 \n" \
\r
571 " jne %d1, 1, _task1_error_loop \n" \
\r
572 " eq %d1, %d6, 6 \n" \
\r
573 " jne %d1, 1, _task1_error_loop \n" \
\r
574 " eq %d1, %d7, 7 \n" \
\r
575 " jne %d1, 1, _task1_error_loop \n" \
\r
576 " eq %d1, %d8, 8 \n" \
\r
577 " jne %d1, 1, _task1_error_loop \n" \
\r
578 " eq %d1, %d9, 9 \n" \
\r
579 " jne %d1, 1, _task1_error_loop \n" \
\r
580 " eq %d1, %d10, 10 \n" \
\r
581 " jne %d1, 1, _task1_error_loop \n" \
\r
582 " eq %d1, %d11, 11 \n" \
\r
583 " jne %d1, 1, _task1_error_loop \n" \
\r
584 " eq %d1, %d12, 12 \n" \
\r
585 " jne %d1, 1, _task1_error_loop \n" \
\r
586 " eq %d1, %d13, 13 \n" \
\r
587 " jne %d1, 1, _task1_error_loop \n" \
\r
588 " eq %d1, %d14, 14 \n" \
\r
589 " jne %d1, 1, _task1_error_loop \n" \
\r
590 " eq %d1, %d15, 15 \n" \
\r
591 " jne %d1, 1, _task1_error_loop \n" \
\r
592 " mov.a %a15, 2 \n" \
\r
593 " jne.a %a15, %a2, _task1_error_loop \n" \
\r
594 " mov.a %a15, 3 \n" \
\r
595 " jne.a %a15, %a3, _task1_error_loop \n" \
\r
596 " mov.a %a15, 4 \n" \
\r
597 " jne.a %a15, %a4, _task1_error_loop \n" \
\r
598 " mov.a %a15, 5 \n" \
\r
599 " jne.a %a15, %a5, _task1_error_loop \n" \
\r
600 " mov.a %a15, 6 \n" \
\r
601 " jne.a %a15, %a6, _task1_error_loop \n" \
\r
602 " mov.a %a15, 7 \n" \
\r
603 " jne.a %a15, %a7, _task1_error_loop \n" \
\r
604 " mov.a %a15, 12 \n" \
\r
605 " jne.a %a15, %a12, _task1_error_loop \n" \
\r
606 " mov.a %a15, 13 \n" \
\r
607 " jne.a %a15, %a13, _task1_error_loop \n" \
\r
608 " mov.a %a15, 14 \n" \
\r
609 " jne.a %a15, %a14, _task1_error_loop \n" \
\r
610 " j _task1_skip_error_loop \n" \
\r
611 "_task1_error_loop: \n" /* Hitting this error loop will stop the counter incrementing, allowing the check task to recognise an error. */ \
\r
613 " j _task1_error_loop \n" \
\r
614 "_task1_skip_error_loop: \n" );
\r
616 /* Load the parameter address from the stack and modify the value. */
\r
618 " ld.w %d1, [%sp]4 \n" \
\r
620 " st.w [%sp]4, %d1 \n" \
\r
621 " ld.a %a15, [%sp] \n" \
\r
622 " st.w [%a15], %d1 \n" \
\r
623 " j _task1_loop \n" );
\r
625 /* The parameter is used but in the assembly. */
\r
626 (void)pvParameters;
\r
628 /*-----------------------------------------------------------*/
\r
630 static void prvRegisterCheckTask2( void *pvParameters )
\r
632 /* Make space on the stack for the parameter and a counter. */
\r
633 __asm volatile( " sub.a %sp, 4 \n" \
\r
634 " st.a [%sp], %a4 \n" \
\r
635 " mov %d15, 0 \n" \
\r
636 " st.w [%sp]4, %d15 \n" );
\r
638 /* Change all of the Context sensitive registers (except SP and RA). */
\r
639 __asm volatile( " mov %d0, 7 \n" \
\r
647 " mov %d8, 15 \n" \
\r
648 " mov %d9, 14 \n" \
\r
649 " mov %d10, 13 \n" \
\r
650 " mov %d11, 12 \n" \
\r
651 " mov %d12, 11 \n" \
\r
652 " mov %d13, 10 \n" \
\r
653 " mov %d14, 9 \n" \
\r
654 " mov %d15, 8 \n" \
\r
655 " mov.a %a2, 14 \n" \
\r
656 " mov.a %a3, 13 \n" \
\r
657 " mov.a %a4, 12 \n" \
\r
658 " mov.a %a5, 7 \n" \
\r
659 " mov.a %a6, 6 \n" \
\r
660 " mov.a %a7, 5 \n" \
\r
661 " mov.a %a12, 4 \n" \
\r
662 " mov.a %a13, 3 \n" \
\r
663 " mov.a %a14, 2 \n" );
\r
665 /* Check the values of the registers. */
\r
666 __asm volatile( " _task2_loop: \n" \
\r
668 " eq %d1, %d0, 7 \n" \
\r
669 " jne %d1, 1, _task2_error_loop \n" \
\r
670 " eq %d1, %d1, 1 \n" \
\r
671 " jne %d1, 1, _task2_error_loop \n" \
\r
672 " eq %d1, %d2, 5 \n" \
\r
673 " jne %d1, 1, _task2_error_loop \n" \
\r
674 " eq %d1, %d3, 4 \n" \
\r
675 " jne %d1, 1, _task2_error_loop \n" \
\r
676 " eq %d1, %d4, 3 \n" \
\r
677 " jne %d1, 1, _task2_error_loop \n" \
\r
678 " eq %d1, %d5, 2 \n" \
\r
679 " jne %d1, 1, _task2_error_loop \n" \
\r
680 " eq %d1, %d6, 1 \n" \
\r
681 " jne %d1, 1, _task2_error_loop \n" \
\r
682 " eq %d1, %d7, 0 \n" \
\r
683 " jne %d1, 1, _task2_error_loop \n" \
\r
684 " eq %d1, %d8, 15 \n" \
\r
685 " jne %d1, 1, _task2_error_loop \n" \
\r
686 " eq %d1, %d9, 14 \n" \
\r
687 " jne %d1, 1, _task2_error_loop \n" \
\r
688 " eq %d1, %d10, 13 \n" \
\r
689 " jne %d1, 1, _task2_error_loop \n" \
\r
690 " eq %d1, %d11, 12 \n" \
\r
691 " jne %d1, 1, _task2_error_loop \n" \
\r
692 " eq %d1, %d12, 11 \n" \
\r
693 " jne %d1, 1, _task2_error_loop \n" \
\r
694 " eq %d1, %d13, 10 \n" \
\r
695 " jne %d1, 1, _task2_error_loop \n" \
\r
696 " eq %d1, %d14, 9 \n" \
\r
697 " jne %d1, 1, _task2_error_loop \n" \
\r
698 " eq %d1, %d15, 8 \n" \
\r
699 " jne %d1, 1, _task2_error_loop \n" \
\r
700 " mov.a %a15, 14 \n" \
\r
701 " jne.a %a15, %a2, _task2_error_loop \n" \
\r
702 " mov.a %a15, 13 \n" \
\r
703 " jne.a %a15, %a3, _task2_error_loop \n" \
\r
704 " mov.a %a15, 12 \n" \
\r
705 " jne.a %a15, %a4, _task2_error_loop \n" \
\r
706 " mov.a %a15, 7 \n" \
\r
707 " jne.a %a15, %a5, _task2_error_loop \n" \
\r
708 " mov.a %a15, 6 \n" \
\r
709 " jne.a %a15, %a6, _task2_error_loop \n" \
\r
710 " mov.a %a15, 5 \n" \
\r
711 " jne.a %a15, %a7, _task2_error_loop \n" \
\r
712 " mov.a %a15, 4 \n" \
\r
713 " jne.a %a15, %a12, _task2_error_loop \n" \
\r
714 " mov.a %a15, 3 \n" \
\r
715 " jne.a %a15, %a13, _task2_error_loop \n" \
\r
716 " mov.a %a15, 2 \n" \
\r
717 " jne.a %a15, %a14, _task2_error_loop \n" \
\r
718 " j _task2_skip_error_loop \n" \
\r
719 "_task2_error_loop: \n" /* Hitting this error loop will stop the counter incrementing, allowing the check task to recognise an error. */ \
\r
721 " j _task2_error_loop \n" \
\r
722 "_task2_skip_error_loop: \n" );
\r
724 /* Load the parameter address from the stack and modify the value. */
\r
725 __asm volatile( " ld.w %d1, [%sp]4 \n" \
\r
726 " add %d1, %d1, 1 \n" \
\r
727 " st.w [%sp]4, %d1 \n" \
\r
728 " ld.a %a15, [%sp] \n" \
\r
729 " st.w [%a15], %d1 \n" \
\r
730 " j _task2_loop \n" );
\r
732 /* The parameter is used but in the assembly. */
\r
733 (void)pvParameters;
\r
736 /*-----------------------------------------------------------*/
\r