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