]> git.sur5r.net Git - freertos/blob - Demo/RX200_RX210-RSK_Renesas/RTOSDemo/main-full.c
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / RX200_RX210-RSK_Renesas / RTOSDemo / main-full.c
1 /*\r
2     FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.\r
3         \r
4 \r
5     ***************************************************************************\r
6      *                                                                       *\r
7      *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
8      *    Complete, revised, and edited pdf reference manuals are also       *\r
9      *    available.                                                         *\r
10      *                                                                       *\r
11      *    Purchasing FreeRTOS documentation will not only help you, by       *\r
12      *    ensuring you get running as quickly as possible and with an        *\r
13      *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
14      *    the FreeRTOS project to continue with its mission of providing     *\r
15      *    professional grade, cross platform, de facto standard solutions    *\r
16      *    for microcontrollers - completely free of charge!                  *\r
17      *                                                                       *\r
18      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
19      *                                                                       *\r
20      *    Thank you for using FreeRTOS, and thank you for your support!      *\r
21      *                                                                       *\r
22     ***************************************************************************\r
23 \r
24 \r
25     This file is part of the FreeRTOS distribution.\r
26 \r
27     FreeRTOS is free software; you can redistribute it and/or modify it under\r
28     the terms of the GNU General Public License (version 2) as published by the\r
29     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
30     >>>NOTE<<< The modification to the GPL is included to allow you to\r
31     distribute a combined work that includes FreeRTOS without being obliged to\r
32     provide the source code for proprietary components outside of the FreeRTOS\r
33     kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
34     WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
35     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
36     more details. You should have received a copy of the GNU General Public\r
37     License and the FreeRTOS license exception along with FreeRTOS; if not it\r
38     can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
39     by writing to Richard Barry, contact details for whom are available on the\r
40     FreeRTOS WEB site.\r
41 \r
42     1 tab == 4 spaces!\r
43     \r
44     ***************************************************************************\r
45      *                                                                       *\r
46      *    Having a problem?  Start by reading the FAQ "My application does   *\r
47      *    not run, what could be wrong?                                      *\r
48      *                                                                       *\r
49      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
50      *                                                                       *\r
51     ***************************************************************************\r
52 \r
53     \r
54     http://www.FreeRTOS.org - Documentation, training, latest information, \r
55     license and contact details.\r
56     \r
57     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
58     including FreeRTOS+Trace - an indispensable productivity tool.\r
59 \r
60     Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
61     the code with commercial support, indemnification, and middleware, under \r
62     the OpenRTOS brand: http://www.OpenRTOS.com.  High Integrity Systems also\r
63     provide a safety engineered and independently SIL3 certified version under \r
64     the SafeRTOS brand: http://www.SafeRTOS.com.\r
65 */\r
66 \r
67 /* ****************************************************************************\r
68  * This project includes a lot of tasks and tests and is therefore complex.\r
69  * If you would prefer a much simpler project to get started with then select\r
70  * the 'Blinky' build configuration within the HEW IDE.  The Blinky build\r
71  * configuration uses main-blinky.c instead of main-full.c.\r
72  * ****************************************************************************\r
73  *\r
74  * Creates all the demo application tasks, then starts the scheduler.  The web\r
75  * documentation provides more details of the standard demo application tasks,\r
76  * which provide no particular functionality but do provide a good example of\r
77  * how to use the FreeRTOS API.\r
78  *\r
79  * In addition to the standard demo tasks, the following tasks and tests are\r
80  * defined and/or created within this file:\r
81  *\r
82  * "Reg test" tasks - These fill the registers with known values, then \r
83  * repeatedly check that each register still contains its expected value for \r
84  * the lifetime of the tasks.  Each task uses different values.  The tasks run \r
85  * with very low priority so get preempted very frequently.  A check variable \r
86  * is incremented on each iteration of the test loop.  A register containing an \r
87  * unexpected value is indicative of an error in the context switching \r
88  * mechanism and will result in a branch to a null loop - which in turn will \r
89  * prevent the check variable from incrementing any further and allow the check \r
90  * timer (described below) to determine that an error has occurred.  The nature \r
91  * of the reg test tasks necessitates that they are written in assembly code.\r
92  *\r
93  * "Check Timer" and Callback Function - The check timer period is initially \r
94  * set to five seconds.  The check timer callback function checks that all the \r
95  * standard demo tasks are not only still executing, but are executing without \r
96  * reporting any errors.  If the check timer discovers that a task has either \r
97  * stalled, or reported an error, then it changes its own period from the \r
98  * initial five seconds, to just 200ms.  The check timer callback function \r
99  * also toggles LED 3 each time it is called.  This provides a visual \r
100  * indication of the system status:  If the LED toggles every five seconds, \r
101  * then no issues have been discovered.  If the LED toggles every 200ms, then \r
102  * an issue has been discovered with at least one task.\r
103  *\r
104  * "High frequency timer test" - A high frequency periodic interrupt is\r
105  * generated using a timer - the interrupt is assigned a priority above\r
106  * configMAX_SYSCALL_INTERRUPT_PRIORITY, so will not be effected by anything\r
107  * the kernel is doing.  The frequency and priority of the interrupt, in\r
108  * combination with other standard tests executed in this demo, will result\r
109  * in interrupts nesting at least 3 and probably 4 deep.  This test is only\r
110  * included in build configurations that have the optimiser switched on.\r
111  *\r
112  * "Button and LCD test" - This creates two tasks.  The first simply scrolls\r
113  * a message back and forth along the top line of the LCD display.  If no\r
114  * buttons are pushed, the second also scrolls a message back and forth, but\r
115  * along the bottom line of the display.  The automatic scrolling of the second\r
116  * line of the display can be started and stopped using button SW2.  Once \r
117  * stopped it can then be manually nudged left using button SW3, and manually\r
118  * nudged right using button SW1.  Button pushes generate an interrupt, and the\r
119  * interrupt communicates with the task using a queue.\r
120  *\r
121  * *NOTE 1* vApplicationSetupTimerInterrupt() is called by the kernel to let\r
122  * the application set up a timer to generate the tick interrupt.  In this\r
123  * example a compare match timer is used for this purpose.\r
124  *\r
125  * *NOTE 2* The CPU must be in Supervisor mode when the scheduler is started.\r
126  * The PowerON_Reset_PC() supplied in resetprg.c with this demo has\r
127  * Change_PSW_PM_to_UserMode() commented out to ensure this is the case.\r
128  *\r
129  * *NOTE 3* The IntQueue common demo tasks test interrupt nesting and make use\r
130  * of all the 8bit timers (as two cascaded 16bit units).\r
131 */\r
132 \r
133 /* Standard includes. */\r
134 #include <string.h>\r
135 \r
136 /* Hardware specific includes. */\r
137 #include "iodefine.h"\r
138 \r
139 /* Kernel includes. */\r
140 #include "FreeRTOS.h"\r
141 #include "task.h"\r
142 #include "timers.h"\r
143 #include "semphr.h"\r
144 \r
145 /* Standard demo includes. */\r
146 #include "partest.h"\r
147 #include "flash.h"\r
148 #include "IntQueue.h"\r
149 #include "BlockQ.h"\r
150 #include "death.h"\r
151 #include "integer.h"\r
152 #include "blocktim.h"\r
153 #include "semtest.h"\r
154 #include "PollQ.h"\r
155 #include "GenQTest.h"\r
156 #include "QPeek.h"\r
157 #include "recmutex.h"\r
158 \r
159 /* Demo specific tasks. */\r
160 #include "ButtonAndLCD.h"\r
161 \r
162 /* Peripheral includes. */\r
163 #include "lcd.h"\r
164 \r
165 /* Values that are passed into the reg test tasks using the task parameter.  \r
166 The tasks check that the values are passed in correctly. */\r
167 #define mainREG_TEST_1_PARAMETER        ( 0x12121212UL )\r
168 #define mainREG_TEST_2_PARAMETER        ( 0x12345678UL )\r
169 \r
170 /* Priorities at which the tasks are created. */\r
171 #define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
172 #define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )\r
173 #define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )\r
174 #define mainCREATOR_TASK_PRIORITY   ( tskIDLE_PRIORITY + 3 )\r
175 #define mainFLASH_TASK_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
176 #define mainINTEGER_TASK_PRIORITY   ( tskIDLE_PRIORITY )\r
177 #define mainGEN_QUEUE_TASK_PRIORITY     ( tskIDLE_PRIORITY )\r
178 #define mainFLOP_TASK_PRIORITY          ( tskIDLE_PRIORITY )\r
179 \r
180 /* The LED toggled by the check timer. */\r
181 #define mainCHECK_LED                           ( 3 )\r
182 \r
183 /* The period at which the check timer will expire, in ms, provided no errors\r
184 have been reported by any of the standard demo tasks.  ms are converted to the\r
185 equivalent in ticks using the portTICK_RATE_MS constant. */\r
186 #define mainCHECK_TIMER_PERIOD_MS                       ( 5000UL / portTICK_RATE_MS )\r
187 \r
188 /* The period at which the check timer will expire, in ms, if an error has been\r
189 reported in one of the standard demo tasks.  ms are converted to the equivalent\r
190 in ticks using the portTICK_RATE_MS constant. */\r
191 #define mainERROR_CHECK_TIMER_PERIOD_MS         ( 200UL / portTICK_RATE_MS )\r
192 \r
193 /* A block time of zero simple means "Don't Block". */\r
194 #define mainDONT_BLOCK                          ( 0UL )\r
195 \r
196 /*\r
197  * vApplicationMallocFailedHook() will only be called if\r
198  * configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook\r
199  * function that will execute if a call to pvPortMalloc() fails.\r
200  * pvPortMalloc() is called internally by the kernel whenever a task, queue or\r
201  * semaphore is created.  It is also called by various parts of the demo\r
202  * application.\r
203  */\r
204 void vApplicationMallocFailedHook( void );\r
205 \r
206 /*\r
207  * vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1\r
208  * in FreeRTOSConfig.h.  It is a hook function that is called on each iteration\r
209  * of the idle task.  It is essential that code added to this hook function\r
210  * never attempts to block in any way (for example, call xQueueReceive() with\r
211  * a block time specified).  If the application makes use of the vTaskDelete()\r
212  * API function (as this demo application does) then it is also important that\r
213  * vApplicationIdleHook() is permitted to return to its calling function because\r
214  * it is the responsibility of the idle task to clean up memory allocated by the\r
215  * kernel to any task that has since been deleted.\r
216  */\r
217 void vApplicationIdleHook( void );\r
218 \r
219 /*\r
220  * vApplicationStackOverflowHook() will only be called if\r
221  * configCHECK_FOR_STACK_OVERFLOW is set to a non-zero value.  The handle and\r
222  * name of the offending task should be passed in the function parameters, but\r
223  * it is possible that the stack overflow will have corrupted these - in which\r
224  * case pxCurrentTCB can be inspected to find the same information.\r
225  */\r
226 void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName );\r
227 \r
228 /*\r
229  * The reg test tasks as described at the top of this file.\r
230  */\r
231 static void prvRegTest1Task( void *pvParameters );\r
232 static void prvRegTest2Task( void *pvParameters );\r
233 \r
234 /*\r
235  * The actual implementation of the reg test functionality, which, because of\r
236  * the direct register access, have to be in assembly.\r
237  */\r
238 static void prvRegTest1Implementation( void );\r
239 static void prvRegTest2Implementation( void );\r
240 \r
241 /*\r
242  * The check timer callback function, as described at the top of this file.\r
243  */\r
244 static void prvCheckTimerCallback( xTimerHandle xTimer );\r
245 \r
246 \r
247 /*-----------------------------------------------------------*/\r
248 \r
249 /* Variables that are incremented on each iteration of the reg test tasks -\r
250 provided the tasks have not reported any errors.  The check timer inspects these\r
251 variables to ensure they are still incrementing as expected.  If a variable\r
252 stops incrementing then it is likely that its associate task has stalled. */\r
253 unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;\r
254 \r
255 /* The check timer.  This uses prvCheckTimerCallback() as its callback\r
256 function. */\r
257 static xTimerHandle xCheckTimer = NULL;\r
258 \r
259 /*-----------------------------------------------------------*/\r
260 \r
261 void main(void)\r
262 {\r
263 extern void HardwareSetup( void );\r
264 \r
265         /* Renesas provided CPU configuration routine.  The clocks are configured in\r
266         here. */\r
267         HardwareSetup();        \r
268 \r
269         /* Turn all LEDs off. */\r
270         vParTestInitialise();\r
271 \r
272         /* Start the reg test tasks which test the context switching mechanism. */\r
273         xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
274         xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
275 \r
276         /* The button and LCD tasks, as described at the top of this file. */\r
277         vStartButtonAndLCDDemo();\r
278 \r
279         /* Create the standard demo tasks. */\r
280         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
281         vCreateBlockTimeTasks();\r
282         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
283         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
284         vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );\r
285         vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );\r
286         vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );\r
287         vStartQueuePeekTasks();\r
288         vStartRecursiveMutexTasks();\r
289         vStartInterruptQueueTasks();\r
290 \r
291         /* The suicide tasks must be created last as they need to know how many\r
292         tasks were running prior to their creation in order to ascertain whether\r
293         or not the correct/expected number of tasks are running at any given time. */\r
294         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
295 \r
296         /* Create the software timer that performs the 'check' functionality,\r
297         as described at the top of this file. */\r
298         xCheckTimer = xTimerCreate( ( const signed char * ) "CheckTimer",/* A text name, purely to help debugging. */\r
299                                                                 ( mainCHECK_TIMER_PERIOD_MS ),          /* The timer period, in this case 5000ms (5s). */\r
300                                                                 pdTRUE,                                                         /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
301                                                                 ( void * ) 0,                                           /* The ID is not used, so can be set to anything. */\r
302                                                                 prvCheckTimerCallback                           /* The callback function that inspects the status of all the other tasks. */\r
303                                                           );\r
304                                                           \r
305         configASSERT( xCheckTimer );\r
306         \r
307         /* Start the check timer.  It will actually start when the scheduler is\r
308         started. */\r
309         xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
310 \r
311         /* Start the tasks running. */\r
312         vTaskStartScheduler();\r
313 \r
314         /* If all is well we will never reach here as the scheduler will now be\r
315         running.  If we do reach here then it is likely that there was insufficient\r
316         heap available for the idle task to be created. */\r
317         for( ;; );\r
318 }\r
319 /*-----------------------------------------------------------*/\r
320 \r
321 static void prvCheckTimerCallback( xTimerHandle xTimer )\r
322 {\r
323 static long lChangedTimerPeriodAlready = pdFALSE, lErrorStatus = pdPASS;\r
324 static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL;\r
325 \r
326         /* Check the standard demo tasks are running without error. */\r
327         if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
328         {\r
329                 lErrorStatus = pdFAIL;\r
330         }\r
331         else if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
332         {\r
333                 lErrorStatus = pdFAIL;\r
334         }\r
335         else if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
336         {\r
337                 lErrorStatus = pdFAIL;\r
338         }\r
339         else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
340         {\r
341                 lErrorStatus = pdFAIL;\r
342         }\r
343         else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
344         {\r
345                 lErrorStatus = pdFAIL;\r
346         }\r
347         else if( xArePollingQueuesStillRunning() != pdTRUE )\r
348         {\r
349                 lErrorStatus = pdFAIL;\r
350         }\r
351         else if( xIsCreateTaskStillRunning() != pdTRUE )\r
352         {\r
353                 lErrorStatus = pdFAIL;\r
354         }\r
355         else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
356         {\r
357                 lErrorStatus = pdFAIL;\r
358         }\r
359         else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
360         {\r
361                 lErrorStatus = pdFAIL;\r
362         }\r
363         else if( xAreIntQueueTasksStillRunning() != pdPASS )\r
364         {\r
365                 lErrorStatus = pdFAIL;\r
366         }\r
367 \r
368         /* Check the reg test tasks are still cycling.  They will stop incrementing\r
369         their loop counters if they encounter an error. */\r
370         if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )\r
371         {\r
372                 lErrorStatus = pdFAIL;\r
373         }\r
374 \r
375         if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )\r
376         {\r
377                 lErrorStatus = pdFAIL;\r
378         }\r
379 \r
380         ulLastRegTest1CycleCount = ulRegTest1CycleCount;\r
381         ulLastRegTest2CycleCount = ulRegTest2CycleCount;\r
382 \r
383         /* Toggle the check LED to give an indication of the system status.  If\r
384         the LED toggles every 5 seconds then everything is ok.  A faster toggle\r
385         indicates an error. */\r
386         vParTestToggleLED( mainCHECK_LED );\r
387         \r
388         /* Was an error detected this time through the callback execution? */\r
389         if( lErrorStatus != pdPASS )\r
390         {\r
391                 if( lChangedTimerPeriodAlready == pdFALSE )\r
392                 {\r
393                         lChangedTimerPeriodAlready = pdTRUE;\r
394                         \r
395                         /* This call to xTimerChangePeriod() uses a zero block time.  \r
396                         Functions called from inside of a timer callback function must \r
397                         *never* attempt to block. */\r
398                         xTimerChangePeriod( xCheckTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );\r
399                 }\r
400         }\r
401 }\r
402 /*-----------------------------------------------------------*/\r
403 \r
404 /* The RX port uses this callback function to configure its tick interrupt.\r
405 This allows the application to choose the tick interrupt source. */\r
406 void vApplicationSetupTimerInterrupt( void )\r
407 {\r
408         /* Enable compare match timer 0. */\r
409         MSTP( CMT0 ) = 0;\r
410 \r
411         /* Interrupt on compare match. */\r
412         CMT0.CMCR.BIT.CMIE = 1;\r
413 \r
414         /* Set the compare match value. */\r
415         CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 );\r
416 \r
417         /* Divide the PCLK by 8. */\r
418         CMT0.CMCR.BIT.CKS = 0;\r
419 \r
420         /* Enable the interrupt... */\r
421         _IEN( _CMT0_CMI0 ) = 1;\r
422 \r
423         /* ...and set its priority to the application defined kernel priority. */\r
424         _IPR( _CMT0_CMI0 ) = configKERNEL_INTERRUPT_PRIORITY;\r
425 \r
426         /* Start the timer. */\r
427         CMT.CMSTR0.BIT.STR0 = 1;\r
428 }\r
429 /*-----------------------------------------------------------*/\r
430 \r
431 /* This function is explained by the comments above its prototype at the top\r
432 of this file. */\r
433 void vApplicationMallocFailedHook( void )\r
434 {\r
435         for( ;; );\r
436 }\r
437 /*-----------------------------------------------------------*/\r
438 \r
439 /* This function is explained by the comments above its prototype at the top\r
440 of this file. */\r
441 void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )\r
442 {\r
443         for( ;; );\r
444 }\r
445 /*-----------------------------------------------------------*/\r
446 \r
447 /* This function is explained by the comments above its prototype at the top\r
448 of this file. */\r
449 void vApplicationIdleHook( void )\r
450 {\r
451         /* If this is being executed then the kernel has been started.  Start the high\r
452         frequency timer test as described at the top of this file.  This is only\r
453         included in the optimised build configuration - otherwise it takes up too much\r
454         CPU time and can disrupt other tests. */\r
455         #ifdef INCLUDE_HIGH_FREQUENCY_TIMER_TEST\r
456         static portBASE_TYPE xTimerTestStarted = pdFALSE;\r
457         extern void vSetupHighFrequencyTimer( void );\r
458                 if( xTimerTestStarted == pdFALSE )\r
459                 {\r
460                         vSetupHighFrequencyTimer();\r
461                         xTimerTestStarted = pdTRUE;\r
462                 }\r
463         #endif\r
464 }\r
465 /*-----------------------------------------------------------*/\r
466 \r
467 /* This function is explained in the comments at the top of this file. */\r
468 static void prvRegTest1Task( void *pvParameters )\r
469 {\r
470         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_1_PARAMETER )\r
471         {\r
472                 /* The parameter did not contain the expected value. */\r
473                 for( ;; )\r
474                 {\r
475                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
476                         taskDISABLE_INTERRUPTS();\r
477                 }\r
478         }\r
479 \r
480         /* This is an inline asm function that never returns. */\r
481         prvRegTest1Implementation();\r
482 }\r
483 /*-----------------------------------------------------------*/\r
484 \r
485 /* This function is explained in the comments at the top of this file. */\r
486 static void prvRegTest2Task( void *pvParameters )\r
487 {\r
488         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_2_PARAMETER )\r
489         {\r
490                 /* The parameter did not contain the expected value. */\r
491                 for( ;; )\r
492                 {\r
493                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
494                         taskDISABLE_INTERRUPTS();\r
495                 }\r
496         }\r
497 \r
498         /* This is an inline asm function that never returns. */\r
499         prvRegTest2Implementation();\r
500 }\r
501 /*-----------------------------------------------------------*/\r
502 \r
503 /* This function is explained in the comments at the top of this file. */\r
504 #pragma inline_asm prvRegTest1Implementation\r
505 static void prvRegTest1Implementation( void )\r
506 {\r
507         ; Put a known value in each register.\r
508         MOV.L   #1, R1\r
509         MOV.L   #2, R2\r
510         MOV.L   #3, R3\r
511         MOV.L   #4, R4\r
512         MOV.L   #5, R5\r
513         MOV.L   #6, R6\r
514         MOV.L   #7, R7\r
515         MOV.L   #8, R8\r
516         MOV.L   #9, R9\r
517         MOV.L   #10, R10\r
518         MOV.L   #11, R11\r
519         MOV.L   #12, R12\r
520         MOV.L   #13, R13\r
521         MOV.L   #14, R14\r
522         MOV.L   #15, R15\r
523 \r
524         ; Loop, checking each itteration that each register still contains the\r
525         ; expected value.\r
526 TestLoop1:\r
527 \r
528         ; Push the registers that are going to get clobbered.\r
529         PUSHM   R14-R15\r
530 \r
531         ; Increment the loop counter to show this task is still getting CPU time.\r
532         MOV.L   #_ulRegTest1CycleCount, R14\r
533         MOV.L   [ R14 ], R15\r
534         ADD             #1, R15\r
535         MOV.L   R15, [ R14 ]\r
536 \r
537         ; Yield to extend the text coverage.  Set the bit in the ITU SWINTR register.\r
538         MOV.L   #1, R14\r
539         MOV.L   #0872E0H, R15\r
540         MOV.B   R14, [R15]\r
541         NOP\r
542         NOP\r
543 \r
544         ; Restore the clobbered registers.\r
545         POPM    R14-R15\r
546 \r
547         ; Now compare each register to ensure it still contains the value that was\r
548         ; set before this loop was entered.\r
549         CMP             #1, R1\r
550         BNE             RegTest1Error\r
551         CMP             #2, R2\r
552         BNE             RegTest1Error\r
553         CMP             #3, R3\r
554         BNE             RegTest1Error\r
555         CMP             #4, R4\r
556         BNE             RegTest1Error\r
557         CMP             #5, R5\r
558         BNE             RegTest1Error\r
559         CMP             #6, R6\r
560         BNE             RegTest1Error\r
561         CMP             #7, R7\r
562         BNE             RegTest1Error\r
563         CMP             #8, R8\r
564         BNE             RegTest1Error\r
565         CMP             #9, R9\r
566         BNE             RegTest1Error\r
567         CMP             #10, R10\r
568         BNE             RegTest1Error\r
569         CMP             #11, R11\r
570         BNE             RegTest1Error\r
571         CMP             #12, R12\r
572         BNE             RegTest1Error\r
573         CMP             #13, R13\r
574         BNE             RegTest1Error\r
575         CMP             #14, R14\r
576         BNE             RegTest1Error\r
577         CMP             #15, R15\r
578         BNE             RegTest1Error\r
579 \r
580         ; All comparisons passed, start a new itteratio of this loop.\r
581         BRA             TestLoop1\r
582 \r
583 RegTest1Error:\r
584         ; A compare failed, just loop here so the loop counter stops incrementing\r
585         ; causing the check timer to indicate the error.\r
586         BRA RegTest1Error\r
587 }\r
588 /*-----------------------------------------------------------*/\r
589 \r
590 /* This function is explained in the comments at the top of this file. */\r
591 #pragma inline_asm prvRegTest2Implementation\r
592 static void prvRegTest2Implementation( void )\r
593 {\r
594         ; Put a known value in each register.\r
595         MOV.L   #10, R1\r
596         MOV.L   #20, R2\r
597         MOV.L   #30, R3\r
598         MOV.L   #40, R4\r
599         MOV.L   #50, R5\r
600         MOV.L   #60, R6\r
601         MOV.L   #70, R7\r
602         MOV.L   #80, R8\r
603         MOV.L   #90, R9\r
604         MOV.L   #100, R10\r
605         MOV.L   #110, R11\r
606         MOV.L   #120, R12\r
607         MOV.L   #130, R13\r
608         MOV.L   #140, R14\r
609         MOV.L   #150, R15\r
610 \r
611         ; Loop, checking on each itteration that each register still contains the\r
612         ; expected value.\r
613 TestLoop2:\r
614 \r
615         ; Push the registers that are going to get clobbered.\r
616         PUSHM   R14-R15\r
617 \r
618         ; Increment the loop counter to show this task is still getting CPU time.\r
619         MOV.L   #_ulRegTest2CycleCount, R14\r
620         MOV.L   [ R14 ], R15\r
621         ADD             #1, R15\r
622         MOV.L   R15, [ R14 ]\r
623 \r
624         ; Restore the clobbered registers.\r
625         POPM    R14-R15\r
626 \r
627         CMP             #10, R1\r
628         BNE             RegTest2Error\r
629         CMP             #20, R2\r
630         BNE             RegTest2Error\r
631         CMP             #30, R3\r
632         BNE             RegTest2Error\r
633         CMP             #40, R4\r
634         BNE             RegTest2Error\r
635         CMP             #50, R5\r
636         BNE             RegTest2Error\r
637         CMP             #60, R6\r
638         BNE             RegTest2Error\r
639         CMP             #70, R7\r
640         BNE             RegTest2Error\r
641         CMP             #80, R8\r
642         BNE             RegTest2Error\r
643         CMP             #90, R9\r
644         BNE             RegTest2Error\r
645         CMP             #100, R10\r
646         BNE             RegTest2Error\r
647         CMP             #110, R11\r
648         BNE             RegTest2Error\r
649         CMP             #120, R12\r
650         BNE             RegTest2Error\r
651         CMP             #130, R13\r
652         BNE             RegTest2Error\r
653         CMP             #140, R14\r
654         BNE             RegTest2Error\r
655         CMP             #150, R15\r
656         BNE             RegTest2Error\r
657 \r
658         ; All comparisons passed, start a new itteratio of this loop.\r
659         BRA             TestLoop2\r
660 \r
661 RegTest2Error:\r
662         ; A compare failed, just loop here so the loop counter stops incrementing\r
663         ; - causing the check timer to indicate the error.\r
664         BRA RegTest2Error\r
665 }\r
666 /*-----------------------------------------------------------*/\r
667 \r