summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorAlexander Krutwig <alexander.krutwig@embedded-brains.de>2015-05-12 14:32:47 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-05-20 08:40:33 +0200
commit7cd2484c4cf9fc759b7205ed6d8adcc6d2c28ff6 (patch)
treedd60b6032354124d97233e7070506f09d1566832 /cpukit/rtems
parenttimecounter: Port to RTEMS (diff)
downloadrtems-7cd2484c4cf9fc759b7205ed6d8adcc6d2c28ff6.tar.bz2
timecounter: Use in RTEMS
Replace timestamp implementation with FreeBSD bintime and timecounters. New test sptests/sptimecounter02. Update #2271.
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/Makefile.am2
-rw-r--r--cpukit/rtems/include/rtems/rtems/clock.h31
-rw-r--r--cpukit/rtems/src/clockgetuptime.c2
-rw-r--r--cpukit/rtems/src/clockgetuptimenanoseconds.c9
-rw-r--r--cpukit/rtems/src/clockgetuptimeseconds.c43
-rw-r--r--cpukit/rtems/src/clockgetuptimetimeval.c2
-rw-r--r--cpukit/rtems/src/clocksetnsecshandler.c34
-rw-r--r--cpukit/rtems/src/clocktick.c17
8 files changed, 14 insertions, 126 deletions
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index 084b39f8b3..f38990d2a7 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 2a1c77251f..989bf2f5c9 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 91ce6c46ee..acbe39a00e 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 0310e592e9..03ff73bba3 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 0312921113..0000000000
--- 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@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 0cbaa836bc..2e09ae2cd2 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 ae08246902..0000000000
--- 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 fe49e9a059..e2cd35f5fc 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;
}