]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/PIC32MEC14xx_MPLAB/src/Full_Demo/RegisterTestTasks.S
Add PIC32MEC14xx port and demo application.
[freertos] / FreeRTOS / Demo / PIC32MEC14xx_MPLAB / src / Full_Demo / RegisterTestTasks.S
1 /*\r
2     FreeRTOS V8.2.2 - Copyright (C) 2015 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     This file is part of the FreeRTOS distribution.\r
8 \r
9     FreeRTOS is free software; you can redistribute it and/or modify it under\r
10     the terms of the GNU General Public License (version 2) as published by the\r
11     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
12 \r
13     ***************************************************************************\r
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
16     >>!   obliged to provide the source code for proprietary components     !<<\r
17     >>!   outside of the FreeRTOS kernel.                                   !<<\r
18     ***************************************************************************\r
19 \r
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
23     link: http://www.freertos.org/a00114.html\r
24 \r
25     ***************************************************************************\r
26      *                                                                       *\r
27      *    FreeRTOS provides completely free yet professionally developed,    *\r
28      *    robust, strictly quality controlled, supported, and cross          *\r
29      *    platform software that is more than just the market leader, it     *\r
30      *    is the industry's de facto standard.                               *\r
31      *                                                                       *\r
32      *    Help yourself get started quickly while simultaneously helping     *\r
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
34      *    tutorial book, reference manual, or both:                          *\r
35      *    http://www.FreeRTOS.org/Documentation                              *\r
36      *                                                                       *\r
37     ***************************************************************************\r
38 \r
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
40     the FAQ page "My application does not run, what could be wrong?".  Have you\r
41     defined configASSERT()?\r
42 \r
43     http://www.FreeRTOS.org/support - In return for receiving this top quality\r
44     embedded software for free we request you assist our global community by\r
45     participating in the support forum.\r
46 \r
47     http://www.FreeRTOS.org/training - Investing in training allows your team to\r
48     be as productive as possible as early as possible.  Now you can receive\r
49     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
50     Ltd, and the world's leading authority on the world's leading RTOS.\r
51 \r
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
55 \r
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
58 \r
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
61     licenses offer ticketed support, indemnification and commercial middleware.\r
62 \r
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
64     engineered and independently SIL3 certified version for use in safety and\r
65     mission critical applications that require provable dependability.\r
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69 \r
70 \r
71 #include <xc.h>\r
72 #include <sys/asm.h>\r
73 \r
74 \r
75         .global vRegTest1\r
76         .global vRegTest2\r
77 \r
78 /* Reg test macro helper. Test a register for a known value branching to\r
79 error_loop if not correct otherwise continuing on */\r
80 .macro  portREG_TEST work_reg, test_reg, test_value\r
81         .set    micromips\r
82         .set    noreorder\r
83         .set    noat\r
84 \r
85         /* Check each register maintains the value assigned to it for the lifetime\r
86         of the task. */\r
87         addiu   \work_reg, $0, 0x00\r
88         addiu   \work_reg, \test_reg, -\test_value\r
89         beq             \work_reg, $0, 1f\r
90         nop\r
91         /* The register value was not that expected.  Jump to the error loop so the\r
92         cycle counter stops incrementing. */\r
93         b       error_loop\r
94         nop\r
95 1:\r
96         .endm\r
97 \r
98 \r
99         .set    micromips\r
100         .set    noreorder\r
101         .set    noat\r
102         .ent    error_loop\r
103 \r
104 /* Reg test tasks call the error loop when they find an error.  Sitting in the\r
105 tight error loop prevents them incrementing their ulRegTestnCycles counter, and\r
106 so allows the check softwate timer to know an error has been found. */\r
107 error_loop:\r
108         b       error_loop\r
109         nop\r
110 \r
111         .end error_loop\r
112 \r
113 \r
114         .set    micromips\r
115         .set    noreorder\r
116         .set    noat\r
117         .ent    vRegTest1\r
118 \r
119 vRegTest1:\r
120         /* Fill the registers with known values. */\r
121         addiu   $1, $0, 0x11\r
122         addiu   $2, $0, 0x12\r
123         addiu   $3, $0, 0x13\r
124         /* $4 contains the address of the loop counter - don't mess with $4. */\r
125         addiu   $5, $0, 0x15\r
126         addiu   $6, $0, 0x16\r
127         addiu   $7, $0, 0x17\r
128         addiu   $8, $0, 0x18\r
129         addiu   $9, $0, 0x19\r
130         addiu   $10, $0, 0x110\r
131         addiu   $11, $0, 0x111\r
132         addiu   $12, $0, 0x112\r
133         addiu   $13, $0, 0x113\r
134         addiu   $14, $0, 0x114\r
135         addiu   $15, $0, 0x115\r
136         addiu   $16, $0, 0x116\r
137         addiu   $17, $0, 0x117\r
138         addiu   $18, $0, 0x118\r
139         addiu   $19, $0, 0x119\r
140         addiu   $20, $0, 0x120\r
141         addiu   $21, $0, 0x121\r
142         addiu   $23, $0, 0x123\r
143         addiu   $24, $0, 0x124\r
144         addiu   $25, $0, 0x125\r
145         addiu   $30, $0, 0x130\r
146         addiu   $22, $0, 0x131\r
147 \r
148 vRegTest1Loop:\r
149         portREG_TEST    $22, $1, 0x11\r
150         portREG_TEST    $22, $2, 0x12\r
151         portREG_TEST    $22, $3, 0x13\r
152         portREG_TEST    $22, $5, 0x15\r
153         portREG_TEST    $22, $6, 0x16\r
154         portREG_TEST    $22, $7, 0x17\r
155         portREG_TEST    $22, $8, 0x18\r
156         portREG_TEST    $22, $9, 0x19\r
157         portREG_TEST    $22, $10, 0x110\r
158         portREG_TEST    $22, $11, 0x111\r
159         portREG_TEST    $22, $12, 0x112\r
160         portREG_TEST    $22, $13, 0x113\r
161         portREG_TEST    $22, $14, 0x114\r
162         portREG_TEST    $22, $15, 0x115\r
163         portREG_TEST    $22, $16, 0x116\r
164         portREG_TEST    $22, $17, 0x117\r
165         portREG_TEST    $22, $18, 0x118\r
166         portREG_TEST    $22, $19, 0x119\r
167         portREG_TEST    $22, $20, 0x120\r
168         portREG_TEST    $22, $21, 0x121\r
169         portREG_TEST    $22, $23, 0x123\r
170         portREG_TEST    $22, $24, 0x124\r
171         portREG_TEST    $22, $25, 0x125\r
172         portREG_TEST    $22, $30, 0x130\r
173 \r
174         /* No errors detected.  Increment the loop count so the check timer knows\r
175         this task is still running without error, then loop back to do it all\r
176         again.  The address of the loop counter is in $4. */\r
177         lw              $22, 0( $4 )\r
178         addiu   $22, $22, 0x01\r
179         sw              $22, 0( $4 )\r
180         b               vRegTest1Loop\r
181         nop\r
182 \r
183         .end    vRegTest1\r
184 \r
185 \r
186         .set    micromips\r
187         .set    noreorder\r
188         .set    noat\r
189         .ent    vRegTest2\r
190 \r
191 vRegTest2:\r
192         addiu   $1, $0, 0x21\r
193         addiu   $2, $0, 0x22\r
194         addiu   $3, $0, 0x23\r
195         /* $4 contains the address of the loop counter - don't mess with $4. */\r
196         addiu   $5, $0, 0x25\r
197         addiu   $6, $0, 0x26\r
198         addiu   $7, $0, 0x27\r
199         addiu   $8, $0, 0x28\r
200         addiu   $9, $0, 0x29\r
201         addiu   $10, $0, 0x210\r
202         addiu   $11, $0, 0x211\r
203         addiu   $12, $0, 0x212\r
204         addiu   $13, $0, 0x213\r
205         addiu   $14, $0, 0x214\r
206         addiu   $15, $0, 0x215\r
207         addiu   $16, $0, 0x216\r
208         addiu   $17, $0, 0x217\r
209         addiu   $18, $0, 0x218\r
210         addiu   $19, $0, 0x219\r
211         addiu   $20, $0, 0x220\r
212         addiu   $21, $0, 0x221\r
213         addiu   $23, $0, 0x223\r
214         addiu   $24, $0, 0x224\r
215         addiu   $25, $0, 0x225\r
216         addiu   $30, $0, 0x230\r
217         addiu   $22, $0, 0x231\r
218 \r
219 vRegTest2Loop:\r
220         portREG_TEST    $22, $1, 0x21\r
221         portREG_TEST    $22, $2, 0x22\r
222         portREG_TEST    $22, $3, 0x23\r
223         portREG_TEST    $22, $5, 0x25\r
224         portREG_TEST    $22, $6, 0x26\r
225         portREG_TEST    $22, $7, 0x27\r
226         portREG_TEST    $22, $8, 0x28\r
227         portREG_TEST    $22, $9, 0x29\r
228         portREG_TEST    $22, $10, 0x210\r
229         portREG_TEST    $22, $11, 0x211\r
230         portREG_TEST    $22, $12, 0x212\r
231         portREG_TEST    $22, $13, 0x213\r
232         portREG_TEST    $22, $14, 0x214\r
233         portREG_TEST    $22, $15, 0x215\r
234         portREG_TEST    $22, $16, 0x216\r
235         portREG_TEST    $22, $17, 0x217\r
236         portREG_TEST    $22, $18, 0x218\r
237         portREG_TEST    $22, $19, 0x219\r
238         portREG_TEST    $22, $20, 0x220\r
239         portREG_TEST    $22, $21, 0x221\r
240         portREG_TEST    $22, $23, 0x223\r
241         portREG_TEST    $22, $24, 0x224\r
242         portREG_TEST    $22, $25, 0x225\r
243         portREG_TEST    $22, $30, 0x230\r
244 \r
245         /* No errors detected.  Increment the loop count so the check timer knows\r
246         this task is still running without error, then loop back to do it all\r
247         again.  The address of the loop counter is in $4. */\r
248         lw              $22, 0( $4 )\r
249         addiu   $22, $22, 0x01\r
250         sw              $22, 0( $4 )\r
251         b               vRegTest2Loop\r
252         nop\r
253 \r
254         .end    vRegTest2\r
255 \r
256 \r
257 \r