1 |
584 |
jeremybenn |
/*
|
2 |
|
|
FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
|
3 |
|
|
|
4 |
|
|
***************************************************************************
|
5 |
|
|
* *
|
6 |
|
|
* If you are: *
|
7 |
|
|
* *
|
8 |
|
|
* + New to FreeRTOS, *
|
9 |
|
|
* + Wanting to learn FreeRTOS or multitasking in general quickly *
|
10 |
|
|
* + Looking for basic training, *
|
11 |
|
|
* + Wanting to improve your FreeRTOS skills and productivity *
|
12 |
|
|
* *
|
13 |
|
|
* then take a look at the FreeRTOS books - available as PDF or paperback *
|
14 |
|
|
* *
|
15 |
|
|
* "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
|
16 |
|
|
* http://www.FreeRTOS.org/Documentation *
|
17 |
|
|
* *
|
18 |
|
|
* A pdf reference manual is also available. Both are usually delivered *
|
19 |
|
|
* to your inbox within 20 minutes to two hours when purchased between 8am *
|
20 |
|
|
* and 8pm GMT (although please allow up to 24 hours in case of *
|
21 |
|
|
* exceptional circumstances). Thank you for your support! *
|
22 |
|
|
* *
|
23 |
|
|
***************************************************************************
|
24 |
|
|
|
25 |
|
|
This file is part of the FreeRTOS distribution.
|
26 |
|
|
|
27 |
|
|
FreeRTOS is free software; you can redistribute it and/or modify it under
|
28 |
|
|
the terms of the GNU General Public License (version 2) as published by the
|
29 |
|
|
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
30 |
|
|
***NOTE*** The exception to the GPL is included to allow you to distribute
|
31 |
|
|
a combined work that includes FreeRTOS without being obliged to provide the
|
32 |
|
|
source code for proprietary components outside of the FreeRTOS kernel.
|
33 |
|
|
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
34 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
35 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
36 |
|
|
more details. You should have received a copy of the GNU General Public
|
37 |
|
|
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
38 |
|
|
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
39 |
|
|
by writing to Richard Barry, contact details for whom are available on the
|
40 |
|
|
FreeRTOS WEB site.
|
41 |
|
|
|
42 |
|
|
1 tab == 4 spaces!
|
43 |
|
|
|
44 |
|
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
45 |
|
|
contact details.
|
46 |
|
|
|
47 |
|
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
48 |
|
|
critical systems.
|
49 |
|
|
|
50 |
|
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
51 |
|
|
licensing and training services.
|
52 |
|
|
*/
|
53 |
|
|
|
54 |
|
|
/*
|
55 |
|
|
* Creates all the demo application tasks, then starts the scheduler.
|
56 |
|
|
* In addition to the standard demo tasks, the following tasks and tests are
|
57 |
|
|
* defined and/or created within this file:
|
58 |
|
|
*
|
59 |
|
|
* "Check" task - This only executes every five seconds but has the highest
|
60 |
|
|
* priority so is guaranteed to get processor time. Its main function is to
|
61 |
|
|
* check that all the standard demo tasks are still operational. The check
|
62 |
|
|
* task will write an error message to the console should an error be detected
|
63 |
|
|
* within any of the demo tasks. The check task also toggles the LED defined
|
64 |
|
|
* by mainCHECK_LED every 5 seconds while the system is error free, with the
|
65 |
|
|
* toggle rate increasing to every 500ms should an error occur.
|
66 |
|
|
*
|
67 |
|
|
* "Reg test" tasks - These fill the registers with known values, then check
|
68 |
|
|
* that each register still contains its expected value. Each task uses
|
69 |
|
|
* different values. The tasks run with very low priority so get preempted very
|
70 |
|
|
* frequently. A register containing an unexpected value is indicative of an
|
71 |
|
|
* error in the context switching mechanism.
|
72 |
|
|
*
|
73 |
|
|
* See the online documentation for this demo for more information on interrupt
|
74 |
|
|
* usage.
|
75 |
|
|
*/
|
76 |
|
|
|
77 |
|
|
/* Standard includes. */
|
78 |
|
|
#include <stddef.h>
|
79 |
|
|
#include <stdio.h>
|
80 |
|
|
#include <string.h>
|
81 |
|
|
|
82 |
|
|
/* Scheduler includes. */
|
83 |
|
|
#include "FreeRTOS.h"
|
84 |
|
|
#include "task.h"
|
85 |
|
|
#include "queue.h"
|
86 |
|
|
|
87 |
|
|
/* Demo application includes. */
|
88 |
|
|
#include "partest.h"
|
89 |
|
|
#include "flash.h"
|
90 |
|
|
#include "blocktim.h"
|
91 |
|
|
#include "semtest.h"
|
92 |
|
|
#include "serial.h"
|
93 |
|
|
#include "comtest.h"
|
94 |
|
|
#include "GenQTest.h"
|
95 |
|
|
#include "QPeek.h"
|
96 |
|
|
#include "integer.h"
|
97 |
|
|
#include "PollQ.h"
|
98 |
|
|
#include "BlockQ.h"
|
99 |
|
|
#include "dynamic.h"
|
100 |
|
|
#include "countsem.h"
|
101 |
|
|
#include "recmutex.h"
|
102 |
|
|
#include "death.h"
|
103 |
|
|
|
104 |
|
|
/*-----------------------------------------------------------*/
|
105 |
|
|
|
106 |
|
|
#error The batch file Demo\NiosII_CycloneIII_DBC3C40_GCC\CreateProjectDirectoryStructure.bat must be executed before the project is imported into the workspace. Failure to do this will result in the include paths stored in the project being deleted. Remove this line after CreateProjectDirectoryStructure.bat has been executed.
|
107 |
|
|
|
108 |
|
|
/*-----------------------------------------------------------*/
|
109 |
|
|
|
110 |
|
|
/* The rate at which the LED controlled by the 'check' task will toggle when no
|
111 |
|
|
errors have been detected. */
|
112 |
|
|
#define mainNO_ERROR_PERIOD ( 5000 )
|
113 |
|
|
|
114 |
|
|
/* The rate at which the LED controlled by the 'check' task will toggle when an
|
115 |
|
|
error has been detected. */
|
116 |
|
|
#define mainERROR_PERIOD ( 500 )
|
117 |
|
|
|
118 |
|
|
/* The LED toggled by the Check task. */
|
119 |
|
|
#define mainCHECK_LED ( 7 )
|
120 |
|
|
|
121 |
|
|
/* The first LED used by the ComTest tasks. One LED toggles each time a
|
122 |
|
|
character is transmitted, and one each time a character is received and
|
123 |
|
|
verified as being the expected character. */
|
124 |
|
|
#define mainCOMTEST_LED ( 4 )
|
125 |
|
|
|
126 |
|
|
/* Priority definitions for the tasks in the demo application. */
|
127 |
|
|
#define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
128 |
|
|
#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
129 |
|
|
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
|
130 |
|
|
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
131 |
|
|
#define mainQUEUE_BLOCK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
132 |
|
|
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
133 |
|
|
#define mainSEMAPHORE_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
|
134 |
|
|
#define mainGENERIC_QUEUE_PRIORITY ( tskIDLE_PRIORITY )
|
135 |
|
|
#define mainREG_TEST_PRIORITY ( tskIDLE_PRIORITY )
|
136 |
|
|
|
137 |
|
|
/* Misc. */
|
138 |
|
|
#define mainDONT_WAIT ( 0 )
|
139 |
|
|
|
140 |
|
|
/* The parameters passed to the reg test tasks. This is just done to check
|
141 |
|
|
the parameter passing mechanism is working correctly. */
|
142 |
|
|
#define mainREG_TEST_1_PARAMETER ( ( void * ) 0x12345678 )
|
143 |
|
|
#define mainREG_TEST_2_PARAMETER ( ( void * ) 0x87654321 )
|
144 |
|
|
|
145 |
|
|
/*-----------------------------------------------------------*/
|
146 |
|
|
|
147 |
|
|
/*
|
148 |
|
|
* Setup the processor ready for the demo.
|
149 |
|
|
*/
|
150 |
|
|
static void prvSetupHardware( void );
|
151 |
|
|
|
152 |
|
|
/*
|
153 |
|
|
* Execute all of the check functions to ensure the tests haven't failed.
|
154 |
|
|
*/
|
155 |
|
|
static void prvCheckTask( void *pvParameters );
|
156 |
|
|
|
157 |
|
|
/*
|
158 |
|
|
* The register test (or RegTest) tasks as described at the top of this file.
|
159 |
|
|
*/
|
160 |
|
|
static void prvFirstRegTestTask( void *pvParameters );
|
161 |
|
|
static void prvSecondRegTestTask( void *pvParameters );
|
162 |
|
|
|
163 |
|
|
/*-----------------------------------------------------------*/
|
164 |
|
|
|
165 |
|
|
/* Counters that are incremented on each iteration of the RegTest tasks
|
166 |
|
|
so long as no errors have been detected. */
|
167 |
|
|
volatile unsigned long ulRegTest1Counter = 0UL, ulRegTest2Counter = 0UL;
|
168 |
|
|
|
169 |
|
|
/*-----------------------------------------------------------*/
|
170 |
|
|
|
171 |
|
|
/*
|
172 |
|
|
* Create the demo tasks then start the scheduler.
|
173 |
|
|
*/
|
174 |
|
|
int main( void )
|
175 |
|
|
{
|
176 |
|
|
/* Configure any hardware required for this demo. */
|
177 |
|
|
prvSetupHardware();
|
178 |
|
|
|
179 |
|
|
/* Create all the other standard demo tasks. These serve no purpose other
|
180 |
|
|
than to test the port and demonstrate the use of the FreeRTOS API. */
|
181 |
|
|
vStartLEDFlashTasks( tskIDLE_PRIORITY );
|
182 |
|
|
vStartIntegerMathTasks( mainGENERIC_QUEUE_PRIORITY );
|
183 |
|
|
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
|
184 |
|
|
vStartBlockingQueueTasks( mainQUEUE_BLOCK_PRIORITY );
|
185 |
|
|
vCreateBlockTimeTasks();
|
186 |
|
|
vStartSemaphoreTasks( mainSEMAPHORE_TASK_PRIORITY );
|
187 |
|
|
vStartDynamicPriorityTasks();
|
188 |
|
|
vStartQueuePeekTasks();
|
189 |
|
|
vStartGenericQueueTasks( mainGENERIC_QUEUE_PRIORITY );
|
190 |
|
|
vStartCountingSemaphoreTasks();
|
191 |
|
|
vStartRecursiveMutexTasks();
|
192 |
|
|
vAltStartComTestTasks( mainCOM_TEST_PRIORITY, 0, mainCOMTEST_LED );
|
193 |
|
|
|
194 |
|
|
/* prvCheckTask uses sprintf so requires more stack. */
|
195 |
|
|
xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
|
196 |
|
|
|
197 |
|
|
/* The RegTest tasks as described at the top of this file. */
|
198 |
|
|
xTaskCreate( prvFirstRegTestTask, "Rreg1", configMINIMAL_STACK_SIZE, mainREG_TEST_1_PARAMETER, mainREG_TEST_PRIORITY, NULL );
|
199 |
|
|
xTaskCreate( prvSecondRegTestTask, "Rreg2", configMINIMAL_STACK_SIZE, mainREG_TEST_2_PARAMETER, mainREG_TEST_PRIORITY, NULL );
|
200 |
|
|
|
201 |
|
|
/* This task has to be created last as it keeps account of the number of tasks
|
202 |
|
|
it expects to see running. */
|
203 |
|
|
vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
|
204 |
|
|
|
205 |
|
|
/* Finally start the scheduler. */
|
206 |
|
|
vTaskStartScheduler();
|
207 |
|
|
|
208 |
|
|
/* Will only reach here if there is insufficient heap available to start
|
209 |
|
|
the scheduler. */
|
210 |
|
|
for( ;; );
|
211 |
|
|
}
|
212 |
|
|
/*-----------------------------------------------------------*/
|
213 |
|
|
|
214 |
|
|
static void prvSetupHardware( void )
|
215 |
|
|
{
|
216 |
|
|
/* Setup the digital IO for the LED's. */
|
217 |
|
|
vParTestInitialise();
|
218 |
|
|
}
|
219 |
|
|
/*-----------------------------------------------------------*/
|
220 |
|
|
|
221 |
|
|
void vApplicationStackOverflowHook( void )
|
222 |
|
|
{
|
223 |
|
|
/* Look at pxCurrentTCB to see which task overflowed its stack. */
|
224 |
|
|
for( ;; )
|
225 |
|
|
{
|
226 |
|
|
asm( "break" );
|
227 |
|
|
}
|
228 |
|
|
}
|
229 |
|
|
/*-----------------------------------------------------------*/
|
230 |
|
|
|
231 |
|
|
void _general_exception_handler( unsigned long ulCause, unsigned long ulStatus )
|
232 |
|
|
{
|
233 |
|
|
/* This overrides the definition provided by the kernel. Other exceptions
|
234 |
|
|
should be handled here. */
|
235 |
|
|
for( ;; )
|
236 |
|
|
{
|
237 |
|
|
asm( "break" );
|
238 |
|
|
}
|
239 |
|
|
}
|
240 |
|
|
/*-----------------------------------------------------------*/
|
241 |
|
|
|
242 |
|
|
static void prvCheckTask( void *pvParameters )
|
243 |
|
|
{
|
244 |
|
|
portTickType xLastExecutionTime, ulTicksToWait = mainNO_ERROR_PERIOD;
|
245 |
|
|
unsigned long ulLastRegTest1 = 0UL, ulLastRegTest2 = 0UL;
|
246 |
|
|
const char * pcMessage;
|
247 |
|
|
|
248 |
|
|
/* Initialise the variable used to control our iteration rate prior to
|
249 |
|
|
its first use. */
|
250 |
|
|
xLastExecutionTime = xTaskGetTickCount();
|
251 |
|
|
|
252 |
|
|
for( ;; )
|
253 |
|
|
{
|
254 |
|
|
/* Wait until it is time to run the tests again. */
|
255 |
|
|
vTaskDelayUntil( &xLastExecutionTime, ulTicksToWait );
|
256 |
|
|
|
257 |
|
|
/* Have any of the standard demo tasks detected an error in their
|
258 |
|
|
operation? */
|
259 |
|
|
if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
|
260 |
|
|
{
|
261 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
262 |
|
|
pcMessage = "Error: Integer Maths.\n";
|
263 |
|
|
}
|
264 |
|
|
else if( xAreGenericQueueTasksStillRunning() != pdTRUE )
|
265 |
|
|
{
|
266 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
267 |
|
|
pcMessage = "Error: GenQ.\n";
|
268 |
|
|
}
|
269 |
|
|
else if( xAreBlockingQueuesStillRunning() != pdTRUE )
|
270 |
|
|
{
|
271 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
272 |
|
|
pcMessage = "Error: BlockQ.\n";
|
273 |
|
|
}
|
274 |
|
|
else if( xArePollingQueuesStillRunning() != pdTRUE )
|
275 |
|
|
{
|
276 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
277 |
|
|
pcMessage = "Error: PollQ.\n";
|
278 |
|
|
}
|
279 |
|
|
else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
|
280 |
|
|
{
|
281 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
282 |
|
|
pcMessage = "Error: PeekQ.\n";
|
283 |
|
|
}
|
284 |
|
|
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
|
285 |
|
|
{
|
286 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
287 |
|
|
pcMessage = "Error: Block Time.\n";
|
288 |
|
|
}
|
289 |
|
|
else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
|
290 |
|
|
{
|
291 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
292 |
|
|
pcMessage = "Error: Semaphore Test.\n";
|
293 |
|
|
}
|
294 |
|
|
else if( xAreComTestTasksStillRunning() != pdTRUE )
|
295 |
|
|
{
|
296 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
297 |
|
|
pcMessage = "Error: Comm Test.\n";
|
298 |
|
|
}
|
299 |
|
|
else if( xIsCreateTaskStillRunning() != pdTRUE )
|
300 |
|
|
{
|
301 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
302 |
|
|
pcMessage = "Error: Suicidal Tasks.\n";
|
303 |
|
|
}
|
304 |
|
|
else if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
|
305 |
|
|
{
|
306 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
307 |
|
|
pcMessage = "Error: Dynamic Priority.\n";
|
308 |
|
|
}
|
309 |
|
|
else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
|
310 |
|
|
{
|
311 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
312 |
|
|
pcMessage = "Error: Count Semaphore.\n";
|
313 |
|
|
}
|
314 |
|
|
else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
|
315 |
|
|
{
|
316 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
317 |
|
|
pcMessage = "Error: Recursive Mutex.\n";
|
318 |
|
|
}
|
319 |
|
|
else if( ulLastRegTest1 == ulRegTest1Counter )
|
320 |
|
|
{
|
321 |
|
|
/* ulRegTest1Counter is no longer being incremented, indicating
|
322 |
|
|
that an error has been discovered in prvFirstRegTestTask(). */
|
323 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
324 |
|
|
pcMessage = "Error: Reg Test1.\n";
|
325 |
|
|
}
|
326 |
|
|
else if( ulLastRegTest2 == ulRegTest2Counter )
|
327 |
|
|
{
|
328 |
|
|
/* ulRegTest2Counter is no longer being incremented, indicating
|
329 |
|
|
that an error has been discovered in prvSecondRegTestTask(). */
|
330 |
|
|
ulTicksToWait = mainERROR_PERIOD;
|
331 |
|
|
pcMessage = "Error: Reg Test2.\n";
|
332 |
|
|
}
|
333 |
|
|
else
|
334 |
|
|
{
|
335 |
|
|
pcMessage = NULL;
|
336 |
|
|
}
|
337 |
|
|
|
338 |
|
|
/* Remember the counter values this time around so a counter failing
|
339 |
|
|
to be incremented correctly can be spotted. */
|
340 |
|
|
ulLastRegTest1 = ulRegTest1Counter;
|
341 |
|
|
ulLastRegTest2 = ulRegTest2Counter;
|
342 |
|
|
|
343 |
|
|
/* Print out an error message if there is one. Mutual exclusion is
|
344 |
|
|
not used as this is the only task accessing stdout. */
|
345 |
|
|
if( pcMessage != NULL )
|
346 |
|
|
{
|
347 |
|
|
printf( pcMessage );
|
348 |
|
|
}
|
349 |
|
|
|
350 |
|
|
/* Provide visual feedback of the system status. If the LED is toggled
|
351 |
|
|
every 5 seconds then no errors have been found. If the LED is toggled
|
352 |
|
|
every 500ms then at least one error has been found. */
|
353 |
|
|
vParTestToggleLED( mainCHECK_LED );
|
354 |
|
|
}
|
355 |
|
|
}
|
356 |
|
|
/*-----------------------------------------------------------*/
|
357 |
|
|
|
358 |
|
|
static void prvFirstRegTestTask( void *pvParameters )
|
359 |
|
|
{
|
360 |
|
|
/* Check the parameters are passed in as expected. */
|
361 |
|
|
if( pvParameters != mainREG_TEST_1_PARAMETER )
|
362 |
|
|
{
|
363 |
|
|
/* Don't execute any further so an error is recognised by the check
|
364 |
|
|
task. */
|
365 |
|
|
vTaskDelete( NULL );
|
366 |
|
|
}
|
367 |
|
|
|
368 |
|
|
/* Fill registers with known values, then check that each register still
|
369 |
|
|
contains its expected value. An incorrect value is indicative of an error
|
370 |
|
|
in the context switching process.
|
371 |
|
|
|
372 |
|
|
If no errors are found ulRegTest1Counter is incremented. The check task
|
373 |
|
|
will recognise an error if ulRegTest1Counter stops being incremented.
|
374 |
|
|
This task also performs a manual yield in the middle of its execution, just
|
375 |
|
|
to increase the test coverage. */
|
376 |
|
|
asm volatile (
|
377 |
|
|
" .extern ulRegTest1Counter \n" \
|
378 |
|
|
" \n" \
|
379 |
|
|
" addi r3, r0, 3 \n" \
|
380 |
|
|
" addi r4, r0, 4 \n" \
|
381 |
|
|
" addi r5, r0, 5 \n" \
|
382 |
|
|
" addi r6, r0, 6 \n" \
|
383 |
|
|
" addi r7, r0, 7 \n" \
|
384 |
|
|
" addi r8, r0, 8 \n" \
|
385 |
|
|
" addi r9, r0, 9 \n" \
|
386 |
|
|
" addi r10, r0, 10 \n" \
|
387 |
|
|
" addi r11, r0, 11 \n" \
|
388 |
|
|
" addi r12, r0, 12 \n" \
|
389 |
|
|
" addi r13, r0, 13 \n" \
|
390 |
|
|
" addi r14, r0, 14 \n" \
|
391 |
|
|
" addi r15, r0, 15 \n" \
|
392 |
|
|
" addi r16, r0, 16 \n" \
|
393 |
|
|
" addi r17, r0, 17 \n" \
|
394 |
|
|
" addi r18, r0, 18 \n" \
|
395 |
|
|
" addi r19, r0, 19 \n" \
|
396 |
|
|
" addi r20, r0, 20 \n" \
|
397 |
|
|
" addi r21, r0, 21 \n" \
|
398 |
|
|
" addi r22, r0, 22 \n" \
|
399 |
|
|
" addi r23, r0, 23 \n" \
|
400 |
|
|
" addi r28, r0, 28 \n" \
|
401 |
|
|
" addi r31, r0, 31 \n" \
|
402 |
|
|
"RegTest1: \n" \
|
403 |
|
|
" addi r2, r0, 0 \n" \
|
404 |
|
|
" trap \n" \
|
405 |
|
|
" bne r2, r0, RegTest1Error \n" \
|
406 |
|
|
" addi r2, r0, 3 \n" \
|
407 |
|
|
" bne r2, r3, RegTest1Error \n" \
|
408 |
|
|
" addi r2, r0, 4 \n" \
|
409 |
|
|
" bne r2, r4, RegTest1Error \n" \
|
410 |
|
|
" addi r2, r0, 5 \n" \
|
411 |
|
|
" bne r2, r5, RegTest1Error \n" \
|
412 |
|
|
" addi r2, r0, 6 \n" \
|
413 |
|
|
" bne r2, r6, RegTest1Error \n" \
|
414 |
|
|
" addi r2, r0, 7 \n" \
|
415 |
|
|
" bne r2, r7, RegTest1Error \n" \
|
416 |
|
|
" addi r2, r0, 8 \n" \
|
417 |
|
|
" bne r2, r8, RegTest1Error \n" \
|
418 |
|
|
" addi r2, r0, 9 \n" \
|
419 |
|
|
" bne r2, r9, RegTest1Error \n" \
|
420 |
|
|
" addi r2, r0, 10 \n" \
|
421 |
|
|
" bne r2, r10, RegTest1Error \n" \
|
422 |
|
|
" addi r2, r0, 11 \n" \
|
423 |
|
|
" bne r2, r11, RegTest1Error \n" \
|
424 |
|
|
" addi r2, r0, 12 \n" \
|
425 |
|
|
" bne r2, r12, RegTest1Error \n" \
|
426 |
|
|
" addi r2, r0, 13 \n" \
|
427 |
|
|
" bne r2, r13, RegTest1Error \n" \
|
428 |
|
|
" addi r2, r0, 14 \n" \
|
429 |
|
|
" bne r2, r14, RegTest1Error \n" \
|
430 |
|
|
" addi r2, r0, 15 \n" \
|
431 |
|
|
" bne r2, r15, RegTest1Error \n" \
|
432 |
|
|
" addi r2, r0, 16 \n" \
|
433 |
|
|
" bne r2, r16, RegTest1Error \n" \
|
434 |
|
|
" addi r2, r0, 17 \n" \
|
435 |
|
|
" bne r2, r17, RegTest1Error \n" \
|
436 |
|
|
" addi r2, r0, 18 \n" \
|
437 |
|
|
" bne r2, r18, RegTest1Error \n" \
|
438 |
|
|
" addi r2, r0, 19 \n" \
|
439 |
|
|
" bne r2, r19, RegTest1Error \n" \
|
440 |
|
|
" addi r2, r0, 20 \n" \
|
441 |
|
|
" bne r2, r20, RegTest1Error \n" \
|
442 |
|
|
" addi r2, r0, 21 \n" \
|
443 |
|
|
" bne r2, r21, RegTest1Error \n" \
|
444 |
|
|
" addi r2, r0, 22 \n" \
|
445 |
|
|
" bne r2, r22, RegTest1Error \n" \
|
446 |
|
|
" addi r2, r0, 23 \n" \
|
447 |
|
|
" bne r2, r23, RegTest1Error \n" \
|
448 |
|
|
" addi r2, r0, 28 \n" \
|
449 |
|
|
" bne r2, r28, RegTest1Error \n" \
|
450 |
|
|
" addi r2, r0, 31 \n" \
|
451 |
|
|
" bne r2, r31, RegTest1Error \n" \
|
452 |
|
|
" ldw r2, %gprel(ulRegTest1Counter)(gp) \n" \
|
453 |
|
|
" addi r2, r2, 1 \n" \
|
454 |
|
|
" stw r2, %gprel(ulRegTest1Counter)(gp) \n" \
|
455 |
|
|
" br RegTest1 \n" \
|
456 |
|
|
"RegTest1Error: \n" \
|
457 |
|
|
" br RegTest1Error \n"
|
458 |
|
|
);
|
459 |
|
|
}
|
460 |
|
|
/*-----------------------------------------------------------*/
|
461 |
|
|
|
462 |
|
|
static void prvSecondRegTestTask( void *pvParameters )
|
463 |
|
|
{
|
464 |
|
|
/* Check the parameters are passed in as expected. */
|
465 |
|
|
if( pvParameters != mainREG_TEST_2_PARAMETER )
|
466 |
|
|
{
|
467 |
|
|
/* Don't execute any further so an error is recognised by the check
|
468 |
|
|
task. */
|
469 |
|
|
vTaskDelete( NULL );
|
470 |
|
|
}
|
471 |
|
|
|
472 |
|
|
/* Fill registers with known values, then check that each register still
|
473 |
|
|
contains its expected value. An incorrect value is indicative of an error
|
474 |
|
|
in the context switching process.
|
475 |
|
|
|
476 |
|
|
If no errors are found ulRegTest2Counter is incremented. The check task
|
477 |
|
|
will recognise an error if ulRegTest2Counter stops being incremented. */
|
478 |
|
|
asm volatile (
|
479 |
|
|
" .extern ulRegTest2Counter \n" \
|
480 |
|
|
" \n" \
|
481 |
|
|
" addi r3, r0, 3 \n" \
|
482 |
|
|
" addi r4, r0, 4 \n" \
|
483 |
|
|
" addi r5, r0, 5 \n" \
|
484 |
|
|
" addi r6, r0, 6 \n" \
|
485 |
|
|
" addi r7, r0, 7 \n" \
|
486 |
|
|
" addi r8, r0, 8 \n" \
|
487 |
|
|
" addi r9, r0, 9 \n" \
|
488 |
|
|
" addi r10, r0, 10 \n" \
|
489 |
|
|
" addi r11, r0, 11 \n" \
|
490 |
|
|
" addi r12, r0, 12 \n" \
|
491 |
|
|
" addi r13, r0, 13 \n" \
|
492 |
|
|
" addi r14, r0, 14 \n" \
|
493 |
|
|
" addi r15, r0, 15 \n" \
|
494 |
|
|
" addi r16, r0, 16 \n" \
|
495 |
|
|
" addi r17, r0, 17 \n" \
|
496 |
|
|
" addi r18, r0, 18 \n" \
|
497 |
|
|
" addi r19, r0, 19 \n" \
|
498 |
|
|
" addi r20, r0, 20 \n" \
|
499 |
|
|
" addi r21, r0, 21 \n" \
|
500 |
|
|
" addi r22, r0, 22 \n" \
|
501 |
|
|
" addi r23, r0, 23 \n" \
|
502 |
|
|
" addi r28, r0, 28 \n" \
|
503 |
|
|
" addi r31, r0, 31 \n" \
|
504 |
|
|
"RegTest2: \n" \
|
505 |
|
|
" addi r2, r0, 0 \n" \
|
506 |
|
|
" bne r2, r0, RegTest2Error \n" \
|
507 |
|
|
" addi r2, r0, 3 \n" \
|
508 |
|
|
" bne r2, r3, RegTest2Error \n" \
|
509 |
|
|
" addi r2, r0, 4 \n" \
|
510 |
|
|
" bne r2, r4, RegTest2Error \n" \
|
511 |
|
|
" addi r2, r0, 5 \n" \
|
512 |
|
|
" bne r2, r5, RegTest2Error \n" \
|
513 |
|
|
" addi r2, r0, 6 \n" \
|
514 |
|
|
" bne r2, r6, RegTest2Error \n" \
|
515 |
|
|
" addi r2, r0, 7 \n" \
|
516 |
|
|
" bne r2, r7, RegTest2Error \n" \
|
517 |
|
|
" addi r2, r0, 8 \n" \
|
518 |
|
|
" bne r2, r8, RegTest2Error \n" \
|
519 |
|
|
" addi r2, r0, 9 \n" \
|
520 |
|
|
" bne r2, r9, RegTest2Error \n" \
|
521 |
|
|
" addi r2, r0, 10 \n" \
|
522 |
|
|
" bne r2, r10, RegTest2Error \n" \
|
523 |
|
|
" addi r2, r0, 11 \n" \
|
524 |
|
|
" bne r2, r11, RegTest2Error \n" \
|
525 |
|
|
" addi r2, r0, 12 \n" \
|
526 |
|
|
" bne r2, r12, RegTest2Error \n" \
|
527 |
|
|
" addi r2, r0, 13 \n" \
|
528 |
|
|
" bne r2, r13, RegTest2Error \n" \
|
529 |
|
|
" addi r2, r0, 14 \n" \
|
530 |
|
|
" bne r2, r14, RegTest2Error \n" \
|
531 |
|
|
" addi r2, r0, 15 \n" \
|
532 |
|
|
" bne r2, r15, RegTest2Error \n" \
|
533 |
|
|
" addi r2, r0, 16 \n" \
|
534 |
|
|
" bne r2, r16, RegTest2Error \n" \
|
535 |
|
|
" addi r2, r0, 17 \n" \
|
536 |
|
|
" bne r2, r17, RegTest2Error \n" \
|
537 |
|
|
" addi r2, r0, 18 \n" \
|
538 |
|
|
" bne r2, r18, RegTest2Error \n" \
|
539 |
|
|
" addi r2, r0, 19 \n" \
|
540 |
|
|
" bne r2, r19, RegTest2Error \n" \
|
541 |
|
|
" addi r2, r0, 20 \n" \
|
542 |
|
|
" bne r2, r20, RegTest2Error \n" \
|
543 |
|
|
" addi r2, r0, 21 \n" \
|
544 |
|
|
" bne r2, r21, RegTest2Error \n" \
|
545 |
|
|
" addi r2, r0, 22 \n" \
|
546 |
|
|
" bne r2, r22, RegTest2Error \n" \
|
547 |
|
|
" addi r2, r0, 23 \n" \
|
548 |
|
|
" bne r2, r23, RegTest2Error \n" \
|
549 |
|
|
" addi r2, r0, 28 \n" \
|
550 |
|
|
" bne r2, r28, RegTest2Error \n" \
|
551 |
|
|
" addi r2, r0, 31 \n" \
|
552 |
|
|
" bne r2, r31, RegTest2Error \n" \
|
553 |
|
|
" ldw r2, %gprel(ulRegTest2Counter)(gp) \n" \
|
554 |
|
|
" addi r2, r2, 1 \n" \
|
555 |
|
|
" stw r2, %gprel(ulRegTest2Counter)(gp) \n" \
|
556 |
|
|
" br RegTest2 \n" \
|
557 |
|
|
"RegTest2Error: \n" \
|
558 |
|
|
" br RegTest2Error \n"
|
559 |
|
|
);
|
560 |
|
|
}
|
561 |
|
|
/*-----------------------------------------------------------*/
|
562 |
|
|
|