]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RX600_RX62N-RSK_Renesas/RTOSDemo/main-full.c
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS / Demo / RX600_RX62N-RSK_Renesas / RTOSDemo / main-full.c
1 /*\r
2     FreeRTOS V9.0.0rc2 - Copyright (C) 2016 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     This file is part of the FreeRTOS distribution.\r
8 \r
9     FreeRTOS is free software; you can redistribute it and/or modify it under\r
10     the terms of the GNU General Public License (version 2) as published by the\r
11     Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
12 \r
13     ***************************************************************************\r
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
16     >>!   obliged to provide the source code for proprietary components     !<<\r
17     >>!   outside of the FreeRTOS kernel.                                   !<<\r
18     ***************************************************************************\r
19 \r
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
23     link: http://www.freertos.org/a00114.html\r
24 \r
25     ***************************************************************************\r
26      *                                                                       *\r
27      *    FreeRTOS provides completely free yet professionally developed,    *\r
28      *    robust, strictly quality controlled, supported, and cross          *\r
29      *    platform software that is more than just the market leader, it     *\r
30      *    is the industry's de facto standard.                               *\r
31      *                                                                       *\r
32      *    Help yourself get started quickly while simultaneously helping     *\r
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
34      *    tutorial book, reference manual, or both:                          *\r
35      *    http://www.FreeRTOS.org/Documentation                              *\r
36      *                                                                       *\r
37     ***************************************************************************\r
38 \r
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
40     the FAQ page "My application does not run, what could be wrong?".  Have you\r
41     defined configASSERT()?\r
42 \r
43     http://www.FreeRTOS.org/support - In return for receiving this top quality\r
44     embedded software for free we request you assist our global community by\r
45     participating in the support forum.\r
46 \r
47     http://www.FreeRTOS.org/training - Investing in training allows your team to\r
48     be as productive as possible as early as possible.  Now you can receive\r
49     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
50     Ltd, and the world's leading authority on the world's leading RTOS.\r
51 \r
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
55 \r
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
58 \r
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
61     licenses offer ticketed support, indemnification and commercial middleware.\r
62 \r
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
64     engineered and independently SIL3 certified version for use in safety and\r
65     mission critical applications that require provable dependability.\r
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69 \r
70 /* ****************************************************************************\r
71  * This project includes a lot of tasks and tests and is therefore complex.\r
72  * If you would prefer a much simpler project to get started with then select\r
73  * the 'Blinky' build configuration within the HEW IDE.\r
74  * ****************************************************************************\r
75  *\r
76  * Creates all the demo application tasks, then starts the scheduler.  The web\r
77  * documentation provides more details of the standard demo application tasks,\r
78  * which provide no particular functionality but do provide a good example of\r
79  * how to use the FreeRTOS API.  The tasks defined in flop.c are included in the\r
80  * set of standard demo tasks to ensure the floating point unit gets some\r
81  * exercise.\r
82  *\r
83  * In addition to the standard demo tasks, the following tasks and tests are\r
84  * defined and/or created within this file:\r
85  *\r
86  * Webserver ("uIP") task - This serves a number of dynamically generated WEB\r
87  * pages to a standard WEB browser.  The IP and MAC addresses are configured by\r
88  * constants defined at the bottom of FreeRTOSConfig.h.  Use either a standard\r
89  * Ethernet cable to connect through a hug, or a cross over (point to point)\r
90  * cable to connect directly.  Ensure the IP address used is compatible with the\r
91  * IP address of the machine running the browser - the easiest way to achieve\r
92  * this is to ensure the first three octets of the IP addresses are the same.\r
93  *\r
94  * "Reg test" tasks - These fill the registers with known values, then check\r
95  * that each register still contains its expected value.  Each task uses\r
96  * different values.  The tasks run with very low priority so get preempted\r
97  * very frequently.  A check variable is incremented on each iteration of the\r
98  * test loop.  A register containing an unexpected value is indicative of an\r
99  * error in the context switching mechanism and will result in a branch to a\r
100  * null loop - which in turn will prevent the check variable from incrementing\r
101  * any further and allow the check task (described below) to determine that an\r
102  * error has occurred.  The nature of the reg test tasks necessitates that they\r
103  * are written in assembly code.\r
104  *\r
105  * "Check" task - This only executes every five seconds but has a high priority\r
106  * to ensure it gets processor time.  Its main function is to check that all the\r
107  * standard demo tasks are still operational.  While no errors have been\r
108  * discovered the check task will toggle LED 5 every 5 seconds - the toggle\r
109  * rate increasing to 200ms being a visual indication that at least one task has\r
110  * reported unexpected behaviour.\r
111  *\r
112  * "High frequency timer test" - A high frequency periodic interrupt is\r
113  * generated using a timer - the interrupt is assigned a priority above\r
114  * configMAX_SYSCALL_INTERRUPT_PRIORITY so should not be effected by anything\r
115  * the kernel is doing.  The frequency and priority of the interrupt, in\r
116  * combination with other standard tests executed in this demo, should result\r
117  * in interrupts nesting at least 3 and probably 4 deep.  This test is only\r
118  * included in build configurations that have the optimiser switched on.  In\r
119  * optimised builds the count of high frequency ticks is used as the time base\r
120  * for the run time stats.\r
121  *\r
122  * *NOTE 1* If LED5 is toggling every 5 seconds then all the demo application\r
123  * tasks are executing as expected and no errors have been reported in any\r
124  * tasks.  The toggle rate increasing to 200ms indicates that at least one task\r
125  * has reported unexpected behaviour.\r
126  *\r
127  * *NOTE 2* vApplicationSetupTimerInterrupt() is called by the kernel to let\r
128  * the application set up a timer to generate the tick interrupt.  In this\r
129  * example a compare match timer is used for this purpose.\r
130  *\r
131  * *NOTE 3* The CPU must be in Supervisor mode when the scheduler is started.\r
132  * The PowerON_Reset_PC() supplied in resetprg.c with this demo has\r
133  * Change_PSW_PM_to_UserMode() commented out to ensure this is the case.\r
134  *\r
135  * *NOTE 4* The IntQueue common demo tasks test interrupt nesting and make use\r
136  * of all the 8bit timers (as two cascaded 16bit units).\r
137 */\r
138 \r
139 /* Hardware specific includes. */\r
140 #include "iodefine.h"\r
141 \r
142 /* Kernel includes. */\r
143 #include "FreeRTOS.h"\r
144 #include "task.h"\r
145 \r
146 /* Standard demo includes. */\r
147 #include "partest.h"\r
148 #include "flash.h"\r
149 #include "IntQueue.h"\r
150 #include "BlockQ.h"\r
151 #include "death.h"\r
152 #include "integer.h"\r
153 #include "blocktim.h"\r
154 #include "semtest.h"\r
155 #include "PollQ.h"\r
156 #include "GenQTest.h"\r
157 #include "QPeek.h"\r
158 #include "recmutex.h"\r
159 #include "flop.h"\r
160 \r
161 /* Values that are passed into the reg test tasks using the task parameter.  The\r
162 tasks check that the values are passed in correctly. */\r
163 #define mainREG_TEST_1_PARAMETER        ( 0x12121212UL )\r
164 #define mainREG_TEST_2_PARAMETER        ( 0x12345678UL )\r
165 \r
166 /* Priorities at which the tasks are created. */\r
167 #define mainCHECK_TASK_PRIORITY         ( configMAX_PRIORITIES - 1 )\r
168 #define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
169 #define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )\r
170 #define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )\r
171 #define mainCREATOR_TASK_PRIORITY   ( tskIDLE_PRIORITY + 3 )\r
172 #define mainFLASH_TASK_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
173 #define mainuIP_TASK_PRIORITY           ( tskIDLE_PRIORITY + 2 )\r
174 #define mainINTEGER_TASK_PRIORITY   ( tskIDLE_PRIORITY )\r
175 #define mainGEN_QUEUE_TASK_PRIORITY     ( tskIDLE_PRIORITY )\r
176 #define mainFLOP_TASK_PRIORITY          ( tskIDLE_PRIORITY )\r
177 \r
178 /* The WEB server uses string handling functions, which in turn use a bit more\r
179 stack than most of the other tasks. */\r
180 #define mainuIP_STACK_SIZE                      ( configMINIMAL_STACK_SIZE * 3 )\r
181 \r
182 /* The LED toggled by the check task. */\r
183 #define mainCHECK_LED                           ( 5 )\r
184 \r
185 /* The rate at which mainCHECK_LED will toggle when all the tasks are running\r
186 without error.  Controlled by the check task as described at the top of this\r
187 file. */\r
188 #define mainNO_ERROR_CYCLE_TIME         ( 5000 / portTICK_PERIOD_MS )\r
189 \r
190 /* The rate at which mainCHECK_LED will toggle when an error has been reported\r
191 by at least one task.  Controlled by the check task as described at the top of\r
192 this file. */\r
193 #define mainERROR_CYCLE_TIME            ( 200 / portTICK_PERIOD_MS )\r
194 \r
195 /*\r
196  * vApplicationMallocFailedHook() will only be called if\r
197  * configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook\r
198  * function that will execute if a call to pvPortMalloc() fails.\r
199  * pvPortMalloc() is called internally by the kernel whenever a task, queue or\r
200  * semaphore is created.  It is also called by various parts of the demo\r
201  * application.\r
202  */\r
203 void vApplicationMallocFailedHook( void );\r
204 \r
205 /*\r
206  * vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1\r
207  * in FreeRTOSConfig.h.  It is a hook function that is called on each iteration\r
208  * of the idle task.  It is essential that code added to this hook function\r
209  * never attempts to block in any way (for example, call xQueueReceive() with\r
210  * a block time specified).  If the application makes use of the vTaskDelete()\r
211  * API function (as this demo application does) then it is also important that\r
212  * vApplicationIdleHook() is permitted to return to its calling function because\r
213  * it is the responsibility of the idle task to clean up memory allocated by the\r
214  * kernel to any task that has since been deleted.\r
215  */\r
216 void vApplicationIdleHook( void );\r
217 \r
218 /*\r
219  * vApplicationStackOverflowHook() will only be called if\r
220  * configCHECK_FOR_STACK_OVERFLOW is set to a non-zero value.  The handle and\r
221  * name of the offending task should be passed in the function parameters, but\r
222  * it is possible that the stack overflow will have corrupted these - in which\r
223  * case pxCurrentTCB can be inspected to find the same information.\r
224  */\r
225 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );\r
226 \r
227 /*\r
228  * The reg test tasks as described at the top of this file.\r
229  */\r
230 static void prvRegTest1Task( void *pvParameters );\r
231 static void prvRegTest2Task( void *pvParameters );\r
232 \r
233 /*\r
234  * The actual implementation of the reg test functionality, which, because of\r
235  * the direct register access, have to be in assembly.\r
236  */\r
237 static void prvRegTest1Implementation( void );\r
238 static void prvRegTest2Implementation( void );\r
239 \r
240 /*\r
241  * The check task as described at the top of this file.\r
242  */\r
243 static void prvCheckTask( void *pvParameters );\r
244 \r
245 /*\r
246  * Contains the implementation of the WEB server.\r
247  */\r
248 extern void vuIP_Task( void *pvParameters );\r
249 \r
250 /*-----------------------------------------------------------*/\r
251 \r
252 /* Variables that are incremented on each iteration of the reg test tasks -\r
253 provided the tasks have not reported any errors.  The check task inspects these\r
254 variables to ensure they are still incrementing as expected.  If a variable\r
255 stops incrementing then it is likely that its associate task has stalled. */\r
256 unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;\r
257 \r
258 /* The status message that is displayed at the bottom of the "task stats" web\r
259 page, which is served by the uIP task.  This will report any errors picked up\r
260 by the reg test task. */\r
261 const char *pcStatusMessage = "All tasks executing without error.";\r
262 \r
263 /*-----------------------------------------------------------*/\r
264 \r
265 void main(void)\r
266 {\r
267 extern void HardwareSetup( void );\r
268 \r
269         /* Renesas provided CPU configuration routine.  The clocks are configured in\r
270         here. */\r
271         HardwareSetup();\r
272 \r
273         /* Turn all LEDs off. */\r
274         vParTestInitialise();\r
275 \r
276         /* Start the reg test tasks which test the context switching mechanism. */\r
277         xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
278         xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
279 \r
280         /* The web server task. */\r
281         xTaskCreate( vuIP_Task, "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL );\r
282 \r
283         /* Start the check task as described at the top of this file. */\r
284         xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE * 3, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
285 \r
286         /* Create the standard demo tasks. */\r
287         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
288         vCreateBlockTimeTasks();\r
289         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
290         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
291         vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );\r
292         vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );\r
293         vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );\r
294         vStartQueuePeekTasks();\r
295         vStartRecursiveMutexTasks();\r
296         vStartInterruptQueueTasks();\r
297         vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
298 \r
299         /* The suicide tasks must be created last as they need to know how many\r
300         tasks were running prior to their creation in order to ascertain whether\r
301         or not the correct/expected number of tasks are running at any given time. */\r
302         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
303 \r
304         /* Start the tasks running. */\r
305         vTaskStartScheduler();\r
306 \r
307         /* If all is well we will never reach here as the scheduler will now be\r
308         running.  If we do reach here then it is likely that there was insufficient\r
309         heap available for the idle task to be created. */\r
310         for( ;; );\r
311 }\r
312 /*-----------------------------------------------------------*/\r
313 \r
314 static void prvCheckTask( void *pvParameters )\r
315 {\r
316 static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL;\r
317 TickType_t xNextWakeTime, xCycleFrequency = mainNO_ERROR_CYCLE_TIME;\r
318 extern void vSetupHighFrequencyTimer( void );\r
319 \r
320         /* If this is being executed then the kernel has been started.  Start the high\r
321         frequency timer test as described at the top of this file.  This is only\r
322         included in the optimised build configuration - otherwise it takes up too much\r
323         CPU time and can disrupt other tests. */\r
324         #ifdef INCLUDE_HIGH_FREQUENCY_TIMER_TEST\r
325                 vSetupHighFrequencyTimer();\r
326         #endif\r
327 \r
328         /* Initialise xNextWakeTime - this only needs to be done once. */\r
329         xNextWakeTime = xTaskGetTickCount();\r
330 \r
331         for( ;; )\r
332         {\r
333                 /* Place this task in the blocked state until it is time to run again. */\r
334                 vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );\r
335 \r
336                 /* Check the standard demo tasks are running without error. */\r
337                 if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
338                 {\r
339                         /* Increase the rate at which this task cycles, which will increase the\r
340                         rate at which mainCHECK_LED flashes to give visual feedback that an error\r
341                         has occurred. */\r
342                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
343                         pcStatusMessage = "Error: GenQueue";\r
344                 }\r
345                 else if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
346                 {\r
347                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
348                         pcStatusMessage = "Error: QueuePeek";\r
349                 }\r
350                 else if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
351                 {\r
352                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
353                         pcStatusMessage = "Error: BlockQueue";\r
354                 }\r
355                 else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
356                 {\r
357                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
358                         pcStatusMessage = "Error: BlockTime";\r
359                 }\r
360                 else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
361                 {\r
362                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
363                         pcStatusMessage = "Error: SemTest";\r
364                 }\r
365                 else if( xArePollingQueuesStillRunning() != pdTRUE )\r
366                 {\r
367                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
368                         pcStatusMessage = "Error: PollQueue";\r
369                 }\r
370                 else if( xIsCreateTaskStillRunning() != pdTRUE )\r
371                 {\r
372                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
373                         pcStatusMessage = "Error: Death";\r
374                 }\r
375                 else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
376                 {\r
377                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
378                         pcStatusMessage = "Error: IntMath";\r
379                 }\r
380                 else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
381                 {\r
382                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
383                         pcStatusMessage = "Error: RecMutex";\r
384                 }\r
385                 else if( xAreIntQueueTasksStillRunning() != pdPASS )\r
386                 {\r
387                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
388                         pcStatusMessage = "Error: IntQueue";\r
389                 }\r
390                 else if( xAreMathsTaskStillRunning() != pdPASS )\r
391                 {\r
392                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
393                         pcStatusMessage = "Error: Flop";\r
394                 }\r
395 \r
396                 /* Check the reg test tasks are still cycling.  They will stop incrementing\r
397                 their loop counters if they encounter an error. */\r
398                 if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )\r
399                 {\r
400                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
401                         pcStatusMessage = "Error: RegTest1";\r
402                 }\r
403 \r
404                 if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )\r
405                 {\r
406                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
407                         pcStatusMessage = "Error: RegTest2";\r
408                 }\r
409 \r
410                 ulLastRegTest1CycleCount = ulRegTest1CycleCount;\r
411                 ulLastRegTest2CycleCount = ulRegTest2CycleCount;\r
412 \r
413                 /* Toggle the check LED to give an indication of the system status.  If\r
414                 the LED toggles every 5 seconds then everything is ok.  A faster toggle\r
415                 indicates an error. */\r
416                 vParTestToggleLED( mainCHECK_LED );\r
417         }\r
418 }\r
419 /*-----------------------------------------------------------*/\r
420 \r
421 /* The RX port uses this callback function to configure its tick interrupt.\r
422 This allows the application to choose the tick interrupt source. */\r
423 void vApplicationSetupTimerInterrupt( void )\r
424 {\r
425         /* Enable compare match timer 0. */\r
426         MSTP( CMT0 ) = 0;\r
427 \r
428         /* Interrupt on compare match. */\r
429         CMT0.CMCR.BIT.CMIE = 1;\r
430 \r
431         /* Set the compare match value. */\r
432         CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 );\r
433 \r
434         /* Divide the PCLK by 8. */\r
435         CMT0.CMCR.BIT.CKS = 0;\r
436 \r
437         /* Enable the interrupt... */\r
438         _IEN( _CMT0_CMI0 ) = 1;\r
439 \r
440         /* ...and set its priority to the application defined kernel priority. */\r
441         _IPR( _CMT0_CMI0 ) = configKERNEL_INTERRUPT_PRIORITY;\r
442 \r
443         /* Start the timer. */\r
444         CMT.CMSTR0.BIT.STR0 = 1;\r
445 }\r
446 /*-----------------------------------------------------------*/\r
447 \r
448 /* This function is explained by the comments above its prototype at the top\r
449 of this file. */\r
450 void vApplicationMallocFailedHook( void )\r
451 {\r
452         for( ;; );\r
453 }\r
454 /*-----------------------------------------------------------*/\r
455 \r
456 /* This function is explained by the comments above its prototype at the top\r
457 of this file. */\r
458 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )\r
459 {\r
460         for( ;; );\r
461 }\r
462 /*-----------------------------------------------------------*/\r
463 \r
464 /* This function is explained by the comments above its prototype at the top\r
465 of this file. */\r
466 void vApplicationIdleHook( void )\r
467 {\r
468 }\r
469 /*-----------------------------------------------------------*/\r
470 \r
471 /* This function is explained in the comments at the top of this file. */\r
472 static void prvRegTest1Task( void *pvParameters )\r
473 {\r
474         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_1_PARAMETER )\r
475         {\r
476                 /* The parameter did not contain the expected value. */\r
477                 for( ;; )\r
478                 {\r
479                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
480                         taskDISABLE_INTERRUPTS();\r
481                 }\r
482         }\r
483 \r
484         /* This is an inline asm function that never returns. */\r
485         prvRegTest1Implementation();\r
486 }\r
487 /*-----------------------------------------------------------*/\r
488 \r
489 /* This function is explained in the comments at the top of this file. */\r
490 static void prvRegTest2Task( void *pvParameters )\r
491 {\r
492         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_2_PARAMETER )\r
493         {\r
494                 /* The parameter did not contain the expected value. */\r
495                 for( ;; )\r
496                 {\r
497                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
498                         taskDISABLE_INTERRUPTS();\r
499                 }\r
500         }\r
501 \r
502         /* This is an inline asm function that never returns. */\r
503         prvRegTest2Implementation();\r
504 }\r
505 /*-----------------------------------------------------------*/\r
506 \r
507 /* This function is explained in the comments at the top of this file. */\r
508 #pragma inline_asm prvRegTest1Implementation\r
509 static void prvRegTest1Implementation( void )\r
510 {\r
511         ; Put a known value in each register.\r
512         MOV.L   #1, R1\r
513         MOV.L   #2, R2\r
514         MOV.L   #3, R3\r
515         MOV.L   #4, R4\r
516         MOV.L   #5, R5\r
517         MOV.L   #6, R6\r
518         MOV.L   #7, R7\r
519         MOV.L   #8, R8\r
520         MOV.L   #9, R9\r
521         MOV.L   #10, R10\r
522         MOV.L   #11, R11\r
523         MOV.L   #12, R12\r
524         MOV.L   #13, R13\r
525         MOV.L   #14, R14\r
526         MOV.L   #15, R15\r
527 \r
528         ; Loop, checking each iteration that each register still contains the\r
529         ; expected value.\r
530 TestLoop1:\r
531 \r
532         ; Push the registers that are going to get clobbered.\r
533         PUSHM   R14-R15\r
534 \r
535         ; Increment the loop counter to show this task is still getting CPU time.\r
536         MOV.L   #_ulRegTest1CycleCount, R14\r
537         MOV.L   [ R14 ], R15\r
538         ADD             #1, R15\r
539         MOV.L   R15, [ R14 ]\r
540 \r
541         ; Yield to extend the text coverage.  Set the bit in the ITU SWINTR register.\r
542         MOV.L   #1, R14\r
543         MOV.L   #0872E0H, R15\r
544         MOV.B   R14, [R15]\r
545         NOP\r
546         NOP\r
547 \r
548         ; Restore the clobbered registers.\r
549         POPM    R14-R15\r
550 \r
551         ; Now compare each register to ensure it still contains the value that was\r
552         ; set before this loop was entered.\r
553         CMP             #1, R1\r
554         BNE             RegTest1Error\r
555         CMP             #2, R2\r
556         BNE             RegTest1Error\r
557         CMP             #3, R3\r
558         BNE             RegTest1Error\r
559         CMP             #4, R4\r
560         BNE             RegTest1Error\r
561         CMP             #5, R5\r
562         BNE             RegTest1Error\r
563         CMP             #6, R6\r
564         BNE             RegTest1Error\r
565         CMP             #7, R7\r
566         BNE             RegTest1Error\r
567         CMP             #8, R8\r
568         BNE             RegTest1Error\r
569         CMP             #9, R9\r
570         BNE             RegTest1Error\r
571         CMP             #10, R10\r
572         BNE             RegTest1Error\r
573         CMP             #11, R11\r
574         BNE             RegTest1Error\r
575         CMP             #12, R12\r
576         BNE             RegTest1Error\r
577         CMP             #13, R13\r
578         BNE             RegTest1Error\r
579         CMP             #14, R14\r
580         BNE             RegTest1Error\r
581         CMP             #15, R15\r
582         BNE             RegTest1Error\r
583 \r
584         ; All comparisons passed, start a new itteratio of this loop.\r
585         BRA             TestLoop1\r
586 \r
587 RegTest1Error:\r
588         ; A compare failed, just loop here so the loop counter stops incrementing\r
589         ; causing the check task to indicate the error.\r
590         BRA RegTest1Error\r
591 }\r
592 /*-----------------------------------------------------------*/\r
593 \r
594 /* This function is explained in the comments at the top of this file. */\r
595 #pragma inline_asm prvRegTest2Implementation\r
596 static void prvRegTest2Implementation( void )\r
597 {\r
598         ; Put a known value in each register.\r
599         MOV.L   #10, R1\r
600         MOV.L   #20, R2\r
601         MOV.L   #30, R3\r
602         MOV.L   #40, R4\r
603         MOV.L   #50, R5\r
604         MOV.L   #60, R6\r
605         MOV.L   #70, R7\r
606         MOV.L   #80, R8\r
607         MOV.L   #90, R9\r
608         MOV.L   #100, R10\r
609         MOV.L   #110, R11\r
610         MOV.L   #120, R12\r
611         MOV.L   #130, R13\r
612         MOV.L   #140, R14\r
613         MOV.L   #150, R15\r
614 \r
615         ; Loop, checking on each iteration that each register still contains the\r
616         ; expected value.\r
617 TestLoop2:\r
618 \r
619         ; Push the registers that are going to get clobbered.\r
620         PUSHM   R14-R15\r
621 \r
622         ; Increment the loop counter to show this task is still getting CPU time.\r
623         MOV.L   #_ulRegTest2CycleCount, R14\r
624         MOV.L   [ R14 ], R15\r
625         ADD             #1, R15\r
626         MOV.L   R15, [ R14 ]\r
627 \r
628         ; Restore the clobbered registers.\r
629         POPM    R14-R15\r
630 \r
631         CMP             #10, R1\r
632         BNE             RegTest2Error\r
633         CMP             #20, R2\r
634         BNE             RegTest2Error\r
635         CMP             #30, R3\r
636         BNE             RegTest2Error\r
637         CMP             #40, R4\r
638         BNE             RegTest2Error\r
639         CMP             #50, R5\r
640         BNE             RegTest2Error\r
641         CMP             #60, R6\r
642         BNE             RegTest2Error\r
643         CMP             #70, R7\r
644         BNE             RegTest2Error\r
645         CMP             #80, R8\r
646         BNE             RegTest2Error\r
647         CMP             #90, R9\r
648         BNE             RegTest2Error\r
649         CMP             #100, R10\r
650         BNE             RegTest2Error\r
651         CMP             #110, R11\r
652         BNE             RegTest2Error\r
653         CMP             #120, R12\r
654         BNE             RegTest2Error\r
655         CMP             #130, R13\r
656         BNE             RegTest2Error\r
657         CMP             #140, R14\r
658         BNE             RegTest2Error\r
659         CMP             #150, R15\r
660         BNE             RegTest2Error\r
661 \r
662         ; All comparisons passed, start a new itteratio of this loop.\r
663         BRA             TestLoop2\r
664 \r
665 RegTest2Error:\r
666         ; A compare failed, just loop here so the loop counter stops incrementing\r
667         ; - causing the check task to indicate the error.\r
668         BRA RegTest2Error\r
669 }\r
670 /*-----------------------------------------------------------*/\r
671 \r
672 char *pcGetTaskStatusMessage( void )\r
673 {\r
674         /* Not bothered about a critical section here although technically because of\r
675         the task priorities the pointer could change it will be atomic if not near\r
676         atomic and its not critical. */\r
677         return ( char * ) pcStatusMessage;\r
678 }\r
679 /*-----------------------------------------------------------*/\r
680 \r
681 \r