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