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