]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4F_Infineon_XMC4500_Tasking/main_full.c
Update version numbers to V7.4.1.
[freertos] / FreeRTOS / Demo / CORTEX_M4F_Infineon_XMC4500_Tasking / main_full.c
1 /*\r
2     FreeRTOS V7.4.1 - Copyright (C) 2013 Real Time Engineers Ltd.\r
3 \r
4     FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
5     http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     ***************************************************************************\r
8      *                                                                       *\r
9      *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
10      *    Complete, revised, and edited pdf reference manuals are also       *\r
11      *    available.                                                         *\r
12      *                                                                       *\r
13      *    Purchasing FreeRTOS documentation will not only help you, by       *\r
14      *    ensuring you get running as quickly as possible and with an        *\r
15      *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
16      *    the FreeRTOS project to continue with its mission of providing     *\r
17      *    professional grade, cross platform, de facto standard solutions    *\r
18      *    for microcontrollers - completely free of charge!                  *\r
19      *                                                                       *\r
20      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
21      *                                                                       *\r
22      *    Thank you for using FreeRTOS, and thank you for your support!      *\r
23      *                                                                       *\r
24     ***************************************************************************\r
25 \r
26 \r
27     This file is part of the FreeRTOS distribution.\r
28 \r
29     FreeRTOS is free software; you can redistribute it and/or modify it under\r
30     the terms of the GNU General Public License (version 2) as published by the\r
31     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
32 \r
33     >>>>>>NOTE<<<<<< The modification to the GPL is included to allow you to\r
34     distribute a combined work that includes FreeRTOS without being obliged to\r
35     provide the source code for proprietary components outside of the FreeRTOS\r
36     kernel.\r
37 \r
38     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
39     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
40     FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\r
41     details. You should have received a copy of the GNU General Public License\r
42     and the FreeRTOS license exception along with FreeRTOS; if not it can be\r
43     viewed here: http://www.freertos.org/a00114.html and also obtained by\r
44     writing to Real Time Engineers Ltd., contact details for whom are available\r
45     on the FreeRTOS WEB site.\r
46 \r
47     1 tab == 4 spaces!\r
48 \r
49     ***************************************************************************\r
50      *                                                                       *\r
51      *    Having a problem?  Start by reading the FAQ "My application does   *\r
52      *    not run, what could be wrong?"                                     *\r
53      *                                                                       *\r
54      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
55      *                                                                       *\r
56     ***************************************************************************\r
57 \r
58 \r
59     http://www.FreeRTOS.org - Documentation, books, training, latest versions, \r
60     license and Real Time Engineers Ltd. contact details.\r
61 \r
62     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
63     including FreeRTOS+Trace - an indispensable productivity tool, and our new\r
64     fully thread aware and reentrant UDP/IP stack.\r
65 \r
66     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High \r
67     Integrity Systems, who sell the code with commercial support, \r
68     indemnification and middleware, under the OpenRTOS brand.\r
69     \r
70     http://www.SafeRTOS.com - High Integrity Systems also provide a safety \r
71     engineered and independently SIL3 certified version for use in safety and \r
72     mission critical applications that require provable dependability.\r
73 */\r
74 \r
75 /******************************************************************************\r
76  * NOTE 1:  This project provides two demo applications.  A simple blinky style\r
77  * project, and a more comprehensive test and demo application.  The\r
78  * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select\r
79  * between the two.  See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY\r
80  * in main.c.  This file implements the comprehensive test and demo version.\r
81  *\r
82  * NOTE 2:  This file only contains the source code that is specific to the\r
83  * full demo.  Generic functions, such FreeRTOS hook functions, and functions\r
84  * required to configure the hardware, are defined in main.c.\r
85  ******************************************************************************\r
86  *\r
87  * main_full() creates all the demo application tasks and a software timer, then\r
88  * starts the scheduler.  The web documentation provides more details of the \r
89  * standard demo application tasks, which provide no particular functionality, \r
90  * but do provide a good example of how to use the FreeRTOS API.\r
91  *\r
92  * In addition to the standard demo tasks, the following tasks and tests are\r
93  * defined and/or created within this file:\r
94  *\r
95  * "Reg test" tasks - These fill both the core and floating point registers with\r
96  * known values, then check that each register maintains its expected value for\r
97  * the lifetime of the task.  Each task uses a different set of values.  The reg\r
98  * test tasks execute with a very low priority, so get preempted very\r
99  * frequently.  A register containing an unexpected value is indicative of an\r
100  * error in the context switching mechanism.\r
101  *\r
102  * "Check" timer - The check software timer period is initially set to three\r
103  * seconds.  The callback function associated with the check software timer\r
104  * checks that all the standard demo tasks, and the register check tasks, are\r
105  * not only still executing, but are executing without reporting any errors.  If\r
106  * the check software timer discovers that a task has either stalled, or\r
107  * reported an error, then it changes its own execution period from the initial\r
108  * three seconds, to just 200ms.  The check software timer callback function\r
109  * also toggles the single LED each time it is called.  This provides a visual\r
110  * indication of the system status:  If the LED toggles every three seconds,\r
111  * then no issues have been discovered.  If the LED toggles every 200ms, then\r
112  * an issue has been discovered with at least one task.\r
113  */\r
114 \r
115 /* Standard includes. */\r
116 #include <stdio.h>\r
117 \r
118 /* Kernel includes. */\r
119 #include "FreeRTOS.h"\r
120 #include "task.h"\r
121 #include "timers.h"\r
122 #include "semphr.h"\r
123 \r
124 /* Standard demo application includes. */\r
125 #include "flop.h"\r
126 #include "integer.h"\r
127 #include "PollQ.h"\r
128 #include "semtest.h"\r
129 #include "dynamic.h"\r
130 #include "BlockQ.h"\r
131 #include "blocktim.h"\r
132 #include "countsem.h"\r
133 #include "GenQTest.h"\r
134 #include "recmutex.h"\r
135 #include "death.h"\r
136 \r
137 /* Hardware includes. */\r
138 #include "XMC4500.h"\r
139 #include "System_XMC4500.h"\r
140 \r
141 /* Priorities for the demo application tasks. */\r
142 #define mainQUEUE_POLL_PRIORITY                         ( tskIDLE_PRIORITY + 2UL )\r
143 #define mainSEM_TEST_PRIORITY                           ( tskIDLE_PRIORITY + 1UL )\r
144 #define mainBLOCK_Q_PRIORITY                            ( tskIDLE_PRIORITY + 2UL )\r
145 #define mainCREATOR_TASK_PRIORITY                       ( tskIDLE_PRIORITY + 3UL )\r
146 #define mainFLOP_TASK_PRIORITY                          ( tskIDLE_PRIORITY )\r
147 \r
148 /* To toggle the single LED */\r
149 #define mainTOGGLE_LED()                                        ( PORT3->OMR =  0x02000200 )\r
150 \r
151 /* A block time of zero simply means "don't block". */\r
152 #define mainDONT_BLOCK                                          ( 0UL )\r
153 \r
154 /* The period after which the check timer will expire, in ms, provided no errors\r
155 have been reported by any of the standard demo tasks.  ms are converted to the\r
156 equivalent in ticks using the portTICK_RATE_MS constant. */\r
157 #define mainCHECK_TIMER_PERIOD_MS                       ( 3000UL / portTICK_RATE_MS )\r
158 \r
159 /* The period at which the check timer will expire, in ms, if an error has been\r
160 reported in one of the standard demo tasks.  ms are converted to the equivalent\r
161 in ticks using the portTICK_RATE_MS constant. */\r
162 #define mainERROR_CHECK_TIMER_PERIOD_MS         ( 200UL / portTICK_RATE_MS )\r
163 \r
164 /*-----------------------------------------------------------*/\r
165 \r
166 /*\r
167  * The check timer callback function, as described at the top of this file.\r
168  */\r
169 static void prvCheckTimerCallback( xTimerHandle xTimer );\r
170 \r
171 /*\r
172  * Register check tasks, and the tasks used to write over and check the contents\r
173  * of the FPU registers, as described at the top of this file.  The nature of\r
174  * these files necessitates that they are written in an assembly file.\r
175  */\r
176 static void vRegTest1Task( void *pvParameters );\r
177 static void vRegTest2Task( void *pvParameters );\r
178 \r
179 /*-----------------------------------------------------------*/\r
180 \r
181 /* The following two variables are used to communicate the status of the\r
182 register check tasks to the check software timer.  If the variables keep\r
183 incrementing, then the register check tasks has not discovered any errors.  If\r
184 a variable stops incrementing, then an error has been found. */\r
185 volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;\r
186 \r
187 /*-----------------------------------------------------------*/\r
188 \r
189 void main_full( void )\r
190 {\r
191 xTimerHandle xCheckTimer = NULL;\r
192 \r
193         /* Start all the other standard demo/test tasks.  The have not particular\r
194         functionality, but do demonstrate how to use the FreeRTOS API and test the\r
195         kernel port. */\r
196         vStartIntegerMathTasks( tskIDLE_PRIORITY );\r
197         vStartDynamicPriorityTasks();\r
198         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
199         vCreateBlockTimeTasks();\r
200         vStartCountingSemaphoreTasks();\r
201         vStartGenericQueueTasks( tskIDLE_PRIORITY );\r
202         vStartRecursiveMutexTasks();\r
203         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
204         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
205         vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
206         \r
207         /* Create the register check tasks, as described at the top of this\r
208         file */\r
209         xTaskCreate( vRegTest1Task, ( signed char * ) "Reg1", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );\r
210         xTaskCreate( vRegTest2Task, ( signed char * ) "Reg2", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );\r
211 \r
212         /* Create the software timer that performs the 'check' functionality,\r
213         as described at the top of this file. */\r
214         xCheckTimer = xTimerCreate( ( const signed char * ) "CheckTimer",/* A text name, purely to help debugging. */\r
215                                                                 ( mainCHECK_TIMER_PERIOD_MS ),          /* The timer period, in this case 3000ms (3s). */\r
216                                                                 pdTRUE,                                                         /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
217                                                                 ( void * ) 0,                                           /* The ID is not used, so can be set to anything. */\r
218                                                                 prvCheckTimerCallback                           /* The callback function that inspects the status of all the other tasks. */\r
219                                                           );    \r
220         \r
221         if( xCheckTimer != NULL )\r
222         {\r
223                 xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
224         }\r
225 \r
226         /* The set of tasks created by the following function call have to be \r
227         created last as they keep account of the number of tasks they expect to see \r
228         running. */\r
229         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
230 \r
231         /* Start the scheduler. */\r
232         vTaskStartScheduler();\r
233         \r
234         /* If all is well, the scheduler will now be running, and the following line\r
235         will never be reached.  If the following line does execute, then there was\r
236         insufficient FreeRTOS heap memory available for the idle and/or timer tasks\r
237         to be created.  See the memory management section on the FreeRTOS web site\r
238         for more details. */\r
239         for( ;; )\r
240         {\r
241                 __asm volatile( "NOP" );\r
242         }\r
243 }\r
244 /*-----------------------------------------------------------*/\r
245 \r
246 static void prvCheckTimerCallback( xTimerHandle xTimer )\r
247 {\r
248 static long lChangedTimerPeriodAlready = pdFALSE;\r
249 static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;\r
250 unsigned long ulErrorFound = pdFALSE;\r
251 \r
252         /* Check all the demo tasks (other than the flash tasks) to ensure\r
253         that they are all still running, and that none have detected an error. */\r
254 \r
255         if( xAreMathsTaskStillRunning() != pdTRUE )\r
256         {\r
257                 ulErrorFound = pdTRUE;\r
258         }\r
259 \r
260         if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
261         {\r
262                 ulErrorFound = pdTRUE;\r
263         }\r
264 \r
265         if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
266         {\r
267                 ulErrorFound = pdTRUE;\r
268         }\r
269 \r
270         if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
271         {\r
272                 ulErrorFound = pdTRUE;\r
273         }\r
274 \r
275         if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
276         {\r
277                 ulErrorFound = pdTRUE;\r
278         }\r
279 \r
280         if ( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
281         {\r
282                 ulErrorFound = pdTRUE;\r
283         }\r
284 \r
285         if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
286         {\r
287                 ulErrorFound = pdTRUE;\r
288         }\r
289 \r
290         if( xIsCreateTaskStillRunning() != pdTRUE )\r
291         {\r
292                 ulErrorFound = pdTRUE;\r
293         }\r
294 \r
295         if( xArePollingQueuesStillRunning() != pdTRUE )\r
296         {\r
297                 ulErrorFound = pdTRUE;\r
298         }\r
299 \r
300         if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
301         {\r
302                 ulErrorFound = pdTRUE;\r
303         }\r
304         \r
305         /* Check that the register test 1 task is still running. */\r
306         if( ulLastRegTest1Value == ulRegTest1LoopCounter )\r
307         {\r
308                 ulErrorFound = pdTRUE;\r
309         }\r
310         ulLastRegTest1Value = ulRegTest1LoopCounter;\r
311 \r
312         /* Check that the register test 2 task is still running. */\r
313         if( ulLastRegTest2Value == ulRegTest2LoopCounter )\r
314         {\r
315                 ulErrorFound = pdTRUE;\r
316         }\r
317         ulLastRegTest2Value = ulRegTest2LoopCounter;\r
318 \r
319         /* Toggle the check LED to give an indication of the system status.  If\r
320         the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then\r
321         everything is ok.  A faster toggle indicates an error. */\r
322         mainTOGGLE_LED();       \r
323         \r
324         /* Have any errors been latch in ulErrorFound?  If so, shorten the\r
325         period of the check timer to mainERROR_CHECK_TIMER_PERIOD_MS milliseconds.\r
326         This will result in an increase in the rate at which mainCHECK_LED\r
327         toggles. */\r
328         if( ulErrorFound != pdFALSE )\r
329         {\r
330                 if( lChangedTimerPeriodAlready == pdFALSE )\r
331                 {\r
332                         lChangedTimerPeriodAlready = pdTRUE;\r
333                         \r
334                         /* This call to xTimerChangePeriod() uses a zero block time.\r
335                         Functions called from inside of a timer callback function must\r
336                         *never* attempt to block. */\r
337                         xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );\r
338                 }\r
339         }\r
340 }\r
341 /*-----------------------------------------------------------*/\r
342 \r
343 /* This is a naked function. */\r
344 static void vRegTest1Task( void *pvParameters )\r
345 {\r
346         __asm volatile\r
347         (\r
348                 "                                                                                                                       \n" /* Fill the core registers with known values. */\r
349                 "       mov r0, #100                                                                                    \n"\r
350                 "       mov r1, #101                                                                                    \n"\r
351                 "       mov r2, #102                                                                                    \n"\r
352                 "       mov r3, #103                                                                                    \n"\r
353                 "       mov     r4, #104                                                                                        \n"\r
354                 "       mov     r5, #105                                                                                        \n"\r
355                 "       mov     r6, #106                                                                                        \n"\r
356                 "       mov r7, #107                                                                                    \n"\r
357                 "       mov     r8, #108                                                                                        \n"\r
358                 "       mov     r9, #109                                                                                        \n"\r
359                 "       mov     r10, #110                                                                                       \n"\r
360                 "       mov     r11, #111                                                                                       \n"\r
361                 "       mov r12, #112                                                                                   \n"\r
362                 "                                                                                                                       \n"\r
363                 "       vmov d0, r0, r1                                                                                 \n" /* Fill the VFP registers with known values. */\r
364                 "       vmov d1, r2, r3                                                                                 \n"\r
365                 "       vmov d2, r4, r5                                                                                 \n"\r
366                 "       vmov d3, r6, r7                                                                                 \n"\r
367                 "       vmov d4, r8, r9                                                                                 \n"\r
368                 "       vmov d5, r10, r11                                                                               \n"\r
369                 "       vmov d6, r0, r1                                                                                 \n"\r
370                 "       vmov d7, r2, r3                                                                                 \n"\r
371                 "       vmov d8, r4, r5                                                                                 \n"\r
372                 "       vmov d9, r6, r7                                                                                 \n"\r
373                 "       vmov d10, r8, r9                                                                                \n"\r
374                 "       vmov d11, r10, r11                                                                              \n"\r
375                 "       vmov d12, r0, r1                                                                                \n"\r
376                 "       vmov d13, r2, r3                                                                                \n"\r
377                 "       vmov d14, r4, r5                                                                                \n"\r
378                 "       vmov d15, r6, r7                                                                                \n"\r
379                 "                                                                                                                       \n"\r
380                 "reg1_loop:                                                                                                     \n" /* Check all the VFP registers still contain the values set above." */\r
381                 "       push { r0-r1 }                                                                                  \n" /* First save registers that are clobbered by the test. */\r
382                 "                                                                                                                       \n"\r
383                 "       vmov r0, r1, d0                                                                                 \n"\r
384                 "       cmp r0, #100                                                                                    \n"\r
385                 "       bne reg1_error_loopf                                                                    \n"\r
386                 "       cmp r1, #101                                                                                    \n"\r
387                 "       bne reg1_error_loopf                                                                    \n"\r
388                 "       vmov r0, r1, d1                                                                                 \n"\r
389                 "       cmp r0, #102                                                                                    \n"\r
390                 "       bne reg1_error_loopf                                                                    \n"\r
391                 "       cmp r1, #103                                                                                    \n"\r
392                 "       bne reg1_error_loopf                                                                    \n"\r
393                 "       vmov r0, r1, d2                                                                                 \n"\r
394                 "       cmp r0, #104                                                                                    \n"\r
395                 "       bne reg1_error_loopf                                                                    \n"\r
396                 "       cmp r1, #105                                                                                    \n"\r
397                 "       bne reg1_error_loopf                                                                    \n"\r
398                 "       vmov r0, r1, d3                                                                                 \n"\r
399                 "       cmp r0, #106                                                                                    \n"\r
400                 "       bne reg1_error_loopf                                                                    \n"\r
401                 "       cmp r1, #107                                                                                    \n"\r
402                 "       bne reg1_error_loopf                                                                    \n"\r
403                 "       vmov r0, r1, d4                                                                                 \n"\r
404                 "       cmp r0, #108                                                                                    \n"\r
405                 "       bne reg1_error_loopf                                                                    \n"\r
406                 "       cmp r1, #109                                                                                    \n"\r
407                 "       bne reg1_error_loopf                                                                    \n"\r
408                 "       vmov r0, r1, d5                                                                                 \n"\r
409                 "       cmp r0, #110                                                                                    \n"\r
410                 "       bne reg1_error_loopf                                                                    \n"\r
411                 "       cmp r1, #111                                                                                    \n"\r
412                 "       bne reg1_error_loopf                                                                    \n"\r
413                 "       vmov r0, r1, d6                                                                                 \n"\r
414                 "       cmp r0, #100                                                                                    \n"\r
415                 "       bne reg1_error_loopf                                                                    \n"\r
416                 "       cmp r1, #101                                                                                    \n"\r
417                 "       bne reg1_error_loopf                                                                    \n"\r
418                 "       vmov r0, r1, d7                                                                                 \n"\r
419                 "       cmp r0, #102                                                                                    \n"\r
420                 "       bne reg1_error_loopf                                                                    \n"\r
421                 "       cmp r1, #103                                                                                    \n"\r
422                 "       bne reg1_error_loopf                                                                    \n"\r
423                 "       vmov r0, r1, d8                                                                                 \n"\r
424                 "       cmp r0, #104                                                                                    \n"\r
425                 "       bne reg1_error_loopf                                                                    \n"\r
426                 "       cmp r1, #105                                                                                    \n"\r
427                 "       bne reg1_error_loopf                                                                    \n"\r
428                 "       vmov r0, r1, d9                                                                                 \n"\r
429                 "       cmp r0, #106                                                                                    \n"\r
430                 "       bne reg1_error_loopf                                                                    \n"\r
431                 "       cmp r1, #107                                                                                    \n"\r
432                 "       bne reg1_error_loopf                                                                    \n"\r
433                 "       vmov r0, r1, d10                                                                                \n"\r
434                 "       cmp r0, #108                                                                                    \n"\r
435                 "       bne reg1_error_loopf                                                                    \n"\r
436                 "       cmp r1, #109                                                                                    \n"\r
437                 "       bne reg1_error_loopf                                                                    \n"\r
438                 "       vmov r0, r1, d11                                                                                \n"\r
439                 "       cmp r0, #110                                                                                    \n"\r
440                 "       bne reg1_error_loopf                                                                    \n"\r
441                 "       cmp r1, #111                                                                                    \n"\r
442                 "       bne reg1_error_loopf                                                                    \n"\r
443                 "       vmov r0, r1, d12                                                                                \n"\r
444                 "       cmp r0, #100                                                                                    \n"\r
445                 "       bne reg1_error_loopf                                                                    \n"\r
446                 "       cmp r1, #101                                                                                    \n"\r
447                 "       bne reg1_error_loopf                                                                    \n"\r
448                 "       vmov r0, r1, d13                                                                                \n"\r
449                 "       cmp r0, #102                                                                                    \n"\r
450                 "       bne reg1_error_loopf                                                                    \n"\r
451                 "       cmp r1, #103                                                                                    \n"\r
452                 "       bne reg1_error_loopf                                                                    \n"\r
453                 "       vmov r0, r1, d14                                                                                \n"\r
454                 "       cmp r0, #104                                                                                    \n"\r
455                 "       bne reg1_error_loopf                                                                    \n"\r
456                 "       cmp r1, #105                                                                                    \n"\r
457                 "       bne reg1_error_loopf                                                                    \n"\r
458                 "       vmov r0, r1, d15                                                                                \n"\r
459                 "       cmp r0, #106                                                                                    \n"\r
460                 "       bne reg1_error_loopf                                                                    \n"\r
461                 "       cmp r1, #107                                                                                    \n"\r
462                 "       bne reg1_error_loopf                                                                    \n"\r
463                 "                                                                                                                       \n"\r
464                 "       pop {r0-r1}                                                                                             \n" /* Restore the registers that were clobbered by the test. */\r
465                 "                                                                                                                       \n"\r
466                 "       b reg1_loopf_pass                                                                               \n" /* VFP register test passed.  Jump to the core register test. */\r
467                 "                                                                                                                       \n"\r
468                 "reg1_error_loopf:                                                                                      \n"\r
469                 "       b reg1_error_loopf                                                                              \n" /* If this line is hit then a VFP register value was found to be\n incorrect. */\r
470                 "                                                                                                                       \n"\r
471                 "reg1_loopf_pass:                                                                                       \n"\r
472                 "                                                                                                                       \n"\r
473                 "       cmp     r0, #100                                                                                        \n"\r
474                 "       bne     reg1_error_loop                                                                         \n"\r
475                 "       cmp     r1, #101                                                                                        \n"\r
476                 "       bne     reg1_error_loop                                                                         \n"\r
477                 "       cmp     r2, #102                                                                                        \n"\r
478                 "       bne     reg1_error_loop                                                                         \n"\r
479                 "       cmp r3, #103                                                                                    \n"\r
480                 "       bne     reg1_error_loop                                                                         \n"\r
481                 "       cmp     r4, #104                                                                                        \n"\r
482                 "       bne     reg1_error_loop                                                                         \n"\r
483                 "       cmp     r5, #105                                                                                        \n"\r
484                 "       bne     reg1_error_loop                                                                         \n"\r
485                 "       cmp     r6, #106                                                                                        \n"\r
486                 "       bne     reg1_error_loop                                                                         \n"\r
487                 "       cmp     r7, #107                                                                                        \n"\r
488                 "       bne     reg1_error_loop                                                                         \n"\r
489                 "       cmp     r8, #108                                                                                        \n"\r
490                 "       bne     reg1_error_loop                                                                         \n"\r
491                 "       cmp     r9, #109                                                                                        \n"\r
492                 "       bne     reg1_error_loop                                                                         \n"\r
493                 "       cmp     r10, #110                                                                                       \n"\r
494                 "       bne     reg1_error_loop                                                                         \n"\r
495                 "       cmp     r11, #111                                                                                       \n"\r
496                 "       bne     reg1_error_loop                                                                         \n"\r
497                 "       cmp     r12, #112                                                                                       \n"\r
498                 "       bne     reg1_error_loop                                                                         \n"\r
499                 "                                                                                                                       \n"\r
500                 "       push { r0-r1 }                                                                                  \n" /* Everything passed, increment the loop counter. */\r
501                 "       ldr     r0, =ulRegTest1LoopCounter                                                      \n"\r
502                 "       ldr r1, [r0]                                                                                    \n"\r
503                 "       adds r1, r1, #1                                                                                 \n"\r
504                 "       str r1, [r0]                                                                                    \n"\r
505                 "       pop { r0-r1 }                                                                                   \n"\r
506                 "                                                                                                                       \n"\r
507                 "       b reg1_loop                                                                                             \n" /* Start again. */\r
508                 "                                                                                                                       \n"\r
509                 "reg1_error_loop:                                                                                       \n" /* If this line is hit then there was an error in a core register value. */\r
510                 "       b reg1_error_loop                                                                               \n" /* The loop ensures the loop counter stops incrementing. */\r
511                 "       nop                                                                                                             "\r
512         );\r
513 }\r
514 /*-----------------------------------------------------------*/\r
515 \r
516 /* This is a naked function. */\r
517 static void vRegTest2Task( void *pvParameters )\r
518 {\r
519         __asm volatile\r
520         (\r
521                 "       mov r0, #-1                                                                                             \n" /* Set all the core registers to known values. */\r
522                 "       mov r1, #1                                                                                              \n"\r
523                 "       mov r2, #2                                                                                              \n"\r
524                 "       mov r3, #3                                                                                              \n"\r
525                 "       mov     r4, #4                                                                                          \n"\r
526                 "       mov     r5, #5                                                                                          \n"\r
527                 "       mov     r6, #6                                                                                          \n"\r
528                 "       mov r7, #7                                                                                              \n"\r
529                 "       mov     r8, #8                                                                                          \n"\r
530                 "       mov     r9, #9                                                                                          \n"\r
531                 "       mov     r10, #10                                                                                        \n"\r
532                 "       mov     r11, #11                                                                                        \n"\r
533                 "       mov r12, #12                                                                                    \n"\r
534                 "                                                                                                                       \n"\r
535                 "       vmov d0, r0, r1                                                                                 \n" /* Set all the VFP to known values. */\r
536                 "       vmov d1, r2, r3                                                                                 \n"\r
537                 "       vmov d2, r4, r5                                                                                 \n"\r
538                 "       vmov d3, r6, r7                                                                                 \n"\r
539                 "       vmov d4, r8, r9                                                                                 \n"\r
540                 "       vmov d5, r10, r11                                                                               \n"\r
541                 "       vmov d6, r0, r1                                                                                 \n"\r
542                 "       vmov d7, r2, r3                                                                                 \n"\r
543                 "       vmov d8, r4, r5                                                                                 \n"\r
544                 "       vmov d9, r6, r7                                                                                 \n"\r
545                 "       vmov d10, r8, r9                                                                                \n"\r
546                 "       vmov d11, r10, r11                                                                              \n"\r
547                 "       vmov d12, r0, r1                                                                                \n"\r
548                 "       vmov d13, r2, r3                                                                                \n"\r
549                 "       vmov d14, r4, r5                                                                                \n"\r
550                 "       vmov d15, r6, r7                                                                                \n"\r
551                 "                                                                                                                       \n"\r
552                 "reg2_loop:                                                                                                     \n"\r
553                 "                                                                                                                       \n"\r
554                 "       push { r0-r1 }                                                                                  \n" /* Check all the VFP registers still contain the values set above. */\r
555                 "       vmov r0, r1, d0                                                                                 \n" /*First save registers that are clobbered by the test. */\r
556                 "       cmp r0, #-1                                                                                             \n"\r
557                 "       bne reg2_error_loopf                                                                    \n"\r
558                 "       cmp r1, #1                                                                                              \n"\r
559                 "       bne reg2_error_loopf                                                                    \n"\r
560                 "       vmov r0, r1, d1                                                                                 \n"\r
561                 "       cmp r0, #2                                                                                              \n"\r
562                 "       bne reg2_error_loopf                                                                    \n"\r
563                 "       cmp r1, #3                                                                                              \n"\r
564                 "       bne reg2_error_loopf                                                                    \n"\r
565                 "       vmov r0, r1, d2                                                                                 \n"\r
566                 "       cmp r0, #4                                                                                              \n"\r
567                 "       bne reg2_error_loopf                                                                    \n"\r
568                 "       cmp r1, #5                                                                                              \n"\r
569                 "       bne reg2_error_loopf                                                                    \n"\r
570                 "       vmov r0, r1, d3                                                                                 \n"\r
571                 "       cmp r0, #6                                                                                              \n"\r
572                 "       bne reg2_error_loopf                                                                    \n"\r
573                 "       cmp r1, #7                                                                                              \n"\r
574                 "       bne reg2_error_loopf                                                                    \n"\r
575                 "       vmov r0, r1, d4                                                                                 \n"\r
576                 "       cmp r0, #8                                                                                              \n"\r
577                 "       bne reg2_error_loopf                                                                    \n"\r
578                 "       cmp r1, #9                                                                                              \n"\r
579                 "       bne reg2_error_loopf                                                                    \n"\r
580                 "       vmov r0, r1, d5                                                                                 \n"\r
581                 "       cmp r0, #10                                                                                             \n"\r
582                 "       bne reg2_error_loopf                                                                    \n"\r
583                 "       cmp r1, #11                                                                                             \n"\r
584                 "       bne reg2_error_loopf                                                                    \n"\r
585                 "       vmov r0, r1, d6                                                                                 \n"\r
586                 "       cmp r0, #-1                                                                                             \n"\r
587                 "       bne reg2_error_loopf                                                                    \n"\r
588                 "       cmp r1, #1                                                                                              \n"\r
589                 "       bne reg2_error_loopf                                                                    \n"\r
590                 "       vmov r0, r1, d7                                                                                 \n"\r
591                 "       cmp r0, #2                                                                                              \n"\r
592                 "       bne reg2_error_loopf                                                                    \n"\r
593                 "       cmp r1, #3                                                                                              \n"\r
594                 "       bne reg2_error_loopf                                                                    \n"\r
595                 "       vmov r0, r1, d8                                                                                 \n"\r
596                 "       cmp r0, #4                                                                                              \n"\r
597                 "       bne reg2_error_loopf                                                                    \n"\r
598                 "       cmp r1, #5                                                                                              \n"\r
599                 "       bne reg2_error_loopf                                                                    \n"\r
600                 "       vmov r0, r1, d9                                                                                 \n"\r
601                 "       cmp r0, #6                                                                                              \n"\r
602                 "       bne reg2_error_loopf                                                                    \n"\r
603                 "       cmp r1, #7                                                                                              \n"\r
604                 "       bne reg2_error_loopf                                                                    \n"\r
605                 "       vmov r0, r1, d10                                                                                \n"\r
606                 "       cmp r0, #8                                                                                              \n"\r
607                 "       bne reg2_error_loopf                                                                    \n"\r
608                 "       cmp r1, #9                                                                                              \n"\r
609                 "       bne reg2_error_loopf                                                                    \n"\r
610                 "       vmov r0, r1, d11                                                                                \n"\r
611                 "       cmp r0, #10                                                                                             \n"\r
612                 "       bne reg2_error_loopf                                                                    \n"\r
613                 "       cmp r1, #11                                                                                             \n"\r
614                 "       bne reg2_error_loopf                                                                    \n"\r
615                 "       vmov r0, r1, d12                                                                                \n"\r
616                 "       cmp r0, #-1                                                                                             \n"\r
617                 "       bne reg2_error_loopf                                                                    \n"\r
618                 "       cmp r1, #1                                                                                              \n"\r
619                 "       bne reg2_error_loopf                                                                    \n"\r
620                 "       vmov r0, r1, d13                                                                                \n"\r
621                 "       cmp r0, #2                                                                                              \n"\r
622                 "       bne reg2_error_loopf                                                                    \n"\r
623                 "       cmp r1, #3                                                                                              \n"\r
624                 "       bne reg2_error_loopf                                                                    \n"\r
625                 "       vmov r0, r1, d14                                                                                \n"\r
626                 "       cmp r0, #4                                                                                              \n"\r
627                 "       bne reg2_error_loopf                                                                    \n"\r
628                 "       cmp r1, #5                                                                                              \n"\r
629                 "       bne reg2_error_loopf                                                                    \n"\r
630                 "       vmov r0, r1, d15                                                                                \n"\r
631                 "       cmp r0, #6                                                                                              \n"\r
632                 "       bne reg2_error_loopf                                                                    \n"\r
633                 "       cmp r1, #7                                                                                              \n"\r
634                 "       bne reg2_error_loopf                                                                    \n"\r
635                 "                                                                                                                       \n"\r
636                 "       pop {r0-r1}                                                                                             \n" /* Restore the registers that were clobbered by the test. */\r
637                 "                                                                                                                       \n"\r
638                 "       b reg2_loopf_pass                                                                               \n" /* VFP register test passed.  Jump to the core register test. */\r
639                 "                                                                                                                       \n"\r
640                 "reg2_error_loopf:                                                                                      \n"\r
641                 "       b reg2_error_loopf                                                                              \n" /* If this line is hit then a VFP register value was found to be incorrect. */\r
642                 "                                                                                                                       \n"\r
643                 "reg2_loopf_pass:                                                                                       \n"\r
644                 "                                                                                                                       \n"\r
645                 "       cmp     r0, #-1                                                                                         \n"\r
646                 "       bne     reg2_error_loop                                                                         \n"\r
647                 "       cmp     r1, #1                                                                                          \n"\r
648                 "       bne     reg2_error_loop                                                                         \n"\r
649                 "       cmp     r2, #2                                                                                          \n"\r
650                 "       bne     reg2_error_loop                                                                         \n"\r
651                 "       cmp r3, #3                                                                                              \n"\r
652                 "       bne     reg2_error_loop                                                                         \n"\r
653                 "       cmp     r4, #4                                                                                          \n"\r
654                 "       bne     reg2_error_loop                                                                         \n"\r
655                 "       cmp     r5, #5                                                                                          \n"\r
656                 "       bne     reg2_error_loop                                                                         \n"\r
657                 "       cmp     r6, #6                                                                                          \n"\r
658                 "       bne     reg2_error_loop                                                                         \n"\r
659                 "       cmp     r7, #7                                                                                          \n"\r
660                 "       bne     reg2_error_loop                                                                         \n"\r
661                 "       cmp     r8, #8                                                                                          \n"\r
662                 "       bne     reg2_error_loop                                                                         \n"\r
663                 "       cmp     r9, #9                                                                                          \n"\r
664                 "       bne     reg2_error_loop                                                                         \n"\r
665                 "       cmp     r10, #10                                                                                        \n"\r
666                 "       bne     reg2_error_loop                                                                         \n"\r
667                 "       cmp     r11, #11                                                                                        \n"\r
668                 "       bne     reg2_error_loop                                                                         \n"\r
669                 "       cmp     r12, #12                                                                                        \n"\r
670                 "       bne     reg2_error_loop                                                                         \n"\r
671                 "                                                                                                                       \n"\r
672                 "       push { r0-r1 }                                                                                  \n" /* Increment the loop counter to indicate this test is still functioning correctly. */\r
673                 "       ldr     r0, =ulRegTest2LoopCounter                                                      \n"\r
674                 "       ldr r1, [r0]                                                                                    \n"\r
675                 "       adds r1, r1, #1                                                                                 \n"\r
676                 "       str r1, [r0]                                                                                    \n"\r
677                 "       pop { r0-r1 }                                                                                   \n"\r
678                 "                                                                                                                       \n"\r
679                 "       b reg2_loop                                                                                             \n" /* Start again. */\r
680                 "                                                                                                                       \n"\r
681                 "reg2_error_loop:                                                                                       \n" /* If this line is hit then there was an error in a core register value. */\r
682                 "       b reg2_error_loop                                                                               \n" /* This loop ensures the loop counter variable stops incrementing. */\r
683                 "       nop                                                                                                             \n"\r
684         );\r
685 }\r
686 \r
687 \r
688 \r