2 FreeRTOS V8.0.0:rc1 - Copyright (C) 2014 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\r
9 * FreeRTOS provides completely free yet professionally developed, *
\r
10 * robust, strictly quality controlled, supported, and cross *
\r
11 * platform software that has become a de facto standard. *
\r
13 * Help yourself get started quickly and support the FreeRTOS *
\r
14 * project by purchasing a FreeRTOS tutorial book, reference *
\r
15 * manual, or both from: http://www.FreeRTOS.org/Documentation *
\r
19 ***************************************************************************
\r
21 This file is part of the FreeRTOS distribution.
\r
23 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
24 the terms of the GNU General Public License (version 2) as published by the
\r
25 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
27 >>! NOTE: The modification to the GPL is included to allow you to distribute
\r
28 >>! a combined work that includes FreeRTOS without being obliged to provide
\r
29 >>! the source code for proprietary components outside of the FreeRTOS
\r
32 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
33 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
34 FOR A PARTICULAR PURPOSE. Full license text is available from the following
\r
35 link: http://www.freertos.org/a00114.html
\r
39 ***************************************************************************
\r
41 * Having a problem? Start by reading the FAQ "My application does *
\r
42 * not run, what could be wrong?" *
\r
44 * http://www.FreeRTOS.org/FAQHelp.html *
\r
46 ***************************************************************************
\r
48 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
49 license and Real Time Engineers Ltd. contact details.
\r
51 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
52 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
53 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
55 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
56 Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
57 licenses offer ticketed support, indemnification and middleware.
\r
59 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
60 engineered and independently SIL3 certified version for use in safety and
\r
61 mission critical applications that require provable dependability.
\r
66 /******************************************************************************
\r
67 * >>>>>> NOTE: <<<<<<
\r
69 * main() can be configured to create either a very simple LED flasher demo, or
\r
70 * a more comprehensive test/demo application.
\r
72 * To create a very simple LED flasher example, set the
\r
73 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant (defined below) to 1. When
\r
74 * this is done, only the standard demo flash tasks are created. The standard
\r
75 * demo flash example creates three tasks, each toggle an LED at a fixed but
\r
76 * different frequency.
\r
78 * To create a more comprehensive test and demo application, set
\r
79 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0.
\r
81 * Two build configurations are provided, one that executes from RAM and one
\r
82 * that executes from Flash. The RAM build uses size optimisation, the Flash
\r
83 * build has optimisation completely turned off. The documentation page for
\r
84 * this port on the FreeRTOS.org web site provides full information.
\r
85 ******************************************************************************
\r
87 * main() creates all the demo application tasks and timers, then starts the
\r
88 * scheduler. The web documentation provides more details of the standard demo
\r
89 * application tasks, which provide no particular functionality, but do provide
\r
90 * a good example of how to use the FreeRTOS API.
\r
92 * In addition to the standard demo tasks, the following tasks and tests are
\r
93 * defined and/or created within this file:
\r
95 * "Reg test" tasks - These fill the registers with known values, then check
\r
96 * that each register maintains its expected value for the lifetime of the
\r
97 * task. Each task uses a different set of values. The reg test tasks execute
\r
98 * with a very low priority, so get preempted very frequently. A register
\r
99 * containing an unexpected value is indicative of an error in the context
\r
100 * switching mechanism.
\r
102 * "Check" task - The check task period is initially set to five seconds.
\r
103 * Each time it executes, the check task checks that all the standard demo
\r
104 * tasks, and the register check tasks, are not only still executing, but are
\r
105 * executing without reporting any errors. If the check task discovers that a
\r
106 * task has either stalled, or reported an error, then it changes its own
\r
107 * execution period from the initial five seconds, to just 500ms. The check
\r
108 * task also toggles an LED each time it is called. This provides a visual
\r
109 * indication of the system status: If the LED toggles every five seconds,
\r
110 * then no issues have been discovered. If the LED toggles every 500ms, then
\r
111 * an issue has been discovered with at least one task.
\r
113 * ***NOTE*** This demo uses the standard comtest tasks, which has special
\r
114 * hardware requirements as a loopback connector, or UART echo server are
\r
115 * required. See the documentation page for this demo on the FreeRTOS.org web
\r
116 * site for more information. Note that the comtest tasks were tested by
\r
117 * placing the UART into loopback mode directly in the serial initialisation
\r
118 * sequence, and as such, the baud rate used has not been verified as actually
\r
122 /* Standard includes. */
\r
123 #include <stdlib.h>
\r
124 #include <string.h>
\r
126 /* Scheduler includes. */
\r
127 #include "FreeRTOS.h"
\r
129 #include "croutine.h"
\r
131 /* Demo application includes. */
\r
132 #include "partest.h"
\r
134 #include "integer.h"
\r
136 #include "comtest2.h"
\r
137 #include "semtest.h"
\r
138 #include "dynamic.h"
\r
139 #include "BlockQ.h"
\r
140 #include "blocktim.h"
\r
141 #include "countsem.h"
\r
142 #include "GenQTest.h"
\r
143 #include "recmutex.h"
\r
144 #include "serial.h"
\r
146 #include "TimerDemo.h"
\r
147 #include "InterruptNestTest.h"
\r
149 /*-----------------------------------------------------------*/
\r
151 /* Constants for the ComTest tasks. */
\r
152 #define mainCOM_TEST_BAUD_RATE ( ( unsigned long ) 200000 )
\r
154 #define mainCOM_TEST_LED ( 5 )
\r
156 /* Priorities for the demo application tasks. */
\r
157 #define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
158 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
159 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
160 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
161 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
162 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
163 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
165 /* The rate at which the on board LED will toggle when there is/is not an
\r
167 #define mainNO_ERROR_FLASH_PERIOD_MS ( ( TickType_t ) 5000 / portTICK_PERIOD_MS )
\r
168 #define mainERROR_FLASH_PERIOD_MS ( ( TickType_t ) 500 / portTICK_PERIOD_MS )
\r
169 #define mainON_BOARD_LED_BIT ( ( unsigned long ) 7 )
\r
171 /* Constant used by the standard timer test functions. The timers created by
\r
172 the timer test functions will all have a period that is a multiple of this
\r
174 #define mainTIMER_TEST_PERIOD ( 200 )
\r
176 /* Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 1 to create a simple demo.
\r
177 Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0 to create a much more
\r
178 comprehensive test application. See the comments at the top of this file, and
\r
179 the documentation page on the http://www.FreeRTOS.org web site for more
\r
181 #define mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY 0
\r
183 /*-----------------------------------------------------------*/
\r
186 * Checks that all the demo application tasks are still executing without error
\r
187 * - as described at the top of the file.
\r
189 static long prvCheckOtherTasksAreStillRunning( void );
\r
192 * The task that executes at the highest priority and calls
\r
193 * prvCheckOtherTasksAreStillRunning(). See the description at the top
\r
196 static void prvCheckTask( void *pvParameters );
\r
199 * Configure the processor ready to run this demo.
\r
201 static void prvSetupHardware( void );
\r
204 * Writes to and checks the value of each register that is used in the context
\r
205 * of a task. See the comments at the top of this file.
\r
207 static void prvRegisterCheckTask1( void *pvParameters );
\r
208 static void prvRegisterCheckTask2( void *pvParameters );
\r
211 * Specific check to see if the register test functions are still operating
\r
214 static portBASE_TYPE prvAreRegTestTasksStillRunning( void );
\r
217 * This file can be used to create either a simple LED flasher example, or a
\r
218 * comprehensive test/demo application - depending on the setting of the
\r
219 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant defined above. If
\r
220 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 1, then the following
\r
221 * function will create a lot of additional tasks and timers. If
\r
222 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 0, then the following
\r
223 * function will do nothing.
\r
225 static void prvOptionallyCreateComprehensveTestApplication( void );
\r
227 /*-----------------------------------------------------------*/
\r
229 /* Used by the register test tasks to indicated liveness. */
\r
230 static unsigned long ulRegisterTest1Count = 0;
\r
231 static unsigned long ulRegisterTest2Count = 0;
\r
233 /*-----------------------------------------------------------*/
\r
236 * Starts all the tasks, then starts the scheduler.
\r
240 /* Setup the hardware for use with the TriCore evaluation board. */
\r
241 prvSetupHardware();
\r
243 /* Start standard demo/test application flash tasks. See the comments at
\r
244 the top of this file. The LED flash tasks are always created. The other
\r
245 tasks are only created if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to
\r
246 0 (at the top of this file). See the comments at the top of this file for
\r
247 more information. */
\r
248 vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
\r
250 /* The following function will only create more tasks and timers if
\r
251 mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 0 (at the top of this
\r
252 file). See the comments at the top of this file for more information. */
\r
253 prvOptionallyCreateComprehensveTestApplication();
\r
255 /* Now all the tasks have been started - start the scheduler. */
\r
256 vTaskStartScheduler();
\r
258 /* If all is well then the following line will never be reached. If
\r
259 execution does reach here, then it is highly probably that the heap size
\r
260 is too small for the idle and/or timer tasks to be created within
\r
261 vTaskStartScheduler(). */
\r
264 /*-----------------------------------------------------------*/
\r
266 static void prvCheckTask( void *pvParameters )
\r
268 TickType_t xDelayPeriod = mainNO_ERROR_FLASH_PERIOD_MS;
\r
269 TickType_t xLastExecutionTime;
\r
271 /* Just to stop compiler warnings. */
\r
272 ( void ) pvParameters;
\r
274 /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
\r
275 works correctly. */
\r
276 xLastExecutionTime = xTaskGetTickCount();
\r
278 /* Cycle for ever, delaying then checking all the other tasks are still
\r
279 operating without error. If an error is detected then the delay period
\r
280 is decreased from mainNO_ERROR_FLASH_PERIOD_MS to mainERROR_FLASH_PERIOD_MS so
\r
281 the on board LED flash rate will increase. NOTE: This task could easily
\r
282 be replaced by a software timer callback to remove the overhead of having
\r
287 /* Delay until it is time to execute again. */
\r
288 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );
\r
290 /* Check all the standard demo application tasks are executing without
\r
292 if( prvCheckOtherTasksAreStillRunning() != pdPASS )
\r
294 /* An error has been detected in one of the tasks - flash the LED
\r
295 at a higher frequency to give visible feedback that something has
\r
296 gone wrong (it might just be that the loop back connector required
\r
297 by the comtest tasks has not been fitted). */
\r
298 xDelayPeriod = mainERROR_FLASH_PERIOD_MS;
\r
301 /* The toggle rate of the LED depends on how long this task delays for.
\r
302 An error reduces the delay period and so increases the toggle rate. */
\r
303 vParTestToggleLED( mainON_BOARD_LED_BIT );
\r
306 /*-----------------------------------------------------------*/
\r
308 static long prvCheckOtherTasksAreStillRunning( void )
\r
310 long lReturn = pdPASS;
\r
311 unsigned long ulHighFrequencyTimerTaskIterations, ulExpectedIncFrequency_ms;
\r
313 /* Check all the demo tasks (other than the flash tasks) to ensure
\r
314 that they are all still running, and that none have detected an error. */
\r
316 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
321 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
326 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
331 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
336 if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
341 if ( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
346 if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
351 if( prvAreRegTestTasksStillRunning() != pdTRUE )
\r
356 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
361 if( xAreTimerDemoTasksStillRunning( mainNO_ERROR_FLASH_PERIOD_MS ) != pdTRUE )
\r
366 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
371 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
376 /* Obtain the number of times the task associated with the high frequency
\r
377 (interrupt nesting) timer test has increment since the check task last
\r
378 executed, and the frequency at which it is expected to execute in ms. */
\r
379 ulHighFrequencyTimerTaskIterations = ulInterruptNestingTestGetIterationCount( &ulExpectedIncFrequency_ms );
\r
380 if( ( ulHighFrequencyTimerTaskIterations < ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) - 1 ) )
\r
382 ( ulHighFrequencyTimerTaskIterations > ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) +5 ) )
\r
385 /* Would have expected the high frequency timer task to have
\r
386 incremented its execution count more times that reported. */
\r
392 /*-----------------------------------------------------------*/
\r
394 static void prvSetupHardware( void )
\r
396 extern void set_cpu_frequency(void);
\r
398 /* Set-up the PLL. */
\r
399 set_cpu_frequency();
\r
401 /* Initialise LED outputs. */
\r
402 vParTestInitialise();
\r
404 /*-----------------------------------------------------------*/
\r
406 void vApplicationMallocFailedHook( void )
\r
408 /* vApplicationMallocFailedHook() will only be called if
\r
409 configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
\r
410 function that will get called if a call to pvPortMalloc() fails.
\r
411 pvPortMalloc() is called internally by the kernel whenever a task, queue,
\r
412 timer or semaphore is created. It is also called by various parts of the
\r
413 demo application. If heap_1.c or heap_2.c are used, then the size of the
\r
414 heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
\r
415 FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
\r
416 to query the size of free heap space that remains (although it does not
\r
417 provide information on how the remaining heap might be fragmented). */
\r
418 taskDISABLE_INTERRUPTS();
\r
421 /*-----------------------------------------------------------*/
\r
423 void vApplicationTickHook( void )
\r
425 #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY != 1
\r
427 /* vApplicationTickHook() will only be called if configUSE_TICK_HOOK is set
\r
428 to 1 in FreeRTOSConfig.h. It is a hook function that will get called during
\r
429 each FreeRTOS tick interrupt. Note that vApplicationTickHook() is called
\r
430 from an interrupt context. */
\r
432 /* Call the periodic timer test, which tests the timer API functions that
\r
433 can be called from an ISR. */
\r
434 vTimerPeriodicISRTests();
\r
436 #endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
438 /*-----------------------------------------------------------*/
\r
440 void vApplicationIdleHook( void )
\r
442 /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
\r
443 to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle
\r
444 task. It is essential that code added to this hook function never attempts
\r
445 to block in any way (for example, call xQueueReceive() with a block time
\r
446 specified, or call vTaskDelay()). If the application makes use of the
\r
447 vTaskDelete() API function (as this demo application does) then it is also
\r
448 important that vApplicationIdleHook() is permitted to return to its calling
\r
449 function, because it is the responsibility of the idle task to clean up
\r
450 memory allocated by the kernel to any task that has since been deleted. */
\r
452 /*-----------------------------------------------------------*/
\r
454 static portBASE_TYPE prvAreRegTestTasksStillRunning( void )
\r
456 static unsigned long ulPreviousRegisterTest1Count = 0;
\r
457 static unsigned long ulPreviousRegisterTest2Count = 0;
\r
458 portBASE_TYPE xReturn = pdPASS;
\r
460 /* Check to see if the Counts have changed since the last check. */
\r
461 if( ulRegisterTest1Count == ulPreviousRegisterTest1Count )
\r
466 if( ulRegisterTest2Count == ulPreviousRegisterTest2Count )
\r
471 /* Remember the current count for the next time this function is called. */
\r
472 ulPreviousRegisterTest1Count = ulRegisterTest1Count;
\r
473 ulPreviousRegisterTest2Count = ulRegisterTest2Count;
\r
477 /*-----------------------------------------------------------*/
\r
479 static void prvOptionallyCreateComprehensveTestApplication( void )
\r
481 #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY == 0
\r
483 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
484 vStartDynamicPriorityTasks();
\r
485 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
486 vCreateBlockTimeTasks();
\r
487 vStartCountingSemaphoreTasks();
\r
488 vStartGenericQueueTasks( tskIDLE_PRIORITY );
\r
489 vStartRecursiveMutexTasks();
\r
490 vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
\r
491 vSetupInterruptNestingTest();
\r
492 vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
\r
493 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
494 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
496 /* Create the register test tasks, as described at the top of this file. */
\r
497 xTaskCreate( prvRegisterCheckTask1, "Reg 1", configMINIMAL_STACK_SIZE, &ulRegisterTest1Count, tskIDLE_PRIORITY, NULL );
\r
498 xTaskCreate( prvRegisterCheckTask2, "Reg 2", configMINIMAL_STACK_SIZE, &ulRegisterTest2Count, tskIDLE_PRIORITY, NULL );
\r
500 /* Start the check task - which is defined in this file. */
\r
501 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
503 /* This task has to be created last as it keeps account of the number of tasks
\r
504 it expects to see running. */
\r
505 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
507 #else /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
509 /* Just to prevent compiler warnings when the configuration options are
\r
510 set such that these static functions are not used. */
\r
511 ( void ) prvCheckTask;
\r
512 ( void ) prvRegisterCheckTask1;
\r
513 ( void ) prvRegisterCheckTask2;
\r
515 #endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
517 /*-----------------------------------------------------------*/
\r
519 static void prvRegisterCheckTask1( void *pvParameters )
\r
521 /* Make space on the stack for the parameter and a counter. */
\r
522 __asm volatile( " sub.a %sp, 4 \n"
\r
523 " st.a [%sp], %a4 \n"
\r
525 " st.w [%sp]4, %d15 \n" );
\r
527 /* Change all of the Context sensitive registers (except SP and RA). */
\r
551 " mov.a %a12, 12 \n"
\r
552 " mov.a %a13, 13 \n"
\r
553 " mov.a %a14, 14 \n" );
\r
555 /* Check the values of the registers. */
\r
556 __asm( " _task1_loop: \n" \
\r
557 " eq %d1, %d0, 0 \n" \
\r
558 " jne %d1, 1, _task1_error_loop \n" \
\r
559 " eq %d1, %d1, 1 \n" \
\r
560 " jne %d1, 1, _task1_error_loop \n" \
\r
561 " eq %d1, %d2, 2 \n" \
\r
562 " jne %d1, 1, _task1_error_loop \n" \
\r
563 " eq %d1, %d3, 3 \n" \
\r
564 " jne %d1, 1, _task1_error_loop \n" \
\r
565 " eq %d1, %d4, 4 \n" \
\r
566 " jne %d1, 1, _task1_error_loop \n" \
\r
567 " eq %d1, %d5, 5 \n" \
\r
568 " jne %d1, 1, _task1_error_loop \n" \
\r
569 " eq %d1, %d6, 6 \n" \
\r
570 " jne %d1, 1, _task1_error_loop \n" \
\r
571 " eq %d1, %d7, 7 \n" \
\r
572 " jne %d1, 1, _task1_error_loop \n" \
\r
573 " eq %d1, %d8, 8 \n" \
\r
574 " jne %d1, 1, _task1_error_loop \n" \
\r
575 " eq %d1, %d9, 9 \n" \
\r
576 " jne %d1, 1, _task1_error_loop \n" \
\r
577 " eq %d1, %d10, 10 \n" \
\r
578 " jne %d1, 1, _task1_error_loop \n" \
\r
579 " eq %d1, %d11, 11 \n" \
\r
580 " jne %d1, 1, _task1_error_loop \n" \
\r
581 " eq %d1, %d12, 12 \n" \
\r
582 " jne %d1, 1, _task1_error_loop \n" \
\r
583 " eq %d1, %d13, 13 \n" \
\r
584 " jne %d1, 1, _task1_error_loop \n" \
\r
585 " eq %d1, %d14, 14 \n" \
\r
586 " jne %d1, 1, _task1_error_loop \n" \
\r
587 " eq %d1, %d15, 15 \n" \
\r
588 " jne %d1, 1, _task1_error_loop \n" \
\r
589 " mov.a %a15, 2 \n" \
\r
590 " jne.a %a15, %a2, _task1_error_loop \n" \
\r
591 " mov.a %a15, 3 \n" \
\r
592 " jne.a %a15, %a3, _task1_error_loop \n" \
\r
593 " mov.a %a15, 4 \n" \
\r
594 " jne.a %a15, %a4, _task1_error_loop \n" \
\r
595 " mov.a %a15, 5 \n" \
\r
596 " jne.a %a15, %a5, _task1_error_loop \n" \
\r
597 " mov.a %a15, 6 \n" \
\r
598 " jne.a %a15, %a6, _task1_error_loop \n" \
\r
599 " mov.a %a15, 7 \n" \
\r
600 " jne.a %a15, %a7, _task1_error_loop \n" \
\r
601 " mov.a %a15, 12 \n" \
\r
602 " jne.a %a15, %a12, _task1_error_loop \n" \
\r
603 " mov.a %a15, 13 \n" \
\r
604 " jne.a %a15, %a13, _task1_error_loop \n" \
\r
605 " mov.a %a15, 14 \n" \
\r
606 " jne.a %a15, %a14, _task1_error_loop \n" \
\r
607 " j _task1_skip_error_loop \n" \
\r
608 "_task1_error_loop: \n" /* Hitting this error loop will stop the counter incrementing, allowing the check task to recognise an error. */ \
\r
610 " j _task1_error_loop \n" \
\r
611 "_task1_skip_error_loop: \n" );
\r
613 /* Load the parameter address from the stack and modify the value. */
\r
615 " ld.w %d1, [%sp]4 \n" \
\r
617 " st.w [%sp]4, %d1 \n" \
\r
618 " ld.a %a15, [%sp] \n" \
\r
619 " st.w [%a15], %d1 \n" \
\r
620 " j _task1_loop \n" );
\r
622 /* The parameter is used but in the assembly. */
\r
623 (void)pvParameters;
\r
625 /*-----------------------------------------------------------*/
\r
627 static void prvRegisterCheckTask2( void *pvParameters )
\r
629 /* Make space on the stack for the parameter and a counter. */
\r
630 __asm volatile( " sub.a %sp, 4 \n" \
\r
631 " st.a [%sp], %a4 \n" \
\r
632 " mov %d15, 0 \n" \
\r
633 " st.w [%sp]4, %d15 \n" );
\r
635 /* Change all of the Context sensitive registers (except SP and RA). */
\r
636 __asm volatile( " mov %d0, 7 \n" \
\r
644 " mov %d8, 15 \n" \
\r
645 " mov %d9, 14 \n" \
\r
646 " mov %d10, 13 \n" \
\r
647 " mov %d11, 12 \n" \
\r
648 " mov %d12, 11 \n" \
\r
649 " mov %d13, 10 \n" \
\r
650 " mov %d14, 9 \n" \
\r
651 " mov %d15, 8 \n" \
\r
652 " mov.a %a2, 14 \n" \
\r
653 " mov.a %a3, 13 \n" \
\r
654 " mov.a %a4, 12 \n" \
\r
655 " mov.a %a5, 7 \n" \
\r
656 " mov.a %a6, 6 \n" \
\r
657 " mov.a %a7, 5 \n" \
\r
658 " mov.a %a12, 4 \n" \
\r
659 " mov.a %a13, 3 \n" \
\r
660 " mov.a %a14, 2 \n" );
\r
662 /* Check the values of the registers. */
\r
663 __asm volatile( " _task2_loop: \n" \
\r
665 " eq %d1, %d0, 7 \n" \
\r
666 " jne %d1, 1, _task2_error_loop \n" \
\r
667 " eq %d1, %d1, 1 \n" \
\r
668 " jne %d1, 1, _task2_error_loop \n" \
\r
669 " eq %d1, %d2, 5 \n" \
\r
670 " jne %d1, 1, _task2_error_loop \n" \
\r
671 " eq %d1, %d3, 4 \n" \
\r
672 " jne %d1, 1, _task2_error_loop \n" \
\r
673 " eq %d1, %d4, 3 \n" \
\r
674 " jne %d1, 1, _task2_error_loop \n" \
\r
675 " eq %d1, %d5, 2 \n" \
\r
676 " jne %d1, 1, _task2_error_loop \n" \
\r
677 " eq %d1, %d6, 1 \n" \
\r
678 " jne %d1, 1, _task2_error_loop \n" \
\r
679 " eq %d1, %d7, 0 \n" \
\r
680 " jne %d1, 1, _task2_error_loop \n" \
\r
681 " eq %d1, %d8, 15 \n" \
\r
682 " jne %d1, 1, _task2_error_loop \n" \
\r
683 " eq %d1, %d9, 14 \n" \
\r
684 " jne %d1, 1, _task2_error_loop \n" \
\r
685 " eq %d1, %d10, 13 \n" \
\r
686 " jne %d1, 1, _task2_error_loop \n" \
\r
687 " eq %d1, %d11, 12 \n" \
\r
688 " jne %d1, 1, _task2_error_loop \n" \
\r
689 " eq %d1, %d12, 11 \n" \
\r
690 " jne %d1, 1, _task2_error_loop \n" \
\r
691 " eq %d1, %d13, 10 \n" \
\r
692 " jne %d1, 1, _task2_error_loop \n" \
\r
693 " eq %d1, %d14, 9 \n" \
\r
694 " jne %d1, 1, _task2_error_loop \n" \
\r
695 " eq %d1, %d15, 8 \n" \
\r
696 " jne %d1, 1, _task2_error_loop \n" \
\r
697 " mov.a %a15, 14 \n" \
\r
698 " jne.a %a15, %a2, _task2_error_loop \n" \
\r
699 " mov.a %a15, 13 \n" \
\r
700 " jne.a %a15, %a3, _task2_error_loop \n" \
\r
701 " mov.a %a15, 12 \n" \
\r
702 " jne.a %a15, %a4, _task2_error_loop \n" \
\r
703 " mov.a %a15, 7 \n" \
\r
704 " jne.a %a15, %a5, _task2_error_loop \n" \
\r
705 " mov.a %a15, 6 \n" \
\r
706 " jne.a %a15, %a6, _task2_error_loop \n" \
\r
707 " mov.a %a15, 5 \n" \
\r
708 " jne.a %a15, %a7, _task2_error_loop \n" \
\r
709 " mov.a %a15, 4 \n" \
\r
710 " jne.a %a15, %a12, _task2_error_loop \n" \
\r
711 " mov.a %a15, 3 \n" \
\r
712 " jne.a %a15, %a13, _task2_error_loop \n" \
\r
713 " mov.a %a15, 2 \n" \
\r
714 " jne.a %a15, %a14, _task2_error_loop \n" \
\r
715 " j _task2_skip_error_loop \n" \
\r
716 "_task2_error_loop: \n" /* Hitting this error loop will stop the counter incrementing, allowing the check task to recognise an error. */ \
\r
718 " j _task2_error_loop \n" \
\r
719 "_task2_skip_error_loop: \n" );
\r
721 /* Load the parameter address from the stack and modify the value. */
\r
722 __asm volatile( " ld.w %d1, [%sp]4 \n" \
\r
723 " add %d1, %d1, 1 \n" \
\r
724 " st.w [%sp]4, %d1 \n" \
\r
725 " ld.a %a15, [%sp] \n" \
\r
726 " st.w [%a15], %d1 \n" \
\r
727 " j _task2_loop \n" );
\r
729 /* The parameter is used but in the assembly. */
\r
730 (void)pvParameters;
\r
733 /*-----------------------------------------------------------*/
\r