source: rtems/cpukit/score/include/rtems/score/tod.h @ 3a4ae6c

4.104.114.84.95
Last change on this file since 3a4ae6c was 3a4ae6c, checked in by Joel Sherrill <joel.sherrill@…>, on 09/11/95 at 19:35:39

The word "RTEMS" almost completely removed from the core.

Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.

Configuration parameter maximum_devices added.

Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.

Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.

Added user extension for post-switch.

Utilized user extensions to implement API specific functionality
like signal dispatching.

Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.

Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.

All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.

Updated spsize to reflect new and moved variables.

Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.

Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.

  • Property mode set to 100644
File size: 6.8 KB
Line 
1/*  tod.h
2 *
3 *  This include file contains all the constants and structures associated
4 *  with the Time of Day Handler.
5 *
6 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
7 *  On-Line Applications Research Corporation (OAR).
8 *  All rights assigned to U.S. Government, 1994.
9 *
10 *  This material may be reproduced by or for the U.S. Government pursuant
11 *  to the copyright license under the clause at DFARS 252.227-7013.  This
12 *  notice must appear in all copies of this file and its derivatives.
13 *
14 *  $Id$
15 */
16
17#ifndef __TIME_OF_DAY_h
18#define __TIME_OF_DAY_h
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <rtems/core/object.h>
25#include <rtems/core/watchdog.h>
26
27/*
28 *  The following constants are related to the time of day.
29 */
30
31#define TOD_SECONDS_PER_MINUTE 60
32#define TOD_MINUTES_PER_HOUR   60
33#define TOD_MONTHS_PER_YEAR    12
34#define TOD_DAYS_PER_YEAR      365
35#define TOD_HOURS_PER_DAY      24
36#define TOD_SECONDS_PER_DAY    (TOD_SECONDS_PER_MINUTE * \
37                                TOD_MINUTES_PER_HOUR   * \
38                                TOD_HOURS_PER_DAY)
39
40#define TOD_MICROSECONDS_PER_SECOND 1000000
41#define TOD_MILLISECONDS_PER_SECOND 1000
42
43/*
44 *  The following constant define the earliest year to which an
45 *  time of day can be initialized.  This is considered the
46 *  epoch.
47 */
48
49#define TOD_BASE_YEAR 1988
50
51/*
52 *  The following record defines the time of control block.  This
53 *  control block is used to maintain the current time of day.
54 */
55
56typedef struct {                   /* RTEID style time/date */
57  unsigned32 year;                 /* year, A.D. */
58  unsigned32 month;                /* month, 1 -> 12 */
59  unsigned32 day;                  /* day, 1 -> 31 */
60  unsigned32 hour;                 /* hour, 0 -> 23 */
61  unsigned32 minute;               /* minute, 0 -> 59 */
62  unsigned32 second;               /* second, 0 -> 59 */
63  unsigned32 ticks;                /* elapsed ticks between secs */
64}   TOD_Control;
65
66/*
67 *  The following contains the current time of day.
68 */
69
70EXTERN TOD_Control _TOD_Current;
71
72/*
73 *  The following contains the number of seconds from 00:00:00
74 *  January 1, TOD_BASE_YEAR until the current time of day.
75 */
76
77EXTERN Watchdog_Interval _TOD_Seconds_since_epoch;
78
79/*
80 *  The following contains the number of ticks since the
81 *  system was booted.
82 */
83
84EXTERN Watchdog_Interval _TOD_Ticks_since_boot;
85
86/*
87 *  The following contains the number of microseconds per tick.
88 */
89
90EXTERN unsigned32 _TOD_Microseconds_per_tick;
91
92/*
93 *  The following contains the number of clock ticks per second.
94 *
95 *  NOTE:
96 *
97 *  If one second is NOT evenly divisible by the number of microseconds
98 *  per clock tick, this value will contain only the integer portion
99 *  of the division.  This means that the interval between clock ticks
100 *  can be a source of error in the current time of day.
101 */
102
103EXTERN unsigned32 _TOD_Ticks_per_second;
104
105/*
106 *  This is the control structure for the watchdog timer which
107 *  fires to service the seconds chain.
108 */
109
110EXTERN Watchdog_Control _TOD_Seconds_watchdog;
111
112#ifdef INIT
113
114/*
115 *  The following array contains the number of days in all months.
116 *  The first dimension should be 1 for leap years, and 0 otherwise.
117 *  The second dimension should range from 1 to 12 for January to
118 *  February, respectively.
119 */
120
121const unsigned32 _TOD_Days_per_month[ 2 ][ 13 ] = {
122  { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
123  { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
124};
125
126/*
127 *  The following array contains the number of days in all months
128 *  up to the month indicated by the index of the second dimension.
129 *  The first dimension should be 1 for leap years, and 0 otherwise.
130 */
131
132const unsigned16 _TOD_Days_to_date[2][13] = {
133  { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 },
134  { 0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }
135};
136
137/*
138 *  The following array contains the number of days in the years
139 *  since the last leap year.  The index should be 0 for leap
140 *  years, and the number of years since the beginning of a leap
141 *  year otherwise.
142 */
143
144const unsigned16 _TOD_Days_since_last_leap_year[4] = { 0, 366, 761, 1126 };
145
146#else
147
148extern const unsigned16 _TOD_Days_to_date[2][13]; /* Julian days */
149extern const unsigned16 _TOD_Days_since_last_leap_year[4];
150extern const unsigned32 _TOD_Days_per_month[2][13];
151
152#endif
153
154/*
155 *  _TOD_Handler_initialization
156 *
157 *  DESCRIPTION:
158 *
159 *  This routine performs the initialization necessary for this handler.
160 */
161
162void _TOD_Handler_initialization(
163  unsigned32 microseconds_per_tick
164);
165
166/*
167 *  _TOD_Set
168 *
169 *  DESCRIPTION:
170 *
171 *  This routine sets the current time of day to THE_TOD and
172 *  the equivalent SECONDS_SINCE_EPOCH.
173 */
174
175void _TOD_Set(
176  TOD_Control       *the_tod,
177  Watchdog_Interval  seconds_since_epoch
178);
179
180/*
181 *  _TOD_Validate
182 *
183 *  DESCRIPTION:
184 *
185 *  This function returns TRUE if THE_TOD contains
186 *  a valid time of day, and FALSE otherwise.
187 */
188
189boolean _TOD_Validate(
190  TOD_Control *the_tod
191);
192
193/*
194 *  _TOD_To_seconds
195 *
196 *  DESCRIPTION:
197 *
198 *  This function returns the number seconds between the epoch and THE_TOD.
199 */
200
201Watchdog_Interval _TOD_To_seconds(
202  TOD_Control *the_tod
203);
204
205/*
206 *  _TOD_Is_set
207 *
208 *  DESCRIPTION:
209 *
210 *  This function returns TRUE if the application has set the current
211 *  time of day, and FALSE otherwise.
212 */
213
214STATIC INLINE boolean _TOD_Is_set( void );
215
216/*
217 *  _TOD_Tickle_ticks
218 *
219 *  DESCRIPTION:
220 *
221 *  This routine increments the ticks field of the current time of
222 *  day at each clock tick.
223 */
224
225STATIC INLINE void _TOD_Tickle_ticks( void );
226
227/*
228 *  _TOD_Deactivate
229 *
230 *  DESCRIPTION:
231 *
232 *  This routine deactivates updating of the current time of day.
233 */
234
235STATIC INLINE void _TOD_Deactivate( void );
236
237/*
238 *  _TOD_Activate
239 *
240 *  DESCRIPTION:
241 *
242 *  This routine deactivates updating of the current time of day.
243 */
244
245STATIC INLINE void _TOD_Activate(
246  Watchdog_Interval ticks
247);
248
249/*
250 *  _TOD_Tickle
251 *
252 *  DESCRIPTION:
253 *
254 *  This routine is scheduled as a watchdog function and is invoked at
255 *  each second boundary.  It updates the current time of day to indicate
256 *  that a second has passed and processes the seconds watchdog chain.
257 */
258
259void _TOD_Tickle(
260  Objects_Id  id,
261  void       *ignored
262);
263
264/*
265 *  TOD_MILLISECONDS_TO_MICROSECONDS
266 *
267 *  DESCRIPTION:
268 *
269 *  This routine converts an interval expressed in milliseconds to microseconds.
270 *
271 *  NOTE:
272 *
273 *  This must be a macro so it can be used in "static" tables.
274 */
275
276#define TOD_MILLISECONDS_TO_MICROSECONDS(_ms) ((_ms) * 1000)
277
278/*
279 *  TOD_MILLISECONDS_TO_TICKS
280 *
281 *  DESCRIPTION:
282 *
283 *  This routine converts an interval expressed in milliseconds to ticks.
284 *
285 *  NOTE:
286 *
287 *  This must be a macro so it can be used in "static" tables.
288 */
289
290#define TOD_MILLISECONDS_TO_TICKS(_ms) \
291    (TOD_MILLISECONDS_TO_MICROSECONDS(_ms) / _TOD_Microseconds_per_tick)
292
293#include <rtems/core/tod.inl>
294
295#ifdef __cplusplus
296}
297#endif
298
299#endif
300/* end of include file */
Note: See TracBrowser for help on using the repository browser.