summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-31 14:10:20 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-08-01 16:45:46 +0200
commit965a442a4ed63845455956433f7581934663081c (patch)
treefbc25d4d54b675b14585e82f34130b7692626cb2 /cpukit/score
parentscore: Add and use _TOD_Is_set() (diff)
downloadrtems-965a442a4ed63845455956433f7581934663081c.tar.bz2
score: Move nanoseconds since last tick support
Move the nanoseconds since last tick support from the Watchdog to the TOD handler. Now the TOD managment is encapsulated in the TOD_Control structure.
Diffstat (limited to '')
-rw-r--r--cpukit/score/Makefile.am4
-rw-r--r--cpukit/score/include/rtems/score/tod.h41
-rw-r--r--cpukit/score/include/rtems/score/todimpl.h16
-rw-r--r--cpukit/score/include/rtems/score/watchdog.h9
-rw-r--r--cpukit/score/include/rtems/score/watchdogimpl.h16
-rw-r--r--cpukit/score/preinstall.am4
-rw-r--r--cpukit/score/src/coretod.c18
-rw-r--r--cpukit/score/src/coretodget.c4
-rw-r--r--cpukit/score/src/watchdognanoseconds.c36
9 files changed, 77 insertions, 71 deletions
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 015b23020e..e300c3e8ef 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -70,6 +70,7 @@ 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/tod.h
include_rtems_score_HEADERS += include/rtems/score/todimpl.h
include_rtems_score_HEADERS += include/rtems/score/userext.h
include_rtems_score_HEADERS += include/rtems/score/userextimpl.h
@@ -305,8 +306,7 @@ libscore_a_SOURCES += src/coretod.c src/coretodset.c src/coretodget.c \
## WATCHDOG_C_FILES
libscore_a_SOURCES += src/watchdog.c src/watchdogadjust.c \
src/watchdogadjusttochain.c src/watchdoginsert.c src/watchdogremove.c \
- src/watchdogtickle.c src/watchdogreport.c src/watchdogreportchain.c \
- src/watchdognanoseconds.c
+ src/watchdogtickle.c src/watchdogreport.c src/watchdogreportchain.c
## USEREXT_C_FILES
libscore_a_SOURCES += src/userextaddset.c \
diff --git a/cpukit/score/include/rtems/score/tod.h b/cpukit/score/include/rtems/score/tod.h
new file mode 100644
index 0000000000..57609b994f
--- /dev/null
+++ b/cpukit/score/include/rtems/score/tod.h
@@ -0,0 +1,41 @@
+/**
+ * @file
+ *
+ * @ingroup ScoreTOD
+ *
+ * @brief Time of Day Handler API
+ */
+
+/*
+ * 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.com/license/LICENSE.
+ */
+
+#ifndef _RTEMS_SCORE_TOD_H
+#define _RTEMS_SCORE_TOD_H
+
+#include <rtems/score/basedefs.h>
+
+#ifdef __cplusplus
+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
+
+#endif
+/* end of include file */
diff --git a/cpukit/score/include/rtems/score/todimpl.h b/cpukit/score/include/rtems/score/todimpl.h
index 0e2da2fcae..a7c3e5d737 100644
--- a/cpukit/score/include/rtems/score/todimpl.h
+++ b/cpukit/score/include/rtems/score/todimpl.h
@@ -18,7 +18,7 @@
#ifndef _RTEMS_SCORE_TODIMPL_H
#define _RTEMS_SCORE_TODIMPL_H
-#include <rtems/score/basedefs.h>
+#include <rtems/score/tod.h>
#include <rtems/score/timestamp.h>
#include <sys/time.h>
@@ -149,6 +149,13 @@ 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
@@ -300,6 +307,13 @@ RTEMS_INLINE_ROUTINE void _TOD_Get_timeval(
_Timestamp_To_timeval( snapshot_as_timestamp_ptr, time );
}
+RTEMS_INLINE_ROUTINE void _TOD_Set_nanoseconds_since_last_tick_handler(
+ TOD_Nanoseconds_since_last_tick_routine routine
+)
+{
+ _TOD.nanoseconds_since_last_tick = routine;
+}
+
RTEMS_INLINE_ROUTINE bool _TOD_Is_set( void )
{
return _TOD.is_set;
diff --git a/cpukit/score/include/rtems/score/watchdog.h b/cpukit/score/include/rtems/score/watchdog.h
index b67e5ca28c..bd218fd7fd 100644
--- a/cpukit/score/include/rtems/score/watchdog.h
+++ b/cpukit/score/include/rtems/score/watchdog.h
@@ -64,15 +64,6 @@ typedef Watchdog_Service_routine ( *Watchdog_Service_routine_entry )(
);
/**
- * @brief Pointer to the BSP plugin to obtain the number
- * of nanoseconds since the last clock tick.
- *
- * This type defines a pointer to the BSP plugin to obtain the number
- * of nanoseconds since the last clock tick.
- */
-typedef uint32_t (*Watchdog_Nanoseconds_since_last_tick_routine)(void);
-
-/**
* @brief The constant for indefinite wait.
*
* This is the constant for indefinite wait. It is actually an
diff --git a/cpukit/score/include/rtems/score/watchdogimpl.h b/cpukit/score/include/rtems/score/watchdogimpl.h
index 3085a440f6..faf68fa81c 100644
--- a/cpukit/score/include/rtems/score/watchdogimpl.h
+++ b/cpukit/score/include/rtems/score/watchdogimpl.h
@@ -93,15 +93,6 @@ SCORE_EXTERN volatile uint32_t _Watchdog_Sync_count;
SCORE_EXTERN volatile Watchdog_Interval _Watchdog_Ticks_since_boot;
/**
- * @brief The number of nanoseconds since the last clock tick.
- *
- * This is a pointer to the optional BSP plugin to obtain the number
- * of nanoseconds since the last clock tick.
- */
-extern Watchdog_Nanoseconds_since_last_tick_routine
- _Watchdog_Nanoseconds_since_tick_handler;
-
-/**
* @brief Watchdog chain which is managed at ticks.
*
* This is the watchdog chain which is managed at ticks.
@@ -245,13 +236,6 @@ void _Watchdog_Report_chain(
);
/**
- * @brief Handler for default nanoseconds since last tick.
- *
- * @retval 0 Always.
- */
-uint32_t _Watchdog_Nanoseconds_since_tick_default_handler( void );
-
-/**
* This routine initializes the specified watchdog. The watchdog is
* made inactive, the watchdog id and handler routine are set to the
* specified values.
diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am
index 6d0cb81348..80fad5b97e 100644
--- a/cpukit/score/preinstall.am
+++ b/cpukit/score/preinstall.am
@@ -263,6 +263,10 @@ $(PROJECT_INCLUDE)/rtems/score/timestamp64.h: include/rtems/score/timestamp64.h
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timestamp64.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timestamp64.h
+$(PROJECT_INCLUDE)/rtems/score/tod.h: include/rtems/score/tod.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/tod.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/tod.h
+
$(PROJECT_INCLUDE)/rtems/score/todimpl.h: include/rtems/score/todimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/todimpl.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/todimpl.h
diff --git a/cpukit/score/src/coretod.c b/cpukit/score/src/coretod.c
index bcdfa39009..3359d4e8ca 100644
--- a/cpukit/score/src/coretod.c
+++ b/cpukit/score/src/coretod.c
@@ -20,14 +20,22 @@
#include <rtems/score/todimpl.h>
+static uint32_t _TOD_Nanoseconds_since_tick_default_handler( void )
+{
+ return 0;
+}
+
void _TOD_Handler_initialization(void)
{
- /* POSIX format TOD (timespec) */
- _Timestamp_Set( &_TOD.now, TOD_SECONDS_1970_THROUGH_1988, 0 );
+ TOD_Control *tod = &_TOD;
+
+ _Timestamp_Set( &tod->now, TOD_SECONDS_1970_THROUGH_1988, 0 );
+
+ _Timestamp_Set_to_zero( &tod->uptime );
- /* Uptime (timespec) */
- _Timestamp_Set_to_zero( &_TOD.uptime );
+ tod->nanoseconds_since_last_tick =
+ _TOD_Nanoseconds_since_tick_default_handler;
/* TOD has not been set */
- _TOD.is_set = false;
+ tod->is_set = false;
}
diff --git a/cpukit/score/src/coretodget.c b/cpukit/score/src/coretodget.c
index b45930a2a4..50262fd2f5 100644
--- a/cpukit/score/src/coretodget.c
+++ b/cpukit/score/src/coretodget.c
@@ -20,20 +20,20 @@
#include <rtems/score/todimpl.h>
#include <rtems/score/isrlevel.h>
-#include <rtems/score/watchdogimpl.h>
Timestamp_Control *_TOD_Get_with_nanoseconds(
Timestamp_Control *snapshot,
const Timestamp_Control *clock
)
{
+ TOD_Control *tod = &_TOD;
ISR_Level level;
Timestamp_Control offset;
Timestamp_Control now;
uint32_t nanoseconds;
_ISR_Disable( level );
- nanoseconds = (*_Watchdog_Nanoseconds_since_tick_handler)();
+ nanoseconds = ( *tod->nanoseconds_since_last_tick )();
now = *clock;
_ISR_Enable( level );
diff --git a/cpukit/score/src/watchdognanoseconds.c b/cpukit/score/src/watchdognanoseconds.c
deleted file mode 100644
index 9c25239dff..0000000000
--- a/cpukit/score/src/watchdognanoseconds.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * @file
- *
- * @brief Default Nanoseconds Since Last Tick Handler
- * @ingroup ScoreWatchdog
- */
-
-/*
- * Copyright (c) 2010 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.com/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems/system.h>
-#include <rtems/score/watchdogimpl.h>
-
-Watchdog_Nanoseconds_since_last_tick_routine
- _Watchdog_Nanoseconds_since_tick_handler =
- _Watchdog_Nanoseconds_since_tick_default_handler;
-
-uint32_t _Watchdog_Nanoseconds_since_tick_default_handler( void )
-{
- return 0;
-}