RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
todimpl.h
Go to the documentation of this file.
1
9/*
10 * COPYRIGHT (c) 1989-2009.
11 * On-Line Applications Research Corporation (OAR).
12 *
13 * The license and distribution terms for this file may be
14 * found in the file LICENSE in this distribution or at
15 * http://www.rtems.org/license/LICENSE.
16 */
17
18#ifndef _RTEMS_SCORE_TODIMPL_H
19#define _RTEMS_SCORE_TODIMPL_H
20
21#include <rtems/score/status.h>
25
26#include <sys/time.h>
27#include <time.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
49#define TOD_SECONDS_PER_MINUTE (uint32_t)60
50
54#define TOD_MINUTES_PER_HOUR (uint32_t)60
55
59#define TOD_MONTHS_PER_YEAR (uint32_t)12
60
64#define TOD_DAYS_PER_YEAR (uint32_t)365
65
69#define TOD_HOURS_PER_DAY (uint32_t)24
70
75#define TOD_SECONDS_PER_DAY (uint32_t) (TOD_SECONDS_PER_MINUTE * \
76 TOD_MINUTES_PER_HOUR * \
77 TOD_HOURS_PER_DAY)
78
82#define TOD_SECONDS_PER_NON_LEAP_YEAR (365 * TOD_SECONDS_PER_DAY)
83
87#define TOD_MILLISECONDS_PER_SECOND (uint32_t)1000
88
92#define TOD_MICROSECONDS_PER_SECOND (uint32_t)1000000
93
97#define TOD_NANOSECONDS_PER_SECOND (uint32_t)1000000000
98
102#define TOD_NANOSECONDS_PER_MICROSECOND (uint32_t)1000
103
111#define TOD_SECONDS_1970_THROUGH_1988 \
112 (((1987 - 1970 + 1) * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
113 (4 * TOD_SECONDS_PER_DAY))
114
122#define TOD_BASE_YEAR 1988
123
135typedef struct {
142 bool is_set;
144
148extern TOD_Control _TOD;
149
153void _TOD_Lock( void );
154
158void _TOD_Unlock( void );
159
166#if defined(RTEMS_DEBUG)
167bool _TOD_Is_owner( void );
168#endif
169
175static inline void _TOD_Acquire( ISR_lock_Context *lock_context )
176{
177 _Timecounter_Acquire( lock_context );
178}
179
185static inline void _TOD_Release( ISR_lock_Context *lock_context )
186{
187 _Timecounter_Release( lock_context );
188}
189
204Status_Control _TOD_Set(
205 const struct timespec *tod,
206 ISR_lock_Context *lock_context
207);
208
214static inline void _TOD_Get(
215 struct timespec *tod
216)
217{
219}
220
231static inline void _TOD_Get_uptime(
233)
234{
235 *time = _Timecounter_Sbinuptime();
236}
237
245static inline void _TOD_Get_zero_based_uptime(
247)
248{
249 *time = _Timecounter_Sbinuptime() - SBT_1S;
250}
251
259static inline void _TOD_Get_zero_based_uptime_as_timespec(
260 struct timespec *time
261)
262{
264 --time->tv_sec;
265}
266
275static inline uint32_t _TOD_Seconds_since_epoch( void )
276{
277 return (uint32_t) _Timecounter_Time_second;
278}
279
290uint32_t TOD_TICKS_PER_SECOND_method(void);
291
300#define TOD_TICKS_PER_SECOND TOD_TICKS_PER_SECOND_method()
301
309 struct timeval *time
310)
311{
313}
314
323void _TOD_Adjust(
324 const struct timespec *delta
325);
326
334{
335 return _TOD.is_set;
336}
337
359typedef enum {
365
369typedef struct TOD_Hook {
372
374 Status_Control ( *handler )( TOD_Action, const struct timespec * );
376
381
390 TOD_Hook *hook
391);
392
401 TOD_Hook *hook
402);
403
415Status_Control _TOD_Hook_Run(
416 TOD_Action action,
417 const struct timespec *tod
418);
419
420
423#ifdef __cplusplus
424}
425#endif
426
427#endif
428/* end of include file */
Constants and Structures Associated with Watchdog Timers.
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
Status_Control _TOD_Hook_Run(TOD_Action action, const struct timespec *tod)
Run the TOD Action Hooks.
Definition: coretodhookrun.c:45
Chain_Control _TOD_Hooks
Set of registered methods for TOD Actions.
Definition: coretodhookdata.c:44
void _TOD_Hook_Unregister(TOD_Hook *hook)
Remove a TOD Action Hook.
Definition: coretodhookunregister.c:44
struct TOD_Hook TOD_Hook
Structure to manage each TOD action hook.
void _TOD_Hook_Register(TOD_Hook *hook)
Add a TOD Action Hook.
Definition: coretodhookregister.c:44
TOD_Action
Possible actions where a registered hook could be invoked.
Definition: todimpl.h:359
@ TOD_ACTION_SET_CLOCK
Constant to indicate the TOD is being set.
Definition: todimpl.h:363
Status_Control _TOD_Set(const struct timespec *tod, ISR_lock_Context *lock_context)
Sets the time of day.
Definition: coretodset.c:44
TOD_Control _TOD
TOD Management information.
Definition: coretod.c:24
void _TOD_Unlock(void)
Unlocks the time of day mutex.
Definition: coretod.c:33
RTEMS_INLINE_ROUTINE void _TOD_Get_timeval(struct timeval *time)
This routine returns a timeval based upon the internal timespec format TOD.
Definition: todimpl.h:308
void _TOD_Adjust(const struct timespec *delta)
Adjusts the Time of Time.
Definition: coretodadjust.c:24
uint32_t TOD_TICKS_PER_SECOND_method(void)
Gets number of ticks in a second.
Definition: coretodtickspersec.c:25
void _TOD_Lock(void)
Locks the time of day mutex.
Definition: coretod.c:28
RTEMS_INLINE_ROUTINE bool _TOD_Is_set(void)
Check if the TOD is Set.
Definition: todimpl.h:333
void _Timecounter_Microtime(struct timeval *tv)
Returns the wall clock time in the timeval format.
void _Timecounter_Nanotime(struct timespec *ts)
Returns the wall clock time in the timespec format.
int64_t _Timecounter_Sbinuptime(void)
Returns the uptime in the sbintime_t format.
volatile time_t _Timecounter_Time_second
The wall clock time in seconds.
void _Timecounter_Nanouptime(struct timespec *ts)
Returns the uptime in the timespec format.
#define _Timecounter_Release(lock_context)
Releases the timecounter lock.
Definition: timecounter.h:211
#define _Timecounter_Acquire(lock_context)
Lock to protect the timecounter mechanic.
Definition: timecounter.h:201
int64_t Timestamp_Control
Definition: timestamp.h:57
Definition: chain.h:68
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
TOD control.
Definition: todimpl.h:135
bool is_set
Indicates if the time of day is set.
Definition: todimpl.h:142
Structure to manage each TOD action hook.
Definition: todimpl.h:369
Status_Control(* handler)(TOD_Action, const struct timespec *)
Definition: todimpl.h:374
Chain_Node Node
Definition: todimpl.h:371
Timecounter Implementation.
Helpers for Manipulating Timestamps.
Definition: chain.h:86