]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A5_SAMA5D2x_Xplained_IAR/Full_Demo/reg_test.S
Update to MIT licensed FreeRTOS V10.0.0 - see https://www.freertos.org/History.txt
[freertos] / FreeRTOS / Demo / CORTEX_A5_SAMA5D2x_Xplained_IAR / Full_Demo / reg_test.S
1 ;/*\r
2 ; * FreeRTOS Kernel V10.0.0\r
3 ; * Copyright (C) 2017 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. If you wish to use our Amazon\r
14 ; * FreeRTOS name, please do so in a fair use way that does not cause confusion.\r
15 ; *\r
16 ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
17 ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
18 ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
19 ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
20 ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
21 ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22 ; *\r
23 ; * http://www.FreeRTOS.org\r
24 ; * http://aws.amazon.com/freertos\r
25 ; *\r
26 ; * 1 tab == 4 spaces!\r
27 ; */\r
28 \r
29         EXPORT vRegTest1Implementation\r
30         EXPORT vRegTest2Implementation\r
31 \r
32         ; This file is built with IAR and ARM compilers.  When the ARM compiler\r
33         ; is used the compiler options must define __IASMARM__ as 0 using the\r
34         ; --predefine "__IASMARM__ SETA 0" command line option.  When compiling\r
35         ; with IAR __IASMARM__ is automatically set to 1 so no additional assembler\r
36         ; options are required.\r
37         SECTION .text:CODE:ROOT(2)\r
38         ARM\r
39 \r
40         ; This function is explained in the comments at the top of main-full.c.\r
41 vRegTest1Implementation\r
42 \r
43         PRESERVE8\r
44         IMPORT ulRegTest1LoopCounter\r
45 \r
46         ; Fill each general purpose register with a known value.\r
47         mov             r0,  #0xFF\r
48         mov             r1,  #0x11\r
49         mov             r2,  #0x22\r
50         mov             r3,  #0x33\r
51         mov     r4,  #0x44\r
52         mov     r5,  #0x55\r
53         mov     r6,  #0x66\r
54         mov     r7,  #0x77\r
55         mov     r8,  #0x88\r
56         mov     r9,  #0x99\r
57         mov     r10, #0xAA\r
58         mov     r11, #0xBB\r
59         mov     r12, #0xCC\r
60         mov             r14, #0xEE\r
61 \r
62         ; Fill each FPU register with a known value.\r
63         vmov    d0, r0, r1\r
64         vmov    d1, r2, r3\r
65         vmov    d2, r4, r5\r
66         vmov    d3, r6, r7\r
67         vmov    d4, r8, r9\r
68         vmov    d5, r10, r11\r
69         vmov    d6, r0, r1\r
70         vmov    d7, r2, r3\r
71         vmov    d8, r4, r5\r
72         vmov    d9, r6, r7\r
73         vmov    d10, r8, r9\r
74         vmov    d11, r10, r11\r
75         vmov    d12, r0, r1\r
76         vmov    d13, r2, r3\r
77         vmov    d14, r4, r5\r
78         vmov    d15, r6, r7\r
79 \r
80         ; Loop, checking each iteration that each register still contains the\r
81         ; expected value.\r
82 reg1_loop\r
83         ; Yield to increase test coverage\r
84         svc 0\r
85 \r
86         ; Check all the VFP registers still contain the values set above.\r
87         ; First save registers that are clobbered by the test.\r
88         push { r0-r1 }\r
89 \r
90         vmov    r0, r1, d0\r
91         cmp     r0, #0xFF\r
92         bne     reg1_error_loopf\r
93         cmp     r1, #0x11\r
94         bne     reg1_error_loopf\r
95         vmov    r0, r1, d1\r
96         cmp     r0, #0x22\r
97         bne     reg1_error_loopf\r
98         cmp     r1, #0x33\r
99         bne     reg1_error_loopf\r
100         vmov    r0, r1, d2\r
101         cmp     r0, #0x44\r
102         bne     reg1_error_loopf\r
103         cmp     r1, #0x55\r
104         bne     reg1_error_loopf\r
105         vmov    r0, r1, d3\r
106         cmp     r0, #0x66\r
107         bne     reg1_error_loopf\r
108         cmp     r1, #0x77\r
109         bne     reg1_error_loopf\r
110         vmov    r0, r1, d4\r
111         cmp     r0, #0x88\r
112         bne     reg1_error_loopf\r
113         cmp     r1, #0x99\r
114         bne     reg1_error_loopf\r
115         vmov    r0, r1, d5\r
116         cmp     r0, #0xAA\r
117         bne     reg1_error_loopf\r
118         cmp     r1, #0xBB\r
119         bne     reg1_error_loopf\r
120         vmov    r0, r1, d6\r
121         cmp     r0, #0xFF\r
122         bne     reg1_error_loopf\r
123         cmp     r1, #0x11\r
124         bne     reg1_error_loopf\r
125         vmov    r0, r1, d7\r
126         cmp     r0, #0x22\r
127         bne     reg1_error_loopf\r
128         cmp     r1, #0x33\r
129         bne     reg1_error_loopf\r
130         vmov    r0, r1, d8\r
131         cmp     r0, #0x44\r
132         bne     reg1_error_loopf\r
133         cmp     r1, #0x55\r
134         bne     reg1_error_loopf\r
135         vmov    r0, r1, d9\r
136         cmp     r0, #0x66\r
137         bne     reg1_error_loopf\r
138         cmp     r1, #0x77\r
139         bne     reg1_error_loopf\r
140         vmov    r0, r1, d10\r
141         cmp     r0, #0x88\r
142         bne     reg1_error_loopf\r
143         cmp     r1, #0x99\r
144         bne     reg1_error_loopf\r
145         vmov    r0, r1, d11\r
146         cmp     r0, #0xAA\r
147         bne     reg1_error_loopf\r
148         cmp     r1, #0xBB\r
149         bne     reg1_error_loopf\r
150         vmov    r0, r1, d12\r
151         cmp     r0, #0xFF\r
152         bne     reg1_error_loopf\r
153         cmp     r1, #0x11\r
154         bne     reg1_error_loopf\r
155         vmov    r0, r1, d13\r
156         cmp     r0, #0x22\r
157         bne     reg1_error_loopf\r
158         cmp     r1, #0x33\r
159         bne     reg1_error_loopf\r
160         vmov    r0, r1, d14\r
161         cmp     r0, #0x44\r
162         bne     reg1_error_loopf\r
163         cmp     r1, #0x55\r
164         bne     reg1_error_loopf\r
165         vmov    r0, r1, d15\r
166         cmp     r0, #0x66\r
167         bne     reg1_error_loopf\r
168         cmp     r1, #0x77\r
169         bne     reg1_error_loopf\r
170 \r
171         ; Restore the registers that were clobbered by the test.\r
172         pop     {r0-r1}\r
173 \r
174         ; VFP register test passed.  Jump to the core register test.\r
175         b               reg1_loopf_pass\r
176 \r
177 reg1_error_loopf\r
178         ; If this line is hit then a VFP register value was found to be\r
179         ; incorrect.\r
180         b reg1_error_loopf\r
181 \r
182 reg1_loopf_pass\r
183 \r
184         ; Test each general purpose register to check that it still contains the\r
185         ; expected known value, jumping to reg1_error_loop if any register contains\r
186         ; an unexpected value.\r
187         cmp             r0, #0xFF\r
188         bne             reg1_error_loop\r
189         cmp             r1, #0x11\r
190         bne             reg1_error_loop\r
191         cmp             r2, #0x22\r
192         bne             reg1_error_loop\r
193         cmp             r3, #0x33\r
194         bne             reg1_error_loop\r
195         cmp             r4, #0x44\r
196         bne             reg1_error_loop\r
197         cmp             r5, #0x55\r
198         bne             reg1_error_loop\r
199         cmp             r6, #0x66\r
200         bne             reg1_error_loop\r
201         cmp             r7, #0x77\r
202         bne             reg1_error_loop\r
203         cmp             r8, #0x88\r
204         bne             reg1_error_loop\r
205         cmp             r9, #0x99\r
206         bne             reg1_error_loop\r
207         cmp             r10, #0xAA\r
208         bne             reg1_error_loop\r
209         cmp             r11, #0xBB\r
210         bne             reg1_error_loop\r
211         cmp             r12, #0xCC\r
212         bne             reg1_error_loop\r
213         cmp             r14, #0xEE\r
214         bne             reg1_error_loop\r
215 \r
216         ; Everything passed, increment the loop counter.\r
217         push { r0-r1 }\r
218         ldr     r0, =ulRegTest1LoopCounter\r
219         ldr r1, [r0]\r
220         adds r1, r1, #1\r
221         str r1, [r0]\r
222         pop { r0-r1 }\r
223 \r
224         ; Start again.\r
225         b reg1_loop\r
226 \r
227 reg1_error_loop\r
228         ; If this line is hit then there was an error in a core register value.\r
229         ; The loop ensures the loop counter stops incrementing.\r
230         b reg1_error_loop\r
231         nop\r
232 \r
233 ;/*-----------------------------------------------------------*/\r
234 \r
235 vRegTest2Implementation\r
236 \r
237         PRESERVE8\r
238         IMPORT ulRegTest2LoopCounter\r
239 \r
240         ; Put a known value in each register.\r
241         mov             r0,  #0xFF000000\r
242         mov             r1,  #0x11000000\r
243         mov             r2,  #0x22000000\r
244         mov             r3,  #0x33000000\r
245         mov     r4,  #0x44000000\r
246         mov     r5,  #0x55000000\r
247         mov     r6,  #0x66000000\r
248         mov     r7,  #0x77000000\r
249         mov     r8,  #0x88000000\r
250         mov     r9,  #0x99000000\r
251         mov     r10, #0xAA000000\r
252         mov     r11, #0xBB000000\r
253         mov     r12, #0xCC000000\r
254         mov     r14, #0xEE000000\r
255 \r
256         ; Likewise the floating point registers\r
257         vmov    d0, r0, r1\r
258         vmov    d1, r2, r3\r
259         vmov    d2, r4, r5\r
260         vmov    d3, r6, r7\r
261         vmov    d4, r8, r9\r
262         vmov    d5, r10, r11\r
263         vmov    d6, r0, r1\r
264         vmov    d7, r2, r3\r
265         vmov    d8, r4, r5\r
266         vmov    d9, r6, r7\r
267         vmov    d10, r8, r9\r
268         vmov    d11, r10, r11\r
269         vmov    d12, r0, r1\r
270         vmov    d13, r2, r3\r
271         vmov    d14, r4, r5\r
272         vmov    d15, r6, r7\r
273 \r
274         ; Loop, checking each iteration that each register still contains the\r
275         ; expected value.\r
276 reg2_loop\r
277         ; Check all the VFP registers still contain the values set above.\r
278         ; First save registers that are clobbered by the test.\r
279         push    { r0-r1 }\r
280 \r
281         vmov    r0, r1, d0\r
282         cmp     r0, #0xFF000000\r
283         bne     reg2_error_loopf\r
284         cmp     r1, #0x11000000\r
285         bne     reg2_error_loopf\r
286         vmov    r0, r1, d1\r
287         cmp     r0, #0x22000000\r
288         bne     reg2_error_loopf\r
289         cmp     r1, #0x33000000\r
290         bne     reg2_error_loopf\r
291         vmov    r0, r1, d2\r
292         cmp     r0, #0x44000000\r
293         bne     reg2_error_loopf\r
294         cmp     r1, #0x55000000\r
295         bne     reg2_error_loopf\r
296         vmov    r0, r1, d3\r
297         cmp     r0, #0x66000000\r
298         bne     reg2_error_loopf\r
299         cmp     r1, #0x77000000\r
300         bne     reg2_error_loopf\r
301         vmov    r0, r1, d4\r
302         cmp     r0, #0x88000000\r
303         bne     reg2_error_loopf\r
304         cmp     r1, #0x99000000\r
305         bne     reg2_error_loopf\r
306         vmov    r0, r1, d5\r
307         cmp     r0, #0xAA000000\r
308         bne     reg2_error_loopf\r
309         cmp     r1, #0xBB000000\r
310         bne     reg2_error_loopf\r
311         vmov    r0, r1, d6\r
312         cmp     r0, #0xFF000000\r
313         bne     reg2_error_loopf\r
314         cmp     r1, #0x11000000\r
315         bne     reg2_error_loopf\r
316         vmov    r0, r1, d7\r
317         cmp     r0, #0x22000000\r
318         bne     reg2_error_loopf\r
319         cmp     r1, #0x33000000\r
320         bne     reg2_error_loopf\r
321         vmov    r0, r1, d8\r
322         cmp     r0, #0x44000000\r
323         bne     reg2_error_loopf\r
324         cmp     r1, #0x55000000\r
325         bne     reg2_error_loopf\r
326         vmov    r0, r1, d9\r
327         cmp     r0, #0x66000000\r
328         bne     reg2_error_loopf\r
329         cmp     r1, #0x77000000\r
330         bne     reg2_error_loopf\r
331         vmov    r0, r1, d10\r
332         cmp     r0, #0x88000000\r
333         bne     reg2_error_loopf\r
334         cmp     r1, #0x99000000\r
335         bne     reg2_error_loopf\r
336         vmov    r0, r1, d11\r
337         cmp     r0, #0xAA000000\r
338         bne     reg2_error_loopf\r
339         cmp     r1, #0xBB000000\r
340         bne     reg2_error_loopf\r
341         vmov    r0, r1, d12\r
342         cmp     r0, #0xFF000000\r
343         bne     reg2_error_loopf\r
344         cmp     r1, #0x11000000\r
345         bne     reg2_error_loopf\r
346         vmov    r0, r1, d13\r
347         cmp     r0, #0x22000000\r
348         bne     reg2_error_loopf\r
349         cmp     r1, #0x33000000\r
350         bne     reg2_error_loopf\r
351         vmov    r0, r1, d14\r
352         cmp     r0, #0x44000000\r
353         bne     reg2_error_loopf\r
354         cmp     r1, #0x55000000\r
355         bne     reg2_error_loopf\r
356         vmov    r0, r1, d15\r
357         cmp     r0, #0x66000000\r
358         bne     reg2_error_loopf\r
359         cmp     r1, #0x77000000\r
360         bne     reg2_error_loopf\r
361 \r
362         ; Restore the registers that were clobbered by the test.\r
363         pop     {r0-r1}\r
364 \r
365         ; VFP register test passed.  Jump to the core register test.\r
366         b               reg2_loopf_pass\r
367 \r
368 reg2_error_loopf\r
369         ; If this line is hit then a VFP register value was found to be\r
370         ; incorrect.\r
371         b               reg2_error_loopf\r
372 \r
373 reg2_loopf_pass\r
374 \r
375         cmp             r0, #0xFF000000\r
376         bne             reg2_error_loop\r
377         cmp             r1, #0x11000000\r
378         bne             reg2_error_loop\r
379         cmp             r2, #0x22000000\r
380         bne             reg2_error_loop\r
381         cmp             r3, #0x33000000\r
382         bne             reg2_error_loop\r
383         cmp             r4, #0x44000000\r
384         bne             reg2_error_loop\r
385         cmp             r5, #0x55000000\r
386         bne             reg2_error_loop\r
387         cmp             r6, #0x66000000\r
388         bne             reg2_error_loop\r
389         cmp             r7, #0x77000000\r
390         bne             reg2_error_loop\r
391         cmp             r8, #0x88000000\r
392         bne             reg2_error_loop\r
393         cmp             r9, #0x99000000\r
394         bne             reg2_error_loop\r
395         cmp             r10, #0xAA000000\r
396         bne             reg2_error_loop\r
397         cmp             r11, #0xBB000000\r
398         bne             reg2_error_loop\r
399         cmp             r12, #0xCC000000\r
400         bne             reg2_error_loop\r
401         cmp     r14, #0xEE000000\r
402         bne             reg2_error_loop\r
403 \r
404         ; Everything passed, increment the loop counter.\r
405         push    { r0-r1 }\r
406         ldr             r0, =ulRegTest2LoopCounter\r
407         ldr     r1, [r0]\r
408         adds    r1, r1, #1\r
409         str     r1, [r0]\r
410         pop     { r0-r1 }\r
411 \r
412         ; Start again.\r
413         b               reg2_loop\r
414 \r
415 reg2_error_loop\r
416         ; If this line is hit then there was an error in a core register value.\r
417         ; The loop ensures the loop counter stops incrementing.\r
418         b               reg2_error_loop\r
419         nop\r
420 \r
421 \r
422         END\r