]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/PIC32MEC14xx_MPLAB/src/Full_Demo/RegisterTestTasks.S
b109593e3c3928a3cbd9e0d4a58bd5c4997c6cee
[freertos] / FreeRTOS / Demo / PIC32MEC14xx_MPLAB / src / Full_Demo / RegisterTestTasks.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 \r
29 #include <xc.h>\r
30 #include <sys/asm.h>\r
31 \r
32 \r
33         .global vRegTest1\r
34         .global vRegTest2\r
35 \r
36 /* Reg test macro helper. Test a register for a known value branching to\r
37 error_loop if not correct otherwise continuing on */\r
38 .macro  portREG_TEST work_reg, test_reg, test_value\r
39         .set    micromips\r
40         .set    noreorder\r
41         .set    noat\r
42 \r
43         /* Check each register maintains the value assigned to it for the lifetime\r
44         of the task. */\r
45         addiu   \work_reg, $0, 0x00\r
46         addiu   \work_reg, \test_reg, -\test_value\r
47         beq             \work_reg, $0, 1f\r
48         nop\r
49         /* The register value was not that expected.  Jump to the error loop so the\r
50         cycle counter stops incrementing. */\r
51         b       error_loop\r
52         nop\r
53 1:\r
54         .endm\r
55 \r
56 \r
57         .set    micromips\r
58         .set    noreorder\r
59         .set    noat\r
60         .ent    error_loop\r
61 \r
62 /* Reg test tasks call the error loop when they find an error.  Sitting in the\r
63 tight error loop prevents them incrementing their ulRegTestnCycles counter, and\r
64 so allows the check softwate timer to know an error has been found. */\r
65 error_loop:\r
66         b       error_loop\r
67         nop\r
68 \r
69         .end error_loop\r
70 \r
71 \r
72         .set    micromips\r
73         .set    noreorder\r
74         .set    noat\r
75         .ent    vRegTest1\r
76 \r
77 vRegTest1:\r
78         /* Fill the registers with known values. */\r
79         addiu   $1, $0, 0x11\r
80         addiu   $2, $0, 0x12\r
81         addiu   $3, $0, 0x13\r
82         /* $4 contains the address of the loop counter - don't mess with $4. */\r
83         addiu   $5, $0, 0x15\r
84         addiu   $6, $0, 0x16\r
85         addiu   $7, $0, 0x17\r
86         addiu   $8, $0, 0x18\r
87         addiu   $9, $0, 0x19\r
88         addiu   $10, $0, 0x110\r
89         addiu   $11, $0, 0x111\r
90         addiu   $12, $0, 0x112\r
91         addiu   $13, $0, 0x113\r
92         addiu   $14, $0, 0x114\r
93         addiu   $15, $0, 0x115\r
94         addiu   $16, $0, 0x116\r
95         addiu   $17, $0, 0x117\r
96         addiu   $18, $0, 0x118\r
97         addiu   $19, $0, 0x119\r
98         addiu   $20, $0, 0x120\r
99         addiu   $21, $0, 0x121\r
100         addiu   $23, $0, 0x123\r
101         addiu   $24, $0, 0x124\r
102         addiu   $25, $0, 0x125\r
103         addiu   $30, $0, 0x130\r
104         addiu   $22, $0, 0x131\r
105 \r
106 vRegTest1Loop:\r
107         portREG_TEST    $22, $1, 0x11\r
108         portREG_TEST    $22, $2, 0x12\r
109         portREG_TEST    $22, $3, 0x13\r
110         portREG_TEST    $22, $5, 0x15\r
111         portREG_TEST    $22, $6, 0x16\r
112         portREG_TEST    $22, $7, 0x17\r
113         portREG_TEST    $22, $8, 0x18\r
114         portREG_TEST    $22, $9, 0x19\r
115         portREG_TEST    $22, $10, 0x110\r
116         portREG_TEST    $22, $11, 0x111\r
117         portREG_TEST    $22, $12, 0x112\r
118         portREG_TEST    $22, $13, 0x113\r
119         portREG_TEST    $22, $14, 0x114\r
120         portREG_TEST    $22, $15, 0x115\r
121         portREG_TEST    $22, $16, 0x116\r
122         portREG_TEST    $22, $17, 0x117\r
123         portREG_TEST    $22, $18, 0x118\r
124         portREG_TEST    $22, $19, 0x119\r
125         portREG_TEST    $22, $20, 0x120\r
126         portREG_TEST    $22, $21, 0x121\r
127         portREG_TEST    $22, $23, 0x123\r
128         portREG_TEST    $22, $24, 0x124\r
129         portREG_TEST    $22, $25, 0x125\r
130         portREG_TEST    $22, $30, 0x130\r
131 \r
132         /* No errors detected.  Increment the loop count so the check timer knows\r
133         this task is still running without error, then loop back to do it all\r
134         again.  The address of the loop counter is in $4. */\r
135         lw              $22, 0( $4 )\r
136         addiu   $22, $22, 0x01\r
137         sw              $22, 0( $4 )\r
138         b               vRegTest1Loop\r
139         nop\r
140 \r
141         .end    vRegTest1\r
142 \r
143 \r
144         .set    micromips\r
145         .set    noreorder\r
146         .set    noat\r
147         .ent    vRegTest2\r
148 \r
149 vRegTest2:\r
150         addiu   $1, $0, 0x21\r
151         addiu   $2, $0, 0x22\r
152         addiu   $3, $0, 0x23\r
153         /* $4 contains the address of the loop counter - don't mess with $4. */\r
154         addiu   $5, $0, 0x25\r
155         addiu   $6, $0, 0x26\r
156         addiu   $7, $0, 0x27\r
157         addiu   $8, $0, 0x28\r
158         addiu   $9, $0, 0x29\r
159         addiu   $10, $0, 0x210\r
160         addiu   $11, $0, 0x211\r
161         addiu   $12, $0, 0x212\r
162         addiu   $13, $0, 0x213\r
163         addiu   $14, $0, 0x214\r
164         addiu   $15, $0, 0x215\r
165         addiu   $16, $0, 0x216\r
166         addiu   $17, $0, 0x217\r
167         addiu   $18, $0, 0x218\r
168         addiu   $19, $0, 0x219\r
169         addiu   $20, $0, 0x220\r
170         addiu   $21, $0, 0x221\r
171         addiu   $23, $0, 0x223\r
172         addiu   $24, $0, 0x224\r
173         addiu   $25, $0, 0x225\r
174         addiu   $30, $0, 0x230\r
175         addiu   $22, $0, 0x231\r
176 \r
177 vRegTest2Loop:\r
178         portREG_TEST    $22, $1, 0x21\r
179         portREG_TEST    $22, $2, 0x22\r
180         portREG_TEST    $22, $3, 0x23\r
181         portREG_TEST    $22, $5, 0x25\r
182         portREG_TEST    $22, $6, 0x26\r
183         portREG_TEST    $22, $7, 0x27\r
184         portREG_TEST    $22, $8, 0x28\r
185         portREG_TEST    $22, $9, 0x29\r
186         portREG_TEST    $22, $10, 0x210\r
187         portREG_TEST    $22, $11, 0x211\r
188         portREG_TEST    $22, $12, 0x212\r
189         portREG_TEST    $22, $13, 0x213\r
190         portREG_TEST    $22, $14, 0x214\r
191         portREG_TEST    $22, $15, 0x215\r
192         portREG_TEST    $22, $16, 0x216\r
193         portREG_TEST    $22, $17, 0x217\r
194         portREG_TEST    $22, $18, 0x218\r
195         portREG_TEST    $22, $19, 0x219\r
196         portREG_TEST    $22, $20, 0x220\r
197         portREG_TEST    $22, $21, 0x221\r
198         portREG_TEST    $22, $23, 0x223\r
199         portREG_TEST    $22, $24, 0x224\r
200         portREG_TEST    $22, $25, 0x225\r
201         portREG_TEST    $22, $30, 0x230\r
202 \r
203         /* No errors detected.  Increment the loop count so the check timer knows\r
204         this task is still running without error, then loop back to do it all\r
205         again.  The address of the loop counter is in $4. */\r
206         lw              $22, 0( $4 )\r
207         addiu   $22, $22, 0x01\r
208         sw              $22, 0( $4 )\r
209         b               vRegTest2Loop\r
210         nop\r
211 \r
212         .end    vRegTest2\r
213 \r
214 \r
215 \r