2 FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution.
\r
9 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
10 the terms of the GNU General Public License (version 2) as published by the
\r
11 Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
\r
13 ***************************************************************************
\r
14 >>! NOTE: The modification to the GPL is included to allow you to !<<
\r
15 >>! distribute a combined work that includes FreeRTOS without being !<<
\r
16 >>! obliged to provide the source code for proprietary components !<<
\r
17 >>! outside of the FreeRTOS kernel. !<<
\r
18 ***************************************************************************
\r
20 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
21 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
22 FOR A PARTICULAR PURPOSE. Full license text is available on the following
\r
23 link: http://www.freertos.org/a00114.html
\r
25 ***************************************************************************
\r
27 * FreeRTOS provides completely free yet professionally developed, *
\r
28 * robust, strictly quality controlled, supported, and cross *
\r
29 * platform software that is more than just the market leader, it *
\r
30 * is the industry's de facto standard. *
\r
32 * Help yourself get started quickly while simultaneously helping *
\r
33 * to support the FreeRTOS project by purchasing a FreeRTOS *
\r
34 * tutorial book, reference manual, or both: *
\r
35 * http://www.FreeRTOS.org/Documentation *
\r
37 ***************************************************************************
\r
39 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
\r
40 the FAQ page "My application does not run, what could be wrong?". Have you
\r
41 defined configASSERT()?
\r
43 http://www.FreeRTOS.org/support - In return for receiving this top quality
\r
44 embedded software for free we request you assist our global community by
\r
45 participating in the support forum.
\r
47 http://www.FreeRTOS.org/training - Investing in training allows your team to
\r
48 be as productive as possible as early as possible. Now you can receive
\r
49 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
\r
50 Ltd, and the world's leading authority on the world's leading RTOS.
\r
52 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
53 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
54 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
56 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
\r
57 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
\r
59 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
\r
60 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
61 licenses offer ticketed support, indemnification and commercial middleware.
\r
63 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
64 engineered and independently SIL3 certified version for use in safety and
\r
65 mission critical applications that require provable dependability.
\r
70 /******************************************************************************
\r
71 * >>>>>> NOTE: <<<<<<
\r
73 * main() can be configured to create either a very simple LED flasher demo, or
\r
74 * a more comprehensive test/demo application.
\r
76 * To create a very simple LED flasher example, set the
\r
77 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant (defined below) to 1. When
\r
78 * this is done, only the standard demo flash tasks are created. The standard
\r
79 * demo flash example creates three tasks, each toggle an LED at a fixed but
\r
80 * different frequency.
\r
82 * To create a more comprehensive test and demo application, set
\r
83 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0.
\r
85 * Two build configurations are provided, one that executes from RAM and one
\r
86 * that executes from Flash. The RAM build uses size optimisation, the Flash
\r
87 * build has optimisation completely turned off. The documentation page for
\r
88 * this port on the FreeRTOS.org web site provides full information.
\r
89 ******************************************************************************
\r
91 * main() creates all the demo application tasks and timers, then starts the
\r
92 * scheduler. The web documentation provides more details of the standard demo
\r
93 * application tasks, which provide no particular functionality, but do provide
\r
94 * a good example of how to use the FreeRTOS API.
\r
96 * In addition to the standard demo tasks, the following tasks and tests are
\r
97 * defined and/or created within this file:
\r
99 * "Reg test" tasks - These fill the registers with known values, then check
\r
100 * that each register maintains its expected value for the lifetime of the
\r
101 * task. Each task uses a different set of values. The reg test tasks execute
\r
102 * with a very low priority, so get preempted very frequently. A register
\r
103 * containing an unexpected value is indicative of an error in the context
\r
104 * switching mechanism.
\r
106 * "Check" task - The check task period is initially set to five seconds.
\r
107 * Each time it executes, the check task checks that all the standard demo
\r
108 * tasks, and the register check tasks, are not only still executing, but are
\r
109 * executing without reporting any errors. If the check task discovers that a
\r
110 * task has either stalled, or reported an error, then it changes its own
\r
111 * execution period from the initial five seconds, to just 500ms. The check
\r
112 * task also toggles an LED each time it is called. This provides a visual
\r
113 * indication of the system status: If the LED toggles every five seconds,
\r
114 * then no issues have been discovered. If the LED toggles every 500ms, then
\r
115 * an issue has been discovered with at least one task.
\r
117 * ***NOTE*** This demo uses the standard comtest tasks, which has special
\r
118 * hardware requirements as a loopback connector, or UART echo server are
\r
119 * required. See the documentation page for this demo on the FreeRTOS.org web
\r
120 * site for more information. Note that the comtest tasks were tested by
\r
121 * placing the UART into loopback mode directly in the serial initialisation
\r
122 * sequence, and as such, the baud rate used has not been verified as actually
\r
126 /* Standard includes. */
\r
127 #include <stdlib.h>
\r
128 #include <string.h>
\r
130 /* Scheduler includes. */
\r
131 #include "FreeRTOS.h"
\r
133 #include "croutine.h"
\r
135 /* Demo application includes. */
\r
136 #include "partest.h"
\r
138 #include "integer.h"
\r
140 #include "comtest2.h"
\r
141 #include "semtest.h"
\r
142 #include "dynamic.h"
\r
143 #include "BlockQ.h"
\r
144 #include "blocktim.h"
\r
145 #include "countsem.h"
\r
146 #include "GenQTest.h"
\r
147 #include "recmutex.h"
\r
148 #include "serial.h"
\r
150 #include "TimerDemo.h"
\r
151 #include "InterruptNestTest.h"
\r
153 /*-----------------------------------------------------------*/
\r
155 /* Constants for the ComTest tasks. */
\r
156 #define mainCOM_TEST_BAUD_RATE ( ( unsigned long ) 200000 )
\r
158 #define mainCOM_TEST_LED ( 5 )
\r
160 /* Priorities for the demo application tasks. */
\r
161 #define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
162 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
163 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
164 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
165 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
166 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
167 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
169 /* The rate at which the on board LED will toggle when there is/is not an
\r
171 #define mainNO_ERROR_FLASH_PERIOD_MS ( ( TickType_t ) 5000 / portTICK_PERIOD_MS )
\r
172 #define mainERROR_FLASH_PERIOD_MS ( ( TickType_t ) 500 / portTICK_PERIOD_MS )
\r
173 #define mainON_BOARD_LED_BIT ( ( unsigned long ) 7 )
\r
175 /* Constant used by the standard timer test functions. The timers created by
\r
176 the timer test functions will all have a period that is a multiple of this
\r
178 #define mainTIMER_TEST_PERIOD ( 200 )
\r
180 /* Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 1 to create a simple demo.
\r
181 Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0 to create a much more
\r
182 comprehensive test application. See the comments at the top of this file, and
\r
183 the documentation page on the http://www.FreeRTOS.org web site for more
\r
185 #define mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY 0
\r
187 /*-----------------------------------------------------------*/
\r
190 * Checks that all the demo application tasks are still executing without error
\r
191 * - as described at the top of the file.
\r
193 static long prvCheckOtherTasksAreStillRunning( void );
\r
196 * The task that executes at the highest priority and calls
\r
197 * prvCheckOtherTasksAreStillRunning(). See the description at the top
\r
200 static void prvCheckTask( void *pvParameters );
\r
203 * Configure the processor ready to run this demo.
\r
205 static void prvSetupHardware( void );
\r
208 * Writes to and checks the value of each register that is used in the context
\r
209 * of a task. See the comments at the top of this file.
\r
211 static void prvRegisterCheckTask1( void *pvParameters );
\r
212 static void prvRegisterCheckTask2( void *pvParameters );
\r
215 * Specific check to see if the register test functions are still operating
\r
218 static portBASE_TYPE prvAreRegTestTasksStillRunning( void );
\r
221 * This file can be used to create either a simple LED flasher example, or a
\r
222 * comprehensive test/demo application - depending on the setting of the
\r
223 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant defined above. If
\r
224 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 1, then the following
\r
225 * function will create a lot of additional tasks and timers. If
\r
226 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 0, then the following
\r
227 * function will do nothing.
\r
229 static void prvOptionallyCreateComprehensveTestApplication( void );
\r
231 /*-----------------------------------------------------------*/
\r
233 /* Used by the register test tasks to indicated liveness. */
\r
234 static unsigned long ulRegisterTest1Count = 0;
\r
235 static unsigned long ulRegisterTest2Count = 0;
\r
237 /*-----------------------------------------------------------*/
\r
240 * Starts all the tasks, then starts the scheduler.
\r
244 /* Setup the hardware for use with the TriCore evaluation board. */
\r
245 prvSetupHardware();
\r
247 /* Start standard demo/test application flash tasks. See the comments at
\r
248 the top of this file. The LED flash tasks are always created. The other
\r
249 tasks are only created if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to
\r
250 0 (at the top of this file). See the comments at the top of this file for
\r
251 more information. */
\r
252 vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
\r
254 /* The following function will only create more tasks and timers if
\r
255 mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 0 (at the top of this
\r
256 file). See the comments at the top of this file for more information. */
\r
257 prvOptionallyCreateComprehensveTestApplication();
\r
259 /* Now all the tasks have been started - start the scheduler. */
\r
260 vTaskStartScheduler();
\r
262 /* If all is well then the following line will never be reached. If
\r
263 execution does reach here, then it is highly probably that the heap size
\r
264 is too small for the idle and/or timer tasks to be created within
\r
265 vTaskStartScheduler(). */
\r
268 /*-----------------------------------------------------------*/
\r
270 static void prvCheckTask( void *pvParameters )
\r
272 TickType_t xDelayPeriod = mainNO_ERROR_FLASH_PERIOD_MS;
\r
273 TickType_t xLastExecutionTime;
\r
275 /* Just to stop compiler warnings. */
\r
276 ( void ) pvParameters;
\r
278 /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
\r
279 works correctly. */
\r
280 xLastExecutionTime = xTaskGetTickCount();
\r
282 /* Cycle for ever, delaying then checking all the other tasks are still
\r
283 operating without error. If an error is detected then the delay period
\r
284 is decreased from mainNO_ERROR_FLASH_PERIOD_MS to mainERROR_FLASH_PERIOD_MS so
\r
285 the on board LED flash rate will increase. NOTE: This task could easily
\r
286 be replaced by a software timer callback to remove the overhead of having
\r
291 /* Delay until it is time to execute again. */
\r
292 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );
\r
294 /* Check all the standard demo application tasks are executing without
\r
296 if( prvCheckOtherTasksAreStillRunning() != pdPASS )
\r
298 /* An error has been detected in one of the tasks - flash the LED
\r
299 at a higher frequency to give visible feedback that something has
\r
300 gone wrong (it might just be that the loop back connector required
\r
301 by the comtest tasks has not been fitted). */
\r
302 xDelayPeriod = mainERROR_FLASH_PERIOD_MS;
\r
305 /* The toggle rate of the LED depends on how long this task delays for.
\r
306 An error reduces the delay period and so increases the toggle rate. */
\r
307 vParTestToggleLED( mainON_BOARD_LED_BIT );
\r
310 /*-----------------------------------------------------------*/
\r
312 static long prvCheckOtherTasksAreStillRunning( void )
\r
314 long lReturn = pdPASS;
\r
315 unsigned long ulHighFrequencyTimerTaskIterations, ulExpectedIncFrequency_ms;
\r
317 /* Check all the demo tasks (other than the flash tasks) to ensure
\r
318 that they are all still running, and that none have detected an error. */
\r
320 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
325 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
330 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
335 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
340 if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
345 if ( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
350 if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
355 if( prvAreRegTestTasksStillRunning() != pdTRUE )
\r
360 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
365 if( xAreTimerDemoTasksStillRunning( mainNO_ERROR_FLASH_PERIOD_MS ) != pdTRUE )
\r
370 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
375 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
380 /* Obtain the number of times the task associated with the high frequency
\r
381 (interrupt nesting) timer test has increment since the check task last
\r
382 executed, and the frequency at which it is expected to execute in ms. */
\r
383 ulHighFrequencyTimerTaskIterations = ulInterruptNestingTestGetIterationCount( &ulExpectedIncFrequency_ms );
\r
384 if( ( ulHighFrequencyTimerTaskIterations < ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) - 1 ) )
\r
386 ( ulHighFrequencyTimerTaskIterations > ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) +5 ) )
\r
389 /* Would have expected the high frequency timer task to have
\r
390 incremented its execution count more times that reported. */
\r
396 /*-----------------------------------------------------------*/
\r
398 static void prvSetupHardware( void )
\r
400 extern void set_cpu_frequency(void);
\r
402 /* Set-up the PLL. */
\r
403 set_cpu_frequency();
\r
405 /* Initialise LED outputs. */
\r
406 vParTestInitialise();
\r
408 /*-----------------------------------------------------------*/
\r
410 void vApplicationMallocFailedHook( void )
\r
412 /* vApplicationMallocFailedHook() will only be called if
\r
413 configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
\r
414 function that will get called if a call to pvPortMalloc() fails.
\r
415 pvPortMalloc() is called internally by the kernel whenever a task, queue,
\r
416 timer or semaphore is created. It is also called by various parts of the
\r
417 demo application. If heap_1.c or heap_2.c are used, then the size of the
\r
418 heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
\r
419 FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
\r
420 to query the size of free heap space that remains (although it does not
\r
421 provide information on how the remaining heap might be fragmented). */
\r
422 taskDISABLE_INTERRUPTS();
\r
425 /*-----------------------------------------------------------*/
\r
427 void vApplicationTickHook( void )
\r
429 #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY != 1
\r
431 /* vApplicationTickHook() will only be called if configUSE_TICK_HOOK is set
\r
432 to 1 in FreeRTOSConfig.h. It is a hook function that will get called during
\r
433 each FreeRTOS tick interrupt. Note that vApplicationTickHook() is called
\r
434 from an interrupt context. */
\r
436 /* Call the periodic timer test, which tests the timer API functions that
\r
437 can be called from an ISR. */
\r
438 vTimerPeriodicISRTests();
\r
440 #endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
442 /*-----------------------------------------------------------*/
\r
444 void vApplicationIdleHook( void )
\r
446 /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
\r
447 to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle
\r
448 task. It is essential that code added to this hook function never attempts
\r
449 to block in any way (for example, call xQueueReceive() with a block time
\r
450 specified, or call vTaskDelay()). If the application makes use of the
\r
451 vTaskDelete() API function (as this demo application does) then it is also
\r
452 important that vApplicationIdleHook() is permitted to return to its calling
\r
453 function, because it is the responsibility of the idle task to clean up
\r
454 memory allocated by the kernel to any task that has since been deleted. */
\r
456 /*-----------------------------------------------------------*/
\r
458 static portBASE_TYPE prvAreRegTestTasksStillRunning( void )
\r
460 static unsigned long ulPreviousRegisterTest1Count = 0;
\r
461 static unsigned long ulPreviousRegisterTest2Count = 0;
\r
462 portBASE_TYPE xReturn = pdPASS;
\r
464 /* Check to see if the Counts have changed since the last check. */
\r
465 if( ulRegisterTest1Count == ulPreviousRegisterTest1Count )
\r
470 if( ulRegisterTest2Count == ulPreviousRegisterTest2Count )
\r
475 /* Remember the current count for the next time this function is called. */
\r
476 ulPreviousRegisterTest1Count = ulRegisterTest1Count;
\r
477 ulPreviousRegisterTest2Count = ulRegisterTest2Count;
\r
481 /*-----------------------------------------------------------*/
\r
483 static void prvOptionallyCreateComprehensveTestApplication( void )
\r
485 #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY == 0
\r
487 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
488 vStartDynamicPriorityTasks();
\r
489 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
490 vCreateBlockTimeTasks();
\r
491 vStartCountingSemaphoreTasks();
\r
492 vStartGenericQueueTasks( tskIDLE_PRIORITY );
\r
493 vStartRecursiveMutexTasks();
\r
494 vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
\r
495 vSetupInterruptNestingTest();
\r
496 vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
\r
497 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
498 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
500 /* Create the register test tasks, as described at the top of this file. */
\r
501 xTaskCreate( prvRegisterCheckTask1, "Reg 1", configMINIMAL_STACK_SIZE, &ulRegisterTest1Count, tskIDLE_PRIORITY, NULL );
\r
502 xTaskCreate( prvRegisterCheckTask2, "Reg 2", configMINIMAL_STACK_SIZE, &ulRegisterTest2Count, tskIDLE_PRIORITY, NULL );
\r
504 /* Start the check task - which is defined in this file. */
\r
505 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
507 /* This task has to be created last as it keeps account of the number of tasks
\r
508 it expects to see running. */
\r
509 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
511 #else /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
513 /* Just to prevent compiler warnings when the configuration options are
\r
514 set such that these static functions are not used. */
\r
515 ( void ) prvCheckTask;
\r
516 ( void ) prvRegisterCheckTask1;
\r
517 ( void ) prvRegisterCheckTask2;
\r
519 #endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
521 /*-----------------------------------------------------------*/
\r
523 static void prvRegisterCheckTask1( void *pvParameters )
\r
525 /* Make space on the stack for the parameter and a counter. */
\r
526 __asm volatile( " sub.a %sp, 4 \n"
\r
527 " st.a [%sp], %a4 \n"
\r
529 " st.w [%sp]4, %d15 \n" );
\r
531 /* Change all of the Context sensitive registers (except SP and RA). */
\r
555 " mov.a %a12, 12 \n"
\r
556 " mov.a %a13, 13 \n"
\r
557 " mov.a %a14, 14 \n" );
\r
559 /* Check the values of the registers. */
\r
560 __asm( " _task1_loop: \n" \
\r
561 " eq %d1, %d0, 0 \n" \
\r
562 " jne %d1, 1, _task1_error_loop \n" \
\r
563 " eq %d1, %d1, 1 \n" \
\r
564 " jne %d1, 1, _task1_error_loop \n" \
\r
565 " eq %d1, %d2, 2 \n" \
\r
566 " jne %d1, 1, _task1_error_loop \n" \
\r
567 " eq %d1, %d3, 3 \n" \
\r
568 " jne %d1, 1, _task1_error_loop \n" \
\r
569 " eq %d1, %d4, 4 \n" \
\r
570 " jne %d1, 1, _task1_error_loop \n" \
\r
571 " eq %d1, %d5, 5 \n" \
\r
572 " jne %d1, 1, _task1_error_loop \n" \
\r
573 " eq %d1, %d6, 6 \n" \
\r
574 " jne %d1, 1, _task1_error_loop \n" \
\r
575 " eq %d1, %d7, 7 \n" \
\r
576 " jne %d1, 1, _task1_error_loop \n" \
\r
577 " eq %d1, %d8, 8 \n" \
\r
578 " jne %d1, 1, _task1_error_loop \n" \
\r
579 " eq %d1, %d9, 9 \n" \
\r
580 " jne %d1, 1, _task1_error_loop \n" \
\r
581 " eq %d1, %d10, 10 \n" \
\r
582 " jne %d1, 1, _task1_error_loop \n" \
\r
583 " eq %d1, %d11, 11 \n" \
\r
584 " jne %d1, 1, _task1_error_loop \n" \
\r
585 " eq %d1, %d12, 12 \n" \
\r
586 " jne %d1, 1, _task1_error_loop \n" \
\r
587 " eq %d1, %d13, 13 \n" \
\r
588 " jne %d1, 1, _task1_error_loop \n" \
\r
589 " eq %d1, %d14, 14 \n" \
\r
590 " jne %d1, 1, _task1_error_loop \n" \
\r
591 " eq %d1, %d15, 15 \n" \
\r
592 " jne %d1, 1, _task1_error_loop \n" \
\r
593 " mov.a %a15, 2 \n" \
\r
594 " jne.a %a15, %a2, _task1_error_loop \n" \
\r
595 " mov.a %a15, 3 \n" \
\r
596 " jne.a %a15, %a3, _task1_error_loop \n" \
\r
597 " mov.a %a15, 4 \n" \
\r
598 " jne.a %a15, %a4, _task1_error_loop \n" \
\r
599 " mov.a %a15, 5 \n" \
\r
600 " jne.a %a15, %a5, _task1_error_loop \n" \
\r
601 " mov.a %a15, 6 \n" \
\r
602 " jne.a %a15, %a6, _task1_error_loop \n" \
\r
603 " mov.a %a15, 7 \n" \
\r
604 " jne.a %a15, %a7, _task1_error_loop \n" \
\r
605 " mov.a %a15, 12 \n" \
\r
606 " jne.a %a15, %a12, _task1_error_loop \n" \
\r
607 " mov.a %a15, 13 \n" \
\r
608 " jne.a %a15, %a13, _task1_error_loop \n" \
\r
609 " mov.a %a15, 14 \n" \
\r
610 " jne.a %a15, %a14, _task1_error_loop \n" \
\r
611 " j _task1_skip_error_loop \n" \
\r
612 "_task1_error_loop: \n" /* Hitting this error loop will stop the counter incrementing, allowing the check task to recognise an error. */ \
\r
614 " j _task1_error_loop \n" \
\r
615 "_task1_skip_error_loop: \n" );
\r
617 /* Load the parameter address from the stack and modify the value. */
\r
619 " ld.w %d1, [%sp]4 \n" \
\r
621 " st.w [%sp]4, %d1 \n" \
\r
622 " ld.a %a15, [%sp] \n" \
\r
623 " st.w [%a15], %d1 \n" \
\r
624 " j _task1_loop \n" );
\r
626 /* The parameter is used but in the assembly. */
\r
627 (void)pvParameters;
\r
629 /*-----------------------------------------------------------*/
\r
631 static void prvRegisterCheckTask2( void *pvParameters )
\r
633 /* Make space on the stack for the parameter and a counter. */
\r
634 __asm volatile( " sub.a %sp, 4 \n" \
\r
635 " st.a [%sp], %a4 \n" \
\r
636 " mov %d15, 0 \n" \
\r
637 " st.w [%sp]4, %d15 \n" );
\r
639 /* Change all of the Context sensitive registers (except SP and RA). */
\r
640 __asm volatile( " mov %d0, 7 \n" \
\r
648 " mov %d8, 15 \n" \
\r
649 " mov %d9, 14 \n" \
\r
650 " mov %d10, 13 \n" \
\r
651 " mov %d11, 12 \n" \
\r
652 " mov %d12, 11 \n" \
\r
653 " mov %d13, 10 \n" \
\r
654 " mov %d14, 9 \n" \
\r
655 " mov %d15, 8 \n" \
\r
656 " mov.a %a2, 14 \n" \
\r
657 " mov.a %a3, 13 \n" \
\r
658 " mov.a %a4, 12 \n" \
\r
659 " mov.a %a5, 7 \n" \
\r
660 " mov.a %a6, 6 \n" \
\r
661 " mov.a %a7, 5 \n" \
\r
662 " mov.a %a12, 4 \n" \
\r
663 " mov.a %a13, 3 \n" \
\r
664 " mov.a %a14, 2 \n" );
\r
666 /* Check the values of the registers. */
\r
667 __asm volatile( " _task2_loop: \n" \
\r
669 " eq %d1, %d0, 7 \n" \
\r
670 " jne %d1, 1, _task2_error_loop \n" \
\r
671 " eq %d1, %d1, 1 \n" \
\r
672 " jne %d1, 1, _task2_error_loop \n" \
\r
673 " eq %d1, %d2, 5 \n" \
\r
674 " jne %d1, 1, _task2_error_loop \n" \
\r
675 " eq %d1, %d3, 4 \n" \
\r
676 " jne %d1, 1, _task2_error_loop \n" \
\r
677 " eq %d1, %d4, 3 \n" \
\r
678 " jne %d1, 1, _task2_error_loop \n" \
\r
679 " eq %d1, %d5, 2 \n" \
\r
680 " jne %d1, 1, _task2_error_loop \n" \
\r
681 " eq %d1, %d6, 1 \n" \
\r
682 " jne %d1, 1, _task2_error_loop \n" \
\r
683 " eq %d1, %d7, 0 \n" \
\r
684 " jne %d1, 1, _task2_error_loop \n" \
\r
685 " eq %d1, %d8, 15 \n" \
\r
686 " jne %d1, 1, _task2_error_loop \n" \
\r
687 " eq %d1, %d9, 14 \n" \
\r
688 " jne %d1, 1, _task2_error_loop \n" \
\r
689 " eq %d1, %d10, 13 \n" \
\r
690 " jne %d1, 1, _task2_error_loop \n" \
\r
691 " eq %d1, %d11, 12 \n" \
\r
692 " jne %d1, 1, _task2_error_loop \n" \
\r
693 " eq %d1, %d12, 11 \n" \
\r
694 " jne %d1, 1, _task2_error_loop \n" \
\r
695 " eq %d1, %d13, 10 \n" \
\r
696 " jne %d1, 1, _task2_error_loop \n" \
\r
697 " eq %d1, %d14, 9 \n" \
\r
698 " jne %d1, 1, _task2_error_loop \n" \
\r
699 " eq %d1, %d15, 8 \n" \
\r
700 " jne %d1, 1, _task2_error_loop \n" \
\r
701 " mov.a %a15, 14 \n" \
\r
702 " jne.a %a15, %a2, _task2_error_loop \n" \
\r
703 " mov.a %a15, 13 \n" \
\r
704 " jne.a %a15, %a3, _task2_error_loop \n" \
\r
705 " mov.a %a15, 12 \n" \
\r
706 " jne.a %a15, %a4, _task2_error_loop \n" \
\r
707 " mov.a %a15, 7 \n" \
\r
708 " jne.a %a15, %a5, _task2_error_loop \n" \
\r
709 " mov.a %a15, 6 \n" \
\r
710 " jne.a %a15, %a6, _task2_error_loop \n" \
\r
711 " mov.a %a15, 5 \n" \
\r
712 " jne.a %a15, %a7, _task2_error_loop \n" \
\r
713 " mov.a %a15, 4 \n" \
\r
714 " jne.a %a15, %a12, _task2_error_loop \n" \
\r
715 " mov.a %a15, 3 \n" \
\r
716 " jne.a %a15, %a13, _task2_error_loop \n" \
\r
717 " mov.a %a15, 2 \n" \
\r
718 " jne.a %a15, %a14, _task2_error_loop \n" \
\r
719 " j _task2_skip_error_loop \n" \
\r
720 "_task2_error_loop: \n" /* Hitting this error loop will stop the counter incrementing, allowing the check task to recognise an error. */ \
\r
722 " j _task2_error_loop \n" \
\r
723 "_task2_skip_error_loop: \n" );
\r
725 /* Load the parameter address from the stack and modify the value. */
\r
726 __asm volatile( " ld.w %d1, [%sp]4 \n" \
\r
727 " add %d1, %d1, 1 \n" \
\r
728 " st.w [%sp]4, %d1 \n" \
\r
729 " ld.a %a15, [%sp] \n" \
\r
730 " st.w [%a15], %d1 \n" \
\r
731 " j _task2_loop \n" );
\r
733 /* The parameter is used but in the assembly. */
\r
734 (void)pvParameters;
\r
737 /*-----------------------------------------------------------*/
\r