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