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