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