OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [RX600_RX62N-RSK_Renesas/] [RTOSDemo/] [main-full.c] - Blame information for rev 585

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 585 jeremybenn
/*
2
    FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
3
 
4
    ***************************************************************************
5
    *                                                                         *
6
    * If you are:                                                             *
7
    *                                                                         *
8
    *    + New to FreeRTOS,                                                   *
9
    *    + Wanting to learn FreeRTOS or multitasking in general quickly       *
10
    *    + Looking for basic training,                                        *
11
    *    + Wanting to improve your FreeRTOS skills and productivity           *
12
    *                                                                         *
13
    * then take a look at the FreeRTOS books - available as PDF or paperback  *
14
    *                                                                         *
15
    *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *
16
    *                  http://www.FreeRTOS.org/Documentation                  *
17
    *                                                                         *
18
    * A pdf reference manual is also available.  Both are usually delivered   *
19
    * to your inbox within 20 minutes to two hours when purchased between 8am *
20
    * and 8pm GMT (although please allow up to 24 hours in case of            *
21
    * exceptional circumstances).  Thank you for your support!                *
22
    *                                                                         *
23
    ***************************************************************************
24
 
25
    This file is part of the FreeRTOS distribution.
26
 
27
    FreeRTOS is free software; you can redistribute it and/or modify it under
28
    the terms of the GNU General Public License (version 2) as published by the
29
    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
30
    ***NOTE*** The exception to the GPL is included to allow you to distribute
31
    a combined work that includes FreeRTOS without being obliged to provide the
32
    source code for proprietary components outside of the FreeRTOS kernel.
33
    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
34
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
36
    more details. You should have received a copy of the GNU General Public
37
    License and the FreeRTOS license exception along with FreeRTOS; if not it
38
    can be viewed here: http://www.freertos.org/a00114.html and also obtained
39
    by writing to Richard Barry, contact details for whom are available on the
40
    FreeRTOS WEB site.
41
 
42
    1 tab == 4 spaces!
43
 
44
    http://www.FreeRTOS.org - Documentation, latest information, license and
45
    contact details.
46
 
47
    http://www.SafeRTOS.com - A version that is certified for use in safety
48
    critical systems.
49
 
50
    http://www.OpenRTOS.com - Commercial support, development, porting,
51
    licensing and training services.
52
*/
53
 
54
/* ****************************************************************************
55
 * This project includes a lot of tasks and tests and is therefore complex.
56
 * If you would prefer a much simpler project to get started with then select
57
 * the 'Blinky' build configuration within the HEW IDE.
58
 * ****************************************************************************
59
 *
60
 * Creates all the demo application tasks, then starts the scheduler.  The web
61
 * documentation provides more details of the standard demo application tasks,
62
 * which provide no particular functionality but do provide a good example of
63
 * how to use the FreeRTOS API.  The tasks defined in flop.c are included in the
64
 * set of standard demo tasks to ensure the floating point unit gets some
65
 * exercise.
66
 *
67
 * In addition to the standard demo tasks, the following tasks and tests are
68
 * defined and/or created within this file:
69
 *
70
 * Webserver ("uIP") task - This serves a number of dynamically generated WEB
71
 * pages to a standard WEB browser.  The IP and MAC addresses are configured by
72
 * constants defined at the bottom of FreeRTOSConfig.h.  Use either a standard
73
 * Ethernet cable to connect through a hug, or a cross over (point to point)
74
 * cable to connect directly.  Ensure the IP address used is compatible with the
75
 * IP address of the machine running the browser - the easiest way to achieve
76
 * this is to ensure the first three octets of the IP addresses are the same.
77
 *
78
 * "Reg test" tasks - These fill the registers with known values, then check
79
 * that each register still contains its expected value.  Each task uses
80
 * different values.  The tasks run with very low priority so get preempted
81
 * very frequently.  A check variable is incremented on each iteration of the
82
 * test loop.  A register containing an unexpected value is indicative of an
83
 * error in the context switching mechanism and will result in a branch to a
84
 * null loop - which in turn will prevent the check variable from incrementing
85
 * any further and allow the check task (described below) to determine that an
86
 * error has occurred.  The nature of the reg test tasks necessitates that they
87
 * are written in assembly code.
88
 *
89
 * "Check" task - This only executes every five seconds but has a high priority
90
 * to ensure it gets processor time.  Its main function is to check that all the
91
 * standard demo tasks are still operational.  While no errors have been
92
 * discovered the check task will toggle LED 5 every 5 seconds - the toggle
93
 * rate increasing to 200ms being a visual indication that at least one task has
94
 * reported unexpected behaviour.
95
 *
96
 * "High frequency timer test" - A high frequency periodic interrupt is
97
 * generated using a timer - the interrupt is assigned a priority above
98
 * configMAX_SYSCALL_INTERRUPT_PRIORITY so should not be effected by anything
99
 * the kernel is doing.  The frequency and priority of the interrupt, in
100
 * combination with other standard tests executed in this demo, should result
101
 * in interrupts nesting at least 3 and probably 4 deep.  This test is only
102
 * included in build configurations that have the optimiser switched on.  In
103
 * optimised builds the count of high frequency ticks is used as the time base
104
 * for the run time stats.
105
 *
106
 * *NOTE 1* If LED5 is toggling every 5 seconds then all the demo application
107
 * tasks are executing as expected and no errors have been reported in any
108
 * tasks.  The toggle rate increasing to 200ms indicates that at least one task
109
 * has reported unexpected behaviour.
110
 *
111
 * *NOTE 2* vApplicationSetupTimerInterrupt() is called by the kernel to let
112
 * the application set up a timer to generate the tick interrupt.  In this
113
 * example a compare match timer is used for this purpose.
114
 *
115
 * *NOTE 3* The CPU must be in Supervisor mode when the scheduler is started.
116
 * The PowerON_Reset_PC() supplied in resetprg.c with this demo has
117
 * Change_PSW_PM_to_UserMode() commented out to ensure this is the case.
118
 *
119
 * *NOTE 4* The IntQueue common demo tasks test interrupt nesting and make use
120
 * of all the 8bit timers (as two cascaded 16bit units).
121
*/
122
 
