2 FreeRTOS V7.0.2 - Copyright (C) 2011 Real Time Engineers Ltd.
\r
5 ***************************************************************************
\r
7 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
8 * Complete, revised, and edited pdf reference manuals are also *
\r
11 * Purchasing FreeRTOS documentation will not only help you, by *
\r
12 * ensuring you get running as quickly as possible and with an *
\r
13 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
14 * the FreeRTOS project to continue with its mission of providing *
\r
15 * professional grade, cross platform, de facto standard solutions *
\r
16 * for microcontrollers - completely free of charge! *
\r
18 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
20 * Thank you for using FreeRTOS, and thank you for your support! *
\r
22 ***************************************************************************
\r
25 This file is part of the FreeRTOS distribution.
\r
27 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
28 the terms of the GNU General Public License (version 2) as published by the
\r
29 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
30 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
31 distribute a combined work that includes FreeRTOS without being obliged to
\r
32 provide the source code for proprietary components outside of the FreeRTOS
\r
33 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
34 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
35 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
36 more details. You should have received a copy of the GNU General Public
\r
37 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
38 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
39 by writing to Richard Barry, contact details for whom are available on the
\r
44 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
47 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
50 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
51 licensing and training services.
\r
54 /******************************************************************************
\r
55 * >>>>>> NOTE: <<<<<<
\r
57 * main() can be configured to create either a very simple LED flasher demo, or
\r
58 * a more comprehensive test/demo application.
\r
60 * To create a very simple LED flasher example, set the
\r
61 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant (defined below) to 1. When
\r
62 * this is done, only the standard demo flash tasks are created. The standard
\r
63 * demo flash example creates three tasks, each toggle an LED at a fixed but
\r
64 * different frequency.
\r
66 * To create a more comprehensive test and demo application, set
\r
67 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0.
\r
69 * Two build configurations are provided, one that executes from RAM and one
\r
70 * that executes from Flash. The RAM build uses size optimisation, the Flash
\r
71 * build has optimisation completely turned off. The documentation page for
\r
72 * this port on the FreeRTOS.org web site provides full information.
\r
73 ******************************************************************************
\r
75 * main() creates all the demo application tasks and timers, then starts the
\r
76 * scheduler. The web documentation provides more details of the standard demo
\r
77 * application tasks, which provide no particular functionality, but do provide
\r
78 * a good example of how to use the FreeRTOS API.
\r
80 * In addition to the standard demo tasks, the following tasks and tests are
\r
81 * defined and/or created within this file:
\r
83 * "Reg test" tasks - These fill the registers with known values, then check
\r
84 * that each register maintains its expected value for the lifetime of the
\r
85 * task. Each task uses a different set of values. The reg test tasks execute
\r
86 * with a very low priority, so get preempted very frequently. A register
\r
87 * containing an unexpected value is indicative of an error in the context
\r
88 * switching mechanism.
\r
90 * "Check" task - The check task period is initially set to five seconds.
\r
91 * Each time it executes, the check task checks that all the standard demo
\r
92 * tasks, and the register check tasks, are not only still executing, but are
\r
93 * executing without reporting any errors. If the check task discovers that a
\r
94 * task has either stalled, or reported an error, then it changes its own
\r
95 * execution period from the initial five seconds, to just 500ms. The check
\r
96 * task also toggles an LED each time it is called. This provides a visual
\r
97 * indication of the system status: If the LED toggles every five seconds,
\r
98 * then no issues have been discovered. If the LED toggles every 500ms, then
\r
99 * an issue has been discovered with at least one task.
\r
101 * ***NOTE*** This demo uses the standard comtest tasks, which has special
\r
102 * hardware requirements as a loopback connector, or UART echo server are
\r
103 * required. See the documentation page for this demo on the FreeRTOS.org web
\r
104 * site for more information. Note that the comtest tasks were tested by
\r
105 * placing the UART into loopback mode directly in the serial initialisation
\r
106 * sequence, and as such, the baud rate used has not been verified as actually
\r
110 /* Standard includes. */
\r
111 #include <stdlib.h>
\r
112 #include <string.h>
\r
114 /* Scheduler includes. */
\r
115 #include "FreeRTOS.h"
\r
117 #include "croutine.h"
\r
119 /* Demo application includes. */
\r
120 #include "partest.h"
\r
122 #include "integer.h"
\r
124 #include "comtest2.h"
\r
125 #include "semtest.h"
\r
126 #include "dynamic.h"
\r
127 #include "BlockQ.h"
\r
128 #include "blocktim.h"
\r
129 #include "countsem.h"
\r
130 #include "GenQTest.h"
\r
131 #include "recmutex.h"
\r
132 #include "serial.h"
\r
134 #include "TimerDemo.h"
\r
135 #include "InterruptNestTest.h"
\r
137 /*-----------------------------------------------------------*/
\r
139 /* Constants for the ComTest tasks. */
\r
140 #define mainCOM_TEST_BAUD_RATE ( ( unsigned long ) 200000 )
\r
142 #define mainCOM_TEST_LED ( 5 )
\r
144 /* Priorities for the demo application tasks. */
\r
145 #define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
146 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
147 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
148 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
149 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
150 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
151 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
153 /* The rate at which the on board LED will toggle when there is/is not an
\r
155 #define mainNO_ERROR_FLASH_PERIOD_MS ( ( portTickType ) 5000 / portTICK_RATE_MS )
\r
156 #define mainERROR_FLASH_PERIOD_MS ( ( portTickType ) 500 / portTICK_RATE_MS )
\r
157 #define mainON_BOARD_LED_BIT ( ( unsigned long ) 7 )
\r
159 /* Constant used by the standard timer test functions. The timers created by
\r
160 the timer test functions will all have a period that is a multiple of this
\r
162 #define mainTIMER_TEST_PERIOD ( 200 )
\r
164 /* Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 1 to create a simple demo.
\r
165 Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0 to create a much more
\r
166 comprehensive test application. See the comments at the top of this file, and
\r
167 the documentation page on the http://www.FreeRTOS.org web site for more
\r
169 #define mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY 0
\r
171 /*-----------------------------------------------------------*/
\r
174 * Checks that all the demo application tasks are still executing without error
\r
175 * - as described at the top of the file.
\r
177 static long prvCheckOtherTasksAreStillRunning( void );
\r
180 * The task that executes at the highest priority and calls
\r
181 * prvCheckOtherTasksAreStillRunning(). See the description at the top
\r
184 static void prvCheckTask( void *pvParameters );
\r
187 * Configure the processor ready to run this demo.
\r
189 static void prvSetupHardware( void );
\r
192 * Writes to and checks the value of each register that is used in the context
\r
193 * of a task. See the comments at the top of this file.
\r
195 static void prvRegisterCheckTask1( void *pvParameters );
\r
196 static void prvRegisterCheckTask2( void *pvParameters );
\r
199 * Specific check to see if the register test functions are still operating
\r
202 static portBASE_TYPE prvAreRegTestTasksStillRunning( void );
\r
205 * This file can be used to create either a simple LED flasher example, or a
\r
206 * comprehensive test/demo application - depending on the setting of the
\r
207 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant defined above. If
\r
208 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 1, then the following
\r
209 * function will create a lot of additional tasks and timers. If
\r
210 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 0, then the following
\r
211 * function will do nothing.
\r
213 static void prvOptionallyCreateComprehensveTestApplication( void );
\r
215 /*-----------------------------------------------------------*/
\r
217 /* Used by the register test tasks to indicated liveness. */
\r
218 static unsigned long ulRegisterTest1Count = 0;
\r
219 static unsigned long ulRegisterTest2Count = 0;
\r
221 /*-----------------------------------------------------------*/
\r
224 * Starts all the tasks, then starts the scheduler.
\r
228 /* Setup the hardware for use with the TriCore evaluation board. */
\r
229 prvSetupHardware();
\r
231 /* Start standard demo/test application flash tasks. See the comments at
\r
232 the top of this file. The LED flash tasks are always created. The other
\r
233 tasks are only created if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to
\r
234 1 (at the top of this file). See the comments at the top of this file for
\r
235 more information. */
\r
236 vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
\r
238 /* The following function will only create more tasks and timers if
\r
239 mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 1 (at the top of this
\r
240 file). See the comments at the top of this file for more information. */
\r
241 prvOptionallyCreateComprehensveTestApplication();
\r
243 /* Now all the tasks have been started - start the scheduler. */
\r
244 vTaskStartScheduler();
\r
246 /* If all is well then the following line will never be reached. If
\r
247 execution does reach here, then it is highly probably that the heap size
\r
248 is too small for the idle and/or timer tasks to be created within
\r
249 vTaskStartScheduler(). */
\r
252 /*-----------------------------------------------------------*/
\r
254 static void prvCheckTask( void *pvParameters )
\r
256 portTickType xDelayPeriod = mainNO_ERROR_FLASH_PERIOD_MS;
\r
257 portTickType xLastExecutionTime;
\r
259 /* Just to stop compiler warnings. */
\r
260 ( void ) pvParameters;
\r
262 /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
\r
263 works correctly. */
\r
264 xLastExecutionTime = xTaskGetTickCount();
\r
266 /* Cycle for ever, delaying then checking all the other tasks are still
\r
267 operating without error. If an error is detected then the delay period
\r
268 is decreased from mainNO_ERROR_FLASH_PERIOD_MS to mainERROR_FLASH_PERIOD_MS so
\r
269 the on board LED flash rate will increase. NOTE: This task could easily
\r
270 be replaced by a software timer callback to remove the overhead of having
\r
275 /* Delay until it is time to execute again. */
\r
276 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );
\r
278 /* Check all the standard demo application tasks are executing without
\r
280 if( prvCheckOtherTasksAreStillRunning() != pdPASS )
\r
282 /* An error has been detected in one of the tasks - flash the LED
\r
283 at a higher frequency to give visible feedback that something has
\r
284 gone wrong (it might just be that the loop back connector required
\r
285 by the comtest tasks has not been fitted). */
\r
286 xDelayPeriod = mainERROR_FLASH_PERIOD_MS;
\r
289 /* The toggle rate of the LED depends on how long this task delays for.
\r
290 An error reduces the delay period and so increases the toggle rate. */
\r
291 vParTestToggleLED( mainON_BOARD_LED_BIT );
\r
294 /*-----------------------------------------------------------*/
\r
296 static long prvCheckOtherTasksAreStillRunning( void )
\r
298 long lReturn = pdPASS;
\r
299 unsigned long ulHighFrequencyTimerTaskIterations, ulExpectedIncFrequency_ms;
\r
301 /* Check all the demo tasks (other than the flash tasks) to ensure
\r
302 that they are all still running, and that none have detected an error. */
\r
304 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
309 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
314 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
319 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
324 if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
329 if ( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
334 if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
339 if( prvAreRegTestTasksStillRunning() != pdTRUE )
\r
344 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
349 if( xAreTimerDemoTasksStillRunning( mainNO_ERROR_FLASH_PERIOD_MS ) != pdTRUE )
\r
354 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
359 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
364 /* Obtain the number of times the task associated with the high frequency
\r
365 (interrupt nesting) timer test has increment since the check task last
\r
366 executed, and the frequency at which it is expected to execute in ms. */
\r
367 ulHighFrequencyTimerTaskIterations = ulInterruptNestingTestGetIterationCount( &ulExpectedIncFrequency_ms );
\r
368 if( ulHighFrequencyTimerTaskIterations < ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) - 1 ) )
\r
370 /* Would have expected the high frequency timer task to have
\r
371 incremented its execution count more times that reported. */
\r
377 /*-----------------------------------------------------------*/
\r
379 static void prvSetupHardware( void )
\r
381 extern void set_cpu_frequency(void);
\r
383 /* Set-up the PLL. */
\r
384 set_cpu_frequency();
\r
386 /* Initialise LED outputs. */
\r
387 vParTestInitialise();
\r
389 /*-----------------------------------------------------------*/
\r
391 void vApplicationMallocFailedHook( void )
\r
393 /* vApplicationMallocFailedHook() will only be called if
\r
394 configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
\r
395 function that will get called if a call to pvPortMalloc() fails.
\r
396 pvPortMalloc() is called internally by the kernel whenever a task, queue,
\r
397 timer or semaphore is created. It is also called by various parts of the
\r
398 demo application. If heap_1.c or heap_2.c are used, then the size of the
\r
399 heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
\r
400 FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
\r
401 to query the size of free heap space that remains (although it does not
\r
402 provide information on how the remaining heap might be fragmented). */
\r
403 taskDISABLE_INTERRUPTS();
\r
406 /*-----------------------------------------------------------*/
\r
408 void vApplicationTickHook( void )
\r
410 #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY != 1
\r
412 /* vApplicationTickHook() will only be called if configUSE_TICK_HOOK is set
\r
413 to 1 in FreeRTOSConfig.h. It is a hook function that will get called during
\r
414 each FreeRTOS tick interrupt. Note that vApplicationTickHook() is called
\r
415 from an interrupt context. */
\r
417 /* Call the periodic timer test, which tests the timer API functions that
\r
418 can be called from an ISR. */
\r
419 vTimerPeriodicISRTests();
\r
421 #endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
423 /*-----------------------------------------------------------*/
\r
425 void vApplicationIdleHook( void )
\r
427 /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
\r
428 to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle
\r
429 task. It is essential that code added to this hook function never attempts
\r
430 to block in any way (for example, call xQueueReceive() with a block time
\r
431 specified, or call vTaskDelay()). If the application makes use of the
\r
432 vTaskDelete() API function (as this demo application does) then it is also
\r
433 important that vApplicationIdleHook() is permitted to return to its calling
\r
434 function, because it is the responsibility of the idle task to clean up
\r
435 memory allocated by the kernel to any task that has since been deleted. */
\r
437 /*-----------------------------------------------------------*/
\r
439 static portBASE_TYPE prvAreRegTestTasksStillRunning( void )
\r
441 static unsigned long ulPreviousRegisterTest1Count = 0;
\r
442 static unsigned long ulPreviousRegisterTest2Count = 0;
\r
443 portBASE_TYPE xReturn = pdPASS;
\r
445 /* Check to see if the Counts have changed since the last check. */
\r
446 if( ulRegisterTest1Count == ulPreviousRegisterTest1Count )
\r
451 if( ulRegisterTest2Count == ulPreviousRegisterTest2Count )
\r
456 /* Remember the current count for the next time this function is called. */
\r
457 ulPreviousRegisterTest1Count = ulRegisterTest1Count;
\r
458 ulPreviousRegisterTest2Count = ulRegisterTest2Count;
\r
462 /*-----------------------------------------------------------*/
\r
464 static void prvOptionallyCreateComprehensveTestApplication( void )
\r
466 #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY == 0
\r
468 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
469 vStartDynamicPriorityTasks();
\r
470 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
471 vCreateBlockTimeTasks();
\r
472 vStartCountingSemaphoreTasks();
\r
473 vStartGenericQueueTasks( tskIDLE_PRIORITY );
\r
474 vStartRecursiveMutexTasks();
\r
475 vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
\r
476 vSetupInterruptNestingTest();
\r
477 vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
\r
478 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
479 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
481 /* Create the register test tasks, as described at the top of this file. */
\r
482 xTaskCreate( prvRegisterCheckTask1, ( signed char * ) "Reg 1", configMINIMAL_STACK_SIZE, &ulRegisterTest1Count, tskIDLE_PRIORITY, NULL );
\r
483 xTaskCreate( prvRegisterCheckTask2, ( signed char * ) "Reg 2", configMINIMAL_STACK_SIZE, &ulRegisterTest2Count, tskIDLE_PRIORITY, NULL );
\r
485 /* Start the check task - which is defined in this file. */
\r
486 xTaskCreate( prvCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
488 /* This task has to be created last as it keeps account of the number of tasks
\r
489 it expects to see running. */
\r
490 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
492 #else /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
494 /* Just to prevent compiler warnings when the configuration options are
\r
495 set such that these static functions are not used. */
\r
496 ( void ) prvCheckTask;
\r
497 ( void ) prvRegisterCheckTask1;
\r
498 ( void ) prvRegisterCheckTask2;
\r
500 #endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
502 /*-----------------------------------------------------------*/
\r
504 static void prvRegisterCheckTask1( void *pvParameters )
\r
506 /* Make space on the stack for the parameter and a counter. */
\r
507 __asm volatile( " sub.a %sp, 4 \n"
\r
508 " st.a [%sp], %a4 \n"
\r
510 " st.w [%sp]4, %d15 \n" );
\r
512 /* Change all of the Context sensitive registers (except SP and RA). */
\r
536 " mov.a %a12, 12 \n"
\r
537 " mov.a %a13, 13 \n"
\r
538 " mov.a %a14, 14 \n" );
\r
540 /* Check the values of the registers. */
\r
541 __asm( " _task1_loop: \n" \
\r
542 " eq %d1, %d0, 0 \n" \
\r
543 " jne %d1, 1, _task1_error_loop \n" \
\r
544 " eq %d1, %d1, 1 \n" \
\r
545 " jne %d1, 1, _task1_error_loop \n" \
\r
546 " eq %d1, %d2, 2 \n" \
\r
547 " jne %d1, 1, _task1_error_loop \n" \
\r
548 " eq %d1, %d3, 3 \n" \
\r
549 " jne %d1, 1, _task1_error_loop \n" \
\r
550 " eq %d1, %d4, 4 \n" \
\r
551 " jne %d1, 1, _task1_error_loop \n" \
\r
552 " eq %d1, %d5, 5 \n" \
\r
553 " jne %d1, 1, _task1_error_loop \n" \
\r
554 " eq %d1, %d6, 6 \n" \
\r
555 " jne %d1, 1, _task1_error_loop \n" \
\r
556 " eq %d1, %d7, 7 \n" \
\r
557 " jne %d1, 1, _task1_error_loop \n" \
\r
558 " eq %d1, %d8, 8 \n" \
\r
559 " jne %d1, 1, _task1_error_loop \n" \
\r
560 " eq %d1, %d9, 9 \n" \
\r
561 " jne %d1, 1, _task1_error_loop \n" \
\r
562 " eq %d1, %d10, 10 \n" \
\r
563 " jne %d1, 1, _task1_error_loop \n" \
\r
564 " eq %d1, %d11, 11 \n" \
\r
565 " jne %d1, 1, _task1_error_loop \n" \
\r
566 " eq %d1, %d12, 12 \n" \
\r
567 " jne %d1, 1, _task1_error_loop \n" \
\r
568 " eq %d1, %d13, 13 \n" \
\r
569 " jne %d1, 1, _task1_error_loop \n" \
\r
570 " eq %d1, %d14, 14 \n" \
\r
571 " jne %d1, 1, _task1_error_loop \n" \
\r
572 " eq %d1, %d15, 15 \n" \
\r
573 " jne %d1, 1, _task1_error_loop \n" \
\r
574 " mov.a %a15, 2 \n" \
\r
575 " jne.a %a15, %a2, _task1_error_loop \n" \
\r
576 " mov.a %a15, 3 \n" \
\r
577 " jne.a %a15, %a3, _task1_error_loop \n" \
\r
578 " mov.a %a15, 4 \n" \
\r
579 " jne.a %a15, %a4, _task1_error_loop \n" \
\r
580 " mov.a %a15, 5 \n" \
\r
581 " jne.a %a15, %a5, _task1_error_loop \n" \
\r
582 " mov.a %a15, 6 \n" \
\r
583 " jne.a %a15, %a6, _task1_error_loop \n" \
\r
584 " mov.a %a15, 7 \n" \
\r
585 " jne.a %a15, %a7, _task1_error_loop \n" \
\r
586 " mov.a %a15, 12 \n" \
\r
587 " jne.a %a15, %a12, _task1_error_loop \n" \
\r
588 " mov.a %a15, 13 \n" \
\r
589 " jne.a %a15, %a13, _task1_error_loop \n" \
\r
590 " mov.a %a15, 14 \n" \
\r
591 " jne.a %a15, %a14, _task1_error_loop \n" \
\r
592 " j _task1_skip_error_loop \n" \
\r
593 "_task1_error_loop: \n" /* Hitting this error loop will stop the counter incrementing, allowing the check task to recognise an error. */ \
\r
595 " j _task1_error_loop \n" \
\r
596 "_task1_skip_error_loop: \n" );
\r
598 /* Load the parameter address from the stack and modify the value. */
\r
600 " ld.w %d1, [%sp]4 \n" \
\r
602 " st.w [%sp]4, %d1 \n" \
\r
603 " ld.a %a15, [%sp] \n" \
\r
604 " st.w [%a15], %d1 \n" \
\r
605 " j _task1_loop \n" );
\r
607 /* The parameter is used but in the assembly. */
\r
608 (void)pvParameters;
\r
610 /*-----------------------------------------------------------*/
\r
612 static void prvRegisterCheckTask2( void *pvParameters )
\r
614 /* Make space on the stack for the parameter and a counter. */
\r
615 __asm volatile( " sub.a %sp, 4 \n" \
\r
616 " st.a [%sp], %a4 \n" \
\r
617 " mov %d15, 0 \n" \
\r
618 " st.w [%sp]4, %d15 \n" );
\r
620 /* Change all of the Context sensitive registers (except SP and RA). */
\r
621 __asm volatile( " mov %d0, 7 \n" \
\r
629 " mov %d8, 15 \n" \
\r
630 " mov %d9, 14 \n" \
\r
631 " mov %d10, 13 \n" \
\r
632 " mov %d11, 12 \n" \
\r
633 " mov %d12, 11 \n" \
\r
634 " mov %d13, 10 \n" \
\r
635 " mov %d14, 9 \n" \
\r
636 " mov %d15, 8 \n" \
\r
637 " mov.a %a2, 14 \n" \
\r
638 " mov.a %a3, 13 \n" \
\r
639 " mov.a %a4, 12 \n" \
\r
640 " mov.a %a5, 7 \n" \
\r
641 " mov.a %a6, 6 \n" \
\r
642 " mov.a %a7, 5 \n" \
\r
643 " mov.a %a12, 4 \n" \
\r
644 " mov.a %a13, 3 \n" \
\r
645 " mov.a %a14, 2 \n" );
\r
647 /* Check the values of the registers. */
\r
648 __asm volatile( " _task2_loop: \n" \
\r
650 " eq %d1, %d0, 7 \n" \
\r
651 " jne %d1, 1, _task2_error_loop \n" \
\r
652 " eq %d1, %d1, 1 \n" \
\r
653 " jne %d1, 1, _task2_error_loop \n" \
\r
654 " eq %d1, %d2, 5 \n" \
\r
655 " jne %d1, 1, _task2_error_loop \n" \
\r
656 " eq %d1, %d3, 4 \n" \
\r
657 " jne %d1, 1, _task2_error_loop \n" \
\r
658 " eq %d1, %d4, 3 \n" \
\r
659 " jne %d1, 1, _task2_error_loop \n" \
\r
660 " eq %d1, %d5, 2 \n" \
\r
661 " jne %d1, 1, _task2_error_loop \n" \
\r
662 " eq %d1, %d6, 1 \n" \
\r
663 " jne %d1, 1, _task2_error_loop \n" \
\r
664 " eq %d1, %d7, 0 \n" \
\r
665 " jne %d1, 1, _task2_error_loop \n" \
\r
666 " eq %d1, %d8, 15 \n" \
\r
667 " jne %d1, 1, _task2_error_loop \n" \
\r
668 " eq %d1, %d9, 14 \n" \
\r
669 " jne %d1, 1, _task2_error_loop \n" \
\r
670 " eq %d1, %d10, 13 \n" \
\r
671 " jne %d1, 1, _task2_error_loop \n" \
\r
672 " eq %d1, %d11, 12 \n" \
\r
673 " jne %d1, 1, _task2_error_loop \n" \
\r
674 " eq %d1, %d12, 11 \n" \
\r
675 " jne %d1, 1, _task2_error_loop \n" \
\r
676 " eq %d1, %d13, 10 \n" \
\r
677 " jne %d1, 1, _task2_error_loop \n" \
\r
678 " eq %d1, %d14, 9 \n" \
\r
679 " jne %d1, 1, _task2_error_loop \n" \
\r
680 " eq %d1, %d15, 8 \n" \
\r
681 " jne %d1, 1, _task2_error_loop \n" \
\r
682 " mov.a %a15, 14 \n" \
\r
683 " jne.a %a15, %a2, _task2_error_loop \n" \
\r
684 " mov.a %a15, 13 \n" \
\r
685 " jne.a %a15, %a3, _task2_error_loop \n" \
\r
686 " mov.a %a15, 12 \n" \
\r
687 " jne.a %a15, %a4, _task2_error_loop \n" \
\r
688 " mov.a %a15, 7 \n" \
\r
689 " jne.a %a15, %a5, _task2_error_loop \n" \
\r
690 " mov.a %a15, 6 \n" \
\r
691 " jne.a %a15, %a6, _task2_error_loop \n" \
\r
692 " mov.a %a15, 5 \n" \
\r
693 " jne.a %a15, %a7, _task2_error_loop \n" \
\r
694 " mov.a %a15, 4 \n" \
\r
695 " jne.a %a15, %a12, _task2_error_loop \n" \
\r
696 " mov.a %a15, 3 \n" \
\r
697 " jne.a %a15, %a13, _task2_error_loop \n" \
\r
698 " mov.a %a15, 2 \n" \
\r
699 " jne.a %a15, %a14, _task2_error_loop \n" \
\r
700 " j _task2_skip_error_loop \n" \
\r
701 "_task2_error_loop: \n" /* Hitting this error loop will stop the counter incrementing, allowing the check task to recognise an error. */ \
\r
703 " j _task2_error_loop \n" \
\r
704 "_task2_skip_error_loop: \n" );
\r
706 /* Load the parameter address from the stack and modify the value. */
\r
707 __asm volatile( " ld.w %d1, [%sp]4 \n" \
\r
708 " add %d1, %d1, 1 \n" \
\r
709 " st.w [%sp]4, %d1 \n" \
\r
710 " ld.a %a15, [%sp] \n" \
\r
711 " st.w [%a15], %d1 \n" \
\r
712 " j _task2_loop \n" );
\r
714 /* The parameter is used but in the assembly. */
\r
715 (void)pvParameters;
\r
718 /*-----------------------------------------------------------*/
\r