diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-11-16 13:59:27 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-11-21 16:24:22 +0100 |
commit | 62181b21c2ebe7d5b5f82272dc9bfd4175e4254a (patch) | |
tree | 4c308d3c621ebc1dbade0ec4da3cc880f151447e | |
parent | score: Add _Timestamp_To_timeval() (diff) | |
download | rtems-62181b21c2ebe7d5b5f82272dc9bfd4175e4254a.tar.bz2 |
score: Add and use _TOD_Get_with_nanoseconds()
Delete _TOD_Get_as_timestamp().
-rw-r--r-- | cpukit/score/Makefile.am | 2 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/tod.h | 29 | ||||
-rw-r--r-- | cpukit/score/inline/rtems/score/tod.inl | 17 | ||||
-rw-r--r-- | cpukit/score/src/coretodget.c | 22 | ||||
-rw-r--r-- | cpukit/score/src/coretodgetuptime.c | 54 |
5 files changed, 35 insertions, 89 deletions
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index a7a77d9d73..656c198a9b 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -307,7 +307,7 @@ libscore_a_SOURCES += src/ts64addto.c src/ts64dividebyinteger.c \ ## TOD_C_FILES libscore_a_SOURCES += src/coretod.c src/coretodset.c src/coretodget.c \ - src/coretodgetuptime.c src/coretodgetuptimetimespec.c src/coretodtickle.c \ + src/coretodgetuptimetimespec.c src/coretodtickle.c \ src/coretodmsecstoticks.c src/coretodtickspersec.c src/coretodusectoticks.c ## WATCHDOG_C_FILES diff --git a/cpukit/score/include/rtems/score/tod.h b/cpukit/score/include/rtems/score/tod.h index 797f4bbccd..1f21fdbeae 100644 --- a/cpukit/score/include/rtems/score/tod.h +++ b/cpukit/score/include/rtems/score/tod.h @@ -197,22 +197,30 @@ static inline void _TOD_Set( } /** - * @brief Returns the time of day in @a tod_as_timestamp. + * @brief Returns a snapshot of a clock. * - * The @a tod_as_timestamp timestamp represents the time since UNIX epoch. + * This function invokes the nanoseconds extension. + * + * @param[out] snapshot The snapshot. + * @param[in] source The clock. + * + * @return The snapshot. */ -void _TOD_Get_as_timestamp( - Timestamp_Control *tod_as_timestamp +Timestamp_Control *_TOD_Get_with_nanoseconds( + Timestamp_Control *snapshot, + const Timestamp_Control *clock ); static inline void _TOD_Get( struct timespec *tod_as_timespec ) { - Timestamp_Control tod_as_timestamp; + Timestamp_Control tod_as_timestamp; + Timestamp_Control *tod_as_timestamp_ptr; - _TOD_Get_as_timestamp( &tod_as_timestamp ); - _Timestamp_To_timespec( &tod_as_timestamp, tod_as_timespec ); + tod_as_timestamp_ptr = + _TOD_Get_with_nanoseconds( &tod_as_timestamp, &_TOD.now ); + _Timestamp_To_timespec( tod_as_timestamp_ptr, tod_as_timespec ); } /** @@ -223,9 +231,12 @@ static inline void _TOD_Get( * * @param[in] time is a pointer to the uptime to be returned */ -void _TOD_Get_uptime( +static inline void _TOD_Get_uptime( Timestamp_Control *time -); +) +{ + _TOD_Get_with_nanoseconds( time, &_TOD.uptime ); +} /** * @brief _TOD_Get_uptime_as_timespec diff --git a/cpukit/score/inline/rtems/score/tod.inl b/cpukit/score/inline/rtems/score/tod.inl index 14c7b6f5ae..d8a8bb7f20 100644 --- a/cpukit/score/inline/rtems/score/tod.inl +++ b/cpukit/score/inline/rtems/score/tod.inl @@ -56,19 +56,12 @@ RTEMS_INLINE_ROUTINE void _TOD_Get_timeval( struct timeval *time ) { - ISR_Level level; - struct timespec now; - suseconds_t useconds; + Timestamp_Control snapshot_as_timestamp; + Timestamp_Control *snapshot_as_timestamp_ptr; - _ISR_Disable(level); - _TOD_Get( &now ); - _ISR_Enable(level); - - useconds = (suseconds_t)now.tv_nsec; - useconds /= (suseconds_t)TOD_NANOSECONDS_PER_MICROSECOND; - - time->tv_sec = now.tv_sec; - time->tv_usec = useconds; + snapshot_as_timestamp_ptr = + _TOD_Get_with_nanoseconds( &snapshot_as_timestamp, &_TOD.now ); + _Timestamp_To_timeval( snapshot_as_timestamp_ptr, time ); } /**@}*/ diff --git a/cpukit/score/src/coretodget.c b/cpukit/score/src/coretodget.c index 94517e5926..448bc7ba55 100644 --- a/cpukit/score/src/coretodget.c +++ b/cpukit/score/src/coretodget.c @@ -10,35 +10,31 @@ */ #if HAVE_CONFIG_H -#include "config.h" + #include "config.h" #endif -#include <rtems/system.h> -#include <rtems/score/isr.h> -#include <rtems/score/timespec.h> -#include <rtems/score/timestamp.h> #include <rtems/score/tod.h> #include <rtems/score/watchdog.h> -void _TOD_Get_as_timestamp( - Timestamp_Control *tod +Timestamp_Control *_TOD_Get_with_nanoseconds( + Timestamp_Control *snapshot, + const Timestamp_Control *clock ) { ISR_Level level; Timestamp_Control offset; Timestamp_Control now; - long nanoseconds; + uint32_t nanoseconds; - /* assume time checked for NULL by caller */ - - /* _TOD.now is the native current time */ _ISR_Disable( level ); - now = _TOD.now; nanoseconds = (*_Watchdog_Nanoseconds_since_tick_handler)(); + now = *clock; _ISR_Enable( level ); _Timestamp_Set( &offset, 0, nanoseconds ); _Timestamp_Add_to( &now, &offset ); - *tod = now; + *snapshot = now; + + return snapshot; } diff --git a/cpukit/score/src/coretodgetuptime.c b/cpukit/score/src/coretodgetuptime.c deleted file mode 100644 index c3c05aed3c..0000000000 --- a/cpukit/score/src/coretodgetuptime.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Time of Day (TOD) Handler - get uptime - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.com/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/system.h> -#include <rtems/score/isr.h> -#include <rtems/score/timestamp.h> -#include <rtems/score/tod.h> -#include <rtems/score/watchdog.h> - -/* - * _TOD_Get_uptime - * - * This routine is used to obtain the system uptime - * - * Input parameters: - * time - pointer to the timestamp structure - * - * Output parameters: NONE - */ - -void _TOD_Get_uptime( - Timestamp_Control *uptime -) -{ - ISR_Level level; - Timestamp_Control offset; - Timestamp_Control up; - long nanoseconds; - - /* assume time checked for NULL by caller */ - - /* _TOD.uptime is in native timestamp format */ - _ISR_Disable( level ); - up = _TOD.uptime; - nanoseconds = (*_Watchdog_Nanoseconds_since_tick_handler)(); - _ISR_Enable( level ); - - _Timestamp_Set( &offset, 0, nanoseconds ); - _Timestamp_Add_to( &up, &offset ); - *uptime = up; -} |