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