]> git.sur5r.net Git - freertos/blob - Demo/RX600_RX62N-RSK_GNURX/RTOSDemo/main-full.c
RX GCC port - Introduce macros that perform the interrupt entry and exit manually...
[freertos] / Demo / RX600_RX62N-RSK_GNURX / RTOSDemo / main-full.c
1 /*\r
2     FreeRTOS V6.0.5 - Copyright (C) 2010 Real Time Engineers Ltd.\r
3 \r
4     ***************************************************************************\r
5     *                                                                         *\r
6     * If you are:                                                             *\r
7     *                                                                         *\r
8     *    + New to FreeRTOS,                                                   *\r
9     *    + Wanting to learn FreeRTOS or multitasking in general quickly       *\r
10     *    + Looking for basic training,                                        *\r
11     *    + Wanting to improve your FreeRTOS skills and productivity           *\r
12     *                                                                         *\r
13     * then take a look at the FreeRTOS eBook                                  *\r
14     *                                                                         *\r
15     *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *\r
16     *                  http://www.FreeRTOS.org/Documentation                  *\r
17     *                                                                         *\r
18     * A pdf reference manual is also available.  Both are usually delivered   *\r
19     * to your inbox within 20 minutes to two hours when purchased between 8am *\r
20     * and 8pm GMT (although please allow up to 24 hours in case of            *\r
21     * exceptional circumstances).  Thank you for your support!                *\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 exception to the GPL is included to allow you to distribute\r
31     a combined work that includes FreeRTOS without being obliged to provide the\r
32     source code for proprietary components outside of the FreeRTOS kernel.\r
33     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
34     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
35     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     http://www.FreeRTOS.org - Documentation, latest information, license and\r
45     contact details.\r
46 \r
47     http://www.SafeRTOS.com - A version that is certified for use in safety\r
48     critical systems.\r
49 \r
50     http://www.OpenRTOS.com - Commercial support, development, porting,\r
51     licensing and training services.\r
52 */\r
53 \r
54 /* ****************************************************************************\r
55  * This project includes a lot of tasks and tests and is therefore complex.\r
56  * If you would prefer a much simpler project to get started with then select\r
57  * the 'Blinky' build configuration within the HEW IDE.\r
58  * ****************************************************************************\r
59  *\r
60  * Creates all the demo application tasks, then starts the scheduler.  The web\r
61  * documentation provides more details of the standard demo application tasks,\r
62  * which provide no particular functionality but do provide a good example of\r
63  * how to use the FreeRTOS API.  The tasks defined in flop.c are included in the\r
64  * set of standard demo tasks to ensure the floating point unit gets some\r
65  * exercise.\r
66  *\r
67  * In addition to the standard demo tasks, the following tasks and tests are\r
68  * defined and/or created within this file:\r
69  *\r
70  * Webserver ("uIP") task - This serves a number of dynamically generated WEB\r
71  * pages to a standard WEB browser.  The IP and MAC addresses are configured by\r
72  * constants defined at the bottom of FreeRTOSConfig.h.  Use either a standard\r
73  * Ethernet cable to connect through a hug, or a cross over (point to point)\r
74  * cable to connect directly.  Ensure the IP address used is compatible with the\r
75  * IP address of the machine running the browser - the easiest way to achieve\r
76  * this is to ensure the first three octets of the IP addresses are the same.\r
77  *\r
78  * "Reg test" tasks - These fill the registers with known values, then check\r
79  * that each register still contains its expected value.  Each task uses\r
80  * different values.  The tasks run with very low priority so get preempted\r
81  * very frequently.  A check variable is incremented on each iteration of the\r
82  * test loop.  A register containing an unexpected value is indicative of an\r
83  * error in the context switching mechanism and will result in a branch to a\r
84  * null loop - which in turn will prevent the check variable from incrementing\r
85  * any further and allow the check task (described below) to determine that an\r
86  * error has occurred.  The nature of the reg test tasks necessitates that they\r
87  * are written in assembly code.\r
88  *\r
89  * "Check" task - This only executes every five seconds but has a high priority\r
90  * to ensure it gets processor time.  Its main function is to check that all the\r
91  * standard demo tasks are still operational.  While no errors have been\r
92  * discovered the check task will toggle LED 5 every 5 seconds - the toggle\r
93  * rate increasing to 200ms being a visual indication that at least one task has\r
94  * reported unexpected behaviour.\r
95  *\r
96  * "High frequency timer test" - A high frequency periodic interrupt is\r
97  * generated using a timer - the interrupt is assigned a priority above\r
98  * configMAX_SYSCALL_INTERRUPT_PRIORITY so should not be effected by anything\r
99  * the kernel is doing.  The frequency and priority of the interrupt, in\r
100  * combination with other standard tests executed in this demo, should result\r
101  * in interrupts nesting at least 3 and probably 4 deep.  This test is only\r
102  * included in build configurations that have the optimiser switched on.  In\r
103  * optimised builds the count of high frequency ticks is used as the time base\r
104  * for the run time stats.\r
105  *\r
106  * *NOTE 1* If LED5 is toggling every 5 seconds then all the demo application\r
107  * tasks are executing as expected and no errors have been reported in any\r
108  * tasks.  The toggle rate increasing to 200ms indicates that at least one task\r
109  * has reported unexpected behaviour.\r
110  *\r
111  * *NOTE 2* vApplicationSetupTimerInterrupt() is called by the kernel to let\r
112  * the application set up a timer to generate the tick interrupt.  In this\r
113  * example a compare match timer is used for this purpose.\r
114  *\r
115  * *NOTE 3* The CPU must be in Supervisor mode when the scheduler is started.\r
116  * The PowerON_Reset_PC() supplied in resetprg.c with this demo has\r
117  * Change_PSW_PM_to_UserMode() commented out to ensure this is the case.\r
118  *\r
119  * *NOTE 4* The IntQueue common demo tasks test interrupt nesting and make use\r
120  * of all the 8bit timers (as two cascaded 16bit units).\r
121 */\r
122 \r
123 /* Standard includes. */\r
124 #include <string.h>\r
125 #include <stdio.h>\r
126 \r
127 /* Hardware specific includes. */\r
128 #include "iodefine.h"\r
129 \r
130 /* Kernel includes. */\r
131 #include "FreeRTOS.h"\r
132 #include "task.h"\r
133 \r
134 /* Standard demo includes. */\r
135 #include "partest.h"\r
136 #include "flash.h"\r
137 #include "IntQueue.h"\r
138 #include "BlockQ.h"\r
139 #include "death.h"\r
140 #include "integer.h"\r
141 #include "blocktim.h"\r
142 #include "semtest.h"\r
143 #include "PollQ.h"\r
144 #include "GenQTest.h"\r
145 #include "QPeek.h"\r
146 #include "recmutex.h"\r
147 #include "flop.h"\r
148 \r
149 /* Values that are passed into the reg test tasks using the task parameter.  The\r
150 tasks check that the values are passed in correctly. */\r
151 #define mainREG_TEST_1_PARAMETER        ( 0x12121212UL )\r
152 #define mainREG_TEST_2_PARAMETER        ( 0x12345678UL )\r
153 \r
154 /* Priorities at which the tasks are created. */\r
155 #define mainCHECK_TASK_PRIORITY         ( configMAX_PRIORITIES - 1 )\r
156 #define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
157 #define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )\r
158 #define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )\r
159 #define mainCREATOR_TASK_PRIORITY   ( tskIDLE_PRIORITY + 3 )\r
160 #define mainFLASH_TASK_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
161 #define mainuIP_TASK_PRIORITY           ( tskIDLE_PRIORITY + 2 )\r
162 #define mainINTEGER_TASK_PRIORITY   ( tskIDLE_PRIORITY )\r
163 #define mainGEN_QUEUE_TASK_PRIORITY     ( tskIDLE_PRIORITY )\r
164 #define mainFLOP_TASK_PRIORITY          ( tskIDLE_PRIORITY )\r
165 \r
166 /* The WEB server uses string handling functions, which in turn use a bit more\r
167 stack than most of the other tasks. */\r
168 #define mainuIP_STACK_SIZE                      ( configMINIMAL_STACK_SIZE * 3 )\r
169 \r
170 /* The LED toggled by the check task. */\r
171 #define mainCHECK_LED                           ( 5 )\r
172 \r
173 /* The rate at which mainCHECK_LED will toggle when all the tasks are running\r
174 without error.  Controlled by the check task as described at the top of this\r
175 file. */\r
176 #define mainNO_ERROR_CYCLE_TIME         ( 5000 / portTICK_RATE_MS )\r
177 \r
178 /* The rate at which mainCHECK_LED will toggle when an error has been reported\r
179 by at least one task.  Controlled by the check task as described at the top of\r
180 this file. */\r
181 #define mainERROR_CYCLE_TIME            ( 200 / portTICK_RATE_MS )\r
182 \r
183 \r
184 /*\r
185  * vApplicationMallocFailedHook() will only be called if\r
186  * configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook\r
187  * function that will execute if a call to pvPortMalloc() fails.\r
188  * pvPortMalloc() is called internally by the kernel whenever a task, queue or\r
189  * semaphore is created.  It is also called by various parts of the demo\r
190  * application.\r
191  */\r
192 void vApplicationMallocFailedHook( void );\r
193 \r
194 /*\r
195  * vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1\r
196  * in FreeRTOSConfig.h.  It is a hook function that is called on each iteration\r
197  * of the idle task.  It is essential that code added to this hook function\r
198  * never attempts to block in any way (for example, call xQueueReceive() with\r
199  * a block time specified).  If the application makes use of the vTaskDelete()\r
200  * API function (as this demo application does) then it is also important that\r
201  * vApplicationIdleHook() is permitted to return to its calling function because\r
202  * it is the responsibility of the idle task to clean up memory allocated by the\r
203  * kernel to any task that has since been deleted.\r
204  */\r
205 void vApplicationIdleHook( void );\r
206 \r
207 /*\r
208  * vApplicationStackOverflowHook() will only be called if\r
209  * configCHECK_FOR_STACK_OVERFLOW is set to a non-zero value.  The handle and\r
210  * name of the offending task should be passed in the function parameters, but\r
211  * it is possible that the stack overflow will have corrupted these - in which\r
212  * case pxCurrentTCB can be inspected to find the same information.\r
213  */\r
214 void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName );\r
215 \r
216 /*\r
217  * The reg test tasks as described at the top of this file.\r
218  */\r
219 static void prvRegTest1Task( void *pvParameters );\r
220 static void prvRegTest2Task( void *pvParameters );\r
221 \r
222 /*\r
223  * The actual implementation of the reg test functionality, which, because of\r
224  * the direct register access, have to be in assembly.\r
225  */\r
226 static void prvRegTest1Implementation( void ) __attribute__((naked));\r
227 static void prvRegTest2Implementation( void ) __attribute__((naked));\r
228 \r
229 \r
230 /*\r
231  * The check task as described at the top of this file.\r
232  */\r
233 static void prvCheckTask( void *pvParameters );\r
234 \r
235 /*\r
236  * Contains the implementation of the WEB server.\r
237  */\r
238 extern void vuIP_Task( void *pvParameters );\r
239 \r
240 /*-----------------------------------------------------------*/\r
241 \r
242 /* Variables that are incremented on each iteration of the reg test tasks -\r
243 provided the tasks have not reported any errors.  The check task inspects these\r
244 variables to ensure they are still incrementing as expected.  If a variable\r
245 stops incrementing then it is likely that its associate task has stalled. */\r
246 unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;\r
247 \r
248 /* The status message that is displayed at the bottom of the "task stats" web\r
249 page, which is served by the uIP task.  This will report any errors picked up\r
250 by the reg test task. */\r
251 static const char *pcStatusMessage = NULL;\r
252 \r
253 /*-----------------------------------------------------------*/\r
254 \r
255 void main(void)\r
256 {\r
257 extern void HardwareSetup( void );\r
258 \r
259         /* Renesas provided CPU configuration routine.  The clocks are configured in\r
260         here. */\r
261         HardwareSetup();\r
262 \r
263         /* Turn all LEDs off. */\r
264         vParTestInitialise();\r
265 \r
266         /* Start the reg test tasks which test the context switching mechanism. */\r
267         xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
268         xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
269 \r
270         /* The web server task. */\r
271 //      xTaskCreate( vuIP_Task, "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL );\r
272 \r
273         /* Start the check task as described at the top of this file. */\r
274         xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE * 3, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
275 \r
276         /* Create the standard demo tasks. */\r
277         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
278         vCreateBlockTimeTasks();\r
279         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
280         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
281         vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );\r
282         vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );\r
283         vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );\r
284         vStartQueuePeekTasks();\r
285         vStartRecursiveMutexTasks();\r
286         vStartInterruptQueueTasks();\r
287         vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
288 \r
289         /* The suicide tasks must be created last as they need to know how many\r
290         tasks were running prior to their creation in order to ascertain whether\r
291         or not the correct/expected number of tasks are running at any given time. */\r
292         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
293 \r
294         /* Start the tasks running. */\r
295         vTaskStartScheduler();\r
296 \r
297         /* If all is well we will never reach here as the scheduler will now be\r
298         running.  If we do reach here then it is likely that there was insufficient\r
299         heap available for the idle task to be created. */\r
300         for( ;; );\r
301 }\r
302 /*-----------------------------------------------------------*/\r
303 \r
304 static void prvCheckTask( void *pvParameters )\r
305 {\r
306 static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL;\r
307 portTickType xNextWakeTime, xCycleFrequency = mainNO_ERROR_CYCLE_TIME;\r
308 extern void vSetupHighFrequencyTimer( void );\r
309 \r
310         /* If this is being executed then the kernel has been started.  Start the high\r
311         frequency timer test as described at the top of this file.  This is only\r
312         included in the optimised build configuration - otherwise it takes up too much\r
313         CPU time. */\r
314         #ifdef INCLUDE_HIGH_FREQUENCY_TIMER_TEST\r
315                 vSetupHighFrequencyTimer();\r
316         #endif\r
317 \r
318         /* Initialise xNextWakeTime - this only needs to be done once. */\r
319         xNextWakeTime = xTaskGetTickCount();\r
320 \r
321         for( ;; )\r
322         {\r
323                 /* Place this task in the blocked state until it is time to run again. */\r
324                 vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );\r
325 \r
326                 /* Check the standard demo tasks are running without error. */\r
327                 if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
328                 {\r
329                         /* Increase the rate at which this task cycles, which will increase the\r
330                         rate at which mainCHECK_LED flashes to give visual feedback that an error\r
331                         has occurred. */\r
332                         pcStatusMessage = "Error: GenQueue";\r
333                 }\r
334                 else if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
335                 {\r
336                         pcStatusMessage = "Error: QueuePeek\r\n";\r
337                 }\r
338                 else if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
339                 {\r
340                         pcStatusMessage = "Error: BlockQueue\r\n";\r
341                 }\r
342                 else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
343                 {\r
344                         pcStatusMessage = "Error: BlockTime\r\n";\r
345                 }\r
346             else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
347             {\r
348                         pcStatusMessage = "Error: SemTest\r\n";\r
349             }\r
350             else if( xArePollingQueuesStillRunning() != pdTRUE )\r
351             {\r
352                         pcStatusMessage = "Error: PollQueue\r\n";\r
353             }\r
354             else if( xIsCreateTaskStillRunning() != pdTRUE )\r
355             {\r
356                         pcStatusMessage = "Error: Death\r\n";\r
357             }\r
358             else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
359             {\r
360                         pcStatusMessage = "Error: IntMath\r\n";\r
361             }\r
362             else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
363             {\r
364                         pcStatusMessage = "Error: RecMutex\r\n";\r
365             }\r
366                 else if( xAreIntQueueTasksStillRunning() != pdPASS )\r
367                 {\r
368                         pcStatusMessage = "Error: IntQueue\r\n";\r
369                 }\r
370                 else if( xAreMathsTaskStillRunning() != pdPASS )\r
371                 {\r
372                         pcStatusMessage = "Error: Flop\r\n";\r
373                 }\r
374 \r
375                 /* Check the reg test tasks are still cycling.  They will stop incrementing\r
376                 their loop counters if they encounter an error. */\r
377                 if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )\r
378                 {\r
379                         pcStatusMessage = "Error: RegTest1\r\n";\r
380                 }\r
381 \r
382                 if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )\r
383                 {\r
384                         pcStatusMessage = "Error: RegTest2\r\n";\r
385                 }\r
386 \r
387                 ulLastRegTest1CycleCount = ulRegTest1CycleCount;\r
388                 ulLastRegTest2CycleCount = ulRegTest2CycleCount;\r
389 \r
390                 /* Toggle the check LED to give an indication of the system status.  If\r
391                 the LED toggles every 5 seconds then everything is ok.  A faster toggle\r
392                 indicates an error. */\r
393                 vParTestToggleLED( mainCHECK_LED );\r
394 \r
395                 /* Ensure the LED toggles at a faster rate if an error has occurred. */\r
396                 if( pcStatusMessage != NULL )\r
397                 {\r
398                         xCycleFrequency = mainERROR_CYCLE_TIME;\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 }\r
452 /*-----------------------------------------------------------*/\r
453 \r
454 /* This function is explained in the comments at the top of this file. */\r
455 static void prvRegTest1Task( void *pvParameters )\r
456 {\r
457         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_1_PARAMETER )\r
458         {\r
459                 /* The parameter did not contain the expected value. */\r
460                 for( ;; )\r
461                 {\r
462                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
463                         taskDISABLE_INTERRUPTS();\r
464                 }\r
465         }\r
466 \r
467         /* This is an asm function that never returns. */\r
468         prvRegTest1Implementation();\r
469 }\r
470 /*-----------------------------------------------------------*/\r
471 \r
472 /* This function is explained in the comments at the top of this file. */\r
473 static void prvRegTest2Task( void *pvParameters )\r
474 {\r
475         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_2_PARAMETER )\r
476         {\r
477                 /* The parameter did not contain the expected value. */\r
478                 for( ;; )\r
479                 {\r
480                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
481                         taskDISABLE_INTERRUPTS();\r
482                 }\r
483         }\r
484 \r
485         /* This is an asm function that never returns. */\r
486         prvRegTest2Implementation();\r
487 }\r
488 /*-----------------------------------------------------------*/\r
489 \r
490 char *pcGetTaskStatusMessage( void )\r
491 {\r
492         /* Not bothered about a critical section here although technically because of\r
493         the task priorities the pointer could change it will be atomic if not near\r
494         atomic and its not critical. */\r
495         if( pcStatusMessage == NULL )\r
496         {\r
497                 return "All tasks running without error";\r
498         }\r
499         else\r
500         {\r
501                 return ( char * ) pcStatusMessage;\r
502         }\r
503 }\r
504 /*-----------------------------------------------------------*/\r
505 \r
506 /* This function is explained in the comments at the top of this file. */\r
507 static void prvRegTest1Implementation( void )\r
508 {\r
509         __asm volatile\r
510         (\r
511                         /* Put a known value in each register. */\r
512                         "MOV    #1, R1                                          \n" \\r
513                         "MOV    #2, R2                                          \n" \\r
514                         "MOV    #3, R3                                          \n" \\r
515                         "MOV    #4, R4                                          \n" \\r
516                         "MOV    #5, R5                                          \n" \\r
517                         "MOV    #6, R6                                          \n" \\r
518                         "MOV    #7, R7                                          \n" \\r
519                         "MOV    #8, R8                                          \n" \\r
520                         "MOV    #9, R9                                          \n" \\r
521                         "MOV    #10, R10                                        \n" \\r
522                         "MOV    #11, R11                                        \n" \\r
523                         "MOV    #12, R12                                        \n" \\r
524                         "MOV    #13, R13                                        \n" \\r
525                         "MOV    #14, R14                                        \n" \\r
526                         "MOV    #15, R15                                        \n" \\r
527                         \r
528                         /* Loop, checking each itteration that each register still contains the\r
529                         expected value. */\r
530                 "TestLoop1:                                                             \n" \\r
531 \r
532                         /* Push the registers that are going to get clobbered. */\r
533                         "PUSHM  R14-R15                                         \n" \\r
534                         \r
535                         /* Increment the loop counter to show this task is still getting CPU time. */\r
536                         "MOV    #_ulRegTest1CycleCount, R14     \n" \\r
537                         "MOV    [ R14 ], R15                            \n" \\r
538                         "ADD    #1, R15                                         \n" \\r
539                         "MOV    R15, [ R14 ]                            \n" \\r
540                         \r
541                         /* Yield to extend the test coverage.  Set the bit in the ITU SWINTR register. */\r
542                         "MOV    #1, R14                                         \n" \\r
543                         "MOV    #0872E0H, R15                           \n" \\r
544                         "MOV.B  R14, [R15]                                      \n" \\r
545                         "NOP                                                            \n" \\r
546                         "NOP                                                            \n" \\r
547                         \r
548                         /* Restore the clobbered registers. */\r
549                         "POPM   R14-R15                                         \n" \\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                                          \n" \\r
554                         "BNE    RegTest1Error                           \n" \\r
555                         "CMP    #2, R2                                          \n" \\r
556                         "BNE    RegTest1Error                           \n" \\r
557                         "CMP    #3, R3                                          \n" \\r
558                         "BNE    RegTest1Error                           \n" \\r
559                         "CMP    #4, R4                                          \n" \\r
560                         "BNE    RegTest1Error                           \n" \\r
561                         "CMP    #5, R5                                          \n" \\r
562                         "BNE    RegTest1Error                           \n" \\r
563                         "CMP    #6, R6                                          \n" \\r
564                         "BNE    RegTest1Error                           \n" \\r
565                         "CMP    #7, R7                                          \n" \\r
566                         "BNE    RegTest1Error                           \n" \\r
567                         "CMP    #8, R8                                          \n" \\r
568                         "BNE    RegTest1Error                           \n" \\r
569                         "CMP    #9, R9                                          \n" \\r
570                         "BNE    RegTest1Error                           \n" \\r
571                         "CMP    #10, R10                                        \n" \\r
572                         "BNE    RegTest1Error                           \n" \\r
573                         "CMP    #11, R11                                        \n" \\r
574                         "BNE    RegTest1Error                           \n" \\r
575                         "CMP    #12, R12                                        \n" \\r
576                         "BNE    RegTest1Error                           \n" \\r
577                         "CMP    #13, R13                                        \n" \\r
578                         "BNE    RegTest1Error                           \n" \\r
579                         "CMP    #14, R14                                        \n" \\r
580                         "BNE    RegTest1Error                           \n" \\r
581                         "CMP    #15, R15                                        \n" \\r
582                         "BNE    RegTest1Error                           \n" \\r
583 \r
584                         /* All comparisons passed, start a new itteratio of this loop. */\r
585                         "BRA            TestLoop1                               \n" \\r
586                         \r
587                 "RegTest1Error:                                                 \n" \\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 \r
595 /* This function is explained in the comments at the top of this file. */\r
596 static void prvRegTest2Implementation( void )\r
597 {\r
598         __asm volatile\r
599         (\r
600                         /* Put a known value in each register. */\r
601                         "MOV    #10H, R1                                        \n" \\r
602                         "MOV    #20H, R2                                        \n" \\r
603                         "MOV    #30H, R3                                        \n" \\r
604                         "MOV    #40H, R4                                        \n" \\r
605                         "MOV    #50H, R5                                        \n" \\r
606                         "MOV    #60H, R6                                        \n" \\r
607                         "MOV    #70H, R7                                        \n" \\r
608                         "MOV    #80H, R8                                        \n" \\r
609                         "MOV    #90H, R9                                        \n" \\r
610                         "MOV    #100H, R10                                      \n" \\r
611                         "MOV    #110H, R11                                      \n" \\r
612                         "MOV    #120H, R12                                      \n" \\r
613                         "MOV    #130H, R13                                      \n" \\r
614                         "MOV    #140H, R14                                      \n" \\r
615                         "MOV    #150H, R15                                      \n" \\r
616                         \r
617                         /* Loop, checking each itteration that each register still contains the\r
618                         expected value. */\r
619                 "TestLoop2:                                                             \n" \\r
620 \r
621                         /* Push the registers that are going to get clobbered. */\r
622                         "PUSHM  R14-R15                                         \n" \\r
623                         \r
624                         /* Increment the loop counter to show this task is still getting CPU time. */\r
625                         "MOV    #_ulRegTest2CycleCount, R14     \n" \\r
626                         "MOV    [ R14 ], R15                            \n" \\r
627                         "ADD    #1, R15                                         \n" \\r
628                         "MOV    R15, [ R14 ]                            \n" \\r
629                         \r
630                         /* Restore the clobbered registers. */\r
631                         "POPM   R14-R15                                         \n" \\r
632                         \r
633                         /* Now compare each register to ensure it still contains the value that was\r
634                         set before this loop was entered. */\r
635                         "CMP    #10H, R1                                        \n" \\r
636                         "BNE    RegTest2Error                           \n" \\r
637                         "CMP    #20H, R2                                        \n" \\r
638                         "BNE    RegTest2Error                           \n" \\r
639                         "CMP    #30H, R3                                        \n" \\r
640                         "BNE    RegTest2Error                           \n" \\r
641                         "CMP    #40H, R4                                        \n" \\r
642                         "BNE    RegTest2Error                           \n" \\r
643                         "CMP    #50H, R5                                        \n" \\r
644                         "BNE    RegTest2Error                           \n" \\r
645                         "CMP    #60H, R6                                        \n" \\r
646                         "BNE    RegTest2Error                           \n" \\r
647                         "CMP    #70H, R7                                        \n" \\r
648                         "BNE    RegTest2Error                           \n" \\r
649                         "CMP    #80H, R8                                        \n" \\r
650                         "BNE    RegTest2Error                           \n" \\r
651                         "CMP    #90H, R9                                        \n" \\r
652                         "BNE    RegTest2Error                           \n" \\r
653                         "CMP    #100H, R10                                      \n" \\r
654                         "BNE    RegTest2Error                           \n" \\r
655                         "CMP    #110H, R11                                      \n" \\r
656                         "BNE    RegTest2Error                           \n" \\r
657                         "CMP    #120H, R12                                      \n" \\r
658                         "BNE    RegTest2Error                           \n" \\r
659                         "CMP    #130H, R13                                      \n" \\r
660                         "BNE    RegTest2Error                           \n" \\r
661                         "CMP    #140H, R14                                      \n" \\r
662                         "BNE    RegTest2Error                           \n" \\r
663                         "CMP    #150H, R15                                      \n" \\r
664                         "BNE    RegTest2Error                           \n" \\r
665 \r
666                         /* All comparisons passed, start a new itteratio of this loop. */\r
667                         "BRA    TestLoop2                                       \n" \\r
668                         \r
669                 "RegTest2Error:                                                 \n" \\r
670                         /* A compare failed, just loop here so the loop counter stops incrementing\r
671                         - causing the check task to indicate the error. */\r
672                         "BRA RegTest2Error                                        "\r
673         );\r
674 }\r
675 \r