]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4F_CEC1302_Keil_GCC/Keil_Specific/RegTest.c
Rename CORTEX_M4F_CEC1302_Keil to CORTEX_M4F_CEC1302_Keil_GCC as it now contains...
[freertos] / FreeRTOS / Demo / CORTEX_M4F_CEC1302_Keil_GCC / Keil_Specific / RegTest.c
1 /*\r
2     FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     This file is part of the FreeRTOS distribution.\r
8 \r
9     FreeRTOS is free software; you can redistribute it and/or modify it under\r
10     the terms of the GNU General Public License (version 2) as published by the\r
11     Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
12 \r
13     ***************************************************************************\r
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
16     >>!   obliged to provide the source code for proprietary components     !<<\r
17     >>!   outside of the FreeRTOS kernel.                                   !<<\r
18     ***************************************************************************\r
19 \r
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
23     link: http://www.freertos.org/a00114.html\r
24 \r
25     ***************************************************************************\r
26      *                                                                       *\r
27      *    FreeRTOS provides completely free yet professionally developed,    *\r
28      *    robust, strictly quality controlled, supported, and cross          *\r
29      *    platform software that is more than just the market leader, it     *\r
30      *    is the industry's de facto standard.                               *\r
31      *                                                                       *\r
32      *    Help yourself get started quickly while simultaneously helping     *\r
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
34      *    tutorial book, reference manual, or both:                          *\r
35      *    http://www.FreeRTOS.org/Documentation                              *\r
36      *                                                                       *\r
37     ***************************************************************************\r
38 \r
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
40     the FAQ page "My application does not run, what could be wrong?".  Have you\r
41     defined configASSERT()?\r
42 \r
43     http://www.FreeRTOS.org/support - In return for receiving this top quality\r
44     embedded software for free we request you assist our global community by\r
45     participating in the support forum.\r
46 \r
47     http://www.FreeRTOS.org/training - Investing in training allows your team to\r
48     be as productive as possible as early as possible.  Now you can receive\r
49     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
50     Ltd, and the world's leading authority on the world's leading RTOS.\r
51 \r
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
55 \r
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
58 \r
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
61     licenses offer ticketed support, indemnification and commercial middleware.\r
62 \r
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
64     engineered and independently SIL3 certified version for use in safety and\r
65     mission critical applications that require provable dependability.\r
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69 \r
70 /*\r
71  * "Reg test" tasks - These fill the registers with known values, then check\r
72  * that each register maintains its expected value for the lifetime of the\r
73  * task.  Each task uses a different set of values.  The reg test tasks execute\r
74  * with a very low priority, so get preempted very frequently.  A register\r
75  * containing an unexpected value is indicative of an error in the context\r
76  * switching mechanism.\r
77  */\r
78  \r
79  \r
80 __asm void vRegTest1Implementation( void )\r
81 {\r
82         PRESERVE8\r
83         IMPORT ulRegTest1LoopCounter\r
84 \r
85         /* Fill the core registers with known values. */\r
86         mov r0, #100\r
87         mov r1, #101\r
88         mov r2, #102\r
89         mov r3, #103\r
90         mov     r4, #104\r
91         mov     r5, #105\r
92         mov     r6, #106\r
93         mov r7, #107\r
94         mov     r8, #108\r
95         mov     r9, #109\r
96         mov     r10, #110\r
97         mov     r11, #111\r
98         mov r12, #112\r
99 \r
100         /* Fill the VFP registers with known values. */\r
101         vmov d0, r0, r1\r
102         vmov d1, r2, r3\r
103         vmov d2, r4, r5\r
104         vmov d3, r6, r7\r
105         vmov d4, r8, r9\r
106         vmov d5, r10, r11\r
107         vmov d6, r0, r1\r
108         vmov d7, r2, r3\r
109         vmov d8, r4, r5\r
110         vmov d9, r6, r7\r
111         vmov d10, r8, r9\r
112         vmov d11, r10, r11\r
113         vmov d12, r0, r1\r
114         vmov d13, r2, r3\r
115         vmov d14, r4, r5\r
116         vmov d15, r6, r7\r
117 \r
118 reg1_loop\r
119         /* Check all the VFP registers still contain the values set above.\r
120         First save registers that are clobbered by the test. */\r
121         push { r0-r1 }\r
122         \r
123         vmov r0, r1, d0\r
124         cmp r0, #100\r
125         bne reg1_error_loopf\r
126         cmp r1, #101\r
127         bne reg1_error_loopf\r
128         vmov r0, r1, d1\r
129         cmp r0, #102\r
130         bne reg1_error_loopf\r
131         cmp r1, #103\r
132         bne reg1_error_loopf\r
133         vmov r0, r1, d2\r
134         cmp r0, #104\r
135         bne reg1_error_loopf\r
136         cmp r1, #105\r
137         bne reg1_error_loopf\r
138         vmov r0, r1, d3\r
139         cmp r0, #106\r
140         bne reg1_error_loopf\r
141         cmp r1, #107\r
142         bne reg1_error_loopf\r
143         vmov r0, r1, d4\r
144         cmp r0, #108\r
145         bne reg1_error_loopf\r
146         cmp r1, #109\r
147         bne reg1_error_loopf\r
148         vmov r0, r1, d5\r
149         cmp r0, #110\r
150         bne reg1_error_loopf\r
151         cmp r1, #111\r
152         bne reg1_error_loopf\r
153         vmov r0, r1, d6\r
154         cmp r0, #100\r
155         bne reg1_error_loopf\r
156         cmp r1, #101\r
157         bne reg1_error_loopf\r
158         vmov r0, r1, d7\r
159         cmp r0, #102\r
160         bne reg1_error_loopf\r
161         cmp r1, #103\r
162         bne reg1_error_loopf\r
163         vmov r0, r1, d8\r
164         cmp r0, #104\r
165         bne reg1_error_loopf\r
166         cmp r1, #105\r
167         bne reg1_error_loopf\r
168         vmov r0, r1, d9\r
169         cmp r0, #106\r
170         bne reg1_error_loopf\r
171         cmp r1, #107\r
172         bne reg1_error_loopf\r
173         vmov r0, r1, d10\r
174         cmp r0, #108\r
175         bne reg1_error_loopf\r
176         cmp r1, #109\r
177         bne reg1_error_loopf\r
178         vmov r0, r1, d11\r
179         cmp r0, #110\r
180         bne reg1_error_loopf\r
181         cmp r1, #111\r
182         bne reg1_error_loopf\r
183         vmov r0, r1, d12\r
184         cmp r0, #100\r
185         bne reg1_error_loopf\r
186         cmp r1, #101\r
187         bne reg1_error_loopf\r
188         vmov r0, r1, d13\r
189         cmp r0, #102\r
190         bne reg1_error_loopf\r
191         cmp r1, #103\r
192         bne reg1_error_loopf\r
193         vmov r0, r1, d14\r
194         cmp r0, #104\r
195         bne reg1_error_loopf\r
196         cmp r1, #105\r
197         bne reg1_error_loopf\r
198         vmov r0, r1, d15\r
199         cmp r0, #106\r
200         bne reg1_error_loopf\r
201         cmp r1, #107\r
202         bne reg1_error_loopf\r
203         \r
204         /* Restore the registers that were clobbered by the test. */\r
205         pop {r0-r1}\r
206         \r
207         /* VFP register test passed.  Jump to the core register test. */\r
208         b reg1_loopf_pass\r
209 \r
210 reg1_error_loopf\r
211         /* If this line is hit then a VFP register value was found to be\r
212         incorrect. */\r
213         b reg1_error_loopf\r
214 \r
215 reg1_loopf_pass\r
216 \r
217         cmp     r0, #100\r
218         bne     reg1_error_loop\r
219         cmp     r1, #101\r
220         bne     reg1_error_loop\r
221         cmp     r2, #102\r
222         bne     reg1_error_loop\r
223         cmp r3, #103\r
224         bne     reg1_error_loop\r
225         cmp     r4, #104\r
226         bne     reg1_error_loop\r
227         cmp     r5, #105\r
228         bne     reg1_error_loop\r
229         cmp     r6, #106\r
230         bne     reg1_error_loop\r
231         cmp     r7, #107\r
232         bne     reg1_error_loop\r
233         cmp     r8, #108\r
234         bne     reg1_error_loop\r
235         cmp     r9, #109\r
236         bne     reg1_error_loop\r
237         cmp     r10, #110\r
238         bne     reg1_error_loop\r
239         cmp     r11, #111\r
240         bne     reg1_error_loop\r
241         cmp     r12, #112\r
242         bne     reg1_error_loop\r
243         \r
244         /* Everything passed, increment the loop counter. */\r
245         push { r0-r1 }\r
246         ldr     r0, =ulRegTest1LoopCounter\r
247         ldr r1, [r0]\r
248         adds r1, r1, #1\r
249         str r1, [r0]\r
250         pop { r0-r1 }\r
251         \r
252         /* Start again. */\r
253         b reg1_loop\r
254 \r
255 reg1_error_loop\r
256         /* If this line is hit then there was an error in a core register value.\r
257         The loop ensures the loop counter stops incrementing. */\r
258         b reg1_error_loop\r
259         nop\r
260 }\r
261 /*-----------------------------------------------------------*/\r
262 \r
263 __asm void vRegTest2Implementation( void )\r
264 {\r
265         PRESERVE8\r
266         IMPORT ulRegTest2LoopCounter\r
267 \r
268         /* Set all the core registers to known values. */\r
269         mov r0, #-1\r
270         mov r1, #1\r
271         mov r2, #2\r
272         mov r3, #3\r
273         mov     r4, #4\r
274         mov     r5, #5\r
275         mov     r6, #6\r
276         mov r7, #7\r
277         mov     r8, #8\r
278         mov     r9, #9\r
279         mov     r10, #10\r
280         mov     r11, #11\r
281         mov r12, #12\r
282 \r
283         /* Set all the VFP to known values. */\r
284         vmov d0, r0, r1\r
285         vmov d1, r2, r3\r
286         vmov d2, r4, r5\r
287         vmov d3, r6, r7\r
288         vmov d4, r8, r9\r
289         vmov d5, r10, r11\r
290         vmov d6, r0, r1\r
291         vmov d7, r2, r3\r
292         vmov d8, r4, r5\r
293         vmov d9, r6, r7\r
294         vmov d10, r8, r9\r
295         vmov d11, r10, r11\r
296         vmov d12, r0, r1\r
297         vmov d13, r2, r3\r
298         vmov d14, r4, r5\r
299         vmov d15, r6, r7\r
300 \r
301 reg2_loop\r
302         \r
303         /* Check all the VFP registers still contain the values set above.\r
304         First save registers that are clobbered by the test. */\r
305         push { r0-r1 }\r
306         \r
307         vmov r0, r1, d0\r
308         cmp r0, #-1\r
309         bne reg2_error_loopf\r
310         cmp r1, #1\r
311         bne reg2_error_loopf\r
312         vmov r0, r1, d1\r
313         cmp r0, #2\r
314         bne reg2_error_loopf\r
315         cmp r1, #3\r
316         bne reg2_error_loopf\r
317         vmov r0, r1, d2\r
318         cmp r0, #4\r
319         bne reg2_error_loopf\r
320         cmp r1, #5\r
321         bne reg2_error_loopf\r
322         vmov r0, r1, d3\r
323         cmp r0, #6\r
324         bne reg2_error_loopf\r
325         cmp r1, #7\r
326         bne reg2_error_loopf\r
327         vmov r0, r1, d4\r
328         cmp r0, #8\r
329         bne reg2_error_loopf\r
330         cmp r1, #9\r
331         bne reg2_error_loopf\r
332         vmov r0, r1, d5\r
333         cmp r0, #10\r
334         bne reg2_error_loopf\r
335         cmp r1, #11\r
336         bne reg2_error_loopf\r
337         vmov r0, r1, d6\r
338         cmp r0, #-1\r
339         bne reg2_error_loopf\r
340         cmp r1, #1\r
341         bne reg2_error_loopf\r
342         vmov r0, r1, d7\r
343         cmp r0, #2\r
344         bne reg2_error_loopf\r
345         cmp r1, #3\r
346         bne reg2_error_loopf\r
347         vmov r0, r1, d8\r
348         cmp r0, #4\r
349         bne reg2_error_loopf\r
350         cmp r1, #5\r
351         bne reg2_error_loopf\r
352         vmov r0, r1, d9\r
353         cmp r0, #6\r
354         bne reg2_error_loopf\r
355         cmp r1, #7\r
356         bne reg2_error_loopf\r
357         vmov r0, r1, d10\r
358         cmp r0, #8\r
359         bne reg2_error_loopf\r
360         cmp r1, #9\r
361         bne reg2_error_loopf\r
362         vmov r0, r1, d11\r
363         cmp r0, #10\r
364         bne reg2_error_loopf\r
365         cmp r1, #11\r
366         bne reg2_error_loopf\r
367         vmov r0, r1, d12\r
368         cmp r0, #-1\r
369         bne reg2_error_loopf\r
370         cmp r1, #1\r
371         bne reg2_error_loopf\r
372         vmov r0, r1, d13\r
373         cmp r0, #2\r
374         bne reg2_error_loopf\r
375         cmp r1, #3\r
376         bne reg2_error_loopf\r
377         vmov r0, r1, d14\r
378         cmp r0, #4\r
379         bne reg2_error_loopf\r
380         cmp r1, #5\r
381         bne reg2_error_loopf\r
382         vmov r0, r1, d15\r
383         cmp r0, #6\r
384         bne reg2_error_loopf\r
385         cmp r1, #7\r
386         bne reg2_error_loopf\r
387         \r
388         /* Restore the registers that were clobbered by the test. */\r
389         pop {r0-r1}\r
390         \r
391         /* VFP register test passed.  Jump to the core register test. */\r
392         b reg2_loopf_pass\r
393 \r
394 reg2_error_loopf\r
395         /* If this line is hit then a VFP register value was found to be\r
396         incorrect. */\r
397         b reg2_error_loopf\r
398 \r
399 reg2_loopf_pass\r
400 \r
401         cmp     r0, #-1\r
402         bne     reg2_error_loop\r
403         cmp     r1, #1\r
404         bne     reg2_error_loop\r
405         cmp     r2, #2\r
406         bne     reg2_error_loop\r
407         cmp r3, #3\r
408         bne     reg2_error_loop\r
409         cmp     r4, #4\r
410         bne     reg2_error_loop\r
411         cmp     r5, #5\r
412         bne     reg2_error_loop\r
413         cmp     r6, #6\r
414         bne     reg2_error_loop\r
415         cmp     r7, #7\r
416         bne     reg2_error_loop\r
417         cmp     r8, #8\r
418         bne     reg2_error_loop\r
419         cmp     r9, #9\r
420         bne     reg2_error_loop\r
421         cmp     r10, #10\r
422         bne     reg2_error_loop\r
423         cmp     r11, #11\r
424         bne     reg2_error_loop\r
425         cmp     r12, #12\r
426         bne     reg2_error_loop\r
427         \r
428         /* Increment the loop counter to indicate this test is still functioning\r
429         correctly. */\r
430         push { r0-r1 }\r
431         ldr     r0, =ulRegTest2LoopCounter\r
432         ldr r1, [r0]\r
433         adds r1, r1, #1\r
434         str r1, [r0]\r
435         \r
436         /* Yield to increase test coverage. */\r
437         movs r0, #0x01\r
438         ldr r1, =0xe000ed04 /*NVIC_INT_CTRL */\r
439         lsl r0, r0, #28 /* Shift to PendSV bit */\r
440         str r0, [r1]\r
441         dsb\r
442         \r
443         pop { r0-r1 }\r
444         \r
445         /* Start again. */\r
446         b reg2_loop\r
447 \r
448 reg2_error_loop\r
449         /* If this line is hit then there was an error in a core register value.\r
450         This loop ensures the loop counter variable stops incrementing. */\r
451         b reg2_error_loop\r
452 }\r
453 /*-----------------------------------------------------------*/\r
454 \r