annotate packages/devs/wallclock/current/src/emulate.cxx @ 66:bf00f99aec69 ecos-sw-2000-02-02

Merge from eCos master repository on 2000-02-02-19:16:44-GMT
author jlarmour
date Wed, 02 Feb 2000 19:57:02 +0000
parents c38311975d4f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
1 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
2 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
3 // devs/wallclock/emulate.cxx
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
4 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
5 // Wallclock emulation implementation
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
6 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
7 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
8 //####COPYRIGHTBEGIN####
64
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
9 //
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
10 // -------------------------------------------
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
11 // The contents of this file are subject to the Red Hat eCos Public License
66
bf00f99aec69 Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents: 64
diff changeset
12 // Version 1.1 (the "License"); you may not use this file except in
64
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
13 // compliance with the License. You may obtain a copy of the License at
66
bf00f99aec69 Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents: 64
diff changeset
14 // http://www.redhat.com/
64
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
15 //
66
bf00f99aec69 Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents: 64
diff changeset
16 // Software distributed under the License is distributed on an "AS IS"
64
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
18 // License for the specific language governing rights and limitations under
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
19 // the License.
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
20 //
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
21 // The Original Code is eCos - Embedded Configurable Operating System,
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
22 // released September 30, 1998.
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
23 //
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
24 // The Initial Developer of the Original Code is Red Hat.
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
25 // Portions created by Red Hat are
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
27 // All Rights Reserved.
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
28 // -------------------------------------------
c38311975d4f Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents: 24
diff changeset
29 //
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
30 //####COPYRIGHTEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
31 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
32 //#####DESCRIPTIONBEGIN####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
33 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
34 // Author(s): nickg
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
35 // Contributors: nickg
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
36 // Date: 1999-03-05
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
37 // Purpose: Wallclock emulation
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
38 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
39 //####DESCRIPTIONEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
40 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
41 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
42
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
43 #include <pkgconf/wallclock.h> // Wallclock device config
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
44
24
306eee292492 Merge from eCos master repository on 1999-07-16-05:47:06-BST
jlarmour
parents: 2
diff changeset
45 #ifdef CYGIMP_WALLCLOCK_EMULATE
306eee292492 Merge from eCos master repository on 1999-07-16-05:47:06-BST
jlarmour
parents: 2
diff changeset
46
306eee292492 Merge from eCos master repository on 1999-07-16-05:47:06-BST
jlarmour
parents: 2
diff changeset
47 #include <pkgconf/kernel.h> // Kernel config
306eee292492 Merge from eCos master repository on 1999-07-16-05:47:06-BST
jlarmour
parents: 2
diff changeset
48
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
49 #include <cyg/infra/cyg_type.h> // Common type definitions and support
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
50 #include <cyg/hal/hal_diag.h> // HAL diagnostic output
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
51
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
52 #include <cyg/devs/wallclock.hxx>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
53
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
54 #include <cyg/kernel/ktypes.h>
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
55 #include <cyg/kernel/sched.hxx>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
56 #include <cyg/kernel/clock.hxx>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
57
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
58 #include <cyg/kernel/sched.inl>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
59
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
60
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
61 /*---------------------------------------------------------------------------*/
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
62 // Local static variables
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
63
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
64 static Cyg_WallClock wallclock_instance CYG_INIT_PRIORITY( CLOCK );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
65
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
66 static cyg_tick_count epoch_ticks;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
67
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
68 static cyg_uint32 epoch_time_stamp;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
69
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
70 Cyg_WallClock *Cyg_WallClock::wallclock;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
71
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
72 /*---------------------------------------------------------------------------*/
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
73 // Constructor
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
74
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
75 Cyg_WallClock::Cyg_WallClock()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
76 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
77 // install instance pointer
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
78 wallclock = &wallclock_instance;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
79 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
80
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
81 /*---------------------------------------------------------------------------*/
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
82 // Returns the current timestamp. This may involve reading the
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
83 // hardware, so it may take anything up to a second to complete.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
84
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
85 cyg_uint32 Cyg_WallClock::get_current_time()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
86 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
87 Cyg_Clock::cyg_resolution res = Cyg_Clock::real_time_clock->get_resolution();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
88
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
89 Cyg_Scheduler::lock();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
90
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
91 cyg_tick_count diff = Cyg_Clock::real_time_clock->current_value()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
92 - epoch_ticks;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
93
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
94 diff = ( diff * res.dividend ) / ( res.divisor * 1000000000LL ) ;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
95
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
96 Cyg_Scheduler::unlock();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
97
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
98 return epoch_time_stamp + diff;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
99 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
100
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
101 /*---------------------------------------------------------------------------*/
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
102 // Sets the value of the timestamp relative to now. This may involve
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
103 // writing to the hardware, so it may take anything up to a second to
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
104 // complete.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
105 void Cyg_WallClock::set_current_time( cyg_uint32 time_stamp )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
106 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
107 Cyg_Scheduler::lock();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
108
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
109 epoch_time_stamp = time_stamp;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
110 epoch_ticks = Cyg_Clock::real_time_clock->current_value();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
111
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
112 Cyg_Scheduler::unlock();
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
113 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
114
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
115 /*---------------------------------------------------------------------------*/
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
116
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
117 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
118 /*---------------------------------------------------------------------------*/
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
119 /* End of devs/wallclock/emulate.cxx */