summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-03 21:01:09 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-03 21:01:09 +0000
commit37ac61f03aac6abc820b86c77032af2efcbde92f (patch)
tree373f701def93a07483b39baeedb74034deb90714 /cpukit/score
parent2008-12-03 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-37ac61f03aac6abc820b86c77032af2efcbde92f.tar.bz2
2008-12-03 Joel Sherrill <joel.sherrill@OARcorp.com>
PR 1347/cpukit * rtems/include/rtems/rtems/timer.h, rtems/src/rtemstimer.c, rtems/src/timerreset.c, rtems/src/timerserver.c, rtems/src/timerserverfireafter.c, rtems/src/timerserverfirewhen.c, score/Makefile.am, score/include/rtems/score/watchdog.h: Rework Timer Server to ensure that the context allows for blocking, allocating memory, and acquiring semaphores and mutexes. * score/src/watchdogadjusttochain.c: New file.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/Makefile.am3
-rw-r--r--cpukit/score/include/rtems/score/watchdog.h19
-rw-r--r--cpukit/score/src/watchdogadjusttochain.c67
3 files changed, 88 insertions, 1 deletions
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index a3a4d603a5..ece25a8f85 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -173,7 +173,8 @@ 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/watchdoginsert.c src/watchdogremove.c src/watchdogtickle.c
+ src/watchdogadjusttochain.c src/watchdoginsert.c src/watchdogremove.c \
+ src/watchdogtickle.c
## USEREXT_C_FILES
libscore_a_SOURCES += src/userextaddapiset.c src/userextaddset.c \
diff --git a/cpukit/score/include/rtems/score/watchdog.h b/cpukit/score/include/rtems/score/watchdog.h
index a1259ab4c4..9291e1ffea 100644
--- a/cpukit/score/include/rtems/score/watchdog.h
+++ b/cpukit/score/include/rtems/score/watchdog.h
@@ -220,6 +220,25 @@ void _Watchdog_Adjust (
Watchdog_Interval units
);
+/** @brief Watchdog Adjust to Chain
+ *
+ * This routine adjusts the @a header watchdog chain in the forward
+ * @a direction for @a units_arg ticks.
+ *
+ * @param[in] header is the watchdog chain to adjust
+ * @param[in] units is the number of units to adjust @a header
+ * @param[in] to_fire is a pointer to an initialized Chain_Control to which
+ * all watchdog instances that are to be fired will be placed.
+ *
+ * @note This always adjusts forward.
+ */
+void _Watchdog_Adjust_to_chain(
+ Chain_Control *header,
+ Watchdog_Interval units_arg,
+ Chain_Control *to_fire
+
+);
+
/** @brief Watchdog Insert
*
* This routine inserts @a the_watchdog into the @a header watchdog chain
diff --git a/cpukit/score/src/watchdogadjusttochain.c b/cpukit/score/src/watchdogadjusttochain.c
new file mode 100644
index 0000000000..5a03208ee0
--- /dev/null
+++ b/cpukit/score/src/watchdogadjusttochain.c
@@ -0,0 +1,67 @@
+/**
+ * @file watchdogadjusttochain.c
+ *
+ * This is used by the Timer Server task.
+ */
+
+/* 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.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/watchdog.h>
+
+void _Watchdog_Adjust_to_chain(
+ Chain_Control *header,
+ Watchdog_Interval units_arg,
+ Chain_Control *to_fire
+
+)
+{
+ Watchdog_Interval units = units_arg;
+ ISR_Level level;
+ Chain_Node *node;
+
+ if ( !units ) {
+ return;
+ }
+ _ISR_Disable( level );
+
+ if ( !_Chain_Is_empty( header ) ) {
+ while ( units ) {
+ if ( units < _Watchdog_First( header )->delta_interval ) {
+ _Watchdog_First( header )->delta_interval -= units;
+ break;
+ } else {
+ units -= _Watchdog_First( header )->delta_interval;
+ _Watchdog_First( header )->delta_interval = 0;
+
+ do {
+ node = _Chain_Get_unprotected( header );
+ _Chain_Append_unprotected( to_fire, node );
+
+ _ISR_Flash( level );
+
+ } while ( !_Chain_Is_empty( header ) &&
+ _Watchdog_First( header )->delta_interval == 0 );
+
+ if ( _Chain_Is_empty( header ) )
+ break;
+ }
+ }
+
+ }
+ _ISR_Enable( level );
+}
+