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