123
/* Hardware specific includes. */
124
#include "iodefine.h"
125
 
126
/* Kernel includes. */
127
#include "FreeRTOS.h"
128
#include "task.h"
129
 
130
/* Standard demo includes. */
131
#include "partest.h"
132
#include "flash.h"
133
#include "IntQueue.h"
134
#include "BlockQ.h"
135
#include "death.h"
136
#include "integer.h"
137
#include "blocktim.h"
138
#include "semtest.h"
139
#include "PollQ.h"
140
#include "GenQTest.h"
141
#include "QPeek.h"
142
#include "recmutex.h"
143
#include "flop.h"
144
 
145
/* Values that are passed into the reg test tasks using the task parameter.  The
146
tasks check that the values are passed in correctly. */
147
#define mainREG_TEST_1_PARAMETER        ( 0x12121212UL )
148
#define mainREG_TEST_2_PARAMETER        ( 0x12345678UL )
149
 
150
/* Priorities at which the tasks are created. */
151
#define mainCHECK_TASK_PRIORITY         ( configMAX_PRIORITIES - 1 )
152
#define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 1 )
153
#define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )
154
#define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )
155
#define mainCREATOR_TASK_PRIORITY   ( tskIDLE_PRIORITY + 3 )
156
#define mainFLASH_TASK_PRIORITY         ( tskIDLE_PRIORITY + 1 )
157
#define mainuIP_TASK_PRIORITY           ( tskIDLE_PRIORITY + 2 )
158
#define mainINTEGER_TASK_PRIORITY   ( tskIDLE_PRIORITY )
159
#define mainGEN_QUEUE_TASK_PRIORITY     ( tskIDLE_PRIORITY )
160
#define mainFLOP_TASK_PRIORITY          ( tskIDLE_PRIORITY )
161
 
162
/* The WEB server uses string handling functions, which in turn use a bit more
163
stack than most of the other tasks. */
164
#define mainuIP_STACK_SIZE                      ( configMINIMAL_STACK_SIZE * 3 )
165
 
166
/* The LED toggled by the check task. */
167
#define mainCHECK_LED                           ( 5 )
168
 
169
/* The rate at which mainCHECK_LED will toggle when all the tasks are running
170
without error.  Controlled by the check task as described at the top of this
171
file. */
172
#define mainNO_ERROR_CYCLE_TIME         ( 5000 / portTICK_RATE_MS )
173
 
174
/* The rate at which mainCHECK_LED will toggle when an error has been reported
175
by at least one task.  Controlled by the check task as described at the top of
176
this file. */
177
#define mainERROR_CYCLE_TIME            ( 200 / portTICK_RATE_MS )
178
 
