From 37ac61f03aac6abc820b86c77032af2efcbde92f Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 3 Dec 2008 21:01:09 +0000 Subject: 2008-12-03 Joel Sherrill 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. --- cpukit/score/Makefile.am | 3 +- cpukit/score/include/rtems/score/watchdog.h | 19 ++++++++ cpukit/score/src/watchdogadjusttochain.c | 67 +++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 cpukit/score/src/watchdogadjusttochain.c (limited to 'cpukit/score') 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 +#include +#include + +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 ); +} + -- cgit v1.2.3