]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/PPC440_SP_FPU_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_SP_FPU_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                 vStartMathTasks( mainFLOP_PRIORITY );\r
164                 vStartFlopRegTests();\r
165         #endif\r
166 \r
167         /* Create the tasks defined within this file. */\r
168         xTaskCreate( prvRegTestTask1, "Regtest1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
169         xTaskCreate( prvRegTestTask2, "Regtest2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
170         xTaskCreate( prvErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
171 \r
172         /* The suicide tasks must be started last as they record the number of other\r
173         tasks that exist within the system.  The value is then used to ensure at run\r
174         time the number of tasks that exists is within expected bounds. */\r
175         vCreateSuicidalTasks( mainDEATH_PRIORITY );\r
176 \r
177         /* Now start the scheduler.  Following this call the created tasks should\r
178         be executing. */        \r
179         vTaskStartScheduler();\r
180 \r
181         /* vTaskStartScheduler() will only return if an error occurs while the \r
182         idle task is being created. */\r
183         for( ;; );\r
184 \r
185         return 0;\r
186 }\r
187 /*-----------------------------------------------------------*/\r
188 \r
189 static portBASE_TYPE prvCheckOtherTasksAreStillRunning( void )\r
190 {\r
191 portBASE_TYPE lReturn = pdPASS;\r
192 static unsigned long ulLastRegTest1Counter= 0UL, ulLastRegTest2Counter = 0UL;\r
193 \r
194         /* The demo tasks maintain a count that increments every cycle of the task\r
195         provided that the task has never encountered an error.  This function \r
196         checks the counts maintained by the tasks to ensure they are still being\r
197         incremented.  A count remaining at the same value between calls therefore\r
198         indicates that an error has been detected. */\r
199 \r
200         if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
201         {\r
202                 lReturn = pdFAIL;\r
203         }\r
204 \r
205         if( xAreComTestTasksStillRunning() != pdTRUE )\r
206         {\r
207                 lReturn = pdFAIL;\r
208         }\r
209         \r
210         if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
211         {\r
212                 lReturn = pdFAIL;\r
213         }\r
214         \r
215         if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
216         {\r
217                 lReturn = pdFAIL;\r
218         }\r
219         \r
220         if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
221         {\r
222                 lReturn = pdFAIL;\r
223         }\r
224         \r
225         if( xIsCreateTaskStillRunning() != pdTRUE )\r
226         {\r
227                 lReturn = pdFAIL;\r
228         }\r
229         \r
230         if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
231         {\r
232                 lReturn = pdFAIL;\r
233         }\r
234         \r
235         if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
236         {\r
237                 lReturn = pdFAIL;\r
238         }\r
239         \r
240         if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
241         {\r
242                 lReturn = pdFAIL;\r
243         }\r
244 \r
245         if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
246         {\r
247                 lReturn = pdFAIL;\r
248         }\r
249 \r
250         if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
251         {\r
252                 lReturn = pdFAIL;\r
253         }\r
254 \r
255         #if ( configUSE_FPU == 1 )\r
256                 if( xAreMathsTaskStillRunning() != pdTRUE )\r
257                 {\r
258                         lReturn = pdFAIL;\r
259                 }\r
260 \r
261                 if( xAreFlopRegisterTestsStillRunning() != pdTRUE )\r
262                 {\r
263                         lReturn = pdFAIL;\r
264                 }\r
265         #endif\r
266 \r
267         /* Have the register test tasks found any errors? */\r
268         if( xRegTestStatus != pdPASS )\r
269         {\r
270                 lReturn = pdFAIL;\r
271         }\r
272 \r
273         /* Are the register test tasks still looping? */\r
274         if( ulLastRegTest1Counter == ulRegTest1Counter )\r
275         {\r
276                 lReturn = pdFAIL;\r
277         }\r
278         else\r
279         {\r
280                 ulLastRegTest1Counter = ulRegTest1Counter;\r
281         }\r
282 \r
283         if( ulLastRegTest2Counter == ulRegTest2Counter )\r
284         {\r
285                 lReturn = pdFAIL;\r
286         }\r
287         else\r
288         {\r
289                 ulLastRegTest2Counter = ulRegTest2Counter;\r
290         }\r
291 \r
292         return lReturn;\r
293 }\r
294 /*-----------------------------------------------------------*/\r
295 \r
296 static void prvErrorChecks( void *pvParameters )\r
297 {\r
298 TickType_t xDelayPeriod = mainNO_ERROR_CHECK_DELAY, xLastExecutionTime;\r
299 volatile unsigned portBASE_TYPE uxFreeStack;\r
300 \r
301         /* Just to remove compiler warning. */\r
302         ( void ) pvParameters;\r
303 \r
304         /* This call is just to demonstrate the use of the function - nothing is\r
305         done with the value.  You would expect the stack high water mark to be\r
306         lower (the function to return a larger value) here at function entry than\r
307         later following calls to other functions. */\r
308         uxFreeStack = uxTaskGetStackHighWaterMark( NULL );\r
309 \r
310         /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()\r
311         works correctly. */\r
312         xLastExecutionTime = xTaskGetTickCount();\r
313 \r
314         /* Cycle for ever, delaying then checking all the other tasks are still\r
315         operating without error. */\r
316         for( ;; )\r
317         {\r
318                 /* Again just for demo purposes - uxFreeStack should have a lower value\r
319                 here than following the call to uxTaskGetStackHighWaterMark() on the\r
320                 task entry. */\r
321                 uxFreeStack = uxTaskGetStackHighWaterMark( NULL );\r
322 \r
323                 /* Wait until it is time to check again.  The time we wait here depends\r
324                 on whether an error has been detected or not.  When an error is \r
325                 detected the time is shortened resulting in a faster LED flash rate. */\r
326                 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );\r
327 \r
328                 /* See if the other tasks are all ok. */\r
329                 if( prvCheckOtherTasksAreStillRunning() != pdPASS )\r
330                 {\r
331                         /* An error occurred in one of the tasks so shorten the delay \r
332                         period - which has the effect of increasing the frequency of the\r
333                         LED toggle. */\r
334                         xDelayPeriod = mainERROR_CHECK_DELAY;\r
335                 }\r
336 \r
337                 /* Flash! */\r
338                 vParTestToggleLED( mainCHECK_TEST_LED );\r
339         }\r
340 }\r
341 /*-----------------------------------------------------------*/\r
342 \r
343 static void prvSetupHardware( void )\r
344 {\r
345         XCache_EnableICache( 0x80000000 );\r
346         XCache_EnableDCache( 0x80000000 );\r
347 \r
348         /* Setup the IO port for use with the LED outputs. */\r
349         vParTestInitialise();\r
350 }\r
351 /*-----------------------------------------------------------*/\r
352 \r
353 void prvRegTest1Pass( void )\r
354 {\r
355         /* Called from the inline assembler - this cannot be static\r
356         otherwise it can get optimised away. */\r
357         ulRegTest1Counter++;\r
358 }\r
359 /*-----------------------------------------------------------*/\r
360 \r
361 void prvRegTest2Pass( void )\r
362 {\r
363         /* Called from the inline assembler - this cannot be static\r
364         otherwise it can get optimised away. */\r
365         ulRegTest2Counter++;\r
366 }\r
367 /*-----------------------------------------------------------*/\r
368 \r
369 void prvRegTestFail( void )\r
370 {\r
371         /* Called from the inline assembler - this cannot be static\r
372         otherwise it can get optimised away. */\r
373         xRegTestStatus = pdFAIL;\r
374 }\r
375 /*-----------------------------------------------------------*/\r
376 \r
377 static void prvRegTestTask1( void *pvParameters )\r
378 {\r
379         /* Just to remove compiler warning. */\r
380         ( void ) pvParameters;\r
381 \r
382         /* The first register test task as described at the top of this file.  The\r
383         values used in the registers are different to those use in the second \r
384         register test task.  Also, unlike the second register test task, this task\r
385         yields between setting the register values and subsequently checking the\r
386         register values. */\r
387         asm volatile\r
388         (\r
389                 "RegTest1Start:                                 \n\t" \\r
390                 "                                                               \n\t" \\r
391                 "       li              0, 301                          \n\t" \\r
392                 "       mtspr   256, 0  #USPRG0         \n\t" \\r
393                 "       li              0, 501                          \n\t" \\r
394                 "       mtspr   8, 0    #LR                     \n\t" \\r
395                 "       li              0, 4                            \n\t" \\r
396                 "       mtspr   1, 0    #XER            \n\t" \\r
397                 "                                                               \n\t" \\r
398                 "       li              0, 1                            \n\t" \\r
399                 "       li              2, 2                            \n\t" \\r
400                 "       li              3, 3                            \n\t" \\r
401                 "       li              4,      4                               \n\t" \\r
402                 "       li              5,      5                               \n\t" \\r
403                 "       li              6,      6                               \n\t" \\r
404                 "       li              7,      7                               \n\t" \\r
405                 "       li              8,      8                               \n\t" \\r
406                 "       li              9,      9                               \n\t" \\r
407                 "       li              10,     10                              \n\t" \\r
408                 "       li              11,     11                              \n\t" \\r
409                 "       li              12,     12                              \n\t" \\r
410                 "       li              13,     13                              \n\t" \\r
411                 "       li              14,     14                              \n\t" \\r
412                 "       li              15,     15                              \n\t" \\r
413                 "       li              16,     16                              \n\t" \\r
414                 "       li              17,     17                              \n\t" \\r
415                 "       li              18,     18                              \n\t" \\r
416                 "       li              19,     19                              \n\t" \\r
417                 "       li              20,     20                              \n\t" \\r
418                 "       li              21,     21                              \n\t" \\r
419                 "       li              22,     22                              \n\t" \\r
420                 "       li              23,     23                              \n\t" \\r
421                 "       li              24,     24                              \n\t" \\r
422                 "       li              25,     25                              \n\t" \\r
423                 "       li              26,     26                              \n\t" \\r
424                 "       li              27,     27                              \n\t" \\r
425                 "       li              28,     28                              \n\t" \\r
426                 "       li              29,     29                              \n\t" \\r
427                 "       li              30,     30                              \n\t" \\r
428                 "       li              31,     31                              \n\t" \\r
429                 "                                                               \n\t" \\r
430                 "       sc                                                      \n\t" \\r
431                 "       nop                                                     \n\t" \\r
432                 "                                                               \n\t" \\r
433                 "       cmpwi   0, 1                            \n\t" \\r
434                 "       bne     RegTest1Fail                    \n\t" \\r
435                 "       cmpwi   2, 2                            \n\t" \\r
436                 "       bne     RegTest1Fail                    \n\t" \\r
437                 "       cmpwi   3, 3                            \n\t" \\r
438                 "       bne     RegTest1Fail                    \n\t" \\r
439                 "       cmpwi   4, 4                            \n\t" \\r
440                 "       bne     RegTest1Fail                    \n\t" \\r
441                 "       cmpwi   5, 5                            \n\t" \\r
442                 "       bne     RegTest1Fail                    \n\t" \\r
443                 "       cmpwi   6, 6                            \n\t" \\r
444                 "       bne     RegTest1Fail                    \n\t" \\r
445                 "       cmpwi   7, 7                            \n\t" \\r
446                 "       bne     RegTest1Fail                    \n\t" \\r
447                 "       cmpwi   8, 8                            \n\t" \\r
448                 "       bne     RegTest1Fail                    \n\t" \\r
449                 "       cmpwi   9, 9                            \n\t" \\r
450                 "       bne     RegTest1Fail                    \n\t" \\r
451                 "       cmpwi   10, 10                          \n\t" \\r
452                 "       bne     RegTest1Fail                    \n\t" \\r
453                 "       cmpwi   11, 11                          \n\t" \\r
454                 "       bne     RegTest1Fail                    \n\t" \\r
455                 "       cmpwi   12, 12                          \n\t" \\r
456                 "       bne     RegTest1Fail                    \n\t" \\r
457                 "       cmpwi   13, 13                          \n\t" \\r
458                 "       bne     RegTest1Fail                    \n\t" \\r
459                 "       cmpwi   14, 14                          \n\t" \\r
460                 "       bne     RegTest1Fail                    \n\t" \\r
461                 "       cmpwi   15, 15                          \n\t" \\r
462                 "       bne     RegTest1Fail                    \n\t" \\r
463                 "       cmpwi   16, 16                          \n\t" \\r
464                 "       bne     RegTest1Fail                    \n\t" \\r
465                 "       cmpwi   17, 17                          \n\t" \\r
466                 "       bne     RegTest1Fail                    \n\t" \\r
467                 "       cmpwi   18, 18                          \n\t" \\r
468                 "       bne     RegTest1Fail                    \n\t" \\r
469                 "       cmpwi   19, 19                          \n\t" \\r
470                 "       bne     RegTest1Fail                    \n\t" \\r
471                 "       cmpwi   20, 20                          \n\t" \\r
472                 "       bne     RegTest1Fail                    \n\t" \\r
473                 "       cmpwi   21, 21                          \n\t" \\r
474                 "       bne     RegTest1Fail                    \n\t" \\r
475                 "       cmpwi   22, 22                          \n\t" \\r
476                 "       bne     RegTest1Fail                    \n\t" \\r
477                 "       cmpwi   23, 23                          \n\t" \\r
478                 "       bne     RegTest1Fail                    \n\t" \\r
479                 "       cmpwi   24, 24                          \n\t" \\r
480                 "       bne     RegTest1Fail                    \n\t" \\r
481                 "       cmpwi   25, 25                          \n\t" \\r
482                 "       bne     RegTest1Fail                    \n\t" \\r
483                 "       cmpwi   26, 26                          \n\t" \\r
484                 "       bne     RegTest1Fail                    \n\t" \\r
485                 "       cmpwi   27, 27                          \n\t" \\r
486                 "       bne     RegTest1Fail                    \n\t" \\r
487                 "       cmpwi   28, 28                          \n\t" \\r
488                 "       bne     RegTest1Fail                    \n\t" \\r
489                 "       cmpwi   29, 29                          \n\t" \\r
490                 "       bne     RegTest1Fail                    \n\t" \\r
491                 "       cmpwi   30, 30                          \n\t" \\r
492                 "       bne     RegTest1Fail                    \n\t" \\r
493                 "       cmpwi   31, 31                          \n\t" \\r
494                 "       bne     RegTest1Fail                    \n\t" \\r
495                 "                                                               \n\t" \\r
496                 "       mfspr   0, 256  #USPRG0         \n\t" \\r
497                 "       cmpwi   0, 301                          \n\t" \\r
498                 "       bne     RegTest1Fail                    \n\t" \\r
499                 "       mfspr   0, 8    #LR                     \n\t" \\r
500                 "       cmpwi   0, 501                          \n\t" \\r
501                 "       bne     RegTest1Fail                    \n\t" \\r
502                 "       mfspr   0, 1    #XER            \n\t" \\r
503                 "       cmpwi   0, 4                            \n\t" \\r
504                 "       bne     RegTest1Fail                    \n\t" \\r
505                 "                                                               \n\t" \\r
506                 "       bl prvRegTest1Pass                      \n\t" \\r
507                 "       b RegTest1Start                         \n\t" \\r
508                 "                                                               \n\t" \\r
509                 "RegTest1Fail:                                  \n\t" \\r
510                 "                                                               \n\t" \\r
511                 "                                                               \n\t" \\r
512                 "       bl prvRegTestFail                       \n\t" \\r
513                 "       b RegTest1Start                         \n\t" \\r
514         );\r
515 }\r
516 /*-----------------------------------------------------------*/\r
517 \r
518 static void prvRegTestTask2( void *pvParameters )\r
519 {\r
520         /* Just to remove compiler warning. */\r
521         ( void ) pvParameters;\r
522 \r
523         /* The second register test task as described at the top of this file.  \r
524         Note that this task fills the registers with different values to the\r
525         first register test task. */\r
526         asm volatile\r
527         (\r
528                 "RegTest2Start:                                 \n\t" \\r
529                 "                                                               \n\t" \\r
530                 "       li              0, 300                          \n\t" \\r
531                 "       mtspr   256, 0  #USPRG0         \n\t" \\r
532                 "       li              0, 500                          \n\t" \\r
533                 "       mtspr   8, 0    #LR                     \n\t" \\r
534                 "       li              0, 4                            \n\t" \\r
535                 "       mtspr   1, 0    #XER            \n\t" \\r
536                 "                                                               \n\t" \\r
537                 "       li              0, 11                           \n\t" \\r
538                 "       li              2, 12                           \n\t" \\r
539                 "       li              3, 13                           \n\t" \\r
540                 "       li              4,      14                              \n\t" \\r
541                 "       li              5,      15                              \n\t" \\r
542                 "       li              6,      16                              \n\t" \\r
543                 "       li              7,      17                              \n\t" \\r
544                 "       li              8,      18                              \n\t" \\r
545                 "       li              9,      19                              \n\t" \\r
546                 "       li              10,     110                             \n\t" \\r
547                 "       li              11,     111                             \n\t" \\r
548                 "       li              12,     112                             \n\t" \\r
549                 "       li              13,     113                             \n\t" \\r
550                 "       li              14,     114                             \n\t" \\r
551                 "       li              15,     115                             \n\t" \\r
552                 "       li              16,     116                             \n\t" \\r
553                 "       li              17,     117                             \n\t" \\r
554                 "       li              18,     118                             \n\t" \\r
555                 "       li              19,     119                             \n\t" \\r
556                 "       li              20,     120                             \n\t" \\r
557                 "       li              21,     121                             \n\t" \\r
558                 "       li              22,     122                             \n\t" \\r
559                 "       li              23,     123                             \n\t" \\r
560                 "       li              24,     124                             \n\t" \\r
561                 "       li              25,     125                             \n\t" \\r
562                 "       li              26,     126                             \n\t" \\r
563                 "       li              27,     127                             \n\t" \\r
564                 "       li              28,     128                             \n\t" \\r
565                 "       li              29,     129                             \n\t" \\r
566                 "       li              30,     130                             \n\t" \\r
567                 "       li              31,     131                             \n\t" \\r
568                 "                                                               \n\t" \\r
569                 "       cmpwi   0, 11                           \n\t" \\r
570                 "       bne     RegTest2Fail                    \n\t" \\r
571                 "       cmpwi   2, 12                           \n\t" \\r
572                 "       bne     RegTest2Fail                    \n\t" \\r
573                 "       cmpwi   3, 13                           \n\t" \\r
574                 "       bne     RegTest2Fail                    \n\t" \\r
575                 "       cmpwi   4, 14                           \n\t" \\r
576                 "       bne     RegTest2Fail                    \n\t" \\r
577                 "       cmpwi   5, 15                           \n\t" \\r
578                 "       bne     RegTest2Fail                    \n\t" \\r
579                 "       cmpwi   6, 16                           \n\t" \\r
580                 "       bne     RegTest2Fail                    \n\t" \\r
581                 "       cmpwi   7, 17                           \n\t" \\r
582                 "       bne     RegTest2Fail                    \n\t" \\r
583                 "       cmpwi   8, 18                           \n\t" \\r
584                 "       bne     RegTest2Fail                    \n\t" \\r
585                 "       cmpwi   9, 19                           \n\t" \\r
586                 "       bne     RegTest2Fail                    \n\t" \\r
587                 "       cmpwi   10, 110                         \n\t" \\r
588                 "       bne     RegTest2Fail                    \n\t" \\r
589                 "       cmpwi   11, 111                         \n\t" \\r
590                 "       bne     RegTest2Fail                    \n\t" \\r
591                 "       cmpwi   12, 112                         \n\t" \\r
592                 "       bne     RegTest2Fail                    \n\t" \\r
593                 "       cmpwi   13, 113                         \n\t" \\r
594                 "       bne     RegTest2Fail                    \n\t" \\r
595                 "       cmpwi   14, 114                         \n\t" \\r
596                 "       bne     RegTest2Fail                    \n\t" \\r
597                 "       cmpwi   15, 115                         \n\t" \\r
598                 "       bne     RegTest2Fail                    \n\t" \\r
599                 "       cmpwi   16, 116                         \n\t" \\r
600                 "       bne     RegTest2Fail                    \n\t" \\r
601                 "       cmpwi   17, 117                         \n\t" \\r
602                 "       bne     RegTest2Fail                    \n\t" \\r
603                 "       cmpwi   18, 118                         \n\t" \\r
604                 "       bne     RegTest2Fail                    \n\t" \\r
605                 "       cmpwi   19, 119                         \n\t" \\r
606                 "       bne     RegTest2Fail                    \n\t" \\r
607                 "       cmpwi   20, 120                         \n\t" \\r
608                 "       bne     RegTest2Fail                    \n\t" \\r
609                 "       cmpwi   21, 121                         \n\t" \\r
610                 "       bne     RegTest2Fail                    \n\t" \\r
611                 "       cmpwi   22, 122                         \n\t" \\r
612                 "       bne     RegTest2Fail                    \n\t" \\r
613                 "       cmpwi   23, 123                         \n\t" \\r
614                 "       bne     RegTest2Fail                    \n\t" \\r
615                 "       cmpwi   24, 124                         \n\t" \\r
616                 "       bne     RegTest2Fail                    \n\t" \\r
617                 "       cmpwi   25, 125                         \n\t" \\r
618                 "       bne     RegTest2Fail                    \n\t" \\r
619                 "       cmpwi   26, 126                         \n\t" \\r
620                 "       bne     RegTest2Fail                    \n\t" \\r
621                 "       cmpwi   27, 127                         \n\t" \\r
622                 "       bne     RegTest2Fail                    \n\t" \\r
623                 "       cmpwi   28, 128                         \n\t" \\r
624                 "       bne     RegTest2Fail                    \n\t" \\r
625                 "       cmpwi   29, 129                         \n\t" \\r
626                 "       bne     RegTest2Fail                    \n\t" \\r
627                 "       cmpwi   30, 130                         \n\t" \\r
628                 "       bne     RegTest2Fail                    \n\t" \\r
629                 "       cmpwi   31, 131                         \n\t" \\r
630                 "       bne     RegTest2Fail                    \n\t" \\r
631                 "                                                               \n\t" \\r
632                 "       mfspr   0, 256  #USPRG0         \n\t" \\r
633                 "       cmpwi   0, 300                          \n\t" \\r
634                 "       bne     RegTest2Fail                    \n\t" \\r
635                 "       mfspr   0, 8    #LR                     \n\t" \\r
636                 "       cmpwi   0, 500                          \n\t" \\r
637                 "       bne     RegTest2Fail                    \n\t" \\r
638                 "       mfspr   0, 1    #XER            \n\t" \\r
639                 "       cmpwi   0, 4                            \n\t" \\r
640                 "       bne     RegTest2Fail                    \n\t" \\r
641                 "                                                               \n\t" \\r
642                 "       bl prvRegTest2Pass                      \n\t" \\r
643                 "       b RegTest2Start                         \n\t" \\r
644                 "                                                               \n\t" \\r
645                 "RegTest2Fail:                                  \n\t" \\r
646                 "                                                               \n\t" \\r
647                 "                                                               \n\t" \\r
648                 "       bl prvRegTestFail                       \n\t" \\r
649                 "       b RegTest2Start                         \n\t" \\r
650         );\r
651 }\r
652 /*-----------------------------------------------------------*/\r
653 \r
654 /* This hook function will get called if there is a suspected stack overflow.\r
655 An overflow can cause the task name to be corrupted, in which case the task\r
656 handle needs to be used to determine the offending task. */\r
657 void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName );\r
658 void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName )\r
659 {\r
660 /* To prevent the optimiser removing the variables. */\r
661 volatile TaskHandle_t xTaskIn = xTask;\r
662 volatile signed char *pcTaskNameIn = pcTaskName;\r
663 \r
664         /* Remove compiler warnings. */\r
665         ( void ) xTaskIn;\r
666         ( void ) pcTaskNameIn;\r
667 \r
668         /* The following three calls are simply to stop compiler warnings about the\r
669         functions not being used - they are called from the inline assembly. */\r
670         prvRegTest1Pass();\r
671         prvRegTest2Pass();\r
672         prvRegTestFail();\r
673 \r
674         for( ;; );\r
675 }\r
676 \r
677 \r
678 \r