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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [sparclite/] [sleb/] [v2_0/] [tests/] [slebtime.cxx] - Blame information for rev 616

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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