]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemo/RegisterTests.c
Update version number to 8.1.2 after moving the defaulting of configUSE_PORT_OPTIMISE...
[freertos] / FreeRTOS / Demo / MicroBlaze_Spartan-6_EthernetLite / SDKProjects / RTOSDemo / RegisterTests.c
1 /*\r
2     FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd. \r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     ***************************************************************************\r
8      *                                                                       *\r
9      *    FreeRTOS provides completely free yet professionally developed,    *\r
10      *    robust, strictly quality controlled, supported, and cross          *\r
11      *    platform software that has become a de facto standard.             *\r
12      *                                                                       *\r
13      *    Help yourself get started quickly and support the FreeRTOS         *\r
14      *    project by purchasing a FreeRTOS tutorial book, reference          *\r
15      *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
16      *                                                                       *\r
17      *    Thank you!                                                         *\r
18      *                                                                       *\r
19     ***************************************************************************\r
20 \r
21     This file is part of the FreeRTOS distribution.\r
22 \r
23     FreeRTOS is free software; you can redistribute it and/or modify it under\r
24     the terms of the GNU General Public License (version 2) as published by the\r
25     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
26 \r
27     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
28     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
29     >>!   obliged to provide the source code for proprietary components     !<<\r
30     >>!   outside of the FreeRTOS kernel.                                   !<<\r
31 \r
32     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
33     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
34     FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
35     link: http://www.freertos.org/a00114.html\r
36 \r
37     1 tab == 4 spaces!\r
38 \r
39     ***************************************************************************\r
40      *                                                                       *\r
41      *    Having a problem?  Start by reading the FAQ "My application does   *\r
42      *    not run, what could be wrong?"                                     *\r
43      *                                                                       *\r
44      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
45      *                                                                       *\r
46     ***************************************************************************\r
47 \r
48     http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
49     license and Real Time Engineers Ltd. contact details.\r
50 \r
51     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
52     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
53     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
54 \r
55     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
56     Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
57     licenses offer ticketed support, indemnification and middleware.\r
58 \r
59     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
60     engineered and independently SIL3 certified version for use in safety and\r
61     mission critical applications that require provable dependability.\r
62 \r
63     1 tab == 4 spaces!\r
64 */\r
65 \r
66 /* Scheduler includes. */\r
67 #include "FreeRTOS.h"\r
68 #include "task.h"\r
69 \r
70 /*\r
71  * The register test task as described in the comments at the top of main-full.c.\r
72  */\r
73 void vRegisterTest1( void *pvParameters );\r
74 void vRegisterTest2( void *pvParameters );\r
75 \r
76 /* Variables that are incremented on each iteration of the reg test tasks -\r
77 provided the tasks have not reported any errors.  The check timer inspects these\r
78 variables to ensure they are still incrementing as expected.  If a variable\r
79 stops incrementing then it is likely that its associate task has stalled or\r
80 detected an error. */\r
81 volatile unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;\r
82 \r
83 /*-----------------------------------------------------------*/\r
84 \r
85 void vRegisterTest1( void *pvParameters )\r
86 {\r
87         /* This task uses an infinite loop that is implemented in the assembly \r
88         code.\r
89         \r
90         First fill the relevant registers with known values. */\r
91         asm volatile (  "       addi r3, r0, 3          \n\t" \\r
92                                         "       addi r4, r0, 4          \n\t" \\r
93                                         "       addi r6, r0, 6          \n\t" \\r
94                                         "       addi r7, r0, 7          \n\t" \\r
95                                         "       addi r8, r0, 8          \n\t" \\r
96                                         "       addi r9, r0, 9          \n\t" \\r
97                                         "       addi r10, r0, 10        \n\t" \\r
98                                         "       addi r11, r0, 11        \n\t" \\r
99                                         "       addi r12, r0, 12        \n\t" \\r
100                                         "       addi r16, r0, 16        \n\t" \\r
101                                         "       addi r19, r0, 19        \n\t" \\r
102                                         "       addi r20, r0, 20        \n\t" \\r
103                                         "       addi r21, r0, 21        \n\t" \\r
104                                         "       addi r22, r0, 22        \n\t" \\r
105                                         "       addi r23, r0, 23        \n\t" \\r
106                                         "       addi r24, r0, 24        \n\t" \\r
107                                         "       addi r25, r0, 25        \n\t" \\r
108                                         "       addi r26, r0, 26        \n\t" \\r
109                                         "       addi r27, r0, 27        \n\t" \\r
110                                         "       addi r28, r0, 28        \n\t" \\r
111                                         "       addi r29, r0, 29        \n\t" \\r
112                                         "       addi r30, r0, 30        \n\t" \\r
113                                         "       addi r31, r0, 31        \n\t"\r
114                                 );\r
115 \r
116         /* Now test the register values to ensure they contain the same value that\r
117         was written to them above.       This task will get preempted frequently so \r
118         other tasks are likely to have executed since the register values were \r
119         written.  If any register contains an unexpected value then the task will\r
120         branch to Error_Loop_1, which in turn prevents it from incrementing its\r
121         loop counter, enabling the check timer to determine that all is not as it\r
122         should be. */\r
123 \r
124         asm volatile (  "Loop_Start_1:                          \n\t" \\r
125                                         "       xori r18, r3, 3                 \n\t" \\r
126                                         "       bnei r18, Error_Loop_1  \n\t" \\r
127                                         "       xori r18, r4, 4                 \n\t" \\r
128                                         "       bnei r18, Error_Loop_1  \n\t" \\r
129                                         "       xori r18, r6, 6                 \n\t" \\r
130                                         "       bnei r18, Error_Loop_1  \n\t" \\r
131                                         "       xori r18, r7, 7                 \n\t" \\r
132                                         "       bnei r18, Error_Loop_1  \n\t" \\r
133                                         "       xori r18, r8, 8                 \n\t" \\r
134                                         "       bnei r18, Error_Loop_1  \n\t" \\r
135                                         "       xori r18, r9, 9                 \n\t" \\r
136                                         "       bnei r18, Error_Loop_1  \n\t" \\r
137                                         "       xori r18, r10, 10               \n\t" \\r
138                                         "       bnei r18, Error_Loop_1  \n\t" \\r
139                                         "       xori r18, r11, 11               \n\t" \\r
140                                         "       bnei r18, Error_Loop_1  \n\t" \\r
141                                         "       xori r18, r12, 12               \n\t" \\r
142                                         "       bnei r18, Error_Loop_1  \n\t" \\r
143                                         "       xori r18, r16, 16               \n\t" \\r
144                                         "       bnei r18, Error_Loop_1  \n\t" \\r
145                                         "       xori r18, r19, 19               \n\t" \\r
146                                         "       bnei r18, Error_Loop_1  \n\t" \\r
147                                         "       xori r18, r20, 20               \n\t" \\r
148                                         "       bnei r18, Error_Loop_1  \n\t" \\r
149                                         "       xori r18, r21, 21               \n\t" \\r
150                                         "       bnei r18, Error_Loop_1  \n\t" \\r
151                                         "       xori r18, r22, 22               \n\t" \\r
152                                         "       bnei r18, Error_Loop_1  \n\t" \\r
153                                         "       xori r18, r23, 23               \n\t" \\r
154                                         "       bnei r18, Error_Loop_1  \n\t" \\r
155                                         "       xori r18, r24, 24               \n\t" \\r
156                                         "       bnei r18, Error_Loop_1  \n\t" \\r
157                                         "       xori r18, r25, 25               \n\t" \\r
158                                         "       bnei r18, Error_Loop_1  \n\t" \\r
159                                         "       xori r18, r26, 26               \n\t" \\r
160                                         "       bnei r18, Error_Loop_1  \n\t" \\r
161                                         "       xori r18, r27, 27               \n\t" \\r
162                                         "       bnei r18, Error_Loop_1  \n\t" \\r
163                                         "       xori r18, r28, 28               \n\t" \\r
164                                         "       bnei r18, Error_Loop_1  \n\t" \\r
165                                         "       xori r18, r29, 29               \n\t" \\r
166                                         "       bnei r18, Error_Loop_1  \n\t" \\r
167                                         "       xori r18, r30, 30               \n\t" \\r
168                                         "       bnei r18, Error_Loop_1  \n\t" \\r
169                                         "       xori r18, r31, 31               \n\t" \\r
170                                         "       bnei r18, Error_Loop_1  \n\t"\r
171                                  );\r
172 \r
173         /* If this task has not branched to the error loop, then everything is ok,\r
174         and the check variable can be incremented to indicate that this task\r
175         is still running.  Then, brach back to the top to check the register\r
176         contents again. */\r
177         asm volatile (  "       lwi r18, r0, ulRegTest1CycleCount       \n\t" \\r
178                                         "       addik r18, r18, 1                                       \n\t" \\r
179                                         "       swi r18, r0, ulRegTest1CycleCount       \n\t" \\r
180                                         "                                                                               \n\t" \\r
181                                         "       bri Loop_Start_1 "\r
182                                  );\r
183 \r
184          /* The test function will branch here if it discovers an error.  This part\r
185         of the code just sits in a NULL loop, which prevents the check variable\r
186         incrementing any further to allow the check timer to recognize that this\r
187         test has failed. */\r
188         asm volatile (  "Error_Loop_1:                  \n\t" \\r
189                                         "       bri 0                           \n\t" \\r
190                                         "       nop                                     \n\t" \\r
191                                  );\r
192 \r
193         ( void ) pvParameters;\r
194 }\r
195 /*-----------------------------------------------------------*/\r
196 \r
197 void vRegisterTest2( void *pvParameters )\r
198 {\r
199         /* This task uses an infinite loop that is implemented in the assembly \r
200         code.\r
201         \r
202         First fill the registers with known values. */\r
203         asm volatile (  "       addi r16, r0, 1016      \n\t" \\r
204                                         "       addi r19, r0, 1019      \n\t" \\r
205                                         "       addi r20, r0, 1020      \n\t" \\r
206                                         "       addi r21, r0, 1021      \n\t" \\r
207                                         "       addi r22, r0, 1022      \n\t" \\r
208                                         "       addi r23, r0, 1023      \n\t" \\r
209                                         "       addi r24, r0, 1024      \n\t" \\r
210                                         "       addi r25, r0, 1025      \n\t" \\r
211                                         "       addi r26, r0, 1026      \n\t" \\r
212                                         "       addi r27, r0, 1027      \n\t" \\r
213                                         "       addi r28, r0, 1028      \n\t" \\r
214                                         "       addi r29, r0, 1029      \n\t" \\r
215                                         "       addi r30, r0, 1030      \n\t" \\r
216                                         "       addi r31, r0, 1031      \n\t" \\r
217                                         "                                                       " \\r
218                                         "Loop_Start_2:                          "\r
219                                 );\r
220 \r
221         /* Unlike vRegisterTest1, vRegisterTest2 performs a yield.  This increases\r
222         the test coverage, but does mean volatile registers need re-loading with \r
223         their exepcted values. */\r
224         taskYIELD();\r
225 \r
226         /* taskYIELD() could have changed temporaries - set them back to those\r
227         expected by the reg test task. */\r
228         asm volatile (  "       addi r3, r0, 103        \n\t" \\r
229                                         "       addi r4, r0, 104        \n\t" \\r
230                                         "       addi r6, r0, 106        \n\t" \\r
231                                         "       addi r7, r0, 107        \n\t" \\r
232                                         "       addi r8, r0, 108        \n\t" \\r
233                                         "       addi r9, r0, 109        \n\t" \\r
234                                         "       addi r10, r0, 1010      \n\t" \\r
235                                         "       addi r11, r0, 1011      \n\t" \\r
236                                         "       addi r12, r0, 1012      \n\t" \\r
237                                 );\r
238 \r
239 \r
240         /* Now test the register values to ensure they contain the same value that\r
241         was written to them above.       This task will get preempted frequently so \r
242         other tasks are likely to have executed since the register values were \r
243         written. */\r
244         asm volatile (  "       xori r18, r3, 103               \n\t" \\r
245                                         "       bnei r18, Error_Loop_2  \n\t" \\r
246                                         "       xori r18, r4, 104               \n\t" \\r
247                                         "       bnei r18, Error_Loop_2  \n\t" \\r
248                                         "       xori r18, r6, 106               \n\t" \\r
249                                         "       bnei r18, Error_Loop_2  \n\t" \\r
250                                         "       xori r18, r7, 107               \n\t" \\r
251                                         "       bnei r18, Error_Loop_2  \n\t" \\r
252                                         "       xori r18, r8, 108               \n\t" \\r
253                                         "       bnei r18, Error_Loop_2  \n\t" \\r
254                                         "       xori r18, r9, 109               \n\t" \\r
255                                         "       bnei r18, Error_Loop_2  \n\t" \\r
256                                         "       xori r18, r10, 1010             \n\t" \\r
257                                         "       bnei r18, Error_Loop_2  \n\t" \\r
258                                         "       xori r18, r11, 1011             \n\t" \\r
259                                         "       bnei r18, Error_Loop_2  \n\t" \\r
260                                         "       xori r18, r12, 1012             \n\t" \\r
261                                         "       bnei r18, Error_Loop_2  \n\t" \\r
262                                         "       xori r18, r16, 1016             \n\t" \\r
263                                         "       bnei r18, Error_Loop_2  \n\t" \\r
264                                         "       xori r18, r19, 1019             \n\t" \\r
265                                         "       bnei r18, Error_Loop_2  \n\t" \\r
266                                         "       xori r18, r20, 1020             \n\t" \\r
267                                         "       bnei r18, Error_Loop_2  \n\t" \\r
268                                         "       xori r18, r21, 1021             \n\t" \\r
269                                         "       bnei r18, Error_Loop_2  \n\t" \\r
270                                         "       xori r18, r22, 1022             \n\t" \\r
271                                         "       bnei r18, Error_Loop_2  \n\t" \\r
272                                         "       xori r18, r23, 1023             \n\t" \\r
273                                         "       bnei r18, Error_Loop_2  \n\t" \\r
274                                         "       xori r18, r24, 1024             \n\t" \\r
275                                         "       bnei r18, Error_Loop_2  \n\t" \\r
276                                         "       xori r18, r25, 1025             \n\t" \\r
277                                         "       bnei r18, Error_Loop_2  \n\t" \\r
278                                         "       xori r18, r26, 1026             \n\t" \\r
279                                         "       bnei r18, Error_Loop_2  \n\t" \\r
280                                         "       xori r18, r27, 1027             \n\t" \\r
281                                         "       bnei r18, Error_Loop_2  \n\t" \\r
282                                         "       xori r18, r28, 1028             \n\t" \\r
283                                         "       bnei r18, Error_Loop_2  \n\t" \\r
284                                         "       xori r18, r29, 1029             \n\t" \\r
285                                         "       bnei r18, Error_Loop_2  \n\t" \\r
286                                         "       xori r18, r30, 1030             \n\t" \\r
287                                         "       bnei r18, Error_Loop_2  \n\t" \\r
288                                         "       xori r18, r31, 1031             \n\t" \\r
289                                         "       bnei r18, Error_Loop_2  \n\t"\r
290                                  );\r
291 \r
292         /* If this task has not branched to the error loop, then everything is ok,\r
293         and the check variable should be incremented to indicate that this task\r
294         is still running.  Then, brach back to the top to check the registers\r
295         again. */\r
296         asm volatile (  "       lwi r18, r0, ulRegTest2CycleCount       \n\t" \\r
297                                         "       addik r18, r18, 1                                       \n\t" \\r
298                                         "       swi r18, r0, ulRegTest2CycleCount       \n\t" \\r
299                                         "                                                                               \n\t" \\r
300                                         "       bri Loop_Start_2 "\r
301                                  );\r
302 \r
303          /* The test function will branch here if it discovers an error.  This part\r
304         of the code just sits in a NULL loop, which prevents the check variable\r
305         incrementing any further to allow the check timer to recognize that this\r
306         test has failed. */\r
307         asm volatile (  "Error_Loop_2:                  \n\t" \\r
308                                         "       bri 0                           \n\t" \\r
309                                         "       nop                                     \n\t" \\r
310                                  );\r
311 \r
312         ( void ) pvParameters;\r
313 }\r
314 \r
315 \r
316 \r
317 \r
318 \r
319 \r