]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RISC-V_RV32M1_Vega_GCC_Eclipse/projects/RTOSDemo_ri5cy/full_demo/RegTest.S
Update the RegTest.S file used by several GCC RISC-V demos to ensure correct alignmen...
[freertos] / FreeRTOS / Demo / RISC-V_RV32M1_Vega_GCC_Eclipse / projects / RTOSDemo_ri5cy / full_demo / RegTest.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         .extern ulRegTest1LoopCounter\r
29         .extern ulRegTest2LoopCounter\r
30 \r
31         .global vRegTest1Implementation\r
32         .global vRegTest2Implementation\r
33 \r
34 /*-----------------------------------------------------------*/\r
35 \r
36 /* Constants to define the additional registers found on the Pulpino RI5KY. */\r
37 #define lpstart0        0x7b0\r
38 #define lpend0          0x7b1\r
39 #define lpcount0        0x7b2\r
40 #define lpstart1        0x7b4\r
41 #define lpend1          0x7b5\r
42 #define lpcount1        0x7b6\r
43 \r
44 /*-----------------------------------------------------------*/\r
45 \r
46 /*\r
47  * The register check tasks are described in the comments at the top of\r
48  * main_full.c.\r
49  */\r
50 \r
51 .align( 8 )\r
52 vRegTest1Implementation:\r
53 \r
54         /* Fill the additional registers with known values. */\r
55         li t0, 0xaa\r
56         csrw lpstart0, t0\r
57         li t0, 0xab\r
58         csrw lpstart1, t0\r
59         li t0, 0xac\r
60         csrw lpend0, t0\r
61         li t0, 0xad\r
62         csrw lpend1, t0\r
63         li t0, 0xae\r
64         csrw lpcount0, t0\r
65         li t0, 0xaf\r
66         csrw lpcount1, t0\r
67 \r
68         /* Fill the core registers with known values. */\r
69         li x5, 0x5\r
70         li x6, 0x6\r
71         li x7, 0x7\r
72         li x8, 0x8\r
73         li x9, 0x9\r
74         li x10, 0xa\r
75         li x11, 0xb\r
76         li x12, 0xc\r
77         li x13, 0xd\r
78         li x14, 0xe\r
79         li x15, 0xf\r
80         li x16, 0x10\r
81         li x17, 0x11\r
82         li x18, 0x12\r
83         li x19, 0x13\r
84         li x20, 0x14\r
85         li x21, 0x15\r
86         li x22, 0x16\r
87         li x23, 0x17\r
88         li x24, 0x18\r
89         li x25, 0x19\r
90         li x26, 0x1a\r
91         li x27, 0x1b\r
92         li x28, 0x1c\r
93         li x29, 0x1d\r
94         li x30, 0x1e\r
95 \r
96 reg1_loop:\r
97 \r
98         /* Check each register still contains the expected known value.\r
99         vRegTest1Implementation uses x31 as the temporary, vRegTest2Implementation\r
100         uses x5 as the temporary. */\r
101         li x31, 0x5\r
102         bne x31, x5, reg1_error_loop\r
103         li x31, 0x6\r
104         bne x31, x6, reg1_error_loop\r
105         li x31, 0x7\r
106         bne x31, x7, reg1_error_loop\r
107         li x31, 0x8\r
108         bne x31, x8, reg1_error_loop\r
109         li x31, 0x9\r
110         bne x31, x9, reg1_error_loop\r
111         li x31, 0xa\r
112         bne x31, x10, reg1_error_loop\r
113         li x31, 0xb\r
114         bne x31, x11, reg1_error_loop\r
115         li x31, 0xc\r
116         bne x31, x12, reg1_error_loop\r
117         li x31, 0xd\r
118         bne x31, x13, reg1_error_loop\r
119         li x31, 0xe\r
120         bne x31, x14, reg1_error_loop\r
121         li x31, 0xf\r
122         bne x31, x15, reg1_error_loop\r
123         li x31, 0x10\r
124         bne x31, x16, reg1_error_loop\r
125         li x31, 0x11\r
126         bne x31, x17, reg1_error_loop\r
127         li x31, 0x12\r
128         bne x31, x18, reg1_error_loop\r
129         li x31, 0x13\r
130         bne x31, x19, reg1_error_loop\r
131         li x31, 0x14\r
132         bne x31, x20, reg1_error_loop\r
133         li x31, 0x15\r
134         bne x31, x21, reg1_error_loop\r
135         li x31, 0x16\r
136         bne x31, x22, reg1_error_loop\r
137         li x31, 0x17\r
138         bne x31, x23, reg1_error_loop\r
139         li x31, 0x18\r
140         bne x31, x24, reg1_error_loop\r
141         li x31, 0x19\r
142         bne x31, x25, reg1_error_loop\r
143         li x31, 0x1a\r
144         bne x31, x26, reg1_error_loop\r
145         li x31, 0x1b\r
146         bne x31, x27, reg1_error_loop\r
147         li x31, 0x1c\r
148         bne x31, x28, reg1_error_loop\r
149         li x31, 0x1d\r
150         bne x31, x29, reg1_error_loop\r
151         li x31, 0x1e\r
152         bne x31, x30, reg1_error_loop\r
153 \r
154         /* Check additional chip specific registers still contain the expected\r
155         values. */\r
156         csrr x30, lpstart0\r
157         li x31, 0xaa\r
158         bne x30, x31, reg1_error_loop\r
159         csrr x30, lpstart1\r
160         li x31, 0xab\r
161         bne x30, x31, reg1_error_loop\r
162         csrr x30, lpend0\r
163         li x31, 0xac\r
164         bne x30, x31, reg1_error_loop\r
165         csrr x30, lpend1\r
166         li x31, 0xad\r
167         bne x30, x31, reg1_error_loop\r
168         csrr x30, lpcount0\r
169         li x31, 0xae\r
170         bne x30, x31, reg1_error_loop\r
171         csrr x30, lpcount1\r
172         li x31, 0xaf\r
173         bne x30, x31, reg1_error_loop\r
174 \r
175         /* Everything passed, increment the loop counter. */\r
176         lw x31, ulRegTest1LoopCounterConst\r
177         lw x30, 0(x31)\r
178         addi x30, x30, 1\r
179         sw x30, 0(x31)\r
180 \r
181         /* Restore clobbered register reading for next loop. */\r
182         li x30, 0x1e\r
183 \r
184         /* Yield to increase code coverage. */\r
185         ecall\r
186 \r
187         /* Start again. */\r
188         jal reg1_loop\r
189 \r
190 reg1_error_loop:\r
191         /* Jump here if a register contains an uxpected value.  This stops the loop\r
192         counter being incremented so the check task knows an error was found. */\r
193         ebreak\r
194         jal reg1_error_loop\r
195 \r
196 .align( 16 )\r
197 ulRegTest1LoopCounterConst: .word ulRegTest1LoopCounter\r
198 \r
199 /*-----------------------------------------------------------*/\r
200 \r
201 .align( 8 )\r
202 vRegTest2Implementation:\r
203 \r
204         /* Fill the additional registers with known values. */\r
205         li t0, 0x1aa\r
206         csrw lpstart0, t0\r
207         li t0, 0x1ab\r
208         csrw lpstart1, t0\r
209         li t0, 0x1ac\r
210         csrw lpend0, t0\r
211         li t0, 0x1ad\r
212         csrw lpend1, t0\r
213         li t0, 0x1ae\r
214         csrw lpcount0, t0\r
215         li t0, 0x1af\r
216         csrw lpcount1, t0\r
217 \r
218         /* Fill the core registers with known values. */\r
219         li x6, 0x61\r
220         li x7, 0x71\r
221         li x8, 0x81\r
222         li x9, 0x91\r
223         li x10, 0xa1\r
224         li x11, 0xb1\r
225         li x12, 0xc1\r
226         li x13, 0xd1\r
227         li x14, 0xe1\r
228         li x15, 0xf1\r
229         li x16, 0x20\r
230         li x17, 0x21\r
231         li x18, 0x22\r
232         li x19, 0x23\r
233         li x20, 0x24\r
234         li x21, 0x25\r
235         li x22, 0x26\r
236         li x23, 0x27\r
237         li x24, 0x28\r
238         li x25, 0x29\r
239         li x26, 0x2a\r
240         li x27, 0x2b\r
241         li x28, 0x2c\r
242         li x29, 0x2d\r
243         li x30, 0x2e\r
244         li x31, 0x2f\r
245 \r
246 Reg2_loop:\r
247 \r
248         /* Check each register still contains the expected known value.\r
249         vRegTest2Implementation uses x5 as the temporary, vRegTest1Implementation\r
250         uses x31 as the temporary. */\r
251         li x5, 0x61\r
252         bne x5, x6, reg2_error_loop\r
253         li x5, 0x71\r
254         bne x5, x7, reg2_error_loop\r
255         li x5, 0x81\r
256         bne x5, x8, reg2_error_loop\r
257         li x5, 0x91\r
258         bne x5, x9, reg2_error_loop\r
259         li x5, 0xa1\r
260         bne x5, x10, reg2_error_loop\r
261         li x5, 0xb1\r
262         bne x5, x11, reg2_error_loop\r
263         li x5, 0xc1\r
264         bne x5, x12, reg2_error_loop\r
265         li x5, 0xd1\r
266         bne x5, x13, reg2_error_loop\r
267         li x5, 0xe1\r
268         bne x5, x14, reg2_error_loop\r
269         li x5, 0xf1\r
270         bne x5, x15, reg2_error_loop\r
271         li x5, 0x20\r
272         bne x5, x16, reg2_error_loop\r
273         li x5, 0x21\r
274         bne x5, x17, reg2_error_loop\r
275         li x5, 0x22\r
276         bne x5, x18, reg2_error_loop\r
277         li x5, 0x23\r
278         bne x5, x19, reg2_error_loop\r
279         li x5, 0x24\r
280         bne x5, x20, reg2_error_loop\r
281         li x5, 0x25\r
282         bne x5, x21, reg2_error_loop\r
283         li x5, 0x26\r
284         bne x5, x22, reg2_error_loop\r
285         li x5, 0x27\r
286         bne x5, x23, reg2_error_loop\r
287         li x5, 0x28\r
288         bne x5, x24, reg2_error_loop\r
289         li x5, 0x29\r
290         bne x5, x25, reg2_error_loop\r
291         li x5, 0x2a\r
292         bne x5, x26, reg2_error_loop\r
293         li x5, 0x2b\r
294         bne x5, x27, reg2_error_loop\r
295         li x5, 0x2c\r
296         bne x5, x28, reg2_error_loop\r
297         li x5, 0x2d\r
298         bne x5, x29, reg2_error_loop\r
299         li x5, 0x2e\r
300         bne x5, x30, reg2_error_loop\r
301         li x5, 0x2f\r
302         bne x5, x31, reg2_error_loop\r
303 \r
304         /* Check additional chip specific registers still contain the expected\r
305         values. */\r
306         csrr x5, lpstart0\r
307         li x6, 0x1aa\r
308         bne x5, x6, reg2_error_loop\r
309         csrr x5, lpstart1\r
310         li x6, 0x1ab\r
311         bne x5, x6, reg2_error_loop\r
312         csrr x5, lpend0\r
313         li x6, 0x1ac\r
314         bne x5, x6, reg2_error_loop\r
315         csrr x5, lpend1\r
316         li x6, 0x1ad\r
317         bne x5, x6, reg2_error_loop\r
318         csrr x5, lpcount0\r
319         li x6, 0x1ae\r
320         bne x5, x6, reg2_error_loop\r
321         csrr x5, lpcount1\r
322         li x6, 0x1af\r
323         bne x5, x6, reg2_error_loop\r
324 \r
325         /* Everything passed, increment the loop counter. */\r
326         lw x5, ulRegTest2LoopCounterConst\r
327         lw x6, 0(x5)\r
328         addi x6, x6, 1\r
329         sw x6, 0(x5)\r
330 \r
331         /* Restore clobbered register reading for next loop. */\r
332         li x6, 0x61\r
333 \r
334         /* Start again. */\r
335         jal Reg2_loop\r
336 \r
337 reg2_error_loop:\r
338         /* Jump here if a register contains an uxpected value.  This stops the loop\r
339         counter being incremented so the check task knows an error was found. */\r
340         ebreak\r
341         jal reg2_error_loop\r
342 \r
343 .align( 16 )\r
344 ulRegTest2LoopCounterConst: .word ulRegTest2LoopCounter\r
345 \r
346 \r