Mercurial > ecos-v3_0-branch
annotate packages/hal/sparclite/sleb/current/tests/slebtime.cxx @ 2729:74dbf4c3f2e1 after-copyright-change-20090129
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
| author | jlarmour |
|---|---|
| date | Thu, 29 Jan 2009 17:47:46 +0000 |
| parents | d2c90368aeef |
| children |
| rev | line source |
|---|---|
| 2 | 1 /*================================================================= |
| 2 // | |
| 3 // slebtime.cxx | |
| 4 // | |
| 5 // SPARClite HAL timing tests | |
| 6 // | |
| 7 //========================================================================== | |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
8 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
9 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
12 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
13 // eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
14 // the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
15 // Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
16 // version. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
17 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
18 // eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
21 // for more details. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
22 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
23 // You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
24 // along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
26 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
27 // As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
28 // macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
29 // and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
30 // this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
31 // the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
32 // must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
33 // General Public License v2. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
34 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
35 // This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
36 // on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
37 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
38 // ####ECOSGPLCOPYRIGHTEND#### |
| 2 | 39 //========================================================================== |
| 40 //#####DESCRIPTIONBEGIN#### | |
| 41 // | |
| 42 // Author(s): dsm | |
| 43 // Contributors: dsm, nickg | |
| 44 // Date: 1998-06-18 | |
| 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 #include <cyg/hal/hal_clock.h> | |
| 65 | |
| 66 #include <pkgconf/infra.h> | |
| 67 | |
| 68 #include <cyg/infra/diag.h> | |
| 69 | |
| 70 #include <cyg/kernel/thread.hxx> | |
| 71 #include <cyg/kernel/thread.inl> | |
| 72 #include <cyg/kernel/sched.hxx> | |
| 73 #include <cyg/kernel/sched.inl> | |
| 74 | |
| 75 // ------------------------------------------------------------------------- | |
| 76 | |
| 77 static void entry1( CYG_ADDRWORD arg ) | |
| 78 { | |
| 79 int i; | |
| 80 char *s = "tick 00"; | |
| 81 extern Cyg_Thread thread2; | |
| 82 CYG_TEST_INFO( "Starting measured seconds..." ); | |
| 83 for ( i = 0; i < 20 ; i++ ) { | |
| 84 Cyg_Thread::self()->delay( 100 ); // units should be centiSeconds | |
| 85 if ( '9' == s[ 6 ]++ ) { | |
| 86 s[ 6 ] = '0'; | |
| 87 s[ 5 ] ++; | |
| 88 } | |
| 89 CYG_TEST_INFO( s ); | |
| 90 } | |
| 91 CYG_TEST_PASS( "Done measured seconds..." ); | |
| 92 thread2.resume(); | |
| 93 } | |
| 94 | |
| 95 static void entry2( CYG_ADDRWORD arg ) | |
| 96 { | |
| 97 #define LOOPS 30 | |
| 98 int i, t1, t2, a; | |
| 99 int loops[ LOOPS ] = { 0,0,0,0,0 , 0,0,0,0,0 , | |
| 100 0,0,0,0,0 , 0,0,0,0,0 , | |
| 101 0,0,0,0,0 , 0,0,0,0,0 }; | |
| 102 | |
| 103 char s[] = "0 count 00 loops 00000"; | |
| 104 | |
| 105 for ( a = 0; a < 10; a++, (*s)++ ) { | |
| 106 CYG_TEST_INFO( "------------------------------------------" ); | |
| 107 HAL_CLOCK_READ( &t1 ); | |
| 108 do { | |
| 109 t2 = t1; | |
| 110 HAL_CLOCK_READ( &t1 ); | |
| 111 } while ( t1 >= t2 ); | |
| 112 | |
| 113 for ( i = 0; i < LOOPS; i++ ) { | |
| 114 register int z = 0; | |
| 115 while ( t1 <= i ) { | |
| 116 z++; | |
| 117 HAL_CLOCK_READ( &t1 ); | |
| 118 } | |
| 119 loops[ i ] = z; | |
| 120 } | |
| 121 | |
| 122 s[9] = '0'; | |
| 123 s[8] = '0'; | |
| 124 for ( i = 0; i < LOOPS; i++ ) { | |
|
16
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
125 s[ sizeof( s ) - 2 ] = '0' + loops[ i ] / 1 % 10; |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
126 s[ sizeof( s ) - 3 ] = '0' + loops[ i ] / 10 % 10; |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
127 s[ sizeof( s ) - 4 ] = '0' + loops[ i ] / 100 % 10; |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
128 s[ sizeof( s ) - 5 ] = '0' + loops[ i ] / 1000 % 10; |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
129 s[ sizeof( s ) - 6 ] = '0' + loops[ i ] / 10000 % 10; |
| 2 | 130 CYG_TEST_INFO( s ); |
| 131 if ( '9' == s[9]++ ) { | |
| 132 s[9] = '0'; | |
| 133 s[8]++; | |
| 134 } | |
| 135 } | |
| 136 } | |
| 137 CYG_TEST_PASS( "Counted loops per timer tick" ); | |
| 138 CYG_TEST_EXIT( "All done" ); | |
| 139 } | |
| 140 | |
| 141 // ------------------------------------------------------------------------- | |
| 142 | |
| 143 static char stack1[ CYGNUM_HAL_STACK_SIZE_TYPICAL ]; | |
| 144 static char stack2[ CYGNUM_HAL_STACK_SIZE_TYPICAL ]; | |
| 145 | |
| 146 static Cyg_Thread thread1 CYG_INIT_PRIORITY( APPLICATION ) | |
| 147 = Cyg_Thread( 2u, entry1, 0u, "timed minute thread", | |
| 148 (CYG_ADDRWORD)stack1, | |
| 149 (CYG_ADDRWORD)CYGNUM_HAL_STACK_SIZE_TYPICAL ); | |
| 150 | |
| 151 static Cyg_Thread thread2 CYG_INIT_PRIORITY( APPLICATION ) | |
| 152 = Cyg_Thread( 4u, entry2, 0u, "uS clock loops timing thread", | |
| 153 (CYG_ADDRWORD)stack2, | |
| 154 (CYG_ADDRWORD)CYGNUM_HAL_STACK_SIZE_TYPICAL ); | |
| 155 | |
| 156 // ------------------------------------------------------------------------- | |
| 157 | |
|
130
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
158 #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
159 externC void |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
160 cyg_hal_invoke_constructors(); |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
161 #endif |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
162 |
| 2 | 163 externC void |
| 164 cyg_user_start( void ) | |
| 165 { | |
|
130
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
166 #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
167 cyg_hal_invoke_constructors(); |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
168 #endif |
| 2 | 169 CYG_TEST_INIT(); |
| 170 CYG_TEST_INFO( "cyg_user_start()" ); | |
| 171 thread1.resume(); | |
| 172 } | |
| 173 | |
| 174 // ------------------------------------------------------------------------- | |
| 175 | |
| 176 #else // ! CYGVAR_KERNEL_COUNTERS_CLOCK | |
| 177 #define N_A_MSG "no kernel clock" | |
| 178 #endif // CYGVAR_KERNEL_COUNTERS_CLOCK | |
| 179 #else // ! CYGPKG_KERNEL | |
| 180 #define N_A_MSG "no kernel" | |
| 181 #endif // CYGPKG_KERNEL | |
| 182 | |
| 183 #ifdef N_A_MSG | |
| 184 externC void | |
| 185 cyg_start( void ) | |
| 186 { | |
| 187 CYG_TEST_INIT(); | |
| 188 CYG_TEST_NA( N_A_MSG ); | |
| 189 } | |
| 190 #endif // N_A_MSG defined ie. we are N/A. | |
| 191 | |
| 192 /* EOF slebtime.cxx */ |
