]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RX200_RX231-RSK_Renesas_e2studio/src/Full_Demo/main_full.c
Update version number in readiness for V10.3.0 release. Sync SVN with reviewed releas...
[freertos] / FreeRTOS / Demo / RX200_RX231-RSK_Renesas_e2studio / src / Full_Demo / main_full.c
1 /*\r
2  * FreeRTOS Kernel V10.3.0\r
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\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
11  *\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
14  *\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
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 /******************************************************************************\r
29  * NOTE 1:  This project provides two demo applications.  A simple blinky\r
30  * style project, and a more comprehensive test and demo application.  The\r
31  * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to\r
32  * select between the two.  See the notes on using\r
33  * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY in main.c.  This file implements the\r
34  * comprehensive version.\r
35  *\r
36  * NOTE 2:  This file only contains the source code that is specific to the\r
37  * full demo.  Generic functions, such FreeRTOS hook functions, and functions\r
38  * required to configure the hardware, are defined in main.c.\r
39  *\r
40  ******************************************************************************\r
41  *\r
42  * main_full() creates a set of demo application tasks and software timers, then\r
43  * starts the scheduler.  The web documentation provides more details of the\r
44  * standard demo application tasks, which provide no particular functionality,\r
45  * but do provide a good example of how to use the FreeRTOS API.\r
46  *\r
47  * In addition to the standard demo tasks, the following tasks and tests are\r
48  * defined and/or created within this file:\r
49  *\r
50  * "Reg test" tasks - These fill both the core and floating point registers with\r
51  * known values, then check that each register maintains its expected value for\r
52  * the lifetime of the task.  Each task uses a different set of values.  The reg\r
53  * test tasks execute with a very low priority, so get preempted very\r
54  * frequently.  A register containing an unexpected value is indicative of an\r
55  * error in the context switching mechanism.\r
56  *\r
57  * "Check" task - The check task period is initially set to three seconds.  The\r
58  * task checks that all the standard demo tasks are not only still executing,\r
59  * but are executing without reporting any errors.  If the check task discovers\r
60  * that a task has either stalled, or reported an error, then it changes its own\r
61  * execution period from the initial three seconds, to just 200ms.  The check\r
62  * task also toggles an LED on each iteration of its loop.  This provides a\r
63  * visual indication of the system status:  If the LED toggles every three\r
64  * seconds, then no issues have been discovered.  If the LED toggles every\r
65  * 200ms, then an issue has been discovered with at least one task.\r
66  */\r
67 \r
68 /* Standard includes. */\r
69 #include <stdio.h>\r
70 \r
71 /* Kernel includes. */\r
72 #include "FreeRTOS.h"\r
73 #include "task.h"\r
74 #include "timers.h"\r
75 #include "semphr.h"\r
76 \r
77 /* Standard demo application includes. */\r
78 #include "flop.h"\r
79 #include "semtest.h"\r
80 #include "dynamic.h"\r
81 #include "BlockQ.h"\r
82 #include "blocktim.h"\r
83 #include "countsem.h"\r
84 #include "GenQTest.h"\r
85 #include "recmutex.h"\r
86 #include "death.h"\r
87 #include "partest.h"\r
88 #include "comtest2.h"\r
89 #include "serial.h"\r
90 #include "TimerDemo.h"\r
91 #include "QueueOverwrite.h"\r
92 #include "IntQueue.h"\r
93 #include "EventGroupsDemo.h"\r
94 #include "TaskNotify.h"\r
95 #include "IntSemTest.h"\r
96 \r
97 /* Renesas includes. */\r
98 #include "rskrx231def.h"\r
99 \r
100 /* Priorities for the demo application tasks. */\r
101 #define mainSEM_TEST_PRIORITY                           ( tskIDLE_PRIORITY + 1UL )\r
102 #define mainBLOCK_Q_PRIORITY                            ( tskIDLE_PRIORITY + 2UL )\r
103 #define mainCREATOR_TASK_PRIORITY                       ( tskIDLE_PRIORITY + 3UL )\r
104 #define mainFLOP_TASK_PRIORITY                          ( tskIDLE_PRIORITY )\r
105 #define mainUART_COMMAND_CONSOLE_STACK_SIZE     ( configMINIMAL_STACK_SIZE * 3UL )\r
106 #define mainCHECK_TASK_PRIORITY                         ( configMAX_PRIORITIES - 1 )\r
107 #define mainQUEUE_OVERWRITE_PRIORITY            ( tskIDLE_PRIORITY )\r
108 \r
109 /* The period of the check task, in ms, provided no errors have been reported by\r
110 any of the standard demo tasks.  ms are converted to the equivalent in ticks\r
111 using the portTICK_PERIOD_MS constant. */\r
112 #define mainNO_ERROR_CHECK_TASK_PERIOD          pdMS_TO_TICKS( 3000UL )\r
113 \r
114 /* The period of the check task, in ms, if an error has been reported in one of\r
115 the standard demo tasks.  ms are converted to the equivalent in ticks using the\r
116 portTICK_PERIOD_MS constant. */\r
117 #define mainERROR_CHECK_TASK_PERIOD             pdMS_TO_TICKS( 200UL )\r
118 \r
119 /* Parameters that are passed into the register check tasks solely for the\r
120 purpose of ensuring parameters are passed into tasks correctly. */\r
121 #define mainREG_TEST_1_PARAMETER        ( ( void * ) 0x12121212UL )\r
122 #define mainREG_TEST_2_PARAMETER        ( ( void * ) 0x12345678UL )\r
123 \r
124 /* The base period used by the timer test tasks. */\r
125 #define mainTIMER_TEST_PERIOD                           ( 50 )\r
126 \r
127 /*-----------------------------------------------------------*/\r
128 \r
129 /*\r
130  * Entry point for the comprehensive demo (as opposed to the simple blinky\r
131  * demo).\r
132  */\r
133 void main_full( void );\r
134 \r
135 /*\r
136  * The full demo includes some functionality called from the tick hook.\r
137  */\r
138 void vFullDemoTickHook( void );\r
139 \r
140  /*\r
141  * The check task, as described at the top of this file.\r
142  */\r
143 static void prvCheckTask( void *pvParameters );\r
144 \r
145 /*\r
146  * Register check tasks, and the tasks used to write over and check the contents\r
147  * of the registers, as described at the top of this file.  The nature of these\r
148  * files necessitates that they are written in assembly, but the entry points\r
149  * are kept in the C file for the convenience of checking the task parameter.\r
150  */\r
151 static void prvRegTest1Task( void *pvParameters );\r
152 static void prvRegTest2Task( void *pvParameters );\r
153 static void prvRegTest1Implementation( void );\r
154 static void prvRegTest2Implementation( void );\r
155 \r
156 /*\r
157  * A high priority task that does nothing other than execute at a pseudo random\r
158  * time to ensure the other test tasks don't just execute in a repeating\r
159  * pattern.\r
160  */\r
161 static void prvPseudoRandomiser( void *pvParameters );\r
162 \r
163 /*-----------------------------------------------------------*/\r
164 \r
165 /* The following two variables are used to communicate the status of the\r
166 register check tasks to the check task.  If the variables keep incrementing,\r
167 then the register check tasks have not discovered any errors.  If a variable\r
168 stops incrementing, then an error has been found. */\r
169 volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;\r
170 \r
171 /*-----------------------------------------------------------*/\r
172 \r
173 void main_full( void )\r
174 {\r
175         /* Start all the other standard demo/test tasks.  They have no particular\r
176         functionality, but do demonstrate how to use the FreeRTOS API and test the\r
177         kernel port. */\r
178         vStartInterruptQueueTasks();\r
179         vStartDynamicPriorityTasks();\r
180         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
181         vCreateBlockTimeTasks();\r
182         vStartCountingSemaphoreTasks();\r
183         vStartGenericQueueTasks( tskIDLE_PRIORITY );\r
184         vStartRecursiveMutexTasks();\r
185         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
186         vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
187         vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
188         vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );\r
189         vStartEventGroupTasks();\r
190         vStartTaskNotifyTask();\r
191         vStartInterruptSemaphoreTasks();\r
192 \r
193         /* Create the register check tasks, as described at the top of this     file */\r
194         xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
195         xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
196 \r
197         /* Create the task that just adds a little random behaviour. */\r
198         xTaskCreate( prvPseudoRandomiser, "Rnd", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );\r
199 \r
200         /* Create the task that performs the 'check' functionality,     as described at\r
201         the top of this file. */\r
202         xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
203 \r
204         /* The set of tasks created by the following function call have to be\r
205         created last as they keep account of the number of tasks they expect to see\r
206         running. */\r
207         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
208 \r
209         /* Start the scheduler. */\r
210         vTaskStartScheduler();\r
211 \r
212         /* If all is well, the scheduler will now be running, and the following\r
213         line will never be reached.  If the following line does execute, then\r
214         there was insufficient FreeRTOS heap memory available for the Idle and/or\r
215         timer tasks to be created.  See the memory management section on the\r
216         FreeRTOS web site for more details on the FreeRTOS heap\r
217         http://www.freertos.org/a00111.html. */\r
218         for( ;; );\r
219 }\r
220 /*-----------------------------------------------------------*/\r
221 \r
222 static void prvCheckTask( void *pvParameters )\r
223 {\r
224 TickType_t xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD;\r
225 TickType_t xLastExecutionTime;\r
226 static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;\r
227 unsigned long ulErrorFound = pdFALSE;\r
228 \r
229         /* Just to stop compiler warnings. */\r
230         ( void ) pvParameters;\r
231 \r
232         /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()\r
233         works correctly. */\r
234         xLastExecutionTime = xTaskGetTickCount();\r
235 \r
236         /* Cycle for ever, delaying then checking all the other tasks are still\r
237         operating without error.  The onboard LED is toggled on each iteration.\r
238         If an error is detected then the delay period is decreased from\r
239         mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD.  This has the\r
240         effect of increasing the rate at which the onboard LED toggles, and in so\r
241         doing gives visual feedback of the system status. */\r
242         for( ;; )\r
243         {\r
244                 /* Delay until it is time to execute again. */\r
245                 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );\r
246 \r
247                 /* Check all the demo tasks (other than the flash tasks) to ensure\r
248                 that they are all still running, and that none have detected an error. */\r
249                 if( xAreIntQueueTasksStillRunning() != pdTRUE )\r
250                 {\r
251                         ulErrorFound |= 1UL << 0UL;\r
252                 }\r
253 \r
254                 if( xAreMathsTaskStillRunning() != pdTRUE )\r
255                 {\r
256                         ulErrorFound |= 1UL << 1UL;\r
257                 }\r
258 \r
259                 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
260                 {\r
261                         ulErrorFound |= 1UL << 2UL;\r
262                 }\r
263 \r
264                 if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
265                 {\r
266                         ulErrorFound |= 1UL << 3UL;\r
267                 }\r
268 \r
269                 if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
270                 {\r
271                         ulErrorFound |= 1UL << 4UL;\r
272                 }\r
273 \r
274                 if ( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
275                 {\r
276                         ulErrorFound |= 1UL << 5UL;\r
277                 }\r
278 \r
279                 if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
280                 {\r
281                         ulErrorFound |= 1UL << 6UL;\r
282                 }\r
283 \r
284                 if( xIsCreateTaskStillRunning() != pdTRUE )\r
285                 {\r
286                         ulErrorFound |= 1UL << 7UL;\r
287                 }\r
288 \r
289                 if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
290                 {\r
291                         ulErrorFound |= 1UL << 8UL;\r
292                 }\r
293 \r
294                 if( xAreTimerDemoTasksStillRunning( ( TickType_t ) mainNO_ERROR_CHECK_TASK_PERIOD ) != pdPASS )\r
295                 {\r
296                         ulErrorFound |= 1UL << 9UL;\r
297                 }\r
298 \r
299                 if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
300                 {\r
301                         ulErrorFound |= 1UL << 10UL;\r
302                 }\r
303 \r
304                 if( xIsQueueOverwriteTaskStillRunning() != pdPASS )\r
305                 {\r
306                         ulErrorFound |= 1UL << 11UL;\r
307                 }\r
308 \r
309                 if( xAreEventGroupTasksStillRunning() != pdPASS )\r
310                 {\r
311                         ulErrorFound |= 1UL << 12UL;\r
312                 }\r
313 \r
314                 if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
315                 {\r
316                         ulErrorFound |= 1UL << 13UL;\r
317                 }\r
318 \r
319                 if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
320                 {\r
321                         ulErrorFound |= 1UL << 14UL;\r
322                 }\r
323 \r
324                 /* Check that the register test 1 task is still running. */\r
325                 if( ulLastRegTest1Value == ulRegTest1LoopCounter )\r
326                 {\r
327                         ulErrorFound |= 1UL << 15UL;\r
328                 }\r
329                 ulLastRegTest1Value = ulRegTest1LoopCounter;\r
330 \r
331                 /* Check that the register test 2 task is still running. */\r
332                 if( ulLastRegTest2Value == ulRegTest2LoopCounter )\r
333                 {\r
334                         ulErrorFound |= 1UL << 16UL;\r
335                 }\r
336                 ulLastRegTest2Value = ulRegTest2LoopCounter;\r
337 \r
338                 /* Toggle the check LED to give an indication of the system status.  If\r
339                 the LED toggles every mainNO_ERROR_CHECK_TASK_PERIOD milliseconds then\r
340                 everything is ok.  A faster toggle indicates an error. */\r
341                 LED0 = !LED0;\r
342 \r
343                 if( ulErrorFound != pdFALSE )\r
344                 {\r
345                         /* An error has been detected in one of the tasks - flash the LED\r
346                         at a higher frequency to give visible feedback that something has\r
347                         gone wrong (it might just be that the loop back connector required\r
348                         by the comtest tasks has not been fitted). */\r
349                         xDelayPeriod = mainERROR_CHECK_TASK_PERIOD;\r
350                 }\r
351         }\r
352 }\r
353 /*-----------------------------------------------------------*/\r
354 \r
355 static void prvPseudoRandomiser( void *pvParameters )\r
356 {\r
357 const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL, ulMinDelay = pdMS_TO_TICKS( 35 );\r
358 volatile uint32_t ulNextRand = ( uint32_t ) &pvParameters, ulValue;\r
359 \r
360         /* This task does nothing other than ensure there is a little bit of\r
361         disruption in the scheduling pattern of the other tasks.  Normally this is\r
362         done by generating interrupts at pseudo random times. */\r
363         for( ;; )\r
364         {\r
365                 ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;\r
366                 ulValue = ( ulNextRand >> 16UL ) & 0xffUL;\r
367 \r
368                 if( ulValue < ulMinDelay )\r
369                 {\r
370                         ulValue = ulMinDelay;\r
371                 }\r
372 \r
373                 vTaskDelay( ulValue );\r
374 \r
375                 while( ulValue > 0 )\r
376                 {\r
377                         nop();\r
378                         nop();\r
379                         nop();\r
380                         nop();\r
381                         nop();\r
382                         nop();\r
383                         nop();\r
384                         nop();\r
385 \r
386                         ulValue--;\r
387                 }\r
388         }\r
389 }\r
390 /*-----------------------------------------------------------*/\r
391 \r
392 void vFullDemoTickHook( void )\r
393 {\r
394         /* The full demo includes a software timer demo/test that requires\r
395         prodding periodically from the tick interrupt. */\r
396         vTimerPeriodicISRTests();\r
397 \r
398         /* Call the periodic queue overwrite from ISR demo. */\r
399         vQueueOverwritePeriodicISRDemo();\r
400 \r
401         /* Call the periodic event group from ISR demo. */\r
402         vPeriodicEventGroupsProcessing();\r
403 \r
404         /* Use task notifications from an interrupt. */\r
405         xNotifyTaskFromISR();\r
406 \r
407         /* Use mutexes from interrupts. */\r
408         vInterruptSemaphorePeriodicTest();\r
409 }\r
410 /*-----------------------------------------------------------*/\r
411 \r
412 /* This function is explained in the comments at the top of this file. */\r
413 static void prvRegTest1Task( void *pvParameters )\r
414 {\r
415         if( pvParameters != mainREG_TEST_1_PARAMETER )\r
416         {\r
417                 /* The parameter did not contain the expected value. */\r
418                 for( ;; )\r
419                 {\r
420                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
421                         taskDISABLE_INTERRUPTS();\r
422                 }\r
423         }\r
424 \r
425         /* This is an inline asm function that never returns. */\r
426         prvRegTest1Implementation();\r
427 }\r
428 /*-----------------------------------------------------------*/\r
429 \r
430 /* This function is explained in the comments at the top of this file. */\r
431 static void prvRegTest2Task( void *pvParameters )\r
432 {\r
433         if( pvParameters != mainREG_TEST_2_PARAMETER )\r
434         {\r
435                 /* The parameter did not contain the expected value. */\r
436                 for( ;; )\r
437                 {\r
438                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
439                         taskDISABLE_INTERRUPTS();\r
440                 }\r
441         }\r
442 \r
443         /* This is an inline asm function that never returns. */\r
444         prvRegTest2Implementation();\r
445 }\r
446 /*-----------------------------------------------------------*/\r
447 \r
448 /* This function is explained in the comments at the top of this file. */\r
449 #pragma inline_asm prvRegTest1Implementation\r
450 static void prvRegTest1Implementation( void )\r
451 {\r
452         ; Put a known value in each register.\r
453         MOV.L   #1, R1\r
454         MOV.L   #2, R2\r
455         MOV.L   #3, R3\r
456         MOV.L   #4, R4\r
457         MOV.L   #5, R5\r
458         MOV.L   #6, R6\r
459         MOV.L   #7, R7\r
460         MOV.L   #8, R8\r
461         MOV.L   #9, R9\r
462         MOV.L   #10, R10\r
463         MOV.L   #11, R11\r
464         MOV.L   #12, R12\r
465         MOV.L   #13, R13\r
466         MOV.L   #14, R14\r
467         MOV.L   #15, R15\r
468 \r
469         ; Loop, checking each iteration that each register still contains the\r
470         ; expected value.\r
471 TestLoop1:\r
472 \r
473         ; Push the registers that are going to get clobbered.\r
474         PUSHM   R14-R15\r
475 \r
476         ; Increment the loop counter to show this task is still getting CPU time.\r
477         MOV.L   #_ulRegTest1LoopCounter, R14\r
478         MOV.L   [ R14 ], R15\r
479         ADD             #1, R15\r
480         MOV.L   R15, [ R14 ]\r
481 \r
482         ; Yield to extend the text coverage.  Set the bit in the ITU SWINTR register.\r
483         MOV.L   #1, R14\r
484         MOV.L   #0872E0H, R15\r
485         MOV.B   R14, [R15]\r
486         NOP\r
487         NOP\r
488 \r
489         ; Restore the clobbered registers.\r
490         POPM    R14-R15\r
491 \r
492         ; Now compare each register to ensure it still contains the value that was\r
493         ; set before this loop was entered.\r
494         CMP             #1, R1\r
495         BNE             RegTest1Error\r
496         CMP             #2, R2\r
497         BNE             RegTest1Error\r
498         CMP             #3, R3\r
499         BNE             RegTest1Error\r
500         CMP             #4, R4\r
501         BNE             RegTest1Error\r
502         CMP             #5, R5\r
503         BNE             RegTest1Error\r
504         CMP             #6, R6\r
505         BNE             RegTest1Error\r
506         CMP             #7, R7\r
507         BNE             RegTest1Error\r
508         CMP             #8, R8\r
509         BNE             RegTest1Error\r
510         CMP             #9, R9\r
511         BNE             RegTest1Error\r
512         CMP             #10, R10\r
513         BNE             RegTest1Error\r
514         CMP             #11, R11\r
515         BNE             RegTest1Error\r
516         CMP             #12, R12\r
517         BNE             RegTest1Error\r
518         CMP             #13, R13\r
519         BNE             RegTest1Error\r
520         CMP             #14, R14\r
521         BNE             RegTest1Error\r
522         CMP             #15, R15\r
523         BNE             RegTest1Error\r
524 \r
525         ; All comparisons passed, start a new itteratio of this loop.\r
526         BRA             TestLoop1\r
527 \r
528 RegTest1Error:\r
529         ; A compare failed, just loop here so the loop counter stops incrementing\r
530         ; causing the check task to indicate the error.\r
531         BRA RegTest1Error\r
532 }\r
533 /*-----------------------------------------------------------*/\r
534 \r
535 /* This function is explained in the comments at the top of this file. */\r
536 #pragma inline_asm prvRegTest2Implementation\r
537 static void prvRegTest2Implementation( void )\r
538 {\r
539         ; Put a known value in each register.\r
540         MOV.L   #10, R1\r
541         MOV.L   #20, R2\r
542         MOV.L   #30, R3\r
543         MOV.L   #40, R4\r
544         MOV.L   #50, R5\r
545         MOV.L   #60, R6\r
546         MOV.L   #70, R7\r
547         MOV.L   #80, R8\r
548         MOV.L   #90, R9\r
549         MOV.L   #100, R10\r
550         MOV.L   #110, R11\r
551         MOV.L   #120, R12\r
552         MOV.L   #130, R13\r
553         MOV.L   #140, R14\r
554         MOV.L   #150, R15\r
555 \r
556         ; Loop, checking on each iteration that each register still contains the\r
557         ; expected value.\r
558 TestLoop2:\r
559 \r
560         ; Push the registers that are going to get clobbered.\r
561         PUSHM   R14-R15\r
562 \r
563         ; Increment the loop counter to show this task is still getting CPU time.\r
564         MOV.L   #_ulRegTest2LoopCounter, R14\r
565         MOV.L   [ R14 ], R15\r
566         ADD             #1, R15\r
567         MOV.L   R15, [ R14 ]\r
568 \r
569         ; Restore the clobbered registers.\r
570         POPM    R14-R15\r
571 \r
572         CMP             #10, R1\r
573         BNE             RegTest2Error\r
574         CMP             #20, R2\r
575         BNE             RegTest2Error\r
576         CMP             #30, R3\r
577         BNE             RegTest2Error\r
578         CMP             #40, R4\r
579         BNE             RegTest2Error\r
580         CMP             #50, R5\r
581         BNE             RegTest2Error\r
582         CMP             #60, R6\r
583         BNE             RegTest2Error\r
584         CMP             #70, R7\r
585         BNE             RegTest2Error\r
586         CMP             #80, R8\r
587         BNE             RegTest2Error\r
588         CMP             #90, R9\r
589         BNE             RegTest2Error\r
590         CMP             #100, R10\r
591         BNE             RegTest2Error\r
592         CMP             #110, R11\r
593         BNE             RegTest2Error\r
594         CMP             #120, R12\r
595         BNE             RegTest2Error\r
596         CMP             #130, R13\r
597         BNE             RegTest2Error\r
598         CMP             #140, R14\r
599         BNE             RegTest2Error\r
600         CMP             #150, R15\r
601         BNE             RegTest2Error\r
602 \r
603         ; All comparisons passed, start a new itteratio of this loop.\r
604         BRA             TestLoop2\r
605 \r
606 RegTest2Error:\r
607         ; A compare failed, just loop here so the loop counter stops incrementing\r
608         ; - causing the check task to indicate the error.\r
609         BRA RegTest2Error\r
610 }\r
611 /*-----------------------------------------------------------*/\r
612 \r
613 \r
614 \r
615 \r