]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M7_SAMV71_Xplained/Full_Demo/RegTest.c
Update version number ready for V8.2.1 release.
[freertos] / FreeRTOS / Demo / CORTEX_M7_SAMV71_Xplained / Full_Demo / RegTest.c
1 /*\r
2     FreeRTOS V8.2.1 - 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 __asm void vRegTest1Implementation( void )\r
71 {\r
72         PRESERVE8\r
73         IMPORT ulRegTest1LoopCounter\r
74 \r
75         /* Fill the core registers with known values. */\r
76         mov r0, #100\r
77         mov r1, #101\r
78         mov r2, #102\r
79         mov r3, #103\r
80         mov     r4, #104\r
81         mov     r5, #105\r
82         mov     r6, #106\r
83         mov r7, #107\r
84         mov     r8, #108\r
85         mov     r9, #109\r
86         mov     r10, #110\r
87         mov     r11, #111\r
88         mov r12, #112\r
89 \r
90         /* Fill the VFP registers with known values. */\r
91         vmov d0, r0, r1\r
92         vmov d1, r2, r3\r
93         vmov d2, r4, r5\r
94         vmov d3, r6, r7\r
95         vmov d4, r8, r9\r
96         vmov d5, r10, r11\r
97         vmov d6, r0, r1\r
98         vmov d7, r2, r3\r
99         vmov d8, r4, r5\r
100         vmov d9, r6, r7\r
101         vmov d10, r8, r9\r
102         vmov d11, r10, r11\r
103         vmov d12, r0, r1\r
104         vmov d13, r2, r3\r
105         vmov d14, r4, r5\r
106         vmov d15, r6, r7\r
107 \r
108 reg1_loop\r
109         /* Check all the VFP registers still contain the values set above.\r
110         First save registers that are clobbered by the test. */\r
111         push { r0-r1 }\r
112         \r
113         vmov r0, r1, d0\r
114         cmp r0, #100\r
115         bne reg1_error_loopf\r
116         cmp r1, #101\r
117         bne reg1_error_loopf\r
118         vmov r0, r1, d1\r
119         cmp r0, #102\r
120         bne reg1_error_loopf\r
121         cmp r1, #103\r
122         bne reg1_error_loopf\r
123         vmov r0, r1, d2\r
124         cmp r0, #104\r
125         bne reg1_error_loopf\r
126         cmp r1, #105\r
127         bne reg1_error_loopf\r
128         vmov r0, r1, d3\r
129         cmp r0, #106\r
130         bne reg1_error_loopf\r
131         cmp r1, #107\r
132         bne reg1_error_loopf\r
133         vmov r0, r1, d4\r
134         cmp r0, #108\r
135         bne reg1_error_loopf\r
136         cmp r1, #109\r
137         bne reg1_error_loopf\r
138         vmov r0, r1, d5\r
139         cmp r0, #110\r
140         bne reg1_error_loopf\r
141         cmp r1, #111\r
142         bne reg1_error_loopf\r
143         vmov r0, r1, d6\r
144         cmp r0, #100\r
145         bne reg1_error_loopf\r
146         cmp r1, #101\r
147         bne reg1_error_loopf\r
148         vmov r0, r1, d7\r
149         cmp r0, #102\r
150         bne reg1_error_loopf\r
151         cmp r1, #103\r
152         bne reg1_error_loopf\r
153         vmov r0, r1, d8\r
154         cmp r0, #104\r
155         bne reg1_error_loopf\r
156         cmp r1, #105\r
157         bne reg1_error_loopf\r
158         vmov r0, r1, d9\r
159         cmp r0, #106\r
160         bne reg1_error_loopf\r
161         cmp r1, #107\r
162         bne reg1_error_loopf\r
163         vmov r0, r1, d10\r
164         cmp r0, #108\r
165         bne reg1_error_loopf\r
166         cmp r1, #109\r
167         bne reg1_error_loopf\r
168         vmov r0, r1, d11\r
169         cmp r0, #110\r
170         bne reg1_error_loopf\r
171         cmp r1, #111\r
172         bne reg1_error_loopf\r
173         vmov r0, r1, d12\r
174         cmp r0, #100\r
175         bne reg1_error_loopf\r
176         cmp r1, #101\r
177         bne reg1_error_loopf\r
178         vmov r0, r1, d13\r
179         cmp r0, #102\r
180         bne reg1_error_loopf\r
181         cmp r1, #103\r
182         bne reg1_error_loopf\r
183         vmov r0, r1, d14\r
184         cmp r0, #104\r
185         bne reg1_error_loopf\r
186         cmp r1, #105\r
187         bne reg1_error_loopf\r
188         vmov r0, r1, d15\r
189         cmp r0, #106\r
190         bne reg1_error_loopf\r
191         cmp r1, #107\r
192         bne reg1_error_loopf\r
193         \r
194         /* Restore the registers that were clobbered by the test. */\r
195         pop {r0-r1}\r
196         \r
197         /* VFP register test passed.  Jump to the core register test. */\r
198         b reg1_loopf_pass\r
199 \r
200 reg1_error_loopf\r
201         /* If this line is hit then a VFP register value was found to be\r
202         incorrect. */\r
203         b reg1_error_loopf\r
204 \r
205 reg1_loopf_pass\r
206 \r
207         cmp     r0, #100\r
208         bne     reg1_error_loop\r
209         cmp     r1, #101\r
210         bne     reg1_error_loop\r
211         cmp     r2, #102\r
212         bne     reg1_error_loop\r
213         cmp r3, #103\r
214         bne     reg1_error_loop\r
215         cmp     r4, #104\r
216         bne     reg1_error_loop\r
217         cmp     r5, #105\r
218         bne     reg1_error_loop\r
219         cmp     r6, #106\r
220         bne     reg1_error_loop\r
221         cmp     r7, #107\r
222         bne     reg1_error_loop\r
223         cmp     r8, #108\r
224         bne     reg1_error_loop\r
225         cmp     r9, #109\r
226         bne     reg1_error_loop\r
227         cmp     r10, #110\r
228         bne     reg1_error_loop\r
229         cmp     r11, #111\r
230         bne     reg1_error_loop\r
231         cmp     r12, #112\r
232         bne     reg1_error_loop\r
233         \r
234         /* Everything passed, increment the loop counter. */\r
235         push { r0-r1 }\r
236         ldr     r0, =ulRegTest1LoopCounter\r
237         ldr r1, [r0]\r
238         adds r1, r1, #1\r
239         str r1, [r0]\r
240         pop { r0-r1 }\r
241         \r
242         /* Start again. */\r
243         b reg1_loop\r
244 \r
245 reg1_error_loop\r
246         /* If this line is hit then there was an error in a core register value.\r
247         The loop ensures the loop counter stops incrementing. */\r
248         b reg1_error_loop\r
249         nop\r
250 }\r
251 /*-----------------------------------------------------------*/\r
252 \r
253 __asm void vRegTest2Implementation( void )\r
254 {\r
255         PRESERVE8\r
256         IMPORT ulRegTest2LoopCounter\r
257 \r
258         /* Set all the core registers to known values. */\r
259         mov r0, #-1\r
260         mov r1, #1\r
261         mov r2, #2\r
262         mov r3, #3\r
263         mov     r4, #4\r
264         mov     r5, #5\r
265         mov     r6, #6\r
266         mov r7, #7\r
267         mov     r8, #8\r
268         mov     r9, #9\r
269         mov     r10, #10\r
270         mov     r11, #11\r
271         mov r12, #12\r
272 \r
273         /* Set all the VFP to known values. */\r
274         vmov d0, r0, r1\r
275         vmov d1, r2, r3\r
276         vmov d2, r4, r5\r
277         vmov d3, r6, r7\r
278         vmov d4, r8, r9\r
279         vmov d5, r10, r11\r
280         vmov d6, r0, r1\r
281         vmov d7, r2, r3\r
282         vmov d8, r4, r5\r
283         vmov d9, r6, r7\r
284         vmov d10, r8, r9\r
285         vmov d11, r10, r11\r
286         vmov d12, r0, r1\r
287         vmov d13, r2, r3\r
288         vmov d14, r4, r5\r
289         vmov d15, r6, r7\r
290 \r
291 reg2_loop\r
292         \r
293         /* Check all the VFP registers still contain the values set above.\r
294         First save registers that are clobbered by the test. */\r
295         push { r0-r1 }\r
296         \r
297         vmov r0, r1, d0\r
298         cmp r0, #-1\r
299         bne reg2_error_loopf\r
300         cmp r1, #1\r
301         bne reg2_error_loopf\r
302         vmov r0, r1, d1\r
303         cmp r0, #2\r
304         bne reg2_error_loopf\r
305         cmp r1, #3\r
306         bne reg2_error_loopf\r
307         vmov r0, r1, d2\r
308         cmp r0, #4\r
309         bne reg2_error_loopf\r
310         cmp r1, #5\r
311         bne reg2_error_loopf\r
312         vmov r0, r1, d3\r
313         cmp r0, #6\r
314         bne reg2_error_loopf\r
315         cmp r1, #7\r
316         bne reg2_error_loopf\r
317         vmov r0, r1, d4\r
318         cmp r0, #8\r
319         bne reg2_error_loopf\r
320         cmp r1, #9\r
321         bne reg2_error_loopf\r
322         vmov r0, r1, d5\r
323         cmp r0, #10\r
324         bne reg2_error_loopf\r
325         cmp r1, #11\r
326         bne reg2_error_loopf\r
327         vmov r0, r1, d6\r
328         cmp r0, #-1\r
329         bne reg2_error_loopf\r
330         cmp r1, #1\r
331         bne reg2_error_loopf\r
332         vmov r0, r1, d7\r
333         cmp r0, #2\r
334         bne reg2_error_loopf\r
335         cmp r1, #3\r
336         bne reg2_error_loopf\r
337         vmov r0, r1, d8\r
338         cmp r0, #4\r
339         bne reg2_error_loopf\r
340         cmp r1, #5\r
341         bne reg2_error_loopf\r
342         vmov r0, r1, d9\r
343         cmp r0, #6\r
344         bne reg2_error_loopf\r
345         cmp r1, #7\r
346         bne reg2_error_loopf\r
347         vmov r0, r1, d10\r
348         cmp r0, #8\r
349         bne reg2_error_loopf\r
350         cmp r1, #9\r
351         bne reg2_error_loopf\r
352         vmov r0, r1, d11\r
353         cmp r0, #10\r
354         bne reg2_error_loopf\r
355         cmp r1, #11\r
356         bne reg2_error_loopf\r
357         vmov r0, r1, d12\r
358         cmp r0, #-1\r
359         bne reg2_error_loopf\r
360         cmp r1, #1\r
361         bne reg2_error_loopf\r
362         vmov r0, r1, d13\r
363         cmp r0, #2\r
364         bne reg2_error_loopf\r
365         cmp r1, #3\r
366         bne reg2_error_loopf\r
367         vmov r0, r1, d14\r
368         cmp r0, #4\r
369         bne reg2_error_loopf\r
370         cmp r1, #5\r
371         bne reg2_error_loopf\r
372         vmov r0, r1, d15\r
373         cmp r0, #6\r
374         bne reg2_error_loopf\r
375         cmp r1, #7\r
376         bne reg2_error_loopf\r
377         \r
378         /* Restore the registers that were clobbered by the test. */\r
379         pop {r0-r1}\r
380         \r
381         /* VFP register test passed.  Jump to the core register test. */\r
382         b reg2_loopf_pass\r
383 \r
384 reg2_error_loopf\r
385         /* If this line is hit then a VFP register value was found to be\r
386         incorrect. */\r
387         b reg2_error_loopf\r
388 \r
389 reg2_loopf_pass\r
390 \r
391         cmp     r0, #-1\r
392         bne     reg2_error_loop\r
393         cmp     r1, #1\r
394         bne     reg2_error_loop\r
395         cmp     r2, #2\r
396         bne     reg2_error_loop\r
397         cmp r3, #3\r
398         bne     reg2_error_loop\r
399         cmp     r4, #4\r
400         bne     reg2_error_loop\r
401         cmp     r5, #5\r
402         bne     reg2_error_loop\r
403         cmp     r6, #6\r
404         bne     reg2_error_loop\r
405         cmp     r7, #7\r
406         bne     reg2_error_loop\r
407         cmp     r8, #8\r
408         bne     reg2_error_loop\r
409         cmp     r9, #9\r
410         bne     reg2_error_loop\r
411         cmp     r10, #10\r
412         bne     reg2_error_loop\r
413         cmp     r11, #11\r
414         bne     reg2_error_loop\r
415         cmp     r12, #12\r
416         bne     reg2_error_loop\r
417         \r
418         /* Increment the loop counter to indicate this test is still functioning\r
419         correctly. */\r
420         push { r0-r1 }\r
421         ldr     r0, =ulRegTest2LoopCounter\r
422         ldr r1, [r0]\r
423         adds r1, r1, #1\r
424         str r1, [r0]\r
425         \r
426         /* Yield to increase test coverage. */\r
427         movs r0, #0x01\r
428         ldr r1, =0xe000ed04 /*NVIC_INT_CTRL */\r
429         lsl r0, r0, #28 /* Shift to PendSV bit */\r
430         str r0, [r1]\r
431         dsb\r
432         \r
433         pop { r0-r1 }\r
434         \r
435         /* Start again. */\r
436         b reg2_loop\r
437 \r
438 reg2_error_loop\r
439         /* If this line is hit then there was an error in a core register value.\r
440         This loop ensures the loop counter variable stops incrementing. */\r
441         b reg2_error_loop\r
442 }\r
443 /*-----------------------------------------------------------*/\r
444 \r