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