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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [powerpc/] [viper/] [current/] [tests/] [vipertime.cxx] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
/*=================================================================
2
//
3
//        vipertime.cxx
4
//
5
//        PowerPC VIPER HAL timing tests
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later
16
// version.
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
// for more details.
22
//
23
// You should have received a copy of the GNU General Public License
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
26
//
27
// As a special exception, if other files instantiate templates or use
28
// macros or inline functions from this file, or you compile this file
29
// and link it with other works to produce a work based on this file,
30
// this file does not by itself cause the resulting work to be covered by
31
// the GNU General Public License. However the source code for this file
32
// must still be made available in accordance with section (3) of the GNU
33
// General Public License v2.
34
//
35
// This exception does not invalidate any other reasons why a work based
36
// on this file might be covered by the GNU General Public License.
37
// -------------------------------------------
38
// ####ECOSGPLCOPYRIGHTEND####
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):     hmt
43
// Contributors:  hmt
44
// Date:          1999-06-01
45
//####DESCRIPTIONEND####
46
*/
47
 
48
#include <pkgconf/system.h>
49
#include <pkgconf/hal.h>
50
 
51
#include <cyg/infra/cyg_type.h>
52
#include <cyg/infra/cyg_ass.h>
53
#include <cyg/infra/testcase.h>
54
 
55
#ifdef CYGPKG_KERNEL
56
 
57
#include <pkgconf/kernel.h>
58
 
59
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK
60
 
61
#include <cyg/hal/hal_arch.h>
62
#include <cyg/hal/hal_intr.h>
63
#include <cyg/hal/hal_diag.h>
64
 
65
#include <pkgconf/infra.h>
66
 
67
#include <cyg/infra/diag.h>
68
 
69
#include <cyg/kernel/thread.hxx>
70
#include <cyg/kernel/thread.inl>
71
#include <cyg/kernel/sched.hxx>
72
#include <cyg/kernel/sched.inl>
73
 
74
// ------------------------------------------------------------------------
75
 
76
externC void hal_viper_flash_led( int count );
77
externC void hal_viper_set_led( int val );
78
 
79
// -------------------------------------------------------------------------
80
 
81
static void entry1( CYG_ADDRWORD arg )
82
{
83
    int i;
84
    char *s = "tick 00";
85
    extern Cyg_Thread thread2;
86
    CYG_TEST_INFO( "Starting measured seconds..." );
87
    for ( i = 0; i < 20 ; i++ ) {
88
        Cyg_Thread::self()->delay( 100 ); // units should be centiSeconds
89
 
90
        hal_viper_set_led( ((~i) & 7)<<1 );
91
 
92
        if ( '9' == s[ 6 ]++ ) {
93
            s[ 6 ] = '0';
94
            s[ 5 ] ++;
95
        }
96
        CYG_TEST_INFO( s );
97
    }
98
 
99
    CYG_TEST_PASS( "Done measured seconds..." );
100
 
101
    hal_viper_flash_led( 5 );
102
 
103
    thread2.resume();
104
}
105
 
106
//---------------------------------------------------------------
107
 
108
#define LOOPS 30
109
 
110
int loops[ LOOPS ] = { 0,0,0,0,0 , 0,0,0,0,0 ,
111
                       0,0,0,0,0 , 0,0,0,0,0 ,
112
                       0,0,0,0,0 , 0,0,0,0,0 };
113
 
114
char s[] = "0 count 00 loops 00000";
115
 
116
static void entry2( CYG_ADDRWORD arg )
117
{
118
#if 0 // Do not bother with this on PPC
119
    int i, t1, t2, a;
120
    for ( a = 0; a < 10; a++, (*s)++ ) {
121
        CYG_TEST_INFO( "------------------------------------------" );
122
        HAL_CLOCK_READ( &t1 );
123
        do {
124
            t2 = t1;
125
            HAL_CLOCK_READ( &t1 );
126
        } while ( t1 >= t2 );
127
 
128
        for ( i = 0; i < LOOPS; i++ ) {
129
            register int z = 0;
130
            while ( t1 <= i ) {
131
                z++;
132
                HAL_CLOCK_READ( &t1 );
133
            }
134
            loops[ i ] = z;
135
        }
136
 
137
        s[9] = '0';
138
        s[8] = '0';
139
        for ( i = 0; i < LOOPS; i++ ) {
140
            s[ sizeof( s ) - 2 ] = '0' + loops[ i ] / 1       % 10;
141
            s[ sizeof( s ) - 3 ] = '0' + loops[ i ] / 10      % 10;
142
            s[ sizeof( s ) - 4 ] = '0' + loops[ i ] / 100     % 10;
143
            s[ sizeof( s ) - 5 ] = '0' + loops[ i ] / 1000    % 10;
144
            s[ sizeof( s ) - 6 ] = '0' + loops[ i ] / 10000   % 10;
145
            CYG_TEST_INFO( s );
146
            if ( '9' == s[9]++ ) {
147
                s[9] = '0';
148
                s[8]++;
149
            }
150
        }
151
    }
152
#endif
153
    CYG_TEST_PASS( "Counted loops per timer tick" );
154
    CYG_TEST_EXIT( "All done" );
155
}
156
 
157
// -------------------------------------------------------------------------
158
 
159
static char stack1[ CYGNUM_HAL_STACK_SIZE_TYPICAL ];
160
static char stack2[ CYGNUM_HAL_STACK_SIZE_TYPICAL ];
161
 
162
static Cyg_Thread thread1     CYG_INIT_PRIORITY( APPLICATION )
163
 = Cyg_Thread( 2u, entry1, 0u, "timed minute thread",
164
               (CYG_ADDRWORD)stack1,
165
               (CYG_ADDRWORD)CYGNUM_HAL_STACK_SIZE_TYPICAL );
166
 
167
static Cyg_Thread thread2     CYG_INIT_PRIORITY( APPLICATION )
168
 = Cyg_Thread( 4u, entry2, 0u, "uS clock loops timing thread",
169
               (CYG_ADDRWORD)stack2,
170
               (CYG_ADDRWORD)CYGNUM_HAL_STACK_SIZE_TYPICAL );
171
 
172
// -------------------------------------------------------------------------
173
 
174
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
175
externC void
176
cyg_hal_invoke_constructors();
177
#endif
178
 
179
externC void
180
cyg_user_start( void )
181
{
182
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
183
    cyg_hal_invoke_constructors();
184
#endif
185
    CYG_TEST_INIT();
186
    CYG_TEST_INFO( "cyg_user_start()" );
187
    thread1.resume();
188
}
189
 
190
// -------------------------------------------------------------------------
191
 
192
#else  // ! CYGVAR_KERNEL_COUNTERS_CLOCK
193
#define N_A_MSG "no kernel clock"
194
#endif // CYGVAR_KERNEL_COUNTERS_CLOCK
195
#else  // ! CYGPKG_KERNEL
196
#define N_A_MSG "no kernel"
197
#endif // CYGPKG_KERNEL
198
 
199
#ifdef N_A_MSG
200
externC void
201
cyg_start( void )
202
{
203
    CYG_TEST_INIT();
204
    CYG_TEST_NA( N_A_MSG );
205
}
206
#endif // N_A_MSG defined ie. we are N/A.
207
 
208
/* EOF vipertime.cxx */

powered by: WebSVN 2.1.0

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