diff options
author | Chris Johns <chrisj@rtems.org> | 2013-12-24 16:38:42 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2013-12-24 16:46:19 +1100 |
commit | 2d1bdc8f797db5ab6e3ba6945befaf73d9062798 (patch) | |
tree | e8a3eecc64c589a9d0495790e09092dc572f36cf /cpukit/rtems | |
parent | mips/shared: added new doxygen (diff) | |
download | rtems-2d1bdc8f797db5ab6e3ba6945befaf73d9062798.tar.bz2 |
cpukit/rtems: Add rtems_clock_get_uptime_nanoseconds to the RTEMS API.
Add Timestamp support in the score to return a timestamp in nanoseconds.
Add a test.
Update the RTEMS API documentation.
Diffstat (limited to 'cpukit/rtems')
-rw-r--r-- | cpukit/rtems/Makefile.am | 1 | ||||
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/clock.h | 7 | ||||
-rw-r--r-- | cpukit/rtems/src/clockgetuptimenanoseconds.c | 35 |
3 files changed, 43 insertions, 0 deletions
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am index c8fcfa6bd2..fd5af5aaa1 100644 --- a/cpukit/rtems/Makefile.am +++ b/cpukit/rtems/Makefile.am @@ -151,6 +151,7 @@ librtems_a_SOURCES += src/clockgettodtimeval.c librtems_a_SOURCES += src/clockgetuptime.c librtems_a_SOURCES += src/clockgetuptimetimeval.c librtems_a_SOURCES += src/clockgetuptimeseconds.c +librtems_a_SOURCES += src/clockgetuptimenanoseconds.c librtems_a_SOURCES += src/clockset.c librtems_a_SOURCES += src/clocksetnsecshandler.c librtems_a_SOURCES += src/clocktick.c diff --git a/cpukit/rtems/include/rtems/rtems/clock.h b/cpukit/rtems/include/rtems/rtems/clock.h index e933a5e31a..dc5901ab0d 100644 --- a/cpukit/rtems/include/rtems/rtems/clock.h +++ b/cpukit/rtems/include/rtems/rtems/clock.h @@ -257,6 +257,13 @@ void rtems_clock_get_uptime_timeval( struct timeval *uptime ); time_t rtems_clock_get_uptime_seconds( void ); /** + * @brief Returns the system uptime in nanoseconds. + * + * @retval The system uptime in nanoseconds. + */ +uint64_t rtems_clock_get_uptime_nanoseconds( void ); + +/** * @brief TOD Validate * * This support function returns true if @a the_tod contains diff --git a/cpukit/rtems/src/clockgetuptimenanoseconds.c b/cpukit/rtems/src/clockgetuptimenanoseconds.c new file mode 100644 index 0000000000..c07a4305db --- /dev/null +++ b/cpukit/rtems/src/clockgetuptimenanoseconds.c @@ -0,0 +1,35 @@ +/** + * @file + * + * @brief Returns the system uptime in seconds. + * @ingroup ClassicClock Clocks + */ + +/* + * Copyright (c) 2013 Chris Johns <chrisj@rtems.org>. All rights reserved. + * + * 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/rtems/clock.h> +#include <rtems/score/todimpl.h> + +uint64_t rtems_clock_get_uptime_nanoseconds( void ) +{ + Timestamp_Control snapshot_as_timestamp; + uint32_t nanoseconds; + ISR_Level level; + + _TOD_Acquire( &_TOD, level ); + snapshot_as_timestamp = _TOD.uptime; + nanoseconds = ( *_TOD.nanoseconds_since_last_tick )(); + _TOD_Release( &_TOD, level ); + + return _Timestamp_Get_As_nanoseconds( &snapshot_as_timestamp, nanoseconds ); +} |