179
/*
180
 * vApplicationMallocFailedHook() will only be called if
181
 * configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook
182
 * function that will execute if a call to pvPortMalloc() fails.
183
 * pvPortMalloc() is called internally by the kernel whenever a task, queue or
184
 * semaphore is created.  It is also called by various parts of the demo
185
 * application.
186
 */
187
void vApplicationMallocFailedHook( void );
188
 
189
/*
190
 * vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1
191
 * in FreeRTOSConfig.h.  It is a hook function that is called on each iteration
192
 * of the idle task.  It is essential that code added to this hook function
193
 * never attempts to block in any way (for example, call xQueueReceive() with
194
 * a block time specified).  If the application makes use of the vTaskDelete()
195
 * API function (as this demo application does) then it is also important that
196
 * vApplicationIdleHook() is permitted to return to its calling function because
197
 * it is the responsibility of the idle task to clean up memory allocated by the
198
 * kernel to any task that has since been deleted.
199
 */
200
void vApplicationIdleHook( void );
201
 
202
/*
203
 * vApplicationStackOverflowHook() will only be called if
204
 * configCHECK_FOR_STACK_OVERFLOW is set to a non-zero value.  The handle and
205
 * name of the offending task should be passed in the function parameters, but
206
 * it is possible that the stack overflow will have corrupted these - in which
207
 * case pxCurrentTCB can be inspected to find the same information.
208
 */
209
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName );
210
 
211
/*
212
 * The reg test tasks as described at the top of this file.
213
 */
214
static void prvRegTest1Task( void *pvParameters );
215
static void prvRegTest2Task( void *pvParameters );
216
 
217
/*
218
 * The actual implementation of the reg test functionality, which, because of
219
 * the direct register access, have to be in assembly.
220
 */
221
static void prvRegTest1Implementation( void );
222
static void prvRegTest2Implementation( void );
223
 
224
/*
225
 * The check task as described at the top of this file.
226
 */
227
static void prvCheckTask( void *pvParameters );
228
 
229
/*
230
 * Contains the implementation of the WEB server.
231
 */
232
extern void vuIP_Task( void *pvParameters );
233
 
234
/*-----------------------------------------------------------*/
235
 
236
/* Variables that are incremented on each iteration of the reg test tasks -
237
provided the tasks have not reported any errors.  The check task inspects these
238
variables to ensure they are still incrementing as expected.  If a variable
239
stops incrementing then it is likely that its associate task has stalled. */
240
unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;
241
 
242
/* The status message that is displayed at the bottom of the "task stats" web
243
page, which is served by the uIP task.  This will report any errors picked up
244
by the reg test task. */
245
const char *pcStatusMessage = "All tasks executing without error.";
246
 
247
/*-----------------------------------------------------------*/
248
 
249
void main(void)
250
{
251
extern void HardwareSetup( void );
252
 
253
        /* Renesas provided CPU configuration routine.  The clocks are configured in
254
        here. */
255
        HardwareSetup();
256
 
257
        /* Turn all LEDs off. */
258
        vParTestInitialise();
259
 
260
        /* Start the reg test tasks which test the context switching mechanism. */
261
        xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );
262
        xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );
263
 
264
        /* The web server task. */
265
        xTaskCreate( vuIP_Task, "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL );
266
 
267
        /* Start the check task as described at the top of this file. */
268
        xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE * 3, NULL, mainCHECK_TASK_PRIORITY, NULL );
269
 
270
        /* Create the standard demo tasks. */
271
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
272
        vCreateBlockTimeTasks();
273
        vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
274
        vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
275
        vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
276
        vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
277
        vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );
278
        vStartQueuePeekTasks();
279
        vStartRecursiveMutexTasks();
280
        vStartInterruptQueueTasks();
281
        vStartMathTasks( mainFLOP_TASK_PRIORITY );
282
 
283
        /* The suicide tasks must be created last as they need to know how many
284
        tasks were running prior to their creation in order to ascertain whether
285
        or not the correct/expected number of tasks are running at any given time. */
286
        vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
287
 
288
        /* Start the tasks running. */
289
        vTaskStartScheduler();
290
 
291
        /* If all is well we will never reach here as the scheduler will now be
292
        running.  If we do reach here then it is likely that there was insufficient
293
        heap available for the idle task to be created. */
294
        for( ;; );
295
}
296
/*-----------------------------------------------------------*/
297
 
