source: rtems/cpukit/rtems/include/rtems/rtems/clock.h @ 33c0f97

4.115
Last change on this file since 33c0f97 was 33c0f97, checked in by Sebastian Huber <sebastian.huber@…>, on 09/28/11 at 15:46:13

2011-09-28 Sebastian Huber <sebastian.huber@…>

  • rtems/include/rtems/rtems/clock.h, rtems/src/clockset.c: Added const qualifier in rtems_clock_set().
  • Property mode set to 100644
File size: 7.6 KB
Line 
1/**
2 * @file rtems/rtems/clock.h
3 *
4 *  This include file contains all the constants and structures associated
5 *  with the Clock Manager.  This manager provides facilities to set, obtain,
6 *  and continually update the current date and time.
7 *
8 *  This manager provides directives to:
9 *
10 *     - set the current date and time
11 *     - obtain the current date and time
12 *     - set the nanoseconds since last clock tick handler
13 *     - announce a clock tick
14 *     - obtain the system uptime
15 */
16
17/*  COPYRIGHT (c) 1989-2008.
18 *  On-Line Applications Research Corporation (OAR).
19 *
20 *  The license and distribution terms for this file may be
21 *  found in the file LICENSE in this distribution or at
22 *  http://www.rtems.com/license/LICENSE.
23 *
24 *  $Id$
25 */
26
27#ifndef _RTEMS_RTEMS_CLOCK_H
28#define _RTEMS_RTEMS_CLOCK_H
29
30#include <rtems/score/tod.h>
31#include <rtems/score/watchdog.h>
32#include <rtems/rtems/status.h>
33#include <rtems/rtems/types.h>
34
35#include <sys/time.h> /* struct timeval */
36
37/**
38 *  @defgroup ClassicClock Clocks
39 *
40 *  @ingroup ClassicRTEMS
41 *
42 *  This encapsulates functionality which XXX
43 */
44/**@{*/
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/**
51 *  List of things which can be returned by the rtems_clock_get directive.
52 */
53typedef enum {
54  /** This value indicates obtain TOD in Classic API format. */
55  RTEMS_CLOCK_GET_TOD,
56  /** This value indicates obtain the number of seconds since the epoch. */
57  RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH,
58  /** This value indicates obtain the number of ticks since system boot. */
59  RTEMS_CLOCK_GET_TICKS_SINCE_BOOT,
60  /** This value indicates obtain the number of ticks per second. */
61  RTEMS_CLOCK_GET_TICKS_PER_SECOND,
62  /** This value indicates obtain the TOD in struct timeval format. */
63  RTEMS_CLOCK_GET_TIME_VALUE
64} rtems_clock_get_options;
65
66/**
67 *  Type for the nanoseconds since last tick BSP extension.
68 */
69typedef Watchdog_Nanoseconds_since_last_tick_routine
70  rtems_nanoseconds_extension_routine;
71
72/**
73 *  @brief Obtain Current Time of Day
74 *
75 *  This routine implements the rtems_clock_get directive.  It returns
76 *  one of the following:
77 *    + current time of day
78 *    + seconds since epoch
79 *    + ticks since boot
80 *    + ticks per second
81 *
82 *  @param[in] option is the format of time to return
83 *  @param[in] time_buffer points to the output area
84 *
85 *  @return This method returns RTEMS_SUCCESSFUL if there was not an
86 *          error.  Otherwise, a status code is returned indicating the
87 *          source of the error.
88 */
89rtems_status_code rtems_clock_get(
90  rtems_clock_get_options  option,
91  void                    *time_buffer
92);
93
94/**
95 *  @brief Obtain Current Time of Day (Classic TOD)
96 *
97 *  This routine implements the rtems_clock_get_tod directive.  It returns
98 *  the current time of day in the format defined by RTEID.
99 *
100 *  @param[in] time_buffer points to the time of day structure
101 *
102 *  @return This method returns RTEMS_SUCCESSFUL if there was not an
103 *          error.  Otherwise, a status code is returned indicating the
104 *          source of the error.  If successful, the time_buffer will
105 *          be filled in with the current time of day.
106 */
107rtems_status_code rtems_clock_get_tod(
108  rtems_time_of_day *time_buffer
109);
110
111/**
112 *  @brief Obtain TOD in struct timeval Format
113 *
114 *  This routine implements the rtems_clock_get_tod_timeval
115 *  directive.
116 *
117 *  @param[in] time points to the struct timeval variable to fill in
118 *
119 *  @return This method returns RTEMS_SUCCESSFUL if there was not an
120 *          error.  Otherwise, a status code is returned indicating the
121 *          source of the error.  If successful, the time will
122 *          be filled in with the current time of day.
123 */
124rtems_status_code rtems_clock_get_tod_timeval(
125  struct timeval *time
126);
127
128/**
129 *  @brief Obtain Seconds Since Epoch
130 *
131 *  This routine implements the rtems_clock_get_seconds_since_epoch
132 *  directive.
133 *
134 *  @param[in] the_interval points to the interval variable to fill in
135 *
136 *  @return This method returns RTEMS_SUCCESSFUL if there was not an
137 *          error.  Otherwise, a status code is returned indicating the
138 *          source of the error.  If successful, the time_buffer will
139 *          be filled in with the current time of day.
140 */
141rtems_status_code rtems_clock_get_seconds_since_epoch(
142  rtems_interval *the_interval
143);
144
145/**
146 *  @brief Obtain Ticks Since Boot
147 *
148 *  This routine implements the rtems_clock_get_ticks_since_boot
149 *  directive.
150 *
151 *  @return This method returns the number of ticks since boot.  It cannot
152 *          fail since RTEMS always keeps a running count of ticks since boot.
153 */
154rtems_interval rtems_clock_get_ticks_since_boot(void);
155
156/**
157 *  @brief Obtain Ticks Per Seconds
158 *
159 *  This routine implements the rtems_clock_get_ticks_per_second
160 *  directive.
161 *
162 *  @return This method returns the number of ticks since boot.  It cannot
163 *          fail since RTEMS is always configured to know the number of
164 *          ticks per second.
165 */
166rtems_interval rtems_clock_get_ticks_per_second(void);
167
168/**
169 *  @brief Set the Current TOD
170 *
171 *  This routine implements the rtems_clock_set directive.  It sets
172 *  the current time of day to that in the time_buffer record.
173 *
174 *  @param[in] time_buffer points to the new TOD
175 *
176 *  @return This method returns RTEMS_SUCCESSFUL if there was not an
177 *          error.  Otherwise, a status code is returned indicating the
178 *          source of the error.
179 *
180 *  @note Activities scheduled based upon the current time of day
181 *        may be executed immediately if the time is moved forward.
182 */
183rtems_status_code rtems_clock_set(
184  const rtems_time_of_day *time_buffer
185);
186
187/**
188 *  @brief Announce a Clock Tick
189 *
190 *  This routine implements the rtems_clock_tick directive.  It is invoked
191 *  to inform RTEMS of the occurrence of a clock tick.
192 *
193 *  @return This directive always returns RTEMS_SUCCESSFUL.
194 *
195 *  @note This method is typically called from an ISR and is the basis
196 *        for all timeouts and delays.
197 */
198rtems_status_code rtems_clock_tick( void );
199
200/**
201 *  @brief Set the BSP specific Nanoseconds Extension
202 *
203 *  This directive sets the BSP provided nanoseconds since last tick
204 *  extension.
205 *
206 *  @param[in] routine is a pointer to the extension routine
207 *
208 *  @return This method returns RTEMS_SUCCESSFUL if there was not an
209 *          error.  Otherwise, a status code is returned indicating the
210 *          source of the error.
211 */
212rtems_status_code rtems_clock_set_nanoseconds_extension(
213  rtems_nanoseconds_extension_routine routine
214);
215
216/**
217 *  @brief Obtain the System Uptime
218 *
219 *  This directive returns the system uptime.
220 *
221 *  @param[in] uptime is a pointer to the time structure
222 *
223 *  @return This method returns RTEMS_SUCCESSFUL if there was not an
224 *          error.  Otherwise, a status code is returned indicating the
225 *          source of the error.  If successful, the uptime will be
226 *          filled in.
227 */
228rtems_status_code rtems_clock_get_uptime(
229  struct timespec *uptime
230);
231
232/**
233 *  @brief _TOD_Validate
234 *
235 *  This support function returns true if @a the_tod contains
236 *  a valid time of day, and false otherwise.
237 *
238 *  @param[in] the_tod is the TOD structure to validate
239 *
240 *  @return This method returns true if the TOD is valid and false otherwise.
241 */
242bool _TOD_Validate(
243  const rtems_time_of_day *the_tod
244);
245
246/**
247 *  @brief _TOD_To_seconds
248 *
249 *  This function returns the number seconds between the epoch and @a the_tod.
250 *
251 *  @param[in] the_tod is the TOD structure to convert to seconds
252 *
253 *  @return This method returns the number of seconds since epoch represented
254 *          by @a the_tod
255 */
256Watchdog_Interval _TOD_To_seconds(
257  const rtems_time_of_day *the_tod
258);
259
260#ifdef __cplusplus
261}
262#endif
263
264/**@}*/
265
266#endif
267/* end of include file */
Note: See TracBrowser for help on using the repository browser.