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