]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/RTOSDemo/src/Full_Demo/RegisterTests.S
commit 9f316c246baafa15c542a5aea81a94f26e3d6507
[freertos] / FreeRTOS / Demo / MicroBlaze_Kintex7_EthernetLite / RTOSDemo / src / Full_Demo / RegisterTests.S
1 /*\r
2  * FreeRTOS Kernel V10.3.0\r
3  * Copyright (C) 2020 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 \r
29 /*\r
30  * The register test task as described in the comments at the top of main-full.c.\r
31  */\r
32 .global vRegTest1Implementation\r
33 .global vRegTest2Implementation\r
34 \r
35 /* Variables that are incremented on each iteration of the reg test tasks -\r
36 provided the tasks have not reported any errors.  The check timer inspects these\r
37 variables to ensure they are still incrementing as expected.  If a variable\r
38 stops incrementing then it is likely that its associate task has stalled or\r
39 detected an error. */\r
40 .extern ulRegTest1LoopCounter\r
41 .extern ulRegTest2LoopCounter\r
42 \r
43 /*-----------------------------------------------------------*/\r
44 \r
45 .section .text\r
46 .align 2\r
47 vRegTest1Implementation:\r
48         /* First fill the relevant registers with known values.  r0 is always 0, r1\r
49         is the stack pointer, and r3 is a read only small data area pointer. */\r
50         addi r3, r0, 3\r
51         addi r4, r0, 4\r
52         addi r5, r0, 5\r
53         addi r6, r0, 6\r
54         addi r7, r0, 7\r
55         addi r8, r0, 8\r
56         addi r9, r0, 9\r
57         addi r10, r0, 10\r
58         addi r11, r0, 11\r
59         addi r12, r0, 12\r
60         /* R13 = read write small data area anchour. */\r
61         /* R14 = return address for interrupt. */\r
62         /* R15 = return address for sub-routine. */\r
63         /* R16 = return address for trap. */\r
64         /* R17 = return address for exceptions. */\r
65         /* R18 = reserved for assembler and compiler temporaries. */\r
66         addi r19, r0, 19\r
67         addi r20, r0, 20\r
68         addi r21, r0, 21\r
69         addi r22, r0, 22\r
70         addi r23, r0, 23\r
71         addi r24, r0, 24\r
72         addi r25, r0, 25\r
73         addi r26, r0, 26\r
74         addi r27, r0, 27\r
75         addi r28, r0, 28\r
76         addi r29, r0, 29\r
77         addi r30, r0, 30\r
78         addi r31, r0, 31\r
79 \r
80         /* Now test the register values to ensure they contain the same value that\r
81         was written to them above.       This task will get preempted frequently so\r
82         other tasks are likely to have executed since the register values were\r
83         written.  If any register contains an unexpected value then the task will\r
84         branch to Error_Loop_1, which in turn prevents it from incrementing its\r
85         loop counter, enabling the check timer to determine that all is not as it\r
86         should be. */\r
87 \r
88 Loop_Start_1:\r
89         xori r18, r3, 3\r
90         bnei r18, Error_Loop_1\r
91         xori r18, r4, 4\r
92         bnei r18, Error_Loop_1\r
93         xori r18, r6, 6\r
94         bnei r18, Error_Loop_1\r
95         xori r18, r7, 7\r
96         bnei r18, Error_Loop_1\r
97         xori r18, r8, 8\r
98         bnei r18, Error_Loop_1\r
99         xori r18, r9, 9\r
100         bnei r18, Error_Loop_1\r
101         xori r18, r10, 10\r
102         bnei r18, Error_Loop_1\r
103         xori r18, r11, 11\r
104         bnei r18, Error_Loop_1\r
105         xori r18, r12, 12\r
106         bnei r18, Error_Loop_1\r
107         xori r18, r19, 19\r
108         bnei r18, Error_Loop_1\r
109         xori r18, r20, 20\r
110         bnei r18, Error_Loop_1\r
111         xori r18, r21, 21\r
112         bnei r18, Error_Loop_1\r
113         xori r18, r22, 22\r
114         bnei r18, Error_Loop_1\r
115         xori r18, r23, 23\r
116         bnei r18, Error_Loop_1\r
117         xori r18, r24, 24\r
118         bnei r18, Error_Loop_1\r
119         xori r18, r25, 25\r
120         bnei r18, Error_Loop_1\r
121         xori r18, r26, 26\r
122         bnei r18, Error_Loop_1\r
123         xori r18, r27, 27\r
124         bnei r18, Error_Loop_1\r
125         xori r18, r28, 28\r
126         bnei r18, Error_Loop_1\r
127         xori r18, r29, 29\r
128         bnei r18, Error_Loop_1\r
129         xori r18, r30, 30\r
130         bnei r18, Error_Loop_1\r
131         xori r18, r31, 31\r
132         bnei r18, Error_Loop_1\r
133 \r
134         /* If this task has not branched to the error loop, then everything is ok,\r
135         and the check variable can be incremented to indicate that this task\r
136         is still running.  Then, brach back to the top to check the register\r
137         contents again. */\r
138         lwi r18, r0, ulRegTest1LoopCounter\r
139         addik r18, r18, 1\r
140         swi r18, r0, ulRegTest1LoopCounter\r
141 \r
142         bri Loop_Start_1\r
143 \r
144         /* The test function will branch here if it discovers an error.  This part\r
145         of the code just sits in a NULL loop, which prevents the check variable\r
146         incrementing any further to allow the check timer to recognize that this\r
147         test has failed. */\r
148 Error_Loop_1:\r
149         bri 0\r
150         nop\r
151 \r
152 /*-----------------------------------------------------------*/\r
153 \r
154 .section .text\r
155 .align 2\r
156 vRegTest2Implementation:\r
157         /* First fill the relevant registers with known values.  r0 is always 0, r1\r
158         is the stack pointer, and r3 is a read only small data area pointer. */\r
159         addi r3, r0, 30000\r
160         addi r4, r0, 40000\r
161         addi r5, r0, 50000\r
162         addi r6, r0, 60000\r
163         addi r7, r0, 70000\r
164         addi r8, r0, 80000\r
165         addi r9, r0, 90000\r
166         addi r10, r0, 100000\r
167         addi r11, r0, 110000\r
168         addi r12, r0, 120000\r
169         /* R13 = read write small data area anchour. */\r
170         /* R14 = return address for interrupt. */\r
171         /* R15 = return address for sub-routine. */\r
172         /* R16 = return address for trap. */\r
173         /* R17 = return address for exceptions. */\r
174         /* R18 = reserved for assembler and compiler temporaries. */\r
175         addi r19, r0, 190000\r
176         addi r20, r0, 200000\r
177         addi r21, r0, 210000\r
178         addi r22, r0, 220000\r
179         addi r23, r0, 230000\r
180         addi r24, r0, 240000\r
181         addi r25, r0, 250000\r
182         addi r26, r0, 260000\r
183         addi r27, r0, 270000\r
184         addi r28, r0, 280000\r
185         addi r29, r0, 290000\r
186         addi r30, r0, 300000\r
187         addi r31, r0, 310000\r
188 \r
189         /* Now test the register values to ensure they contain the same value that\r
190         was written to them above.       This task will get preempted frequently so\r
191         other tasks are likely to have executed since the register values were\r
192         written.  If any register contains an unexpected value then the task will\r
193         branch to Error_Loop_2, which in turn prevents it from incrementing its\r
194         loop counter, enabling the check timer to determine that all is not as it\r
195         should be. */\r
196 \r
197 Loop_Start_2:\r
198         xori r18, r3, 30000\r
199         bnei r18, Error_Loop_2\r
200         xori r18, r4, 40000\r
201         bnei r18, Error_Loop_2\r
202         xori r18, r6, 60000\r
203         bnei r18, Error_Loop_2\r
204         xori r18, r7, 70000\r
205         bnei r18, Error_Loop_2\r
206         xori r18, r8, 80000\r
207         bnei r18, Error_Loop_2\r
208         xori r18, r9, 90000\r
209         bnei r18, Error_Loop_2\r
210         xori r18, r10, 100000\r
211         bnei r18, Error_Loop_2\r
212         xori r18, r11, 110000\r
213         bnei r18, Error_Loop_2\r
214         xori r18, r12, 120000\r
215         bnei r18, Error_Loop_2\r
216         xori r18, r19, 190000\r
217         bnei r18, Error_Loop_2\r
218         xori r18, r20, 200000\r
219         bnei r18, Error_Loop_2\r
220         xori r18, r21, 210000\r
221         bnei r18, Error_Loop_2\r
222         xori r18, r22, 220000\r
223         bnei r18, Error_Loop_2\r
224         xori r18, r23, 230000\r
225         bnei r18, Error_Loop_2\r
226         xori r18, r24, 240000\r
227         bnei r18, Error_Loop_2\r
228         xori r18, r25, 250000\r
229         bnei r18, Error_Loop_2\r
230         xori r18, r26, 260000\r
231         bnei r18, Error_Loop_2\r
232         xori r18, r27, 270000\r
233         bnei r18, Error_Loop_2\r
234         xori r18, r28, 280000\r
235         bnei r18, Error_Loop_2\r
236         xori r18, r29, 290000\r
237         bnei r18, Error_Loop_2\r
238         xori r18, r30, 300000\r
239         bnei r18, Error_Loop_2\r
240         xori r18, r31, 310000\r
241         bnei r18, Error_Loop_2\r
242 \r
243         /* If this task has not branched to the error loop, then everything is ok,\r
244         and the check variable can be incremented to indicate that this task\r
245         is still running.  Then, brach back to the top to check the register\r
246         contents again. */\r
247         lwi r18, r0, ulRegTest2LoopCounter\r
248         addik r18, r18, 1\r
249         swi r18, r0, ulRegTest2LoopCounter\r
250 \r
251         bri Loop_Start_2\r
252 \r
253         /* The test function will branch here if it discovers an error.  This part\r
254         of the code just sits in a NULL loop, which prevents the check variable\r
255         incrementing any further to allow the check timer to recognize that this\r
256         test has failed. */\r
257 Error_Loop_2:\r
258         bri 0\r
259         nop\r
260 \r