]> git.sur5r.net Git - freertos/blob - Demo/PPC440_SP_FPU_Xilinx_Virtex5_GCC/RTOSDemo/main.c
Update to V6.1.1
[freertos] / Demo / PPC440_SP_FPU_Xilinx_Virtex5_GCC / RTOSDemo / main.c
1 /*\r
2     FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
3 \r
4     ***************************************************************************\r
5     *                                                                         *\r
6     * If you are:                                                             *\r
7     *                                                                         *\r
8     *    + New to FreeRTOS,                                                   *\r
9     *    + Wanting to learn FreeRTOS or multitasking in general quickly       *\r
10     *    + Looking for basic training,                                        *\r
11     *    + Wanting to improve your FreeRTOS skills and productivity           *\r
12     *                                                                         *\r
13     * then take a look at the FreeRTOS books - available as PDF or paperback  *\r
14     *                                                                         *\r
15     *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *\r
16     *                  http://www.FreeRTOS.org/Documentation                  *\r
17     *                                                                         *\r
18     * A pdf reference manual is also available.  Both are usually delivered   *\r
19     * to your inbox within 20 minutes to two hours when purchased between 8am *\r
20     * and 8pm GMT (although please allow up to 24 hours in case of            *\r
21     * exceptional circumstances).  Thank you for your support!                *\r
22     *                                                                         *\r
23     ***************************************************************************\r
24 \r
25     This file is part of the FreeRTOS distribution.\r
26 \r
27     FreeRTOS is free software; you can redistribute it and/or modify it under\r
28     the terms of the GNU General Public License (version 2) as published by the\r
29     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
30     ***NOTE*** The exception to the GPL is included to allow you to distribute\r
31     a combined work that includes FreeRTOS without being obliged to provide the\r
32     source code for proprietary components outside of the FreeRTOS kernel.\r
33     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
34     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
35     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
36     more details. You should have received a copy of the GNU General Public \r
37     License and the FreeRTOS license exception along with FreeRTOS; if not it \r
38     can be viewed here: http://www.freertos.org/a00114.html and also obtained \r
39     by writing to Richard Barry, contact details for whom are available on the\r
40     FreeRTOS WEB site.\r
41 \r
42     1 tab == 4 spaces!\r
43 \r
44     http://www.FreeRTOS.org - Documentation, latest information, license and\r
45     contact details.\r
46 \r
47     http://www.SafeRTOS.com - A version that is certified for use in safety\r
48     critical systems.\r
49 \r
50     http://www.OpenRTOS.com - Commercial support, development, porting,\r
51     licensing and training services.\r
52 */\r
53 \r
54 /*\r
55  * Creates all the demo application tasks, then starts the scheduler.  The WEB\r
56  * documentation provides more details of the demo application tasks.\r
57  * \r
58  * In addition to the standard demo tasks, the follow demo specific tasks are\r
59  * create:\r
60  *\r
61  * The "Check" task.  This only executes every three seconds but has the highest \r
62  * priority so is guaranteed to get processor time.  Its main function is to \r
63  * check that all the other tasks are still operational.  Most tasks maintain \r
64  * a unique count that is incremented each time the task successfully completes \r
65  * its function.  Should any error occur within such a task the count is \r
66  * permanently halted.  The check task inspects the count of each task to ensure \r
67  * it has changed since the last time the check task executed.  If all the count \r
68  * variables have changed all the tasks are still executing error free, and the \r
69  * check task toggles the onboard LED.  Should any task contain an error at any time \r
70  * the LED toggle rate will change from 3 seconds to 500ms.\r
71  *\r
72  * The "Register Check" tasks.  These tasks fill the CPU registers with known\r
73  * values, then check that each register still contains the expected value, the\r
74  * discovery of an unexpected value being indicative of an error in the RTOS\r
75  * context switch mechanism.  The register check tasks operate at low priority\r
76  * so are switched in and out frequently.\r
77  *\r
78  */\r
79 \r
80 /* Scheduler includes. */\r
81 #include "FreeRTOS.h"\r
82 #include "task.h"\r
83 \r
84 /* Xilinx library includes. */\r
85 #include "xcache_l.h"\r
86 #include "xintc.h"\r
87 \r
88 /* Demo application includes. */\r
89 #include "flash.h"\r
90 #include "integer.h"\r
91 #include "comtest2.h"\r
92 #include "semtest.h"\r
93 #include "BlockQ.h"\r
94 #include "dynamic.h"\r
95 #include "GenQTest.h"\r
96 #include "QPeek.h"\r
97 #include "blocktim.h"\r
98 #include "death.h"\r
99 #include "partest.h"\r
100 #include "countsem.h"\r
101 #include "recmutex.h"\r
102 #include "flop.h"\r
103 #include "flop-reg-test.h"\r
104 \r
105 /* Priorities assigned to the demo tasks. */\r
106 #define mainCHECK_TASK_PRIORITY                 ( tskIDLE_PRIORITY + 4 )\r
107 #define mainSEM_TEST_PRIORITY                   ( tskIDLE_PRIORITY + 2 )\r
108 #define mainCOM_TEST_PRIORITY                   ( tskIDLE_PRIORITY + 1 )\r
109 #define mainQUEUE_BLOCK_PRIORITY                ( tskIDLE_PRIORITY + 1 )\r
110 #define mainDEATH_PRIORITY                              ( tskIDLE_PRIORITY + 1 )\r
111 #define mainLED_TASK_PRIORITY                   ( tskIDLE_PRIORITY + 1 )\r
112 #define mainGENERIC_QUEUE_PRIORITY              ( tskIDLE_PRIORITY )\r
113 #define mainQUEUE_POLL_PRIORITY                 ( tskIDLE_PRIORITY + 1 )\r
114 #define mainFLOP_PRIORITY                               ( tskIDLE_PRIORITY )\r
115 \r
116 /* The first LED used by the COM test and check tasks respectively. */\r
117 #define mainCOM_TEST_LED                                ( 4 )\r
118 #define mainCHECK_TEST_LED                              ( 3 )\r
119 \r
120 /* The baud rate used by the comtest tasks is set by the hardware, so the\r
121 baud rate parameters passed into the comtest initialisation has no effect. */\r
122 #define mainBAUD_SET_IN_HARDWARE                ( 0 )\r
123 \r
124 /* Delay periods used by the check task.  If no errors have been found then\r
125 the check LED will toggle every mainNO_ERROR_CHECK_DELAY milliseconds.  If an\r
126 error has been found at any time then the toggle rate will increase to \r
127 mainERROR_CHECK_DELAY milliseconds. */\r
128 #define mainNO_ERROR_CHECK_DELAY                ( ( portTickType ) 3000 / portTICK_RATE_MS  )\r
129 #define mainERROR_CHECK_DELAY                   ( ( portTickType ) 500 / portTICK_RATE_MS  )\r
130 \r
131 \r
132 /* \r
133  * The tasks defined within this file - described within the comments at the\r
134  * head of this page. \r
135  */\r
136 static void prvRegTestTask1( void *pvParameters );\r
137 static void prvRegTestTask2( void *pvParameters );\r
138 static void prvErrorChecks( void *pvParameters );\r
139 \r
140 /*\r
141  * Called by the 'check' task to inspect all the standard demo tasks within\r
142  * the system, as described within the comments at the head of this page.\r
143  */\r
144 static portBASE_TYPE prvCheckOtherTasksAreStillRunning( void );\r
145 \r
146 /*\r
147  * Perform any hardware initialisation required by the demo application.\r
148  */\r
149 static void prvSetupHardware( void );\r
150 \r
151 /*-----------------------------------------------------------*/\r
152 \r
153 /* xRegTestStatus will get set to pdFAIL by the regtest tasks if they\r
154 discover an unexpected value. */\r
155 static volatile unsigned portBASE_TYPE xRegTestStatus = pdPASS;\r
156 \r
157 /* Counters used to ensure the regtest tasks are still running. */\r
158 static volatile unsigned long ulRegTest1Counter = 0UL, ulRegTest2Counter = 0UL;\r
159 \r
160 /*-----------------------------------------------------------*/\r
161 \r
162 int main( void )\r
163 {\r
164 \r
165         /* Must be called prior to installing any interrupt handlers! */\r
166         vPortSetupInterruptController();\r
167 \r
168         /* In this case prvSetupHardware() just enables the caches and and\r
169         configures the IO ports for the LED outputs. */\r
170         prvSetupHardware();\r
171 \r
172         /* Start the standard demo application tasks.  Note that the baud rate used\r
173         by the comtest tasks is set by the hardware, so the baud rate parameter\r
174         passed has no effect. */\r
175         vStartLEDFlashTasks( mainLED_TASK_PRIORITY );   \r
176         vStartIntegerMathTasks( tskIDLE_PRIORITY );\r
177         vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainBAUD_SET_IN_HARDWARE, mainCOM_TEST_LED );\r
178         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
179         vStartBlockingQueueTasks ( mainQUEUE_BLOCK_PRIORITY );  \r
180         vStartDynamicPriorityTasks();   \r
181         vStartGenericQueueTasks( mainGENERIC_QUEUE_PRIORITY );\r
182         vStartQueuePeekTasks();\r
183         vCreateBlockTimeTasks();\r
184         vStartCountingSemaphoreTasks();\r
185         vStartRecursiveMutexTasks();\r
186 \r
187         #if ( configUSE_FPU == 1 )\r
188                 vStartMathTasks( mainFLOP_PRIORITY );\r
189                 vStartFlopRegTests();\r
190         #endif\r
191 \r
192         /* Create the tasks defined within this file. */\r
193         xTaskCreate( prvRegTestTask1, ( signed char * ) "Regtest1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
194         xTaskCreate( prvRegTestTask2, ( signed char * ) "Regtest2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
195         xTaskCreate( prvErrorChecks, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
196 \r
197         /* The suicide tasks must be started last as they record the number of other\r
198         tasks that exist within the system.  The value is then used to ensure at run\r
199         time the number of tasks that exists is within expected bounds. */\r
200         vCreateSuicidalTasks( mainDEATH_PRIORITY );\r
201 \r
202         /* Now start the scheduler.  Following this call the created tasks should\r
203         be executing. */        \r
204         vTaskStartScheduler();\r
205 \r
206         /* vTaskStartScheduler() will only return if an error occurs while the \r
207         idle task is being created. */\r
208         for( ;; );\r
209 \r
210         return 0;\r
211 }\r
212 /*-----------------------------------------------------------*/\r
213 \r
214 static portBASE_TYPE prvCheckOtherTasksAreStillRunning( void )\r
215 {\r
216 portBASE_TYPE lReturn = pdPASS;\r
217 static unsigned long ulLastRegTest1Counter= 0UL, ulLastRegTest2Counter = 0UL;\r
218 \r
219         /* The demo tasks maintain a count that increments every cycle of the task\r
220         provided that the task has never encountered an error.  This function \r
221         checks the counts maintained by the tasks to ensure they are still being\r
222         incremented.  A count remaining at the same value between calls therefore\r
223         indicates that an error has been detected. */\r
224 \r
225         if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
226         {\r
227                 lReturn = pdFAIL;\r
228         }\r
229 \r
230         if( xAreComTestTasksStillRunning() != pdTRUE )\r
231         {\r
232                 lReturn = pdFAIL;\r
233         }\r
234         \r
235         if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
236         {\r
237                 lReturn = pdFAIL;\r
238         }\r
239         \r
240         if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
241         {\r
242                 lReturn = pdFAIL;\r
243         }\r
244         \r
245         if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
246         {\r
247                 lReturn = pdFAIL;\r
248         }\r
249         \r
250         if( xIsCreateTaskStillRunning() != pdTRUE )\r
251         {\r
252                 lReturn = pdFAIL;\r
253         }\r
254         \r
255         if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
256         {\r
257                 lReturn = pdFAIL;\r
258         }\r
259         \r
260         if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
261         {\r
262                 lReturn = pdFAIL;\r
263         }\r
264         \r
265         if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
266         {\r
267                 lReturn = pdFAIL;\r
268         }\r
269 \r
270         if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
271         {\r
272                 lReturn = pdFAIL;\r
273         }\r
274 \r
275         if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
276         {\r
277                 lReturn = pdFAIL;\r
278         }\r
279 \r
280         #if ( configUSE_FPU == 1 )\r
281                 if( xAreMathsTaskStillRunning() != pdTRUE )\r
282                 {\r
283                         lReturn = pdFAIL;\r
284                 }\r
285 \r
286                 if( xAreFlopRegisterTestsStillRunning() != pdTRUE )\r
287                 {\r
288                         lReturn = pdFAIL;\r
289                 }\r
290         #endif\r
291 \r
292         /* Have the register test tasks found any errors? */\r
293         if( xRegTestStatus != pdPASS )\r
294         {\r
295                 lReturn = pdFAIL;\r
296         }\r
297 \r
298         /* Are the register test tasks still looping? */\r
299         if( ulLastRegTest1Counter == ulRegTest1Counter )\r
300         {\r
301                 lReturn = pdFAIL;\r
302         }\r
303         else\r
304         {\r
305                 ulLastRegTest1Counter = ulRegTest1Counter;\r
306         }\r
307 \r
308         if( ulLastRegTest2Counter == ulRegTest2Counter )\r
309         {\r
310                 lReturn = pdFAIL;\r
311         }\r
312         else\r
313         {\r
314                 ulLastRegTest2Counter = ulRegTest2Counter;\r
315         }\r
316 \r
317         return lReturn;\r
318 }\r
319 /*-----------------------------------------------------------*/\r
320 \r
321 static void prvErrorChecks( void *pvParameters )\r
322 {\r
323 portTickType xDelayPeriod = mainNO_ERROR_CHECK_DELAY, xLastExecutionTime;\r
324 volatile unsigned portBASE_TYPE uxFreeStack;\r
325 \r
326         /* Just to remove compiler warning. */\r
327         ( void ) pvParameters;\r
328 \r
329         /* This call is just to demonstrate the use of the function - nothing is\r
330         done with the value.  You would expect the stack high water mark to be\r
331         lower (the function to return a larger value) here at function entry than\r
332         later following calls to other functions. */\r
333         uxFreeStack = uxTaskGetStackHighWaterMark( NULL );\r
334 \r
335         /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()\r
336         works correctly. */\r
337         xLastExecutionTime = xTaskGetTickCount();\r
338 \r
339         /* Cycle for ever, delaying then checking all the other tasks are still\r
340         operating without error. */\r
341         for( ;; )\r
342         {\r
343                 /* Again just for demo purposes - uxFreeStack should have a lower value\r
344                 here than following the call to uxTaskGetStackHighWaterMark() on the\r
345                 task entry. */\r
346                 uxFreeStack = uxTaskGetStackHighWaterMark( NULL );\r
347 \r
348                 /* Wait until it is time to check again.  The time we wait here depends\r
349                 on whether an error has been detected or not.  When an error is \r
350                 detected the time is shortened resulting in a faster LED flash rate. */\r
351                 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );\r
352 \r
353                 /* See if the other tasks are all ok. */\r
354                 if( prvCheckOtherTasksAreStillRunning() != pdPASS )\r
355                 {\r
356                         /* An error occurred in one of the tasks so shorten the delay \r
357                         period - which has the effect of increasing the frequency of the\r
358                         LED toggle. */\r
359                         xDelayPeriod = mainERROR_CHECK_DELAY;\r
360                 }\r
361 \r
362                 /* Flash! */\r
363                 vParTestToggleLED( mainCHECK_TEST_LED );\r
364         }\r
365 }\r
366 /*-----------------------------------------------------------*/\r
367 \r
368 static void prvSetupHardware( void )\r
369 {\r
370         XCache_EnableICache( 0x80000000 );\r
371         XCache_EnableDCache( 0x80000000 );\r
372 \r
373         /* Setup the IO port for use with the LED outputs. */\r
374         vParTestInitialise();\r
375 }\r
376 /*-----------------------------------------------------------*/\r
377 \r
378 void prvRegTest1Pass( void )\r
379 {\r
380         /* Called from the inline assembler - this cannot be static\r
381         otherwise it can get optimised away. */\r
382         ulRegTest1Counter++;\r
383 }\r
384 /*-----------------------------------------------------------*/\r
385 \r
386 void prvRegTest2Pass( void )\r
387 {\r
388         /* Called from the inline assembler - this cannot be static\r
389         otherwise it can get optimised away. */\r
390         ulRegTest2Counter++;\r
391 }\r
392 /*-----------------------------------------------------------*/\r
393 \r
394 void prvRegTestFail( void )\r
395 {\r
396         /* Called from the inline assembler - this cannot be static\r
397         otherwise it can get optimised away. */\r
398         xRegTestStatus = pdFAIL;\r
399 }\r
400 /*-----------------------------------------------------------*/\r
401 \r
402 static void prvRegTestTask1( void *pvParameters )\r
403 {\r
404         /* Just to remove compiler warning. */\r
405         ( void ) pvParameters;\r
406 \r
407         /* The first register test task as described at the top of this file.  The\r
408         values used in the registers are different to those use in the second \r
409         register test task.  Also, unlike the second register test task, this task\r
410         yields between setting the register values and subsequently checking the\r
411         register values. */\r
412         asm volatile\r
413         (\r
414                 "RegTest1Start:                                 \n\t" \\r
415                 "                                                               \n\t" \\r
416                 "       li              0, 301                          \n\t" \\r
417                 "       mtspr   256, 0  #USPRG0         \n\t" \\r
418                 "       li              0, 501                          \n\t" \\r
419                 "       mtspr   8, 0    #LR                     \n\t" \\r
420                 "       li              0, 4                            \n\t" \\r
421                 "       mtspr   1, 0    #XER            \n\t" \\r
422                 "                                                               \n\t" \\r
423                 "       li              0, 1                            \n\t" \\r
424                 "       li              2, 2                            \n\t" \\r
425                 "       li              3, 3                            \n\t" \\r
426                 "       li              4,      4                               \n\t" \\r
427                 "       li              5,      5                               \n\t" \\r
428                 "       li              6,      6                               \n\t" \\r
429                 "       li              7,      7                               \n\t" \\r
430                 "       li              8,      8                               \n\t" \\r
431                 "       li              9,      9                               \n\t" \\r
432                 "       li              10,     10                              \n\t" \\r
433                 "       li              11,     11                              \n\t" \\r
434                 "       li              12,     12                              \n\t" \\r
435                 "       li              13,     13                              \n\t" \\r
436                 "       li              14,     14                              \n\t" \\r
437                 "       li              15,     15                              \n\t" \\r
438                 "       li              16,     16                              \n\t" \\r
439                 "       li              17,     17                              \n\t" \\r
440                 "       li              18,     18                              \n\t" \\r
441                 "       li              19,     19                              \n\t" \\r
442                 "       li              20,     20                              \n\t" \\r
443                 "       li              21,     21                              \n\t" \\r
444                 "       li              22,     22                              \n\t" \\r
445                 "       li              23,     23                              \n\t" \\r
446                 "       li              24,     24                              \n\t" \\r
447                 "       li              25,     25                              \n\t" \\r
448                 "       li              26,     26                              \n\t" \\r
449                 "       li              27,     27                              \n\t" \\r
450                 "       li              28,     28                              \n\t" \\r
451                 "       li              29,     29                              \n\t" \\r
452                 "       li              30,     30                              \n\t" \\r
453                 "       li              31,     31                              \n\t" \\r
454                 "                                                               \n\t" \\r
455                 "       sc                                                      \n\t" \\r
456                 "       nop                                                     \n\t" \\r
457                 "                                                               \n\t" \\r
458                 "       cmpwi   0, 1                            \n\t" \\r
459                 "       bne     RegTest1Fail                    \n\t" \\r
460                 "       cmpwi   2, 2                            \n\t" \\r
461                 "       bne     RegTest1Fail                    \n\t" \\r
462                 "       cmpwi   3, 3                            \n\t" \\r
463                 "       bne     RegTest1Fail                    \n\t" \\r
464                 "       cmpwi   4, 4                            \n\t" \\r
465                 "       bne     RegTest1Fail                    \n\t" \\r
466                 "       cmpwi   5, 5                            \n\t" \\r
467                 "       bne     RegTest1Fail                    \n\t" \\r
468                 "       cmpwi   6, 6                            \n\t" \\r
469                 "       bne     RegTest1Fail                    \n\t" \\r
470                 "       cmpwi   7, 7                            \n\t" \\r
471                 "       bne     RegTest1Fail                    \n\t" \\r
472                 "       cmpwi   8, 8                            \n\t" \\r
473                 "       bne     RegTest1Fail                    \n\t" \\r
474                 "       cmpwi   9, 9                            \n\t" \\r
475                 "       bne     RegTest1Fail                    \n\t" \\r
476                 "       cmpwi   10, 10                          \n\t" \\r
477                 "       bne     RegTest1Fail                    \n\t" \\r
478                 "       cmpwi   11, 11                          \n\t" \\r
479                 "       bne     RegTest1Fail                    \n\t" \\r
480                 "       cmpwi   12, 12                          \n\t" \\r
481                 "       bne     RegTest1Fail                    \n\t" \\r
482                 "       cmpwi   13, 13                          \n\t" \\r
483                 "       bne     RegTest1Fail                    \n\t" \\r
484                 "       cmpwi   14, 14                          \n\t" \\r
485                 "       bne     RegTest1Fail                    \n\t" \\r
486                 "       cmpwi   15, 15                          \n\t" \\r
487                 "       bne     RegTest1Fail                    \n\t" \\r
488                 "       cmpwi   16, 16                          \n\t" \\r
489                 "       bne     RegTest1Fail                    \n\t" \\r
490                 "       cmpwi   17, 17                          \n\t" \\r
491                 "       bne     RegTest1Fail                    \n\t" \\r
492                 "       cmpwi   18, 18                          \n\t" \\r
493                 "       bne     RegTest1Fail                    \n\t" \\r
494                 "       cmpwi   19, 19                          \n\t" \\r
495                 "       bne     RegTest1Fail                    \n\t" \\r
496                 "       cmpwi   20, 20                          \n\t" \\r
497                 "       bne     RegTest1Fail                    \n\t" \\r
498                 "       cmpwi   21, 21                          \n\t" \\r
499                 "       bne     RegTest1Fail                    \n\t" \\r
500                 "       cmpwi   22, 22                          \n\t" \\r
501                 "       bne     RegTest1Fail                    \n\t" \\r
502                 "       cmpwi   23, 23                          \n\t" \\r
503                 "       bne     RegTest1Fail                    \n\t" \\r
504                 "       cmpwi   24, 24                          \n\t" \\r
505                 "       bne     RegTest1Fail                    \n\t" \\r
506                 "       cmpwi   25, 25                          \n\t" \\r
507                 "       bne     RegTest1Fail                    \n\t" \\r
508                 "       cmpwi   26, 26                          \n\t" \\r
509                 "       bne     RegTest1Fail                    \n\t" \\r
510                 "       cmpwi   27, 27                          \n\t" \\r
511                 "       bne     RegTest1Fail                    \n\t" \\r
512                 "       cmpwi   28, 28                          \n\t" \\r
513                 "       bne     RegTest1Fail                    \n\t" \\r
514                 "       cmpwi   29, 29                          \n\t" \\r
515                 "       bne     RegTest1Fail                    \n\t" \\r
516                 "       cmpwi   30, 30                          \n\t" \\r
517                 "       bne     RegTest1Fail                    \n\t" \\r
518                 "       cmpwi   31, 31                          \n\t" \\r
519                 "       bne     RegTest1Fail                    \n\t" \\r
520                 "                                                               \n\t" \\r
521                 "       mfspr   0, 256  #USPRG0         \n\t" \\r
522                 "       cmpwi   0, 301                          \n\t" \\r
523                 "       bne     RegTest1Fail                    \n\t" \\r
524                 "       mfspr   0, 8    #LR                     \n\t" \\r
525                 "       cmpwi   0, 501                          \n\t" \\r
526                 "       bne     RegTest1Fail                    \n\t" \\r
527                 "       mfspr   0, 1    #XER            \n\t" \\r
528                 "       cmpwi   0, 4                            \n\t" \\r
529                 "       bne     RegTest1Fail                    \n\t" \\r
530                 "                                                               \n\t" \\r
531                 "       bl prvRegTest1Pass                      \n\t" \\r
532                 "       b RegTest1Start                         \n\t" \\r
533                 "                                                               \n\t" \\r
534                 "RegTest1Fail:                                  \n\t" \\r
535                 "                                                               \n\t" \\r
536                 "                                                               \n\t" \\r
537                 "       bl prvRegTestFail                       \n\t" \\r
538                 "       b RegTest1Start                         \n\t" \\r
539         );\r
540 }\r
541 /*-----------------------------------------------------------*/\r
542 \r
543 static void prvRegTestTask2( void *pvParameters )\r
544 {\r
545         /* Just to remove compiler warning. */\r
546         ( void ) pvParameters;\r
547 \r
548         /* The second register test task as described at the top of this file.  \r
549         Note that this task fills the registers with different values to the\r
550         first register test task. */\r
551         asm volatile\r
552         (\r
553                 "RegTest2Start:                                 \n\t" \\r
554                 "                                                               \n\t" \\r
555                 "       li              0, 300                          \n\t" \\r
556                 "       mtspr   256, 0  #USPRG0         \n\t" \\r
557                 "       li              0, 500                          \n\t" \\r
558                 "       mtspr   8, 0    #LR                     \n\t" \\r
559                 "       li              0, 4                            \n\t" \\r
560                 "       mtspr   1, 0    #XER            \n\t" \\r
561                 "                                                               \n\t" \\r
562                 "       li              0, 11                           \n\t" \\r
563                 "       li              2, 12                           \n\t" \\r
564                 "       li              3, 13                           \n\t" \\r
565                 "       li              4,      14                              \n\t" \\r
566                 "       li              5,      15                              \n\t" \\r
567                 "       li              6,      16                              \n\t" \\r
568                 "       li              7,      17                              \n\t" \\r
569                 "       li              8,      18                              \n\t" \\r
570                 "       li              9,      19                              \n\t" \\r
571                 "       li              10,     110                             \n\t" \\r
572                 "       li              11,     111                             \n\t" \\r
573                 "       li              12,     112                             \n\t" \\r
574                 "       li              13,     113                             \n\t" \\r
575                 "       li              14,     114                             \n\t" \\r
576                 "       li              15,     115                             \n\t" \\r
577                 "       li              16,     116                             \n\t" \\r
578                 "       li              17,     117                             \n\t" \\r
579                 "       li              18,     118                             \n\t" \\r
580                 "       li              19,     119                             \n\t" \\r
581                 "       li              20,     120                             \n\t" \\r
582                 "       li              21,     121                             \n\t" \\r
583                 "       li              22,     122                             \n\t" \\r
584                 "       li              23,     123                             \n\t" \\r
585                 "       li              24,     124                             \n\t" \\r
586                 "       li              25,     125                             \n\t" \\r
587                 "       li              26,     126                             \n\t" \\r
588                 "       li              27,     127                             \n\t" \\r
589                 "       li              28,     128                             \n\t" \\r
590                 "       li              29,     129                             \n\t" \\r
591                 "       li              30,     130                             \n\t" \\r
592                 "       li              31,     131                             \n\t" \\r
593                 "                                                               \n\t" \\r
594                 "       cmpwi   0, 11                           \n\t" \\r
595                 "       bne     RegTest2Fail                    \n\t" \\r
596                 "       cmpwi   2, 12                           \n\t" \\r
597                 "       bne     RegTest2Fail                    \n\t" \\r
598                 "       cmpwi   3, 13                           \n\t" \\r
599                 "       bne     RegTest2Fail                    \n\t" \\r
600                 "       cmpwi   4, 14                           \n\t" \\r
601                 "       bne     RegTest2Fail                    \n\t" \\r
602                 "       cmpwi   5, 15                           \n\t" \\r
603                 "       bne     RegTest2Fail                    \n\t" \\r
604                 "       cmpwi   6, 16                           \n\t" \\r
605                 "       bne     RegTest2Fail                    \n\t" \\r
606                 "       cmpwi   7, 17                           \n\t" \\r
607                 "       bne     RegTest2Fail                    \n\t" \\r
608                 "       cmpwi   8, 18                           \n\t" \\r
609                 "       bne     RegTest2Fail                    \n\t" \\r
610                 "       cmpwi   9, 19                           \n\t" \\r
611                 "       bne     RegTest2Fail                    \n\t" \\r
612                 "       cmpwi   10, 110                         \n\t" \\r
613                 "       bne     RegTest2Fail                    \n\t" \\r
614                 "       cmpwi   11, 111                         \n\t" \\r
615                 "       bne     RegTest2Fail                    \n\t" \\r
616                 "       cmpwi   12, 112                         \n\t" \\r
617                 "       bne     RegTest2Fail                    \n\t" \\r
618                 "       cmpwi   13, 113                         \n\t" \\r
619                 "       bne     RegTest2Fail                    \n\t" \\r
620                 "       cmpwi   14, 114                         \n\t" \\r
621                 "       bne     RegTest2Fail                    \n\t" \\r
622                 "       cmpwi   15, 115                         \n\t" \\r
623                 "       bne     RegTest2Fail                    \n\t" \\r
624                 "       cmpwi   16, 116                         \n\t" \\r
625                 "       bne     RegTest2Fail                    \n\t" \\r
626                 "       cmpwi   17, 117                         \n\t" \\r
627                 "       bne     RegTest2Fail                    \n\t" \\r
628                 "       cmpwi   18, 118                         \n\t" \\r
629                 "       bne     RegTest2Fail                    \n\t" \\r
630                 "       cmpwi   19, 119                         \n\t" \\r
631                 "       bne     RegTest2Fail                    \n\t" \\r
632                 "       cmpwi   20, 120                         \n\t" \\r
633                 "       bne     RegTest2Fail                    \n\t" \\r
634                 "       cmpwi   21, 121                         \n\t" \\r
635                 "       bne     RegTest2Fail                    \n\t" \\r
636                 "       cmpwi   22, 122                         \n\t" \\r
637                 "       bne     RegTest2Fail                    \n\t" \\r
638                 "       cmpwi   23, 123                         \n\t" \\r
639                 "       bne     RegTest2Fail                    \n\t" \\r
640                 "       cmpwi   24, 124                         \n\t" \\r
641                 "       bne     RegTest2Fail                    \n\t" \\r
642                 "       cmpwi   25, 125                         \n\t" \\r
643                 "       bne     RegTest2Fail                    \n\t" \\r
644                 "       cmpwi   26, 126                         \n\t" \\r
645                 "       bne     RegTest2Fail                    \n\t" \\r
646                 "       cmpwi   27, 127                         \n\t" \\r
647                 "       bne     RegTest2Fail                    \n\t" \\r
648                 "       cmpwi   28, 128                         \n\t" \\r
649                 "       bne     RegTest2Fail                    \n\t" \\r
650                 "       cmpwi   29, 129                         \n\t" \\r
651                 "       bne     RegTest2Fail                    \n\t" \\r
652                 "       cmpwi   30, 130                         \n\t" \\r
653                 "       bne     RegTest2Fail                    \n\t" \\r
654                 "       cmpwi   31, 131                         \n\t" \\r
655                 "       bne     RegTest2Fail                    \n\t" \\r
656                 "                                                               \n\t" \\r
657                 "       mfspr   0, 256  #USPRG0         \n\t" \\r
658                 "       cmpwi   0, 300                          \n\t" \\r
659                 "       bne     RegTest2Fail                    \n\t" \\r
660                 "       mfspr   0, 8    #LR                     \n\t" \\r
661                 "       cmpwi   0, 500                          \n\t" \\r
662                 "       bne     RegTest2Fail                    \n\t" \\r
663                 "       mfspr   0, 1    #XER            \n\t" \\r
664                 "       cmpwi   0, 4                            \n\t" \\r
665                 "       bne     RegTest2Fail                    \n\t" \\r
666                 "                                                               \n\t" \\r
667                 "       bl prvRegTest2Pass                      \n\t" \\r
668                 "       b RegTest2Start                         \n\t" \\r
669                 "                                                               \n\t" \\r
670                 "RegTest2Fail:                                  \n\t" \\r
671                 "                                                               \n\t" \\r
672                 "                                                               \n\t" \\r
673                 "       bl prvRegTestFail                       \n\t" \\r
674                 "       b RegTest2Start                         \n\t" \\r
675         );\r
676 }\r
677 /*-----------------------------------------------------------*/\r
678 \r
679 /* This hook function will get called if there is a suspected stack overflow.\r
680 An overflow can cause the task name to be corrupted, in which case the task\r
681 handle needs to be used to determine the offending task. */\r
682 void vApplicationStackOverflowHook( xTaskHandle xTask, signed char *pcTaskName );\r
683 void vApplicationStackOverflowHook( xTaskHandle xTask, signed char *pcTaskName )\r
684 {\r
685 /* To prevent the optimiser removing the variables. */\r
686 volatile xTaskHandle xTaskIn = xTask;\r
687 volatile signed char *pcTaskNameIn = pcTaskName;\r
688 \r
689         /* Remove compiler warnings. */\r
690         ( void ) xTaskIn;\r
691         ( void ) pcTaskNameIn;\r
692 \r
693         /* The following three calls are simply to stop compiler warnings about the\r
694         functions not being used - they are called from the inline assembly. */\r
695         prvRegTest1Pass();\r
696         prvRegTest2Pass();\r
697         prvRegTestFail();\r
698 \r
699         for( ;; );\r
700 }\r
701 \r
702 \r
703 \r