Mercurial > flash_v2
annotate packages/kernel/current/tests/clock1.cxx @ 648:0c5540a10fcc
* tests/fptest.c: Changed to run for a constant time rather than a
constant number of iterations, with a shorter run time for
simulated targets.
| author | nickg |
|---|---|
| date | Wed, 19 Feb 2003 19:14:48 +0000 |
| parents | d2c90368aeef |
| children |
| rev | line source |
|---|---|
| 0 | 1 //========================================================================== |
| 2 // | |
| 3 // clock1.cxx | |
| 4 // | |
| 5 // Clock test 1 - Real Time Clock | |
| 6 // | |
| 7 //========================================================================== | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
8 //####ECOSGPLCOPYRIGHTBEGIN#### |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
9 // ------------------------------------------- |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
12 // |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
13 // eCos is free software; you can redistribute it and/or modify it under |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
14 // the terms of the GNU General Public License as published by the Free |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
15 // Software Foundation; either version 2 or (at your option) any later version. |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
16 // |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
20 // for more details. |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
21 // |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
22 // You should have received a copy of the GNU General Public License along |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
23 // with eCos; if not, write to the Free Software Foundation, Inc., |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
25 // |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
26 // As a special exception, if other files instantiate templates or use macros |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
27 // or inline functions from this file, or you compile this file and link it |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
28 // with other works to produce a work based on this file, this file does not |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
29 // by itself cause the resulting work to be covered by the GNU General Public |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
30 // License. However the source code for this file must still be made available |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
31 // in accordance with section (3) of the GNU General Public License. |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
32 // |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
33 // This exception does not invalidate any other reasons why a work based on |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
34 // this file might be covered by the GNU General Public License. |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
35 // |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
|
210
d2c90368aeef
Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents:
208
diff
changeset
|
37 // at http://sources.redhat.com/ecos/ecos-license/ |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
38 // ------------------------------------------- |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
39 //####ECOSGPLCOPYRIGHTEND#### |
| 0 | 40 //========================================================================== |
| 41 //#####DESCRIPTIONBEGIN#### | |
| 42 // | |
| 43 // Author(s): dsm | |
| 44 // Contributors: dsm | |
| 45 // Date: 1998-02-16 | |
| 46 // Description: Tests the Kernel Real Time Clock | |
| 47 // This test creates a thread, starts the scheduler and | |
| 48 // delays for a time of about 5 seconds. This test should | |
| 49 // be expected to run for about this length of time. | |
| 50 // Omissions: | |
| 51 // Doesn't test alarms attached to RTC. | |
| 52 // Assumptions: | |
| 53 // CYGVAR_KERNEL_COUNTERS_CLOCK must be set. | |
| 54 // Resolution of clock small compared with 5s. | |
| 55 // Overhead small compared with 5s. | |
| 56 // Options: | |
| 57 // CYGIMP_KERNEL_COUNTERS_SINGLE_LIST | |
| 58 // CYGIMP_KERNEL_COUNTERS_MULTI_LIST | |
| 59 // CYGVAR_KERNEL_COUNTERS_CLOCK | |
| 60 // CYGNUM_KERNEL_COUNTERS_MULTI_LIST_SIZE | |
| 61 //####DESCRIPTIONEND#### | |
| 62 | |
| 63 #include <pkgconf/kernel.h> | |
| 64 | |
| 65 #include <cyg/kernel/clock.hxx> | |
| 66 #include <cyg/kernel/thread.hxx> | |
| 67 | |
| 68 #include <cyg/infra/testcase.h> | |
| 69 | |
| 70 #include <cyg/kernel/clock.inl> | |
| 71 #include <cyg/kernel/thread.inl> | |
| 72 | |
| 73 #ifdef CYGVAR_KERNEL_COUNTERS_CLOCK | |
| 74 | |
| 75 | |
| 76 #define NTHREADS 1 | |
| 77 #include "testaux.hxx" | |
| 78 | |
| 79 static cyg_uint32 ticks; // Number of ticks thread[0] will delay for | |
| 80 | |
| 2 | 81 static cyg_uint64 TEST_DELAY; |
| 82 | |
| 0 | 83 static void entry0( CYG_ADDRWORD data ) |
| 84 { | |
| 85 ((Cyg_Thread *)data)->delay(ticks); | |
| 86 | |
| 87 CYG_TEST_PASS_FINISH("Clock 1 OK"); | |
| 88 } | |
| 89 | |
| 90 void clock1_main( void ) | |
| 91 { | |
| 92 CYG_TEST_INIT(); | |
| 93 | |
| 2 | 94 if (cyg_test_is_simulator) { |
| 95 TEST_DELAY = 100000000ll; | |
| 96 } else { | |
| 97 TEST_DELAY = 3000000000ll; | |
| 98 } | |
| 99 | |
| 0 | 100 new_thread(entry0, (CYG_ADDRWORD)&thread_obj[0]); |
| 101 | |
| 102 Cyg_Clock::cyg_resolution res; | |
| 103 | |
| 104 res = Cyg_Clock::real_time_clock->get_resolution (); | |
| 105 | |
| 106 // RTC takes res.dividend/res.divisor ns/tick | |
| 107 ticks = ((cyg_uint64)TEST_DELAY * res.divisor) / res.dividend; | |
| 108 | |
| 109 Cyg_Scheduler::start(); | |
| 110 } | |
| 111 | |
| 112 externC void | |
| 113 cyg_start( void ) | |
| 114 { | |
|
130
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
115 #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
|
116 cyg_hal_invoke_constructors(); |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
117 #endif |
| 0 | 118 clock1_main(); |
| 119 } | |
| 120 | |
| 121 #else // def CYGVAR_KERNEL_COUNTERS_CLOCK | |
| 122 | |
| 123 externC void | |
| 124 cyg_start( void ) | |
| 125 { | |
| 126 CYG_TEST_INIT(); | |
| 2 | 127 CYG_TEST_NA( "Kernel real-time clock disabled"); |
| 0 | 128 } |
| 129 | |
| 130 #endif // def CYGVAR_KERNEL_COUNTERS_CLOCK | |
| 131 | |
| 132 // EOF clock1.cxx |
