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