298
static void prvCheckTask( void *pvParameters )
299
{
300
static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL;
301
portTickType xNextWakeTime, xCycleFrequency = mainNO_ERROR_CYCLE_TIME;
302
extern void vSetupHighFrequencyTimer( void );
303
 
304
        /* If this is being executed then the kernel has been started.  Start the high
305
        frequency timer test as described at the top of this file.  This is only
306
        included in the optimised build configuration - otherwise it takes up too much
307
        CPU time and can disrupt other tests. */
308
        #ifdef INCLUDE_HIGH_FREQUENCY_TIMER_TEST
309
                vSetupHighFrequencyTimer();
310
        #endif
311
 
312
        /* Initialise xNextWakeTime - this only needs to be done once. */
313
        xNextWakeTime = xTaskGetTickCount();
314
 
315
        for( ;; )
316
        {
317
                /* Place this task in the blocked state until it is time to run again. */
318
                vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );
319
 
320
                /* Check the standard demo tasks are running without error. */
321
                if( xAreGenericQueueTasksStillRunning() != pdTRUE )
322
                {
323
                        /* Increase the rate at which this task cycles, which will increase the
324
                        rate at which mainCHECK_LED flashes to give visual feedback that an error
325
                        has occurred. */
326
                        xCycleFrequency = mainERROR_CYCLE_TIME;
327
                        pcStatusMessage = "Error: GenQueue";
328
                }
329
                else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
330
                {
331
                        xCycleFrequency = mainERROR_CYCLE_TIME;
332
                        pcStatusMessage = "Error: QueuePeek";
333
                }
334
                else if( xAreBlockingQueuesStillRunning() != pdTRUE )
335
                {
336
                        xCycleFrequency = mainERROR_CYCLE_TIME;
337
                        pcStatusMessage = "Error: BlockQueue";
338
                }
339
                else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
340
                {
341
                        xCycleFrequency = mainERROR_CYCLE_TIME;
342
                        pcStatusMessage = "Error: BlockTime";
343
                }
344
                else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
345
                {
346
                        xCycleFrequency = mainERROR_CYCLE_TIME;
347
                        pcStatusMessage = "Error: SemTest";
348
                }
349
                else if( xArePollingQueuesStillRunning() != pdTRUE )
350
                {
351
                        xCycleFrequency = mainERROR_CYCLE_TIME;
352
                        pcStatusMessage = "Error: PollQueue";
353
                }
354
                else if( xIsCreateTaskStillRunning() != pdTRUE )
355
                {
356
                        xCycleFrequency = mainERROR_CYCLE_TIME;
357
                        pcStatusMessage = "Error: Death";
358
                }
359
                else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
360
                {
361
                        xCycleFrequency = mainERROR_CYCLE_TIME;
362
                        pcStatusMessage = "Error: IntMath";
363
                }
364
                else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
365
                {
366
                        xCycleFrequency = mainERROR_CYCLE_TIME;
367
                        pcStatusMessage = "Error: RecMutex";
368
                }
369
                else if( xAreIntQueueTasksStillRunning() != pdPASS )
370
                {
371
                        xCycleFrequency = mainERROR_CYCLE_TIME;
372
                        pcStatusMessage = "Error: IntQueue";
373
                }
374
                else if( xAreMathsTaskStillRunning() != pdPASS )
375
                {
376
                        xCycleFrequency = mainERROR_CYCLE_TIME;
377
                        pcStatusMessage = "Error: Flop";
378
                }
379
 
380
                /* Check the reg test tasks are still cycling.  They will stop incrementing
381
                their loop counters if they encounter an error. */
382
                if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )
383
                {
384
                        xCycleFrequency = mainERROR_CYCLE_TIME;
385
                        pcStatusMessage = "Error: RegTest1";
386
                }
387
 
388
                if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )
389
                {
390
                        xCycleFrequency = mainERROR_CYCLE_TIME;
391
                        pcStatusMessage = "Error: RegTest2";
392
                }
393
 
394
                ulLastRegTest1CycleCount = ulRegTest1CycleCount;
395
                ulLastRegTest2CycleCount = ulRegTest2CycleCount;
396
 
397
                /* Toggle the check LED to give an indication of the system status.  If
398
                the LED toggles every 5 seconds then everything is ok.  A faster toggle
399
                indicates an error. */
400
                vParTestToggleLED( mainCHECK_LED );
401
        }
402
}
403
/*-----------------------------------------------------------*/
404
 
