2 * FreeRTOS Kernel V10.3.0
\r
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 * http://www.FreeRTOS.org
\r
23 * http://aws.amazon.com/freertos
\r
25 * 1 tab == 4 spaces!
\r
28 /******************************************************************************
\r
29 * >>>>>> NOTE: <<<<<<
\r
31 * main() can be configured to create either a very simple LED flasher demo, or
\r
32 * a more comprehensive test/demo application.
\r
34 * To create a very simple LED flasher example, set the
\r
35 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant (defined below) to 1. When
\r
36 * this is done, only the standard demo flash tasks are created. The standard
\r
37 * demo flash example creates three tasks, each toggle an LED at a fixed but
\r
38 * different frequency.
\r
40 * To create a more comprehensive test and demo application, set
\r
41 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0.
\r
43 * Two build configurations are provided, one that executes from RAM and one
\r
44 * that executes from Flash. The RAM build uses size optimisation, the Flash
\r
45 * build has optimisation completely turned off. The documentation page for
\r
46 * this port on the FreeRTOS.org web site provides full information.
\r
47 ******************************************************************************
\r
49 * main() creates all the demo application tasks and timers, then starts the
\r
50 * scheduler. The web documentation provides more details of the standard demo
\r
51 * application tasks, which provide no particular functionality, but do provide
\r
52 * a good example of how to use the FreeRTOS API.
\r
54 * In addition to the standard demo tasks, the following tasks and tests are
\r
55 * defined and/or created within this file:
\r
57 * "Reg test" tasks - These fill the registers with known values, then check
\r
58 * that each register maintains its expected value for the lifetime of the
\r
59 * task. Each task uses a different set of values. The reg test tasks execute
\r
60 * with a very low priority, so get preempted very frequently. A register
\r
61 * containing an unexpected value is indicative of an error in the context
\r
62 * switching mechanism.
\r
64 * "Check" task - The check task period is initially set to five seconds.
\r
65 * Each time it executes, the check task checks that all the standard demo
\r
66 * tasks, and the register check tasks, are not only still executing, but are
\r
67 * executing without reporting any errors. If the check task discovers that a
\r
68 * task has either stalled, or reported an error, then it changes its own
\r
69 * execution period from the initial five seconds, to just 500ms. The check
\r
70 * task also toggles an LED each time it is called. This provides a visual
\r
71 * indication of the system status: If the LED toggles every five seconds,
\r
72 * then no issues have been discovered. If the LED toggles every 500ms, then
\r
73 * an issue has been discovered with at least one task.
\r
75 * ***NOTE*** This demo uses the standard comtest tasks, which has special
\r
76 * hardware requirements as a loopback connector, or UART echo server are
\r
77 * required. See the documentation page for this demo on the FreeRTOS.org web
\r
78 * site for more information. Note that the comtest tasks were tested by
\r
79 * placing the UART into loopback mode directly in the serial initialisation
\r
80 * sequence, and as such, the baud rate used has not been verified as actually
\r
84 /* Standard includes. */
\r
88 /* Scheduler includes. */
\r
89 #include "FreeRTOS.h"
\r
91 #include "croutine.h"
\r
93 /* Demo application includes. */
\r
94 #include "partest.h"
\r
96 #include "integer.h"
\r
98 #include "comtest2.h"
\r
99 #include "semtest.h"
\r
100 #include "dynamic.h"
\r
101 #include "BlockQ.h"
\r
102 #include "blocktim.h"
\r
103 #include "countsem.h"
\r
104 #include "GenQTest.h"
\r
105 #include "recmutex.h"
\r
106 #include "serial.h"
\r
108 #include "TimerDemo.h"
\r
109 #include "InterruptNestTest.h"
\r
111 /*-----------------------------------------------------------*/
\r
113 /* Constants for the ComTest tasks. */
\r
114 #define mainCOM_TEST_BAUD_RATE ( ( unsigned long ) 200000 )
\r
116 #define mainCOM_TEST_LED ( 5 )
\r
118 /* Priorities for the demo application tasks. */
\r
119 #define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
120 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
121 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
122 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
123 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
124 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
125 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
127 /* The rate at which the on board LED will toggle when there is/is not an
\r
129 #define mainNO_ERROR_FLASH_PERIOD_MS ( ( TickType_t ) 5000 / portTICK_PERIOD_MS )
\r
130 #define mainERROR_FLASH_PERIOD_MS ( ( TickType_t ) 500 / portTICK_PERIOD_MS )
\r
131 #define mainON_BOARD_LED_BIT ( ( unsigned long ) 7 )
\r
133 /* Constant used by the standard timer test functions. The timers created by
\r
134 the timer test functions will all have a period that is a multiple of this
\r
136 #define mainTIMER_TEST_PERIOD ( 200 )
\r
138 /* Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 1 to create a simple demo.
\r
139 Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0 to create a much more
\r
140 comprehensive test application. See the comments at the top of this file, and
\r
141 the documentation page on the http://www.FreeRTOS.org web site for more
\r
143 #define mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY 0
\r
145 /*-----------------------------------------------------------*/
\r
148 * Checks that all the demo application tasks are still executing without error
\r
149 * - as described at the top of the file.
\r
151 static long prvCheckOtherTasksAreStillRunning( void );
\r
154 * The task that executes at the highest priority and calls
\r
155 * prvCheckOtherTasksAreStillRunning(). See the description at the top
\r
158 static void prvCheckTask( void *pvParameters );
\r
161 * Configure the processor ready to run this demo.
\r
163 static void prvSetupHardware( void );
\r
166 * Writes to and checks the value of each register that is used in the context
\r
167 * of a task. See the comments at the top of this file.
\r
169 static void prvRegisterCheckTask1( void *pvParameters );
\r
170 static void prvRegisterCheckTask2( void *pvParameters );
\r
173 * Specific check to see if the register test functions are still operating
\r
176 static portBASE_TYPE prvAreRegTestTasksStillRunning( void );
\r
179 * This file can be used to create either a simple LED flasher example, or a
\r
180 * comprehensive test/demo application - depending on the setting of the
\r
181 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant defined above. If
\r
182 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 1, then the following
\r
183 * function will create a lot of additional tasks and timers. If
\r
184 * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 0, then the following
\r
185 * function will do nothing.
\r
187 static void prvOptionallyCreateComprehensveTestApplication( void );
\r
189 /*-----------------------------------------------------------*/
\r
191 /* Used by the register test tasks to indicated liveness. */
\r
192 static unsigned long ulRegisterTest1Count = 0;
\r
193 static unsigned long ulRegisterTest2Count = 0;
\r
195 /*-----------------------------------------------------------*/
\r
198 * Starts all the tasks, then starts the scheduler.
\r
202 /* Setup the hardware for use with the TriCore evaluation board. */
\r
203 prvSetupHardware();
\r
205 /* Start standard demo/test application flash tasks. See the comments at
\r
206 the top of this file. The LED flash tasks are always created. The other
\r
207 tasks are only created if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to
\r
208 0 (at the top of this file). See the comments at the top of this file for
\r
209 more information. */
\r
210 vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
\r
212 /* The following function will only create more tasks and timers if
\r
213 mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 0 (at the top of this
\r
214 file). See the comments at the top of this file for more information. */
\r
215 prvOptionallyCreateComprehensveTestApplication();
\r
217 /* Now all the tasks have been started - start the scheduler. */
\r
218 vTaskStartScheduler();
\r
220 /* If all is well then the following line will never be reached. If
\r
221 execution does reach here, then it is highly probably that the heap size
\r
222 is too small for the idle and/or timer tasks to be created within
\r
223 vTaskStartScheduler(). */
\r
226 /*-----------------------------------------------------------*/
\r
228 static void prvCheckTask( void *pvParameters )
\r
230 TickType_t xDelayPeriod = mainNO_ERROR_FLASH_PERIOD_MS;
\r
231 TickType_t xLastExecutionTime;
\r
233 /* Just to stop compiler warnings. */
\r
234 ( void ) pvParameters;
\r
236 /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
\r
237 works correctly. */
\r
238 xLastExecutionTime = xTaskGetTickCount();
\r
240 /* Cycle for ever, delaying then checking all the other tasks are still
\r
241 operating without error. If an error is detected then the delay period
\r
242 is decreased from mainNO_ERROR_FLASH_PERIOD_MS to mainERROR_FLASH_PERIOD_MS so
\r
243 the on board LED flash rate will increase. NOTE: This task could easily
\r
244 be replaced by a software timer callback to remove the overhead of having
\r
249 /* Delay until it is time to execute again. */
\r
250 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );
\r
252 /* Check all the standard demo application tasks are executing without
\r
254 if( prvCheckOtherTasksAreStillRunning() != pdPASS )
\r
256 /* An error has been detected in one of the tasks - flash the LED
\r
257 at a higher frequency to give visible feedback that something has
\r
258 gone wrong (it might just be that the loop back connector required
\r
259 by the comtest tasks has not been fitted). */
\r
260 xDelayPeriod = mainERROR_FLASH_PERIOD_MS;
\r
263 /* The toggle rate of the LED depends on how long this task delays for.
\r
264 An error reduces the delay period and so increases the toggle rate. */
\r
265 vParTestToggleLED( mainON_BOARD_LED_BIT );
\r
268 /*-----------------------------------------------------------*/
\r
270 static long prvCheckOtherTasksAreStillRunning( void )
\r
272 long lReturn = pdPASS;
\r
273 unsigned long ulHighFrequencyTimerTaskIterations, ulExpectedIncFrequency_ms;
\r
275 /* Check all the demo tasks (other than the flash tasks) to ensure
\r
276 that they are all still running, and that none have detected an error. */
\r
278 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
283 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
288 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
293 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
298 if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
303 if ( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
308 if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
313 if( prvAreRegTestTasksStillRunning() != pdTRUE )
\r
318 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
323 if( xAreTimerDemoTasksStillRunning( mainNO_ERROR_FLASH_PERIOD_MS ) != pdTRUE )
\r
328 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
333 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
338 /* Obtain the number of times the task associated with the high frequency
\r
339 (interrupt nesting) timer test has increment since the check task last
\r
340 executed, and the frequency at which it is expected to execute in ms. */
\r
341 ulHighFrequencyTimerTaskIterations = ulInterruptNestingTestGetIterationCount( &ulExpectedIncFrequency_ms );
\r
342 if( ( ulHighFrequencyTimerTaskIterations < ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) - 1 ) )
\r
344 ( ulHighFrequencyTimerTaskIterations > ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) +5 ) )
\r
347 /* Would have expected the high frequency timer task to have
\r
348 incremented its execution count more times that reported. */
\r
354 /*-----------------------------------------------------------*/
\r
356 static void prvSetupHardware( void )
\r
358 extern void set_cpu_frequency(void);
\r
360 /* Set-up the PLL. */
\r
361 set_cpu_frequency();
\r
363 /* Initialise LED outputs. */
\r
364 vParTestInitialise();
\r
366 /*-----------------------------------------------------------*/
\r
368 void vApplicationMallocFailedHook( void )
\r
370 /* vApplicationMallocFailedHook() will only be called if
\r
371 configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
\r
372 function that will get called if a call to pvPortMalloc() fails.
\r
373 pvPortMalloc() is called internally by the kernel whenever a task, queue,
\r
374 timer or semaphore is created. It is also called by various parts of the
\r
375 demo application. If heap_1.c or heap_2.c are used, then the size of the
\r
376 heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
\r
377 FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
\r
378 to query the size of free heap space that remains (although it does not
\r
379 provide information on how the remaining heap might be fragmented). */
\r
380 taskDISABLE_INTERRUPTS();
\r
383 /*-----------------------------------------------------------*/
\r
385 void vApplicationTickHook( void )
\r
387 #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY != 1
\r
389 /* vApplicationTickHook() will only be called if configUSE_TICK_HOOK is set
\r
390 to 1 in FreeRTOSConfig.h. It is a hook function that will get called during
\r
391 each FreeRTOS tick interrupt. Note that vApplicationTickHook() is called
\r
392 from an interrupt context. */
\r
394 /* Call the periodic timer test, which tests the timer API functions that
\r
395 can be called from an ISR. */
\r
396 vTimerPeriodicISRTests();
\r
398 #endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
400 /*-----------------------------------------------------------*/
\r
402 void vApplicationIdleHook( void )
\r
404 /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
\r
405 to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle
\r
406 task. It is essential that code added to this hook function never attempts
\r
407 to block in any way (for example, call xQueueReceive() with a block time
\r
408 specified, or call vTaskDelay()). If the application makes use of the
\r
409 vTaskDelete() API function (as this demo application does) then it is also
\r
410 important that vApplicationIdleHook() is permitted to return to its calling
\r
411 function, because it is the responsibility of the idle task to clean up
\r
412 memory allocated by the kernel to any task that has since been deleted. */
\r
414 /*-----------------------------------------------------------*/
\r
416 static portBASE_TYPE prvAreRegTestTasksStillRunning( void )
\r
418 static unsigned long ulPreviousRegisterTest1Count = 0;
\r
419 static unsigned long ulPreviousRegisterTest2Count = 0;
\r
420 portBASE_TYPE xReturn = pdPASS;
\r
422 /* Check to see if the Counts have changed since the last check. */
\r
423 if( ulRegisterTest1Count == ulPreviousRegisterTest1Count )
\r
428 if( ulRegisterTest2Count == ulPreviousRegisterTest2Count )
\r
433 /* Remember the current count for the next time this function is called. */
\r
434 ulPreviousRegisterTest1Count = ulRegisterTest1Count;
\r
435 ulPreviousRegisterTest2Count = ulRegisterTest2Count;
\r
439 /*-----------------------------------------------------------*/
\r
441 static void prvOptionallyCreateComprehensveTestApplication( void )
\r
443 #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY == 0
\r
445 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
446 vStartDynamicPriorityTasks();
\r
447 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
448 vCreateBlockTimeTasks();
\r
449 vStartCountingSemaphoreTasks();
\r
450 vStartGenericQueueTasks( tskIDLE_PRIORITY );
\r
451 vStartRecursiveMutexTasks();
\r
452 vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
\r
453 vSetupInterruptNestingTest();
\r
454 vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
\r
455 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
456 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
458 /* Create the register test tasks, as described at the top of this file. */
\r
459 xTaskCreate( prvRegisterCheckTask1, "Reg 1", configMINIMAL_STACK_SIZE, &ulRegisterTest1Count, tskIDLE_PRIORITY, NULL );
\r
460 xTaskCreate( prvRegisterCheckTask2, "Reg 2", configMINIMAL_STACK_SIZE, &ulRegisterTest2Count, tskIDLE_PRIORITY, NULL );
\r
462 /* Start the check task - which is defined in this file. */
\r
463 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
465 /* This task has to be created last as it keeps account of the number of tasks
\r
466 it expects to see running. */
\r
467 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
469 #else /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
471 /* Just to prevent compiler warnings when the configuration options are
\r
472 set such that these static functions are not used. */
\r
473 ( void ) prvCheckTask;
\r
474 ( void ) prvRegisterCheckTask1;
\r
475 ( void ) prvRegisterCheckTask2;
\r
477 #endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
\r
479 /*-----------------------------------------------------------*/
\r
481 static void prvRegisterCheckTask1( void *pvParameters )
\r
483 /* Make space on the stack for the parameter and a counter. */
\r
484 __asm volatile( " sub.a %sp, 4 \n"
\r
485 " st.a [%sp], %a4 \n"
\r
487 " st.w [%sp]4, %d15 \n" );
\r
489 /* Change all of the Context sensitive registers (except SP and RA). */
\r
513 " mov.a %a12, 12 \n"
\r
514 " mov.a %a13, 13 \n"
\r
515 " mov.a %a14, 14 \n" );
\r
517 /* Check the values of the registers. */
\r
518 __asm( " _task1_loop: \n" \
\r
519 " eq %d1, %d0, 0 \n" \
\r
520 " jne %d1, 1, _task1_error_loop \n" \
\r
521 " eq %d1, %d1, 1 \n" \
\r
522 " jne %d1, 1, _task1_error_loop \n" \
\r
523 " eq %d1, %d2, 2 \n" \
\r
524 " jne %d1, 1, _task1_error_loop \n" \
\r
525 " eq %d1, %d3, 3 \n" \
\r
526 " jne %d1, 1, _task1_error_loop \n" \
\r
527 " eq %d1, %d4, 4 \n" \
\r
528 " jne %d1, 1, _task1_error_loop \n" \
\r
529 " eq %d1, %d5, 5 \n" \
\r
530 " jne %d1, 1, _task1_error_loop \n" \
\r
531 " eq %d1, %d6, 6 \n" \
\r
532 " jne %d1, 1, _task1_error_loop \n" \
\r
533 " eq %d1, %d7, 7 \n" \
\r
534 " jne %d1, 1, _task1_error_loop \n" \
\r
535 " eq %d1, %d8, 8 \n" \
\r
536 " jne %d1, 1, _task1_error_loop \n" \
\r
537 " eq %d1, %d9, 9 \n" \
\r
538 " jne %d1, 1, _task1_error_loop \n" \
\r
539 " eq %d1, %d10, 10 \n" \
\r
540 " jne %d1, 1, _task1_error_loop \n" \
\r
541 " eq %d1, %d11, 11 \n" \
\r
542 " jne %d1, 1, _task1_error_loop \n" \
\r
543 " eq %d1, %d12, 12 \n" \
\r
544 " jne %d1, 1, _task1_error_loop \n" \
\r
545 " eq %d1, %d13, 13 \n" \
\r
546 " jne %d1, 1, _task1_error_loop \n" \
\r
547 " eq %d1, %d14, 14 \n" \
\r
548 " jne %d1, 1, _task1_error_loop \n" \
\r
549 " eq %d1, %d15, 15 \n" \
\r
550 " jne %d1, 1, _task1_error_loop \n" \
\r
551 " mov.a %a15, 2 \n" \
\r
552 " jne.a %a15, %a2, _task1_error_loop \n" \
\r
553 " mov.a %a15, 3 \n" \
\r
554 " jne.a %a15, %a3, _task1_error_loop \n" \
\r
555 " mov.a %a15, 4 \n" \
\r
556 " jne.a %a15, %a4, _task1_error_loop \n" \
\r
557 " mov.a %a15, 5 \n" \
\r
558 " jne.a %a15, %a5, _task1_error_loop \n" \
\r
559 " mov.a %a15, 6 \n" \
\r
560 " jne.a %a15, %a6, _task1_error_loop \n" \
\r
561 " mov.a %a15, 7 \n" \
\r
562 " jne.a %a15, %a7, _task1_error_loop \n" \
\r
563 " mov.a %a15, 12 \n" \
\r
564 " jne.a %a15, %a12, _task1_error_loop \n" \
\r
565 " mov.a %a15, 13 \n" \
\r
566 " jne.a %a15, %a13, _task1_error_loop \n" \
\r
567 " mov.a %a15, 14 \n" \
\r
568 " jne.a %a15, %a14, _task1_error_loop \n" \
\r
569 " j _task1_skip_error_loop \n" \
\r
570 "_task1_error_loop: \n" /* Hitting this error loop will stop the counter incrementing, allowing the check task to recognise an error. */ \
\r
572 " j _task1_error_loop \n" \
\r
573 "_task1_skip_error_loop: \n" );
\r
575 /* Load the parameter address from the stack and modify the value. */
\r
577 " ld.w %d1, [%sp]4 \n" \
\r
579 " st.w [%sp]4, %d1 \n" \
\r
580 " ld.a %a15, [%sp] \n" \
\r
581 " st.w [%a15], %d1 \n" \
\r
582 " j _task1_loop \n" );
\r
584 /* The parameter is used but in the assembly. */
\r
585 (void)pvParameters;
\r
587 /*-----------------------------------------------------------*/
\r
589 static void prvRegisterCheckTask2( void *pvParameters )
\r
591 /* Make space on the stack for the parameter and a counter. */
\r
592 __asm volatile( " sub.a %sp, 4 \n" \
\r
593 " st.a [%sp], %a4 \n" \
\r
594 " mov %d15, 0 \n" \
\r
595 " st.w [%sp]4, %d15 \n" );
\r
597 /* Change all of the Context sensitive registers (except SP and RA). */
\r
598 __asm volatile( " mov %d0, 7 \n" \
\r
606 " mov %d8, 15 \n" \
\r
607 " mov %d9, 14 \n" \
\r
608 " mov %d10, 13 \n" \
\r
609 " mov %d11, 12 \n" \
\r
610 " mov %d12, 11 \n" \
\r
611 " mov %d13, 10 \n" \
\r
612 " mov %d14, 9 \n" \
\r
613 " mov %d15, 8 \n" \
\r
614 " mov.a %a2, 14 \n" \
\r
615 " mov.a %a3, 13 \n" \
\r
616 " mov.a %a4, 12 \n" \
\r
617 " mov.a %a5, 7 \n" \
\r
618 " mov.a %a6, 6 \n" \
\r
619 " mov.a %a7, 5 \n" \
\r
620 " mov.a %a12, 4 \n" \
\r
621 " mov.a %a13, 3 \n" \
\r
622 " mov.a %a14, 2 \n" );
\r
624 /* Check the values of the registers. */
\r
625 __asm volatile( " _task2_loop: \n" \
\r
627 " eq %d1, %d0, 7 \n" \
\r
628 " jne %d1, 1, _task2_error_loop \n" \
\r
629 " eq %d1, %d1, 1 \n" \
\r
630 " jne %d1, 1, _task2_error_loop \n" \
\r
631 " eq %d1, %d2, 5 \n" \
\r
632 " jne %d1, 1, _task2_error_loop \n" \
\r
633 " eq %d1, %d3, 4 \n" \
\r
634 " jne %d1, 1, _task2_error_loop \n" \
\r
635 " eq %d1, %d4, 3 \n" \
\r
636 " jne %d1, 1, _task2_error_loop \n" \
\r
637 " eq %d1, %d5, 2 \n" \
\r
638 " jne %d1, 1, _task2_error_loop \n" \
\r
639 " eq %d1, %d6, 1 \n" \
\r
640 " jne %d1, 1, _task2_error_loop \n" \
\r
641 " eq %d1, %d7, 0 \n" \
\r
642 " jne %d1, 1, _task2_error_loop \n" \
\r
643 " eq %d1, %d8, 15 \n" \
\r
644 " jne %d1, 1, _task2_error_loop \n" \
\r
645 " eq %d1, %d9, 14 \n" \
\r
646 " jne %d1, 1, _task2_error_loop \n" \
\r
647 " eq %d1, %d10, 13 \n" \
\r
648 " jne %d1, 1, _task2_error_loop \n" \
\r
649 " eq %d1, %d11, 12 \n" \
\r
650 " jne %d1, 1, _task2_error_loop \n" \
\r
651 " eq %d1, %d12, 11 \n" \
\r
652 " jne %d1, 1, _task2_error_loop \n" \
\r
653 " eq %d1, %d13, 10 \n" \
\r
654 " jne %d1, 1, _task2_error_loop \n" \
\r
655 " eq %d1, %d14, 9 \n" \
\r
656 " jne %d1, 1, _task2_error_loop \n" \
\r
657 " eq %d1, %d15, 8 \n" \
\r
658 " jne %d1, 1, _task2_error_loop \n" \
\r
659 " mov.a %a15, 14 \n" \
\r
660 " jne.a %a15, %a2, _task2_error_loop \n" \
\r
661 " mov.a %a15, 13 \n" \
\r
662 " jne.a %a15, %a3, _task2_error_loop \n" \
\r
663 " mov.a %a15, 12 \n" \
\r
664 " jne.a %a15, %a4, _task2_error_loop \n" \
\r
665 " mov.a %a15, 7 \n" \
\r
666 " jne.a %a15, %a5, _task2_error_loop \n" \
\r
667 " mov.a %a15, 6 \n" \
\r
668 " jne.a %a15, %a6, _task2_error_loop \n" \
\r
669 " mov.a %a15, 5 \n" \
\r
670 " jne.a %a15, %a7, _task2_error_loop \n" \
\r
671 " mov.a %a15, 4 \n" \
\r
672 " jne.a %a15, %a12, _task2_error_loop \n" \
\r
673 " mov.a %a15, 3 \n" \
\r
674 " jne.a %a15, %a13, _task2_error_loop \n" \
\r
675 " mov.a %a15, 2 \n" \
\r
676 " jne.a %a15, %a14, _task2_error_loop \n" \
\r
677 " j _task2_skip_error_loop \n" \
\r
678 "_task2_error_loop: \n" /* Hitting this error loop will stop the counter incrementing, allowing the check task to recognise an error. */ \
\r
680 " j _task2_error_loop \n" \
\r
681 "_task2_skip_error_loop: \n" );
\r
683 /* Load the parameter address from the stack and modify the value. */
\r
684 __asm volatile( " ld.w %d1, [%sp]4 \n" \
\r
685 " add %d1, %d1, 1 \n" \
\r
686 " st.w [%sp]4, %d1 \n" \
\r
687 " ld.a %a15, [%sp] \n" \
\r
688 " st.w [%a15], %d1 \n" \
\r
689 " j _task2_loop \n" );
\r
691 /* The parameter is used but in the assembly. */
\r
692 (void)pvParameters;
\r
695 /*-----------------------------------------------------------*/
\r