]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/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-Qemu-sifive_e-FreedomStudio / 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 /*\r
37  * The register check tasks are described in the comments at the top of\r
38  * main_full.c.\r
39  */\r
40 \r
41 .align( 8 )\r
42 vRegTest1Implementation:\r
43 \r
44         /* Fill the core registers with known values. */\r
45         li x5, 0x5\r
46         li x6, 0x6\r
47         li x7, 0x7\r
48         li x8, 0x8\r
49         li x9, 0x9\r
50         li x10, 0xa\r
51         li x11, 0xb\r
52         li x12, 0xc\r
53         li x13, 0xd\r
54         li x14, 0xe\r
55         li x15, 0xf\r
56         li x16, 0x10\r
57         li x17, 0x11\r
58         li x18, 0x12\r
59         li x19, 0x13\r
60         li x20, 0x14\r
61         li x21, 0x15\r
62         li x22, 0x16\r
63         li x23, 0x17\r
64         li x24, 0x18\r
65         li x25, 0x19\r
66         li x26, 0x1a\r
67         li x27, 0x1b\r
68         li x28, 0x1c\r
69         li x29, 0x1d\r
70         li x30, 0x1e\r
71 \r
72 reg1_loop:\r
73 \r
74         /* Check each register still contains the expected known value.\r
75         vRegTest1Implementation uses x31 as the temporary, vRegTest2Implementation\r
76         uses x5 as the temporary. */\r
77         li x31, 0x5\r
78         bne x31, x5, reg1_error_loop\r
79         li x31, 0x6\r
80         bne x31, x6, reg1_error_loop\r
81         li x31, 0x7\r
82         bne x31, x7, reg1_error_loop\r
83         li x31, 0x8\r
84         bne x31, x8, reg1_error_loop\r
85         li x31, 0x9\r
86         bne x31, x9, reg1_error_loop\r
87         li x31, 0xa\r
88         bne x31, x10, reg1_error_loop\r
89         li x31, 0xb\r
90         bne x31, x11, reg1_error_loop\r
91         li x31, 0xc\r
92         bne x31, x12, reg1_error_loop\r
93         li x31, 0xd\r
94         bne x31, x13, reg1_error_loop\r
95         li x31, 0xe\r
96         bne x31, x14, reg1_error_loop\r
97         li x31, 0xf\r
98         bne x31, x15, reg1_error_loop\r
99         li x31, 0x10\r
100         bne x31, x16, reg1_error_loop\r
101         li x31, 0x11\r
102         bne x31, x17, reg1_error_loop\r
103         li x31, 0x12\r
104         bne x31, x18, reg1_error_loop\r
105         li x31, 0x13\r
106         bne x31, x19, reg1_error_loop\r
107         li x31, 0x14\r
108         bne x31, x20, reg1_error_loop\r
109         li x31, 0x15\r
110         bne x31, x21, reg1_error_loop\r
111         li x31, 0x16\r
112         bne x31, x22, reg1_error_loop\r
113         li x31, 0x17\r
114         bne x31, x23, reg1_error_loop\r
115         li x31, 0x18\r
116         bne x31, x24, reg1_error_loop\r
117         li x31, 0x19\r
118         bne x31, x25, reg1_error_loop\r
119         li x31, 0x1a\r
120         bne x31, x26, reg1_error_loop\r
121         li x31, 0x1b\r
122         bne x31, x27, reg1_error_loop\r
123         li x31, 0x1c\r
124         bne x31, x28, reg1_error_loop\r
125         li x31, 0x1d\r
126         bne x31, x29, reg1_error_loop\r
127         li x31, 0x1e\r
128         bne x31, x30, reg1_error_loop\r
129 \r
130         /* Everything passed, increment the loop counter. */\r
131         lw x31, ulRegTest1LoopCounterConst\r
132         lw x30, 0(x31)\r
133         addi x30, x30, 1\r
134         sw x30, 0(x31)\r
135 \r
136         /* Restore clobbered register reading for next loop. */\r
137         li x30, 0x1e\r
138 \r
139         /* Yield to increase code coverage. */\r
140         ecall\r
141 \r
142         /* Start again. */\r
143         jal reg1_loop\r
144 \r
145 reg1_error_loop:\r
146         /* Jump here if a register contains an uxpected value.  This stops the loop\r
147         counter being incremented so the check task knows an error was found. */\r
148         ebreak\r
149         jal reg1_error_loop\r
150 \r
151 .align( 16 )\r
152 ulRegTest1LoopCounterConst: .word ulRegTest1LoopCounter\r
153 \r
154 /*-----------------------------------------------------------*/\r
155 \r
156 .align( 8 )\r
157 vRegTest2Implementation:\r
158 \r
159         /* Fill the core registers with known values. */\r
160         li x6, 0x61\r
161         li x7, 0x71\r
162         li x8, 0x81\r
163         li x9, 0x91\r
164         li x10, 0xa1\r
165         li x11, 0xb1\r
166         li x12, 0xc1\r
167         li x13, 0xd1\r
168         li x14, 0xe1\r
169         li x15, 0xf1\r
170         li x16, 0x20\r
171         li x17, 0x21\r
172         li x18, 0x22\r
173         li x19, 0x23\r
174         li x20, 0x24\r
175         li x21, 0x25\r
176         li x22, 0x26\r
177         li x23, 0x27\r
178         li x24, 0x28\r
179         li x25, 0x29\r
180         li x26, 0x2a\r
181         li x27, 0x2b\r
182         li x28, 0x2c\r
183         li x29, 0x2d\r
184         li x30, 0x2e\r
185         li x31, 0x2f\r
186 \r
187 Reg2_loop:\r
188 \r
189         /* Check each register still contains the expected known value.\r
190         vRegTest2Implementation uses x5 as the temporary, vRegTest1Implementation\r
191         uses x31 as the temporary. */\r
192         li x5, 0x61\r
193         bne x5, x6, reg2_error_loop\r
194         li x5, 0x71\r
195         bne x5, x7, reg2_error_loop\r
196         li x5, 0x81\r
197         bne x5, x8, reg2_error_loop\r
198         li x5, 0x91\r
199         bne x5, x9, reg2_error_loop\r
200         li x5, 0xa1\r
201         bne x5, x10, reg2_error_loop\r
202         li x5, 0xb1\r
203         bne x5, x11, reg2_error_loop\r
204         li x5, 0xc1\r
205         bne x5, x12, reg2_error_loop\r
206         li x5, 0xd1\r
207         bne x5, x13, reg2_error_loop\r
208         li x5, 0xe1\r
209         bne x5, x14, reg2_error_loop\r
210         li x5, 0xf1\r
211         bne x5, x15, reg2_error_loop\r
212         li x5, 0x20\r
213         bne x5, x16, reg2_error_loop\r
214         li x5, 0x21\r
215         bne x5, x17, reg2_error_loop\r
216         li x5, 0x22\r
217         bne x5, x18, reg2_error_loop\r
218         li x5, 0x23\r
219         bne x5, x19, reg2_error_loop\r
220         li x5, 0x24\r
221         bne x5, x20, reg2_error_loop\r
222         li x5, 0x25\r
223         bne x5, x21, reg2_error_loop\r
224         li x5, 0x26\r
225         bne x5, x22, reg2_error_loop\r
226         li x5, 0x27\r
227         bne x5, x23, reg2_error_loop\r
228         li x5, 0x28\r
229         bne x5, x24, reg2_error_loop\r
230         li x5, 0x29\r
231         bne x5, x25, reg2_error_loop\r
232         li x5, 0x2a\r
233         bne x5, x26, reg2_error_loop\r
234         li x5, 0x2b\r
235         bne x5, x27, reg2_error_loop\r
236         li x5, 0x2c\r
237         bne x5, x28, reg2_error_loop\r
238         li x5, 0x2d\r
239         bne x5, x29, reg2_error_loop\r
240         li x5, 0x2e\r
241         bne x5, x30, reg2_error_loop\r
242         li x5, 0x2f\r
243         bne x5, x31, reg2_error_loop\r
244 \r
245         /* Everything passed, increment the loop counter. */\r
246         lw x5, ulRegTest2LoopCounterConst\r
247         lw x6, 0(x5)\r
248         addi x6, x6, 1\r
249         sw x6, 0(x5)\r
250 \r
251         /* Restore clobbered register reading for next loop. */\r
252         li x6, 0x61\r
253 \r
254         /* Start again. */\r
255         jal Reg2_loop\r
256 \r
257 reg2_error_loop:\r
258         /* Jump here if a register contains an uxpected value.  This stops the loop\r
259         counter being incremented so the check task knows an error was found. */\r
260         ebreak\r
261         jal reg2_error_loop\r
262 \r
263 .align( 16 )\r
264 ulRegTest2LoopCounterConst: .word ulRegTest2LoopCounter\r
265 \r
266 \r