405
/* The RX port uses this callback function to configure its tick interrupt.
406
This allows the application to choose the tick interrupt source. */
407
void vApplicationSetupTimerInterrupt( void )
408
{
409
        /* Enable compare match timer 0. */
410
        MSTP( CMT0 ) = 0;
411
 
412
        /* Interrupt on compare match. */
413
        CMT0.CMCR.BIT.CMIE = 1;
414
 
415
        /* Set the compare match value. */
416
        CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 );
417
 
418
        /* Divide the PCLK by 8. */
419
        CMT0.CMCR.BIT.CKS = 0;
420
 
421
        /* Enable the interrupt... */
422
        _IEN( _CMT0_CMI0 ) = 1;
423
 
424
        /* ...and set its priority to the application defined kernel priority. */
425
        _IPR( _CMT0_CMI0 ) = configKERNEL_INTERRUPT_PRIORITY;
426
 
427
        /* Start the timer. */
428
        CMT.CMSTR0.BIT.STR0 = 1;
429
}
430
/*-----------------------------------------------------------*/
431
 
432
/* This function is explained by the comments above its prototype at the top
433
of this file. */
434
void vApplicationMallocFailedHook( void )
435
{
436
        for( ;; );
437
}
438
/*-----------------------------------------------------------*/
439
 
440
/* This function is explained by the comments above its prototype at the top
441
of this file. */
442
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )
443
{
444
        for( ;; );
445
}
446
/*-----------------------------------------------------------*/
447
 
448
/* This function is explained by the comments above its prototype at the top
449
of this file. */
450
void vApplicationIdleHook( void )
451
{
452
}
453
/*-----------------------------------------------------------*/
454
 
455
/* This function is explained in the comments at the top of this file. */
456
static void prvRegTest1Task( void *pvParameters )
457
{
458
        if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_1_PARAMETER )
459
        {
460
                /* The parameter did not contain the expected value. */
461
                for( ;; )
462
                {
463
                        /* Stop the tick interrupt so its obvious something has gone wrong. */
464
                        taskDISABLE_INTERRUPTS();
465
                }
466
        }
467
 
468
        /* This is an inline asm function that never returns. */
469
        prvRegTest1Implementation();
470
}
471
/*-----------------------------------------------------------*/
472
 
473
/* This function is explained in the comments at the top of this file. */
474
static void prvRegTest2Task( void *pvParameters )
475
{
476
        if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_2_PARAMETER )
477
        {
478
                /* The parameter did not contain the expected value. */
479
                for( ;; )
480
                {
481
                        /* Stop the tick interrupt so its obvious something has gone wrong. */
482
                        taskDISABLE_INTERRUPTS();
483
                }
484
        }
485
 
486
        /* This is an inline asm function that never returns. */
487
        prvRegTest2Implementation();
488
}
489
/*-----------------------------------------------------------*/
490
 
491
/* This function is explained in the comments at the top of this file. */
492
#pragma inline_asm prvRegTest1Implementation
493
static void prvRegTest1Implementation( void )
494
{
495
        ; Put a known value in each register.
496
        MOV.L   #1, R1
497
        MOV.L   #2, R2
498
        MOV.L   #3, R3
499
        MOV.L   #4, R4
500
        MOV.L   #5, R5
501
        MOV.L   #6, R6
502
        MOV.L   #7, R7
503
        MOV.L   #8, R8
504
        MOV.L   #9, R9
505
        MOV.L   #10, R10
506
        MOV.L   #11, R11
507
        MOV.L   #12, R12
508
        MOV.L   #13, R13
509
        MOV.L   #14, R14
510
        MOV.L   #15, R15
511
 
512
        ; Loop, checking each itteration that each register still contains the
513
        ; expected value.
514
TestLoop1:
515
 
516
        ; Push the registers that are going to get clobbered.
517
        PUSHM   R14-R15
518
 
519
        ; Increment the loop counter to show this task is still getting CPU time.
520
        MOV.L   #_ulRegTest1CycleCount, R14
521
        MOV.L   [ R14 ], R15
522
        ADD             #1, R15
523
        MOV.L   R15, [ R14 ]
524
 
525
        ; Yield to extend the text coverage.  Set the bit in the ITU SWINTR register.
526
        MOV.L   #1, R14
527
        MOV.L   #0872E0H, R15
528
        MOV.B   R14, [R15]
529
        NOP
530
        NOP
531
 
532
        ; Restore the clobbered registers.
533
        POPM    R14-R15
534
 
535
        ; Now compare each register to ensure it still contains the value that was
536
        ; set before this loop was entered.
537
        CMP             #1, R1
538
        BNE             RegTest1Error
539
        CMP             #2, R2
540
        BNE             RegTest1Error
541
        CMP             #3, R3
542
        BNE             RegTest1Error
543
        CMP             #4, R4
544
        BNE             RegTest1Error
545
        CMP             #5, R5
546
        BNE             RegTest1Error
547
        CMP             #6, R6
548
        BNE             RegTest1Error
549
        CMP             #7, R7
550
        BNE             RegTest1Error
551
        CMP             #8, R8
552
        BNE             RegTest1Error
553
        CMP             #9, R9
554
        BNE             RegTest1Error
555
        CMP             #10, R10
556
        BNE             RegTest1Error
557
        CMP             #11, R11
558
        BNE             RegTest1Error
559
        CMP             #12, R12
560
        BNE             RegTest1Error
561
        CMP             #13, R13
562
        BNE             RegTest1Error
563
        CMP             #14, R14
564
        BNE             RegTest1Error
565
        CMP             #15, R15
566
        BNE             RegTest1Error
567
 
568
        ; All comparisons passed, start a new itteratio of this loop.
569
        BRA             TestLoop1
570
 
571
RegTest1Error:
572
        ; A compare failed, just loop here so the loop counter stops incrementing
573
        ; causing the check task to indicate the error.
574
        BRA RegTest1Error
575
}
576
/*-----------------------------------------------------------*/
577
 
