[rtems commit] timecounter: Use in RTEMS
Sebastian Huber
sebh at rtems.org
Wed May 20 07:12:04 UTC 2015
Module: rtems
Branch: master
Commit: 7cd2484c4cf9fc759b7205ed6d8adcc6d2c28ff6
Changeset: http://git.rtems.org/rtems/commit/?id=7cd2484c4cf9fc759b7205ed6d8adcc6d2c28ff6
Author: Alexander Krutwig <alexander.krutwig at embedded-brains.de>
Date: Tue May 12 14:32:47 2015 +0200
timecounter: Use in RTEMS
Replace timestamp implementation with FreeBSD bintime and timecounters.
New test sptests/sptimecounter02.
Update #2271.
---
cpukit/libnetworking/rtems/rtems_bsdnet_internal.h | 3 +-
cpukit/libnetworking/rtems/rtems_glue.c | 4 -
cpukit/posix/src/clockgettime.c | 8 +-
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 | 2 -
cpukit/rtems/include/rtems/rtems/clock.h | 31 +-
cpukit/rtems/src/clockgetuptime.c | 2 +-
cpukit/rtems/src/clockgetuptimenanoseconds.c | 9 +-
cpukit/rtems/src/clockgetuptimeseconds.c | 43 ---
cpukit/rtems/src/clockgetuptimetimeval.c | 2 +-
cpukit/rtems/src/clocksetnsecshandler.c | 34 --
cpukit/rtems/src/clocktick.c | 17 +-
cpukit/sapi/src/exinit.c | 1 +
cpukit/score/Makefile.am | 16 +-
cpukit/score/include/rtems/score/timespec.h | 6 +-
cpukit/score/include/rtems/score/timestamp.h | 253 ++++++++------
cpukit/score/include/rtems/score/timestamp64.h | 379 ---------------------
cpukit/score/include/rtems/score/tod.h | 9 -
cpukit/score/include/rtems/score/todimpl.h | 135 ++++----
cpukit/score/include/rtems/score/watchdogimpl.h | 7 +
cpukit/score/preinstall.am | 4 -
cpukit/score/src/coretod.c | 20 +-
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 | 19 +-
cpukit/score/src/coretodtickle.c | 22 +-
cpukit/score/src/kern_tc.c | 6 +
cpukit/score/src/timespecgetasnanoseconds.c | 7 +-
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 --
cpukit/score/src/watchdogtick.c | 34 ++
testsuites/sptests/Makefile.am | 1 +
testsuites/sptests/configure.ac | 1 +
testsuites/sptests/spclock_err01/init.c | 8 -
testsuites/sptests/spsize/size.c | 3 -
testsuites/sptests/sptimecounter02/Makefile.am | 20 ++
testsuites/sptests/sptimecounter02/init.c | 268 +++++++++++++++
.../sptests/sptimecounter02/sptimecounter02.doc | 12 +
.../sptests/sptimecounter02/sptimecounter02.scn | 46 +++
53 files changed, 652 insertions(+), 1277 deletions(-)
diff --git a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
index fc0370c..4de1b0b 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/bsd.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_bsd_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 e43dc6e..1355fbb 100644
--- a/cpukit/libnetworking/rtems/rtems_glue.c
+++ b/cpukit/libnetworking/rtems/rtems_glue.c
@@ -1339,7 +1339,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..83a35d7 100644
--- a/cpukit/posix/src/clockgettime.c
+++ b/cpukit/posix/src/clockgettime.c
@@ -37,19 +37,21 @@ 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
if ( clock_id == CLOCK_MONOTONIC ) {
- _TOD_Get_uptime_as_timespec( tp );
+ _TOD_Get_zero_based_uptime_as_timespec( tp );
+ --tp->tv_sec;
return 0;
}
#endif
#ifdef _POSIX_CPUTIME
if ( clock_id == CLOCK_PROCESS_CPUTIME_ID ) {
- _TOD_Get_uptime_as_timespec( tp );
+ _TOD_Get_zero_based_uptime_as_timespec( tp );
+ --tp->tv_sec;
return 0;
}
#endif
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 2967df6..2a8cec7 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 084b39f..f38990d 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -155,10 +155,8 @@ librtems_a_SOURCES += src/clockgettod.c
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
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..989bf2f 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
*/
@@ -35,6 +34,7 @@
#include <rtems/rtems/status.h>
#include <rtems/rtems/types.h>
#include <rtems/config.h>
+#include <rtems/score/timecounterimpl.h>
#include <sys/time.h> /* struct timeval */
@@ -69,12 +69,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 +273,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.
@@ -328,7 +304,10 @@ void rtems_clock_get_uptime_timeval( struct timeval *uptime );
*
* @retval The system uptime in seconds.
*/
-time_t rtems_clock_get_uptime_seconds( void );
+RTEMS_INLINE_ROUTINE time_t rtems_clock_get_uptime_seconds( void )
+{
+ return _Timecounter_Time_uptime - 1;
+}
/**
* @brief Returns the system uptime in nanoseconds.
diff --git a/cpukit/rtems/src/clockgetuptime.c b/cpukit/rtems/src/clockgetuptime.c
index 91ce6c4..acbe39a 100644
--- a/cpukit/rtems/src/clockgetuptime.c
+++ b/cpukit/rtems/src/clockgetuptime.c
@@ -42,6 +42,6 @@ rtems_status_code rtems_clock_get_uptime(
if ( !uptime )
return RTEMS_INVALID_ADDRESS;
- _TOD_Get_uptime_as_timespec( uptime );
+ _TOD_Get_zero_based_uptime_as_timespec( uptime );
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/clockgetuptimenanoseconds.c b/cpukit/rtems/src/clockgetuptimenanoseconds.c
index 0310e59..03ff73b 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_zero_based_uptime(&snapshot_as_timestamp);
- return _Timestamp_Get_As_nanoseconds( &snapshot_as_timestamp, nanoseconds );
+ return _Timestamp_Get_as_nanoseconds(&snapshot_as_timestamp);
}
diff --git a/cpukit/rtems/src/clockgetuptimeseconds.c b/cpukit/rtems/src/clockgetuptimeseconds.c
deleted file mode 100644
index 0312921..0000000
--- a/cpukit/rtems/src/clockgetuptimeseconds.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * @file
- *
- * @brief Returns the system uptime in seconds.
- * @ingroup ClassicClock Clocks
- */
-
-/*
- * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
- *
- * embedded brains GmbH
- * Obere Lagerstr. 30
- * 82178 Puchheim
- * Germany
- * <rtems at 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/rtems/clock.h>
-#include <rtems/score/todimpl.h>
-
-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 );
-
- _Timestamp_To_timespec( &snapshot_as_timestamp, &snapshot_as_timespec );
-
- return snapshot_as_timespec.tv_sec;
-}
diff --git a/cpukit/rtems/src/clockgetuptimetimeval.c b/cpukit/rtems/src/clockgetuptimetimeval.c
index 0cbaa83..2e09ae2 100644
--- a/cpukit/rtems/src/clockgetuptimetimeval.c
+++ b/cpukit/rtems/src/clockgetuptimetimeval.c
@@ -30,6 +30,6 @@ void rtems_clock_get_uptime_timeval( struct timeval *uptime )
{
Timestamp_Control snapshot_as_timestamp;
- _TOD_Get_uptime( &snapshot_as_timestamp );
+ _TOD_Get_zero_based_uptime( &snapshot_as_timestamp );
_Timestamp_To_timeval( &snapshot_as_timestamp, uptime );
}
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/rtems/src/clocktick.c b/cpukit/rtems/src/clocktick.c
index fe49e9a..e2cd35f 100644
--- a/cpukit/rtems/src/clocktick.c
+++ b/cpukit/rtems/src/clocktick.c
@@ -19,21 +19,14 @@
#endif
#include <rtems/rtems/clock.h>
-#include <rtems/score/schedulerimpl.h>
-#include <rtems/score/threadimpl.h>
-#include <rtems/score/todimpl.h>
-#include <rtems/score/watchdogimpl.h>
+#include <rtems/score/timecounter.h>
rtems_status_code rtems_clock_tick( void )
{
- _TOD_Tickle_ticks();
-
- _Watchdog_Tickle_ticks();
-
- _Scheduler_Tick();
-
- if ( _Thread_Dispatch_is_enabled() )
- _Thread_Dispatch();
+ _Timecounter_Tick_simple(
+ rtems_configuration_get_microseconds_per_tick(),
+ 0
+ );
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c
index ba71ec4..3115899 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>
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index a16aeda..11399e9 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -93,7 +93,6 @@ include_rtems_score_HEADERS += include/rtems/score/threadq.h
include_rtems_score_HEADERS += include/rtems/score/threadqimpl.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
@@ -320,23 +319,16 @@ 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
libscore_a_SOURCES += src/watchdog.c src/watchdogadjust.c \
src/watchdoginsert.c src/watchdogremove.c
+libscore_a_SOURCES += src/watchdogtick.c
libscore_a_SOURCES += src/watchdogtickssinceboot.c
## USEREXT_C_FILES
diff --git a/cpukit/score/include/rtems/score/timespec.h b/cpukit/score/include/rtems/score/timespec.h
index 9200880..72a0001 100644
--- a/cpukit/score/include/rtems/score/timespec.h
+++ b/cpukit/score/include/rtems/score/timespec.h
@@ -94,13 +94,11 @@ extern "C" {
* This method returns the timestamp as nanoseconds.
*
* @param[in] time points to the timestamp.
- * @param[in] nanoseconds the nanoseconds since the last tick.
*
* @retval The time in nanoseconds.
*/
-uint64_t _Timespec_Get_As_nanoseconds(
- const struct timespec *time,
- const uint32_t nanoseconds
+uint64_t _Timespec_Get_as_nanoseconds(
+ const struct timespec *time
);
/**
diff --git a/cpukit/score/include/rtems/score/timestamp.h b/cpukit/score/include/rtems/score/timestamp.h
index dbd0425..9d25943 100644
--- a/cpukit/score/include/rtems/score/timestamp.h
+++ b/cpukit/score/include/rtems/score/timestamp.h
@@ -42,37 +42,17 @@
#include <sys/time.h>
-#include <rtems/score/cpu.h>
+#include <rtems/score/basedefs.h>
#include <rtems/score/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 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.
@@ -84,13 +64,19 @@ extern "C" {
* @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 +86,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 +106,20 @@ 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(
+ const Timestamp_Control *_lhs,
+ const Timestamp_Control *_rhs
+)
+{
+ if ( _lhs->sec < _rhs->sec )
+ return true;
+
+ if ( _lhs->sec > _rhs->sec )
+ return false;
+
+ return _lhs->frac < _rhs->frac;
+}
/**
* @brief Greater than operator for timestamps.
@@ -138,8 +132,20 @@ 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(
+ const Timestamp_Control *_lhs,
+ const Timestamp_Control *_rhs
+)
+{
+ if ( _lhs->sec > _rhs->sec )
+ return true;
+
+ if ( _lhs->sec < _rhs->sec )
+ return false;
+
+ return _lhs->frac > _rhs->frac;
+}
/**
* @brief Equal to than operator for timestamps.
@@ -152,13 +158,14 @@ 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(
+ const Timestamp_Control *_lhs,
+ const Timestamp_Control *_rhs
+)
+{
+ return _lhs->sec == _rhs->sec && _lhs->frac == _rhs->frac;
+}
/**
* @brief Adds two timestamps.
@@ -171,13 +178,17 @@ 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 +203,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 +228,26 @@ 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 _ts_left;
+ struct timespec _ts_right;
+
+ bintime2timespec( _lhs, &_ts_left );
+ bintime2timespec( _rhs, &_ts_right );
+
+ _Timespec_Divide(
+ &_ts_left,
+ &_ts_right,
+ _ival_percentage,
+ _fval_percentage
+ );
+}
/**
* @brief Get seconds portion of timestamp.
@@ -230,13 +258,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 +274,16 @@ 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.
@@ -264,13 +294,16 @@ extern "C" {
*
* @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
+)
+{
+ struct timespec _ts;
+
+ bintime2timespec( _time, &_ts );
+
+ return _Timespec_Get_as_nanoseconds( &_ts );
+}
/**
* @brief Convert timestamp to struct timespec.
@@ -280,14 +313,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 +327,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..56c176d 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.
*
@@ -201,6 +169,18 @@ void _TOD_Set_with_timestamp(
const Timestamp_Control *tod_as_timestamp
);
+/**
+ * @brief Sets the time of day from timespec.
+ *
+ * The @a tod_as_timestamp timestamp represents the time since UNIX epoch.
+ * The watchdog seconds chain will be adjusted.
+ *
+ * In the process the input given as timespec will be transformed to FreeBSD
+ * bintime format to guarantee the right format for later setting it with a
+ * timestamp.
+ *
+ * @param[in] tod_as_timespec is the constant of the time of day as a timespec
+ */
static inline void _TOD_Set(
const struct timespec *tod_as_timespec
)
@@ -216,31 +196,27 @@ static inline void _TOD_Set(
}
/**
- * @brief Returns a snapshot of a clock.
- *
- * This function invokes the nanoseconds extension.
+ * @brief Gets the current time in the bintime format.
*
- * @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
+ * @param[out] time is the value gathered by the bintime request
*/
-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 );
+/**
+ * @brief Gets the current time in the timespec format.
+ *
+ * @param[out] time is the value gathered by the nanotime request
+ */
+static inline void _TOD_Get_as_timespec(
+ struct timespec *time
+)
+{
+ _Timecounter_Nanotime(time);
}
/**
@@ -249,26 +225,47 @@ static inline void _TOD_Get(
* This routine returns the system uptime with potential accuracy
* to the nanosecond.
*
+ * The initial uptime value is undefined.
+ *
* @param[in] time is a pointer to the uptime to be returned
*/
static inline void _TOD_Get_uptime(
Timestamp_Control *time
)
{
- _TOD_Get_with_nanoseconds( time, &_TOD.uptime );
+ _Timecounter_Binuptime( time );
}
/**
* @brief Gets the system uptime with potential accuracy to the nanosecond.
- *
- * This routine returns the system uptime with potential accuracy
* to the nanosecond.
*
+ * The initial uptime value is zero.
+ *
+ * @param[in] time is a pointer to the uptime to be returned
+ */
+static inline void _TOD_Get_zero_based_uptime(
+ Timestamp_Control *time
+)
+{
+ _Timecounter_Binuptime( time );
+ --time->sec;
+}
+
+/**
+ * @brief Gets the system uptime with potential accuracy to the nanosecond.
+ *
+ * The initial uptime value is zero.
+ *
* @param[in] time is a pointer to the uptime to be returned
*/
-void _TOD_Get_uptime_as_timespec(
+static inline void _TOD_Get_zero_based_uptime_as_timespec(
struct timespec *time
-);
+)
+{
+ _Timecounter_Nanouptime( time );
+ --time->tv_sec;
+}
/**
* @brief Number of seconds Since RTEMS epoch.
@@ -276,7 +273,10 @@ 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 )
+{
+ return (uint32_t) _Timecounter_Time_second;
+}
/**
* @brief Increments time of day at each clock tick.
@@ -314,12 +314,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 +330,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/include/rtems/score/watchdogimpl.h b/cpukit/score/include/rtems/score/watchdogimpl.h
index 6804bf2..8405232 100644
--- a/cpukit/score/include/rtems/score/watchdogimpl.h
+++ b/cpukit/score/include/rtems/score/watchdogimpl.h
@@ -138,6 +138,13 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Flash(
void _Watchdog_Handler_initialization( void );
/**
+ * @brief Triggers a watchdog tick.
+ *
+ * This routine executes TOD, watchdog and scheduler ticks.
+ */
+void _Watchdog_Tick( void );
+
+/**
* @brief Removes @a the_watchdog from the watchdog chain.
*
* This routine removes @a the_watchdog from the watchdog chain on which
diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am
index 13ea020..062fe1b 100644
--- a/cpukit/score/preinstall.am
+++ b/cpukit/score/preinstall.am
@@ -344,10 +344,6 @@ $(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
diff --git a/cpukit/score/src/coretod.c b/cpukit/score/src/coretod.c
index 2deeeba..975ffef 100644
--- a/cpukit/score/src/coretod.c
+++ b/cpukit/score/src/coretod.c
@@ -20,24 +20,16 @@
#include <rtems/score/todimpl.h>
-static uint32_t _TOD_Nanoseconds_since_tick_default_handler( void )
-{
- return 0;
-}
-
void _TOD_Handler_initialization(void)
{
- TOD_Control *tod = &_TOD;
-
- _ISR_lock_Initialize( &tod->lock, "TOD" );
-
- _Timestamp_Set( &tod->now, TOD_SECONDS_1970_THROUGH_1988, 0 );
+ struct timespec ts;
- _Timestamp_Set_to_zero( &tod->uptime );
+ _Timecounter_Initialize();
- tod->nanoseconds_since_last_tick =
- _TOD_Nanoseconds_since_tick_default_handler;
+ ts.tv_sec = TOD_SECONDS_1970_THROUGH_1988;
+ ts.tv_nsec = 0;
+ _Timecounter_Set_clock( &ts );
/* TOD has not been set */
- tod->is_set = false;
+ _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
- * <rtems at 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 3d11758..3230179 100644
--- a/cpukit/score/src/coretodset.c
+++ b/cpukit/score/src/coretodset.c
@@ -26,20 +26,21 @@ void _TOD_Set_with_timestamp(
const Timestamp_Control *tod_as_timestamp
)
{
- TOD_Control *tod = &_TOD;
- uint32_t nanoseconds = _Timestamp_Get_nanoseconds( tod_as_timestamp );
- Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod_as_timestamp );
+ struct timespec ts;
+ uint32_t nanoseconds;
+ Watchdog_Interval seconds_next;
Watchdog_Interval seconds_now;
- ISR_lock_Context lock_context;
Watchdog_Header *header;
+ _Timestamp_To_timespec( tod_as_timestamp, &ts );
+ nanoseconds = ts.tv_nsec;
+ seconds_next = ts.tv_sec;
+
_Thread_Disable_dispatch();
seconds_now = _TOD_Seconds_since_epoch();
- _TOD_Acquire( tod, &lock_context );
- tod->now = *tod_as_timestamp;
- _TOD_Release( tod, &lock_context );
+ _Timecounter_Set_clock( &ts );
header = &_Watchdog_Seconds_header;
@@ -48,8 +49,8 @@ void _TOD_Set_with_timestamp(
else
_Watchdog_Adjust_forward( header, seconds_next - seconds_now );
- tod->seconds_trigger = nanoseconds;
- tod->is_set = true;
+ _TOD.seconds_trigger = nanoseconds;
+ _TOD.is_set = true;
_Thread_Enable_dispatch();
}
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/kern_tc.c b/cpukit/score/src/kern_tc.c
index bca73ec..5479927 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -33,6 +33,7 @@
#define time_second _Timecounter_Time_second
#define time_uptime _Timecounter_Time_uptime
#include <rtems/score/timecounterimpl.h>
+#include <rtems/score/watchdogimpl.h>
#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD r277406 2015-01-20T03:54:30Z$");
@@ -1886,6 +1887,9 @@ _Timecounter_Tick(void)
{
#endif /* __rtems__ */
tc_windup();
+#ifdef __rtems__
+ _Watchdog_Tick();
+#endif /* __rtems__ */
}
#ifdef __rtems__
void
@@ -1924,6 +1928,8 @@ _Timecounter_Tick_simple(uint32_t delta, uint32_t offset)
time_uptime = th->th_offset.sec;
_ISR_lock_Release_and_ISR_enable(&_Timecounter_Lock, &lock_context);
+
+ _Watchdog_Tick();
}
#endif /* __rtems__ */
diff --git a/cpukit/score/src/timespecgetasnanoseconds.c b/cpukit/score/src/timespecgetasnanoseconds.c
index 4ef1af4..2f8d17f 100644
--- a/cpukit/score/src/timespecgetasnanoseconds.c
+++ b/cpukit/score/src/timespecgetasnanoseconds.c
@@ -20,10 +20,9 @@
#include <rtems/score/timespec.h>
#include <rtems/score/todimpl.h>
-uint64_t _Timespec_Get_As_nanoseconds(
- const struct timespec *time,
- const uint32_t nanoseconds
+uint64_t _Timespec_Get_as_nanoseconds(
+ const struct timespec *time
)
{
- return ( ((uint64_t) time->tv_sec) * 1000000000ULL ) + time->tv_nsec + nanoseconds;
+ return ( ((uint64_t) time->tv_sec) * 1000000000ULL ) + time->tv_nsec;
}
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
- * <rtems at 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/cpukit/score/src/watchdogtick.c b/cpukit/score/src/watchdogtick.c
new file mode 100644
index 0000000..b9bc3f7
--- /dev/null
+++ b/cpukit/score/src/watchdogtick.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems at 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.
+ */
+
+#include <rtems/score/schedulerimpl.h>
+#include <rtems/score/threadimpl.h>
+#include <rtems/score/todimpl.h>
+#include <rtems/score/watchdogimpl.h>
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+void _Watchdog_Tick( void )
+{
+ _TOD_Tickle_ticks();
+
+ _Watchdog_Tickle_ticks();
+
+ _Scheduler_Tick();
+
+ if ( _Thread_Dispatch_is_enabled() )
+ _Thread_Dispatch();
+}
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 8844436..c3fc443 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -39,6 +39,7 @@ _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 d463532..b8287a4 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -42,6 +42,7 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes")
AC_CONFIG_FILES([Makefile
spintrcritical23/Makefile
sptimecounter01/Makefile
+sptimecounter02/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 58bcc89..657fa42 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..badb647
--- /dev/null
+++ b/testsuites/sptests/sptimecounter02/Makefile.am
@@ -0,0 +1,20 @@
+rtems_tests_PROGRAMS = sptimecounter02
+sptimecounter02_SOURCES = init.c
+sptimecounter02_SOURCES += ../../support/src/spin.c
+
+dist_rtems_tests_DATA = sptimecounter02.scn sptimecounter02.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .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..c7d72a8
--- /dev/null
+++ b/testsuites/sptests/sptimecounter02/init.c
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems at 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 <unistd.h>
+
+#include <rtems.h>
+#include <rtems/counter.h>
+#include <rtems/test.h>
+
+#include <rtems/score/timecounterimpl.h>
+#include <rtems/timecounter.h>
+#include <rtems/bsd.h>
+
+#include <test_support.h>
+
+#include "tmacros.h"
+
+const char rtems_test_name[] = "SPTIMECOUNTER 2";
+
+#define CPU_COUNT 32
+
+#define DURATION_IN_SECONDS 1
+
+typedef struct {
+ rtems_test_parallel_context base;
+ struct timecounter tc_null;
+ uint32_t binuptime_per_job[CPU_COUNT];
+ sbintime_t duration_per_job[CPU_COUNT];
+ uint32_t rtemsuptime_per_job[CPU_COUNT];
+} timecounter_context;
+
+static timecounter_context test_instance;
+
+static rtems_interval test_duration(void)
+{
+ return DURATION_IN_SECONDS * rtems_clock_get_ticks_per_second();
+}
+
+static uint32_t test_get_timecount_null(struct timecounter *tc)
+{
+ return 0;
+}
+
+static void install_tc_null(timecounter_context *ctx)
+{
+ struct timecounter *tc_cpu = &ctx->tc_null;
+
+ 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;
+ rtems_timecounter_install(tc_cpu);
+}
+
+static rtems_interval test_bintime_init(
+ rtems_test_parallel_context *base,
+ void *arg,
+ size_t active_workers
+)
+{
+ rtems_test_spin_until_next_tick();
+
+ 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;
+ uint32_t counter = 1;
+ struct bintime start;
+ struct bintime end;
+
+ rtems_bsd_binuptime(&start);
+
+ do {
+ ++counter;
+ rtems_bsd_binuptime(&end);
+ } while (!rtems_test_parallel_stop_job(&ctx->base));
+
+ ctx->binuptime_per_job[worker_index] = counter;
+ ctx->duration_per_job[worker_index] = bttosbt(end) - bttosbt(start);
+}
+
+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) {
+ sbintime_t error;
+
+ printf(
+ " <Counter worker=\"%zu\">%" PRIu32 "</Counter>\n"
+ " <Duration worker=\"%zu\" unit=\"sbintime\">%" PRId64 "</Duration>\n",
+ i + 1,
+ ctx->binuptime_per_job[i],
+ i + 1,
+ ctx->duration_per_job[i]
+ );
+
+ error = DURATION_IN_SECONDS * SBT_1S - ctx->duration_per_job[i];
+ rtems_test_assert(error * error < SBT_1MS * SBT_1MS);
+ }
+
+ 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;
+
+ install_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_bsd_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
+ }
+};
+
+static void Init(rtems_task_argument arg)
+{
+ timecounter_context *ctx = &test_instance;
+ struct bintime bt;
+ struct timespec ts;
+ struct timeval tv;
+
+ TEST_BEGIN();
+
+ printf("<SPTimecounter01>\n");
+
+ rtems_test_parallel(
+ &ctx->base,
+ NULL,
+ &timecounter_jobs[0],
+ RTEMS_ARRAY_SIZE(timecounter_jobs)
+ );
+
+ /* Check for all functions available in the bsd.h user space */
+
+ rtems_bsd_bintime(&bt);
+ rtems_bsd_microtime(&tv);
+ rtems_bsd_nanotime(&ts);
+ rtems_bsd_binuptime(&bt);
+ rtems_bsd_microuptime(&tv);
+ rtems_bsd_nanouptime(&ts);
+ rtems_bsd_getbintime(&bt);
+ rtems_bsd_getmicrotime(&tv);
+ rtems_bsd_getnanotime(&ts);
+ rtems_bsd_getbinuptime(&bt);
+ rtems_bsd_getmicrouptime(&tv);
+ rtems_bsd_getnanouptime(&ts);
+
+ printf("</SPTimecounter01>\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..9988ad0
--- /dev/null
+++ b/testsuites/sptests/sptimecounter02/sptimecounter02.doc
@@ -0,0 +1,12 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: sptimecounter02
+
+directives:
+
+ rtems_timecounter_install, rtems_bsd_binuptime.
+
+concepts:
+
+ measurement of performance tests: how often per timeframe can FreeBSD time
+ routines be called in comparison to original rtems timing routines.
diff --git a/testsuites/sptests/sptimecounter02/sptimecounter02.scn b/testsuites/sptests/sptimecounter02/sptimecounter02.scn
new file mode 100644
index 0000000..004c50e
--- /dev/null
+++ b/testsuites/sptests/sptimecounter02/sptimecounter02.scn
@@ -0,0 +1,46 @@
+*** BEGIN OF TEST SPTIMECOUNTER_2 ***
+<SPTimecounter01>
+ <BinuptimeTest activeWorker="1">
+ <Counter worker="1">591457</Counter>
+ <Duration worker="1" unit="sbintime">4294787862</Duration>
+ <BinuptimeTest activeWorker="2">
+ <Counter worker="1">587737</Counter>
+ <Duration worker="1" unit="sbintime">4294603178</Duration>
+ <Counter worker="2">587754</Counter>
+ <Duration worker="2" unit="sbintime">4294596307</Duration>
+ <BinuptimeTest activeWorker="3">
+ <Counter worker="1">583602</Counter>
+ <Duration worker="1" unit="sbintime">4293605982</Duration>
+ <Counter worker="2">583643</Counter>
+ <Duration worker="2" unit="sbintime">4293602260</Duration>
+ <Counter worker="3">583659</Counter>
+ <Duration worker="3" unit="sbintime">4293604551</Duration>
+ <BinuptimeTest activeWorker="4">
+ <Counter worker="1">583086</Counter>
+ <Duration worker="1" unit="sbintime">4291246232</Duration>
+ <Counter worker="2">583124</Counter>
+ <Duration worker="2" unit="sbintime">4291243178</Duration>
+ <Counter worker="3">583139</Counter>
+ <Duration worker="3" unit="sbintime">4291242796</Duration>
+ <Counter worker="4">565417</Counter>
+ <Duration worker="4" unit="sbintime">4291304930</Duration>
+ <BinuptimeNullTest activeWorker="1">
+ <Counter worker="1">615571</Counter>
+ </BinuptimeNullTest>
+ <BinuptimeNullTest activeWorker="2">
+ <Counter worker="1">615857</Counter>
+ <Counter worker="2">615856</Counter>
+ </BinuptimeNullTest>
+ <BinuptimeNullTest activeWorker="3">
+ <Counter worker="1">615316</Counter>
+ <Counter worker="2">615328</Counter>
+ <Counter worker="3">615337</Counter>
+ </BinuptimeNullTest>
+ <BinuptimeNullTest activeWorker="4">
+ <Counter worker="1">615495</Counter>
+ <Counter worker="2">615502</Counter>
+ <Counter worker="3">615509</Counter>
+ <Counter worker="4">597117</Counter>
+ </BinuptimeNullTest>
+</SPTimecounter01>
+*** END OF TEST SPTIMECOUNTER_2 ***
More information about the vc
mailing list