]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4F_Infineon_XMC4500_GCC_Atollic/src/main_full.c
d7961d1a1ba22d518c5ceb52511a03433118dbe5
[freertos] / FreeRTOS / Demo / CORTEX_M4F_Infineon_XMC4500_GCC_Atollic / src / main_full.c
1 /*\r
2     FreeRTOS V7.4.2 - 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 ) __attribute__((naked));\r
177 static void vRegTest2Task( void *pvParameters ) __attribute__((naked));\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 /*-----------------------------------------------------------*/\r
242 \r
243 static void prvCheckTimerCallback( xTimerHandle xTimer )\r
244 {\r
245 static long lChangedTimerPeriodAlready = pdFALSE;\r
246 static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;\r
247 unsigned long ulErrorFound = pdFALSE;\r
248 \r
249         /* Check all the demo tasks (other than the flash tasks) to ensure\r
250         that they are all still running, and that none have detected an error. */\r
251 \r
252         if( xAreMathsTaskStillRunning() != pdTRUE )\r
253         {\r
254                 ulErrorFound = pdTRUE;\r
255         }\r
256 \r
257         if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
258         {\r
259                 ulErrorFound = pdTRUE;\r
260         }\r
261 \r
262         if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
263         {\r
264                 ulErrorFound = pdTRUE;\r
265         }\r
266 \r
267         if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
268         {\r
269                 ulErrorFound = pdTRUE;\r
270         }\r
271 \r
272         if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
273         {\r
274                 ulErrorFound = pdTRUE;\r
275         }\r
276 \r
277         if ( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
278         {\r
279                 ulErrorFound = pdTRUE;\r
280         }\r
281 \r
282         if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
283         {\r
284                 ulErrorFound = pdTRUE;\r
285         }\r
286 \r
287         if( xIsCreateTaskStillRunning() != pdTRUE )\r
288         {\r
289                 ulErrorFound = pdTRUE;\r
290         }\r
291 \r
292         if( xArePollingQueuesStillRunning() != pdTRUE )\r
293         {\r
294                 ulErrorFound = pdTRUE;\r
295         }\r
296 \r
297         if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
298         {\r
299                 ulErrorFound = pdTRUE;\r
300         }\r
301         \r
302         /* Check that the register test 1 task is still running. */\r
303         if( ulLastRegTest1Value == ulRegTest1LoopCounter )\r
304         {\r
305                 ulErrorFound = pdTRUE;\r
306         }\r
307         ulLastRegTest1Value = ulRegTest1LoopCounter;\r
308 \r
309         /* Check that the register test 2 task is still running. */\r
310         if( ulLastRegTest2Value == ulRegTest2LoopCounter )\r
311         {\r
312                 ulErrorFound = pdTRUE;\r
313         }\r
314         ulLastRegTest2Value = ulRegTest2LoopCounter;\r
315 \r
316         /* Toggle the check LED to give an indication of the system status.  If\r
317         the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then\r
318         everything is ok.  A faster toggle indicates an error. */\r
319         mainTOGGLE_LED();       \r
320         \r
321         /* Have any errors been latch in ulErrorFound?  If so, shorten the\r
322         period of the check timer to mainERROR_CHECK_TIMER_PERIOD_MS milliseconds.\r
323         This will result in an increase in the rate at which mainCHECK_LED\r
324         toggles. */\r
325         if( ulErrorFound != pdFALSE )\r
326         {\r
327                 if( lChangedTimerPeriodAlready == pdFALSE )\r
328                 {\r
329                         lChangedTimerPeriodAlready = pdTRUE;\r
330                         \r
331                         /* This call to xTimerChangePeriod() uses a zero block time.\r
332                         Functions called from inside of a timer callback function must\r
333                         *never* attempt to block. */\r
334                         xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );\r
335                 }\r
336         }\r
337 }\r
338 /*-----------------------------------------------------------*/\r
339 \r
340 /* This is a naked function. */\r
341 static void vRegTest1Task( void *pvParameters )\r
342 {\r
343         __asm volatile\r
344         (\r
345                 "       /* Fill the core registers with known values. */                \n"\r
346                 "       mov r0, #100                                                                                    \n"\r
347                 "       mov r1, #101                                                                                    \n"\r
348                 "       mov r2, #102                                                                                    \n"\r
349                 "       mov r3, #103                                                                                    \n"\r
350                 "       mov     r4, #104                                                                                        \n"\r
351                 "       mov     r5, #105                                                                                        \n"\r
352                 "       mov     r6, #106                                                                                        \n"\r
353                 "       mov r7, #107                                                                                    \n"\r
354                 "       mov     r8, #108                                                                                        \n"\r
355                 "       mov     r9, #109                                                                                        \n"\r
356                 "       mov     r10, #110                                                                                       \n"\r
357                 "       mov     r11, #111                                                                                       \n"\r
358                 "       mov r12, #112                                                                                   \n"\r
359                 "                                                                                                                       \n"\r
360                 "       /* Fill the VFP registers with known values. */                 \n"\r
361                 "       vmov d0, r0, r1                                                                                 \n"\r
362                 "       vmov d1, r2, r3                                                                                 \n"\r
363                 "       vmov d2, r4, r5                                                                                 \n"\r
364                 "       vmov d3, r6, r7                                                                                 \n"\r
365                 "       vmov d4, r8, r9                                                                                 \n"\r
366                 "       vmov d5, r10, r11                                                                               \n"\r
367                 "       vmov d6, r0, r1                                                                                 \n"\r
368                 "       vmov d7, r2, r3                                                                                 \n"\r
369                 "       vmov d8, r4, r5                                                                                 \n"\r
370                 "       vmov d9, r6, r7                                                                                 \n"\r
371                 "       vmov d10, r8, r9                                                                                \n"\r
372                 "       vmov d11, r10, r11                                                                              \n"\r
373                 "       vmov d12, r0, r1                                                                                \n"\r
374                 "       vmov d13, r2, r3                                                                                \n"\r
375                 "       vmov d14, r4, r5                                                                                \n"\r
376                 "       vmov d15, r6, r7                                                                                \n"\r
377                 "                                                                                                                       \n"\r
378                 "reg1_loop:                                                                                                     \n"\r
379                 "       /* Check all the VFP registers still contain the values set above.\n"\r
380                 "       First save registers that are clobbered by the test. */ \n"\r
381                 "       push { r0-r1 }                                                                                  \n"\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                 "       /* Restore the registers that were clobbered by the test. */\n"\r
465                 "       pop {r0-r1}                                                                                             \n"\r
466                 "                                                                                                                       \n"\r
467                 "       /* VFP register test passed.  Jump to the core register test. */\n"\r
468                 "       b reg1_loopf_pass                                                                               \n"\r
469                 "                                                                                                                       \n"\r
470                 "reg1_error_loopf:                                                                                      \n"\r
471                 "       /* If this line is hit then a VFP register value was found to be\n"\r
472                 "       incorrect. */                                                                                   \n"\r
473                 "       b reg1_error_loopf                                                                              \n"\r
474                 "                                                                                                                       \n"\r
475                 "reg1_loopf_pass:                                                                                       \n"\r
476                 "                                                                                                                       \n"\r
477                 "       cmp     r0, #100                                                                                        \n"\r
478                 "       bne     reg1_error_loop                                                                         \n"\r
479                 "       cmp     r1, #101                                                                                        \n"\r
480                 "       bne     reg1_error_loop                                                                         \n"\r
481                 "       cmp     r2, #102                                                                                        \n"\r
482                 "       bne     reg1_error_loop                                                                         \n"\r
483                 "       cmp r3, #103                                                                                    \n"\r
484                 "       bne     reg1_error_loop                                                                         \n"\r
485                 "       cmp     r4, #104                                                                                        \n"\r
486                 "       bne     reg1_error_loop                                                                         \n"\r
487                 "       cmp     r5, #105                                                                                        \n"\r
488                 "       bne     reg1_error_loop                                                                         \n"\r
489                 "       cmp     r6, #106                                                                                        \n"\r
490                 "       bne     reg1_error_loop                                                                         \n"\r
491                 "       cmp     r7, #107                                                                                        \n"\r
492                 "       bne     reg1_error_loop                                                                         \n"\r
493                 "       cmp     r8, #108                                                                                        \n"\r
494                 "       bne     reg1_error_loop                                                                         \n"\r
495                 "       cmp     r9, #109                                                                                        \n"\r
496                 "       bne     reg1_error_loop                                                                         \n"\r
497                 "       cmp     r10, #110                                                                                       \n"\r
498                 "       bne     reg1_error_loop                                                                         \n"\r
499                 "       cmp     r11, #111                                                                                       \n"\r
500                 "       bne     reg1_error_loop                                                                         \n"\r
501                 "       cmp     r12, #112                                                                                       \n"\r
502                 "       bne     reg1_error_loop                                                                         \n"\r
503                 "                                                                                                                       \n"\r
504                 "       /* Everything passed, increment the loop counter. */    \n"\r
505                 "       push { r0-r1 }                                                                                  \n"\r
506                 "       ldr     r0, =ulRegTest1LoopCounter                                                      \n"\r
507                 "       ldr r1, [r0]                                                                                    \n"\r
508                 "       adds r1, r1, #1                                                                                 \n"\r
509                 "       str r1, [r0]                                                                                    \n"\r
510                 "       pop { r0-r1 }                                                                                   \n"\r
511                 "                                                                                                                       \n"\r
512                 "       /* Start again. */                                                                              \n"\r
513                 "       b reg1_loop                                                                                             \n"\r
514                 "                                                                                                                       \n"\r
515                 "reg1_error_loop:                                                                                       \n"\r
516                 "       /* If this line is hit then there was an error in a core register value.\n"\r
517                 "       The loop ensures the loop counter stops incrementing. */\n"\r
518                 "       b reg1_error_loop                                                                               \n"\r
519                 "       nop                                                                                                             "\r
520         );\r
521 }\r
522 /*-----------------------------------------------------------*/\r
523 \r
524 /* This is a naked function. */\r
525 static void vRegTest2Task( void *pvParameters )\r
526 {\r
527         __asm volatile\r
528         (\r
529                 "       /* Set all the core registers to known values. */               \n"\r
530                 "       mov r0, #-1                                                                                             \n"\r
531                 "       mov r1, #1                                                                                              \n"\r
532                 "       mov r2, #2                                                                                              \n"\r
533                 "       mov r3, #3                                                                                              \n"\r
534                 "       mov     r4, #4                                                                                          \n"\r
535                 "       mov     r5, #5                                                                                          \n"\r
536                 "       mov     r6, #6                                                                                          \n"\r
537                 "       mov r7, #7                                                                                              \n"\r
538                 "       mov     r8, #8                                                                                          \n"\r
539                 "       mov     r9, #9                                                                                          \n"\r
540                 "       mov     r10, #10                                                                                        \n"\r
541                 "       mov     r11, #11                                                                                        \n"\r
542                 "       mov r12, #12                                                                                    \n"\r
543                 "                                                                                                                       \n"\r
544                 "       /* Set all the VFP to known values. */                                  \n"\r
545                 "       vmov d0, r0, r1                                                                                 \n"\r
546                 "       vmov d1, r2, r3                                                                                 \n"\r
547                 "       vmov d2, r4, r5                                                                                 \n"\r
548                 "       vmov d3, r6, r7                                                                                 \n"\r
549                 "       vmov d4, r8, r9                                                                                 \n"\r
550                 "       vmov d5, r10, r11                                                                               \n"\r
551                 "       vmov d6, r0, r1                                                                                 \n"\r
552                 "       vmov d7, r2, r3                                                                                 \n"\r
553                 "       vmov d8, r4, r5                                                                                 \n"\r
554                 "       vmov d9, r6, r7                                                                                 \n"\r
555                 "       vmov d10, r8, r9                                                                                \n"\r
556                 "       vmov d11, r10, r11                                                                              \n"\r
557                 "       vmov d12, r0, r1                                                                                \n"\r
558                 "       vmov d13, r2, r3                                                                                \n"\r
559                 "       vmov d14, r4, r5                                                                                \n"\r
560                 "       vmov d15, r6, r7                                                                                \n"\r
561                 "                                                                                                                       \n"\r
562                 "reg2_loop:                                                                                                     \n"\r
563                 "                                                                                                                       \n"\r
564                 "       /* Check all the VFP registers still contain the values set above.\n"\r
565                 "       First save registers that are clobbered by the test. */ \n"\r
566                 "       push { r0-r1 }                                                                                  \n"\r
567                 "                                                                                                                       \n"\r
568                 "       vmov r0, r1, d0                                                                                 \n"\r
569                 "       cmp r0, #-1                                                                                             \n"\r
570                 "       bne reg2_error_loopf                                                                    \n"\r
571                 "       cmp r1, #1                                                                                              \n"\r
572                 "       bne reg2_error_loopf                                                                    \n"\r
573                 "       vmov r0, r1, d1                                                                                 \n"\r
574                 "       cmp r0, #2                                                                                              \n"\r
575                 "       bne reg2_error_loopf                                                                    \n"\r
576                 "       cmp r1, #3                                                                                              \n"\r
577                 "       bne reg2_error_loopf                                                                    \n"\r
578                 "       vmov r0, r1, d2                                                                                 \n"\r
579                 "       cmp r0, #4                                                                                              \n"\r
580                 "       bne reg2_error_loopf                                                                    \n"\r
581                 "       cmp r1, #5                                                                                              \n"\r
582                 "       bne reg2_error_loopf                                                                    \n"\r
583                 "       vmov r0, r1, d3                                                                                 \n"\r
584                 "       cmp r0, #6                                                                                              \n"\r
585                 "       bne reg2_error_loopf                                                                    \n"\r
586                 "       cmp r1, #7                                                                                              \n"\r
587                 "       bne reg2_error_loopf                                                                    \n"\r
588                 "       vmov r0, r1, d4                                                                                 \n"\r
589                 "       cmp r0, #8                                                                                              \n"\r
590                 "       bne reg2_error_loopf                                                                    \n"\r
591                 "       cmp r1, #9                                                                                              \n"\r
592                 "       bne reg2_error_loopf                                                                    \n"\r
593                 "       vmov r0, r1, d5                                                                                 \n"\r
594                 "       cmp r0, #10                                                                                             \n"\r
595                 "       bne reg2_error_loopf                                                                    \n"\r
596                 "       cmp r1, #11                                                                                             \n"\r
597                 "       bne reg2_error_loopf                                                                    \n"\r
598                 "       vmov r0, r1, d6                                                                                 \n"\r
599                 "       cmp r0, #-1                                                                                             \n"\r
600                 "       bne reg2_error_loopf                                                                    \n"\r
601                 "       cmp r1, #1                                                                                              \n"\r
602                 "       bne reg2_error_loopf                                                                    \n"\r
603                 "       vmov r0, r1, d7                                                                                 \n"\r
604                 "       cmp r0, #2                                                                                              \n"\r
605                 "       bne reg2_error_loopf                                                                    \n"\r
606                 "       cmp r1, #3                                                                                              \n"\r
607                 "       bne reg2_error_loopf                                                                    \n"\r
608                 "       vmov r0, r1, d8                                                                                 \n"\r
609                 "       cmp r0, #4                                                                                              \n"\r
610                 "       bne reg2_error_loopf                                                                    \n"\r
611                 "       cmp r1, #5                                                                                              \n"\r
612                 "       bne reg2_error_loopf                                                                    \n"\r
613                 "       vmov r0, r1, d9                                                                                 \n"\r
614                 "       cmp r0, #6                                                                                              \n"\r
615                 "       bne reg2_error_loopf                                                                    \n"\r
616                 "       cmp r1, #7                                                                                              \n"\r
617                 "       bne reg2_error_loopf                                                                    \n"\r
618                 "       vmov r0, r1, d10                                                                                \n"\r
619                 "       cmp r0, #8                                                                                              \n"\r
620                 "       bne reg2_error_loopf                                                                    \n"\r
621                 "       cmp r1, #9                                                                                              \n"\r
622                 "       bne reg2_error_loopf                                                                    \n"\r
623                 "       vmov r0, r1, d11                                                                                \n"\r
624                 "       cmp r0, #10                                                                                             \n"\r
625                 "       bne reg2_error_loopf                                                                    \n"\r
626                 "       cmp r1, #11                                                                                             \n"\r
627                 "       bne reg2_error_loopf                                                                    \n"\r
628                 "       vmov r0, r1, d12                                                                                \n"\r
629                 "       cmp r0, #-1                                                                                             \n"\r
630                 "       bne reg2_error_loopf                                                                    \n"\r
631                 "       cmp r1, #1                                                                                              \n"\r
632                 "       bne reg2_error_loopf                                                                    \n"\r
633                 "       vmov r0, r1, d13                                                                                \n"\r
634                 "       cmp r0, #2                                                                                              \n"\r
635                 "       bne reg2_error_loopf                                                                    \n"\r
636                 "       cmp r1, #3                                                                                              \n"\r
637                 "       bne reg2_error_loopf                                                                    \n"\r
638                 "       vmov r0, r1, d14                                                                                \n"\r
639                 "       cmp r0, #4                                                                                              \n"\r
640                 "       bne reg2_error_loopf                                                                    \n"\r
641                 "       cmp r1, #5                                                                                              \n"\r
642                 "       bne reg2_error_loopf                                                                    \n"\r
643                 "       vmov r0, r1, d15                                                                                \n"\r
644                 "       cmp r0, #6                                                                                              \n"\r
645                 "       bne reg2_error_loopf                                                                    \n"\r
646                 "       cmp r1, #7                                                                                              \n"\r
647                 "       bne reg2_error_loopf                                                                    \n"\r
648                 "                                                                                                                       \n"\r
649                 "       /* Restore the registers that were clobbered by the test. */\n"\r
650                 "       pop {r0-r1}                                                                                             \n"\r
651                 "                                                                                                                       \n"\r
652                 "       /* VFP register test passed.  Jump to the core register test. */\n"\r
653                 "       b reg2_loopf_pass                                                                               \n"\r
654                 "                                                                                                                       \n"\r
655                 "reg2_error_loopf:                                                                                      \n"\r
656                 "       /* If this line is hit then a VFP register value was found to be\n"\r
657                 "       incorrect. */                                                                                   \n"\r
658                 "       b reg2_error_loopf                                                                              \n"\r
659                 "                                                                                                                       \n"\r
660                 "reg2_loopf_pass:                                                                                       \n"\r
661                 "                                                                                                                       \n"\r
662                 "       cmp     r0, #-1                                                                                         \n"\r
663                 "       bne     reg2_error_loop                                                                         \n"\r
664                 "       cmp     r1, #1                                                                                          \n"\r
665                 "       bne     reg2_error_loop                                                                         \n"\r
666                 "       cmp     r2, #2                                                                                          \n"\r
667                 "       bne     reg2_error_loop                                                                         \n"\r
668                 "       cmp r3, #3                                                                                              \n"\r
669                 "       bne     reg2_error_loop                                                                         \n"\r
670                 "       cmp     r4, #4                                                                                          \n"\r
671                 "       bne     reg2_error_loop                                                                         \n"\r
672                 "       cmp     r5, #5                                                                                          \n"\r
673                 "       bne     reg2_error_loop                                                                         \n"\r
674                 "       cmp     r6, #6                                                                                          \n"\r
675                 "       bne     reg2_error_loop                                                                         \n"\r
676                 "       cmp     r7, #7                                                                                          \n"\r
677                 "       bne     reg2_error_loop                                                                         \n"\r
678                 "       cmp     r8, #8                                                                                          \n"\r
679                 "       bne     reg2_error_loop                                                                         \n"\r
680                 "       cmp     r9, #9                                                                                          \n"\r
681                 "       bne     reg2_error_loop                                                                         \n"\r
682                 "       cmp     r10, #10                                                                                        \n"\r
683                 "       bne     reg2_error_loop                                                                         \n"\r
684                 "       cmp     r11, #11                                                                                        \n"\r
685                 "       bne     reg2_error_loop                                                                         \n"\r
686                 "       cmp     r12, #12                                                                                        \n"\r
687                 "       bne     reg2_error_loop                                                                         \n"\r
688                 "                                                                                                                       \n"\r
689                 "       /* Increment the loop counter to indicate this test is still functioning\n"\r
690                 "       correctly. */                                                                                   \n"\r
691                 "       push { r0-r1 }                                                                                  \n"\r
692                 "       ldr     r0, =ulRegTest2LoopCounter                                                      \n"\r
693                 "       ldr r1, [r0]                                                                                    \n"\r
694                 "       adds r1, r1, #1                                                                                 \n"\r
695                 "       str r1, [r0]                                                                                    \n"\r
696                 "       pop { r0-r1 }                                                                                   \n"\r
697                 "                                                                                                                       \n"\r
698                 "       /* Start again. */                                                                              \n"\r
699                 "       b reg2_loop                                                                                             \n"\r
700                 "                                                                                                                       \n"\r
701                 "reg2_error_loop:                                                                                       \n"\r
702                 "       /* If this line is hit then there was an error in a core register value.\n"\r
703                 "       This loop ensures the loop counter variable stops incrementing. */\n"\r
704                 "       b reg2_error_loop                                                                               \n"\r
705                 "       nop                                                                                                             \n"\r
706         );\r
707 }\r
708 \r
709 \r
710 \r