578
/* This function is explained in the comments at the top of this file. */
579
#pragma inline_asm prvRegTest2Implementation
580
static void prvRegTest2Implementation( void )
581
{
582
        ; Put a known value in each register.
583
        MOV.L   #10, R1
584
        MOV.L   #20, R2
585
        MOV.L   #30, R3
586
        MOV.L   #40, R4
587
        MOV.L   #50, R5
588
        MOV.L   #60, R6
589
        MOV.L   #70, R7
590
        MOV.L   #80, R8
591
        MOV.L   #90, R9
592
        MOV.L   #100, R10
593
        MOV.L   #110, R11
594
        MOV.L   #120, R12
595
        MOV.L   #130, R13
596
        MOV.L   #140, R14
597
        MOV.L   #150, R15
598
 
599
        ; Loop, checking on each itteration that each register still contains the
600
        ; expected value.
601
TestLoop2:
602
 
603
        ; Push the registers that are going to get clobbered.
604
        PUSHM   R14-R15
605
 
606
        ; Increment the loop counter to show this task is still getting CPU time.
607
        MOV.L   #_ulRegTest2CycleCount, R14
608
        MOV.L   [ R14 ], R15
609
        ADD             #1, R15
610
        MOV.L   R15, [ R14 ]
611
 
612
        ; Restore the clobbered registers.
613
        POPM    R14-R15
614
 
615
        CMP             #10, R1
616
        BNE             RegTest2Error
617
        CMP             #20, R2
618
        BNE             RegTest2Error
619
        CMP             #30, R3
620
        BNE             RegTest2Error
621
        CMP             #40, R4
622
        BNE             RegTest2Error
623
        CMP             #50, R5
624
        BNE             RegTest2Error
625
        CMP             #60, R6
626
        BNE             RegTest2Error
627
        CMP             #70, R7
628
        BNE             RegTest2Error
629
        CMP             #80, R8
630
        BNE             RegTest2Error
631
        CMP             #90, R9
632
        BNE             RegTest2Error
633
        CMP             #100, R10
634
        BNE             RegTest2Error
635
        CMP             #110, R11
636
        BNE             RegTest2Error
637
        CMP             #120, R12
638
        BNE             RegTest2Error
639
        CMP             #130, R13
640
        BNE             RegTest2Error
641
        CMP             #140, R14
642
        BNE             RegTest2Error
643
        CMP             #150, R15
644
        BNE             RegTest2Error
645
 
646
        ; All comparisons passed, start a new itteratio of this loop.
647
        BRA             TestLoop2
648
 
649
RegTest2Error:
650
        ; A compare failed, just loop here so the loop counter stops incrementing
651
        ; - causing the check task to indicate the error.
652
        BRA RegTest2Error
653
}
654
/*-----------------------------------------------------------*/
655
 
656
char *pcGetTaskStatusMessage( void )
657
{
658
        /* Not bothered about a critical section here although technically because of
659
        the task priorities the pointer could change it will be atomic if not near
660
        atomic and its not critical. */
661
        return ( char * ) pcStatusMessage;
662
}
663
/*-----------------------------------------------------------*/
664
 
665
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.