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