I didn't read much of this, but it needs doxygen, and probably part of the previous patch should be merged in here, or some better splitting/recombining of patches so I don't have to review code that gets fixed. It's worth repeating, the "rtems_*time" functions are not following the API conventions of rtems_package_method, it should be rtems_timecounter_*time like rtems_timecounter_bintime.
Please use a short git-commit message for the first line, and longer git commit message after a blank line. This will avoid really long lines in git log, and long subjects in git-send-email. I guess this advice is in the Git page (https://devel.rtems.org/wiki/Developer/Git). Gedare On Wed, Apr 1, 2015 at 10:37 AM, Alexander Krutwig <alexander.krut...@embedded-brains.de> wrote: > --- > cpukit/libnetworking/rtems/rtems_bsdnet_internal.h | 3 +- > cpukit/libnetworking/rtems/rtems_glue.c | 4 - > cpukit/posix/src/clockgettime.c | 3 +- > cpukit/posix/src/posixtimespecabsolutetimeout.c | 2 +- > cpukit/posix/src/timergettime.c | 2 +- > cpukit/posix/src/timersettime.c | 4 +- > cpukit/posix/src/timertsr.c | 2 +- > cpukit/rtems/Makefile.am | 1 - > cpukit/rtems/include/rtems/rtems/clock.h | 25 -- > cpukit/rtems/src/clockgetuptimenanoseconds.c | 9 +- > cpukit/rtems/src/clockgetuptimeseconds.c | 6 +- > cpukit/rtems/src/clocksetnsecshandler.c | 34 -- > cpukit/sapi/Makefile.am | 1 + > cpukit/sapi/include/rtems/timecounter.h | 89 +++++ > cpukit/sapi/preinstall.am | 4 + > cpukit/sapi/src/exinit.c | 3 + > cpukit/score/Makefile.am | 18 +- > cpukit/score/include/rtems/score/timecounter.h | 59 +++- > cpukit/score/include/rtems/score/timecounterimpl.h | 119 +++++++ > cpukit/score/include/rtems/score/timestamp.h | 267 ++++++++------- > cpukit/score/include/rtems/score/timestamp64.h | 379 > --------------------- > cpukit/score/include/rtems/score/tod.h | 9 - > cpukit/score/include/rtems/score/todimpl.h | 101 ++---- > cpukit/score/preinstall.am | 10 +- > cpukit/score/src/coretod.c | 18 +- > cpukit/score/src/coretodadjust.c | 9 +- > cpukit/score/src/coretodget.c | 46 --- > cpukit/score/src/coretodgetuptimetimespec.c | 32 -- > cpukit/score/src/coretodsecondssinceepoch.c | 32 -- > cpukit/score/src/coretodset.c | 10 +- > cpukit/score/src/coretodtickle.c | 22 +- > cpukit/score/src/tcgetscalerandmask.c | 40 +++ > cpukit/score/src/ts64addto.c | 31 -- > cpukit/score/src/ts64divide.c | 51 --- > cpukit/score/src/ts64equalto.c | 31 -- > cpukit/score/src/ts64getnanoseconds.c | 30 -- > cpukit/score/src/ts64getseconds.c | 30 -- > cpukit/score/src/ts64lessthan.c | 31 -- > cpukit/score/src/ts64set.c | 33 -- > cpukit/score/src/ts64settozero.c | 31 -- > cpukit/score/src/ts64subtract.c | 31 -- > cpukit/score/src/ts64totimespec.c | 32 -- > cpukit/score/src/ts64totimeval.c | 37 -- > testsuites/sptests/Makefile.am | 2 + > testsuites/sptests/configure.ac | 2 + > testsuites/sptests/spclock_err01/init.c | 8 - > testsuites/sptests/spsize/size.c | 3 - > testsuites/sptests/sptimecounter02/Makefile.am | 19 ++ > testsuites/sptests/sptimecounter02/init.c | 266 +++++++++++++++ > .../sptests/sptimecounter02/sptimecounter02.doc | 11 + > .../sptests/sptimecounter02/sptimecounter02.scn | 0 > 51 files changed, 818 insertions(+), 1224 deletions(-) > delete mode 100644 cpukit/rtems/src/clocksetnsecshandler.c > create mode 100644 cpukit/sapi/include/rtems/timecounter.h > create mode 100644 cpukit/score/include/rtems/score/timecounterimpl.h > delete mode 100644 cpukit/score/include/rtems/score/timestamp64.h > delete mode 100644 cpukit/score/src/coretodget.c > delete mode 100644 cpukit/score/src/coretodgetuptimetimespec.c > delete mode 100644 cpukit/score/src/coretodsecondssinceepoch.c > create mode 100644 cpukit/score/src/tcgetscalerandmask.c > delete mode 100644 cpukit/score/src/ts64addto.c > delete mode 100644 cpukit/score/src/ts64divide.c > delete mode 100644 cpukit/score/src/ts64equalto.c > delete mode 100644 cpukit/score/src/ts64getnanoseconds.c > delete mode 100644 cpukit/score/src/ts64getseconds.c > delete mode 100644 cpukit/score/src/ts64lessthan.c > delete mode 100644 cpukit/score/src/ts64set.c > delete mode 100644 cpukit/score/src/ts64settozero.c > delete mode 100644 cpukit/score/src/ts64subtract.c > delete mode 100644 cpukit/score/src/ts64totimespec.c > delete mode 100644 cpukit/score/src/ts64totimeval.c > create mode 100644 testsuites/sptests/sptimecounter02/Makefile.am > create mode 100644 testsuites/sptests/sptimecounter02/init.c > create mode 100644 testsuites/sptests/sptimecounter02/sptimecounter02.doc > create mode 100644 testsuites/sptests/sptimecounter02/sptimecounter02.scn > > diff --git a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h > b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h > index fc0370c..01562b1 100644 > --- a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h > +++ b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h > @@ -12,6 +12,7 @@ > > #include <rtems.h> > #include <rtems/fs.h> > +#include <rtems/timecounter.h> > > #ifdef __cplusplus > extern "C" { > @@ -61,7 +62,7 @@ void *memset(void *s, int c, size_t n); > #define panic rtems_panic > #define suser(a,b) 0 > > -void microtime(struct timeval *tv); > +#define microtime(tv) rtems_microtime(tv) > > #define hz rtems_bsdnet_ticks_per_second > #define tick rtems_bsdnet_microseconds_per_tick > diff --git a/cpukit/libnetworking/rtems/rtems_glue.c > b/cpukit/libnetworking/rtems/rtems_glue.c > index f05530e..0a42f97 100644 > --- a/cpukit/libnetworking/rtems/rtems_glue.c > +++ b/cpukit/libnetworking/rtems/rtems_glue.c > @@ -1344,7 +1344,3 @@ m_clalloc(int ncl, int nowait) > return 1; > } > > -void microtime(struct timeval *tv) > -{ > - rtems_clock_get_uptime_timeval(tv); > -} > diff --git a/cpukit/posix/src/clockgettime.c b/cpukit/posix/src/clockgettime.c > index 2838ba6..06cafa5 100644 > --- a/cpukit/posix/src/clockgettime.c > +++ b/cpukit/posix/src/clockgettime.c > @@ -37,7 +37,8 @@ int clock_gettime( > rtems_set_errno_and_return_minus_one( EINVAL ); > > if ( clock_id == CLOCK_REALTIME ) { > - _TOD_Get(tp); > + > + _TOD_Get_as_timespec(tp); > return 0; > } > #ifdef CLOCK_MONOTONIC > diff --git a/cpukit/posix/src/posixtimespecabsolutetimeout.c > b/cpukit/posix/src/posixtimespecabsolutetimeout.c > index 32da45f..f302986 100644 > --- a/cpukit/posix/src/posixtimespecabsolutetimeout.c > +++ b/cpukit/posix/src/posixtimespecabsolutetimeout.c > @@ -57,7 +57,7 @@ POSIX_Absolute_timeout_conversion_results_t > _POSIX_Absolute_timeout_to_ticks( > /* > * Is the absolute time in the past? > */ > - _TOD_Get( ¤t_time ); > + _TOD_Get_as_timespec( ¤t_time ); > > if ( _Timespec_Less_than( abstime, ¤t_time ) ) > return POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST; > diff --git a/cpukit/posix/src/timergettime.c b/cpukit/posix/src/timergettime.c > index 2a810ef..f065cc9 100644 > --- a/cpukit/posix/src/timergettime.c > +++ b/cpukit/posix/src/timergettime.c > @@ -49,7 +49,7 @@ int timer_gettime( > rtems_set_errno_and_return_minus_one( EINVAL ); > > /* Reads the current time */ > - _TOD_Get( ¤t_time ); > + _TOD_Get_as_timespec( ¤t_time ); > > ptimer = _POSIX_Timer_Get( timerid, &location ); > switch ( location ) { > diff --git a/cpukit/posix/src/timersettime.c b/cpukit/posix/src/timersettime.c > index 6cc3780..4d2af5d 100644 > --- a/cpukit/posix/src/timersettime.c > +++ b/cpukit/posix/src/timersettime.c > @@ -66,7 +66,7 @@ int timer_settime( > /* Convert absolute to relative time */ > if (flags == TIMER_ABSTIME) { > struct timespec now; > - _TOD_Get( &now ); > + _TOD_Get_as_timespec( &now ); > /* Check for seconds in the past */ > if ( _Timespec_Greater_than( &now, &normalize.it_value ) ) > rtems_set_errno_and_return_minus_one( EINVAL ); > @@ -125,7 +125,7 @@ int timer_settime( > > /* Indicate that the time is running */ > ptimer->state = POSIX_TIMER_STATE_CREATE_RUN; > - _TOD_Get( &ptimer->time ); > + _TOD_Get_as_timespec( &ptimer->time ); > _Objects_Put( &ptimer->Object ); > return 0; > > diff --git a/cpukit/posix/src/timertsr.c b/cpukit/posix/src/timertsr.c > index 8555463..512dd06 100644 > --- a/cpukit/posix/src/timertsr.c > +++ b/cpukit/posix/src/timertsr.c > @@ -58,7 +58,7 @@ void _POSIX_Timer_TSR( > return; > > /* Store the time when the timer was started again */ > - _TOD_Get( &ptimer->time ); > + _TOD_Get_as_timespec( &ptimer->time ); > > /* The state really did not change but just to be safe */ > ptimer->state = POSIX_TIMER_STATE_CREATE_RUN; > diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am > index 5e6f2ea..1af8536 100644 > --- a/cpukit/rtems/Makefile.am > +++ b/cpukit/rtems/Makefile.am > @@ -158,7 +158,6 @@ 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 > librtems_a_SOURCES += src/clocktodtoseconds.c > librtems_a_SOURCES += src/clocktodvalidate.c > diff --git a/cpukit/rtems/include/rtems/rtems/clock.h > b/cpukit/rtems/include/rtems/rtems/clock.h > index 2a1c772..89750cf 100644 > --- a/cpukit/rtems/include/rtems/rtems/clock.h > +++ b/cpukit/rtems/include/rtems/rtems/clock.h > @@ -14,7 +14,6 @@ > * > * - set the current date and time > * - obtain the current date and time > - * - set the nanoseconds since last clock tick handler > * - announce a clock tick > * - obtain the system uptime > */ > @@ -69,12 +68,6 @@ typedef enum { > } rtems_clock_get_options; > > /** > - * Type for the nanoseconds since last tick BSP extension. > - */ > -typedef TOD_Nanoseconds_since_last_tick_routine > - rtems_nanoseconds_extension_routine; > - > -/** > * @brief Obtain Current Time of Day > * > * @deprecated rtems_clock_get() is deprecated. Use the more explicit > @@ -279,24 +272,6 @@ rtems_status_code rtems_clock_set( > rtems_status_code rtems_clock_tick( void ); > > /** > - * @brief Set the BSP specific Nanoseconds Extension > - * > - * Clock Manager > - * > - * This directive sets the BSP provided nanoseconds since last tick > - * extension. > - * > - * @param[in] routine is a pointer to the extension routine > - * > - * @return This method returns RTEMS_SUCCESSFUL if there was not an > - * error. Otherwise, a status code is returned indicating the > - * source of the error. > - */ > -rtems_status_code rtems_clock_set_nanoseconds_extension( > - rtems_nanoseconds_extension_routine routine > -); > - > -/** > * @brief Obtain the System Uptime > * > * This directive returns the system uptime. > diff --git a/cpukit/rtems/src/clockgetuptimenanoseconds.c > b/cpukit/rtems/src/clockgetuptimenanoseconds.c > index 0310e59..d43f672 100644 > --- a/cpukit/rtems/src/clockgetuptimenanoseconds.c > +++ b/cpukit/rtems/src/clockgetuptimenanoseconds.c > @@ -23,13 +23,8 @@ > uint64_t rtems_clock_get_uptime_nanoseconds( void ) > { > Timestamp_Control snapshot_as_timestamp; > - uint32_t nanoseconds; > - ISR_lock_Context lock_context; > > - _TOD_Acquire( &_TOD, &lock_context ); > - snapshot_as_timestamp = _TOD.uptime; > - nanoseconds = ( *_TOD.nanoseconds_since_last_tick )(); > - _TOD_Release( &_TOD, &lock_context ); > + _TOD_Get_uptime(&snapshot_as_timestamp); > > - return _Timestamp_Get_As_nanoseconds( &snapshot_as_timestamp, nanoseconds > ); > + return _Timestamp_Get_nanoseconds(&snapshot_as_timestamp); > } > diff --git a/cpukit/rtems/src/clockgetuptimeseconds.c > b/cpukit/rtems/src/clockgetuptimeseconds.c > index 0312921..5c6b57c 100644 > --- a/cpukit/rtems/src/clockgetuptimeseconds.c > +++ b/cpukit/rtems/src/clockgetuptimeseconds.c > @@ -28,14 +28,10 @@ > > time_t rtems_clock_get_uptime_seconds( void ) > { > - TOD_Control *tod = &_TOD; > Timestamp_Control snapshot_as_timestamp; > struct timespec snapshot_as_timespec; > - ISR_lock_Context lock_context; > > - _TOD_Acquire( tod, &lock_context ); > - snapshot_as_timestamp = tod->uptime; > - _TOD_Release( tod, &lock_context ); > + _TOD_Get_uptime(&snapshot_as_timestamp); > > _Timestamp_To_timespec( &snapshot_as_timestamp, &snapshot_as_timespec ); > > diff --git a/cpukit/rtems/src/clocksetnsecshandler.c > b/cpukit/rtems/src/clocksetnsecshandler.c > deleted file mode 100644 > index ae08246..0000000 > --- a/cpukit/rtems/src/clocksetnsecshandler.c > +++ /dev/null > @@ -1,34 +0,0 @@ > -/** > - * @file > - * > - * @brief Set the BSP specific Nanoseconds Extension > - * @ingroup ClassicClock Clocks > - */ > - > -/* > - * COPYRIGHT (c) 1989-2006. > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > -#include "config.h" > -#endif > - > -#include <rtems/rtems/clock.h> > -#include <rtems/score/todimpl.h> > - > -rtems_status_code rtems_clock_set_nanoseconds_extension( > - rtems_nanoseconds_extension_routine routine > -) > -{ > - if ( !routine ) > - return RTEMS_INVALID_ADDRESS; > - > - _TOD_Set_nanoseconds_since_last_tick_handler( routine ); > - > - return RTEMS_SUCCESSFUL; > -} > diff --git a/cpukit/sapi/Makefile.am b/cpukit/sapi/Makefile.am > index 070800e..17f0e4f 100644 > --- a/cpukit/sapi/Makefile.am > +++ b/cpukit/sapi/Makefile.am > @@ -19,6 +19,7 @@ include_rtems_HEADERS += include/rtems/rbheap.h > include_rtems_HEADERS += include/rtems/rbtree.h > include_rtems_HEADERS += include/rtems/scheduler.h > include_rtems_HEADERS += include/rtems/sptables.h > +include_rtems_HEADERS += include/rtems/timecounter.h > include_rtems_HEADERS += include/rtems/timespec.h > > EXTRA_DIST = include/rtems/README > diff --git a/cpukit/sapi/include/rtems/timecounter.h > b/cpukit/sapi/include/rtems/timecounter.h > new file mode 100644 > index 0000000..a496e64 > --- /dev/null > +++ b/cpukit/sapi/include/rtems/timecounter.h > @@ -0,0 +1,89 @@ > +/* > + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. > + * > + * embedded brains GmbH > + * Dornierstr. 4 > + * 82178 Puchheim > + * Germany > + * <rt...@embedded-brains.de> > + * > + * The license and distribution terms for this file may be > + * found in the file LICENSE in this distribution or at > + * http://www.rtems.org/license/LICENSE. > + */ > + > +#ifndef _RTEMS_TIMECOUNTER_H > +#define _RTEMS_TIMECOUNTER_H > + > +#include <rtems/score/timecounter.h> > +#include <rtems/score/basedefs.h> > + > +#ifdef __cplusplus > +extern "C" { > +#endif /* __cplusplus */ > + > +RTEMS_INLINE_ROUTINE void rtems_bintime( struct bintime *bt ) > +{ > + _Timecounter_Bintime( bt ); > +} > + > +RTEMS_INLINE_ROUTINE void rtems_nanotime( struct timespec *ts ) > +{ > + _Timecounter_Nanotime( ts ); > +} > + > +RTEMS_INLINE_ROUTINE void rtems_microtime( struct timeval *tv ) > +{ > + _Timecounter_Microtime( tv ); > +} > + > +RTEMS_INLINE_ROUTINE void rtems_binuptime( struct bintime *bt ) > +{ > + _Timecounter_Binuptime( bt ); > +} > + > +RTEMS_INLINE_ROUTINE void rtems_nanouptime( struct timespec *ts ) > +{ > + _Timecounter_Nanouptime( ts ); > +} > + > +RTEMS_INLINE_ROUTINE void rtems_microuptime( struct timeval *tv ) > +{ > + _Timecounter_Microuptime( tv ); > +} > + > +RTEMS_INLINE_ROUTINE void rtems_getbintime( struct bintime *bt ) > +{ > + _Timecounter_Getbintime( bt ); > +} > + > +RTEMS_INLINE_ROUTINE void rtems_getnanotime( struct timespec *ts ) > +{ > + _Timecounter_Getnanotime( ts ); > +} > + > +RTEMS_INLINE_ROUTINE void rtems_getmicrotime( struct timeval *tv ) > +{ > + _Timecounter_Getmicrotime( tv ); > +} > + > +RTEMS_INLINE_ROUTINE void rtems_getbinuptime( struct bintime *bt ) > +{ > + _Timecounter_Getbinuptime( bt ); > +} > + > +RTEMS_INLINE_ROUTINE void rtems_getnanouptime( struct timespec *ts ) > +{ > + _Timecounter_Getnanouptime( ts ); > +} > + > +RTEMS_INLINE_ROUTINE void rtems_getmicrouptime( struct timeval *tv ) > +{ > + _Timecounter_Getmicrouptime( tv ); > +} > + > +#ifdef __cplusplus > +} > +#endif /* __cplusplus */ > + > +#endif /* _RTEMS_TIMECOUNTER_H */ > diff --git a/cpukit/sapi/preinstall.am b/cpukit/sapi/preinstall.am > index 3f864bb..4509842 100644 > --- a/cpukit/sapi/preinstall.am > +++ b/cpukit/sapi/preinstall.am > @@ -82,6 +82,10 @@ $(PROJECT_INCLUDE)/rtems/sptables.h: > include/rtems/sptables.h $(PROJECT_INCLUDE) > $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/sptables.h > PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/sptables.h > > +$(PROJECT_INCLUDE)/rtems/timecounter.h: include/rtems/timecounter.h > $(PROJECT_INCLUDE)/rtems/$(dirstamp) > + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/timecounter.h > +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/timecounter.h > + > $(PROJECT_INCLUDE)/rtems/timespec.h: include/rtems/timespec.h > $(PROJECT_INCLUDE)/rtems/$(dirstamp) > $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/timespec.h > PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/timespec.h > diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c > index 235ba77..5c265a6 100644 > --- a/cpukit/sapi/src/exinit.c > +++ b/cpukit/sapi/src/exinit.c > @@ -44,6 +44,7 @@ > #include <rtems/score/priority.h> > #include <rtems/score/schedulerimpl.h> > #include <rtems/score/smpimpl.h> > +#include <rtems/score/timecounter.h> > #include <rtems/score/threadimpl.h> > #include <rtems/score/todimpl.h> > #include <rtems/score/userextimpl.h> > @@ -69,6 +70,8 @@ void rtems_initialize_data_structures(void) > * are disabled by boot_card(). > */ > > + _Timecounter_Initialize(); > + > #if defined(RTEMS_MULTIPROCESSING) > /* > * Initialize the system state based on whether this is an MP system. > diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am > index 55fdc99..596df68 100644 > --- a/cpukit/score/Makefile.am > +++ b/cpukit/score/Makefile.am > @@ -94,7 +94,8 @@ include_rtems_score_HEADERS += > include/rtems/score/threadqimpl.h > include_rtems_score_HEADERS += include/rtems/score/threadsync.h > include_rtems_score_HEADERS += include/rtems/score/timespec.h > include_rtems_score_HEADERS += include/rtems/score/timestamp.h > -include_rtems_score_HEADERS += include/rtems/score/timestamp64.h > +include_rtems_score_HEADERS += include/rtems/score/timecounter.h > +include_rtems_score_HEADERS += include/rtems/score/timecounterimpl.h > include_rtems_score_HEADERS += include/rtems/score/tls.h > include_rtems_score_HEADERS += include/rtems/score/tod.h > include_rtems_score_HEADERS += include/rtems/score/todimpl.h > @@ -317,18 +318,10 @@ libscore_a_SOURCES += src/timespecaddto.c > src/timespecfromticks.c \ > src/timespecsubtract.c src/timespectoticks.c src/timespecdivide.c \ > src/timespecdividebyinteger.c src/timespecgetasnanoseconds.c > > -## TIMESTAMP_INT64_C_FILES > -libscore_a_SOURCES += src/ts64addto.c \ > - src/ts64divide.c src/ts64equalto.c \ > - src/ts64getnanoseconds.c src/ts64getseconds.c \ > - src/ts64lessthan.c \ > - src/ts64set.c src/ts64settozero.c src/ts64subtract.c \ > - src/ts64totimespec.c src/ts64totimeval.c > - > ## TOD_C_FILES > -libscore_a_SOURCES += src/coretod.c src/coretodset.c src/coretodget.c \ > - src/coretodgetuptimetimespec.c src/coretodtickle.c \ > - src/coretodsecondssinceepoch.c src/coretodtickspersec.c \ > +libscore_a_SOURCES += src/coretod.c src/coretodset.c \ > + src/coretodtickle.c \ > + src/coretodtickspersec.c \ > src/coretodadjust.c > > ## WATCHDOG_C_FILES > @@ -353,6 +346,7 @@ libscore_a_SOURCES += src/once.c > libscore_a_SOURCES += src/resourceiterate.c > libscore_a_SOURCES += src/smpbarrierwait.c > libscore_a_SOURCES += src/kern_tc.c > +libscore_a_SOURCES += src/tcgetscalerandmask.c > > EXTRA_DIST = src/Unlimited.txt > > diff --git a/cpukit/score/include/rtems/score/timecounter.h > b/cpukit/score/include/rtems/score/timecounter.h > index 3744a76..bae5851 100644 > --- a/cpukit/score/include/rtems/score/timecounter.h > +++ b/cpukit/score/include/rtems/score/timecounter.h > @@ -1,23 +1,52 @@ > +/* > + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. > + * > + * embedded brains GmbH > + * Dornierstr. 4 > + * 82178 Puchheim > + * Germany > + * <rt...@embedded-brains.de> > + * > + * The license and distribution terms for this file may be > + * found in the file LICENSE in this distribution or at > + * http://www.rtems.org/license/LICENSE. > + */ > + > +#ifndef _RTEMS_SCORE_TIMECOUNTER_H > +#define _RTEMS_SCORE_TIMECOUNTER_H > > #include <sys/time.h> > > -void _Timecounter_Initialize(void); > +#ifdef __cplusplus > +extern "C" { > +#endif /* __cplusplus */ > + > +void _Timecounter_Bintime( struct bintime *bt ); > + > +void _Timecounter_Nanotime( struct timespec *ts ); > + > +void _Timecounter_Microtime( struct timeval *tv ); > + > +void _Timecounter_Binuptime( struct bintime *bt ); > + > +void _Timecounter_Nanouptime( struct timespec *ts ); > + > +void _Timecounter_Microuptime( struct timeval *tv ); > + > +void _Timecounter_Getbintime( struct bintime *bt ); > + > +void _Timecounter_Getnanotime( struct timespec *ts ); > + > +void _Timecounter_Getmicrotime( struct timeval *tv ); > > -void _Timecounter_Set_clock(const struct timespec *ts); > +void _Timecounter_Getbinuptime( struct bintime *bt ); > > -void _Timecounter_Ticktock(int cnt); > +void _Timecounter_Getnanouptime( struct timespec *ts ); > > -void rtems_bintime(struct bintime *bt); > -void rtems_nanotime(struct timespec *tsp); > -void rtems_microtime(struct timeval *tvp); > -void rtems_binuptime(struct bintime *bt); > -void rtems_nanouptime(struct timespec *tsp); > -void rtems_microuptime(struct timeval *tvp); > -void rtems_getbintime(struct bintime *bt); > -void rtems_getnanotime(struct timespec *tsp); > -void rtems_getmicrotime(struct timeval *tvp); > -void rtems_getbinuptime(struct bintime *bt); > -void rtems_getnanouptime(struct timespec *tsp); > -void rtems_getmicrouptime(struct timeval *tvp); > +void _Timecounter_Getmicrouptime( struct timeval *tv ); > > +#ifdef __cplusplus > +} > +#endif /* __cplusplus */ > > +#endif /* _RTEMS_SCORE_TIMECOUNTER_H */ > diff --git a/cpukit/score/include/rtems/score/timecounterimpl.h > b/cpukit/score/include/rtems/score/timecounterimpl.h > new file mode 100644 > index 0000000..5987672 > --- /dev/null > +++ b/cpukit/score/include/rtems/score/timecounterimpl.h > @@ -0,0 +1,119 @@ > +/* > + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. > + * > + * embedded brains GmbH > + * Dornierstr. 4 > + * 82178 Puchheim > + * Germany > + * <rt...@embedded-brains.de> > + * > + * The license and distribution terms for this file may be > + * found in the file LICENSE in this distribution or at > + * http://www.rtems.org/license/LICENSE. > + */ > + > +#ifndef _RTEMS_SCORE_TIMECOUNTERIMPL_H > +#define _RTEMS_SCORE_TIMECOUNTERIMPL_H > + > +#include <rtems/score/timecounter.h> > +#include <sys/timetc.h> > + > +#ifdef __cplusplus > +extern "C" { > +#endif /* __cplusplus */ > + > +#define TIMECOUNTER_DEFAULT_DRIVER_QUALITY 100 > + > +/** > + * @brief Starts the initialization of the timecounter. > + * > + * This routine sets hardclock ticks per milliseconds and assigns to the > + * timecounters where to get the timecount information for each windup() > call. > + * > + */ > +void _Timecounter_Initialize(void); > + > +/** > + * @brief Sets the clock of the timecounter. > + * > + * This routine converts an input timespec into a bintime which is then set > in > + * the timecounter. > + * > + * @param[in] ts is a timespec for conversion. > + */ > +void _Timecounter_Set_clock(const struct timespec *ts); > + > +/** > + * @brief Sets up the ring of timecounters. > + * > + * This routine installs a "ring" of minimum one timecounter in the format > of > + * the input and calls the windup function afterwards. > + * > + * @param[in] tc is the timecounter instance of which the ring should be > + * created. > + * > + * @code tc->tc_next = timecounters; > + * timecounters = tc; > + * ... > + * (void)tc->tc_get_timecount(tc); > + * ... > + * tc_windup(); > + * @endcode > + */ > +void _Timecounter_Install(struct timecounter *tc); > + > +/** > + * @brief Interrupt Routine that triggers a windup call. > + * > + * Usage for timecount registers that run on binary basis. > + */ > + > +void _Timecounter_Tick(void); > + > +/** > + * @brief Interrupt Routine that cannot trigger a windup call. > + * > + * This routine is needed for a get_timecounter request where the > information > + * is received from a real time clock register that does not offer a binary > + * basis. Here the bintime offset is generated by giving the delta and > offset > + * parameters as inputs. > + * > + * @param[in] delta is one timecounter interval + time from the start of the > + * new interval. > + * @param[in] offset is the time from the start of the new interval. > + * > + * @code > + * th = timehands; > + * ogen = th->th_generation; > + * th->th_offset_count = offset; > + * bintime_addx(&th->th_offset, th->th_scale * delta); > + * @endcode > + */ > + > +void _Timecounter_Tick_simple(u_int delta, u_int offset); > + > +/** > + * @brief creates scaler and mask for _Timecounter_Tick_simple. > + * > + * Calculates the scaler and mask of the next upcoming power of 2. The > scaler > + * is the next power of 2 divided by the counter_ticks_per_clock_ticks. The > + * mask is double the next power of 2 minus 1, as the timecounter can > return a > + * maximum value of the length of two intervals. > + * > + * @param[in] counter_ticks_per_clock_tick > + * @param[out] scaler is the value of the scaling factor which has to > imposed > + * on the values returned by the get_timecount information > + * @param[out] mask is the value of double the next power of 2 minus 1 > + */ > + > +void _Timecounter_Get_binary_scaler_and_mask( > + uint32_t counter_ticks_per_clock_tick, > + uint64_t *scaler, > + uint32_t *mask > +); > + > +#ifdef __cplusplus > +} > +#endif /* __cplusplus */ > + > +#endif /* _RTEMS_SCORE_TIMECOUNTERIMPL_H */ > diff --git a/cpukit/score/include/rtems/score/timestamp.h > b/cpukit/score/include/rtems/score/timestamp.h > index dbd0425..056976b 100644 > --- a/cpukit/score/include/rtems/score/timestamp.h > +++ b/cpukit/score/include/rtems/score/timestamp.h > @@ -42,55 +42,45 @@ > > #include <sys/time.h> > > -#include <rtems/score/cpu.h> > -#include <rtems/score/timespec.h> > +#include <rtems/score/basedefs.h> > + > +#include "timespec.h" > > #ifdef __cplusplus > extern "C" { > #endif > > -#if ! ( ( CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE \ > - && CPU_TIMESTAMP_USE_INT64 == FALSE \ > - && CPU_TIMESTAMP_USE_INT64_INLINE == FALSE ) \ > - || ( CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == FALSE \ > - && CPU_TIMESTAMP_USE_INT64 == TRUE \ > - && CPU_TIMESTAMP_USE_INT64_INLINE == FALSE ) \ > - || ( CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == FALSE \ > - && CPU_TIMESTAMP_USE_INT64 == FALSE \ > - && CPU_TIMESTAMP_USE_INT64_INLINE == TRUE ) ) > - #error "Invalid SuperCore Timestamp implementations selection." > -#endif > - > -#if CPU_TIMESTAMP_USE_INT64 == TRUE || CPU_TIMESTAMP_USE_INT64_INLINE == TRUE > - #include <rtems/score/timestamp64.h> > -#endif > +#define MICROSECONDS_PER_SECOND 1000000 > +#define NANOSECONDS_PER_SECOND 1000000000 > > /** > * Define the Timestamp control type. > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - typedef struct timespec Timestamp_Control; > -#else > - typedef Timestamp64_Control Timestamp_Control; > -#endif > +typedef struct bintime Timestamp_Control; > > /** > * @brief Set timestamp to specified seconds and nanoseconds. > * > - * This method sets the timestamp to the specified @a _seconds and @a > _nanoseconds > - * value. > + * This method sets the timestamp to the specified @a _seconds and > + * @a _nanoseconds value. > * > * @param[in] _time points to the timestamp instance to validate. > * @param[in] _seconds is the seconds portion of the timestamp > * @param[in] _nanoseconds is the nanoseconds portion of the timestamp > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - #define _Timestamp_Set( _time, _seconds, _nanoseconds ) \ > - _Timespec_Set( _time, _seconds, _nanoseconds ) > -#else > - #define _Timestamp_Set( _time, _seconds, _nanoseconds ) \ > - _Timestamp64_Set( _time, _seconds, _nanoseconds ) > -#endif > +RTEMS_INLINE_ROUTINE void _Timestamp_Set( > + Timestamp_Control *_time, > + time_t _seconds, > + long _nanoseconds > +) > +{ > + struct timespec _ts; > + > + _ts.tv_sec = _seconds; > + _ts.tv_nsec = _nanoseconds; > + > + timespec2bintime(&_ts, _time); > +} > > /** > * @brief Sets the timestamp to zero. > @@ -100,13 +90,14 @@ extern "C" { > * > * @param[in] _time points to the timestamp instance to zero. > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - #define _Timestamp_Set_to_zero( _time ) \ > - _Timespec_Set_to_zero( _time ) > -#else > - #define _Timestamp_Set_to_zero( _time ) \ > - _Timestamp64_Set_to_zero( _time ) > -#endif > + > +RTEMS_INLINE_ROUTINE void _Timestamp_Set_to_zero( > + Timestamp_Control *_time > +) > +{ > + _time->sec = 0; > + _time->frac = 0; > +} > > /** > * @brief Less than operator for timestamps. > @@ -119,13 +110,23 @@ extern "C" { > * @retval This method returns true if @a _lhs is less than the @a _rhs and > * false otherwise. > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - #define _Timestamp_Less_than( _lhs, _rhs ) \ > - _Timespec_Less_than( _lhs, _rhs ) > -#else > - #define _Timestamp_Less_than( _lhs, _rhs ) \ > - _Timestamp64_Less_than( _lhs, _rhs ) > -#endif > + > +RTEMS_INLINE_ROUTINE bool _Timestamp_Less_than( > + Timestamp_Control *_lhs, Timestamp_Control *_rhs > +) > +{ > + if ( _lhs->sec < _rhs->sec ) > + return true; > + > + if ( _lhs->sec > _rhs->sec ) > + return false; > + > + /* assert: lhs->tv_sec == rhs->tv_sec */ > + if ( _lhs->frac < _rhs->frac) > + return true; > + > + return false; > +} > > /** > * @brief Greater than operator for timestamps. > @@ -138,8 +139,23 @@ extern "C" { > * @retval This method returns true if @a _lhs is greater than the @a _rhs > and > * false otherwise. > */ > -#define _Timestamp_Greater_than( _lhs, _rhs ) \ > - _Timestamp_Less_than( _rhs, _lhs ) > + > +RTEMS_INLINE_ROUTINE bool _Timestamp_Greater_than( > + Timestamp_Control *_lhs, Timestamp_Control *_rhs > +) > +{ > + if ( _lhs->sec > _rhs->sec ) > + return true; > + > + if ( _lhs->sec < _rhs->sec ) > + return false; > + > + /* assert: lhs->tv_sec == rhs->tv_sec */ > + if ( _lhs->frac > _rhs->frac) > + return true; > + > + return false; > +} > > /** > * @brief Equal to than operator for timestamps. > @@ -152,13 +168,16 @@ extern "C" { > * @retval This method returns true if @a _lhs is equal to @a _rhs and > * false otherwise. > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - #define _Timestamp_Equal_to( _lhs, _rhs ) \ > - _Timespec_Equal_to( _lhs, _rhs ) > -#else > - #define _Timestamp_Equal_to( _lhs, _rhs ) \ > - _Timestamp64_Equal_to( _lhs, _rhs ) > -#endif > + > +RTEMS_INLINE_ROUTINE bool _Timestamp_Equal_to( > + Timestamp_Control *_lhs, Timestamp_Control *_rhs > +) > +{ > + if (( _lhs->sec < _rhs->sec) && (_lhs->frac == _rhs->frac)) > + return true; > + > + return false; > +} > > /** > * @brief Adds two timestamps. > @@ -171,13 +190,15 @@ extern "C" { > * > * @retval This method returns the number of seconds @a time increased by. > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - #define _Timestamp_Add_to( _time, _add ) \ > - _Timespec_Add_to( _time, _add ) > -#else > - #define _Timestamp_Add_to( _time, _add ) \ > - _Timestamp64_Add_to( _time, _add ) > -#endif > +RTEMS_INLINE_ROUTINE time_t _Timestamp_Add_to( > + Timestamp_Control *_time, > + const Timestamp_Control *_add > +) > +{ > + time_t seconds = _time->sec; > + bintime_add(_time, _add); > + return ((_time->sec) - seconds); > +} > > /** > * @brief Subtracts two timestamps. > @@ -192,13 +213,17 @@ extern "C" { > * > * @retval This method fills in @a _result. > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - #define _Timestamp_Subtract( _start, _end, _result ) \ > - _Timespec_Subtract( _start, _end, _result ) > -#else > - #define _Timestamp_Subtract( _start, _end, _result ) \ > - _Timestamp64_Subtract( _start, _end, _result ) > -#endif > +RTEMS_INLINE_ROUTINE void _Timestamp_Subtract( > + const Timestamp_Control *_start, > + const Timestamp_Control *_end, > + Timestamp_Control *_result > +) > +{ > + _result->sec = _end->sec; > + _result->frac = _end->frac; > + > + bintime_sub(_result, _start); > +} > > /** > * @brief Divides a timestamp by another timestamp. > @@ -213,13 +238,24 @@ extern "C" { > * > * @retval This method fills in @a result. > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - #define _Timestamp_Divide( _lhs, _rhs, _ival_percentage, _fval_percentage > ) \ > - _Timespec_Divide( _lhs, _rhs, _ival_percentage, _fval_percentage ) > -#else > - #define _Timestamp_Divide( _lhs, _rhs, _ival_percentage, _fval_percentage > ) \ > - _Timestamp64_Divide( _lhs, _rhs, _ival_percentage, > _fval_percentage ) > -#endif > +RTEMS_INLINE_ROUTINE void _Timestamp_Divide( > + const Timestamp_Control *_lhs, > + const Timestamp_Control *_rhs, > + uint32_t *_ival_percentage, > + uint32_t *_fval_percentage > +) > +{ > + struct timespec _time_left, _time_right; > + > + bintime2timespec(_lhs, &_time_left); > + bintime2timespec(_rhs, &_time_right); > + > + _Timespec_Divide(&_time_left, > + &_time_right, > + _ival_percentage, > + _fval_percentage > + ); > +} > > /** > * @brief Get seconds portion of timestamp. > @@ -230,13 +266,12 @@ extern "C" { > * > * @retval The seconds portion of @a _time. > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - #define _Timestamp_Get_seconds( _time ) \ > - _Timespec_Get_seconds( _time ) > -#else > - #define _Timestamp_Get_seconds( _time ) \ > - _Timestamp64_Get_seconds( _time ) > -#endif > +RTEMS_INLINE_ROUTINE time_t _Timestamp_Get_seconds( > + const Timestamp_Control *_time > +) > +{ > + return _time->sec; > +} > > /** > * @brief Get nanoseconds portion of timestamp. > @@ -247,13 +282,14 @@ extern "C" { > * > * @retval The nanoseconds portion of @a _time. > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - #define _Timestamp_Get_nanoseconds( _time ) \ > - _Timespec_Get_nanoseconds( _time ) > -#else > - #define _Timestamp_Get_nanoseconds( _time ) \ > - _Timestamp64_Get_nanoseconds( _time ) > -#endif > +RTEMS_INLINE_ROUTINE uint32_t _Timestamp_Get_nanoseconds( > + const Timestamp_Control *_time > +) > +{ > + struct timespec _ts; > + bintime2timespec(_time, &_ts); > + return _ts.tv_nsec; > +} > > /** > * @brief Get the timestamp as nanoseconds. > @@ -261,16 +297,23 @@ extern "C" { > * This method returns the timestamp as nanoseconds. > * > * @param[in] _time points to the timestamp > + * @param[in] _nanoseconds adds nanoseconds since last tick > * > * @retval The time in nanoseconds. > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - #define _Timestamp_Get_As_nanoseconds( _timestamp, _nanoseconds ) \ > - _Timespec_Get_As_nanoseconds( _timestamp, _nanoseconds ) > -#else > - #define _Timestamp_Get_As_nanoseconds( _timestamp, _nanoseconds ) \ > - _Timestamp64_Get_As_nanoseconds( _timestamp, _nanoseconds ) > -#endif > +RTEMS_INLINE_ROUTINE uint64_t _Timestamp_Get_As_nanoseconds( > + const Timestamp_Control *_time, > + const uint32_t _nanoseconds > +) > +{ > + struct timespec ts; > + uint64_t overall_ns_val; > + > + bintime2timespec(_time, &ts); > + overall_ns_val = _Timespec_Get_As_nanoseconds(&ts, _nanoseconds); > + > + return overall_ns_val; > +} > > /** > * @brief Convert timestamp to struct timespec. > @@ -280,14 +323,13 @@ extern "C" { > * @param[in] _timestamp points to the timestamp > * @param[in] _timespec points to the timespec > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - /* in this case we know they are the same type so use simple assignment */ > - #define _Timestamp_To_timespec( _timestamp, _timespec ) \ > - *(_timespec) = *(_timestamp) > -#else > - #define _Timestamp_To_timespec( _timestamp, _timespec ) \ > - _Timestamp64_To_timespec( _timestamp, _timespec ) > -#endif > +RTEMS_INLINE_ROUTINE void _Timestamp_To_timespec( > + const Timestamp_Control *_timestamp, > + struct timespec *_timespec > +) > +{ > + bintime2timespec(_timestamp, _timespec); > +} > > /** > * @brief Convert timestamp to struct timeval. > @@ -295,16 +337,13 @@ extern "C" { > * @param[in] _timestamp points to the timestamp > * @param[in] _timeval points to the timeval > */ > -#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE > - #define _Timestamp_To_timeval( _timestamp, _timeval ) \ > - do { \ > - (_timeval)->tv_sec = (_timestamp)->tv_sec; \ > - (_timeval)->tv_usec = (_timestamp)->tv_nsec / 1000; \ > - } while (0) > -#else > - #define _Timestamp_To_timeval( _timestamp, _timeval ) \ > - _Timestamp64_To_timeval( _timestamp, _timeval ) > -#endif > +RTEMS_INLINE_ROUTINE void _Timestamp_To_timeval( > + const Timestamp_Control *_timestamp, > + struct timeval *_timeval > +) > +{ > + bintime2timeval(_timestamp, _timeval); > +} > > #ifdef __cplusplus > } > diff --git a/cpukit/score/include/rtems/score/timestamp64.h > b/cpukit/score/include/rtems/score/timestamp64.h > deleted file mode 100644 > index 39b4965..0000000 > --- a/cpukit/score/include/rtems/score/timestamp64.h > +++ /dev/null > @@ -1,379 +0,0 @@ > -/** > - * @file rtems/score/timestamp64.h > - * > - * @brief Helpers for Manipulating 64-bit Integer Timestamps > - * > - * This include file contains helpers for manipulating > - * 64-bit integer timestamps. > - */ > - > -/* > - * COPYRIGHT (c) 1989-2009. > - * 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.org/license/LICENSE. > - */ > - > -#ifndef _RTEMS_SCORE_TIMESTAMP64_H > -#define _RTEMS_SCORE_TIMESTAMP64_H > - > -/** > - * @defgroup SuperCoreTimestamp64 SuperCore Sixty-Four Bit Timestamps > - * > - * @ingroup Score > - * > - * This handler encapsulates functionality related to manipulating > - * the 64 bit integer implementation of SuperCore Timestamps. > - */ > -/**@{*/ > - > -#ifdef __cplusplus > -extern "C" { > -#endif > - > -/* > - * This .h file is not for general use. It is an alternative > - * implementation of Timestamps and should only be used that way. > - */ > -#ifndef _RTEMS_SCORE_TIMESTAMP_H > - #error "Should only be included by rtems/score/timestamp.h" > -#endif > - > -/* > - * Verify something is defined. > - */ > -#if CPU_TIMESTAMP_USE_INT64 != TRUE && CPU_TIMESTAMP_USE_INT64_INLINE != TRUE > - #error "SuperCore Timestamp64 implementation included but not defined." > -#endif > - > -/** > - * Define the Timestamp control type. > - */ > -typedef int64_t Timestamp64_Control; > - > -static inline void _Timestamp64_implementation_Set( > - Timestamp64_Control *_time, > - Timestamp64_Control _seconds, > - Timestamp64_Control _nanoseconds > -) > -{ > - *_time = _seconds * 1000000000L + _nanoseconds; > -} > - > -/** > - * @brief Set 64-bit timestamp to seconds nanosecond. > - * > - * This method sets the timestamp to the specified seconds and nanoseconds > - * value. > - * > - * @param[in] _time points to the timestamp instance to validate. > - * @param[in] _seconds is the seconds portion of the timestamp > - * @param[in] _nanoseconds is the nanoseconds portion of the timestamp > - */ > -#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE > - #define _Timestamp64_Set( _time, _seconds, _nanoseconds ) \ > - _Timestamp64_implementation_Set( _time, _seconds, _nanoseconds ) > -#else > - void _Timestamp64_Set( > - Timestamp64_Control *_time, > - Timestamp64_Control _seconds, > - Timestamp64_Control _nanoseconds > - ); > -#endif > - > -static inline void _Timestamp64_implementation_Set_to_zero( > - Timestamp64_Control *_time > -) > -{ > - *_time = 0; > -} > - > -/** > - * @brief Sets the 64-bit timestamp to zero. > - * > - * This method sets the timestamp to zero value. > - * > - * @param[in] _time points to the timestamp instance to zero. > - */ > -#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE > - #define _Timestamp64_Set_to_zero( _time ) \ > - _Timestamp64_implementation_Set_to_zero( _time ) > -#else > - void _Timestamp64_Set_to_zero( > - Timestamp64_Control *_time > - ); > -#endif > - > -static inline bool _Timestamp64_implementation_Less_than( > - const Timestamp64_Control *_lhs, > - const Timestamp64_Control *_rhs > -) > -{ > - return *_lhs < *_rhs; > -} > - > -/** > - * @brief The "less than" operator for 64-bit timestamps. > - * > - * This method is the less than operator for timestamps. > - * > - * @param[in] _lhs points to the left hand side timestamp > - * @param[in] _rhs points to the right hand side timestamp > - * > - * @retval This method returns true if @a _lhs is less than the @a _rhs and > - * false otherwise. > - */ > -#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE > - #define _Timestamp64_Less_than( _lhs, _rhs ) \ > - _Timestamp64_implementation_Less_than( _lhs, _rhs ) > -#else > - bool _Timestamp64_Less_than( > - const Timestamp64_Control *_lhs, > - const Timestamp64_Control *_rhs > - ); > -#endif > - > -static inline bool _Timestamp64_implementation_Equal_to( > - const Timestamp64_Control *_lhs, > - const Timestamp64_Control *_rhs > -) > -{ > - return *_lhs == *_rhs; > -} > - > -#define _Timestamp64_Greater_than( _lhs, _rhs ) \ > - _Timestamp64_Less_than( _rhs, _lhs ) > - > -/** > - * @brief The "equal to" operator for 64-bit timestamps. > - * > - * This method is the is equal to than operator for timestamps. > - * > - * @param[in] _lhs points to the left hand side timestamp > - * @param[in] _rhs points to the right hand side timestamp > - * > - * @retval This method returns true if @a _lhs is equal to @a _rhs and > - * false otherwise. > - */ > -#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE > - #define _Timestamp64_Equal_to( _lhs, _rhs ) \ > - _Timestamp64_implementation_Equal_to( _lhs, _rhs ) > -#else > - bool _Timestamp64_Equal_to( > - const Timestamp64_Control *_lhs, > - const Timestamp64_Control *_rhs > - ); > -#endif > - > -static inline void _Timestamp64_implementation_Add_to( > - Timestamp64_Control *_time, > - const Timestamp64_Control *_add > -) > -{ > - *_time += *_add; > -} > - > -/** > - * @brief Add two 64-bit timestamps. > - * > - * This routine adds two timestamps. The second argument is added > - * to the first. > - * > - * @param[in] _time points to the base time to be added to > - * @param[in] _add points to the timestamp to add to the first argument > - * > - * @retval This method returns the number of seconds @a time increased by. > - */ > -#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE > - #define _Timestamp64_Add_to( _time, _add ) \ > - _Timestamp64_implementation_Add_to( _time, _add ) > -#else > - void _Timestamp64_Add_to( > - Timestamp64_Control *_time, > - const Timestamp64_Control *_add > - ); > -#endif > - > -static inline void _Timestamp64_implementation_Subtract( > - const Timestamp64_Control *_start, > - const Timestamp64_Control *_end, > - Timestamp64_Control *_result > -) > -{ > - *_result = *_end - *_start; > -} > - > -/** > - * @brief Subtract two 64-bit timestamps. > - * > - * This routine subtracts two timestamps. @a result is set to > - * @a end - @a start. > - * > - * @param[in] _start points to the starting time > - * @param[in] _end points to the ending time > - * @param[out] _result points to the difference between > - * starting and ending time. > - */ > -#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE > - #define _Timestamp64_Subtract( _start, _end, _result ) \ > - _Timestamp64_implementation_Subtract( _start, _end, _result ) > -#else > - void _Timestamp64_Subtract( > - const Timestamp64_Control *_start, > - const Timestamp64_Control *_end, > - Timestamp64_Control *_result > - ); > -#endif > - > -/** > - * @brief Divide 64-bit timestamp by another 64-bit timestamp. > - * > - * This routine divides a timestamp by another timestamp. The > - * intended use is for calculating percentages to three decimal points. > - * > - * @param[in] _lhs points to the left hand number > - * @param[in] _rhs points to the right hand number > - * @param[out] _ival_percentage points to the integer portion of the average > - * @param[out] _fval_percentage points to the thousandths of percentage > - */ > -void _Timestamp64_Divide( > - const Timestamp64_Control *_lhs, > - const Timestamp64_Control *_rhs, > - uint32_t *_ival_percentage, > - uint32_t *_fval_percentage > -); > - > -static inline uint32_t _Timestamp64_implementation_Get_seconds( > - const Timestamp64_Control *_time > -) > -{ > - return (uint32_t) (*_time / 1000000000L); > -} > - > -/** > - * @brief Get seconds portion of a 64-bit timestamp. > - * > - * This method returns the seconds portion of the specified timestamp > - * > - * @param[in] _time points to the timestamp > - * > - * @retval The seconds portion of @a _time. > - */ > -#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE > - #define _Timestamp64_Get_seconds( _time ) \ > - _Timestamp64_implementation_Get_seconds( _time ) > -#else > - uint32_t _Timestamp64_Get_seconds( > - const Timestamp64_Control *_time > - ); > -#endif > - > -static inline uint32_t _Timestamp64_implementation_Get_nanoseconds( > - const Timestamp64_Control *_time > -) > -{ > - return (uint32_t) (*_time % 1000000000L); > -} > - > -/** > - * @brief Get nanoseconds portion of a 64-bit timestamp. > - * > - * This method returns the nanoseconds portion of the specified timestamp > - * > - * @param[in] _time points to the timestamp > - * > - * @retval The nanoseconds portion of @a _time. > - */ > -#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE > - #define _Timestamp64_Get_nanoseconds( _time ) \ > - _Timestamp64_implementation_Get_nanoseconds( _time ) > -#else > - uint32_t _Timestamp64_Get_nanoseconds( > - const Timestamp64_Control *_time > - ); > -#endif > - > -static inline uint64_t _Timestamp64_implementation_Get_As_nanoseconds( > - const Timestamp64_Control *_time, > - const uint32_t nanoseconds > -) > -{ > - return *_time + (uint64_t) nanoseconds; > -} > - > -/** > - * @brief Get the 64-bit timestamp as nanoseconds. > - * > - * This method returns the 64-bit timestamp as it is already in nanoseconds. > - * > - * @param[in] _time points to the timestamp > - * > - * @retval The nanoseconds portion of @a _time. > - */ > -#define _Timestamp64_Get_As_nanoseconds( _time, _nanoseconds ) \ > - _Timestamp64_implementation_Get_As_nanoseconds( _time, _nanoseconds ) > - > -static inline void _Timestamp64_implementation_To_timespec( > - const Timestamp64_Control *_timestamp, > - struct timespec *_timespec > -) > -{ > - _timespec->tv_sec = (time_t) (*_timestamp / 1000000000L); > - _timespec->tv_nsec = (long) (*_timestamp % 1000000000L); > -} > - > -/** > - * @brief Convert 64-bit timestamp to struct timespec. > - * > - * This method returns the seconds portion of the specified timestamp > - * > - * @param[in] _timestamp points to the timestamp > - * @param[out] _timespec points to the timespec > - */ > -#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE > - #define _Timestamp64_To_timespec( _timestamp, _timespec ) \ > - _Timestamp64_implementation_To_timespec( _timestamp, _timespec ) > -#else > - void _Timestamp64_To_timespec( > - const Timestamp64_Control *_timestamp, > - struct timespec *_timespec > - ); > -#endif > - > -static inline void _Timestamp64_implementation_To_timeval( > - const Timestamp64_Control *_timestamp, > - struct timeval *_timeval > -) > -{ > - _timeval->tv_sec = (time_t) (*_timestamp / 1000000000U); > - _timeval->tv_usec = (suseconds_t) ((*_timestamp % 1000000000U) / 1000U); > -} > - > -/** > - * @brief Convert 64-bit timestamp to struct timeval. > - * > - * This method returns the seconds portion of the specified timestamp > - * > - * @param[in] _timestamp points to the timestamp > - * @param[out] _timeval points to the timeval > - */ > -#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE > - #define _Timestamp64_To_timeval( _timestamp, _timeval ) \ > - _Timestamp64_implementation_To_timeval( _timestamp, _timeval ) > -#else > - void _Timestamp64_To_timeval( > - const Timestamp64_Control *_timestamp, > - struct timeval *_timeval > - ); > -#endif > - > -#ifdef __cplusplus > -} > -#endif > - > -/**@}*/ > - > -#endif > -/* end of include file */ > diff --git a/cpukit/score/include/rtems/score/tod.h > b/cpukit/score/include/rtems/score/tod.h > index 1972b0f..c0ab5e7 100644 > --- a/cpukit/score/include/rtems/score/tod.h > +++ b/cpukit/score/include/rtems/score/tod.h > @@ -24,15 +24,6 @@ > extern "C" { > #endif > > -/** > - * @brief Returns the nanoseconds since the last clock tick. > - * > - * @ingroup ScoreTOD > - * > - * @return The nanoseconds since the last clock tick. > - */ > -typedef uint32_t ( *TOD_Nanoseconds_since_last_tick_routine )( void ); > - > #ifdef __cplusplus > } > #endif > diff --git a/cpukit/score/include/rtems/score/todimpl.h > b/cpukit/score/include/rtems/score/todimpl.h > index ad5ed39..4fe85d4 100644 > --- a/cpukit/score/include/rtems/score/todimpl.h > +++ b/cpukit/score/include/rtems/score/todimpl.h > @@ -19,8 +19,8 @@ > #define _RTEMS_SCORE_TODIMPL_H > > #include <rtems/score/tod.h> > -#include <rtems/score/isrlock.h> > #include <rtems/score/timestamp.h> > +#include <rtems/score/timecounterimpl.h> > > #include <sys/time.h> > #include <time.h> > @@ -131,25 +131,6 @@ extern "C" { > */ > typedef struct { > /** > - * @brief Current time of day value. > - * > - * This field is protected by the lock. > - */ > - Timestamp_Control now; > - > - /** > - * @brief System uptime. > - * > - * This field is protected by the lock. > - */ > - Timestamp_Control uptime; > - > - /** > - * @brief Lock to protect the now and uptime fields. > - */ > - ISR_lock_Control lock; > - > - /** > * @brief Time of day seconds trigger. > * > * This value specifies the nanoseconds since the last time of day second. > @@ -159,13 +140,6 @@ typedef struct { > uint32_t seconds_trigger; > > /** > - * @brief The current nanoseconds since last tick handler. > - * > - * This field must not be NULL after initialization. > - */ > - TOD_Nanoseconds_since_last_tick_routine nanoseconds_since_last_tick; > - > - /** > * @brief Indicates if the time of day is set. > * > * This is true if the application has set the current > @@ -176,12 +150,6 @@ typedef struct { > > SCORE_EXTERN TOD_Control _TOD; > > -#define _TOD_Acquire( _tod, lock_context ) \ > - _ISR_lock_ISR_disable_and_acquire( &( _tod )->lock, lock_context ) > - > -#define _TOD_Release( _tod, lock_context ) \ > - _ISR_lock_Release_and_ISR_enable( &( _tod )->lock, lock_context ) > - > /** > * @brief Initializes the time of day handler. > * > @@ -215,32 +183,18 @@ static inline void _TOD_Set( > _TOD_Set_with_timestamp( &tod_as_timestamp ); > } > > -/** > - * @brief Returns a snapshot of a clock. > - * > - * This function invokes the nanoseconds extension. > - * > - * @param[out] snapshot points to an area that will contain the current > - * TOD plus the BSP nanoseconds since last tick adjustment > - * @param[in] clock contains the current TOD > - * > - * @retval @a snapshot > - */ > -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 *time > ) > { > - Timestamp_Control tod_as_timestamp; > - Timestamp_Control *tod_as_timestamp_ptr; > + _Timecounter_Bintime(time); > +} > > - tod_as_timestamp_ptr = > - _TOD_Get_with_nanoseconds( &tod_as_timestamp, &_TOD.now ); > - _Timestamp_To_timespec( tod_as_timestamp_ptr, tod_as_timespec ); > +static inline void _TOD_Get_as_timespec( > + struct timespec *time > +) > +{ > + _Timecounter_Nanotime(time); > } > > /** > @@ -255,7 +209,7 @@ static inline void _TOD_Get_uptime( > Timestamp_Control *time > ) > { > - _TOD_Get_with_nanoseconds( time, &_TOD.uptime ); > + _Timecounter_Binuptime(time); > } > > /** > @@ -266,9 +220,12 @@ static inline void _TOD_Get_uptime( > * > * @param[in] time is a pointer to the uptime to be returned > */ > -void _TOD_Get_uptime_as_timespec( > +static inline void _TOD_Get_uptime_as_timespec( > struct timespec *time > -); > +) > +{ > + _Timecounter_Nanouptime(time); > +} > > /** > * @brief Number of seconds Since RTEMS epoch. > @@ -276,7 +233,14 @@ void _TOD_Get_uptime_as_timespec( > * The following contains the number of seconds from 00:00:00 > * January 1, TOD_BASE_YEAR until the current time of day. > */ > -uint32_t _TOD_Seconds_since_epoch( void ); > +static inline uint32_t _TOD_Seconds_since_epoch( void ) > +{ > + struct bintime bt; > + > + _Timecounter_Bintime(&bt); > + > + return bt.sec; > +} > > /** > * @brief Increments time of day at each clock tick. > @@ -314,12 +278,7 @@ RTEMS_INLINE_ROUTINE void _TOD_Get_timeval( > struct timeval *time > ) > { > - Timestamp_Control snapshot_as_timestamp; > - Timestamp_Control *snapshot_as_timestamp_ptr; > - > - snapshot_as_timestamp_ptr = > - _TOD_Get_with_nanoseconds( &snapshot_as_timestamp, &_TOD.now ); > - _Timestamp_To_timeval( snapshot_as_timestamp_ptr, time ); > + _Timecounter_Microtime(time); > } > > /** > @@ -335,18 +294,6 @@ void _TOD_Adjust( > ); > > /** > - * @brief Install the BSP's nanoseconds since clock tick handler > - * > - * @param[in] routine is the BSP's nanoseconds since clock tick method > - */ > -RTEMS_INLINE_ROUTINE void _TOD_Set_nanoseconds_since_last_tick_handler( > - TOD_Nanoseconds_since_last_tick_routine routine > -) > -{ > - _TOD.nanoseconds_since_last_tick = routine; > -} > - > -/** > * @brief Check if the TOD is Set > * > * @return TRUE is the time is set. FALSE otherwise. > diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am > index 75c8be6..b74afb8 100644 > --- a/cpukit/score/preinstall.am > +++ b/cpukit/score/preinstall.am > @@ -348,9 +348,13 @@ $(PROJECT_INCLUDE)/rtems/score/timestamp.h: > include/rtems/score/timestamp.h $(PR > $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timestamp.h > PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timestamp.h > > -$(PROJECT_INCLUDE)/rtems/score/timestamp64.h: > include/rtems/score/timestamp64.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) > - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timestamp64.h > -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timestamp64.h > +$(PROJECT_INCLUDE)/rtems/score/timecounter.h: > include/rtems/score/timecounter.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) > + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timecounter.h > +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timecounter.h > + > +$(PROJECT_INCLUDE)/rtems/score/timecounterimpl.h: > include/rtems/score/timecounterimpl.h > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) > + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timecounterimpl.h > +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timecounterimpl.h > > $(PROJECT_INCLUDE)/rtems/score/tls.h: include/rtems/score/tls.h > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) > $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/tls.h > diff --git a/cpukit/score/src/coretod.c b/cpukit/score/src/coretod.c > index 2deeeba..67d5104 100644 > --- a/cpukit/score/src/coretod.c > +++ b/cpukit/score/src/coretod.c > @@ -20,23 +20,15 @@ > > #include <rtems/score/todimpl.h> > > -static uint32_t _TOD_Nanoseconds_since_tick_default_handler( void ) > -{ > - return 0; > -} > - > void _TOD_Handler_initialization(void) > { > + struct timespec ts; > TOD_Control *tod = &_TOD; > > - _ISR_lock_Initialize( &tod->lock, "TOD" ); > - > - _Timestamp_Set( &tod->now, TOD_SECONDS_1970_THROUGH_1988, 0 ); > - > - _Timestamp_Set_to_zero( &tod->uptime ); > - > - tod->nanoseconds_since_last_tick = > - _TOD_Nanoseconds_since_tick_default_handler; > + ts.tv_sec = TOD_SECONDS_1970_THROUGH_1988; > + ts.tv_nsec = 0; > + _Timecounter_Initialize(); > + _Timecounter_Set_clock(&ts); > > /* TOD has not been set */ > tod->is_set = false; > diff --git a/cpukit/score/src/coretodadjust.c > b/cpukit/score/src/coretodadjust.c > index 09cf01a..6097e20 100644 > --- a/cpukit/score/src/coretodadjust.c > +++ b/cpukit/score/src/coretodadjust.c > @@ -25,8 +25,7 @@ void _TOD_Adjust( > const Timestamp_Control delta > ) > { > - Timestamp_Control tod; > - Timestamp_Control *tod_ptr; > + Timestamp_Control tod; > > /* > * Currently, RTEMS does the adjustment in one movement. > @@ -41,11 +40,11 @@ void _TOD_Adjust( > */ > _Thread_Disable_dispatch(); > > - tod_ptr = _TOD_Get_with_nanoseconds( &tod, &_TOD.now ); > + _TOD_Get( &tod ); > > - _Timestamp_Add_to( tod_ptr, &delta ); > + _Timestamp_Add_to( &tod, &delta ); > > - _TOD_Set_with_timestamp( tod_ptr ); > + _TOD_Set_with_timestamp( &tod ); > > _Thread_Enable_dispatch(); > } > diff --git a/cpukit/score/src/coretodget.c b/cpukit/score/src/coretodget.c > deleted file mode 100644 > index 70eb238..0000000 > --- a/cpukit/score/src/coretodget.c > +++ /dev/null > @@ -1,46 +0,0 @@ > -/** > - * @file > - * > - * @brief Returns a Current TOD with Nanosecond Granularity > - * @ingroup ScoreTOD > - */ > - > -/* > - * COPYRIGHT (c) 1989-2014. > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > - #include "config.h" > -#endif > - > -#include <rtems/score/todimpl.h> > -#include <rtems/score/isrlevel.h> > - > -Timestamp_Control *_TOD_Get_with_nanoseconds( > - Timestamp_Control *snapshot, > - const Timestamp_Control *clock > -) > -{ > - TOD_Control *tod = &_TOD; > - ISR_lock_Context lock_context; > - Timestamp_Control offset; > - Timestamp_Control now; > - uint32_t nanoseconds; > - > - _TOD_Acquire( tod, &lock_context ); > - nanoseconds = ( *tod->nanoseconds_since_last_tick )(); > - now = *clock; > - _TOD_Release( tod, &lock_context ); > - > - _Timestamp_Set( &offset, 0, nanoseconds ); > - _Timestamp_Add_to( &now, &offset ); > - > - *snapshot = now; > - > - return snapshot; > -} > diff --git a/cpukit/score/src/coretodgetuptimetimespec.c > b/cpukit/score/src/coretodgetuptimetimespec.c > deleted file mode 100644 > index 5980b2f..0000000 > --- a/cpukit/score/src/coretodgetuptimetimespec.c > +++ /dev/null > @@ -1,32 +0,0 @@ > -/** > - * @file > - * > - * @brief Get Uptime as struct timespec > - * @ingroup ScoreTOD > - */ > - > -/* > - * COPYRIGHT (c) 1989-2014. > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > -#include "config.h" > -#endif > - > -#include <rtems/score/todimpl.h> > - > -void _TOD_Get_uptime_as_timespec( > - struct timespec *uptime > -) > -{ > - Timestamp_Control uptime_ts; > - > - /* assume time checked for NULL by caller */ > - _TOD_Get_uptime( &uptime_ts ); > - _Timestamp_To_timespec( &uptime_ts, uptime ); > -} > diff --git a/cpukit/score/src/coretodsecondssinceepoch.c > b/cpukit/score/src/coretodsecondssinceepoch.c > deleted file mode 100644 > index b7bd270..0000000 > --- a/cpukit/score/src/coretodsecondssinceepoch.c > +++ /dev/null > @@ -1,32 +0,0 @@ > -/* > - * Copyright (c) 2013 embedded brains GmbH. All rights reserved. > - * > - * embedded brains GmbH > - * Dornierstr. 4 > - * 82178 Puchheim > - * Germany > - * <rt...@embedded-brains.de> > - * > - * The license and distribution terms for this file may be > - * found in the file LICENSE in this distribution or at > - * http://www.rtems.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > - #include "config.h" > -#endif > - > -#include <rtems/score/todimpl.h> > - > -uint32_t _TOD_Seconds_since_epoch( void ) > -{ > - TOD_Control *tod = &_TOD; > - ISR_lock_Context lock_context; > - Timestamp_Control now; > - > - _TOD_Acquire( tod, &lock_context ); > - now = tod->now; > - _TOD_Release( tod, &lock_context ); > - > - return _Timestamp_Get_seconds( &now ); > -} > diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c > index 6006e66..8cff81c 100644 > --- a/cpukit/score/src/coretodset.c > +++ b/cpukit/score/src/coretodset.c > @@ -27,10 +27,14 @@ void _TOD_Set_with_timestamp( > ) > { > TOD_Control *tod = &_TOD; > + struct timespec ts; > uint32_t nanoseconds = _Timestamp_Get_nanoseconds( tod_as_timestamp ); > Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod_as_timestamp > ); > Watchdog_Interval seconds_now; > - ISR_lock_Context lock_context; > + > + bintime2timespec(tod_as_timestamp, &ts); > + nanoseconds = ts.tv_nsec; > + seconds_next = ts.tv_sec; > > _Thread_Disable_dispatch(); > > @@ -41,9 +45,7 @@ void _TOD_Set_with_timestamp( > else > _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now ); > > - _TOD_Acquire( tod, &lock_context ); > - tod->now = *tod_as_timestamp; > - _TOD_Release( tod, &lock_context ); > + _Timecounter_Set_clock(&ts); > > tod->seconds_trigger = nanoseconds; > tod->is_set = true; > diff --git a/cpukit/score/src/coretodtickle.c > b/cpukit/score/src/coretodtickle.c > index 9116fc1..3d7c71e 100644 > --- a/cpukit/score/src/coretodtickle.c > +++ b/cpukit/score/src/coretodtickle.c > @@ -24,30 +24,10 @@ > > void _TOD_Tickle_ticks( void ) > { > - TOD_Control *tod = &_TOD; > - ISR_lock_Context lock_context; > - Timestamp_Control tick; > - uint32_t nanoseconds_per_tick; > - > - nanoseconds_per_tick = rtems_configuration_get_nanoseconds_per_tick(); > - > - /* Convert the tick quantum to a timestamp */ > - _Timestamp_Set( &tick, 0, nanoseconds_per_tick ); > - > /* Update the counter of ticks since boot */ > _Watchdog_Ticks_since_boot += 1; > > - _TOD_Acquire( tod, &lock_context ); > - > - /* Update the uptime */ > - _Timestamp_Add_to( &tod->uptime, &tick ); > - > - /* Update the current TOD */ > - _Timestamp_Add_to( &tod->now, &tick ); > - > - _TOD_Release( tod, &lock_context ); > - > - _TOD.seconds_trigger += nanoseconds_per_tick; > + _TOD.seconds_trigger += rtems_configuration_get_nanoseconds_per_tick(); > if ( _TOD.seconds_trigger >= 1000000000UL ) { > _TOD.seconds_trigger -= 1000000000UL; > _Watchdog_Tickle_seconds(); > diff --git a/cpukit/score/src/tcgetscalerandmask.c > b/cpukit/score/src/tcgetscalerandmask.c > new file mode 100644 > index 0000000..a2a2db4 > --- /dev/null > +++ b/cpukit/score/src/tcgetscalerandmask.c > @@ -0,0 +1,40 @@ > +/* > + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. > + * > + * embedded brains GmbH > + * Dornierstr. 4 > + * 82178 Puchheim > + * Germany > + * <rt...@embedded-brains.de> > + * > + * The license and distribution terms for this file may be > + * found in the file LICENSE in this distribution or at > + * http://www.rtems.org/license/LICENSE. > + */ > + > +#if HAVE_CONFIG_H > + #include "config.h" > +#endif > + > +#include <rtems/score/timecounterimpl.h> > + > +void _Timecounter_Get_binary_scaler_and_mask( > + uint32_t counter_ticks_per_clock_tick, > + uint64_t *scaler, > + uint32_t *mask > +) > +{ > + uint32_t power_of_two = 1; > + int i; > + > + for ( i = 0; i < 32; ++i ) { > + if ( power_of_two >= counter_ticks_per_clock_tick ) { > + break; > + } > + > + power_of_two *= 2; > + } > + > + *mask = (2 * power_of_two) - 1; > + *scaler = ((uint64_t) power_of_two << 32) / counter_ticks_per_clock_tick; > +} > diff --git a/cpukit/score/src/ts64addto.c b/cpukit/score/src/ts64addto.c > deleted file mode 100644 > index a0f4b3c..0000000 > --- a/cpukit/score/src/ts64addto.c > +++ /dev/null > @@ -1,31 +0,0 @@ > -/** > - * @file score/src/ts64addto.c > - * > - * @brief Add to a Timestamp > - * @ingroup SuperCore > - */ > - > -/* > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > -#include "config.h" > -#endif > - > -#include <rtems/score/timestamp.h> > - > -#if CPU_TIMESTAMP_USE_INT64 == TRUE > -void _Timestamp64_Add_to( > - Timestamp64_Control *_time, > - const Timestamp64_Control *_add > -) > -{ > - _Timestamp64_implementation_Add_to( _time, _add ); > -} > -#endif > diff --git a/cpukit/score/src/ts64divide.c b/cpukit/score/src/ts64divide.c > deleted file mode 100644 > index d9a5099..0000000 > --- a/cpukit/score/src/ts64divide.c > +++ /dev/null > @@ -1,51 +0,0 @@ > -/** > - * @file > - * > - * @brief Divide Timestamp > - * @ingroup SuperCore > - */ > - > -/* > - * COPYRIGHT (c) 1989-2007. > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > -#include "config.h" > -#endif > - > -#include <rtems/score/timestamp.h> > - > -/* This method is never inlined. */ > -#if CPU_TIMESTAMP_USE_INT64 == TRUE || CPU_TIMESTAMP_USE_INT64_INLINE == TRUE > -void _Timestamp64_Divide( > - const Timestamp64_Control *_lhs, > - const Timestamp64_Control *_rhs, > - uint32_t *_ival_percentage, > - uint32_t *_fval_percentage > -) > -{ > - Timestamp64_Control answer; > - > - if ( *_rhs == 0 ) { > - *_ival_percentage = 0; > - *_fval_percentage = 0; > - return; > - } > - > - /* > - * This looks odd but gives the results the proper precision. > - * > - * TODO: Rounding on the last digit of the fval. > - */ > - > - answer = (*_lhs * 100000) / *_rhs; > - > - *_ival_percentage = answer / 1000; > - *_fval_percentage = answer % 1000; > -} > -#endif > diff --git a/cpukit/score/src/ts64equalto.c b/cpukit/score/src/ts64equalto.c > deleted file mode 100644 > index fd07474..0000000 > --- a/cpukit/score/src/ts64equalto.c > +++ /dev/null > @@ -1,31 +0,0 @@ > -/** > - * @file > - * > - * @brief Timestamp equal to Operator > - * @ingroup SuperCore > - */ > - > -/* > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > -#include "config.h" > -#endif > - > -#include <rtems/score/timestamp.h> > - > -#if CPU_TIMESTAMP_USE_INT64 == TRUE > -bool _Timestamp64_Equal_to( > - const Timestamp64_Control *_lhs, > - const Timestamp64_Control *_rhs > -) > -{ > - return _Timestamp64_implementation_Equal_to( _lhs, _rhs ); > -} > -#endif > diff --git a/cpukit/score/src/ts64getnanoseconds.c > b/cpukit/score/src/ts64getnanoseconds.c > deleted file mode 100644 > index a5da43b..0000000 > --- a/cpukit/score/src/ts64getnanoseconds.c > +++ /dev/null > @@ -1,30 +0,0 @@ > -/** > - * @file score/src/ts64toticks.c > - * > - * @brief Get Nanoseconds Portion of Timestamp > - * @ingroup SuperCore > - */ > - > -/* > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > -#include "config.h" > -#endif > - > -#include <rtems/score/timestamp.h> > - > -#if CPU_TIMESTAMP_USE_INT64 == TRUE > -uint32_t _Timestamp64_Get_nanoseconds( > - const Timestamp64_Control *_time > -) > -{ > - return _Timestamp64_implementation_Get_nanoseconds( _time ); > -} > -#endif > diff --git a/cpukit/score/src/ts64getseconds.c > b/cpukit/score/src/ts64getseconds.c > deleted file mode 100644 > index eca0536..0000000 > --- a/cpukit/score/src/ts64getseconds.c > +++ /dev/null > @@ -1,30 +0,0 @@ > -/** > - * @file > - * > - * @brief Get Seconds Portion of Timestamp > - * @ingroup SuperCore > - */ > - > -/* > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > -#include "config.h" > -#endif > - > -#include <rtems/score/timestamp.h> > - > -#if CPU_TIMESTAMP_USE_INT64 == TRUE > -uint32_t _Timestamp64_Get_seconds( > - const Timestamp64_Control *_time > -) > -{ > - return _Timestamp64_implementation_Get_seconds( _time ); > -} > -#endif > diff --git a/cpukit/score/src/ts64lessthan.c b/cpukit/score/src/ts64lessthan.c > deleted file mode 100644 > index d147814..0000000 > --- a/cpukit/score/src/ts64lessthan.c > +++ /dev/null > @@ -1,31 +0,0 @@ > -/** > - * @file > - * > - * @brief Timestamp Less Than Operator > - * @ingroup SuperCore Timestamp64 > -*/ > - > -/* > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > -#include "config.h" > -#endif > - > -#include <rtems/score/timestamp.h> > - > -#if CPU_TIMESTAMP_USE_INT64 == TRUE > -bool _Timestamp64_Less_than( > - const Timestamp64_Control *_lhs, > - const Timestamp64_Control *_rhs > -) > -{ > - return _Timestamp64_implementation_Less_than( _lhs, _rhs ); > -} > -#endif > diff --git a/cpukit/score/src/ts64set.c b/cpukit/score/src/ts64set.c > deleted file mode 100644 > index 22771d6..0000000 > --- a/cpukit/score/src/ts64set.c > +++ /dev/null > @@ -1,33 +0,0 @@ > -/** > - * @file > - * > - * @brief Set Timestamp to Specified Seconds and Nanoseconds > - * > - * @ingroup SuperCore > - */ > - > -/* > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > -#include "config.h" > -#endif > - > -#include <rtems/score/timestamp.h> > - > -#if CPU_TIMESTAMP_USE_INT64 == TRUE > -void _Timestamp64_Set( > - Timestamp64_Control *_time, > - Timestamp64_Control _seconds, > - Timestamp64_Control _nanoseconds > -) > -{ > - _Timestamp64_implementation_Set( _time, _seconds, _nanoseconds ); > -} > -#endif > diff --git a/cpukit/score/src/ts64settozero.c > b/cpukit/score/src/ts64settozero.c > deleted file mode 100644 > index 7b319df..0000000 > --- a/cpukit/score/src/ts64settozero.c > +++ /dev/null > @@ -1,31 +0,0 @@ > -/** > - * @file > - * > - * @brief Zero a Timestamp64 Instance > - * > - * @ingroup SuperCore > - */ > - > -/* > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > -#include "config.h" > -#endif > - > -#include <rtems/score/timestamp.h> > - > -#if CPU_TIMESTAMP_USE_INT64 == TRUE > -void _Timestamp64_Set_to_zero( > - Timestamp64_Control *_time > -) > -{ > - _Timestamp64_implementation_Set_to_zero( _time ); > -} > -#endif > diff --git a/cpukit/score/src/ts64subtract.c b/cpukit/score/src/ts64subtract.c > deleted file mode 100644 > index 1ee917b..0000000 > --- a/cpukit/score/src/ts64subtract.c > +++ /dev/null > @@ -1,31 +0,0 @@ > -/** > - * @file > - * > - * @brief Subtract Two Timestamps > - * @ingroup Timestamp > - */ > -/* > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > -#include "config.h" > -#endif > - > -#include <rtems/score/timestamp.h> > - > -#if CPU_TIMESTAMP_USE_INT64 == TRUE > -void _Timestamp64_Subtract( > - const Timestamp64_Control *_start, > - const Timestamp64_Control *_end, > - Timestamp64_Control *_result > -) > -{ > - _Timestamp64_implementation_Subtract( _start, _end, _result ); > -} > -#endif > diff --git a/cpukit/score/src/ts64totimespec.c > b/cpukit/score/src/ts64totimespec.c > deleted file mode 100644 > index 7e81da7..0000000 > --- a/cpukit/score/src/ts64totimespec.c > +++ /dev/null > @@ -1,32 +0,0 @@ > -/** > - * @file > - * > - * @brief Convert Timestamp to Struct Timespec > - * > - * @ingroup SuperCore > - */ > - > -/* > - * 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.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > -#include "config.h" > -#endif > - > -#include <rtems/score/timestamp.h> > - > -#if CPU_TIMESTAMP_USE_INT64 == TRUE > -void _Timestamp64_To_timespec( > - const Timestamp64_Control *_timestamp, > - struct timespec *_timespec > -) > -{ > - _Timestamp64_implementation_To_timespec( _timestamp, _timespec ); > -} > -#endif > diff --git a/cpukit/score/src/ts64totimeval.c > b/cpukit/score/src/ts64totimeval.c > deleted file mode 100644 > index 1ac765b..0000000 > --- a/cpukit/score/src/ts64totimeval.c > +++ /dev/null > @@ -1,37 +0,0 @@ > -/** > - * @file > - * > - * @brief Convert 64-bit Timestamp to struct timeval > - * > - * @ingroup SuperCore > - */ > - > -/* > - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. > - * > - * embedded brains GmbH > - * Obere Lagerstr. 30 > - * 82178 Puchheim > - * Germany > - * <rt...@embedded-brains.de> > - * > - * The license and distribution terms for this file may be > - * found in the file LICENSE in this distribution or at > - * http://www.rtems.org/license/LICENSE. > - */ > - > -#if HAVE_CONFIG_H > - #include "config.h" > -#endif > - > -#include <rtems/score/timestamp.h> > - > -#if CPU_TIMESTAMP_USE_INT64 == TRUE > -void _Timestamp64_To_timeval( > - const Timestamp64_Control *_timestamp, > - struct timeval *_timeval > -) > -{ > - _Timestamp64_implementation_To_timeval( _timestamp, _timeval ); > -} > -#endif > diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am > index 9025ff3..c3fc443 100644 > --- a/testsuites/sptests/Makefile.am > +++ b/testsuites/sptests/Makefile.am > @@ -38,6 +38,8 @@ else > _SUBDIRS += sp29 > endif > _SUBDIRS += spintrcritical23 > +_SUBDIRS += sptimecounter01 > +_SUBDIRS += sptimecounter02 > _SUBDIRS += spatomic01 > _SUBDIRS += spintrcritical22 > _SUBDIRS += spsem03 > diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac > index ae3c763..dbdd30f 100644 > --- a/testsuites/sptests/configure.ac > +++ b/testsuites/sptests/configure.ac > @@ -41,6 +41,8 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes") > # Explicitly list all Makefiles here > AC_CONFIG_FILES([Makefile > spintrcritical23/Makefile > +sptimecounter02/Makefile > +sptimecounter01/Makefile > spatomic01/Makefile > spglobalcon01/Makefile > spintrcritical22/Makefile > diff --git a/testsuites/sptests/spclock_err01/init.c > b/testsuites/sptests/spclock_err01/init.c > index ab5c00a..087c8d4 100644 > --- a/testsuites/sptests/spclock_err01/init.c > +++ b/testsuites/sptests/spclock_err01/init.c > @@ -115,14 +115,6 @@ rtems_task Init( > puts( "TA1 - rtems_clock_get_tod_timeval - RTEMS_NOT_DEFINED" ); > } > > - puts( "TA1 - rtems_clock_set_nanoseconds_extension - > RTEMS_INVALID_ADDRESS" ); > - status = rtems_clock_set_nanoseconds_extension( NULL ); > - fatal_directive_status( > - status, > - RTEMS_INVALID_ADDRESS, > - "rtems_clock_set_nanoseconds_extension NULL param" > - ); > - > /* NULL parameter */ > status = rtems_clock_set( NULL ); > fatal_directive_status( > diff --git a/testsuites/sptests/spsize/size.c > b/testsuites/sptests/spsize/size.c > index f427bd2..3e01466 100644 > --- a/testsuites/sptests/spsize/size.c > +++ b/testsuites/sptests/spsize/size.c > @@ -390,9 +390,6 @@ uninitialized = > > /*timerimpl.h*/ (sizeof _Timer_Information) + > > -/*tod.h*/ (sizeof _TOD.now) + > - (sizeof _TOD.uptime) + > - > /*tqdata.h*/ 0 + > > /*types.h*/ 0 + > diff --git a/testsuites/sptests/sptimecounter02/Makefile.am > b/testsuites/sptests/sptimecounter02/Makefile.am > new file mode 100644 > index 0000000..498c24e > --- /dev/null > +++ b/testsuites/sptests/sptimecounter02/Makefile.am > @@ -0,0 +1,19 @@ > +rtems_tests_PROGRAMS = sptimecounter02 > +sptimecounter02_SOURCES = init.c > + > +dist_rtems_tests_DATA = sptimecounter02.scn sptimecounter02.doc > + > +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg > +include $(top_srcdir)/../automake/compile.am > +include $(top_srcdir)/../automake/leaf.am > + > +AM_CPPFLAGS += -I$(top_srcdir)/../support/include > + > +LINK_OBJS = $(sptimecounter02_OBJECTS) > +LINK_LIBS = $(sptimecounter02_LDLIBS) > + > +sptimecounter02$(EXEEXT): $(sptimecounter02_OBJECTS) > $(sptimecounter02_DEPENDENCIES) > + @rm -f sptimecounter02$(EXEEXT) > + $(make-exe) > + > +include $(top_srcdir)/../automake/local.am > diff --git a/testsuites/sptests/sptimecounter02/init.c > b/testsuites/sptests/sptimecounter02/init.c > new file mode 100644 > index 0000000..781401f > --- /dev/null > +++ b/testsuites/sptests/sptimecounter02/init.c > @@ -0,0 +1,266 @@ > +/* > + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. > + * > + * embedded brains GmbH > + * Dornierstr. 4 > + * 82178 Puchheim > + * Germany > + * <rt...@embedded-brains.de> > + * > + * The license and distribution terms for this file may be > + * found in the file LICENSE in this distribution or at > + * http://www.rtems.org/license/LICENSE. > + */ > + > +#ifdef HAVE_CONFIG_H > + #include "config.h" > +#endif > + > +#define _KERNEL > + > +#include <sys/time.h> > +#include <sys/timetc.h> > + > +#include <stdlib.h> > +#include <stdio.h> > +#include <inttypes.h> > +#include <assert.h> > +#include <unistd.h> > + > +#include <rtems.h> > +#include <rtems/counter.h> > +#include <rtems/test.h> > + > +#include <rtems/score/timecounterimpl.h> > +#include <rtems/timecounter.h> > + > +#include "tmacros.h" > + > +const char rtems_test_name[] = "SPTIMECOUNTER_2"; > + > +#define MASTER_PRIORITY 1 > +#define WORKER_PRIORITY 2 > +#define CPU_COUNT 32 > +#define DURATION_LENGTH 2 > + > +typedef struct { > + rtems_test_parallel_context base; > + struct timecounter tc_soft; > + struct timecounter tc_cpu_counter; > + u_int tc_soft_counter; > + uint32_t binuptime_per_job[CPU_COUNT]; > + uint32_t rtemsuptime_per_job[CPU_COUNT]; > +} timecounter_context; > + > +typedef struct { > + struct bintime start_bin; > + struct bintime end_bin; > + struct bintime diff; > +} test_variables; > + > +static timecounter_context test_instance; > + > +static test_variables test_values; > + > +static rtems_interval test_duration(void) > +{ > + return DURATION_LENGTH * rtems_clock_get_ticks_per_second(); > +} > + > +static u_int test_get_timecount_null(struct timecounter *tc) > +{ > + return 0; > +} > + > +static u_int test_get_timecount_cpu(struct timecounter *tc) > +{ > + return 0xffffffff - rtems_counter_read(); > +} > + > +static void register_hardware_tc_null(timecounter_context *ctx) > +{ > + struct timecounter *tc_cpu = &ctx->tc_cpu_counter; > + > + tc_cpu->tc_get_timecount = test_get_timecount_null; > + tc_cpu->tc_counter_mask = 0xffffffff; > + tc_cpu->tc_frequency = rtems_counter_nanoseconds_to_ticks(1000000000); > + tc_cpu->tc_quality = 2000; > + _Timecounter_Install(tc_cpu); > +} > + > +/* > + * Start of Timers > + */ > + > +static rtems_interval test_bintime_init( > + rtems_test_parallel_context *base, > + void *arg, > + size_t active_workers > +) > +{ > + return test_duration(); > +} > + > +static void test_bintime_body( > + rtems_test_parallel_context *base, > + void *arg, > + size_t active_workers, > + size_t worker_index > +) > +{ > + timecounter_context *ctx = (timecounter_context *) base; > + struct bintime bt; > + uint32_t counter = 0; > + test_variables *values = &test_values; > + > + while (!rtems_test_parallel_stop_job(&ctx->base)) { > + ++counter; > + rtems_binuptime(&bt); > + if (counter == 1){ > + values->start_bin = bt; > + } > + } > + values->end_bin = bt; > + values->diff = bt; > + bintime_sub(&values->diff, &values->start_bin); > + printf("\n%" PRIu32 " %" PRIu64 "\n", values->start_bin.sec, > + values->start_bin.frac); > + printf("%" PRIu32 " %" PRIu64 "\n", values->end_bin.sec, > + values->end_bin.frac); > + assert((values->diff.sec == DURATION_LENGTH) || > + ((values->diff.sec == DURATION_LENGTH - 1) && > + (values->diff.frac > UINT64_C(18000000000000000000))) || > + ((values->diff.sec == DURATION_LENGTH + 1) && > + (values->end_bin.frac < UINT64_C(2000000000000000000))) > + ); > + ctx->binuptime_per_job[worker_index] = counter; > +} > + > +static void test_bintime_fini( > + rtems_test_parallel_context *base, > + void *arg, > + size_t active_workers > +) > +{ > + timecounter_context *ctx = (timecounter_context *) base; > + size_t i; > + > + printf(" <BinuptimeTest activeWorker=\"%zu\">\n", active_workers); > + > + for (i = 0; i < active_workers; ++i) { > + printf( > + " <Counter worker=\"%zu\">%" PRIu32 "</Counter>\n", > + (i+1), ctx->binuptime_per_job[i]); > + } > + printf(" </BinuptimeTest>\n"); > +} > + > +static rtems_interval test_bintime_null_init( > + rtems_test_parallel_context *base, > + void *arg, > + size_t active_workers > +) > +{ > + timecounter_context *ctx = &test_instance; > + > + register_hardware_tc_null(ctx); > + return test_duration(); > +} > + > +static void test_bintime_null_body( > + rtems_test_parallel_context *base, > + void *arg, > + size_t active_workers, > + size_t worker_index > +) > +{ > + timecounter_context *ctx = (timecounter_context *) base; > + struct bintime bt; > + uint32_t counter = 0; > + > + while (!rtems_test_parallel_stop_job(&ctx->base)) { > + ++counter; > + rtems_binuptime(&bt); > + } > + > + ctx->binuptime_per_job[worker_index] = counter; > +} > + > +static void test_bintime_null_fini( > + rtems_test_parallel_context *base, > + void *arg, > + size_t active_workers > +) > +{ > + timecounter_context *ctx = (timecounter_context *) base; > + size_t i; > + > + printf(" <BinuptimenullTest activeWorker=\"%zu\">\n", active_workers); > + > + for (i = 0; i < active_workers; ++i) { > + printf( > + " <Counter worker=\"%zu\">%" PRIu32 "</Counter>\n", > + (i+1), ctx->binuptime_per_job[i]); > + } > + printf(" </BinuptimenullTest>\n"); > +} > + > +static const rtems_test_parallel_job timecounter_jobs[] = { > + { > + .init = test_bintime_init, > + .body = test_bintime_body, > + .fini = test_bintime_fini, > + .cascade = true > + },{ > + .init = test_bintime_null_init, > + .body = test_bintime_null_body, > + .fini = test_bintime_null_fini, > + .cascade = true > + } > +}; > + > +/* > + * Start of Init > + */ > + > +static void Init(rtems_task_argument arg) > +{ > + timecounter_context *ctx = &test_instance; > + > + TEST_BEGIN(); > + > + printf("<TEST>\n"); > + > + rtems_test_parallel( > + &ctx->base, > + NULL, > + &timecounter_jobs[0], > + RTEMS_ARRAY_SIZE(timecounter_jobs) > + ); > + > + printf("</TEST>\n"); > + > + TEST_END(); > + rtems_test_exit(0); > +} > + > +#define CONFIGURE_MICROSECONDS_PER_TICK 1000 > + > +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER > +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER > + > +#define CONFIGURE_MAXIMUM_TASKS (2 + CPU_COUNT - 1) > +#define CONFIGURE_MAXIMUM_TIMERS 2 > +#define CONFIGURE_MAXIMUM_PERIODS 1 > + > +#define CONFIGURE_SMP_APPLICATION > + > +#define CONFIGURE_SMP_MAXIMUM_PROCESSORS CPU_COUNT > + > +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE > + > +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION > + > +#define CONFIGURE_INIT > + > +#include <rtems/confdefs.h> > diff --git a/testsuites/sptests/sptimecounter02/sptimecounter02.doc > b/testsuites/sptests/sptimecounter02/sptimecounter02.doc > new file mode 100644 > index 0000000..56e8bb6 > --- /dev/null > +++ b/testsuites/sptests/sptimecounter02/sptimecounter02.doc > @@ -0,0 +1,11 @@ > +This file describes the directives and concepts tested by this test set. > + > +test set name: sptimecounter02 > + > +directives: > + > + TBD > + > +concepts: > + > + TBD > diff --git a/testsuites/sptests/sptimecounter02/sptimecounter02.scn > b/testsuites/sptests/sptimecounter02/sptimecounter02.scn > new file mode 100644 > index 0000000..e69de29 > -- > 1.8.4.5 > > _______________________________________________ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel